diff --git a/__fixtures__/bolt-workspace/package.json b/__fixtures__/bolt-workspace/package.json deleted file mode 100644 index 851a601f6..000000000 --- a/__fixtures__/bolt-workspace/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "bolt-workspaces", - "description": "bolt-workspaces", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/bolt-workspace/packages/pkg-a/package.json b/__fixtures__/bolt-workspace/packages/pkg-a/package.json deleted file mode 100644 index 6d1b4b4e9..000000000 --- a/__fixtures__/bolt-workspace/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "bolt-workspace-pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/bolt-workspace/packages/pkg-b/package.json b/__fixtures__/bolt-workspace/packages/pkg-b/package.json deleted file mode 100644 index f4635f022..000000000 --- a/__fixtures__/bolt-workspace/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "bolt-workspace-pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/broken-changeset/.changeset/broken-changeset.md b/__fixtures__/broken-changeset/.changeset/broken-changeset.md deleted file mode 100644 index 782d4469d..000000000 --- a/__fixtures__/broken-changeset/.changeset/broken-changeset.md +++ /dev/null @@ -1,7 +0,0 @@ ---- - -"cool-package": minor - --- - -Everything is wrong diff --git a/__fixtures__/dependant-with-tag-range/.changeset/README.md b/__fixtures__/dependant-with-tag-range/.changeset/README.md deleted file mode 100644 index 99f92fc30..000000000 --- a/__fixtures__/dependant-with-tag-range/.changeset/README.md +++ /dev/null @@ -1 +0,0 @@ -# We just want a file in here so git collects it diff --git a/__fixtures__/dependant-with-tag-range/.changeset/config.json b/__fixtures__/dependant-with-tag-range/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/dependant-with-tag-range/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/dependant-with-tag-range/examples/example-a/package.json b/__fixtures__/dependant-with-tag-range/examples/example-a/package.json deleted file mode 100644 index 17ed60185..000000000 --- a/__fixtures__/dependant-with-tag-range/examples/example-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "example-a", - "version": "1.0.0", - "dependencies": { - "pkg-a": "latest" - } -} diff --git a/__fixtures__/dependant-with-tag-range/package.json b/__fixtures__/dependant-with-tag-range/package.json deleted file mode 100644 index f071b78bf..000000000 --- a/__fixtures__/dependant-with-tag-range/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "private": true, - "name": "dependant-with-tag-range", - "description": "example depending on latest tag", - "version": "1.0.0", - "workspaces": [ - "examples/*", - "packages/*" - ] -} diff --git a/__fixtures__/dependant-with-tag-range/packages/pkg-a/package.json b/__fixtures__/dependant-with-tag-range/packages/pkg-a/package.json deleted file mode 100644 index ee09b194d..000000000 --- a/__fixtures__/dependant-with-tag-range/packages/pkg-a/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} diff --git a/__fixtures__/dev-and-prod-dep/.changeset/README.md b/__fixtures__/dev-and-prod-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/dev-and-prod-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/dev-and-prod-dep/.changeset/config.json b/__fixtures__/dev-and-prod-dep/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/dev-and-prod-dep/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/dev-and-prod-dep/package.json b/__fixtures__/dev-and-prod-dep/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/dev-and-prod-dep/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/dev-and-prod-dep/packages/pkg-a/package.json b/__fixtures__/dev-and-prod-dep/packages/pkg-a/package.json deleted file mode 100644 index b0756577c..000000000 --- a/__fixtures__/dev-and-prod-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - }, - "devDependencies": { - "pkg-c": "1.0.0" - } -} diff --git a/__fixtures__/dev-and-prod-dep/packages/pkg-b/package.json b/__fixtures__/dev-and-prod-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/dev-and-prod-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/dev-and-prod-dep/packages/pkg-c/package.json b/__fixtures__/dev-and-prod-dep/packages/pkg-c/package.json deleted file mode 100644 index 888ba5c7e..000000000 --- a/__fixtures__/dev-and-prod-dep/packages/pkg-c/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0" -} diff --git a/__fixtures__/easy-read/.changeset/basic-changeset.md b/__fixtures__/easy-read/.changeset/basic-changeset.md deleted file mode 100644 index c232489ed..000000000 --- a/__fixtures__/easy-read/.changeset/basic-changeset.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"cool-package": minor ---- - -Nice simple summary diff --git a/__fixtures__/empty-changeset/.changeset/empty-changeset.md b/__fixtures__/empty-changeset/.changeset/empty-changeset.md deleted file mode 100644 index a845151cc..000000000 --- a/__fixtures__/empty-changeset/.changeset/empty-changeset.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/__fixtures__/fixed-packages/.changeset/README.md b/__fixtures__/fixed-packages/.changeset/README.md deleted file mode 100644 index 99f92fc30..000000000 --- a/__fixtures__/fixed-packages/.changeset/README.md +++ /dev/null @@ -1 +0,0 @@ -# We just want a file in here so git collects it diff --git a/__fixtures__/fixed-packages/package.json b/__fixtures__/fixed-packages/package.json deleted file mode 100644 index 2035e7a09..000000000 --- a/__fixtures__/fixed-packages/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "two fixed projects", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/fixed-packages/packages/pkg-a/package.json b/__fixtures__/fixed-packages/packages/pkg-a/package.json deleted file mode 100644 index 205afc493..000000000 --- a/__fixtures__/fixed-packages/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/fixed-packages/packages/pkg-b/package.json b/__fixtures__/fixed-packages/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/fixed-packages/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/ignored-changeset/.changeset/.ignored-temporarily.md b/__fixtures__/ignored-changeset/.changeset/.ignored-temporarily.md deleted file mode 100644 index 8e84ebf78..000000000 --- a/__fixtures__/ignored-changeset/.changeset/.ignored-temporarily.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"pkg-b": minor ---- - -Awesome feature, hidden behind a feature flag diff --git a/__fixtures__/ignored-changeset/.changeset/README.md b/__fixtures__/ignored-changeset/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/ignored-changeset/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/ignored-changeset/.changeset/changesets-are-beautiful.md b/__fixtures__/ignored-changeset/.changeset/changesets-are-beautiful.md deleted file mode 100644 index 943b7582e..000000000 --- a/__fixtures__/ignored-changeset/.changeset/changesets-are-beautiful.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"pkg-a": minor ---- - -Nice simple summary, much wow diff --git a/__fixtures__/ignored-changeset/.changeset/config.json b/__fixtures__/ignored-changeset/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/ignored-changeset/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/ignored-changeset/package.json b/__fixtures__/ignored-changeset/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/ignored-changeset/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/ignored-changeset/packages/pkg-a/package.json b/__fixtures__/ignored-changeset/packages/pkg-a/package.json deleted file mode 100644 index 205afc493..000000000 --- a/__fixtures__/ignored-changeset/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/ignored-changeset/packages/pkg-b/package.json b/__fixtures__/ignored-changeset/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/ignored-changeset/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/ignored-package/.changeset/config.json b/__fixtures__/ignored-package/.changeset/config.json deleted file mode 100644 index d218d4990..000000000 --- a/__fixtures__/ignored-package/.changeset/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://unpkg.com/@changesets/config@1.3.0/schema.json", - "ignore": ["ignored-package-pkg-a"] -} diff --git a/__fixtures__/ignored-package/package.json b/__fixtures__/ignored-package/package.json deleted file mode 100644 index fe1271f2b..000000000 --- a/__fixtures__/ignored-package/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "private": true, - "name": "ignored-package", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ] -} diff --git a/__fixtures__/ignored-package/packages/pkg-a/package.json b/__fixtures__/ignored-package/packages/pkg-a/package.json deleted file mode 100644 index 3bb92c331..000000000 --- a/__fixtures__/ignored-package/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "ignored-package-pkg-a", - "version": "1.0.0", - "dependencies": { - "ignored-package-pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/ignored-package/packages/pkg-b/package.json b/__fixtures__/ignored-package/packages/pkg-b/package.json deleted file mode 100644 index 4fe0eb694..000000000 --- a/__fixtures__/ignored-package/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "ignored-package-pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/interlinked-dependencies-with-0x-versions/.changeset/README.md b/__fixtures__/interlinked-dependencies-with-0x-versions/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/interlinked-dependencies-with-0x-versions/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/interlinked-dependencies-with-0x-versions/package.json b/__fixtures__/interlinked-dependencies-with-0x-versions/package.json deleted file mode 100644 index 1a113cc48..000000000 --- a/__fixtures__/interlinked-dependencies-with-0x-versions/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "simple project, where packages are all 0.x versions", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/interlinked-dependencies-with-0x-versions/packages/pkg-a/package.json b/__fixtures__/interlinked-dependencies-with-0x-versions/packages/pkg-a/package.json deleted file mode 100644 index 2fc88bdb8..000000000 --- a/__fixtures__/interlinked-dependencies-with-0x-versions/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "0.0.0", - "dependencies": { - "pkg-b": "~0.0.0" - } -} diff --git a/__fixtures__/interlinked-dependencies-with-0x-versions/packages/pkg-b/package.json b/__fixtures__/interlinked-dependencies-with-0x-versions/packages/pkg-b/package.json deleted file mode 100644 index b49fa181e..000000000 --- a/__fixtures__/interlinked-dependencies-with-0x-versions/packages/pkg-b/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "pkg-b", - "version": "0.0.0", - "dependencies": { - "pkg-c": "0.0.0", - "pkg-a": "^0.0.0" - } -} diff --git a/__fixtures__/interlinked-dependencies-with-0x-versions/packages/pkg-c/package.json b/__fixtures__/interlinked-dependencies-with-0x-versions/packages/pkg-c/package.json deleted file mode 100644 index 51afcc344..000000000 --- a/__fixtures__/interlinked-dependencies-with-0x-versions/packages/pkg-c/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-c", - "version": "0.0.0", - "dependencies": { - "pkg-a": "~0.0.0" - } -} diff --git a/__fixtures__/internal-dependencies/.changeset/README.md b/__fixtures__/internal-dependencies/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/internal-dependencies/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/internal-dependencies/package.json b/__fixtures__/internal-dependencies/package.json deleted file mode 100644 index 684481d64..000000000 --- a/__fixtures__/internal-dependencies/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "simple project, just two workspaces, no dependencies", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/internal-dependencies/packages/pkg-a/package.json b/__fixtures__/internal-dependencies/packages/pkg-a/package.json deleted file mode 100644 index 9db57bb5f..000000000 --- a/__fixtures__/internal-dependencies/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.3", - "dependencies": { - "pkg-b": "~1.2.0" - } -} diff --git a/__fixtures__/internal-dependencies/packages/pkg-b/package.json b/__fixtures__/internal-dependencies/packages/pkg-b/package.json deleted file mode 100644 index 83c540b34..000000000 --- a/__fixtures__/internal-dependencies/packages/pkg-b/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.2.0", - "dependencies": { - "pkg-c": "2.0.0", - "pkg-a": "^1.0.3" - } -} diff --git a/__fixtures__/internal-dependencies/packages/pkg-c/package.json b/__fixtures__/internal-dependencies/packages/pkg-c/package.json deleted file mode 100644 index 52bd12a21..000000000 --- a/__fixtures__/internal-dependencies/packages/pkg-c/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-c", - "version": "2.0.0", - "dependencies": { - "pkg-a": "^1.0.3" - } -} diff --git a/__fixtures__/linked-and-not-linked-packages/.changeset/README.md b/__fixtures__/linked-and-not-linked-packages/.changeset/README.md deleted file mode 100644 index 99f92fc30..000000000 --- a/__fixtures__/linked-and-not-linked-packages/.changeset/README.md +++ /dev/null @@ -1 +0,0 @@ -# We just want a file in here so git collects it diff --git a/__fixtures__/linked-and-not-linked-packages/package.json b/__fixtures__/linked-and-not-linked-packages/package.json deleted file mode 100644 index fd9c39c0b..000000000 --- a/__fixtures__/linked-and-not-linked-packages/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "linked-and-not-linked-packages", - "description": "three projects, 2 linked and one not", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/linked-and-not-linked-packages/packages/pkg-a/package.json b/__fixtures__/linked-and-not-linked-packages/packages/pkg-a/package.json deleted file mode 100644 index ee09b194d..000000000 --- a/__fixtures__/linked-and-not-linked-packages/packages/pkg-a/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} diff --git a/__fixtures__/linked-and-not-linked-packages/packages/pkg-b/package.json b/__fixtures__/linked-and-not-linked-packages/packages/pkg-b/package.json deleted file mode 100644 index 3a55f166a..000000000 --- a/__fixtures__/linked-and-not-linked-packages/packages/pkg-b/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0", - "dependencies": { - "pkg-c": "0.1.0" - } -} diff --git a/__fixtures__/linked-and-not-linked-packages/packages/pkg-c/package.json b/__fixtures__/linked-and-not-linked-packages/packages/pkg-c/package.json deleted file mode 100644 index 86949f43d..000000000 --- a/__fixtures__/linked-and-not-linked-packages/packages/pkg-c/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-c", - "version": "0.1.0" -} diff --git a/__fixtures__/linked-packages-with-linked-dev-dep/.changeset/README.md b/__fixtures__/linked-packages-with-linked-dev-dep/.changeset/README.md deleted file mode 100644 index 99f92fc30..000000000 --- a/__fixtures__/linked-packages-with-linked-dev-dep/.changeset/README.md +++ /dev/null @@ -1 +0,0 @@ -# We just want a file in here so git collects it diff --git a/__fixtures__/linked-packages-with-linked-dev-dep/.changeset/config.js b/__fixtures__/linked-packages-with-linked-dev-dep/.changeset/config.js deleted file mode 100644 index ec00a8614..000000000 --- a/__fixtures__/linked-packages-with-linked-dev-dep/.changeset/config.js +++ /dev/null @@ -1,87 +0,0 @@ -/* -Hey, welcome to the changeset config! This file has been generated -for you with the default configs we use, and some comments around -what options mean, so that it's easy to customise your workflow. - -You should update this as you need to craft your workflow. - -Config provided by a CI command takes precedence over the contents of this file. - -If a config option isn't present here, we will fall back to the defaults. -*/ - -const changesetOptions = { - // If true, we will automatically commit the changeset when the command is run - commit: false -}; - -// This function takes information about a changeset to generate an entry for it in your -// changelog. We provide the full changeset object as well as the version. -// It may be a good idea to replace the commit hash with a link to the commit. - -/* the default shape is: -### Bump Type - -- GIT_HASH: A summary message you wrote, indented? -*/ - -const getReleaseLine = async (changeset, type) => { - const [firstLine, ...futureLines] = changeset.summary - .split("\n") - .map(l => l.trimRight()); - - return `- ${changeset.commit}: ${firstLine}\n${futureLines - .map(l => ` ${l}`) - .join("\n")}`; -}; - -// This function takes information about what dependencies we are updating in the package. -// It provides an array of related changesets, as well as the dependencies updated. - -/* -- Updated dependencies: [ABCDEFG]: -- Updated dependencies: [HIJKLMN]: - - dependencyA@1.0.1 - - dependencyb@1.2.0 -*/ -const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => { - if (dependenciesUpdated.length === 0) return ""; - - const changesetLinks = changesets.map( - changeset => `- Updated dependencies [${changeset.commit}]:` - ); - - const updatedDepenenciesList = dependenciesUpdated.map( - dependency => ` - ${dependency.name}@${dependency.version}` - ); - - return [...changesetLinks, ...updatedDepenenciesList].join("\n"); -}; - -const versionOptions = { - // If true, we will automatically commit the version updating when the command is run - commit: false, - // Adds a skipCI flag to the commit - only valid if `commit` is also true. - skipCI: false, - // Do not modify the `changelog.md` files for packages that are updated - updateChangelog: true, - // A function that returns a string. It takes in options about a change. This allows you to customise your changelog entries - getReleaseLine, - // A function that returns a string. It takes in options about when a pacakge is updated because - getDependencyReleaseLine, - // An array of arrays that defines packages that are linked. - // Linked packages are packages that should be at the same version when they're released. - // If you've used Lerna to version packages before, this is very similar. - linked: [["pkg-a", "pkg-b"]] -}; - -const publishOptions = { - // This sets whether unpublished packages are public by default. We err on the side of caution here. - public: false -}; - -module.exports = { - versionOptions, - changesetOptions, - publishOptions -}; diff --git a/__fixtures__/linked-packages-with-linked-dev-dep/package.json b/__fixtures__/linked-packages-with-linked-dev-dep/package.json deleted file mode 100644 index 5501a2aef..000000000 --- a/__fixtures__/linked-packages-with-linked-dev-dep/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "linked-packages-with-linked-dev-dep", - "description": "linked projects where one of packages has a dev dependency on another", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/linked-packages-with-linked-dev-dep/packages/pkg-a/package.json b/__fixtures__/linked-packages-with-linked-dev-dep/packages/pkg-a/package.json deleted file mode 100644 index b036cfd3a..000000000 --- a/__fixtures__/linked-packages-with-linked-dev-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "devDependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/linked-packages-with-linked-dev-dep/packages/pkg-b/package.json b/__fixtures__/linked-packages-with-linked-dev-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/linked-packages-with-linked-dev-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/linked-packages/.changeset/README.md b/__fixtures__/linked-packages/.changeset/README.md deleted file mode 100644 index 99f92fc30..000000000 --- a/__fixtures__/linked-packages/.changeset/README.md +++ /dev/null @@ -1 +0,0 @@ -# We just want a file in here so git collects it diff --git a/__fixtures__/linked-packages/.changeset/config.js b/__fixtures__/linked-packages/.changeset/config.js deleted file mode 100644 index ec00a8614..000000000 --- a/__fixtures__/linked-packages/.changeset/config.js +++ /dev/null @@ -1,87 +0,0 @@ -/* -Hey, welcome to the changeset config! This file has been generated -for you with the default configs we use, and some comments around -what options mean, so that it's easy to customise your workflow. - -You should update this as you need to craft your workflow. - -Config provided by a CI command takes precedence over the contents of this file. - -If a config option isn't present here, we will fall back to the defaults. -*/ - -const changesetOptions = { - // If true, we will automatically commit the changeset when the command is run - commit: false -}; - -// This function takes information about a changeset to generate an entry for it in your -// changelog. We provide the full changeset object as well as the version. -// It may be a good idea to replace the commit hash with a link to the commit. - -/* the default shape is: -### Bump Type - -- GIT_HASH: A summary message you wrote, indented? -*/ - -const getReleaseLine = async (changeset, type) => { - const [firstLine, ...futureLines] = changeset.summary - .split("\n") - .map(l => l.trimRight()); - - return `- ${changeset.commit}: ${firstLine}\n${futureLines - .map(l => ` ${l}`) - .join("\n")}`; -}; - -// This function takes information about what dependencies we are updating in the package. -// It provides an array of related changesets, as well as the dependencies updated. - -/* -- Updated dependencies: [ABCDEFG]: -- Updated dependencies: [HIJKLMN]: - - dependencyA@1.0.1 - - dependencyb@1.2.0 -*/ -const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => { - if (dependenciesUpdated.length === 0) return ""; - - const changesetLinks = changesets.map( - changeset => `- Updated dependencies [${changeset.commit}]:` - ); - - const updatedDepenenciesList = dependenciesUpdated.map( - dependency => ` - ${dependency.name}@${dependency.version}` - ); - - return [...changesetLinks, ...updatedDepenenciesList].join("\n"); -}; - -const versionOptions = { - // If true, we will automatically commit the version updating when the command is run - commit: false, - // Adds a skipCI flag to the commit - only valid if `commit` is also true. - skipCI: false, - // Do not modify the `changelog.md` files for packages that are updated - updateChangelog: true, - // A function that returns a string. It takes in options about a change. This allows you to customise your changelog entries - getReleaseLine, - // A function that returns a string. It takes in options about when a pacakge is updated because - getDependencyReleaseLine, - // An array of arrays that defines packages that are linked. - // Linked packages are packages that should be at the same version when they're released. - // If you've used Lerna to version packages before, this is very similar. - linked: [["pkg-a", "pkg-b"]] -}; - -const publishOptions = { - // This sets whether unpublished packages are public by default. We err on the side of caution here. - public: false -}; - -module.exports = { - versionOptions, - changesetOptions, - publishOptions -}; diff --git a/__fixtures__/linked-packages/package.json b/__fixtures__/linked-packages/package.json deleted file mode 100644 index f2f6c7519..000000000 --- a/__fixtures__/linked-packages/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "two linked projects", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/linked-packages/packages/pkg-a/package.json b/__fixtures__/linked-packages/packages/pkg-a/package.json deleted file mode 100644 index 6d10d84d6..000000000 --- a/__fixtures__/linked-packages/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "0.1.0" - } -} diff --git a/__fixtures__/linked-packages/packages/pkg-b/package.json b/__fixtures__/linked-packages/packages/pkg-b/package.json deleted file mode 100644 index 7628b7fe6..000000000 --- a/__fixtures__/linked-packages/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "0.1.0" -} diff --git a/__fixtures__/multiple-changesets/.changeset/first-changeset.md b/__fixtures__/multiple-changesets/.changeset/first-changeset.md deleted file mode 100644 index c232489ed..000000000 --- a/__fixtures__/multiple-changesets/.changeset/first-changeset.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"cool-package": minor ---- - -Nice simple summary diff --git a/__fixtures__/multiple-changesets/.changeset/second-changeset.md b/__fixtures__/multiple-changesets/.changeset/second-changeset.md deleted file mode 100644 index e893cc33e..000000000 --- a/__fixtures__/multiple-changesets/.changeset/second-changeset.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"best-package": patch ---- - -I'm amazed we needed to update the best package, because it was already the best diff --git a/__fixtures__/new-config/.changeset/config.json b/__fixtures__/new-config/.changeset/config.json deleted file mode 100644 index e3a81277f..000000000 --- a/__fixtures__/new-config/.changeset/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "changelog": false, - "commit": true -} diff --git a/__fixtures__/no-changeset-folder/.gitkeep b/__fixtures__/no-changeset-folder/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/__fixtures__/no-changeset/.changeset/.gitkeep b/__fixtures__/no-changeset/.changeset/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/__fixtures__/no-name-field/package.json b/__fixtures__/no-name-field/package.json deleted file mode 100644 index 1f6f2d7c7..000000000 --- a/__fixtures__/no-name-field/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "private": true, - "name": "yarn-workspace-base", - "description": "Base yarn workspace work", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ] -} diff --git a/__fixtures__/no-name-field/packages/pkg-a/package.json b/__fixtures__/no-name-field/packages/pkg-a/package.json deleted file mode 100644 index d902f7967..000000000 --- a/__fixtures__/no-name-field/packages/pkg-a/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/no-name-field/packages/pkg-b/package.json b/__fixtures__/no-name-field/packages/pkg-b/package.json deleted file mode 100644 index 1587a6696..000000000 --- a/__fixtures__/no-name-field/packages/pkg-b/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} diff --git a/__fixtures__/no-trailing-newline/package.json b/__fixtures__/no-trailing-newline/package.json deleted file mode 100644 index e66dd5c47..000000000 --- a/__fixtures__/no-trailing-newline/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} \ No newline at end of file diff --git a/__fixtures__/old-changeset/.changeset/basic-changeset/changes.json b/__fixtures__/old-changeset/.changeset/basic-changeset/changes.json deleted file mode 100644 index 6871207b8..000000000 --- a/__fixtures__/old-changeset/.changeset/basic-changeset/changes.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "releases": [ - { - "name": "cool-package", - "type": "minor" - } - ], - "dependents": [] -} diff --git a/__fixtures__/old-changeset/.changeset/basic-changeset/changes.md b/__fixtures__/old-changeset/.changeset/basic-changeset/changes.md deleted file mode 100644 index 80c883ade..000000000 --- a/__fixtures__/old-changeset/.changeset/basic-changeset/changes.md +++ /dev/null @@ -1 +0,0 @@ -Nice simple summary diff --git a/__fixtures__/pinned-caret-tilde-dependents/.changeset/README.md b/__fixtures__/pinned-caret-tilde-dependents/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/pinned-caret-tilde-dependents/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/pinned-caret-tilde-dependents/package.json b/__fixtures__/pinned-caret-tilde-dependents/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/pinned-caret-tilde-dependents/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/pinned-caret-tilde-dependents/packages/caret-dep/package.json b/__fixtures__/pinned-caret-tilde-dependents/packages/caret-dep/package.json deleted file mode 100644 index 2ed661333..000000000 --- a/__fixtures__/pinned-caret-tilde-dependents/packages/caret-dep/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "caret-dep", - "version": "1.0.0", - "dependencies": { - "depended-upon": "^1.0.0" - } -} diff --git a/__fixtures__/pinned-caret-tilde-dependents/packages/depended-upon/package.json b/__fixtures__/pinned-caret-tilde-dependents/packages/depended-upon/package.json deleted file mode 100644 index 4067befeb..000000000 --- a/__fixtures__/pinned-caret-tilde-dependents/packages/depended-upon/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "depended-upon", - "version": "1.0.0" -} diff --git a/__fixtures__/pinned-caret-tilde-dependents/packages/pinned-dep/package.json b/__fixtures__/pinned-caret-tilde-dependents/packages/pinned-dep/package.json deleted file mode 100644 index 3d2cbf5a1..000000000 --- a/__fixtures__/pinned-caret-tilde-dependents/packages/pinned-dep/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pinned-dep", - "version": "1.0.0", - "dependencies": { - "depended-upon": "1.0.0" - } -} diff --git a/__fixtures__/pinned-caret-tilde-dependents/packages/tilde-dep/package.json b/__fixtures__/pinned-caret-tilde-dependents/packages/tilde-dep/package.json deleted file mode 100644 index c7043b85f..000000000 --- a/__fixtures__/pinned-caret-tilde-dependents/packages/tilde-dep/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "tilde-dep", - "version": "1.0.0", - "dependencies": { - "depended-upon": "~1.0.0" - } -} diff --git a/__fixtures__/pnpm-workspace-base/package.json b/__fixtures__/pnpm-workspace-base/package.json deleted file mode 100644 index 3994cd134..000000000 --- a/__fixtures__/pnpm-workspace-base/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "name": "pnpm-workspace-base", - "description": "Base pnpm workspace work", - "version": "1.0.0" -} diff --git a/__fixtures__/pnpm-workspace-base/packages/pkg-a/package.json b/__fixtures__/pnpm-workspace-base/packages/pkg-a/package.json deleted file mode 100644 index 0917eaaec..000000000 --- a/__fixtures__/pnpm-workspace-base/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pnpm-workspace-base-pkg-a", - "version": "1.0.0", - "dependencies": { - "pnpm-workspace-base-pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/pnpm-workspace-base/packages/pkg-b/package.json b/__fixtures__/pnpm-workspace-base/packages/pkg-b/package.json deleted file mode 100644 index 9b8d622e7..000000000 --- a/__fixtures__/pnpm-workspace-base/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pnpm-workspace-base-pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/pnpm-workspace-base/pnpm-workspace.yaml b/__fixtures__/pnpm-workspace-base/pnpm-workspace.yaml deleted file mode 100644 index 03833fc6f..000000000 --- a/__fixtures__/pnpm-workspace-base/pnpm-workspace.yaml +++ /dev/null @@ -1,2 +0,0 @@ -packages: - - '**' diff --git a/__fixtures__/previously-checked-transitive-dependent/.changeset/README.md b/__fixtures__/previously-checked-transitive-dependent/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/previously-checked-transitive-dependent/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/previously-checked-transitive-dependent/package.json b/__fixtures__/previously-checked-transitive-dependent/package.json deleted file mode 100644 index 7780f9306..000000000 --- a/__fixtures__/previously-checked-transitive-dependent/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "private": true, - "name": "previously-checked-transitive-dependent", - "description": "Here we use project where b->a (caret) and c->a (pinned) and b -> c (pinned)", - "description2": "Therefore bumping a will bump c (but not b), but bumping c will bump b anyway", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/previously-checked-transitive-dependent/packages/pkg-a/package.json b/__fixtures__/previously-checked-transitive-dependent/packages/pkg-a/package.json deleted file mode 100644 index ee09b194d..000000000 --- a/__fixtures__/previously-checked-transitive-dependent/packages/pkg-a/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} diff --git a/__fixtures__/previously-checked-transitive-dependent/packages/pkg-b/package.json b/__fixtures__/previously-checked-transitive-dependent/packages/pkg-b/package.json deleted file mode 100644 index b3ed037b4..000000000 --- a/__fixtures__/previously-checked-transitive-dependent/packages/pkg-b/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0", - "dependencies": { - "pkg-a": "^1.0.0" , - "pkg-c": "1.0.0" - } -} diff --git a/__fixtures__/previously-checked-transitive-dependent/packages/pkg-c/package.json b/__fixtures__/previously-checked-transitive-dependent/packages/pkg-c/package.json deleted file mode 100644 index 0762ee6d6..000000000 --- a/__fixtures__/previously-checked-transitive-dependent/packages/pkg-c/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0", - "dependencies": { "pkg-a": "1.0.0" } -} diff --git a/__fixtures__/previously-checked-transitive-peer-dependent/.changeset/README.md b/__fixtures__/previously-checked-transitive-peer-dependent/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/previously-checked-transitive-peer-dependent/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/previously-checked-transitive-peer-dependent/package.json b/__fixtures__/previously-checked-transitive-peer-dependent/package.json deleted file mode 100644 index e2bad47a7..000000000 --- a/__fixtures__/previously-checked-transitive-peer-dependent/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "private": true, - "name": "previously-checked-transitive-peer-dependent", - "description": "pkg-b has a caretDep on pkg-a and a caret dep on pkg-c, pkg-c has a caret peerDep", - "description2": "on pkg-a. Minor bumping pkg-a should not cause pkg-b to release, but will cause a", - "description3:": "major on pkg-c, which in turn patches pkg-b", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/previously-checked-transitive-peer-dependent/packages/pkg-a/package.json b/__fixtures__/previously-checked-transitive-peer-dependent/packages/pkg-a/package.json deleted file mode 100644 index ee09b194d..000000000 --- a/__fixtures__/previously-checked-transitive-peer-dependent/packages/pkg-a/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} diff --git a/__fixtures__/previously-checked-transitive-peer-dependent/packages/pkg-b/package.json b/__fixtures__/previously-checked-transitive-peer-dependent/packages/pkg-b/package.json deleted file mode 100644 index 24733a15d..000000000 --- a/__fixtures__/previously-checked-transitive-peer-dependent/packages/pkg-b/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0", - "dependencies": { - "pkg-a": "^1.0.0", - "pkg-c": "^1.0.0" - } -} diff --git a/__fixtures__/previously-checked-transitive-peer-dependent/packages/pkg-c/package.json b/__fixtures__/previously-checked-transitive-peer-dependent/packages/pkg-c/package.json deleted file mode 100644 index 14074db0a..000000000 --- a/__fixtures__/previously-checked-transitive-peer-dependent/packages/pkg-c/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0", - "peerDependencies": { - "pkg-a": "^1.0.0" - } -} diff --git a/__fixtures__/private-package-with-version-field/.changeset/config.json b/__fixtures__/private-package-with-version-field/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/private-package-with-version-field/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/private-package-with-version-field/package.json b/__fixtures__/private-package-with-version-field/package.json deleted file mode 100644 index 14d4d5c5c..000000000 --- a/__fixtures__/private-package-with-version-field/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "private": true, - "name": "private-package-with-version-field", - "description": "Base yarn workspace work", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ] -} diff --git a/__fixtures__/private-package-with-version-field/packages/pkg-a/package.json b/__fixtures__/private-package-with-version-field/packages/pkg-a/package.json deleted file mode 100644 index ee09b194d..000000000 --- a/__fixtures__/private-package-with-version-field/packages/pkg-a/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} diff --git a/__fixtures__/private-package-with-version-field/packages/pkg-b/package.json b/__fixtures__/private-package-with-version-field/packages/pkg-b/package.json deleted file mode 100644 index f1b81eab5..000000000 --- a/__fixtures__/private-package-with-version-field/packages/pkg-b/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0", - "private": true -} diff --git a/__fixtures__/private-package-with-version-field/packages/pkg-c/package.json b/__fixtures__/private-package-with-version-field/packages/pkg-c/package.json deleted file mode 100644 index 888ba5c7e..000000000 --- a/__fixtures__/private-package-with-version-field/packages/pkg-c/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0" -} diff --git a/__fixtures__/private-package-without-version-field/.changeset/config.json b/__fixtures__/private-package-without-version-field/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/private-package-without-version-field/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/private-package-without-version-field/package.json b/__fixtures__/private-package-without-version-field/package.json deleted file mode 100644 index b245108a3..000000000 --- a/__fixtures__/private-package-without-version-field/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "private": true, - "name": "private-package-without-version-field", - "description": "Base yarn workspace work", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ] -} diff --git a/__fixtures__/private-package-without-version-field/packages/pkg-a/package.json b/__fixtures__/private-package-without-version-field/packages/pkg-a/package.json deleted file mode 100644 index ee09b194d..000000000 --- a/__fixtures__/private-package-without-version-field/packages/pkg-a/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} diff --git a/__fixtures__/private-package-without-version-field/packages/pkg-b/package.json b/__fixtures__/private-package-without-version-field/packages/pkg-b/package.json deleted file mode 100644 index 1a17612fe..000000000 --- a/__fixtures__/private-package-without-version-field/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "private": true -} diff --git a/__fixtures__/private-package-without-version-field/packages/pkg-c/package.json b/__fixtures__/private-package-without-version-field/packages/pkg-c/package.json deleted file mode 100644 index 888ba5c7e..000000000 --- a/__fixtures__/private-package-without-version-field/packages/pkg-c/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0" -} diff --git a/__fixtures__/root-only/package.json b/__fixtures__/root-only/package.json deleted file mode 100644 index 5d2e4dedc..000000000 --- a/__fixtures__/root-only/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "name": "root-only", - "description": "Nothing but the root project, a non-mono-repo", - "version": "1.0.0" -} diff --git a/__fixtures__/self-referenced/package.json b/__fixtures__/self-referenced/package.json deleted file mode 100644 index d7489d9e4..000000000 --- a/__fixtures__/self-referenced/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "self-referenced", - "version": "0.0.0", - "devDependencies": { - "self-referenced": "file:" - } -} diff --git a/__fixtures__/simple-caret-peer-dep/.changeset/README.md b/__fixtures__/simple-caret-peer-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-caret-peer-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-caret-peer-dep/package.json b/__fixtures__/simple-caret-peer-dep/package.json deleted file mode 100644 index cf18b71c8..000000000 --- a/__fixtures__/simple-caret-peer-dep/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "private": true, - "name": "simple-tilde-peer-dep-copy", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-caret-peer-dep/packages/depended-upon/package.json b/__fixtures__/simple-caret-peer-dep/packages/depended-upon/package.json deleted file mode 100644 index 4067befeb..000000000 --- a/__fixtures__/simple-caret-peer-dep/packages/depended-upon/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "depended-upon", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-caret-peer-dep/packages/has-peer-dep/package.json b/__fixtures__/simple-caret-peer-dep/packages/has-peer-dep/package.json deleted file mode 100644 index 530184920..000000000 --- a/__fixtures__/simple-caret-peer-dep/packages/has-peer-dep/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "has-peer-dep", - "version": "1.0.0", - "peerDependencies": { - "depended-upon": "^1.0.0" - } -} diff --git a/__fixtures__/simple-dev-dep/.changeset/README.md b/__fixtures__/simple-dev-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-dev-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-dev-dep/.changeset/config.json b/__fixtures__/simple-dev-dep/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/simple-dev-dep/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/simple-dev-dep/package.json b/__fixtures__/simple-dev-dep/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simple-dev-dep/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-dev-dep/packages/pkg-a/package.json b/__fixtures__/simple-dev-dep/packages/pkg-a/package.json deleted file mode 100644 index b036cfd3a..000000000 --- a/__fixtures__/simple-dev-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "devDependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/simple-dev-dep/packages/pkg-b/package.json b/__fixtures__/simple-dev-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/simple-dev-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-pinned-peer-dep/.changeset/README.md b/__fixtures__/simple-pinned-peer-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-pinned-peer-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-pinned-peer-dep/package.json b/__fixtures__/simple-pinned-peer-dep/package.json deleted file mode 100644 index 830fb6143..000000000 --- a/__fixtures__/simple-pinned-peer-dep/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "private": true, - "name": "simple-pinned-peer-dep", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-pinned-peer-dep/packages/depended-upon/package.json b/__fixtures__/simple-pinned-peer-dep/packages/depended-upon/package.json deleted file mode 100644 index 4067befeb..000000000 --- a/__fixtures__/simple-pinned-peer-dep/packages/depended-upon/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "depended-upon", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-pinned-peer-dep/packages/has-peer-dep/package.json b/__fixtures__/simple-pinned-peer-dep/packages/has-peer-dep/package.json deleted file mode 100644 index fb4fc3df8..000000000 --- a/__fixtures__/simple-pinned-peer-dep/packages/has-peer-dep/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "has-peer-dep", - "version": "1.0.0", - "peerDependencies": { - "depended-upon": "1.0.0" - } -} diff --git a/__fixtures__/simple-project-caret-dep/.changeset/README.md b/__fixtures__/simple-project-caret-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-project-caret-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-project-caret-dep/.changeset/config.json b/__fixtures__/simple-project-caret-dep/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/simple-project-caret-dep/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/simple-project-caret-dep/package.json b/__fixtures__/simple-project-caret-dep/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simple-project-caret-dep/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-project-caret-dep/packages/pkg-a/package.json b/__fixtures__/simple-project-caret-dep/packages/pkg-a/package.json deleted file mode 100644 index 7ba6cd093..000000000 --- a/__fixtures__/simple-project-caret-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "^1.0.0" - } -} diff --git a/__fixtures__/simple-project-caret-dep/packages/pkg-b/package.json b/__fixtures__/simple-project-caret-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/simple-project-caret-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-project-custom-config/.changeset/README.md b/__fixtures__/simple-project-custom-config/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-project-custom-config/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-project-custom-config/.changeset/config.json b/__fixtures__/simple-project-custom-config/.changeset/config.json deleted file mode 100644 index 5ab083e97..000000000 --- a/__fixtures__/simple-project-custom-config/.changeset/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "commit": true, - "changelog": "./getChangelogEntry.js" -} diff --git a/__fixtures__/simple-project-custom-config/.changeset/getChangelogEntry.js b/__fixtures__/simple-project-custom-config/.changeset/getChangelogEntry.js deleted file mode 100644 index 359ce0771..000000000 --- a/__fixtures__/simple-project-custom-config/.changeset/getChangelogEntry.js +++ /dev/null @@ -1,33 +0,0 @@ -// This custom config comes from atlaskit -const getLinkMD = commit => - `[${commit}](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/${commit})`; - -const getReleaseLine = async (changeset, versionType) => { - const indentedSummary = changeset.summary - .split("\n") - .map(l => ` ${l}`.trimRight()) - .join("\n"); - - return `- [${versionType}] ${getLinkMD( - changeset.commit - )}:\n\n${indentedSummary}`; -}; - -const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => { - if (dependenciesUpdated.length === 0) return ""; - - const changesetLinks = changesets.map( - changeset => `- Updated dependencies ${getLinkMD(changeset.commit)}:` - ); - - const updatedDepenenciesList = dependenciesUpdated.map( - dependency => ` - ${dependency.name}@${dependency.newVersion}` - ); - - return [...changesetLinks, ...updatedDepenenciesList].join("\n"); -}; - -module.exports = { - getReleaseLine, - getDependencyReleaseLine -}; diff --git a/__fixtures__/simple-project-custom-config/package.json b/__fixtures__/simple-project-custom-config/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simple-project-custom-config/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-project-custom-config/packages/pkg-a/package.json b/__fixtures__/simple-project-custom-config/packages/pkg-a/package.json deleted file mode 100644 index 205afc493..000000000 --- a/__fixtures__/simple-project-custom-config/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/simple-project-custom-config/packages/pkg-b/package.json b/__fixtures__/simple-project-custom-config/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/simple-project-custom-config/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-project-same-dep-diff-range/.changeset/README.md b/__fixtures__/simple-project-same-dep-diff-range/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-project-same-dep-diff-range/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-project-same-dep-diff-range/.changeset/config.json b/__fixtures__/simple-project-same-dep-diff-range/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/simple-project-same-dep-diff-range/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/simple-project-same-dep-diff-range/package.json b/__fixtures__/simple-project-same-dep-diff-range/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simple-project-same-dep-diff-range/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-project-same-dep-diff-range/packages/pkg-a/package.json b/__fixtures__/simple-project-same-dep-diff-range/packages/pkg-a/package.json deleted file mode 100644 index 70ab6243b..000000000 --- a/__fixtures__/simple-project-same-dep-diff-range/packages/pkg-a/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "peerDependencies": { - "pkg-b": "^1.0.0" - }, - "devDependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/simple-project-same-dep-diff-range/packages/pkg-b/package.json b/__fixtures__/simple-project-same-dep-diff-range/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/simple-project-same-dep-diff-range/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-project-with-changelogs/.changeset/README.md b/__fixtures__/simple-project-with-changelogs/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-project-with-changelogs/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-project-with-changelogs/package.json b/__fixtures__/simple-project-with-changelogs/package.json deleted file mode 100644 index 1e4493120..000000000 --- a/__fixtures__/simple-project-with-changelogs/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "private": true, - "name": "changelog fixtures", - "description": "simple project with no content beside changelog variants", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ], - "releases": { - "baseCommitUrl": "https://somewhere-fake-to-visit.com" - } - } -} diff --git a/__fixtures__/simple-project-with-changelogs/packages/has-empty-changelog/CHANGELOG.md b/__fixtures__/simple-project-with-changelogs/packages/has-empty-changelog/CHANGELOG.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/__fixtures__/simple-project-with-changelogs/packages/has-empty-changelog/package.json b/__fixtures__/simple-project-with-changelogs/packages/has-empty-changelog/package.json deleted file mode 100644 index d5e2866af..000000000 --- a/__fixtures__/simple-project-with-changelogs/packages/has-empty-changelog/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "has-empty-changelog", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-project-with-changelogs/packages/has-filled-changelog/CHANGELOG.md b/__fixtures__/simple-project-with-changelogs/packages/has-filled-changelog/CHANGELOG.md deleted file mode 100644 index e6bfcfcf8..000000000 --- a/__fixtures__/simple-project-with-changelogs/packages/has-filled-changelog/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ -# Has Empty Changelog - -## 1.0.0 - -- [patch] This existed before [b8bb699](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/b8bb699) -- [minor] This also existed before [abcdefg](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/abcdefg) diff --git a/__fixtures__/simple-project-with-changelogs/packages/has-filled-changelog/package.json b/__fixtures__/simple-project-with-changelogs/packages/has-filled-changelog/package.json deleted file mode 100644 index bf222b2fd..000000000 --- a/__fixtures__/simple-project-with-changelogs/packages/has-filled-changelog/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "has-filled-changelog", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-project-with-changelogs/packages/has-no-changelog/package.json b/__fixtures__/simple-project-with-changelogs/packages/has-no-changelog/package.json deleted file mode 100644 index 702722a5a..000000000 --- a/__fixtures__/simple-project-with-changelogs/packages/has-no-changelog/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "has-no-changelog", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-project-with-ignore-config/.changeset/README.md b/__fixtures__/simple-project-with-ignore-config/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-project-with-ignore-config/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-project-with-ignore-config/.changeset/config.json b/__fixtures__/simple-project-with-ignore-config/.changeset/config.json deleted file mode 100644 index 4004d002c..000000000 --- a/__fixtures__/simple-project-with-ignore-config/.changeset/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "ignore": ["pkg-a"] -} diff --git a/__fixtures__/simple-project-with-ignore-config/package.json b/__fixtures__/simple-project-with-ignore-config/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simple-project-with-ignore-config/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-project-with-ignore-config/packages/pkg-a/package.json b/__fixtures__/simple-project-with-ignore-config/packages/pkg-a/package.json deleted file mode 100644 index 205afc493..000000000 --- a/__fixtures__/simple-project-with-ignore-config/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/simple-project-with-ignore-config/packages/pkg-b/package.json b/__fixtures__/simple-project-with-ignore-config/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/simple-project-with-ignore-config/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-project/.changeset/README.md b/__fixtures__/simple-project/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-project/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-project/.changeset/config.json b/__fixtures__/simple-project/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/simple-project/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/simple-project/package.json b/__fixtures__/simple-project/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simple-project/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-project/packages/pkg-a/package.json b/__fixtures__/simple-project/packages/pkg-a/package.json deleted file mode 100644 index 205afc493..000000000 --- a/__fixtures__/simple-project/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/simple-project/packages/pkg-b/package.json b/__fixtures__/simple-project/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/simple-project/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-star-dep/.changeset/README.md b/__fixtures__/simple-star-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-star-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-star-dep/.changeset/config.json b/__fixtures__/simple-star-dep/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/simple-star-dep/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/simple-star-dep/package.json b/__fixtures__/simple-star-dep/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simple-star-dep/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-star-dep/packages/pkg-a/package.json b/__fixtures__/simple-star-dep/packages/pkg-a/package.json deleted file mode 100644 index 1b5eaffb6..000000000 --- a/__fixtures__/simple-star-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "*" - } -} diff --git a/__fixtures__/simple-star-dep/packages/pkg-b/package.json b/__fixtures__/simple-star-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/simple-star-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-tilde-peer-dep/.changeset/README.md b/__fixtures__/simple-tilde-peer-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-tilde-peer-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-tilde-peer-dep/package.json b/__fixtures__/simple-tilde-peer-dep/package.json deleted file mode 100644 index cf18b71c8..000000000 --- a/__fixtures__/simple-tilde-peer-dep/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "private": true, - "name": "simple-tilde-peer-dep-copy", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-tilde-peer-dep/packages/depended-upon/package.json b/__fixtures__/simple-tilde-peer-dep/packages/depended-upon/package.json deleted file mode 100644 index 4067befeb..000000000 --- a/__fixtures__/simple-tilde-peer-dep/packages/depended-upon/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "depended-upon", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-tilde-peer-dep/packages/has-peer-dep/package.json b/__fixtures__/simple-tilde-peer-dep/packages/has-peer-dep/package.json deleted file mode 100644 index 6d5d88f1b..000000000 --- a/__fixtures__/simple-tilde-peer-dep/packages/has-peer-dep/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "has-peer-dep", - "version": "1.0.0", - "peerDependencies": { - "depended-upon": "~1.0.0" - } -} diff --git a/__fixtures__/simple-workspace-range-dep/.changeset/README.md b/__fixtures__/simple-workspace-range-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-workspace-range-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-workspace-range-dep/.changeset/config.json b/__fixtures__/simple-workspace-range-dep/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/simple-workspace-range-dep/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/simple-workspace-range-dep/package.json b/__fixtures__/simple-workspace-range-dep/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simple-workspace-range-dep/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-workspace-range-dep/packages/pkg-a/package.json b/__fixtures__/simple-workspace-range-dep/packages/pkg-a/package.json deleted file mode 100644 index 74bdb1fa6..000000000 --- a/__fixtures__/simple-workspace-range-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "workspace:1.0.0" - } -} diff --git a/__fixtures__/simple-workspace-range-dep/packages/pkg-b/package.json b/__fixtures__/simple-workspace-range-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/simple-workspace-range-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/simple-workspace-wildcard-range-dep/.changeset/README.md b/__fixtures__/simple-workspace-wildcard-range-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simple-workspace-wildcard-range-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simple-workspace-wildcard-range-dep/.changeset/config.json b/__fixtures__/simple-workspace-wildcard-range-dep/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/simple-workspace-wildcard-range-dep/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/simple-workspace-wildcard-range-dep/package.json b/__fixtures__/simple-workspace-wildcard-range-dep/package.json deleted file mode 100644 index 1d9d718fe..000000000 --- a/__fixtures__/simple-workspace-wildcard-range-dep/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-workspace-wildcard-range-dep", - "description": "2 projects, one depending on another with `workspace:*` range", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simple-workspace-wildcard-range-dep/packages/pkg-a/package.json b/__fixtures__/simple-workspace-wildcard-range-dep/packages/pkg-a/package.json deleted file mode 100644 index 7189d052e..000000000 --- a/__fixtures__/simple-workspace-wildcard-range-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "workspace:*" - } -} diff --git a/__fixtures__/simple-workspace-wildcard-range-dep/packages/pkg-b/package.json b/__fixtures__/simple-workspace-wildcard-range-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/simple-workspace-wildcard-range-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/simplest-transitive-dependents/.changeset/README.md b/__fixtures__/simplest-transitive-dependents/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simplest-transitive-dependents/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simplest-transitive-dependents/package.json b/__fixtures__/simplest-transitive-dependents/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simplest-transitive-dependents/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simplest-transitive-dependents/packages/pkg-a/package.json b/__fixtures__/simplest-transitive-dependents/packages/pkg-a/package.json deleted file mode 100644 index ee09b194d..000000000 --- a/__fixtures__/simplest-transitive-dependents/packages/pkg-a/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} diff --git a/__fixtures__/simplest-transitive-dependents/packages/pkg-b/package.json b/__fixtures__/simplest-transitive-dependents/packages/pkg-b/package.json deleted file mode 100644 index 3c931e915..000000000 --- a/__fixtures__/simplest-transitive-dependents/packages/pkg-b/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0", - "dependencies": { "pkg-a": "1.0.0" } -} diff --git a/__fixtures__/simplest-transitive-dependents/packages/pkg-c/package.json b/__fixtures__/simplest-transitive-dependents/packages/pkg-c/package.json deleted file mode 100644 index 09756a7d5..000000000 --- a/__fixtures__/simplest-transitive-dependents/packages/pkg-c/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0", - "dependencies": { "pkg-b": "1.0.0" } -} diff --git a/__fixtures__/simplest-transitive-devdependent/.changeset/README.md b/__fixtures__/simplest-transitive-devdependent/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/simplest-transitive-devdependent/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/simplest-transitive-devdependent/package.json b/__fixtures__/simplest-transitive-devdependent/package.json deleted file mode 100644 index 2e742d825..000000000 --- a/__fixtures__/simplest-transitive-devdependent/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/simplest-transitive-devdependent/packages/pkg-a/package.json b/__fixtures__/simplest-transitive-devdependent/packages/pkg-a/package.json deleted file mode 100644 index ee09b194d..000000000 --- a/__fixtures__/simplest-transitive-devdependent/packages/pkg-a/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} diff --git a/__fixtures__/simplest-transitive-devdependent/packages/pkg-b/package.json b/__fixtures__/simplest-transitive-devdependent/packages/pkg-b/package.json deleted file mode 100644 index 35ff69741..000000000 --- a/__fixtures__/simplest-transitive-devdependent/packages/pkg-b/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0", - "devDependencies": { "pkg-a": "1.0.0" } -} diff --git a/__fixtures__/simplest-transitive-devdependent/packages/pkg-c/package.json b/__fixtures__/simplest-transitive-devdependent/packages/pkg-c/package.json deleted file mode 100644 index 09756a7d5..000000000 --- a/__fixtures__/simplest-transitive-devdependent/packages/pkg-c/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0", - "dependencies": { "pkg-b": "1.0.0" } -} diff --git a/__fixtures__/single-package/.changeset/config.json b/__fixtures__/single-package/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/single-package/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/single-package/package.json b/__fixtures__/single-package/package.json deleted file mode 100644 index ab0e06dbf..000000000 --- a/__fixtures__/single-package/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "name": "single-package", - "description": "Nothing but the root project, a non-mono-repo", - "version": "1.0.0" -} diff --git a/__fixtures__/small-array/package.json b/__fixtures__/small-array/package.json deleted file mode 100644 index ac5884149..000000000 --- a/__fixtures__/small-array/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "files": [ - "lib" - ] -} diff --git a/__fixtures__/tab-indent/package.json b/__fixtures__/tab-indent/package.json deleted file mode 100644 index 99d048688..000000000 --- a/__fixtures__/tab-indent/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0" -} diff --git a/__fixtures__/with-git/.changeset/README.md b/__fixtures__/with-git/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/with-git/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/with-git/.changeset/changes.json b/__fixtures__/with-git/.changeset/changes.json deleted file mode 100644 index 3e9c23d47..000000000 --- a/__fixtures__/with-git/.changeset/changes.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "releases": [{ "name": "with-git", "type": "patch" }], - "dependents": [] -} diff --git a/__fixtures__/with-git/.changeset/quick-lions-devour.md b/__fixtures__/with-git/.changeset/quick-lions-devour.md deleted file mode 100644 index 3802c7428..000000000 --- a/__fixtures__/with-git/.changeset/quick-lions-devour.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"pkga-a": minor ---- - -This is a pretty bogus changeset diff --git a/__fixtures__/with-git/package.json b/__fixtures__/with-git/package.json deleted file mode 100644 index 1ce4de0b5..000000000 --- a/__fixtures__/with-git/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages", - "packages/*" - ] - } -} diff --git a/__fixtures__/with-git/packages/package.json b/__fixtures__/with-git/packages/package.json deleted file mode 100644 index d67d5464c..000000000 --- a/__fixtures__/with-git/packages/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "packages", - "version": "1.0.0" -} diff --git a/__fixtures__/with-git/packages/pkg-a/index.js b/__fixtures__/with-git/packages/pkg-a/index.js deleted file mode 100644 index 5d4a0e1d8..000000000 --- a/__fixtures__/with-git/packages/pkg-a/index.js +++ /dev/null @@ -1 +0,0 @@ -const example = "this is a test file for package A"; diff --git a/__fixtures__/with-git/packages/pkg-a/package.json b/__fixtures__/with-git/packages/pkg-a/package.json deleted file mode 100644 index 205afc493..000000000 --- a/__fixtures__/with-git/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/with-git/packages/pkg-b/index.js b/__fixtures__/with-git/packages/pkg-b/index.js deleted file mode 100644 index dce670e2a..000000000 --- a/__fixtures__/with-git/packages/pkg-b/index.js +++ /dev/null @@ -1 +0,0 @@ -const example = "this is a test file for package B"; diff --git a/__fixtures__/with-git/packages/pkg-b/package.json b/__fixtures__/with-git/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/with-git/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/with-readme/.changeset/README.md b/__fixtures__/with-readme/.changeset/README.md deleted file mode 100644 index be9cf2c5d..000000000 --- a/__fixtures__/with-readme/.changeset/README.md +++ /dev/null @@ -1 +0,0 @@ -NOPE diff --git a/__fixtures__/with-readme/.changeset/basic-changeset.md b/__fixtures__/with-readme/.changeset/basic-changeset.md deleted file mode 100644 index c232489ed..000000000 --- a/__fixtures__/with-readme/.changeset/basic-changeset.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"cool-package": minor ---- - -Nice simple summary diff --git a/__fixtures__/without-existing-changeset/package.json b/__fixtures__/without-existing-changeset/package.json deleted file mode 100644 index 080093def..000000000 --- a/__fixtures__/without-existing-changeset/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "Nothing here but .changeset folder", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } - } - \ No newline at end of file diff --git a/__fixtures__/workspace-alias-range-dep/.changeset/README.md b/__fixtures__/workspace-alias-range-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/workspace-alias-range-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/workspace-alias-range-dep/.changeset/config.json b/__fixtures__/workspace-alias-range-dep/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/workspace-alias-range-dep/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/workspace-alias-range-dep/package.json b/__fixtures__/workspace-alias-range-dep/package.json deleted file mode 100644 index 0031ef590..000000000 --- a/__fixtures__/workspace-alias-range-dep/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "workspace-alias-range-dep", - "description": "3 projects, one depending on the rest with `workspace:^` and `workspace:~` ranges", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/workspace-alias-range-dep/packages/pkg-a/package.json b/__fixtures__/workspace-alias-range-dep/packages/pkg-a/package.json deleted file mode 100644 index f03c33a1e..000000000 --- a/__fixtures__/workspace-alias-range-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "workspace:^", - "pkg-c": "workspace:~" - } -} diff --git a/__fixtures__/workspace-alias-range-dep/packages/pkg-b/package.json b/__fixtures__/workspace-alias-range-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/workspace-alias-range-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/workspace-alias-range-dep/packages/pkg-c/package.json b/__fixtures__/workspace-alias-range-dep/packages/pkg-c/package.json deleted file mode 100644 index 888ba5c7e..000000000 --- a/__fixtures__/workspace-alias-range-dep/packages/pkg-c/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0" -} diff --git a/__fixtures__/workspace-and-other-range-dep/.changeset/README.md b/__fixtures__/workspace-and-other-range-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/workspace-and-other-range-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/workspace-and-other-range-dep/.changeset/config.json b/__fixtures__/workspace-and-other-range-dep/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/workspace-and-other-range-dep/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/workspace-and-other-range-dep/package.json b/__fixtures__/workspace-and-other-range-dep/package.json deleted file mode 100644 index ebb8fb88e..000000000 --- a/__fixtures__/workspace-and-other-range-dep/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "three projects, each depending on one other", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ] -} diff --git a/__fixtures__/workspace-and-other-range-dep/packages/pkg-a/package.json b/__fixtures__/workspace-and-other-range-dep/packages/pkg-a/package.json deleted file mode 100644 index 74bdb1fa6..000000000 --- a/__fixtures__/workspace-and-other-range-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "workspace:1.0.0" - } -} diff --git a/__fixtures__/workspace-and-other-range-dep/packages/pkg-b/package.json b/__fixtures__/workspace-and-other-range-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/workspace-and-other-range-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/workspace-and-other-range-dep/packages/pkg-c/package.json b/__fixtures__/workspace-and-other-range-dep/packages/pkg-c/package.json deleted file mode 100644 index 181af8e4c..000000000 --- a/__fixtures__/workspace-and-other-range-dep/packages/pkg-c/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0", - "dependencies": { - "pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/workspace-version-alias-dep/.changeset/README.md b/__fixtures__/workspace-version-alias-dep/.changeset/README.md deleted file mode 100644 index fd188f505..000000000 --- a/__fixtures__/workspace-version-alias-dep/.changeset/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# We just want a file in here so git collects it - -For this we have deliberately not included a config file, as we want to test the defaults \ No newline at end of file diff --git a/__fixtures__/workspace-version-alias-dep/.changeset/config.json b/__fixtures__/workspace-version-alias-dep/.changeset/config.json deleted file mode 100644 index 0967ef424..000000000 --- a/__fixtures__/workspace-version-alias-dep/.changeset/config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/__fixtures__/workspace-version-alias-dep/package.json b/__fixtures__/workspace-version-alias-dep/package.json deleted file mode 100644 index 148971d3c..000000000 --- a/__fixtures__/workspace-version-alias-dep/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "simple-project", - "description": "Four projects with workspace version aliases", - "version": "1.0.0", - "bolt": { - "workspaces": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/workspace-version-alias-dep/packages/pkg-a/package.json b/__fixtures__/workspace-version-alias-dep/packages/pkg-a/package.json deleted file mode 100644 index 827bbb36d..000000000 --- a/__fixtures__/workspace-version-alias-dep/packages/pkg-a/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "pkg-a", - "version": "1.0.0", - "dependencies": { - "pkg-b": "workspace:*", - "pkg-c": "workspace:^", - "pkg-d": "workspace:~" - } -} diff --git a/__fixtures__/workspace-version-alias-dep/packages/pkg-b/package.json b/__fixtures__/workspace-version-alias-dep/packages/pkg-b/package.json deleted file mode 100644 index be4760eb1..000000000 --- a/__fixtures__/workspace-version-alias-dep/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/workspace-version-alias-dep/packages/pkg-c/package.json b/__fixtures__/workspace-version-alias-dep/packages/pkg-c/package.json deleted file mode 100644 index 888ba5c7e..000000000 --- a/__fixtures__/workspace-version-alias-dep/packages/pkg-c/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-c", - "version": "1.0.0" -} diff --git a/__fixtures__/workspace-version-alias-dep/packages/pkg-d/package.json b/__fixtures__/workspace-version-alias-dep/packages/pkg-d/package.json deleted file mode 100644 index c4b60fc4d..000000000 --- a/__fixtures__/workspace-version-alias-dep/packages/pkg-d/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "pkg-d", - "version": "1.0.0" -} diff --git a/__fixtures__/yarn-workspace-base/package.json b/__fixtures__/yarn-workspace-base/package.json deleted file mode 100644 index 1f6f2d7c7..000000000 --- a/__fixtures__/yarn-workspace-base/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "private": true, - "name": "yarn-workspace-base", - "description": "Base yarn workspace work", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ] -} diff --git a/__fixtures__/yarn-workspace-base/packages/pkg-a/package.json b/__fixtures__/yarn-workspace-base/packages/pkg-a/package.json deleted file mode 100644 index 1f60db472..000000000 --- a/__fixtures__/yarn-workspace-base/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-a", - "version": "1.0.0", - "dependencies": { - "yarn-workspace-base-pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/yarn-workspace-base/packages/pkg-b/package.json b/__fixtures__/yarn-workspace-base/packages/pkg-b/package.json deleted file mode 100644 index e88e32b57..000000000 --- a/__fixtures__/yarn-workspace-base/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/yarn-workspace-mismatched-external/package.json b/__fixtures__/yarn-workspace-mismatched-external/package.json deleted file mode 100644 index c7d908120..000000000 --- a/__fixtures__/yarn-workspace-mismatched-external/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "private": true, - "name": "yarn-workspace-base", - "description": "Base yarn workspace work", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ], - "dependencies": { - "get-workspaces": "^0.2.0" - } -} diff --git a/__fixtures__/yarn-workspace-mismatched-external/packages/pkg-a/package.json b/__fixtures__/yarn-workspace-mismatched-external/packages/pkg-a/package.json deleted file mode 100644 index ff3708174..000000000 --- a/__fixtures__/yarn-workspace-mismatched-external/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-a", - "version": "1.0.0", - "dependencies": { - "get-workspaces": "^0.2.1" - } -} diff --git a/__fixtures__/yarn-workspace-mismatched-external/packages/pkg-b/package.json b/__fixtures__/yarn-workspace-mismatched-external/packages/pkg-b/package.json deleted file mode 100644 index e88e32b57..000000000 --- a/__fixtures__/yarn-workspace-mismatched-external/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/yarn-workspace-mismatched-internal/package.json b/__fixtures__/yarn-workspace-mismatched-internal/package.json deleted file mode 100644 index 1f6f2d7c7..000000000 --- a/__fixtures__/yarn-workspace-mismatched-internal/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "private": true, - "name": "yarn-workspace-base", - "description": "Base yarn workspace work", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ] -} diff --git a/__fixtures__/yarn-workspace-mismatched-internal/packages/pkg-a/package.json b/__fixtures__/yarn-workspace-mismatched-internal/packages/pkg-a/package.json deleted file mode 100644 index 422e5941e..000000000 --- a/__fixtures__/yarn-workspace-mismatched-internal/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-a", - "version": "1.0.0", - "dependencies": { - "yarn-workspace-base-pkg-b": "^0.1.0" - } -} diff --git a/__fixtures__/yarn-workspace-mismatched-internal/packages/pkg-b/package.json b/__fixtures__/yarn-workspace-mismatched-internal/packages/pkg-b/package.json deleted file mode 100644 index e88e32b57..000000000 --- a/__fixtures__/yarn-workspace-mismatched-internal/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/yarn-workspace-missing-external/package.json b/__fixtures__/yarn-workspace-missing-external/package.json deleted file mode 100644 index a89dec011..000000000 --- a/__fixtures__/yarn-workspace-missing-external/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "private": true, - "name": "yarn-workspace-base", - "description": "Base yarn workspace work", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ], - "dependencies": {} -} diff --git a/__fixtures__/yarn-workspace-missing-external/packages/pkg-a/package.json b/__fixtures__/yarn-workspace-missing-external/packages/pkg-a/package.json deleted file mode 100644 index ff3708174..000000000 --- a/__fixtures__/yarn-workspace-missing-external/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-a", - "version": "1.0.0", - "dependencies": { - "get-workspaces": "^0.2.1" - } -} diff --git a/__fixtures__/yarn-workspace-missing-external/packages/pkg-b/package.json b/__fixtures__/yarn-workspace-missing-external/packages/pkg-b/package.json deleted file mode 100644 index e88e32b57..000000000 --- a/__fixtures__/yarn-workspace-missing-external/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/yarn-workspace-packages/package.json b/__fixtures__/yarn-workspace-packages/package.json deleted file mode 100644 index 37c577848..000000000 --- a/__fixtures__/yarn-workspace-packages/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "yarn-workspace-package", - "description": "Yarn workspace using the nested package field", - "version": "1.0.0", - "workspaces": { - "packages": [ - "packages/*" - ] - } -} diff --git a/__fixtures__/yarn-workspace-packages/packages/pkg-a/package.json b/__fixtures__/yarn-workspace-packages/packages/pkg-a/package.json deleted file mode 100644 index 8ad8fd517..000000000 --- a/__fixtures__/yarn-workspace-packages/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "yarn-workspace-package-pkg-a", - "version": "1.0.0", - "dependencies": { - "yarn-workspace-package-pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/yarn-workspace-packages/packages/pkg-b/package.json b/__fixtures__/yarn-workspace-packages/packages/pkg-b/package.json deleted file mode 100644 index bcdec0029..000000000 --- a/__fixtures__/yarn-workspace-packages/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "yarn-workspace-package-pkg-b", - "version": "1.0.0" -} diff --git a/__fixtures__/yarn-workspace-root-contains-dev-deps/package.json b/__fixtures__/yarn-workspace-root-contains-dev-deps/package.json deleted file mode 100644 index 83991ba68..000000000 --- a/__fixtures__/yarn-workspace-root-contains-dev-deps/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "private": true, - "name": "yarn-workspace-root-contains-dev-deps", - "description": "Base yarn workspace work", - "version": "1.0.0", - "workspaces": [ - "packages/*" - ], - "dependencies": { - "react": "^16.8.6" - }, - "devDependencies": { - "react-test-renderer": "^16.8.6" - } -} diff --git a/__fixtures__/yarn-workspace-root-contains-dev-deps/packages/pkg-a/package.json b/__fixtures__/yarn-workspace-root-contains-dev-deps/packages/pkg-a/package.json deleted file mode 100644 index 1f60db472..000000000 --- a/__fixtures__/yarn-workspace-root-contains-dev-deps/packages/pkg-a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-a", - "version": "1.0.0", - "dependencies": { - "yarn-workspace-base-pkg-b": "1.0.0" - } -} diff --git a/__fixtures__/yarn-workspace-root-contains-dev-deps/packages/pkg-b/package.json b/__fixtures__/yarn-workspace-root-contains-dev-deps/packages/pkg-b/package.json deleted file mode 100644 index e88e32b57..000000000 --- a/__fixtures__/yarn-workspace-root-contains-dev-deps/packages/pkg-b/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "yarn-workspace-base-pkg-b", - "version": "1.0.0" -} diff --git a/package.json b/package.json index bc0aa67ec..a16c21516 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "url": "https://github.com/changesets/changesets.git" }, "workspaces": [ - "packages/*" + "packages/*", + "scripts/*" ], "author": "Changesets Contributors", "contributors": [ @@ -68,7 +69,8 @@ }, "preconstruct": { "packages": [ - "packages/*" + "packages/*", + "scripts/*" ] }, "prettier": {} diff --git a/packages/apply-release-plan/package.json b/packages/apply-release-plan/package.json index 90e398936..472f8c3c0 100644 --- a/packages/apply-release-plan/package.json +++ b/packages/apply-release-plan/package.json @@ -23,7 +23,6 @@ }, "devDependencies": { "@changesets/test-utils": "*", - "fixturez": "^1.1.0", "spawndamnit": "^2.0.0" } } diff --git a/packages/apply-release-plan/src/index.test.ts b/packages/apply-release-plan/src/index.test.ts index c73cc3f2d..2862514c8 100644 --- a/packages/apply-release-plan/src/index.test.ts +++ b/packages/apply-release-plan/src/index.test.ts @@ -1,4 +1,3 @@ -import fixtures from "fixturez"; import { ReleasePlan, Config, @@ -14,9 +13,11 @@ import { defaultConfig } from "@changesets/config"; import applyReleasePlan from "./"; import { getPackages } from "@manypkg/get-packages"; -import { temporarilySilenceLogs } from "@changesets/test-utils"; - -const f = fixtures(__dirname); +import { + temporarilySilenceLogs, + testdir, + Fixture, +} from "@changesets/test-utils"; class FakeReleasePlan { changesets: NewChangeset[]; @@ -75,7 +76,7 @@ class FakeReleasePlan { } async function testSetup( - fixtureName: string, + fixture: Fixture, releasePlan: ReleasePlan, config?: Config, snapshot?: string | undefined, @@ -102,7 +103,8 @@ async function testSetup( }, }; } - let tempDir = await f.copy(fixtureName); + let tempDir = await testdir(fixture); + if (setupFunc) { await setupFunc(tempDir); } @@ -130,7 +132,15 @@ describe("apply release plan", () => { it("should not reformat a small array in a package.json", async () => { const releasePlan = new FakeReleasePlan(); let { changedFiles } = await testSetup( - "small-array", + { + "package.json": `{ + "name": "pkg-a", + "version": "1.0.0", + "files": [ + "lib" + ] +}`, + }, releasePlan.getReleasePlan(), releasePlan.config ); @@ -145,13 +155,21 @@ describe("apply release plan", () => { "files": [ "lib" ] -} -`); +}`); }); it("should not change tab indentation in a package.json", async () => { const releasePlan = new FakeReleasePlan(); let { changedFiles } = await testSetup( - "tab-indent", + { + "package.json": JSON.stringify( + { + name: "pkg-a", + version: "1.0.0", + }, + null, + "\t" + ), + }, releasePlan.getReleasePlan(), releasePlan.config ); @@ -163,13 +181,17 @@ describe("apply release plan", () => { expect(pkgJSON).toStrictEqual(`{ \t"name": "pkg-a", \t"version": "1.1.0" -} -`); +}`); }); it("should not add trailing newlines in a package.json if they don't exist", async () => { const releasePlan = new FakeReleasePlan(); let { changedFiles } = await testSetup( - "no-trailing-newline", + { + "package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), releasePlan.config ); @@ -183,12 +205,44 @@ describe("apply release plan", () => { "version": "1.1.0" }`); }); + it("should not remove trailing newlines in a package.json if they exist", async () => { + const releasePlan = new FakeReleasePlan(); + let { changedFiles } = await testSetup( + { + "package.json": + JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }) + "\n", + }, + releasePlan.getReleasePlan(), + releasePlan.config + ); + let pkgPath = changedFiles.find((a) => a.endsWith(`package.json`)); + + if (!pkgPath) throw new Error(`could not find an updated package json`); + let pkgJSON = await fs.readFile(pkgPath, { encoding: "utf-8" }); + + expect(pkgJSON).toStrictEqual(`{ + "name": "pkg-a", + "version": "1.1.0" +}\n`); + }); }); it("should update a version for one package", async () => { const releasePlan = new FakeReleasePlan(); let { changedFiles } = await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), releasePlan.config ); @@ -224,7 +278,23 @@ describe("apply release plan", () => { ] ); let { changedFiles } = await testSetup( - "simple-star-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "*", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), releasePlan.config ); @@ -263,7 +333,23 @@ describe("apply release plan", () => { ] ); let { changedFiles } = await testSetup( - "simple-workspace-range-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), releasePlan.config ); @@ -326,7 +412,33 @@ describe("apply release plan", () => { ] ); let { changedFiles } = await testSetup( - "workspace-version-alias-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:*", + "pkg-c": "workspace:^", + "pkg-d": "workspace:~", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "1.0.0", + }), + "packages/pkg-d/package.json": JSON.stringify({ + name: "pkg-d", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), releasePlan.config ); @@ -380,7 +492,30 @@ describe("apply release plan", () => { } ); let { changedFiles } = await testSetup( - "workspace-and-other-range-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + }, releasePlan.getReleasePlan(), releasePlan.config ); @@ -429,7 +564,23 @@ describe("apply release plan", () => { ); let { changedFiles } = await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), releasePlan.config ); @@ -457,7 +608,23 @@ describe("apply release plan", () => { }); it("should not update the version of the dependent package if the released dep is a dev dep", async () => { let { changedFiles } = await testSetup( - "simple-dev-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + devDependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, { changesets: [ { @@ -533,8 +700,16 @@ describe("apply release plan", () => { }); }); it("should skip dependencies that have the same name as the package", async () => { - let { changedFiles } = await testSetup( - "self-referenced", + let { tempDir } = await testSetup( + { + "package.json": JSON.stringify({ + name: "self-referenced", + version: "1.0.0", + devDependencies: { + "self-referenced": "file:", + }, + }), + }, { changesets: [ { @@ -574,12 +749,8 @@ describe("apply release plan", () => { }, } ); - let pkgPath = changedFiles.find((a) => - a.endsWith(`self-referenced${path.sep}package.json`) - ); - if (!pkgPath) throw new Error(`could not find an updated package json`); - let pkgJSON = await fs.readJSON(pkgPath); + let pkgJSON = await fs.readJSON(path.join(tempDir, "package.json")); expect(pkgJSON).toMatchObject({ name: "self-referenced", @@ -591,7 +762,23 @@ describe("apply release plan", () => { }); it("should not update dependent versions when a package has a changeset type of none", async () => { let { changedFiles } = await testSetup( - "simple-project-caret-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "^1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, { changesets: [ { @@ -632,7 +819,23 @@ describe("apply release plan", () => { }); it("should not update workspace dependent versions when a package has a changeset type of none", async () => { let { changedFiles } = await testSetup( - "simple-workspace-range-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, { changesets: [ { @@ -691,7 +894,23 @@ describe("apply release plan", () => { ] ); let { changedFiles } = await testSetup( - "simple-project-caret-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "^1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), releasePlan.config, "canary" @@ -718,7 +937,26 @@ describe("apply release plan", () => { const updateInternalDependencies = "patch"; it("should update min version ranges of patch bumped internal dependencies", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -792,14 +1030,40 @@ describe("apply release plan", () => { name: "pkg-b", version: "1.2.1", dependencies: { - "pkg-c": "2.0.0", "pkg-a": "^1.0.4", }, }); }); it("should still update min version ranges of patch bumped internal dependencies that have left semver range", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-c": "2.0.0", + "pkg-a": "^1.0.3", + }, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "2.0.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -888,7 +1152,26 @@ describe("apply release plan", () => { }); it("should update min version ranges of minor bumped internal dependencies", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -962,14 +1245,32 @@ describe("apply release plan", () => { name: "pkg-b", version: "1.2.1", dependencies: { - "pkg-c": "2.0.0", "pkg-a": "^1.1.0", }, }); }); it("should update min version ranges of major bumped internal dependencies", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -1043,7 +1344,6 @@ describe("apply release plan", () => { name: "pkg-b", version: "1.2.1", dependencies: { - "pkg-c": "2.0.0", "pkg-a": "^2.0.0", }, }); @@ -1053,7 +1353,26 @@ describe("apply release plan", () => { const updateInternalDependencies = "minor"; it("should NOT update min version ranges of patch bumped internal dependencies", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -1127,14 +1446,40 @@ describe("apply release plan", () => { name: "pkg-b", version: "1.2.1", dependencies: { - "pkg-c": "2.0.0", "pkg-a": "^1.0.3", }, }); }); it("should still update min version ranges of patch bumped internal dependencies that have left semver range", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-c": "2.0.0", + "pkg-a": "^1.0.3", + }, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "2.0.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -1223,7 +1568,34 @@ describe("apply release plan", () => { }); it("should update min version ranges of minor bumped internal dependencies", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-c": "2.0.0", + "pkg-a": "^1.0.3", + }, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "2.0.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -1297,14 +1669,32 @@ describe("apply release plan", () => { name: "pkg-b", version: "1.2.1", dependencies: { - "pkg-c": "2.0.0", "pkg-a": "^1.1.0", }, }); }); it("should update min version ranges of major bumped internal dependencies", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -1378,7 +1768,6 @@ describe("apply release plan", () => { name: "pkg-b", version: "1.2.1", dependencies: { - "pkg-c": "2.0.0", "pkg-a": "^2.0.0", }, }); @@ -1389,15 +1778,31 @@ describe("apply release plan", () => { describe("onlyUpdatePeerDependentsWhenOutOfRange set to true", () => { it("should not bump peerDependencies if they are still in range", async () => { let { changedFiles } = await testSetup( - "simple-caret-peer-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/depended-upon/package.json": JSON.stringify({ + name: "depended-upon", + version: "1.0.0", + }), + "packages/has-peer-dep/package.json": JSON.stringify({ + name: "has-peer-dep", + version: "1.0.0", + peerDependencies: { + "depended-upon": "^1.0.0", + }, + }), + }, { changesets: [ { id: "quick-lions-devour", summary: "Hey, let's have fun with testing!", releases: [ - { name: "has-peer-dep", type: "patch" }, { name: "depended-upon", type: "patch" }, + { name: "has-peer-dep", type: "patch" }, ], }, ], @@ -1470,7 +1875,16 @@ describe("apply release plan", () => { it("should not generate any changelogs", async () => { const releasePlan = new FakeReleasePlan(); let { changedFiles } = await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), { ...releasePlan.config, @@ -1485,7 +1899,16 @@ describe("apply release plan", () => { it("should update a changelog for one package", async () => { const releasePlan = new FakeReleasePlan(); let { changedFiles } = await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), { ...releasePlan.config, @@ -1526,7 +1949,23 @@ describe("apply release plan", () => { ); let { changedFiles } = await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), { ...releasePlan.config, @@ -1567,7 +2006,23 @@ describe("apply release plan", () => { }); it("should not update the changelog if only devDeps changed", async () => { let { changedFiles } = await testSetup( - "simple-dev-dep", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + devDependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, { changesets: [ { @@ -1643,7 +2098,16 @@ describe("apply release plan", () => { releasePlan.releases[0].changesets.push("some-id-1", "some-id-2"); let { changedFiles } = await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), { ...releasePlan.config, @@ -1676,7 +2140,26 @@ describe("apply release plan", () => { it("should add an updated dependencies line when dependencies have been updated", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -1765,7 +2248,26 @@ describe("apply release plan", () => { it("should NOT add updated dependencies line if dependencies have NOT been updated", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -1850,7 +2352,34 @@ describe("apply release plan", () => { it("should only add updated dependencies line for dependencies that have been updated", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-c": "2.0.0", + "pkg-a": "^1.0.3", + }, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "2.0.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -1957,7 +2486,34 @@ describe("apply release plan", () => { it("should still add updated dependencies line for dependencies that have a bump type less than the minimum internal bump range but leave semver range", async () => { let { changedFiles } = await testSetup( - "internal-dependencies", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-c": "2.0.0", + "pkg-a": "^1.0.3", + }, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "2.0.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }, { changesets: [ { @@ -2068,32 +2624,44 @@ describe("apply release plan", () => { it.skip("a package appears twice", async () => { let changedFiles; try { - let testResults = await testSetup("simple-project", { - changesets: [ - { - id: "quick-lions-devour", - summary: "Hey, let's have fun with testing!", - releases: [{ name: "pkg-a", type: "minor" }], - }, - ], - releases: [ - { - name: "pkg-a", - type: "minor", - oldVersion: "1.0.0", - newVersion: "1.1.0", - changesets: ["quick-lions-devour"], - }, - { + let testResults = await testSetup( + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ name: "pkg-a", - type: "minor", - oldVersion: "1.0.0", - newVersion: "1.1.0", - changesets: ["quick-lions-devour"], - }, - ], - preState: undefined, - }); + version: "1.0.0", + }), + }, + { + changesets: [ + { + id: "quick-lions-devour", + summary: "Hey, let's have fun with testing!", + releases: [{ name: "pkg-a", type: "minor" }], + }, + ], + releases: [ + { + name: "pkg-a", + type: "minor", + oldVersion: "1.0.0", + newVersion: "1.1.0", + changesets: ["quick-lions-devour"], + }, + { + name: "pkg-a", + type: "minor", + oldVersion: "1.0.0", + newVersion: "1.1.0", + changesets: ["quick-lions-devour"], + }, + ], + preState: undefined, + } + ); changedFiles = testResults.changedFiles; } catch (e) { expect((e as Error).message).toEqual("some string probably"); @@ -2121,7 +2689,23 @@ describe("apply release plan", () => { ] ); - let tempDir = await f.copy("with-git"); + let tempDir = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await spawn("git", ["init"], { cwd: tempDir }); @@ -2154,7 +2738,23 @@ describe("apply release plan", () => { temporarilySilenceLogs(async () => { let releasePlan = new FakeReleasePlan(); - let tempDir = await f.copy("with-git"); + let tempDir = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await spawn("git", ["init"], { cwd: tempDir }); @@ -2210,12 +2810,21 @@ describe("apply release plan", () => { const thisPath = path.resolve(tempDir, ".changeset", `${id}.md`); changesetPath = thisPath; const content = `---\n---\n${summary}`; - fs.writeFile(thisPath, content); + return fs.outputFile(thisPath, content); }) ); await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), releasePlan.config, undefined, @@ -2237,12 +2846,21 @@ describe("apply release plan", () => { const thisPath = path.resolve(tempDir, ".changeset", `${id}.md`); changesetPath = thisPath; const content = `---\n---\n${summary}`; - fs.writeFile(thisPath, content); + return fs.outputFile(thisPath, content); }) ); await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), { ...releasePlan.config, ignore: ["pkg-a"] }, undefined, @@ -2285,7 +2903,16 @@ describe("apply release plan", () => { ); await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), releasePlan.config, undefined, @@ -2332,7 +2959,16 @@ describe("apply release plan", () => { ); let { tempDir } = await testSetup( - "simple-project", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), { ...releasePlan.config, @@ -2377,7 +3013,23 @@ describe("apply release plan", () => { const releasePlan = new FakeReleasePlan(); let { tempDir } = await testSetup( - "with-git", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), { ...releasePlan.config, @@ -2414,12 +3066,28 @@ describe("apply release plan", () => { const thisPath = path.resolve(tempDir, ".changeset", `${id}.md`); changesetPath = thisPath; const content = `---\n---\n${summary}`; - fs.writeFile(thisPath, content); + return fs.outputFile(thisPath, content); }) ); let { tempDir } = await testSetup( - "with-git", + { + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }, releasePlan.getReleasePlan(), { ...releasePlan.config, diff --git a/packages/cli/package.json b/packages/cli/package.json index cf49f4300..fa3b89161 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -67,7 +67,6 @@ "devDependencies": { "@changesets/parse": "*", "@changesets/test-utils": "*", - "fixturez": "^1.1.0", "strip-ansi": "^5.2.0" } } diff --git a/packages/cli/src/commands/add/__tests__/add.ts b/packages/cli/src/commands/add/__tests__/add.ts index 5e62b4506..25a87422d 100644 --- a/packages/cli/src/commands/add/__tests__/add.ts +++ b/packages/cli/src/commands/add/__tests__/add.ts @@ -1,9 +1,8 @@ import path from "path"; -import fixtures from "fixturez"; import stripAnsi from "strip-ansi"; import * as git from "@changesets/git"; import { defaultConfig } from "@changesets/config"; -import { silenceLogsInBlock } from "@changesets/test-utils"; +import { silenceLogsInBlock, testdir } from "@changesets/test-utils"; import writeChangeset from "@changesets/write"; import { @@ -15,8 +14,6 @@ import { } from "../../../utils/cli-utilities"; import addChangeset from ".."; -const f = fixtures(__dirname); - jest.mock("../../../utils/cli-utilities"); jest.mock("@changesets/git"); jest.mock("@changesets/write"); @@ -91,7 +88,20 @@ describe("Changesets", () => { silenceLogsInBlock(); it("should generate changeset to patch a single package", async () => { - const cwd = await f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); mockUserResponses({ releases: { "pkg-a": "patch" } }); await addChangeset(cwd, { empty: false }, defaultConfig); @@ -116,7 +126,20 @@ describe("Changesets", () => { "should read summary", // @ts-ignore async ({ consoleSummaries, editorSummaries, expectedSummary }) => { - const cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); mockUserResponses({ releases: { "pkg-a": "patch" }, @@ -137,7 +160,13 @@ describe("Changesets", () => { ); it("should generate a changeset in a single package repo", async () => { - const cwd = f.copy("single-package"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + name: "single-package", + version: "1.0.0", + }), + }); const summary = "summary message mock"; @@ -175,7 +204,23 @@ describe("Changesets", () => { }); it("should commit when the commit flag is passed in", async () => { - const cwd = f.copy("simple-project-custom-config"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); mockUserResponses({ releases: { "pkg-a": "patch" } }); await addChangeset( @@ -191,7 +236,16 @@ describe("Changesets", () => { }); it("should create empty changeset when empty flag is passed in", async () => { - const cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }); await addChangeset(cwd, { empty: true }, defaultConfig); @@ -206,7 +260,34 @@ describe("Changesets", () => { }); it("should not include ignored packages in the prompt", async () => { - const cwd = f.copy("internal-dependencies"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.3", + dependencies: { + "pkg-b": "~1.2.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.2.0", + dependencies: { + "pkg-c": "2.0.0", + "pkg-a": "^1.0.3", + }, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "2.0.0", + dependencies: { + "pkg-a": "^1.0.3", + }, + }), + }); mockUserResponses({ releases: { "pkg-a": "patch" } }); await addChangeset( @@ -221,7 +302,24 @@ describe("Changesets", () => { }); it("should not include private packages without a version in the prompt", async () => { - const cwd = f.copy("private-package-without-version-field"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + private: true, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "1.0.0", + }), + }); mockUserResponses({ releases: { "pkg-a": "patch" } }); await addChangeset(cwd, { empty: false }, defaultConfig); @@ -232,7 +330,25 @@ describe("Changesets", () => { }); it("should not include private packages with a version in the prompt if private packages are configured to be not versionable", async () => { - const cwd = f.copy("private-package-with-version-field"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + private: true, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "1.0.0", + }), + }); mockUserResponses({ releases: { "pkg-a": "patch" } }); await addChangeset( diff --git a/packages/cli/src/commands/init/__tests__/command.ts b/packages/cli/src/commands/init/__tests__/command.ts index 57dca15e5..277c09cbb 100644 --- a/packages/cli/src/commands/init/__tests__/command.ts +++ b/packages/cli/src/commands/init/__tests__/command.ts @@ -1,13 +1,10 @@ -import fixtures from "fixturez"; import fs from "fs-extra"; import path from "path"; import { defaultWrittenConfig } from "@changesets/config"; -import { silenceLogsInBlock } from "@changesets/test-utils"; +import { silenceLogsInBlock, testdir } from "@changesets/test-utils"; import initializeCommand from ".."; -const f = fixtures(__dirname); - const getPaths = (cwd: string) => ({ readmePath: path.join(cwd, ".changeset/README.md"), configPath: path.join(cwd, ".changeset/config.json"), @@ -16,7 +13,7 @@ const getPaths = (cwd: string) => ({ describe("init", () => { silenceLogsInBlock(); it("should initialize in a project without a .changeset folder", async () => { - const cwd = await f.copy("without-existing-changeset"); + const cwd = await testdir({}); const { readmePath, configPath } = getPaths(cwd); expect(fs.pathExistsSync(readmePath)).toBe(false); @@ -26,20 +23,25 @@ describe("init", () => { expect(fs.pathExistsSync(configPath)).toBe(true); }); it("should write the default config if it doesn't exist", async () => { - const cwd = await f.copy("simple-project"); - await fs.remove(path.join(cwd, ".changeset/config.json")); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + }); - expect(fs.pathExistsSync(path.join(cwd, ".changeset/README.md"))).toBe( - true - ); await initializeCommand(cwd); expect(await fs.readJson(path.join(cwd, ".changeset/config.json"))).toEqual( { ...defaultWrittenConfig, baseBranch: "main" } ); }); it("should add newline at the end of config", async () => { - const cwd = await f.copy("simple-project"); - await fs.remove(path.join(cwd, ".changeset/config.json")); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + }); await initializeCommand(cwd); @@ -50,14 +52,16 @@ describe("init", () => { expect(lastCharacter).toBe("\n"); }); it("shouldn't overwrite a config if it does exist", async () => { - const cwd = await f.copy("simple-project"); - await fs.writeJson(path.join(cwd, ".changeset/config.json"), { - changelog: false, + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + ".changeset/config.json": JSON.stringify({ + changelog: false, + }), }); - expect(fs.pathExistsSync(path.join(cwd, ".changeset/README.md"))).toBe( - true - ); await initializeCommand(cwd); expect(await fs.readJson(path.join(cwd, ".changeset/config.json"))).toEqual( { diff --git a/packages/cli/src/commands/pre/index.test.ts b/packages/cli/src/commands/pre/index.test.ts index fb476cf0d..1a435adf3 100644 --- a/packages/cli/src/commands/pre/index.test.ts +++ b/packages/cli/src/commands/pre/index.test.ts @@ -1,57 +1,52 @@ -import fixturez from "fixturez"; import path from "path"; import chalk from "chalk"; import * as fs from "fs-extra"; -import { PreState } from "@changesets/types"; import * as logger from "@changesets/logger"; import { ExitError } from "@changesets/errors"; +import { testdir } from "@changesets/test-utils"; import pre from "./index"; -let f = fixturez(__dirname); - -let preStateForSimpleProject: PreState = { - changesets: [], - initialVersions: { - "pkg-a": "1.0.0", - "pkg-b": "1.0.0", - }, - mode: "pre", - tag: "next", -}; - -let preStateForExited: PreState = { - changesets: ["slimy-dingos-whisper"], - initialVersions: { - "pkg-a": "1.0.0", - "pkg-b": "1.0.0", - }, - mode: "exit", - tag: "beta", -}; - jest.mock("@changesets/logger"); let mockedLogger = logger as jest.Mocked; describe("enterPre", () => { it("should enter", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + }); await pre(cwd, { command: "enter", tag: "next" }); - expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))).toEqual( - preStateForSimpleProject - ); + expect( + await fs.readJson(path.join(cwd, ".changeset", "pre.json")) + ).toMatchObject({ + changesets: [], + initialVersions: {}, + mode: "pre", + tag: "next", + }); expect(mockedLogger.success).toBeCalledWith( `Entered pre mode with tag ${chalk.cyan("next")}` ); }); it("should throw if already in pre", async () => { - let cwd = f.copy("simple-project"); - await fs.writeJSON( - path.join(cwd, ".changeset", "pre.json"), - preStateForSimpleProject - ); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + ".changeset/pre.json": JSON.stringify({ + changesets: [], + initialVersions: {}, + mode: "pre", + tag: "next", + }), + }); + await expect( pre(cwd, { command: "enter", tag: "next" }) ).rejects.toBeInstanceOf(ExitError); @@ -63,15 +58,24 @@ describe("enterPre", () => { ); }); it("should enter if already exited pre mode", async () => { - let cwd = f.copy("simple-project"); - await fs.writeJSON( - path.join(cwd, ".changeset", "pre.json"), - preStateForExited - ); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + ".changeset/pre.json": JSON.stringify({ + changesets: [], + initialVersions: {}, + mode: "exit", + tag: "beta", + }), + }); + await pre(cwd, { command: "enter", tag: "next" }); expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))).toEqual( { - ...preStateForExited, + changesets: [], + initialVersions: {}, mode: "pre", tag: "next", } @@ -84,19 +88,36 @@ describe("enterPre", () => { describe("exitPre", () => { it("should exit", async () => { - let cwd = f.copy("simple-project"); - await fs.writeJSON( - path.join(cwd, ".changeset", "pre.json"), - preStateForSimpleProject - ); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + ".changeset/pre.json": JSON.stringify({ + changesets: [], + initialVersions: {}, + mode: "pre", + tag: "next", + }), + }); await pre(cwd, { command: "exit" }); expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))).toEqual( - { ...preStateForSimpleProject, mode: "exit" } + { + changesets: [], + initialVersions: {}, + mode: "exit", + tag: "next", + } ); }); it("should throw if not in pre", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + }); await expect(pre(cwd, { command: "exit" })).rejects.toBeInstanceOf( ExitError ); diff --git a/packages/cli/src/commands/publish/__tests__/index.test.ts b/packages/cli/src/commands/publish/__tests__/index.test.ts index f12c2d627..0e32f9a01 100644 --- a/packages/cli/src/commands/publish/__tests__/index.test.ts +++ b/packages/cli/src/commands/publish/__tests__/index.test.ts @@ -1,10 +1,8 @@ -import fixtures from "fixturez"; import publishCommand from "../index"; import { defaultConfig } from "@changesets/config"; import * as path from "path"; -import * as pre from "@changesets/pre"; import { Config } from "@changesets/types"; -import { silenceLogsInBlock } from "@changesets/test-utils"; +import { silenceLogsInBlock, testdir } from "@changesets/test-utils"; let changelogPath = path.resolve(__dirname, "../../changelog"); let modifiedDefaultConfig: Config = { @@ -12,25 +10,24 @@ let modifiedDefaultConfig: Config = { changelog: [changelogPath, null], }; -const f = fixtures(__dirname); - -jest.mock("../npm-utils.ts"); -jest.mock("../publishPackages.ts"); -jest.mock("@changesets/pre"); - describe("Publish command", () => { silenceLogsInBlock(); - let cwd: string; - beforeEach(async () => { - cwd = await f.copy("simple-project"); - }); describe("in pre state", () => { - beforeEach(() => { - // @ts-ignore - pre.readPreState.mockImplementation(() => ({ mode: "pre" })); - }); it("should report error if the tag option is used in pre release", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + ".changeset/pre.json": JSON.stringify({ + mode: "pre", + }), + }); await expect( publishCommand(cwd, { tag: "experimental" }, modifiedDefaultConfig) ).rejects.toThrowError(); diff --git a/packages/cli/src/commands/publish/__tests__/publishPackages.test.ts b/packages/cli/src/commands/publish/__tests__/publishPackages.test.ts index 29ca9eb41..58a327b9b 100644 --- a/packages/cli/src/commands/publish/__tests__/publishPackages.test.ts +++ b/packages/cli/src/commands/publish/__tests__/publishPackages.test.ts @@ -1,35 +1,13 @@ -import fixtures from "fixturez"; - import publishPackages from "../publishPackages"; import * as npmUtils from "../npm-utils"; import { getPackages } from "@manypkg/get-packages"; -import { silenceLogsInBlock } from "@changesets/test-utils"; +import { silenceLogsInBlock, testdir } from "@changesets/test-utils"; jest.mock("../npm-utils"); jest.mock("is-ci", () => true); -const f = fixtures(__dirname); - describe("publishPackages", () => { silenceLogsInBlock(); - let cwd: string; - - beforeEach(async () => { - cwd = await f.copy("simple-project"); - - // @ts-ignore - npmUtils.infoAllow404.mockImplementation(() => ({ - published: false, - pkgInfo: { - version: "1.0.0", - }, - })); - - // @ts-ignore - npmUtils.publish.mockImplementation(() => ({ - published: true, - })); - }); afterEach(() => { jest.clearAllMocks(); @@ -37,6 +15,30 @@ describe("publishPackages", () => { describe("when isCI", () => { it("does not call out to npm to see if otp is required", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }); + + // @ts-ignore + npmUtils.infoAllow404.mockImplementation(() => ({ + published: false, + pkgInfo: { + version: "1.0.0", + }, + })); + + // @ts-ignore + npmUtils.publish.mockImplementation(() => ({ + published: true, + })); + await publishPackages({ packages: (await getPackages(cwd)).packages, access: "public", diff --git a/packages/cli/src/commands/publish/__tests__/releaseCommand.test.ts b/packages/cli/src/commands/publish/__tests__/releaseCommand.test.ts index 5c5427046..24f57b768 100644 --- a/packages/cli/src/commands/publish/__tests__/releaseCommand.test.ts +++ b/packages/cli/src/commands/publish/__tests__/releaseCommand.test.ts @@ -1,39 +1,21 @@ -import fixtures from "fixturez"; - import publishPackages from "../publishPackages"; import * as git from "@changesets/git"; import { defaultConfig } from "@changesets/config"; -import { silenceLogsInBlock } from "@changesets/test-utils"; +import { silenceLogsInBlock, testdir } from "@changesets/test-utils"; import runRelease from ".."; jest.mock("../../../utils/cli-utilities"); jest.mock("@changesets/git"); jest.mock("../publishPackages"); -const f = fixtures(__dirname); - // @ts-ignore git.tag.mockImplementation(() => Promise.resolve(true)); -// we want to keep other bolt commands still running so our tests are more e2e -// NOTE: This is pretty terrible. Quite obviously bolt is not going to return these results -// each time, but there is only one test that uses the output of this function ('should add git tags') -// and we know this will be heavily refactored once its moved into the bolt org anyway. So we are happy -// to keep this debt in for now. LB takes full responsibility for this if it becomes flakey. - -// @ts-ignore -publishPackages.mockImplementation(() => - Promise.resolve([ - { name: "pkg-a", newVersion: "1.1.0", published: true }, - { name: "pkg-b", newVersion: "1.0.1", published: true }, - ]) -); describe("running release", () => { silenceLogsInBlock(); - let cwd: string; - beforeEach(async () => { - cwd = f.copy("simple-project"); + afterEach(() => { + jest.clearAllMocks(); }); describe("When there is no changeset commits", () => { @@ -41,6 +23,32 @@ describe("running release", () => { // failed one (where the change was pushed back but not released and the next build has no // changeset commits) it("should still run publishPackages", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + + // @ts-ignore + publishPackages.mockImplementation(() => + Promise.resolve([ + { name: "pkg-a", newVersion: "1.1.0", published: true }, + { name: "pkg-b", newVersion: "1.0.1", published: true }, + ]) + ); + await runRelease(cwd, {}, defaultConfig); expect(publishPackages).toHaveBeenCalled(); diff --git a/packages/cli/src/commands/status/__tests__/status.ts b/packages/cli/src/commands/status/__tests__/status.ts index f8b2bfb5d..ac51e482f 100644 --- a/packages/cli/src/commands/status/__tests__/status.ts +++ b/packages/cli/src/commands/status/__tests__/status.ts @@ -1,105 +1,108 @@ -import fixtures from "fixturez"; import fs from "fs-extra"; import path from "path"; import * as git from "@changesets/git"; import { defaultConfig } from "@changesets/config"; -import { silenceLogsInBlock } from "@changesets/test-utils"; +import { silenceLogsInBlock, testdir } from "@changesets/test-utils"; import writeChangeset from "@changesets/write"; import status from ".."; import humanId from "human-id"; -import { NewChangeset, ReleasePlan } from "@changesets/types"; -import { Package } from "@manypkg/get-packages"; jest.mock("human-id"); jest.mock("@changesets/git"); -const f = fixtures(__dirname); - -const simpleChangeset: NewChangeset = { - id: "fake-ids-abound", - summary: "This is a summary", - releases: [ - { name: "pkg-a", type: "minor" }, - { name: "pkg-b", type: "patch" }, - ], -}; - -const simpleReleasePlan: ReleasePlan = { - releases: [ - { - name: "pkg-a", - type: "minor", - changesets: ["ascii"], - oldVersion: "1.0.0", - newVersion: "1.1.0", - }, - { - name: "pkg-b", - type: "patch", - changesets: ["ascii"], - oldVersion: "1.0.0", - newVersion: "1.0.1", - }, - ], - changesets: [ - { - summary: "This is a summary", - releases: [ - { name: "pkg-a", type: "minor" }, - { name: "pkg-b", type: "patch" }, - ], - id: "ascii", - }, - ], - preState: undefined, -}; - -const simpleChangedPackagesList: Package[] = [ - { - packageJson: { name: "pkg-a", version: "1.0.0", dependencies: {} }, - dir: "/fake/folder/doesnt/matter", - }, - { - packageJson: { name: "pkg-b", version: "1.0.0" }, - dir: "/fake/folder/doesnt/matter", - }, -]; - -const writeChangesets = (changesets: NewChangeset[], cwd: string) => { - return Promise.all(changesets.map((commit) => writeChangeset(commit, cwd))); -}; - describe("status", () => { silenceLogsInBlock(); - let cwd: string; - beforeEach(async () => { - cwd = await f.copy("simple-project"); + afterEach(() => { + jest.clearAllMocks(); }); it("should get the status for a simple changeset and return the release object", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); + const changesetID = "ascii"; // @ts-ignore humanId.mockReturnValueOnce(changesetID); // @ts-ignore - git.getChangedPackagesSinceRef.mockImplementation( - () => simpleChangedPackagesList + git.getChangedPackagesSinceRef.mockImplementation(() => [ + { + packageJson: { name: "pkg-a", version: "1.0.0" }, + dir: "/fake/folder/doesnt/matter", + }, + ]); + + await writeChangeset( + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + cwd ); - - await writeChangesets([simpleChangeset], cwd); const releaseObj = await status(cwd, {}, defaultConfig); - expect(releaseObj).toEqual(simpleReleasePlan); + expect(releaseObj).toMatchInlineSnapshot(` + Object { + "changesets": Array [ + Object { + "id": "ascii", + "releases": Array [ + Object { + "name": "pkg-a", + "type": "minor", + }, + ], + "summary": "This is a summary", + }, + ], + "preState": undefined, + "releases": Array [ + Object { + "changesets": Array [ + "ascii", + ], + "name": "pkg-a", + "newVersion": "1.1.0", + "oldVersion": "1.0.0", + "type": "minor", + }, + ], + } + `); }); it("should exit early with a non-zero error code when there are changed packages but no changesets", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); + // @ts-ignore jest.spyOn(process, "exit").mockImplementation(() => {}); // @ts-ignore - git.getChangedPackagesSinceRef.mockImplementation( - () => simpleChangedPackagesList - ); + git.getChangedPackagesSinceRef.mockImplementation(() => [ + { + packageJson: { name: "pkg-a", version: "1.0.0" }, + dir: "/fake/folder/doesnt/matter", + }, + ]); await status(cwd, {}, defaultConfig); @@ -107,6 +110,18 @@ describe("status", () => { }); it("should not exit early with a non-zero error code when there are no changed packages", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); + // @ts-ignore jest.spyOn(process, "exit").mockImplementation(() => {}); // @ts-ignore @@ -123,41 +138,108 @@ describe("status", () => { }); it("should not exit early with a non-zero code when there are changed packages and also a changeset", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); + // @ts-ignore jest.spyOn(process, "exit").mockImplementation(() => {}); // @ts-ignore - git.getChangedPackagesSinceRef.mockImplementation( - () => simpleChangedPackagesList - ); + git.getChangedPackagesSinceRef.mockImplementation(() => [ + { + packageJson: { name: "pkg-a", version: "1.0.0" }, + dir: "/fake/folder/doesnt/matter", + }, + ]); const changesetID = "ascii"; // @ts-ignore humanId.mockReturnValueOnce(changesetID); - await writeChangesets([simpleChangeset], cwd); - const releaseObj = await status(cwd, {}, defaultConfig); + await writeChangeset( + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + cwd + ); + await status(cwd, {}, defaultConfig); - expect(releaseObj).toEqual(simpleReleasePlan); expect(process.exit).not.toHaveBeenCalled(); }); it.skip("should respect the verbose flag", () => false); it("should respect the output flag", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); + const output = "nonsense.json"; // @ts-ignore - git.getChangedPackagesSinceRef.mockImplementation( - () => simpleChangedPackagesList - ); + git.getChangedPackagesSinceRef.mockImplementation(() => [ + { + packageJson: { name: "pkg-a", version: "1.0.0" }, + dir: "/fake/folder/doesnt/matter", + }, + ]); const changesetID = "ascii"; // @ts-ignore humanId.mockReturnValueOnce(changesetID); - await writeChangesets([simpleChangeset], cwd); + await writeChangeset( + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + cwd + ); const probsUndefined = await status(cwd, { output }, defaultConfig); const releaseObj = await fs.readFile(path.join(cwd, output), "utf-8"); expect(probsUndefined).toEqual(undefined); - expect(JSON.parse(releaseObj)).toEqual(simpleReleasePlan); + expect(JSON.parse(releaseObj)).toMatchInlineSnapshot(` + Object { + "changesets": Array [ + Object { + "id": "ascii", + "releases": Array [ + Object { + "name": "pkg-a", + "type": "minor", + }, + ], + "summary": "This is a summary", + }, + ], + "releases": Array [ + Object { + "changesets": Array [ + "ascii", + ], + "name": "pkg-a", + "newVersion": "1.1.0", + "oldVersion": "1.0.0", + "type": "minor", + }, + ], + } + `); }); }); diff --git a/packages/cli/src/commands/tag/__tests__/index.test.ts b/packages/cli/src/commands/tag/__tests__/index.test.ts index 67034d512..985dce730 100644 --- a/packages/cli/src/commands/tag/__tests__/index.test.ts +++ b/packages/cli/src/commands/tag/__tests__/index.test.ts @@ -1,22 +1,32 @@ -import fixtures from "fixturez"; -import { silenceLogsInBlock } from "../../../../../test-utils/src"; +import { silenceLogsInBlock, testdir } from "@changesets/test-utils"; import * as git from "@changesets/git"; import tag from "../index"; -const f = fixtures(__dirname); - jest.mock("@changesets/git"); describe("tag command", () => { silenceLogsInBlock(); - let cwd: string; describe("workspace project", () => { - beforeEach(async () => { - cwd = await f.copy("simple-project"); - }); - it("tags all packages", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + (git.getAllTags as jest.Mock).mockReturnValue(new Set()); expect(git.tag).not.toHaveBeenCalled(); @@ -27,6 +37,24 @@ describe("tag command", () => { }); it("skips tags that already exist", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + (git.getAllTags as jest.Mock).mockReturnValue( new Set([ // pkg-a should not be re-tagged @@ -42,11 +70,14 @@ describe("tag command", () => { }); describe("single package repo", () => { - beforeEach(async () => { - cwd = await f.copy("root-only"); - }); - it("uses a simplified version-only tag", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + name: "root-only", + version: "1.0.0", + }), + }); (git.getAllTags as jest.Mock).mockReturnValue(new Set()); expect(git.tag).not.toHaveBeenCalled(); diff --git a/packages/cli/src/commands/version/version.test.ts b/packages/cli/src/commands/version/version.test.ts index 773b1b2a5..bf24a1954 100644 --- a/packages/cli/src/commands/version/version.test.ts +++ b/packages/cli/src/commands/version/version.test.ts @@ -1,12 +1,10 @@ -import fixtures from "fixturez"; - import fs from "fs-extra"; import path from "path"; import * as git from "@changesets/git"; import { warn } from "@changesets/logger"; -import { silenceLogsInBlock } from "@changesets/test-utils"; +import { silenceLogsInBlock, testdir } from "@changesets/test-utils"; import writeChangeset from "@changesets/write"; -import { NewChangeset, Config } from "@changesets/types"; +import { Config, Changeset } from "@changesets/types"; import { defaultConfig } from "@changesets/config"; import { getPackages } from "@manypkg/get-packages"; import pre from "../pre"; @@ -44,8 +42,6 @@ function mockGlobalDate< }; } -const f = fixtures(__dirname); - let changelogPath = path.resolve(__dirname, "../../changelog"); let commitPath = path.resolve(__dirname, "../../commit"); let modifiedDefaultConfig: Config = { @@ -80,28 +76,7 @@ git.getCurrentCommitId.mockImplementation(() => Promise.resolve("abcdef")); // @ts-ignore git.tag.mockImplementation(() => Promise.resolve(true)); -const simpleChangeset: NewChangeset = { - summary: "This is a summary", - releases: [{ name: "pkg-a", type: "minor" }], - id: "having-lotsof-fun", -}; - -const simpleChangeset2: NewChangeset = { - summary: "This is a summary too", - releases: [ - { name: "pkg-a", type: "minor" }, - { name: "pkg-b", type: "patch" }, - ], - id: "wouldnit-be-nice", -}; - -const simpleChangeset3: NewChangeset = { - summary: "This is not a summary", - releases: [{ name: "pkg-b", type: "patch" }], - id: "hot-day-today", -}; - -const writeChangesets = (changesets: NewChangeset[], cwd: string) => { +const writeChangesets = (changesets: Changeset[], cwd: string) => { return Promise.all( changesets.map((changeset) => writeChangeset(changeset, cwd)) ); @@ -127,8 +102,6 @@ const getChangelog = (pkgName: string, calls: any) => { return getFile(pkgName, "CHANGELOG.md", calls); }; -const writeEmptyChangeset = (cwd: string) => writeChangesets([], cwd); - beforeEach(() => { let i = 0; (humanId as jest.Mock).mockImplementation(() => { @@ -144,20 +117,20 @@ afterEach(() => { describe("running version in a simple project", () => { silenceLogsInBlock(); - let cwd: string; - - beforeEach(async () => { - cwd = await f.copy("simple-project"); - console.error = jest.fn(); - }); - - afterEach(async () => { - console.error = consoleError; - }); describe("when there are no changeset commits", () => { it("should warn if no changeset commits exist", async () => { - await writeEmptyChangeset(cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); await version(cwd, defaultOptions, modifiedDefaultConfig); // @ts-ignore const loggerWarnCalls = warn.mock.calls; @@ -170,7 +143,35 @@ describe("running version in a simple project", () => { describe("when there is a changeset commit", () => { it("should bump releasedPackages", async () => { - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); await version(cwd, defaultOptions, modifiedDefaultConfig); @@ -185,7 +186,32 @@ describe("running version in a simple project", () => { }); it("should not touch package.json of an ignored package when it is not a dependent of any releasedPackages ", async () => { - await writeChangesets([simpleChangeset], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); await version(cwd, defaultOptions, { @@ -201,7 +227,36 @@ describe("running version in a simple project", () => { }); it("should not bump ignored packages", async () => { - await writeChangesets([simpleChangeset, simpleChangeset3], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + { + summary: "This is not a summary", + releases: [{ name: "pkg-b", type: "patch" }], + }, + ], + cwd + ); await version(cwd, defaultOptions, { ...modifiedDefaultConfig, @@ -227,18 +282,62 @@ describe("running version in a simple project", () => { }); it("should not commit the result if commit config is not set", async () => { - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + ], + cwd + ); const spy = jest.spyOn(git, "commit"); - expect(spy).not.toHaveBeenCalled(); - await version(cwd, defaultOptions, modifiedDefaultConfig); expect(spy).not.toHaveBeenCalled(); }); it("should git add the expected files if commit config is set", async () => { - const ids = await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + const ids = await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(git, "add"); expect(spy).not.toHaveBeenCalled(); @@ -260,7 +359,35 @@ describe("running version in a simple project", () => { }); it("should commit the result if commit config is set", async () => { - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(git, "commit"); expect(spy).not.toHaveBeenCalled(); @@ -282,7 +409,35 @@ describe("running version in a simple project", () => { }); it("should skip over ignored changesets", async () => { - const cwd = await f.copy("ignored-changeset"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/changesets-are-beautiful.md": `--- +"pkg-a": minor +--- + +Nice simple summary, much wow +`, + ".changeset/.ignored-temporarily.md": `--- +"pkg-b": minor +--- + +Awesome feature, hidden behind a feature flag +`, + }); await version(cwd, defaultOptions, modifiedDefaultConfig); @@ -307,7 +462,23 @@ describe("running version in a simple project", () => { }); it("should not update a dependant that uses a tag as a dependency rage for a package that could otherwise be local", async () => { - const cwd = await f.copy("dependant-with-tag-range"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["examples/*", "packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + "examples/example-a/package.json": JSON.stringify({ + name: "example-a", + version: "1.0.0", + dependencies: { + "pkg-a": "latest", + }, + }), + }); await writeChangeset( { @@ -339,7 +510,39 @@ describe("running version in a simple project", () => { describe("when there are multiple changeset commits", () => { it("should bump releasedPackages", async () => { - await writeChangesets([simpleChangeset, simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); await version(cwd, defaultOptions, modifiedDefaultConfig); @@ -353,7 +556,39 @@ describe("running version in a simple project", () => { }); it("should bump multiple released packages if required", async () => { - await writeChangesets([simpleChangeset, simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); await version(cwd, defaultOptions, modifiedDefaultConfig); @@ -373,19 +608,81 @@ describe("running version in a simple project", () => { ); }); it("should delete the changeset files", async () => { - await writeChangesets([simpleChangeset, simpleChangeset2], cwd); - await version(cwd, defaultOptions, modifiedDefaultConfig); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); + + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); + expect((await fs.readdir(path.resolve(cwd, ".changeset"))).length).toBe( + 3 + ); - const files = await fs.readdir(path.resolve(cwd, ".changeset")); - expect(files.length).toBe(2); + await version(cwd, defaultOptions, modifiedDefaultConfig); + expect((await fs.readdir(path.resolve(cwd, ".changeset"))).length).toBe( + 1 + ); }); }); }); describe("fixed", () => { it("should bump packages to the correct versions when packages are fixed", async () => { - const cwd = await f.copy("fixed-packages"); - await writeChangesets([simpleChangeset], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); await version(cwd, defaultOptions, { @@ -402,8 +699,32 @@ describe("fixed", () => { }); it("should not bump an ignored fixed package that depends on a package from the group that is being released", async () => { - const cwd = await f.copy("fixed-packages"); - await writeChangesets([simpleChangeset3], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is not a summary", + releases: [{ name: "pkg-b", type: "patch" }], + }, + ], + cwd + ); await version(cwd, defaultOptions, { ...modifiedDefaultConfig, @@ -430,10 +751,34 @@ describe("fixed", () => { }); it("should update CHANGELOGs of all packages from the fixed group", async () => { - const cwd = await f.copy("fixed-packages"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); const spy = jest.spyOn(fs, "writeFile"); - await writeChangesets([simpleChangeset], cwd); + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + ], + cwd + ); await version(cwd, defaultOptions, { ...modifiedDefaultConfig, @@ -463,7 +808,15 @@ describe("fixed", () => { spy.mockClear(); - await writeChangesets([simpleChangeset], cwd); + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + ], + cwd + ); await version(cwd, defaultOptions, { ...modifiedDefaultConfig, @@ -507,8 +860,35 @@ describe("fixed", () => { describe("linked", () => { it("should bump packages to the correct versions when packages are linked", async () => { - const cwd = await f.copy("linked-packages"); - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "0.1.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "0.1.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); await version(cwd, defaultOptions, { @@ -525,11 +905,38 @@ describe("linked", () => { }); it("should not break when there is a linked package without a changeset", async () => { - const cwd = await f.copy("linked-packages"); - await writeChangesets([simpleChangeset], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "0.1.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "0.1.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); - await version(cwd, defaultOptions, modifiedDefaultConfig); + await version(cwd, defaultOptions, { + ...modifiedDefaultConfig, + linked: [["pkg-1", "pkg-2"]], + }); expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-a", version: "1.1.0" }) @@ -539,9 +946,36 @@ describe("linked", () => { describe("workspace range", () => { it("should update dependency range correctly", async () => { - const cwd = f.copy("simple-workspace-range-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); - await writeChangesets([simpleChangeset2], cwd); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = await getPackages(cwd); @@ -561,7 +995,23 @@ describe("workspace range", () => { }); it("should bump dependent package when bumping a `workspace:*` dependency", async () => { - const cwd = f.copy("simple-workspace-wildcard-range-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:*", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { @@ -589,7 +1039,23 @@ describe("workspace range", () => { }); it("should bump dependent package when bumping a `workspace:^` dependency", async () => { - const cwd = f.copy("workspace-alias-range-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:^", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { @@ -607,24 +1073,38 @@ describe("workspace range", () => { version: "1.0.1", dependencies: { "pkg-b": "workspace:^", - "pkg-c": "workspace:~", }, }, { name: "pkg-b", version: "1.0.1", }, - { - name: "pkg-c", - version: "1.0.0", - }, ]); }); }); describe("same package in different dependency types", () => { it("should update different range types correctly", async () => { - let cwd = f.copy("simple-project-same-dep-diff-range"); + let cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + peerDependencies: { + "pkg-b": "^1.0.0", + }, + devDependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [ @@ -662,8 +1142,35 @@ describe("same package in different dependency types", () => { describe("snapshot release", () => { it("should update the package to unique version no matter the kind of version bump it is", async () => { - let cwd = f.copy("simple-project"); - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); await version( cwd, @@ -691,8 +1198,35 @@ describe("snapshot release", () => { }); it("should not commit the result even if commit config is set", async () => { - let cwd = f.copy("simple-project"); - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(git, "commit"); expect(spy).not.toHaveBeenCalled(); @@ -712,7 +1246,16 @@ describe("snapshot release", () => { }); it("should not bump version of a package with an explicit none release type", async () => { - const cwd = await f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-a", type: "none" }], @@ -733,16 +1276,9 @@ describe("snapshot release", () => { .toMatchInlineSnapshot(` Array [ Object { - "dependencies": Object { - "pkg-b": "1.0.0", - }, "name": "pkg-a", "version": "1.0.0", }, - Object { - "name": "pkg-b", - "version": "1.0.0", - }, ] `); }); @@ -750,7 +1286,23 @@ describe("snapshot release", () => { it( "should not bump version of an ignored package when its dependency gets updated", mockGlobalDate(async () => { - const cwd = await f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-b", type: "major" }], @@ -791,8 +1343,35 @@ describe("snapshot release", () => { describe("snapshotPrereleaseTemplate", () => { it('should throw an error when "{tag}" and empty snapshot is used', async () => { - let cwd = f.copy("simple-project"); - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); jest.spyOn(fs, "writeFile"); expect( @@ -814,8 +1393,35 @@ describe("snapshot release", () => { }); it('should throw an error when "{tag}" is set and named snapshot is used', async () => { - let cwd = f.copy("simple-project"); - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); jest.spyOn(fs, "writeFile"); expect( @@ -858,8 +1464,35 @@ describe("snapshot release", () => { "should customize release correctly based on snapshotPrereleaseTemplate template: %p (tag: '%p')", mockGlobalDate( async (snapshotTemplate, snapshotValue, expectedResult) => { - let cwd = f.copy("simple-project"); - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); await version( cwd, @@ -894,8 +1527,35 @@ describe("snapshot release", () => { describe("snapshot.useCalculatedVersion: true", () => { it("should update packages using calculated version", async () => { - let cwd = f.copy("simple-project"); - await writeChangesets([simpleChangeset2], cwd); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); + await writeChangesets( + [ + { + summary: "This is a summary too", + releases: [ + { name: "pkg-a", type: "minor" }, + { name: "pkg-b", type: "patch" }, + ], + }, + ], + cwd + ); const spy = jest.spyOn(fs, "writeFile"); await version( cwd, @@ -927,7 +1587,16 @@ describe("snapshot release", () => { }); it("should not bump version of a package with an explicit none release type", async () => { - const cwd = await f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-a", type: "none" }], @@ -954,16 +1623,9 @@ describe("snapshot release", () => { .toMatchInlineSnapshot(` Array [ Object { - "dependencies": Object { - "pkg-b": "1.0.0", - }, "name": "pkg-a", "version": "1.0.0", }, - Object { - "name": "pkg-b", - "version": "1.0.0", - }, ] `); }); @@ -971,7 +1633,23 @@ describe("snapshot release", () => { it( "should not bump version of an ignored package when its dependency gets updated", mockGlobalDate(async () => { - const cwd = await f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-b", type: "major" }], @@ -1018,9 +1696,31 @@ describe("snapshot release", () => { describe("updateInternalDependents: always", () => { it("should bump a direct dependent when a dependency package gets bumped", async () => { - const cwd = await f.copy("simple-project-caret-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "^1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); const spy = jest.spyOn(fs, "writeFile"); - await writeChangeset(simpleChangeset3, cwd); + await writeChangeset( + { + summary: "This is not a summary", + releases: [{ name: "pkg-b", type: "patch" }], + }, + cwd + ); await version(cwd, defaultOptions, { ...modifiedDefaultConfig, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { @@ -1068,9 +1768,35 @@ describe("updateInternalDependents: always", () => { }); it("should not bump a dev dependent nor its dependent when a package gets bumped", async () => { - const cwd = await f.copy("simplest-transitive-devdependent"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + devDependencies: { "pkg-a": "1.0.0" }, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "1.0.0", + dependencies: { "pkg-b": "1.0.0" }, + }), + }); + const spy = jest.spyOn(fs, "writeFile"); - await writeChangeset(simpleChangeset, cwd); + await writeChangeset( + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + cwd + ); await version(cwd, defaultOptions, { ...modifiedDefaultConfig, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { @@ -1117,7 +1843,23 @@ describe("updateInternalDependents: always", () => { describe("pre", () => { it("should work", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "next" }); await writeChangeset( { @@ -1311,7 +2053,23 @@ describe("pre", () => { `); }); it("should work with adding a package while in pre mode", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "next" }); await writeChangeset( { @@ -1373,7 +2131,23 @@ describe("pre", () => { ]); }); it("should work for my weird case", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-a", type: "minor" }], @@ -1421,7 +2195,23 @@ describe("pre", () => { }); // https://github.com/changesets/changesets/pull/382#discussion_r434434182 it("should bump patch version for packages that had prereleases, but caret dependencies are still in range", async () => { - let cwd = f.copy("simple-project-caret-dep"); + let cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "^1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "next" }); await writeChangeset( { @@ -1467,7 +2257,23 @@ describe("pre", () => { }); it("should use the highest bump type between all prereleases when versioning a package", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-a", type: "major" }], @@ -1515,7 +2321,23 @@ describe("pre", () => { ]); }); it("should use the highest bump type between all prereleases when versioning a dependent package", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "next" }); await writeChangeset( @@ -1565,7 +2387,23 @@ describe("pre", () => { }); it("should not bump packages through devDependencies", async () => { - let cwd = f.copy("simple-dev-dep"); + let cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + devDependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-b", type: "major" }], @@ -1591,7 +2429,23 @@ describe("pre", () => { ]); }); it("should not bump ignored packages through dependencies", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-a", type: "major" }], @@ -1628,12 +2482,28 @@ describe("pre", () => { ]); }); it("should bump dependent of prerelease package when bumping a `workspace:~` dependency", async () => { - const cwd = f.copy("workspace-alias-range-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:~", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "alpha" }); await writeChangeset( { - releases: [{ name: "pkg-c", type: "patch" }], + releases: [{ name: "pkg-b", type: "patch" }], summary: "a very useful summary for the change", }, cwd @@ -1646,23 +2516,34 @@ describe("pre", () => { name: "pkg-a", version: "1.0.1-alpha.0", dependencies: { - "pkg-b": "workspace:^", - "pkg-c": "workspace:~", + "pkg-b": "workspace:~", }, }, { name: "pkg-b", - version: "1.0.0", - }, - { - name: "pkg-c", version: "1.0.1-alpha.0", }, ]); }); it("should replace star range for dependency in dependant package when that dependency has its first prerelease in an already active pre mode", async () => { - const cwd = f.copy("simple-star-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "*", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "alpha" }); @@ -1722,7 +2603,23 @@ describe("pre", () => { }); it("bumping dependency in pre mode should result in dependant with star range on that dependency to be patch bumped and that range to be replaced with exact version", async () => { - const cwd = f.copy("simple-star-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "*", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "alpha" }); @@ -1755,7 +2652,23 @@ describe("pre", () => { }); it("bumping dependency in pre mode should result in dependant with workspace:* range on that dependency to be patch bumped without changing the dependency range", async () => { - const cwd = f.copy("simple-workspace-wildcard-range-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:*", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "alpha" }); @@ -1788,7 +2701,23 @@ describe("pre", () => { }); it("bumping dependency in pre mode should result in dependant with workspace:^ range on that dependency to be patch bumped without changing the dependency range", async () => { - const cwd = f.copy("workspace-alias-range-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:^", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "alpha" }); @@ -1808,7 +2737,6 @@ describe("pre", () => { Object { "dependencies": Object { "pkg-b": "workspace:^", - "pkg-c": "workspace:~", }, "name": "pkg-a", "version": "1.0.1-alpha.0", @@ -1817,22 +2745,34 @@ describe("pre", () => { "name": "pkg-b", "version": "1.0.1-alpha.0", }, - Object { - "name": "pkg-c", - "version": "1.0.0", - }, ] `); }); it("bumping dependency in pre mode should result in dependant with workspace:~ range on that dependency to be patch bumped without changing the dependency range", async () => { - const cwd = f.copy("workspace-alias-range-dep"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "workspace:~", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await pre(cwd, { command: "enter", tag: "alpha" }); await writeChangeset( { - releases: [{ name: "pkg-c", type: "patch" }], + releases: [{ name: "pkg-b", type: "patch" }], summary: "a very useful summary for the change", }, cwd @@ -1845,18 +2785,13 @@ describe("pre", () => { Array [ Object { "dependencies": Object { - "pkg-b": "workspace:^", - "pkg-c": "workspace:~", + "pkg-b": "workspace:~", }, "name": "pkg-a", "version": "1.0.1-alpha.0", }, Object { "name": "pkg-b", - "version": "1.0.0", - }, - Object { - "name": "pkg-c", "version": "1.0.1-alpha.0", }, ] @@ -1869,7 +2804,23 @@ describe("pre", () => { ...modifiedDefaultConfig, linked: [["pkg-a", "pkg-b"]], }; - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-a", type: "minor" }], @@ -1961,7 +2912,27 @@ describe("pre", () => { ...modifiedDefaultConfig, linked: [["pkg-a", "pkg-b"]], }; - let cwd = f.copy("linked-and-not-linked-packages"); + let cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + dependencies: { + "pkg-c": "0.1.0", + }, + }), + "packages/pkg-c/package.json": JSON.stringify({ + name: "pkg-c", + version: "0.1.0", + }), + }); await pre(cwd, { command: "enter", tag: "next" }); await writeChangeset( { @@ -2020,7 +2991,23 @@ describe("pre", () => { ...modifiedDefaultConfig, linked: [["pkg-a", "pkg-b"]], }; - let cwd = f.copy("linked-packages-with-linked-dev-dep"); + let cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + devDependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], diff --git a/packages/cli/src/run.test.ts b/packages/cli/src/run.test.ts index 4a6b6c3fd..8e4b79d40 100644 --- a/packages/cli/src/run.test.ts +++ b/packages/cli/src/run.test.ts @@ -1,20 +1,25 @@ -import fixtures from "fixturez"; import { error } from "@changesets/logger"; +import { testdir } from "@changesets/test-utils"; import { run } from "./run"; -const f = fixtures(__dirname); jest.mock("@changesets/logger"); jest.mock("./commands/version"); describe("cli", () => { describe("version", () => { - let cwd: string; - beforeEach(async () => { - cwd = await f.copy("simple-project"); - }); - it("should validate package name passed in from --ignore flag", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); try { await run(["version"], { ignore: "pkg-c" }, cwd); } catch (e) { @@ -29,6 +34,24 @@ describe("cli", () => { }); it("should throw if dependents of ignored packages are not explicitly listed in the ignore array", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); try { await run(["version"], { ignore: ["pkg-b"] }, cwd); } catch (e) { @@ -43,7 +66,26 @@ describe("cli", () => { }); it("should throw if `--ignore` flag is used while ignore array is also defined in the config file ", async () => { - cwd = await f.copy("simple-project-with-ignore-config"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({ + ignore: ["pkg-a"], + }), + }); try { await run(["version"], { ignore: "pkg-b" }, cwd); } catch (e) { diff --git a/packages/config/package.json b/packages/config/package.json index a49a987ea..8e7b722f3 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -20,8 +20,8 @@ "micromatch": "^4.0.2" }, "devDependencies": { + "@changesets/test-utils": "*", "@types/micromatch": "^4.0.1", - "fixturez": "^1.1.0", "jest-in-case": "^1.0.2" } } diff --git a/packages/config/src/index.test.ts b/packages/config/src/index.test.ts index 6b12f530c..6542edb6b 100644 --- a/packages/config/src/index.test.ts +++ b/packages/config/src/index.test.ts @@ -1,9 +1,9 @@ -import fixturez from "fixturez"; import { read, parse } from "./"; import jestInCase from "jest-in-case"; import * as logger from "@changesets/logger"; import { Config, WrittenConfig } from "@changesets/types"; import { Packages } from "@manypkg/get-packages"; +import { testdir } from "@changesets/test-utils"; jest.mock("@changesets/logger"); @@ -13,8 +13,6 @@ type CorrectCase = { output: Config; }; -let f = fixturez(__dirname); - let defaultPackages: Packages = { root: { packageJson: { name: "", version: "" }, @@ -33,8 +31,13 @@ const withPackages = (pkgNames: string[]) => ({ }); test("read reads the config", async () => { - let dir = f.find("new-config"); - let config = await read(dir, defaultPackages); + let cwd = await testdir({ + ".changeset/config.json": JSON.stringify({ + changelog: false, + commit: true, + }), + }); + let config = await read(cwd, defaultPackages); expect(config).toEqual({ fixed: [], linked: [], diff --git a/packages/git/package.json b/packages/git/package.json index e63c48f59..cf212f13c 100644 --- a/packages/git/package.json +++ b/packages/git/package.json @@ -15,7 +15,8 @@ "spawndamnit": "^2.0.0" }, "devDependencies": { - "file-url": "^3.0.0", - "fixturez": "^1.1.0" + "@changesets/test-utils": "*", + "@changesets/write": "*", + "file-url": "^3.0.0" } } diff --git a/packages/git/src/index.test.ts b/packages/git/src/index.test.ts index ee3037e4a..317885e89 100644 --- a/packages/git/src/index.test.ts +++ b/packages/git/src/index.test.ts @@ -1,7 +1,8 @@ import path from "path"; -import fixtures from "fixturez"; import spawn from "spawndamnit"; import fileUrl from "file-url"; +import { tempdir, testdir } from "@changesets/test-utils"; +import writeChangeset from "@changesets/write"; import { getCommitsThatAddFiles, @@ -16,8 +17,6 @@ import { tagExists, } from "./"; -const f = fixtures(__dirname); - async function getCurrentCommit(cwd: string) { const cmd = await spawn("git", ["rev-parse", "HEAD"], { cwd }); return cmd.stdout.toString().trim(); @@ -36,7 +35,25 @@ async function getCommitCount(cwd: string) { describe("git", () => { let cwd: string; beforeEach(async () => { - cwd = f.copy("with-git"); + cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-a/index.js": `export default "a"`, + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + "packages/pkg-b/index.js": `export default "b"`, + }); await spawn("git", ["init"], { cwd }); // so that this works regardless of what the default branch of git init is and for git versions that don't support --initial-branch(like our CI) { @@ -143,7 +160,6 @@ describe("git", () => { .filter((a) => a); expect(stagedFiles).toEqual([ - "packages/package.json", "packages/pkg-a/index.js", "packages/pkg-a/package.json", "packages/pkg-b/index.js", @@ -259,12 +275,11 @@ describe("git", () => { }); describe("with shallow clone", () => { - // We will add these three well-known files + // We will add these well-known files // over multiple commits, then test looking up // the commits at which they were added. - const file1 = ".changeset/quick-lions-devour.md"; - const file2 = "packages/pkg-a/index.js"; - const file3 = "packages/pkg-b/index.js"; + const file1 = "packages/pkg-a/index.js"; + const file2 = "packages/pkg-b/index.js"; // Roughly how many commits will the deepening algorithm // deepen each time? We use this to set up test data to @@ -291,7 +306,7 @@ describe("git", () => { async function createShallowClone(depth: number): Promise { // Make a 1-commit-deep shallow clone of this repo - const cloneDir = f.temp(); + const cloneDir = tempdir(); await spawn( "git", // Note: a file:// URL is needed in order to make a shallow clone of @@ -344,12 +359,12 @@ describe("git", () => { it("reads the SHA of a file-add even if the first commit of a repo", async () => { // Finding this commit will require deepening the clone right to the start // of the repo history, and coping with a commit that has no parent. - const originalCommit = await addFileAndCommit(file3); + const originalCommit = await addFileAndCommit(file2); await createDummyCommits(shallowCloneDeepeningAmount * 2); const clone = await createShallowClone(5); // Finding this commit will require fully deepening the repo - const commit = (await getCommitsThatAddFiles([file3], clone))[0]; + const commit = (await getCommitsThatAddFiles([file2], clone))[0]; expect(commit).toEqual(originalCommit); // We should have fully deepened @@ -520,27 +535,51 @@ describe("git", () => { it("should get the relative path to the changeset file", async () => { await add("packages/pkg-a/package.json", cwd); await commit("added packageA package.json", cwd); + const changesetId = await writeChangeset( + { + releases: [ + { + name: "pkg-a", + type: "minor", + }, + ], + summary: "Awesome summary", + }, + cwd + ); await add(".changeset", cwd); const files = await getChangedChangesetFilesSinceRef({ cwd, ref: "main", }); - expect(files).toHaveLength(2); - expect(files[1]).toEqual(".changeset/quick-lions-devour.md"); + expect(files).toHaveLength(1); + expect(files[0]).toEqual(`.changeset/${changesetId}.md`); }); it("should work on a ref that isn't the base branch", async () => { await spawn("git", ["checkout", "-b", "some-branch"], { cwd }); await add("packages/pkg-a/package.json", cwd); await commit("added packageA package.json", cwd); + const changesetId = await writeChangeset( + { + releases: [ + { + name: "pkg-a", + type: "minor", + }, + ], + summary: "Awesome summary", + }, + cwd + ); await add(".changeset", cwd); const files = await getChangedChangesetFilesSinceRef({ cwd, ref: "some-branch", }); - expect(files).toHaveLength(2); - expect(files[1]).toEqual(".changeset/quick-lions-devour.md"); + expect(files).toHaveLength(1); + expect(files[0]).toEqual(`.changeset/${changesetId}.md`); }); }); }); diff --git a/packages/pre/package.json b/packages/pre/package.json index 60a6a8d97..63ec0f8fe 100644 --- a/packages/pre/package.json +++ b/packages/pre/package.json @@ -14,6 +14,6 @@ "fs-extra": "^7.0.1" }, "devDependencies": { - "fixturez": "^1.1.0" + "@changesets/test-utils": "*" } } diff --git a/packages/pre/src/index.test.ts b/packages/pre/src/index.test.ts index 8f0faef1a..c717b3d45 100644 --- a/packages/pre/src/index.test.ts +++ b/packages/pre/src/index.test.ts @@ -1,86 +1,184 @@ -import fixturez from "fixturez"; import { enterPre, exitPre, readPreState } from "./index"; import * as fs from "fs-extra"; import path from "path"; -import { PreState } from "@changesets/types"; import { PreEnterButInPreModeError, PreExitButNotInPreModeError, -} from "@changesets/errors/src"; - -let f = fixturez(__dirname); - -let preStateForSimpleProject: PreState = { - changesets: [], - initialVersions: { - "pkg-a": "1.0.0", - "pkg-b": "1.0.0", - }, - mode: "pre", - tag: "next", -}; - -let preStateForExited: PreState = { - changesets: ["slimy-dingos-whisper"], - initialVersions: { - "pkg-a": "1.0.0", - "pkg-b": "1.0.0", - }, - mode: "exit", - tag: "beta", -}; +} from "@changesets/errors"; +import { testdir } from "@changesets/test-utils"; describe("enterPre", () => { it("should enter", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + }); await enterPre(cwd, "next"); - expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))).toEqual( - preStateForSimpleProject - ); + expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))) + .toMatchInlineSnapshot(` + Object { + "changesets": Array [], + "initialVersions": Object { + "pkg-a": "1.0.0", + "pkg-b": "1.0.0", + }, + "mode": "pre", + "tag": "next", + } + `); }); it("should throw if already in pre", async () => { - let cwd = f.copy("simple-project"); - await fs.writeJSON( - path.join(cwd, ".changeset", "pre.json"), - preStateForSimpleProject - ); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/pre.json": JSON.stringify({ + changesets: [], + initialVersions: { + "pkg-a": "1.0.0", + "pkg-b": "1.0.0", + }, + mode: "pre", + tag: "next", + }), + }); await expect(enterPre(cwd, "some-tag")).rejects.toBeInstanceOf( PreEnterButInPreModeError ); }); it("should enter if already exited pre mode", async () => { - let cwd = f.copy("simple-project"); - await fs.writeJSON( - path.join(cwd, ".changeset", "pre.json"), - preStateForExited - ); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/pre.json": JSON.stringify({ + changesets: ["slimy-dingos-whisper"], + initialVersions: { + "pkg-a": "1.0.0", + "pkg-b": "1.0.0", + }, + mode: "exit", + tag: "beta", + }), + }); await enterPre(cwd, "next"); - expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))).toEqual( - { - ...preStateForExited, - mode: "pre", - tag: "next", + expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))) + .toMatchInlineSnapshot(` + Object { + "changesets": Array [ + "slimy-dingos-whisper", + ], + "initialVersions": Object { + "pkg-a": "1.0.0", + "pkg-b": "1.0.0", + }, + "mode": "pre", + "tag": "next", } - ); + `); }); }); describe("exitPre", () => { it("should exit", async () => { - let cwd = f.copy("simple-project"); - await fs.writeJSON( - path.join(cwd, ".changeset", "pre.json"), - preStateForSimpleProject - ); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/pre.json": JSON.stringify({ + changesets: [], + initialVersions: { + "pkg-a": "1.0.0", + "pkg-b": "1.0.0", + }, + mode: "pre", + tag: "next", + }), + }); await exitPre(cwd); - expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))).toEqual( - { ...preStateForSimpleProject, mode: "exit" } - ); + expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))) + .toMatchInlineSnapshot(` + Object { + "changesets": Array [], + "initialVersions": Object { + "pkg-a": "1.0.0", + "pkg-b": "1.0.0", + }, + "mode": "exit", + "tag": "next", + } + `); }); it("should throw if not in pre", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); await expect(exitPre(cwd)).rejects.toBeInstanceOf( PreExitButNotInPreModeError ); @@ -88,10 +186,41 @@ describe("exitPre", () => { }); test("readPreState reads the pre state", async () => { - let cwd = f.copy("simple-project"); - await fs.writeJSON( - path.join(cwd, ".changeset", "pre.json"), - preStateForSimpleProject - ); - expect(await readPreState(cwd)).toEqual(preStateForSimpleProject); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/pre.json": JSON.stringify({ + changesets: [], + initialVersions: { + "pkg-a": "1.0.0", + "pkg-b": "1.0.0", + }, + mode: "pre", + tag: "next", + }), + }); + expect(await readPreState(cwd)).toMatchInlineSnapshot(` + Object { + "changesets": Array [], + "initialVersions": Object { + "pkg-a": "1.0.0", + "pkg-b": "1.0.0", + }, + "mode": "pre", + "tag": "next", + } + `); }); diff --git a/packages/pre/src/index.ts b/packages/pre/src/index.ts index 419bf24be..f39efd689 100644 --- a/packages/pre/src/index.ts +++ b/packages/pre/src/index.ts @@ -38,7 +38,7 @@ export async function exitPre(cwd: string) { throw new PreExitButNotInPreModeError(); } - await fs.writeFile( + await fs.outputFile( preStatePath, JSON.stringify({ ...preState, mode: "exit" }, null, 2) + "\n" ); @@ -61,5 +61,8 @@ export async function enterPre(cwd: string, tag: string) { for (let pkg of packages.packages) { newPreState.initialVersions[pkg.packageJson.name] = pkg.packageJson.version; } - await fs.writeFile(preStatePath, JSON.stringify(newPreState, null, 2) + "\n"); + await fs.outputFile( + preStatePath, + JSON.stringify(newPreState, null, 2) + "\n" + ); } diff --git a/packages/read/package.json b/packages/read/package.json index 227f85b15..ccdc0b4e0 100644 --- a/packages/read/package.json +++ b/packages/read/package.json @@ -18,7 +18,6 @@ }, "devDependencies": { "@changesets/test-utils": "*", - "fixturez": "^1.1.0", "outdent": "^0.5.0" } } diff --git a/packages/read/src/index.test.ts b/packages/read/src/index.test.ts index 5352c6547..386775eaa 100644 --- a/packages/read/src/index.test.ts +++ b/packages/read/src/index.test.ts @@ -1,44 +1,63 @@ -import fixtures from "fixturez"; +import fs from "fs-extra"; +import path from "path"; import outdent from "outdent"; import read from "./"; -import { silenceLogsInBlock } from "@changesets/test-utils"; - -const f = fixtures(__dirname); +import { silenceLogsInBlock, testdir } from "@changesets/test-utils"; silenceLogsInBlock(); describe("read changesets from disc", () => { it("should read a changeset from disc", async () => { - const changesetPath = f.find("easy-read"); + const cwd = await testdir({ + ".changeset/cool-computer-club.md": `--- +"cool-package": minor +--- + +Nice simple summary`, + }); - const changesets = await read(changesetPath); + const changesets = await read(cwd); expect(changesets).toEqual([ { releases: [{ name: "cool-package", type: "minor" }], summary: "Nice simple summary", - id: "basic-changeset", + id: "cool-computer-club", }, ]); }); it("should ignore a readme file", async () => { - const changesetPath = f.find("with-readme"); + const cwd = await testdir({ + ".changeset/README.md": `Changesets are great for monorepos`, + ".changeset/one-chance.md": `--- +"cool-package": minor +--- - const changesets = await read(changesetPath); +Nice simple summary +`, + }); + + const changesets = await read(cwd); expect(changesets).toEqual([ { releases: [{ name: "cool-package", type: "minor" }], summary: "Nice simple summary", - id: "basic-changeset", + id: "one-chance", }, ]); }); it("read a changeset that isn't a three word id", async () => { // I just want it enshrined in the tests that the file name's format // is in no way part of the changeset spec - const changesetPath = f.find("easy-read"); + const cwd = await testdir({ + ".changeset/basic-changeset.md": `--- +"cool-package": minor +--- + +Nice simple summary`, + }); - const changesets = await read(changesetPath); + const changesets = await read(cwd); expect(changesets).toEqual([ { releases: [{ name: "cool-package", type: "minor" }], @@ -48,34 +67,47 @@ describe("read changesets from disc", () => { ]); }); it("should read many changesets from disc", async () => { - const changesetPath = f.find("multiple-changesets"); + const cwd = await testdir({ + ".changeset/cool-computer-club.md": `--- +"cool-package": minor +--- - const changesets = await read(changesetPath); +Nice simple summary`, + ".changeset/tiny-little-but-awesome.md": `--- +"perfect-package": patch +--- + +I'm amazed we needed to update the best package, because it was already the best +`, + }); + + const changesets = await read(cwd); expect(changesets).toEqual([ { releases: [{ name: "cool-package", type: "minor" }], summary: "Nice simple summary", - id: "first-changeset", + id: "cool-computer-club", }, { - releases: [{ name: "best-package", type: "patch" }], + releases: [{ name: "perfect-package", type: "patch" }], summary: "I'm amazed we needed to update the best package, because it was already the best", - id: "second-changeset", + id: "tiny-little-but-awesome", }, ]); }); it("should return an empty array when no changesets are found", async () => { - const changesetPath = f.find("no-changeset"); + const cwd = await testdir({}); + await fs.mkdir(path.join(cwd, ".changeset")); - const changesets = await read(changesetPath); + const changesets = await read(cwd); expect(changesets).toEqual([]); }); it("should error when there is no changeset folder", async () => { - const changesetPath = f.find("no-changeset-folder"); + const cwd = await testdir({}); try { - await read(changesetPath); + await read(cwd); } catch (e) { expect((e as Error).message).toBe( "There is no .changeset directory in this project" @@ -85,9 +117,17 @@ describe("read changesets from disc", () => { expect("never run this because we returned above").toBe(true); }); it("should error on broken changeset?", async () => { - const changesetPath = f.find("broken-changeset"); + const cwd = await testdir({ + ".changeset/broken-changeset.md": `--- + +"cool-package": minor + +-- + +Everything is wrong`, + }); - expect(read(changesetPath)).rejects.toThrow( + expect(read(cwd)).rejects.toThrow( outdent`could not parse changeset - invalid frontmatter: --- "cool-package": minor @@ -98,21 +138,52 @@ describe("read changesets from disc", () => { ); }); it("should return no releases and empty summary when the changeset is empty", async () => { - const changesetPath = f.find("empty-changeset"); + const cwd = await testdir({ + ".changeset/empty-like-void.md": `--- +---`, + }); - const changesets = await read(changesetPath); + const changesets = await read(cwd); expect(changesets).toEqual([ { releases: [], summary: "", - id: "empty-changeset", + id: "empty-like-void", }, ]); }); it("should filter out ignored changesets", async () => { - const changesetPath = f.find("ignored-changeset"); - - const changesets = await read(changesetPath); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/changesets-are-beautiful.md": `--- +"pkg-a": minor +--- + +Nice simple summary, much wow +`, + ".changeset/.ignored-temporarily.md": `--- +"pkg-b": minor +--- + +Awesome feature, hidden behind a feature flag +`, + }); + + const changesets = await read(cwd); expect(changesets).toEqual([ { releases: [{ name: "pkg-a", type: "minor" }], @@ -121,4 +192,28 @@ describe("read changesets from disc", () => { }, ]); }); + + it("should read an old changeset", async () => { + const cwd = await testdir({ + ".changeset/basic-changeset/changes.json": JSON.stringify({ + releases: [ + { + name: "cool-package", + type: "minor", + }, + ], + dependents: [], + }), + ".changeset/basic-changeset/changes.md": `Nice simple summary`, + }); + + const changesets = await read(cwd); + expect(changesets).toEqual([ + { + releases: [{ name: "cool-package", type: "minor" }], + summary: "Nice simple summary", + id: "basic-changeset", + }, + ]); + }); }); diff --git a/packages/release-utils/package.json b/packages/release-utils/package.json index fb9f2a773..d6b7f45a6 100644 --- a/packages/release-utils/package.json +++ b/packages/release-utils/package.json @@ -19,7 +19,6 @@ "@changesets/git": "*", "@changesets/test-utils": "*", "@changesets/write": "*", - "file-url": "^3.0.0", - "fixturez": "^1.1.0" + "file-url": "^3.0.0" } } diff --git a/packages/release-utils/src/run.test.ts b/packages/release-utils/src/run.test.ts index 4539f1a34..8b9aa2c60 100644 --- a/packages/release-utils/src/run.test.ts +++ b/packages/release-utils/src/run.test.ts @@ -1,17 +1,14 @@ import { add, commit } from "@changesets/git"; -import { silenceLogsInBlock } from "@changesets/test-utils"; +import { silenceLogsInBlock, tempdir, testdir } from "@changesets/test-utils"; import { Changeset } from "@changesets/types"; import writeChangeset from "@changesets/write"; import fileUrl from "file-url"; -import fixturez from "fixturez"; import fs from "fs-extra"; import path from "path"; import spawn from "spawndamnit"; import { getCurrentBranch } from "./gitUtils"; import { runPublish, runVersion } from "./run"; -let f = fixturez(__dirname); - const linkNodeModules = async (cwd: string) => { await fs.symlink( path.join(__dirname, "..", "..", "..", "node_modules"), @@ -37,7 +34,7 @@ async function setupRepoAndClone(cwd: string) { const mainBranch = await getCurrentBranch(cwd); // Make a 1-commit-deep shallow clone of this repo - let clone = f.temp(); + let clone = tempdir(); await spawn( "git", // Note: a file:// URL is needed in order to make a shallow clone of @@ -53,7 +50,24 @@ async function setupRepoAndClone(cwd: string) { describe("version", () => { it("returns the right changed packages and pushes to the remote", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); await writeChangesets( [ @@ -98,8 +112,7 @@ describe("version", () => { \\"dependencies\\": { \\"pkg-b\\": \\"1.1.0\\" } - } - " + }" `); expect( @@ -111,8 +124,7 @@ describe("version", () => { "{ \\"name\\": \\"pkg-b\\", \\"version\\": \\"1.1.0\\" - } - " + }" `); expect( await fs.readFile( @@ -161,7 +173,28 @@ describe("version", () => { }); it("only includes bumped packages in the returned changed packages", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify( + { + name: "pkg-b", + version: "1.0.0", + }, + null, + 2 + ), + ".changeset/config.json": JSON.stringify({}), + }); await writeChangesets( [ @@ -202,8 +235,7 @@ describe("version", () => { \\"dependencies\\": { \\"pkg-b\\": \\"1.0.0\\" } - } - " + }" `); expect( @@ -215,8 +247,7 @@ describe("version", () => { "{ \\"name\\": \\"pkg-b\\", \\"version\\": \\"1.0.0\\" - } - " + }" `); expect( @@ -251,14 +282,33 @@ describe("version", () => { }); it("doesn't include ignored package that got a dependency update in returned versions", async () => { - let cwd = f.copy("ignored-package"); + let cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({ + ignore: ["pkg-a"], + }), + }); await writeChangesets( [ { releases: [ { - name: "ignored-package-pkg-b", + name: "pkg-b", type: "minor", }, ], @@ -278,7 +328,7 @@ describe("version", () => { expect(changedPackages).toEqual([ { dir: path.join(clone, "packages", "pkg-b"), - packageJson: { name: "ignored-package-pkg-b", version: "1.1.0" }, + packageJson: { name: "pkg-b", version: "1.1.0" }, }, ]); }); @@ -286,7 +336,13 @@ describe("version", () => { describe("publish", () => { test("single package repo", async () => { - let cwd = f.copy("single-package"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + name: "single-package", + version: "1.0.0", + }), + }); const { clone } = await setupRepoAndClone(cwd); @@ -305,7 +361,24 @@ describe("publish", () => { expect(tagsResult.stdout.toString("utf8").trim()).toEqual("v1.0.0"); }); test("multi package repo", async () => { - let cwd = f.copy("simple-project"); + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + dependencies: { + "pkg-b": "1.0.0", + }, + }), + "packages/pkg-b/package.json": JSON.stringify({ + name: "pkg-b", + version: "1.0.0", + }), + ".changeset/config.json": JSON.stringify({}), + }); const { clone } = await setupRepoAndClone(cwd); diff --git a/packages/test-utils/CHANGELOG.md b/packages/test-utils/CHANGELOG.md deleted file mode 100644 index 30d62995d..000000000 --- a/packages/test-utils/CHANGELOG.md +++ /dev/null @@ -1,45 +0,0 @@ -# @changesets/test-utils - -## 0.0.5 - -### Patch Changes - -- [`1706fb7`](https://github.com/changesets/changesets/commit/1706fb751ecc2f5a792c42f467b2063078d58716) [#321](https://github.com/changesets/changesets/pull/321) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Fix TypeScript declarations - -- Updated dependencies [[`1706fb7`](https://github.com/changesets/changesets/commit/1706fb751ecc2f5a792c42f467b2063078d58716)]: - - @changesets/logger@0.0.5 - -## 0.0.4 - -### Patch Changes - -- [`04ddfd7`](https://github.com/changesets/changesets/commit/04ddfd7c3acbfb84ef9c92873fe7f9dea1f5145c) [#305](https://github.com/changesets/changesets/pull/305) Thanks [@Noviny](https://github.com/Noviny)! - Add link to changelog in readme - -- Updated dependencies [[`04ddfd7`](https://github.com/changesets/changesets/commit/04ddfd7c3acbfb84ef9c92873fe7f9dea1f5145c)]: - - @changesets/logger@0.0.4 - -## 0.0.3 - -### Patch Changes - -- [`9cd1eaf`](https://github.com/changesets/changesets/commit/9cd1eafc1620894a39fe10d3e393ad8f812df53a) [#214](https://github.com/changesets/changesets/pull/214) Thanks [@Noviny](https://github.com/Noviny)! - Remove unused dependencies -- Updated dependencies [[`9cd1eaf`](https://github.com/changesets/changesets/commit/9cd1eafc1620894a39fe10d3e393ad8f812df53a)]: - - @changesets/logger@0.0.3 - -## 0.0.2 - -### Patch Changes - -- Updated dependencies [[`8f0a1ef`](https://github.com/changesets/changesets/commit/8f0a1ef327563512f471677ef0ca99d30da009c0)]: - - @changesets/types@0.4.0 - - @changesets/logger@0.0.2 - -## 0.0.1 - -### Patch Changes - -- [`51a0d76`](https://github.com/changesets/changesets/commit/51a0d766c7064b4c6a9d1490593522c6fcd02929) [#182](https://github.com/changesets/changesets/pull/182) Thanks [@ajaymathur](https://github.com/ajaymathur)! - - Initial release of the package. - -- Updated dependencies [[`51a0d76`](https://github.com/changesets/changesets/commit/51a0d766c7064b4c6a9d1490593522c6fcd02929), [`a679b1d`](https://github.com/changesets/changesets/commit/a679b1dcdcb56652d31536e2d6326ba02a9dfe62)]: - - @changesets/logger@0.0.1 - - @changesets/types@0.3.1 diff --git a/packages/write/package.json b/packages/write/package.json index ff499b83a..d4d181b0c 100644 --- a/packages/write/package.json +++ b/packages/write/package.json @@ -15,6 +15,6 @@ }, "devDependencies": { "@changesets/parse": "*", - "fixturez": "^1.1.0" + "@changesets/test-utils": "*" } } diff --git a/packages/write/src/index.test.ts b/packages/write/src/index.test.ts index 86c017104..284403cdf 100644 --- a/packages/write/src/index.test.ts +++ b/packages/write/src/index.test.ts @@ -1,56 +1,76 @@ -import fixtures from "fixturez"; - import fs from "fs-extra"; import path from "path"; import parse from "@changesets/parse"; -import { Release } from "@changesets/types"; import writeChangeset from "./"; import humanId from "human-id"; - -const f = fixtures(__dirname); +import { testdir } from "@changesets/test-utils"; jest.mock("human-id"); -const simpleChangeset: { summary: string; releases: Release[] } = { - summary: "This is a summary", - releases: [{ name: "pkg-a", type: "minor" }], -}; - -const emptyChangeset: { summary: string; releases: Release[] } = { - summary: "", - releases: [], -}; - describe("simple project", () => { - let cwd: string; - - beforeEach(async () => { - cwd = await f.copy("simple-project"); - }); - it("should write a changeset", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }); + const changesetID = "ascii"; // @ts-ignore humanId.mockReturnValueOnce(changesetID); - await writeChangeset(simpleChangeset, cwd); + await writeChangeset( + { + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }, + cwd + ); const mdPath = path.join(cwd, ".changeset", `${changesetID}.md`); const mdContent = await fs.readFile(mdPath, "utf-8"); - expect(parse(mdContent)).toEqual(simpleChangeset); + expect(parse(mdContent)).toEqual({ + summary: "This is a summary", + releases: [{ name: "pkg-a", type: "minor" }], + }); }); it("should write an empty changeset", async () => { + const cwd = await testdir({ + "package.json": JSON.stringify({ + private: true, + workspaces: ["packages/*"], + }), + "packages/pkg-a/package.json": JSON.stringify({ + name: "pkg-a", + version: "1.0.0", + }), + }); + const changesetID = "ascii"; // @ts-ignore humanId.mockReturnValueOnce(changesetID); - await writeChangeset(emptyChangeset, cwd); + await writeChangeset( + { + summary: "", + releases: [], + }, + cwd + ); const mdPath = path.join(cwd, ".changeset", `${changesetID}.md`); const mdContent = await fs.readFile(mdPath, "utf-8"); - expect(parse(mdContent)).toEqual(emptyChangeset); + expect(parse(mdContent)).toEqual({ + summary: "", + releases: [], + }); }); }); diff --git a/packages/write/src/index.ts b/packages/write/src/index.ts index 0fba55ac1..4328ff442 100644 --- a/packages/write/src/index.ts +++ b/packages/write/src/index.ts @@ -45,7 +45,7 @@ ${releases.map((release) => `"${release.name}": ${release.type}`).join("\n")} ${summary} `; - await fs.writeFile( + await fs.outputFile( newChangesetPath, // Prettier v3 returns a promise await prettierInstance.format(changesetContents, { diff --git a/packages/test-utils/README.md b/scripts/test-utils/README.md similarity index 68% rename from packages/test-utils/README.md rename to scripts/test-utils/README.md index 1bae06a7e..b9f923aff 100644 --- a/packages/test-utils/README.md +++ b/scripts/test-utils/README.md @@ -1,7 +1,5 @@ ## @changesets/test-utils -[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@changesets/test-utils) - > Utilities for testing @changesets/\* packages ### Utilities diff --git a/packages/test-utils/package.json b/scripts/test-utils/package.json similarity index 75% rename from packages/test-utils/package.json rename to scripts/test-utils/package.json index 309752714..067b48d7e 100644 --- a/packages/test-utils/package.json +++ b/scripts/test-utils/package.json @@ -1,12 +1,15 @@ { "name": "@changesets/test-utils", "version": "0.0.5", + "private": true, "description": "Utils for testing changesets packages", "main": "dist/test-utils.cjs.js", "module": "dist/test-utils.esm.js", "license": "MIT", "repository": "https://github.com/changesets/changesets/tree/main/packages/test-utils", "dependencies": { - "@changesets/logger": "^0.0.5" + "@changesets/logger": "^0.0.5", + "fixturez": "^1.1.0", + "fs-extra": "^7.0.1" } } diff --git a/packages/test-utils/src/index.test.ts b/scripts/test-utils/src/index.test.ts similarity index 100% rename from packages/test-utils/src/index.test.ts rename to scripts/test-utils/src/index.test.ts diff --git a/packages/test-utils/src/index.ts b/scripts/test-utils/src/index.ts similarity index 82% rename from packages/test-utils/src/index.ts rename to scripts/test-utils/src/index.ts index 3e7ab08ea..da878a06b 100644 --- a/packages/test-utils/src/index.ts +++ b/scripts/test-utils/src/index.ts @@ -1,3 +1,7 @@ +import fixturez from "fixturez"; +import path from "path"; +import fs from "fs-extra"; + /** * Reason for eslint disable import/no-commonjs * Technically reassigning imports is not allowed and @@ -81,3 +85,20 @@ export const temporarilySilenceLogs = dispose(); } }; + +let f = fixturez(__dirname); + +export interface Fixture extends Record {} + +export async function testdir(dir: Fixture) { + const temp = f.temp(); + await Promise.all( + Object.keys(dir).map(async (filename) => { + const fullPath = path.join(temp, filename); + await fs.outputFile(fullPath, dir[filename]); + }) + ); + return temp; +} + +export const tempdir = f.temp;