diff --git a/.c8rc.json b/.c8rc.json new file mode 100644 index 00000000000..340d0f559aa --- /dev/null +++ b/.c8rc.json @@ -0,0 +1,9 @@ +{ + "all": true, + "clean": true, + "root": ".", + "include": ["packages/*/src/**/*.ts"], + "exclude": ["packages/*/src/**/types.ts"], + "reporter": ["text", "html", "lcov"], + "exclude-after-remap": true +} diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 00000000000..e5b6d8d6a67 --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/changelog-generator.mjs b/.changeset/changelog-generator.mjs new file mode 100644 index 00000000000..e4e57835a79 --- /dev/null +++ b/.changeset/changelog-generator.mjs @@ -0,0 +1,125 @@ +import { getInfo, getInfoFromPullRequest } from "@changesets/get-github-info"; + +/** @typedef {import("@changesets/types").ChangelogFunctions} ChangelogFunctions */ + +/** + * @returns {{ GITHUB_SERVER_URL: string }} value + */ +function readEnv() { + const GITHUB_SERVER_URL = process.env.GITHUB_SERVER_URL || "https://github.com"; + return { GITHUB_SERVER_URL }; +} + +/** @type {ChangelogFunctions} */ +const changelogFunctions = { + getDependencyReleaseLine: async (changesets, dependenciesUpdated, options) => { + if (!options.repo) { + throw new Error( + 'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]', + ); + } + if (dependenciesUpdated.length === 0) return ""; + + const changesetLink = `- Updated dependencies [${( + await Promise.all( + changesets.map(async (cs) => { + if (cs.commit) { + const { links } = await getInfo({ + repo: options.repo, + commit: cs.commit, + }); + return links.commit; + } + }), + ) + ) + .filter(Boolean) + .join(", ")}]:`; + + const updatedDependenciesList = dependenciesUpdated.map( + (dependency) => ` - ${dependency.name}@${dependency.newVersion}`, + ); + + return [changesetLink, ...updatedDependenciesList].join("\n"); + }, + getReleaseLine: async (changeset, type, options) => { + const { GITHUB_SERVER_URL } = readEnv(); + if (!options || !options.repo) { + throw new Error( + 'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]', + ); + } + + /** @type {number | undefined} */ + let prFromSummary; + /** @type {string | undefined} */ + let commitFromSummary; + /** @type {string[]} */ + const usersFromSummary = []; + + const replacedChangelog = changeset.summary + .replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => { + const num = Number(pr); + if (!Number.isNaN(num)) prFromSummary = num; + return ""; + }) + .replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => { + commitFromSummary = commit; + return ""; + }) + .replaceAll(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => { + usersFromSummary.push(user); + return ""; + }) + .trim(); + + const [firstLine, ...futureLines] = replacedChangelog.split("\n").map((l) => l.trimEnd()); + + const links = await (async () => { + if (prFromSummary !== undefined) { + let { links } = await getInfoFromPullRequest({ + repo: options.repo, + pull: prFromSummary, + }); + if (commitFromSummary) { + const shortCommitId = commitFromSummary.slice(0, 7); + links = { + ...links, + commit: `[\`${shortCommitId}\`](${GITHUB_SERVER_URL}/${options.repo}/commit/${commitFromSummary})`, + }; + } + return links; + } + const commitToFetchFrom = commitFromSummary || changeset.commit; + if (commitToFetchFrom) { + const { links } = await getInfo({ + repo: options.repo, + commit: commitToFetchFrom, + }); + return links; + } + return { + commit: null, + pull: null, + user: null, + }; + })(); + + const users = usersFromSummary.length + ? usersFromSummary + .map( + (userFromSummary) => `[@${userFromSummary}](${GITHUB_SERVER_URL}/${userFromSummary})`, + ) + .join(", ") + : links.user; + + let suffix = ""; + if (links.pull || links.commit || users) { + suffix = `(${users ? `by ${users} ` : ""}in ${links.pull || links.commit})`; + } + + return `\n\n- ${firstLine} ${suffix}\n${futureLines.map((l) => ` ${l}`).join("\n")}`; + }, +}; + +export default changelogFunctions; diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 00000000000..b9eb7d7c516 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json", + "changelog": ["./changelog-generator.mjs", { "repo": "webpack/webpack-cli" }], + "fixed": [], + "linked": [], + "access": "public", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.cspell.json b/.cspell.json index 02d12f393c6..f6e53dc0040 100644 --- a/.cspell.json +++ b/.cspell.json @@ -103,18 +103,21 @@ "Zangetsu", "Zenitsu", "quickstart", - "pinia" + "pinia", + "watchpack" ], "dictionaries": ["npm", "software-terms"], "ignorePaths": [ + "OPTIONS.md", + "SERVE-OPTIONS-v*.md", "**/CHANGELOG.md", "**/package.json", "**/dist/**", "**/__snapshots__/**", "**/*.tsbuildinfo", - "**/yarn.lock", "**/*.png.tpl", "**/package-lock.json", + "packages/*/lib/**", "node_modules", "coverage", "*.log" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f8ab0aa2e13..23911c020ee 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,6 +5,6 @@ "settings": { "terminal.integrated.shell.linux": "/bin/bash" }, - "postCreateCommand": "yarn install && yarn build", + "postCreateCommand": "npm install && npm run build", "extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"] } diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 844c3971e3f..00000000000 --- a/.eslintignore +++ /dev/null @@ -1,14 +0,0 @@ -coverage -.nyc_output -node_modules -dist -packages/*/lib -test/**/dist/ -test/**/bin/ -test/**/binary/ -test/**/index.js -test/build/config/error-commonjs/syntax-error.js -test/build/config/error-mjs/syntax-error.mjs -test/build/config/error-array/webpack.config.js -test/build/config-format/esm-require-await/webpack.config.js -test/configtest/with-config-path/syntax-error.config.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 3a7b389a670..00000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,62 +0,0 @@ -module.exports = { - root: true, - reportUnusedDisableDirectives: true, - extends: ["eslint:recommended", "plugin:n/recommended", "prettier"], - parserOptions: { ecmaVersion: 2018, sourceType: "script" }, - plugins: ["n"], - env: { - node: true, - es6: true, - jest: true, - }, - rules: { - "no-process-exit": "off", - "n/no-process-exit": "off", - "no-template-curly-in-string": "error", - "no-caller": "error", - "no-extra-bind": "error", - "no-loop-func": "error", - "no-undef": "error", - "prefer-const": "error", - }, - overrides: [ - { - settings: { - n: { - tryExtensions: [".ts", ".tsx", ".js", ".jsx", ".json"], - }, - }, - files: ["**/*.ts"], - extends: [ - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "prettier", - ], - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint"], - rules: { - "@typescript-eslint/no-unused-vars": [ - "error", - { - args: "all", - argsIgnorePattern: "^_", - caughtErrors: "all", - caughtErrorsIgnorePattern: "^_", - destructuredArrayIgnorePattern: "^_", - varsIgnorePattern: "^_", - ignoreRestSiblings: true, - }, - ], - "n/no-unsupported-features/es-syntax": "off", - "n/no-process-exit": "off", - "@typescript-eslint/no-require-imports": "off", - }, - }, - { - files: ["**/packages/create-webpack-app/**/*.js"], - parserOptions: { - sourceType: "module", - }, - }, - ], -}; diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 6a74a6b9254..ac6be564932 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -11,7 +11,6 @@ Table of Contents - [Your first Contribution](#your-first-contribution) - [Setup](#setup) - [Running Tests](#running-tests) - - [Using yarn](#using-yarn) - [Editor Config](#editor-config) - [Dependencies](#dependencies) - [Branching Model](#branching-model) @@ -21,11 +20,8 @@ Table of Contents - [Testing](#testing) - [Pull Requests](#pull-requests) - [Submitting a good Pull Request](#submitting-a-good-pull-request) -- [Commit message](#commit-message) - - [Commit Message Format](#commit-message-format) - [Contributor License Agreement](#contributor-license-agreement) - [Documentation](#documentation) -- [Releasing](#releasing) - [Join The Development](#join-the-development) ## Issues @@ -53,88 +49,51 @@ In case you are suggesting a new feature, we will match your idea with our curre ## Setup - Install [Node.js](https://nodejs.org/) if you don't have it already. - _Note: Node 6 or greater would be better for "best results"._ -- Fork the **webpack-cli** repo at [https://github.com/webpack/webpack-cli](https://github.com/webpack/webpack-cli). -- `git clone && cd webpack-cli` - -- We use [yarn](https://yarnpkg.com/lang/en/) workspaces, please install it: + _Note: Node 22 or greater would be better for "best results"._ - Read the [Installation Guide](https://yarnpkg.com/en/docs/install) on their official website for detailed instructions on how to install Yarn. +- Fork the **webpack-cli** repo at [https://github.com/webpack/webpack-cli](https://github.com/webpack/webpack-cli). -> Using yarn is not a requirement, [npm](https://www.npmjs.com/) is included in node. +- `git clone && cd webpack-cli` - Install the dependencies: ```bash - yarn install + npm install ``` - Build all the submodules before building for the first time ```bash - yarn build + npm run build ``` > If you are a Docker and Visual Studio Code user, you can quickstart development using [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) Extension ## Running Tests -### Using yarn - - Run all the tests with: ```bash - yarn test - ``` - -- Run CLI tests with: - - ```bash - yarn test:cli - ``` - -- Run tests of all packages: - - ```bash - yarn test:packages - ``` - -- Test a single CLI test case: - - > Must run from root of the project - - ```bash - yarn jest path/to/my-test.js - ``` - -- You can also install jest globally and run tests without npx: - - ```bash - yarn global add jest - jest path/to/my-test.js + npm run test ``` - You can run the linters: ```bash - yarn lint + npm run lint ``` ## Editor Config -The [.editorconfig](https://github.com/webpack/webpack-cli/blob/master/.editorconfig) in the root should ensure consistent formatting. Please make sure you've [installed the plugin](http://editorconfig.org/#download) if your text editor needs one. +The [.editorconfig](https://github.com/webpack/webpack-cli/blob/main/.editorconfig) in the root should ensure consistent formatting. Please make sure you've [installed the plugin](http://editorconfig.org/#download) if your text editor needs one. ## Dependencies -This is a multi-package repository and dependencies are managed using [lerna](https://lerna.js.org/) - -> If you are adding or updating any dependency, please commit the updated `yarn.lock` file. - To update dependencies, import each dependency and make sure the command line build passes. The dependency should support our minimal supported node version for webpack, found in `package.json`. ## Branching Model -We base our branching model on [git flow](http://nvie.com/posts/a-successful-git-branching-model/). Instead of working with a `develop` base branch, we use the `master` branch. We do it to ease the workflow a bit. However, we find that adding prefixes to the branches is useful. +We base our branching model on [git flow](http://nvie.com/posts/a-successful-git-branching-model/). Instead of working with a `develop` base branch, we use the `main` branch. We do it to ease the workflow a bit. However, we find that adding prefixes to the branches is useful. ## Naming a branch @@ -143,7 +102,7 @@ Making a branch in your fork for your contribution is helpful in the following w - It allows you to submit more than one contribution in a single PR. - It allows us to identify what your contribution is about from the branch name. -You will want to checkout the `master` branch locally before creating your new branch. +You will want to checkout the `main` branch locally before creating your new branch. There are two types of branches: @@ -186,55 +145,6 @@ In case you've got a small change in most of the cases, your pull request would - Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. ([More info](https://github.com/blog/1506-closing-issues-via-pull-requests)) - When you have lot of commits in your PR, it's good practice to squash all your commits in one single commit. ([Learn how to squash here](https://davidwalsh.name/squash-commits-git)) -## Commit message - -Our commit messages format follows the [angular.js commits format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits). - -We don't use the scope. The template of a commit would look like this: - -### Commit Message Format - -Each commit message consists of a **header**, a **body** and a **footer**. The header has a special -format that includes a **type** and a **subject**: - -``` -: - - - -