@changesets/pre
Advanced tools
Comparing version 1.0.13 to 1.0.14
# @changesets/pre | ||
## 1.0.14 | ||
### Patch Changes | ||
- Updated dependencies [[`521205d`](https://github.com/changesets/changesets/commit/521205dc8c70fe71b181bd3c4bb7c9c6d2e721d2)]: | ||
- @changesets/types@5.2.1 | ||
## 1.0.13 | ||
@@ -4,0 +11,0 @@ |
@@ -97,3 +97,3 @@ 'use strict'; | ||
await fs.writeFile(preStatePath, JSON.stringify(_objectSpread2(_objectSpread2({}, preState), {}, { | ||
await fs.outputFile(preStatePath, JSON.stringify(_objectSpread2(_objectSpread2({}, preState), {}, { | ||
mode: "exit" | ||
@@ -124,3 +124,3 @@ }), null, 2) + "\n"); | ||
await fs.writeFile(preStatePath, JSON.stringify(newPreState, null, 2) + "\n"); | ||
await fs.outputFile(preStatePath, JSON.stringify(newPreState, null, 2) + "\n"); | ||
} | ||
@@ -127,0 +127,0 @@ |
@@ -68,3 +68,3 @@ "use strict"; | ||
if (void 0 === preState) throw new errors.PreExitButNotInPreModeError; | ||
await fs.writeFile(preStatePath, JSON.stringify(_objectSpread2(_objectSpread2({}, preState), {}, { | ||
await fs.outputFile(preStatePath, JSON.stringify(_objectSpread2(_objectSpread2({}, preState), {}, { | ||
mode: "exit" | ||
@@ -85,5 +85,5 @@ }), null, 2) + "\n"); | ||
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"); | ||
} | ||
exports.enterPre = enterPre, exports.exitPre = exitPre, exports.readPreState = readPreState; |
@@ -1,2 +0,2 @@ | ||
import { readFile, writeFile } from 'fs-extra'; | ||
import { readFile, outputFile } from 'fs-extra'; | ||
import path from 'path'; | ||
@@ -89,3 +89,3 @@ import { getPackages } from '@manypkg/get-packages'; | ||
await writeFile(preStatePath, JSON.stringify(_objectSpread2(_objectSpread2({}, preState), {}, { | ||
await outputFile(preStatePath, JSON.stringify(_objectSpread2(_objectSpread2({}, preState), {}, { | ||
mode: "exit" | ||
@@ -116,5 +116,5 @@ }), null, 2) + "\n"); | ||
await writeFile(preStatePath, JSON.stringify(newPreState, null, 2) + "\n"); | ||
await outputFile(preStatePath, JSON.stringify(newPreState, null, 2) + "\n"); | ||
} | ||
export { enterPre, exitPre, readPreState }; |
{ | ||
"name": "@changesets/pre", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "Utils to make a Changesets repo enter and exit pre mode", | ||
@@ -10,5 +10,5 @@ "main": "dist/pre.cjs.js", | ||
"dependencies": { | ||
"@babel/runtime": "^7.10.4", | ||
"@babel/runtime": "^7.20.1", | ||
"@changesets/errors": "^0.1.4", | ||
"@changesets/types": "^5.2.0", | ||
"@changesets/types": "^5.2.1", | ||
"@manypkg/get-packages": "^1.1.3", | ||
@@ -18,4 +18,4 @@ "fs-extra": "^7.0.1" | ||
"devDependencies": { | ||
"fixturez": "^1.1.0" | ||
"@changesets/test-utils": "*" | ||
} | ||
} |
@@ -1,48 +0,71 @@ | ||
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"; | ||
} from "@changesets/errors"; | ||
import { testdir } from "@changesets/test-utils"; | ||
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", | ||
}; | ||
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(` | ||
{ | ||
"changesets": [], | ||
"initialVersions": { | ||
"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( | ||
@@ -53,15 +76,43 @@ 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( | ||
expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))) | ||
.toMatchInlineSnapshot(` | ||
{ | ||
...preStateForExited, | ||
mode: "pre", | ||
tag: "next", | ||
"changesets": [ | ||
"slimy-dingos-whisper", | ||
], | ||
"initialVersions": { | ||
"pkg-a": "1.0.0", | ||
"pkg-b": "1.0.0", | ||
}, | ||
"mode": "pre", | ||
"tag": "next", | ||
} | ||
); | ||
`); | ||
}); | ||
@@ -72,15 +123,62 @@ }); | ||
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(` | ||
{ | ||
"changesets": [], | ||
"initialVersions": { | ||
"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( | ||
@@ -93,8 +191,39 @@ PreExitButNotInPreModeError | ||
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(` | ||
{ | ||
"changesets": [], | ||
"initialVersions": { | ||
"pkg-a": "1.0.0", | ||
"pkg-b": "1.0.0", | ||
}, | ||
"mode": "pre", | ||
"tag": "next", | ||
} | ||
`); | ||
}); |
@@ -41,3 +41,3 @@ import * as fs from "fs-extra"; | ||
await fs.writeFile( | ||
await fs.outputFile( | ||
preStatePath, | ||
@@ -65,3 +65,6 @@ JSON.stringify({ ...preState, mode: "exit" }, null, 2) + "\n" | ||
} | ||
await fs.writeFile(preStatePath, JSON.stringify(newPreState, null, 2) + "\n"); | ||
await fs.outputFile( | ||
preStatePath, | ||
JSON.stringify(newPreState, null, 2) + "\n" | ||
); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26893
567
Updated@babel/runtime@^7.20.1
Updated@changesets/types@^5.2.1