rangutopia 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/library/build/action.js +3 -3
- package/dist/commands/library/build/action.js.map +1 -1
- package/dist/commands/library/mod.d.ts.map +1 -1
- package/dist/commands/library/mod.js +10 -2
- package/dist/commands/library/mod.js.map +1 -1
- package/dist/commands/library/publish/action.d.ts +3 -0
- package/dist/commands/library/publish/action.d.ts.map +1 -0
- package/dist/commands/library/publish/action.js +132 -0
- package/dist/commands/library/publish/action.js.map +1 -0
- package/dist/commands/library/publish/configs.d.ts +6 -0
- package/dist/commands/library/publish/configs.d.ts.map +1 -0
- package/dist/commands/library/publish/configs.js +23 -0
- package/dist/commands/library/publish/configs.js.map +1 -0
- package/dist/commands/library/publish/constants.d.ts +2 -0
- package/dist/commands/library/publish/constants.d.ts.map +1 -0
- package/dist/commands/library/publish/constants.js +2 -0
- package/dist/commands/library/publish/constants.js.map +1 -0
- package/dist/commands/library/publish/errors.d.ts +41 -0
- package/dist/commands/library/publish/errors.d.ts.map +1 -0
- package/dist/commands/library/publish/errors.js +61 -0
- package/dist/commands/library/publish/errors.js.map +1 -0
- package/dist/commands/library/publish/features.d.ts +7 -0
- package/dist/commands/library/publish/features.d.ts.map +1 -0
- package/dist/commands/library/publish/features.js +29 -0
- package/dist/commands/library/publish/features.js.map +1 -0
- package/dist/commands/library/publish/graph.d.ts +15 -0
- package/dist/commands/library/publish/graph.d.ts.map +1 -0
- package/dist/commands/library/publish/graph.js +82 -0
- package/dist/commands/library/publish/graph.js.map +1 -0
- package/dist/commands/library/publish/helpers.d.ts +29 -0
- package/dist/commands/library/publish/helpers.d.ts.map +1 -0
- package/dist/commands/library/publish/helpers.js +676 -0
- package/dist/commands/library/publish/helpers.js.map +1 -0
- package/dist/commands/library/publish/mod.d.ts +2 -0
- package/dist/commands/library/publish/mod.d.ts.map +1 -0
- package/dist/commands/library/publish/mod.js +2 -0
- package/dist/commands/library/publish/mod.js.map +1 -0
- package/dist/commands/library/publish/options.d.ts +9 -0
- package/dist/commands/library/publish/options.d.ts.map +1 -0
- package/dist/commands/library/publish/options.js +8 -0
- package/dist/commands/library/publish/options.js.map +1 -0
- package/dist/commands/library/publish/state.d.ts +22 -0
- package/dist/commands/library/publish/state.d.ts.map +1 -0
- package/dist/commands/library/publish/state.js +44 -0
- package/dist/commands/library/publish/state.js.map +1 -0
- package/dist/commands/library/publish/types.d.ts +27 -0
- package/dist/commands/library/publish/types.d.ts.map +1 -0
- package/dist/commands/library/publish/types.js +2 -0
- package/dist/commands/library/publish/types.js.map +1 -0
- package/dist/commands/tools/husky/init/action.d.ts.map +1 -1
- package/dist/commands/tools/husky/init/action.js +4 -4
- package/dist/commands/tools/husky/init/action.js.map +1 -1
- package/dist/commands/tools/lint/init/action.js +2 -2
- package/dist/commands/tools/lint/init/action.js.map +1 -1
- package/dist/configs.d.ts +8 -0
- package/dist/configs.d.ts.map +1 -0
- package/dist/configs.js +13 -0
- package/dist/configs.js.map +1 -0
- package/dist/main.js +2 -9
- package/dist/main.js.map +1 -1
- package/dist/modules/logger/logger.d.ts +19 -0
- package/dist/modules/logger/logger.d.ts.map +1 -0
- package/dist/modules/logger/logger.js +47 -0
- package/dist/modules/logger/logger.js.map +1 -0
- package/dist/modules/logger/mod.d.ts +2 -0
- package/dist/modules/logger/mod.d.ts.map +1 -0
- package/dist/modules/logger/mod.js +2 -0
- package/dist/modules/logger/mod.js.map +1 -0
- package/dist/modules/mod.d.ts +3 -0
- package/dist/modules/mod.d.ts.map +1 -0
- package/dist/modules/mod.js +3 -0
- package/dist/modules/mod.js.map +1 -0
- package/dist/modules/monorepoManager/mod.d.ts +6 -0
- package/dist/modules/monorepoManager/mod.d.ts.map +1 -0
- package/dist/modules/monorepoManager/mod.js +26 -0
- package/dist/modules/monorepoManager/mod.js.map +1 -0
- package/dist/modules/monorepoManager/monorepoManager.d.ts +12 -0
- package/dist/modules/monorepoManager/monorepoManager.d.ts.map +1 -0
- package/dist/modules/monorepoManager/monorepoManager.js +13 -0
- package/dist/modules/monorepoManager/monorepoManager.js.map +1 -0
- package/dist/modules/monorepoManager/nxAdapter.d.ts +9 -0
- package/dist/modules/monorepoManager/nxAdapter.d.ts.map +1 -0
- package/dist/modules/monorepoManager/nxAdapter.js +27 -0
- package/dist/modules/monorepoManager/nxAdapter.js.map +1 -0
- package/dist/modules/monorepoManager/turborepoAdapter.d.ts +9 -0
- package/dist/modules/monorepoManager/turborepoAdapter.d.ts.map +1 -0
- package/dist/modules/monorepoManager/turborepoAdapter.js +33 -0
- package/dist/modules/monorepoManager/turborepoAdapter.js.map +1 -0
- package/dist/modules/monorepoManager/types.d.ts +5 -0
- package/dist/modules/monorepoManager/types.d.ts.map +1 -0
- package/dist/modules/monorepoManager/types.js +2 -0
- package/dist/modules/monorepoManager/types.js.map +1 -0
- package/dist/setup.d.ts +3 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +16 -0
- package/dist/setup.js.map +1 -0
- package/dist/utils/changelog.d.ts +8 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +86 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/fs.d.ts +1 -0
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +5 -0
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/log.js +1 -1
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/packageJson.d.ts +22 -0
- package/dist/utils/packageJson.d.ts.map +1 -1
- package/dist/utils/packageJson.js +29 -2
- package/dist/utils/packageJson.js.map +1 -1
- package/dist/utils/yarn.d.ts +15 -1
- package/dist/utils/yarn.d.ts.map +1 -1
- package/dist/utils/yarn.js +59 -10
- package/dist/utils/yarn.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.json +3 -1
- package/.yarn/install-state.gz +0 -0
- package/dist/modules/logger.d.ts +0 -16
- package/dist/modules/logger.d.ts.map +0 -1
- package/dist/modules/logger.js +0 -34
- package/dist/modules/logger.js.map +0 -1
- package/dist/tests/e2e/publish/action.test.d.ts +0 -2
- package/dist/tests/e2e/publish/action.test.d.ts.map +0 -1
- package/dist/tests/e2e/publish/action.test.js +0 -1054
- package/dist/tests/e2e/publish/action.test.js.map +0 -1
- package/dist/utils/ps.d.ts +0 -4
- package/dist/utils/ps.d.ts.map +0 -1
- package/dist/utils/ps.js +0 -21
- package/dist/utils/ps.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -11
- package/dist/vitest.config.js.map +0 -1
- package/tests/e2e/publish/action.test.ts +0 -1393
|
@@ -1,1054 +0,0 @@
|
|
|
1
|
-
import { beforeAll, afterAll, describe, it, expect, vi, beforeEach, afterEach, } from "vitest";
|
|
2
|
-
import { mkdtempSync, writeFileSync, mkdirSync, readFileSync, existsSync, } from "node:fs";
|
|
3
|
-
import { rm } from "node:fs/promises";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { execSync } from "node:child_process";
|
|
7
|
-
import { action } from "../../../src/commands/library/publish/action.js";
|
|
8
|
-
import spawn from "nano-spawn";
|
|
9
|
-
import { removeMonorepoManager, setupMonorepoManager } from "../../../src/modules/mod.js";
|
|
10
|
-
const CHANGELOG_FILE_NAME = "CHANGELOG.md";
|
|
11
|
-
// ── Fixture dir — populated in beforeAll ──────────────────────────────────────
|
|
12
|
-
let fixtureDir = "";
|
|
13
|
-
const originalCwd = process.cwd();
|
|
14
|
-
// ── 1. npm registry: pretend the new version doesn't exist yet ────────────────
|
|
15
|
-
vi.stubGlobal("fetch", async (input) => {
|
|
16
|
-
const url = String(typeof input === "object" && "url" in input ? input.url : input);
|
|
17
|
-
if (url.startsWith("https://registry.npmjs.org")) {
|
|
18
|
-
return { ok: false, status: 404, json: async () => ({}) };
|
|
19
|
-
}
|
|
20
|
-
throw new Error(`Unexpected fetch in e2e test: ${url}`);
|
|
21
|
-
});
|
|
22
|
-
// ── 2. ROOT_PATH — lazily points at the fixture dir ──────────────────────────
|
|
23
|
-
// constants.ts evaluates ROOT_PATH at module load time as process.cwd().
|
|
24
|
-
// We replace the whole module with a getter so every access reads the
|
|
25
|
-
// current fixtureDir value (set before any test code runs).
|
|
26
|
-
vi.mock("../../../src/constants.js", () => ({
|
|
27
|
-
get ROOT_PATH() {
|
|
28
|
-
return fixtureDir;
|
|
29
|
-
},
|
|
30
|
-
}));
|
|
31
|
-
// ── 3. spawn — pass everything through except external-touching calls ────
|
|
32
|
-
vi.mock("nano-spawn", async (importOriginal) => {
|
|
33
|
-
const original = await importOriginal();
|
|
34
|
-
const mockFn = vi.fn(async (cmd, args, opts) => {
|
|
35
|
-
// Block git push
|
|
36
|
-
if (cmd === "git" && args[0] === "push")
|
|
37
|
-
return { stdout: "", stderr: "" };
|
|
38
|
-
// Block yarn publish → no npm registry
|
|
39
|
-
if (cmd === "yarn" && args.includes("publish"))
|
|
40
|
-
return { stdout: "", stderr: "" };
|
|
41
|
-
// gh release view → simulate "not found" so we never think it already exists
|
|
42
|
-
if (cmd === "gh" && args[0] === "release" && args[1] === "view") {
|
|
43
|
-
const err = new Error("release not found");
|
|
44
|
-
err.stderr = "release not found";
|
|
45
|
-
throw err;
|
|
46
|
-
}
|
|
47
|
-
// gh release create → block, no real GitHub token in CI
|
|
48
|
-
if (cmd === "gh" && args[0] === "release" && args[1] === "create")
|
|
49
|
-
return { stdout: "", stderr: "" };
|
|
50
|
-
// Everything else (git log / tag / add / commit, yarn version …) runs for
|
|
51
|
-
// real against the fixture repo.
|
|
52
|
-
return original.default(cmd, args, opts);
|
|
53
|
-
});
|
|
54
|
-
return { default: mockFn };
|
|
55
|
-
});
|
|
56
|
-
// ── 4. Logger — silence output ────────────────────────────────────────────────
|
|
57
|
-
vi.mock("../../../src/modules/mod.js", async (importOriginal) => {
|
|
58
|
-
const original = await importOriginal();
|
|
59
|
-
return {
|
|
60
|
-
...original,
|
|
61
|
-
logger: {
|
|
62
|
-
info: vi.fn(),
|
|
63
|
-
warn: vi.fn(),
|
|
64
|
-
error: vi.fn(),
|
|
65
|
-
success: vi.fn(),
|
|
66
|
-
trace: vi.fn(),
|
|
67
|
-
verbose: vi.fn(),
|
|
68
|
-
table: vi.fn(),
|
|
69
|
-
githubAction: { group: vi.fn(), endGroup: vi.fn() },
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
// ── Assertion helpers ─────────────────────────────────────────────────────────
|
|
74
|
-
// Mirrors production code: scoped packages (@scope/name) use bare name in git tags / GH releases.
|
|
75
|
-
function tagName(pkgName) {
|
|
76
|
-
return pkgName.replace(/@.+\//, '');
|
|
77
|
-
}
|
|
78
|
-
function expectPublishSpawnCalls(tag, published, notPublished, { expectCommit = true, gitReleases } = {}) {
|
|
79
|
-
expect(spawn).toHaveBeenCalledWith("git", ["push", "origin", "--follow-tags", "--no-verify", "--atomic"]);
|
|
80
|
-
if (expectCommit) {
|
|
81
|
-
expect(spawn).toHaveBeenCalledWith("git", expect.arrayContaining(["commit"]));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
expect(spawn).not.toHaveBeenCalledWith("git", expect.arrayContaining(["commit"]));
|
|
85
|
-
}
|
|
86
|
-
published.forEach((pkg, i) => {
|
|
87
|
-
if (gitReleases) {
|
|
88
|
-
expect(spawn).toHaveBeenCalledWith("gh", expect.arrayContaining([
|
|
89
|
-
"release", "create", `${tagName(pkg)}@${gitReleases.newVersion}`,
|
|
90
|
-
expect.stringContaining(gitReleases.commits[i]),
|
|
91
|
-
]));
|
|
92
|
-
}
|
|
93
|
-
expect(spawn).toHaveBeenCalledWith("yarn", ["publish", `packages/${pkg}`, "--tag", tag]);
|
|
94
|
-
});
|
|
95
|
-
for (const pkg of notPublished) {
|
|
96
|
-
expect(spawn).not.toHaveBeenCalledWith("yarn", ["publish", `packages/${pkg}`, "--tag", tag]);
|
|
97
|
-
if (gitReleases)
|
|
98
|
-
expect(spawn).not.toHaveBeenCalledWith("gh", expect.arrayContaining(["release", "create", expect.stringContaining(tagName(pkg))]));
|
|
99
|
-
}
|
|
100
|
-
if (!gitReleases)
|
|
101
|
-
expect(spawn).not.toHaveBeenCalledWith("gh", expect.arrayContaining(["release", "create"]));
|
|
102
|
-
}
|
|
103
|
-
function readPkgJson(pkgDir) {
|
|
104
|
-
return JSON.parse(readFileSync(join(pkgDir, "package.json"), "utf8"));
|
|
105
|
-
}
|
|
106
|
-
function expectPackageVersions(checks) {
|
|
107
|
-
for (const [pkgDir, version] of checks) {
|
|
108
|
-
expect(readPkgJson(pkgDir).version).toBe(version);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function expectDependencyVersions(checks) {
|
|
112
|
-
for (const [pkgDir, depName, version] of checks) {
|
|
113
|
-
expect(readPkgJson(pkgDir).dependencies[depName]).toBe(version);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function expectChangelogs(checks) {
|
|
117
|
-
for (const { dir, exists, match, notMatch } of checks) {
|
|
118
|
-
const changelogPath = join(dir, CHANGELOG_FILE_NAME);
|
|
119
|
-
expect(existsSync(changelogPath)).toBe(exists);
|
|
120
|
-
if (exists) {
|
|
121
|
-
const content = readFileSync(changelogPath, "utf8");
|
|
122
|
-
if (match !== undefined)
|
|
123
|
-
expect(content).toMatch(match);
|
|
124
|
-
if (notMatch !== undefined)
|
|
125
|
-
expect(content).not.toMatch(notMatch);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
function expectReleaseCommit(pkgsAndVersions = [], notContains = []) {
|
|
130
|
-
const log = execSync("git log -1 --format=%B").toString();
|
|
131
|
-
expect(log).toMatch(/^chore\(release\): publish/);
|
|
132
|
-
for (const [name, version] of pkgsAndVersions) {
|
|
133
|
-
expect(log).toContain(`${tagName(name)}@${version}`);
|
|
134
|
-
}
|
|
135
|
-
for (const name of notContains) {
|
|
136
|
-
expect(log).not.toContain(name);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function expectNoReleaseCommit() {
|
|
140
|
-
expect(execSync("git log -1 --format=%s").toString()).not.toMatch(/^chore\(release\): publish/);
|
|
141
|
-
}
|
|
142
|
-
function expectTags(present, absent) {
|
|
143
|
-
for (const [name, version] of present) {
|
|
144
|
-
const tag = `${tagName(name)}@${version}`;
|
|
145
|
-
expect(execSync(`git tag -l ${tag}`).toString().trim()).toBe(tag);
|
|
146
|
-
}
|
|
147
|
-
for (const [name, version] of absent) {
|
|
148
|
-
const tag = `${tagName(name)}@${version}`;
|
|
149
|
-
expect(execSync(`git tag -l ${tag}`).toString().trim()).toBe("");
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function expectNoTags() {
|
|
153
|
-
expect(execSync("git tag").toString().trim()).toBe("");
|
|
154
|
-
}
|
|
155
|
-
function expectNothingPublished() {
|
|
156
|
-
expect(spawn).not.toHaveBeenCalledWith("git", expect.arrayContaining(["commit"]));
|
|
157
|
-
expect(spawn).not.toHaveBeenCalledWith("gh", expect.arrayContaining(["release", "create"]));
|
|
158
|
-
expect(spawn).not.toHaveBeenCalledWith("yarn", expect.arrayContaining(["publish"]));
|
|
159
|
-
}
|
|
160
|
-
// ── Shared fixture constants ───────────────────────────────────────────────────
|
|
161
|
-
const PKG_A_NAME = "@scoped-name/pkg-a";
|
|
162
|
-
const PKG_A_DIR = join("packages", PKG_A_NAME);
|
|
163
|
-
const PKG_B_NAME = "pkg-b";
|
|
164
|
-
const PKG_B_DIR = join("packages", PKG_B_NAME);
|
|
165
|
-
const PKG_C_NAME = "pkg-c";
|
|
166
|
-
const PKG_C_DIR = join("packages", PKG_C_NAME);
|
|
167
|
-
const PKG_D_NAME = "pkg-d";
|
|
168
|
-
const PKG_D_DIR = join("packages", PKG_D_NAME);
|
|
169
|
-
const PKG_E_NAME = "pkg-e";
|
|
170
|
-
const PKG_E_DIR = join("packages", PKG_E_NAME);
|
|
171
|
-
const PKG_F_NAME = "pkg-f";
|
|
172
|
-
const PKG_F_DIR = join("packages", PKG_F_NAME);
|
|
173
|
-
const FIRST_VERSION = "0.0.0";
|
|
174
|
-
// Writes a package's package.json and a minimal src/index.js in one call.
|
|
175
|
-
function writePackageFixture(pkgDir, pkgJson) {
|
|
176
|
-
mkdirSync(join(pkgDir, "src"), { recursive: true });
|
|
177
|
-
writeFileSync(join(pkgDir, "package.json"), JSON.stringify({ ...pkgJson, scripts: { build: "node -e ''" } }));
|
|
178
|
-
writeFileSync(join(pkgDir, "src", "index.js"), `console.log("hello ${pkgJson.name}")\n`);
|
|
179
|
-
}
|
|
180
|
-
function expectNoChangelogs() {
|
|
181
|
-
expectChangelogs([
|
|
182
|
-
{ dir: PKG_A_DIR, exists: false },
|
|
183
|
-
{ dir: PKG_B_DIR, exists: false },
|
|
184
|
-
{ dir: PKG_C_DIR, exists: false },
|
|
185
|
-
{ dir: PKG_D_DIR, exists: false },
|
|
186
|
-
{ dir: PKG_E_DIR, exists: false },
|
|
187
|
-
{ dir: PKG_F_DIR, exists: false },
|
|
188
|
-
]);
|
|
189
|
-
}
|
|
190
|
-
// ── Shared setup / teardown ───────────────────────────────────────────────────
|
|
191
|
-
async function setupFixture(writeMonorepoConfig) {
|
|
192
|
-
process.env.NX_DAEMON = "false";
|
|
193
|
-
fixtureDir = mkdtempSync(join(tmpdir(), "rangutopia-e2e-mono-"));
|
|
194
|
-
process.chdir(fixtureDir);
|
|
195
|
-
writeMonorepoConfig();
|
|
196
|
-
setupMonorepoManager();
|
|
197
|
-
writePackageFixture(PKG_A_DIR, { name: PKG_A_NAME, private: false, version: FIRST_VERSION, dependencies: { [PKG_C_NAME]: FIRST_VERSION } });
|
|
198
|
-
writePackageFixture(PKG_B_DIR, { name: PKG_B_NAME, private: false, version: FIRST_VERSION });
|
|
199
|
-
writePackageFixture(PKG_C_DIR, { name: PKG_C_NAME, private: false, version: FIRST_VERSION, dependencies: { [PKG_B_NAME]: FIRST_VERSION } });
|
|
200
|
-
writePackageFixture(PKG_D_DIR, { name: PKG_D_NAME, private: false, version: FIRST_VERSION });
|
|
201
|
-
writePackageFixture(PKG_E_DIR, { name: PKG_E_NAME, private: false, version: FIRST_VERSION, dependencies: { [PKG_D_NAME]: FIRST_VERSION } });
|
|
202
|
-
writePackageFixture(PKG_F_DIR, { name: PKG_F_NAME, private: true, version: FIRST_VERSION, dependencies: { [PKG_A_NAME]: FIRST_VERSION, [PKG_B_NAME]: FIRST_VERSION, [PKG_D_NAME]: FIRST_VERSION } });
|
|
203
|
-
writeFileSync(".gitignore", "node_modules\n");
|
|
204
|
-
// Run yarn install to fully initialize the workspace so that
|
|
205
|
-
// `yarn workspace <name> version` can resolve package names.
|
|
206
|
-
execSync("yarn install");
|
|
207
|
-
execSync("git init -b main");
|
|
208
|
-
execSync('git config user.email "test@test.com"');
|
|
209
|
-
execSync('git config user.name "Test"');
|
|
210
|
-
execSync("git add .");
|
|
211
|
-
execSync('git commit -m "feat: initial commit"');
|
|
212
|
-
execSync("git update-ref refs/remotes/origin/main HEAD");
|
|
213
|
-
}
|
|
214
|
-
async function teardownFixture() {
|
|
215
|
-
delete process.env.NX_DAEMON;
|
|
216
|
-
process.chdir(originalCwd);
|
|
217
|
-
vi.clearAllMocks();
|
|
218
|
-
await rm(fixtureDir, { recursive: true, force: true });
|
|
219
|
-
removeMonorepoManager();
|
|
220
|
-
// removing changelogs cache folder
|
|
221
|
-
await rm(join(tmpdir(), "CHANGELOGS"), { recursive: true, force: true });
|
|
222
|
-
}
|
|
223
|
-
// ── Monorepo-specific config writers ─────────────────────────────────────────
|
|
224
|
-
function writeNxConfig() {
|
|
225
|
-
writeFileSync("package.json", JSON.stringify({
|
|
226
|
-
name: "monorepo-root",
|
|
227
|
-
private: true,
|
|
228
|
-
packageManager: "yarn@1.22.22",
|
|
229
|
-
workspaces: ["packages/*", "packages/@scoped-name/*"],
|
|
230
|
-
dependencies: {
|
|
231
|
-
nx: "latest",
|
|
232
|
-
}
|
|
233
|
-
}));
|
|
234
|
-
writeFileSync("nx.json", JSON.stringify({
|
|
235
|
-
"$schema": "./node_modules/nx/schemas/nx-schema.json",
|
|
236
|
-
}));
|
|
237
|
-
}
|
|
238
|
-
function writeTurboConfig() {
|
|
239
|
-
writeFileSync("package.json", JSON.stringify({
|
|
240
|
-
name: "monorepo-root",
|
|
241
|
-
private: true,
|
|
242
|
-
packageManager: "yarn@1.22.22",
|
|
243
|
-
workspaces: ["packages/*", "packages/@scoped-name/*"],
|
|
244
|
-
dependencies: {
|
|
245
|
-
turbo: "latest",
|
|
246
|
-
}
|
|
247
|
-
}));
|
|
248
|
-
writeFileSync("turbo.json", JSON.stringify({
|
|
249
|
-
"$schema": "https://turborepo.dev/schema.json",
|
|
250
|
-
"ui": "tui",
|
|
251
|
-
"tasks": {
|
|
252
|
-
"build": {
|
|
253
|
-
"dependsOn": ["^build"],
|
|
254
|
-
"inputs": ["$TURBO_DEFAULT$", ".env*"],
|
|
255
|
-
"outputs": [".next/**", "!.next/cache/**"]
|
|
256
|
-
},
|
|
257
|
-
"lint": {
|
|
258
|
-
"dependsOn": ["^lint"]
|
|
259
|
-
},
|
|
260
|
-
"check-types": {
|
|
261
|
-
"dependsOn": ["^check-types"]
|
|
262
|
-
},
|
|
263
|
-
"dev": {
|
|
264
|
-
"cache": false,
|
|
265
|
-
"persistent": true
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}));
|
|
269
|
-
}
|
|
270
|
-
// ── Tests ─────────────────────────────────────────────────────────────────────
|
|
271
|
-
describe("publish in a nx monorepo", () => {
|
|
272
|
-
beforeEach(async () => { await setupFixture(writeNxConfig); });
|
|
273
|
-
afterEach(async () => { await teardownFixture(); });
|
|
274
|
-
describe("production flow", () => {
|
|
275
|
-
it("should publish the first version with since start option enabled", async () => {
|
|
276
|
-
const UPDATED_VERSION = "0.1.0";
|
|
277
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
278
|
-
await action({
|
|
279
|
-
prod: true,
|
|
280
|
-
next: false,
|
|
281
|
-
experimental: false,
|
|
282
|
-
sinceStart: true,
|
|
283
|
-
});
|
|
284
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
285
|
-
expectPublishSpawnCalls("latest", [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME, PKG_D_NAME, PKG_E_NAME], [PKG_F_NAME], { gitReleases: { newVersion: UPDATED_VERSION, commits: ["initial commit", "initial commit", "initial commit", "initial commit", "initial commit"] } });
|
|
286
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
287
|
-
expectPackageVersions([
|
|
288
|
-
[PKG_A_DIR, UPDATED_VERSION],
|
|
289
|
-
[PKG_B_DIR, UPDATED_VERSION],
|
|
290
|
-
[PKG_C_DIR, UPDATED_VERSION],
|
|
291
|
-
[PKG_D_DIR, UPDATED_VERSION],
|
|
292
|
-
[PKG_E_DIR, UPDATED_VERSION],
|
|
293
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
294
|
-
]);
|
|
295
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
296
|
-
expectDependencyVersions([
|
|
297
|
-
[PKG_A_DIR, PKG_C_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
298
|
-
[PKG_C_DIR, PKG_B_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
299
|
-
[PKG_E_DIR, PKG_D_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
300
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
301
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
302
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
303
|
-
]);
|
|
304
|
-
// ── 4. changelogs ─────────────────────────────────────────────────────────
|
|
305
|
-
const featureMatch = new RegExp(`${UPDATED_VERSION}[\\s\\S]*Features[\\s\\S]*initial commit`);
|
|
306
|
-
expectChangelogs([
|
|
307
|
-
{ dir: PKG_A_DIR, exists: true, match: featureMatch },
|
|
308
|
-
{ dir: PKG_B_DIR, exists: true, match: featureMatch },
|
|
309
|
-
{ dir: PKG_C_DIR, exists: true, match: featureMatch },
|
|
310
|
-
{ dir: PKG_D_DIR, exists: true, match: featureMatch },
|
|
311
|
-
{ dir: PKG_E_DIR, exists: true, match: featureMatch },
|
|
312
|
-
{ dir: PKG_F_DIR, exists: false },
|
|
313
|
-
]);
|
|
314
|
-
// ── 5. release commit ─────────────────────────────────────────────────────
|
|
315
|
-
expectReleaseCommit([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]], [PKG_F_NAME]);
|
|
316
|
-
// ── 6. tags ───────────────────────────────────────────────────────────────
|
|
317
|
-
expectTags([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]], [[PKG_F_NAME, UPDATED_VERSION]]);
|
|
318
|
-
});
|
|
319
|
-
it("should throw an error with since start option disabled", async () => {
|
|
320
|
-
await expect(action({
|
|
321
|
-
prod: true,
|
|
322
|
-
next: false,
|
|
323
|
-
experimental: false,
|
|
324
|
-
sinceStart: false,
|
|
325
|
-
})).rejects.toThrow("Couldn't find the commit hash to compare to for the selected method");
|
|
326
|
-
expectNothingPublished();
|
|
327
|
-
});
|
|
328
|
-
it("should update all dependent packages for second publish in the production flow with pkg-b changing", async () => {
|
|
329
|
-
const PREV_VERSION = "0.1.0";
|
|
330
|
-
const PREV_DEPENDENCY_VERSION = "^" + PREV_VERSION;
|
|
331
|
-
const UPDATED_VERSION = "0.2.0";
|
|
332
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
333
|
-
await action({
|
|
334
|
-
prod: true,
|
|
335
|
-
next: false,
|
|
336
|
-
experimental: false,
|
|
337
|
-
sinceStart: true,
|
|
338
|
-
});
|
|
339
|
-
writeFileSync(join(PKG_B_DIR, "src", "index.js"), 'console.log("hello pkg-b!")\n\n');
|
|
340
|
-
execSync("git add .");
|
|
341
|
-
execSync('git commit -m "feat: second feature"');
|
|
342
|
-
vi.clearAllMocks();
|
|
343
|
-
await action({
|
|
344
|
-
prod: true,
|
|
345
|
-
next: false,
|
|
346
|
-
experimental: false,
|
|
347
|
-
sinceStart: false,
|
|
348
|
-
});
|
|
349
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
350
|
-
expectPublishSpawnCalls("latest", [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME], [PKG_D_NAME, PKG_E_NAME, PKG_F_NAME], { gitReleases: { newVersion: UPDATED_VERSION, commits: ["", "second feature", ""] } });
|
|
351
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
352
|
-
expectPackageVersions([
|
|
353
|
-
[PKG_A_DIR, UPDATED_VERSION],
|
|
354
|
-
[PKG_B_DIR, UPDATED_VERSION],
|
|
355
|
-
[PKG_C_DIR, UPDATED_VERSION],
|
|
356
|
-
[PKG_D_DIR, PREV_VERSION],
|
|
357
|
-
[PKG_E_DIR, PREV_VERSION],
|
|
358
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
359
|
-
]);
|
|
360
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
361
|
-
expectDependencyVersions([
|
|
362
|
-
[PKG_A_DIR, PKG_C_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
363
|
-
[PKG_C_DIR, PKG_B_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
364
|
-
[PKG_E_DIR, PKG_D_NAME, PREV_DEPENDENCY_VERSION],
|
|
365
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
366
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
367
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
368
|
-
]);
|
|
369
|
-
// ── 4. changelogs ─────────────────────────────────────────────────────────
|
|
370
|
-
expectChangelogs([
|
|
371
|
-
{ dir: PKG_B_DIR, exists: true, match: new RegExp(`${UPDATED_VERSION}[\\s\\S]*Features[\\s\\S]*second feature[\\s\\S]*${PREV_VERSION}[\\s\\S]*Features[\\s\\S]*initial commit`) },
|
|
372
|
-
{ dir: PKG_A_DIR, exists: true, match: new RegExp(`${UPDATED_VERSION}[\\s\\S]*${PREV_VERSION}[\\s\\S]*Features[\\s\\S]*initial commit`), notMatch: /second feature/ },
|
|
373
|
-
{ dir: PKG_C_DIR, exists: true, match: new RegExp(`${UPDATED_VERSION}[\\s\\S]*${PREV_VERSION}[\\s\\S]*Features[\\s\\S]*initial commit`), notMatch: /second feature/ },
|
|
374
|
-
{ dir: PKG_D_DIR, exists: true, notMatch: new RegExp(UPDATED_VERSION) },
|
|
375
|
-
{ dir: PKG_E_DIR, exists: true, notMatch: new RegExp(UPDATED_VERSION) },
|
|
376
|
-
{ dir: PKG_F_DIR, exists: false },
|
|
377
|
-
]);
|
|
378
|
-
// ── 5. release commit ─────────────────────────────────────────────────────
|
|
379
|
-
expectReleaseCommit([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION]]);
|
|
380
|
-
// ── 6. tags ───────────────────────────────────────────────────────────────
|
|
381
|
-
expectTags([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION]], [[PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION], [PKG_F_NAME, UPDATED_VERSION]]);
|
|
382
|
-
});
|
|
383
|
-
it("should exit with code 0 after updating a private package", async () => {
|
|
384
|
-
await action({
|
|
385
|
-
prod: true,
|
|
386
|
-
next: false,
|
|
387
|
-
experimental: false,
|
|
388
|
-
sinceStart: true,
|
|
389
|
-
});
|
|
390
|
-
writeFileSync(join(PKG_F_DIR, "src", "index.js"), 'console.log("hello pkg-f!")\n\n');
|
|
391
|
-
execSync("git add .");
|
|
392
|
-
execSync('git commit -m "feat: second feature"');
|
|
393
|
-
vi.clearAllMocks();
|
|
394
|
-
const exitSpy = vi.spyOn(process, "exit").mockImplementation(() => undefined);
|
|
395
|
-
await action({
|
|
396
|
-
prod: true,
|
|
397
|
-
next: false,
|
|
398
|
-
experimental: false,
|
|
399
|
-
sinceStart: false,
|
|
400
|
-
});
|
|
401
|
-
expect(exitSpy).toHaveBeenCalledWith(0);
|
|
402
|
-
exitSpy.mockRestore();
|
|
403
|
-
});
|
|
404
|
-
it("should throw an error after a publication in experimental flow with since start disabled", async () => {
|
|
405
|
-
execSync("git checkout -b experimental");
|
|
406
|
-
writeFileSync(join(PKG_A_DIR, "src", "index.js"), 'console.log("hello pkg-a")\n\n');
|
|
407
|
-
execSync("git add .");
|
|
408
|
-
execSync('git commit -m "feat: second feature"');
|
|
409
|
-
await action({
|
|
410
|
-
prod: false,
|
|
411
|
-
next: false,
|
|
412
|
-
experimental: true,
|
|
413
|
-
sinceStart: false,
|
|
414
|
-
});
|
|
415
|
-
execSync("git restore --staged .");
|
|
416
|
-
execSync("git restore .");
|
|
417
|
-
execSync("git checkout main");
|
|
418
|
-
execSync("git rebase experimental");
|
|
419
|
-
vi.clearAllMocks();
|
|
420
|
-
await expect(action({
|
|
421
|
-
prod: true,
|
|
422
|
-
next: false,
|
|
423
|
-
experimental: false,
|
|
424
|
-
sinceStart: false,
|
|
425
|
-
})).rejects.toThrow("Couldn't find the commit hash to compare to for the selected method");
|
|
426
|
-
expectNothingPublished();
|
|
427
|
-
});
|
|
428
|
-
it("should increase and update versions after a publication in production flow and a publication in experimental flow", async () => {
|
|
429
|
-
const PREV_VERSION = "0.1.0";
|
|
430
|
-
const PREV_DEPENDENCY_VERSION = "^" + PREV_VERSION;
|
|
431
|
-
const UPDATED_VERSION = "0.2.0";
|
|
432
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
433
|
-
await action({
|
|
434
|
-
prod: true,
|
|
435
|
-
next: false,
|
|
436
|
-
experimental: false,
|
|
437
|
-
sinceStart: true,
|
|
438
|
-
});
|
|
439
|
-
execSync("git checkout -b experimental");
|
|
440
|
-
writeFileSync(join(PKG_C_DIR, "src", "index.js"), 'console.log("hello pkg-c")\n\n');
|
|
441
|
-
execSync("git add .");
|
|
442
|
-
execSync('git commit -m "feat: second feature"');
|
|
443
|
-
await action({
|
|
444
|
-
prod: false,
|
|
445
|
-
next: false,
|
|
446
|
-
experimental: true,
|
|
447
|
-
sinceStart: false,
|
|
448
|
-
});
|
|
449
|
-
execSync("git restore --staged .");
|
|
450
|
-
execSync("git restore .");
|
|
451
|
-
execSync("git checkout main");
|
|
452
|
-
execSync("git rebase experimental");
|
|
453
|
-
vi.clearAllMocks();
|
|
454
|
-
await action({
|
|
455
|
-
prod: true,
|
|
456
|
-
next: false,
|
|
457
|
-
experimental: false,
|
|
458
|
-
sinceStart: false,
|
|
459
|
-
});
|
|
460
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
461
|
-
expectPublishSpawnCalls("latest", [PKG_A_NAME, PKG_C_NAME], [PKG_B_NAME, PKG_D_NAME, PKG_E_NAME, PKG_F_NAME], { gitReleases: { newVersion: UPDATED_VERSION, commits: ["", "second feature"] } });
|
|
462
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
463
|
-
expectPackageVersions([
|
|
464
|
-
[PKG_A_DIR, UPDATED_VERSION],
|
|
465
|
-
[PKG_C_DIR, UPDATED_VERSION],
|
|
466
|
-
[PKG_B_DIR, PREV_VERSION],
|
|
467
|
-
[PKG_D_DIR, PREV_VERSION],
|
|
468
|
-
[PKG_E_DIR, PREV_VERSION],
|
|
469
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
470
|
-
]);
|
|
471
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
472
|
-
expectDependencyVersions([
|
|
473
|
-
[PKG_A_DIR, PKG_C_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
474
|
-
[PKG_C_DIR, PKG_B_NAME, PREV_DEPENDENCY_VERSION],
|
|
475
|
-
[PKG_E_DIR, PKG_D_NAME, PREV_DEPENDENCY_VERSION],
|
|
476
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
477
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
478
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
479
|
-
]);
|
|
480
|
-
// ── 4. changelogs ─────────────────────────────────────────────────────────
|
|
481
|
-
expectChangelogs([
|
|
482
|
-
{ dir: PKG_C_DIR, exists: true, match: new RegExp(`${UPDATED_VERSION}[\\s\\S]*Features[\\s\\S]*second feature[\\s\\S]*${PREV_VERSION}[\\s\\S]*Features[\\s\\S]*initial commit`) },
|
|
483
|
-
{ dir: PKG_A_DIR, exists: true, match: new RegExp(`${UPDATED_VERSION}[\\s\\S]*${PREV_VERSION}[\\s\\S]*Features[\\s\\S]*initial commit`), notMatch: /second feature/ },
|
|
484
|
-
{ dir: PKG_B_DIR, exists: true, notMatch: new RegExp(UPDATED_VERSION) },
|
|
485
|
-
{ dir: PKG_D_DIR, exists: true, notMatch: new RegExp(UPDATED_VERSION) },
|
|
486
|
-
{ dir: PKG_E_DIR, exists: true, notMatch: new RegExp(UPDATED_VERSION) },
|
|
487
|
-
{ dir: PKG_F_DIR, exists: false },
|
|
488
|
-
]);
|
|
489
|
-
// ── 5. release commit ─────────────────────────────────────────────────────
|
|
490
|
-
expectReleaseCommit([[PKG_A_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION]]);
|
|
491
|
-
// ── 6. tags ───────────────────────────────────────────────────────────────
|
|
492
|
-
expectTags([[PKG_A_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION]], [[PKG_B_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION], [PKG_F_NAME, UPDATED_VERSION]]);
|
|
493
|
-
});
|
|
494
|
-
it("should increase and update versions and then publish it after a publication in prerelease flow", async () => {
|
|
495
|
-
const UPDATED_VERSION = "0.1.0";
|
|
496
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
497
|
-
await action({
|
|
498
|
-
prod: false,
|
|
499
|
-
next: true,
|
|
500
|
-
experimental: false,
|
|
501
|
-
sinceStart: true,
|
|
502
|
-
});
|
|
503
|
-
vi.clearAllMocks();
|
|
504
|
-
await action({
|
|
505
|
-
prod: true,
|
|
506
|
-
next: false,
|
|
507
|
-
experimental: false,
|
|
508
|
-
sinceStart: true,
|
|
509
|
-
});
|
|
510
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
511
|
-
expectPublishSpawnCalls("latest", [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME, PKG_D_NAME, PKG_E_NAME], [PKG_F_NAME], { gitReleases: { newVersion: UPDATED_VERSION, commits: ["initial commit", "initial commit", "initial commit", "initial commit", "initial commit"] } });
|
|
512
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
513
|
-
expectPackageVersions([
|
|
514
|
-
[PKG_A_DIR, UPDATED_VERSION],
|
|
515
|
-
[PKG_B_DIR, UPDATED_VERSION],
|
|
516
|
-
[PKG_C_DIR, UPDATED_VERSION],
|
|
517
|
-
[PKG_D_DIR, UPDATED_VERSION],
|
|
518
|
-
[PKG_E_DIR, UPDATED_VERSION],
|
|
519
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
520
|
-
]);
|
|
521
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
522
|
-
expectDependencyVersions([
|
|
523
|
-
[PKG_A_DIR, PKG_C_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
524
|
-
[PKG_C_DIR, PKG_B_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
525
|
-
[PKG_E_DIR, PKG_D_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
526
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
527
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
528
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
529
|
-
]);
|
|
530
|
-
// ── 4. changelogs ─────────────────────────────────────────────────────────
|
|
531
|
-
const featureMatch = new RegExp(`${UPDATED_VERSION}[\\s\\S]*Features[\\s\\S]*initial commit`);
|
|
532
|
-
expectChangelogs([
|
|
533
|
-
{ dir: PKG_A_DIR, exists: true, match: featureMatch },
|
|
534
|
-
{ dir: PKG_B_DIR, exists: true, match: featureMatch },
|
|
535
|
-
{ dir: PKG_C_DIR, exists: true, match: featureMatch },
|
|
536
|
-
{ dir: PKG_D_DIR, exists: true, match: featureMatch },
|
|
537
|
-
{ dir: PKG_E_DIR, exists: true, match: featureMatch },
|
|
538
|
-
{ dir: PKG_F_DIR, exists: false },
|
|
539
|
-
]);
|
|
540
|
-
// ── 5. release commit ─────────────────────────────────────────────────────
|
|
541
|
-
expectReleaseCommit([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]], [PKG_F_NAME]);
|
|
542
|
-
// ── 6. tags ───────────────────────────────────────────────────────────────
|
|
543
|
-
expectTags([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]], [[PKG_F_NAME, UPDATED_VERSION]]);
|
|
544
|
-
});
|
|
545
|
-
it("should throw an error with since start disabled after a publication in prerelease flow", async () => {
|
|
546
|
-
await action({
|
|
547
|
-
prod: false,
|
|
548
|
-
next: true,
|
|
549
|
-
experimental: false,
|
|
550
|
-
sinceStart: true,
|
|
551
|
-
});
|
|
552
|
-
vi.clearAllMocks();
|
|
553
|
-
await expect(action({
|
|
554
|
-
prod: true,
|
|
555
|
-
next: false,
|
|
556
|
-
experimental: false,
|
|
557
|
-
sinceStart: false,
|
|
558
|
-
})).rejects.toThrow("Couldn't find the commit hash to compare to for the selected method");
|
|
559
|
-
expectNothingPublished();
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
describe("prerelease flow", () => {
|
|
563
|
-
it("should publish the first prerelease version with since start option enabled without tag and changelog", async () => {
|
|
564
|
-
const UPDATED_VERSION = "0.0.1-next.0";
|
|
565
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
566
|
-
await action({
|
|
567
|
-
prod: false,
|
|
568
|
-
next: true,
|
|
569
|
-
experimental: false,
|
|
570
|
-
sinceStart: true,
|
|
571
|
-
});
|
|
572
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
573
|
-
expectPublishSpawnCalls("next", [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME, PKG_D_NAME, PKG_E_NAME], [PKG_F_NAME]);
|
|
574
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
575
|
-
expectPackageVersions([
|
|
576
|
-
[PKG_A_DIR, UPDATED_VERSION],
|
|
577
|
-
[PKG_B_DIR, UPDATED_VERSION],
|
|
578
|
-
[PKG_C_DIR, UPDATED_VERSION],
|
|
579
|
-
[PKG_D_DIR, UPDATED_VERSION],
|
|
580
|
-
[PKG_E_DIR, UPDATED_VERSION],
|
|
581
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
582
|
-
]);
|
|
583
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
584
|
-
expectDependencyVersions([
|
|
585
|
-
[PKG_A_DIR, PKG_C_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
586
|
-
[PKG_C_DIR, PKG_B_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
587
|
-
[PKG_E_DIR, PKG_D_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
588
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
589
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
590
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
591
|
-
]);
|
|
592
|
-
// ── 4. changelogs (none for prerelease) ───────────────────────────────────
|
|
593
|
-
expectNoChangelogs();
|
|
594
|
-
// ── 5. release commit ─────────────────────────────────────────────────────
|
|
595
|
-
expectReleaseCommit([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]], [PKG_F_NAME]);
|
|
596
|
-
// ── 6. no tags for prerelease ─────────────────────────────────────────────
|
|
597
|
-
expectNoTags();
|
|
598
|
-
});
|
|
599
|
-
it("should throw an error with since start option disabled for the first publication", async () => {
|
|
600
|
-
await expect(action({
|
|
601
|
-
prod: false,
|
|
602
|
-
next: true,
|
|
603
|
-
experimental: false,
|
|
604
|
-
sinceStart: false,
|
|
605
|
-
})).rejects.toThrow("Couldn't find the commit hash to compare to for the selected method");
|
|
606
|
-
expectNothingPublished();
|
|
607
|
-
});
|
|
608
|
-
it("should increase the version and then publish it and update all dependencies for the second publication in prerelease flow with pkg-d changing", async () => {
|
|
609
|
-
const PREV_VERSION = "0.0.1-next.0";
|
|
610
|
-
const PREV_DEPENDENCY_VERSION = "^" + PREV_VERSION;
|
|
611
|
-
const UPDATED_VERSION = "0.0.1-next.1";
|
|
612
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
613
|
-
await action({
|
|
614
|
-
prod: false,
|
|
615
|
-
next: true,
|
|
616
|
-
experimental: false,
|
|
617
|
-
sinceStart: true,
|
|
618
|
-
});
|
|
619
|
-
writeFileSync(join(PKG_D_DIR, "src", "index.js"), 'console.log("hello pkg-d!")\n\n');
|
|
620
|
-
execSync("git add .");
|
|
621
|
-
execSync('git commit -m "feat: second feature"');
|
|
622
|
-
vi.clearAllMocks();
|
|
623
|
-
await action({
|
|
624
|
-
prod: false,
|
|
625
|
-
next: true,
|
|
626
|
-
experimental: false,
|
|
627
|
-
sinceStart: false,
|
|
628
|
-
});
|
|
629
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
630
|
-
expectPublishSpawnCalls("next", [PKG_D_NAME, PKG_E_NAME], [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME, PKG_F_NAME]);
|
|
631
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
632
|
-
expectPackageVersions([
|
|
633
|
-
[PKG_D_DIR, UPDATED_VERSION],
|
|
634
|
-
[PKG_E_DIR, UPDATED_VERSION],
|
|
635
|
-
[PKG_A_DIR, PREV_VERSION],
|
|
636
|
-
[PKG_B_DIR, PREV_VERSION],
|
|
637
|
-
[PKG_C_DIR, PREV_VERSION],
|
|
638
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
639
|
-
]);
|
|
640
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
641
|
-
expectDependencyVersions([
|
|
642
|
-
[PKG_E_DIR, PKG_D_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
643
|
-
[PKG_A_DIR, PKG_C_NAME, PREV_DEPENDENCY_VERSION],
|
|
644
|
-
[PKG_C_DIR, PKG_B_NAME, PREV_DEPENDENCY_VERSION],
|
|
645
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
646
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
647
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
648
|
-
]);
|
|
649
|
-
// ── 4. changelogs (none for prerelease) ───────────────────────────────────
|
|
650
|
-
expectNoChangelogs();
|
|
651
|
-
// ── 5. release commit ─────────────────────────────────────────────────────
|
|
652
|
-
expectReleaseCommit([[PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]]);
|
|
653
|
-
// ── 6. no tags for prerelease ─────────────────────────────────────────────
|
|
654
|
-
expectNoTags();
|
|
655
|
-
});
|
|
656
|
-
it("should create a brand new prerelease version with since start enabled after a publication in experimental flow", async () => {
|
|
657
|
-
const UPDATED_VERSION = "0.0.1-next.0";
|
|
658
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
659
|
-
execSync("git checkout -b experimental");
|
|
660
|
-
writeFileSync(join(PKG_A_DIR, "src", "index.js"), 'console.log("hello world!")\n\n');
|
|
661
|
-
execSync("git add .");
|
|
662
|
-
execSync('git commit -m "feat: second feature"');
|
|
663
|
-
await action({
|
|
664
|
-
prod: false,
|
|
665
|
-
next: false,
|
|
666
|
-
experimental: true,
|
|
667
|
-
sinceStart: true,
|
|
668
|
-
});
|
|
669
|
-
// experimental doesn't commit — restore the dirty package.json
|
|
670
|
-
execSync("git restore --staged .");
|
|
671
|
-
execSync("git restore .");
|
|
672
|
-
execSync("git checkout main");
|
|
673
|
-
execSync("git rebase experimental");
|
|
674
|
-
vi.clearAllMocks();
|
|
675
|
-
await action({
|
|
676
|
-
prod: false,
|
|
677
|
-
next: true,
|
|
678
|
-
experimental: false,
|
|
679
|
-
sinceStart: true,
|
|
680
|
-
});
|
|
681
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
682
|
-
expectPublishSpawnCalls("next", [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME, PKG_D_NAME, PKG_E_NAME], [PKG_F_NAME]);
|
|
683
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
684
|
-
expectPackageVersions([
|
|
685
|
-
[PKG_A_DIR, UPDATED_VERSION],
|
|
686
|
-
[PKG_B_DIR, UPDATED_VERSION],
|
|
687
|
-
[PKG_C_DIR, UPDATED_VERSION],
|
|
688
|
-
[PKG_D_DIR, UPDATED_VERSION],
|
|
689
|
-
[PKG_E_DIR, UPDATED_VERSION],
|
|
690
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
691
|
-
]);
|
|
692
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
693
|
-
expectDependencyVersions([
|
|
694
|
-
[PKG_A_DIR, PKG_C_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
695
|
-
[PKG_C_DIR, PKG_B_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
696
|
-
[PKG_E_DIR, PKG_D_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
697
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
698
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
699
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
700
|
-
]);
|
|
701
|
-
// ── 4. changelogs (none for prerelease) ───────────────────────────────────
|
|
702
|
-
expectNoChangelogs();
|
|
703
|
-
// ── 5. release commit ─────────────────────────────────────────────────────
|
|
704
|
-
expectReleaseCommit([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]], [PKG_F_NAME]);
|
|
705
|
-
// ── 6. no tags for prerelease ─────────────────────────────────────────────
|
|
706
|
-
expectNoTags();
|
|
707
|
-
});
|
|
708
|
-
it("should throw an error with since start disabled after a publication in experimental flow", async () => {
|
|
709
|
-
execSync("git checkout -b experimental");
|
|
710
|
-
writeFileSync(join(PKG_A_DIR, "src", "index.js"), 'console.log("hello world!")\n\n');
|
|
711
|
-
execSync("git add .");
|
|
712
|
-
execSync('git commit -m "feat: second feature"');
|
|
713
|
-
await action({
|
|
714
|
-
prod: false,
|
|
715
|
-
next: false,
|
|
716
|
-
experimental: true,
|
|
717
|
-
sinceStart: true,
|
|
718
|
-
});
|
|
719
|
-
// experimental doesn't commit — restore the dirty package.json
|
|
720
|
-
execSync("git restore --staged .");
|
|
721
|
-
execSync("git restore .");
|
|
722
|
-
execSync("git checkout main");
|
|
723
|
-
execSync("git rebase experimental");
|
|
724
|
-
vi.clearAllMocks();
|
|
725
|
-
await expect(action({
|
|
726
|
-
prod: false,
|
|
727
|
-
next: true,
|
|
728
|
-
experimental: false,
|
|
729
|
-
sinceStart: false,
|
|
730
|
-
})).rejects.toThrow("Couldn't find the commit hash to compare to for the selected method");
|
|
731
|
-
expectNothingPublished();
|
|
732
|
-
});
|
|
733
|
-
it("should increase the version and then publish it and update all dependencies after a publication in production flow with pkg-d changing", async () => {
|
|
734
|
-
const PREV_VERSION = "0.1.0";
|
|
735
|
-
const PREV_DEPENDENCY_VERSION = "^" + PREV_VERSION;
|
|
736
|
-
const UPDATED_VERSION = "0.1.1-next.0";
|
|
737
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
738
|
-
await action({
|
|
739
|
-
prod: true,
|
|
740
|
-
next: false,
|
|
741
|
-
experimental: false,
|
|
742
|
-
sinceStart: true,
|
|
743
|
-
});
|
|
744
|
-
writeFileSync(join(PKG_D_DIR, "src", "index.js"), 'console.log("hello pkg-d!")\n\n');
|
|
745
|
-
execSync("git add .");
|
|
746
|
-
execSync('git commit -m "feat: second feature"');
|
|
747
|
-
vi.clearAllMocks();
|
|
748
|
-
await action({
|
|
749
|
-
prod: false,
|
|
750
|
-
next: true,
|
|
751
|
-
experimental: false,
|
|
752
|
-
sinceStart: false,
|
|
753
|
-
});
|
|
754
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
755
|
-
expectPublishSpawnCalls("next", [PKG_D_NAME, PKG_E_NAME], [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME, PKG_F_NAME]);
|
|
756
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
757
|
-
expectPackageVersions([
|
|
758
|
-
[PKG_D_DIR, UPDATED_VERSION],
|
|
759
|
-
[PKG_E_DIR, UPDATED_VERSION],
|
|
760
|
-
[PKG_A_DIR, PREV_VERSION],
|
|
761
|
-
[PKG_B_DIR, PREV_VERSION],
|
|
762
|
-
[PKG_C_DIR, PREV_VERSION],
|
|
763
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
764
|
-
]);
|
|
765
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
766
|
-
expectDependencyVersions([
|
|
767
|
-
[PKG_E_DIR, PKG_D_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
768
|
-
[PKG_A_DIR, PKG_C_NAME, PREV_DEPENDENCY_VERSION],
|
|
769
|
-
[PKG_C_DIR, PKG_B_NAME, PREV_DEPENDENCY_VERSION],
|
|
770
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
771
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
772
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
773
|
-
]);
|
|
774
|
-
// ── 4. changelogs (exist from prod flow, not updated by prerelease) ────────
|
|
775
|
-
expectChangelogs([
|
|
776
|
-
{ dir: PKG_A_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
777
|
-
{ dir: PKG_B_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
778
|
-
{ dir: PKG_C_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
779
|
-
{ dir: PKG_D_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
780
|
-
{ dir: PKG_E_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
781
|
-
{ dir: PKG_F_DIR, exists: false },
|
|
782
|
-
]);
|
|
783
|
-
// ── 5. release commit ─────────────────────────────────────────────────────
|
|
784
|
-
expectReleaseCommit([[PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]]);
|
|
785
|
-
// ── 6. no tags for prerelease ─────────────────────────────────────────────
|
|
786
|
-
expectTags([], [[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION], [PKG_F_NAME, UPDATED_VERSION]]);
|
|
787
|
-
});
|
|
788
|
-
});
|
|
789
|
-
describe("experimental flow", () => {
|
|
790
|
-
const FIXED_DATE = new Date("2026-04-18");
|
|
791
|
-
const FIXED_DATE_STR = "20260418";
|
|
792
|
-
beforeAll(() => {
|
|
793
|
-
vi.useFakeTimers();
|
|
794
|
-
vi.setSystemTime(FIXED_DATE);
|
|
795
|
-
});
|
|
796
|
-
afterAll(() => {
|
|
797
|
-
vi.useRealTimers();
|
|
798
|
-
});
|
|
799
|
-
it("should publish the first experimental version without commit and tag with pkg-b changing", async () => {
|
|
800
|
-
execSync("git checkout -b experimental");
|
|
801
|
-
writeFileSync(join(PKG_B_DIR, "src", "index.js"), 'console.log("hello pkg-b")\n\n');
|
|
802
|
-
execSync("git add .");
|
|
803
|
-
execSync('git commit -m "feat: second feature"');
|
|
804
|
-
const headHash = execSync("git rev-parse HEAD").toString().trim().slice(0, 8);
|
|
805
|
-
const UPDATED_VERSION = `0.0.0-experimental-${headHash}-${FIXED_DATE_STR}`;
|
|
806
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
807
|
-
await action({
|
|
808
|
-
prod: false,
|
|
809
|
-
next: false,
|
|
810
|
-
experimental: true,
|
|
811
|
-
sinceStart: false,
|
|
812
|
-
});
|
|
813
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
814
|
-
expectPublishSpawnCalls("experimental", [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME], [PKG_D_NAME, PKG_E_NAME, PKG_F_NAME], { expectCommit: false });
|
|
815
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
816
|
-
expectPackageVersions([
|
|
817
|
-
[PKG_A_DIR, UPDATED_VERSION],
|
|
818
|
-
[PKG_B_DIR, UPDATED_VERSION],
|
|
819
|
-
[PKG_C_DIR, UPDATED_VERSION],
|
|
820
|
-
[PKG_D_DIR, FIRST_VERSION],
|
|
821
|
-
[PKG_E_DIR, FIRST_VERSION],
|
|
822
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
823
|
-
]);
|
|
824
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
825
|
-
expectDependencyVersions([
|
|
826
|
-
[PKG_A_DIR, PKG_C_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
827
|
-
[PKG_C_DIR, PKG_B_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
828
|
-
[PKG_E_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
829
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
830
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
831
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
832
|
-
]);
|
|
833
|
-
// ── 4. changelogs (none for experimental) ─────────────────────────────────
|
|
834
|
-
expectNoChangelogs();
|
|
835
|
-
// ── 5. no release commit ──────────────────────────────────────────────────
|
|
836
|
-
expectNoReleaseCommit();
|
|
837
|
-
// ── 6. no version tags ────────────────────────────────────────────────────
|
|
838
|
-
expectNoTags();
|
|
839
|
-
});
|
|
840
|
-
it("should publish a new experimental version for the second publication with pkg-d changing", async () => {
|
|
841
|
-
execSync("git checkout -b experimental");
|
|
842
|
-
writeFileSync(join(PKG_D_DIR, "src", "index.js"), 'console.log("hello pkg-d")\n\n');
|
|
843
|
-
execSync("git add .");
|
|
844
|
-
execSync('git commit -m "feat: second feature"');
|
|
845
|
-
await action({
|
|
846
|
-
prod: false,
|
|
847
|
-
next: false,
|
|
848
|
-
experimental: true,
|
|
849
|
-
sinceStart: false,
|
|
850
|
-
});
|
|
851
|
-
// experimental doesn't commit — restore the dirty package.json
|
|
852
|
-
execSync("git restore --staged .");
|
|
853
|
-
execSync("git restore .");
|
|
854
|
-
writeFileSync(join(PKG_D_DIR, "src", "index.js"), 'console.log("hello pkg-d")\n\n\n');
|
|
855
|
-
execSync("git add .");
|
|
856
|
-
execSync('git commit -m "feat: third feature"');
|
|
857
|
-
vi.clearAllMocks();
|
|
858
|
-
const headHash = execSync("git rev-parse HEAD").toString().trim().slice(0, 8);
|
|
859
|
-
const UPDATED_VERSION = `0.0.0-experimental-${headHash}-${FIXED_DATE_STR}`;
|
|
860
|
-
await action({
|
|
861
|
-
prod: false,
|
|
862
|
-
next: false,
|
|
863
|
-
experimental: true,
|
|
864
|
-
sinceStart: false,
|
|
865
|
-
});
|
|
866
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
867
|
-
expectPublishSpawnCalls("experimental", [PKG_D_NAME, PKG_E_NAME], [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME, PKG_F_NAME], { expectCommit: false });
|
|
868
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
869
|
-
expectPackageVersions([
|
|
870
|
-
[PKG_D_DIR, UPDATED_VERSION],
|
|
871
|
-
[PKG_E_DIR, UPDATED_VERSION],
|
|
872
|
-
[PKG_A_DIR, FIRST_VERSION],
|
|
873
|
-
[PKG_B_DIR, FIRST_VERSION],
|
|
874
|
-
[PKG_C_DIR, FIRST_VERSION],
|
|
875
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
876
|
-
]);
|
|
877
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
878
|
-
expectDependencyVersions([
|
|
879
|
-
[PKG_E_DIR, PKG_D_NAME, `^${UPDATED_VERSION}`],
|
|
880
|
-
[PKG_A_DIR, PKG_C_NAME, FIRST_VERSION],
|
|
881
|
-
[PKG_C_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
882
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
883
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
884
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
885
|
-
]);
|
|
886
|
-
// ── 4. changelogs (none for experimental) ─────────────────────────────────
|
|
887
|
-
expectNoChangelogs();
|
|
888
|
-
// ── 5. no release commit ──────────────────────────────────────────────────
|
|
889
|
-
expectNoReleaseCommit();
|
|
890
|
-
// ── 6. no version tags ────────────────────────────────────────────────────
|
|
891
|
-
expectNoTags();
|
|
892
|
-
});
|
|
893
|
-
it("should create a brand new experimental version after a publication in prerelease flow with pkg-e changing", async () => {
|
|
894
|
-
await action({
|
|
895
|
-
prod: false,
|
|
896
|
-
next: true,
|
|
897
|
-
experimental: false,
|
|
898
|
-
sinceStart: true,
|
|
899
|
-
});
|
|
900
|
-
// update origin head
|
|
901
|
-
execSync("git update-ref refs/remotes/origin/main HEAD");
|
|
902
|
-
execSync("git checkout -b experimental");
|
|
903
|
-
writeFileSync(join(PKG_E_DIR, "src", "index.js"), 'console.log("hello pkg-e")\n\n');
|
|
904
|
-
execSync("git add .");
|
|
905
|
-
execSync('git commit -m "feat: second feature"');
|
|
906
|
-
vi.clearAllMocks();
|
|
907
|
-
const headHash = execSync("git rev-parse HEAD").toString().trim().slice(0, 8);
|
|
908
|
-
const PREV_VERSION = "0.0.1-next.0";
|
|
909
|
-
const PREV_DEPENDENCY_VERSION = "^" + PREV_VERSION;
|
|
910
|
-
const UPDATED_VERSION = `0.0.0-experimental-${headHash}-${FIXED_DATE_STR}`;
|
|
911
|
-
await action({
|
|
912
|
-
prod: false,
|
|
913
|
-
next: false,
|
|
914
|
-
experimental: true,
|
|
915
|
-
sinceStart: false,
|
|
916
|
-
});
|
|
917
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
918
|
-
expectPublishSpawnCalls("experimental", [PKG_E_NAME], [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME, PKG_D_NAME, PKG_F_NAME], { expectCommit: false });
|
|
919
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
920
|
-
expectPackageVersions([
|
|
921
|
-
[PKG_E_DIR, UPDATED_VERSION],
|
|
922
|
-
[PKG_A_DIR, PREV_VERSION],
|
|
923
|
-
[PKG_B_DIR, PREV_VERSION],
|
|
924
|
-
[PKG_C_DIR, PREV_VERSION],
|
|
925
|
-
[PKG_D_DIR, PREV_VERSION],
|
|
926
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
927
|
-
]);
|
|
928
|
-
// ── 3. dependency versions (pkg-d didn't change, deps stay at prev) ───────
|
|
929
|
-
expectDependencyVersions([
|
|
930
|
-
[PKG_E_DIR, PKG_D_NAME, PREV_DEPENDENCY_VERSION],
|
|
931
|
-
[PKG_A_DIR, PKG_C_NAME, PREV_DEPENDENCY_VERSION],
|
|
932
|
-
[PKG_C_DIR, PKG_B_NAME, PREV_DEPENDENCY_VERSION],
|
|
933
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
934
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
935
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
936
|
-
]);
|
|
937
|
-
// ── 4. changelogs (none for prerelease, none for experimental) ────────────
|
|
938
|
-
expectNoChangelogs();
|
|
939
|
-
// ── 5. no release commit ──────────────────────────────────────────────────
|
|
940
|
-
expectNoReleaseCommit();
|
|
941
|
-
// ── 6. no version tags ────────────────────────────────────────────────────
|
|
942
|
-
expectNoTags();
|
|
943
|
-
});
|
|
944
|
-
it("should create a brand new experimental version after a publication in production flow with pkg-c changing", async () => {
|
|
945
|
-
await action({
|
|
946
|
-
prod: true,
|
|
947
|
-
next: false,
|
|
948
|
-
experimental: false,
|
|
949
|
-
sinceStart: true,
|
|
950
|
-
});
|
|
951
|
-
// update origin head
|
|
952
|
-
execSync("git update-ref refs/remotes/origin/main HEAD");
|
|
953
|
-
execSync("git checkout -b experimental");
|
|
954
|
-
writeFileSync(join(PKG_C_DIR, "src", "index.js"), 'console.log("hello pkg-c")\n\n');
|
|
955
|
-
execSync("git add .");
|
|
956
|
-
execSync('git commit -m "feat: second feature"');
|
|
957
|
-
vi.clearAllMocks();
|
|
958
|
-
const headHash = execSync("git rev-parse HEAD").toString().trim().slice(0, 8);
|
|
959
|
-
const PREV_VERSION = "0.1.0";
|
|
960
|
-
const PREV_DEPENDENCY_VERSION = "^" + PREV_VERSION;
|
|
961
|
-
const UPDATED_VERSION = `0.0.0-experimental-${headHash}-${FIXED_DATE_STR}`;
|
|
962
|
-
await action({
|
|
963
|
-
prod: false,
|
|
964
|
-
next: false,
|
|
965
|
-
experimental: true,
|
|
966
|
-
sinceStart: false,
|
|
967
|
-
});
|
|
968
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
969
|
-
expectPublishSpawnCalls("experimental", [PKG_A_NAME, PKG_C_NAME], [PKG_B_NAME, PKG_D_NAME, PKG_E_NAME, PKG_F_NAME], { expectCommit: false });
|
|
970
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
971
|
-
expectPackageVersions([
|
|
972
|
-
[PKG_A_DIR, UPDATED_VERSION],
|
|
973
|
-
[PKG_C_DIR, UPDATED_VERSION],
|
|
974
|
-
[PKG_B_DIR, PREV_VERSION],
|
|
975
|
-
[PKG_D_DIR, PREV_VERSION],
|
|
976
|
-
[PKG_E_DIR, PREV_VERSION],
|
|
977
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
978
|
-
]);
|
|
979
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
980
|
-
expectDependencyVersions([
|
|
981
|
-
[PKG_A_DIR, PKG_C_NAME, `^${UPDATED_VERSION}`],
|
|
982
|
-
[PKG_C_DIR, PKG_B_NAME, PREV_DEPENDENCY_VERSION],
|
|
983
|
-
[PKG_E_DIR, PKG_D_NAME, PREV_DEPENDENCY_VERSION],
|
|
984
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
985
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
986
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
987
|
-
]);
|
|
988
|
-
// ── 4. changelogs (exist from prod flow, not updated by experimental) ─────
|
|
989
|
-
expectChangelogs([
|
|
990
|
-
{ dir: PKG_A_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
991
|
-
{ dir: PKG_B_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
992
|
-
{ dir: PKG_C_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
993
|
-
{ dir: PKG_D_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
994
|
-
{ dir: PKG_E_DIR, exists: true, notMatch: UPDATED_VERSION },
|
|
995
|
-
{ dir: PKG_F_DIR, exists: false },
|
|
996
|
-
]);
|
|
997
|
-
// ── 5. no release commit ──────────────────────────────────────────────────
|
|
998
|
-
expectNoReleaseCommit();
|
|
999
|
-
// ── 6. no new tags ────────────────────────────────────────────────────────
|
|
1000
|
-
expectTags([], [[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION], [PKG_F_NAME, UPDATED_VERSION]]);
|
|
1001
|
-
});
|
|
1002
|
-
});
|
|
1003
|
-
});
|
|
1004
|
-
describe("publish in a turborepo monorepo", () => {
|
|
1005
|
-
beforeEach(async () => { await setupFixture(writeTurboConfig); });
|
|
1006
|
-
afterEach(async () => { await teardownFixture(); });
|
|
1007
|
-
describe("production flow", () => {
|
|
1008
|
-
it("should publish the first version with since start option enabled", async () => {
|
|
1009
|
-
const UPDATED_VERSION = "0.1.0";
|
|
1010
|
-
const UPDATED_DEPENDENCY_VERSION = "^" + UPDATED_VERSION;
|
|
1011
|
-
await action({
|
|
1012
|
-
prod: true,
|
|
1013
|
-
next: false,
|
|
1014
|
-
experimental: false,
|
|
1015
|
-
sinceStart: true,
|
|
1016
|
-
});
|
|
1017
|
-
// ── 1. spawn ─────────────────────────────────────────────────────────────
|
|
1018
|
-
expectPublishSpawnCalls("latest", [PKG_A_NAME, PKG_B_NAME, PKG_C_NAME, PKG_D_NAME, PKG_E_NAME], [PKG_F_NAME], { gitReleases: { newVersion: UPDATED_VERSION, commits: ["initial commit", "initial commit", "initial commit", "initial commit", "initial commit"] } });
|
|
1019
|
-
// ── 2. package versions ───────────────────────────────────────────────────
|
|
1020
|
-
expectPackageVersions([
|
|
1021
|
-
[PKG_A_DIR, UPDATED_VERSION],
|
|
1022
|
-
[PKG_B_DIR, UPDATED_VERSION],
|
|
1023
|
-
[PKG_C_DIR, UPDATED_VERSION],
|
|
1024
|
-
[PKG_D_DIR, UPDATED_VERSION],
|
|
1025
|
-
[PKG_E_DIR, UPDATED_VERSION],
|
|
1026
|
-
[PKG_F_DIR, FIRST_VERSION],
|
|
1027
|
-
]);
|
|
1028
|
-
// ── 3. dependency versions ────────────────────────────────────────────────
|
|
1029
|
-
expectDependencyVersions([
|
|
1030
|
-
[PKG_A_DIR, PKG_C_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
1031
|
-
[PKG_C_DIR, PKG_B_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
1032
|
-
[PKG_E_DIR, PKG_D_NAME, UPDATED_DEPENDENCY_VERSION],
|
|
1033
|
-
[PKG_F_DIR, PKG_A_NAME, FIRST_VERSION],
|
|
1034
|
-
[PKG_F_DIR, PKG_B_NAME, FIRST_VERSION],
|
|
1035
|
-
[PKG_F_DIR, PKG_D_NAME, FIRST_VERSION],
|
|
1036
|
-
]);
|
|
1037
|
-
// ── 4. changelogs ─────────────────────────────────────────────────────────
|
|
1038
|
-
const featureMatch = new RegExp(`${UPDATED_VERSION}[\\s\\S]*Features[\\s\\S]*initial commit`);
|
|
1039
|
-
expectChangelogs([
|
|
1040
|
-
{ dir: PKG_A_DIR, exists: true, match: featureMatch },
|
|
1041
|
-
{ dir: PKG_B_DIR, exists: true, match: featureMatch },
|
|
1042
|
-
{ dir: PKG_C_DIR, exists: true, match: featureMatch },
|
|
1043
|
-
{ dir: PKG_D_DIR, exists: true, match: featureMatch },
|
|
1044
|
-
{ dir: PKG_E_DIR, exists: true, match: featureMatch },
|
|
1045
|
-
{ dir: PKG_F_DIR, exists: false },
|
|
1046
|
-
]);
|
|
1047
|
-
// ── 5. release commit ─────────────────────────────────────────────────────
|
|
1048
|
-
expectReleaseCommit([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]], [PKG_F_NAME]);
|
|
1049
|
-
// ── 6. tags ───────────────────────────────────────────────────────────────
|
|
1050
|
-
expectTags([[PKG_A_NAME, UPDATED_VERSION], [PKG_B_NAME, UPDATED_VERSION], [PKG_C_NAME, UPDATED_VERSION], [PKG_D_NAME, UPDATED_VERSION], [PKG_E_NAME, UPDATED_VERSION]], [[PKG_F_NAME, UPDATED_VERSION]]);
|
|
1051
|
-
});
|
|
1052
|
-
});
|
|
1053
|
-
});
|
|
1054
|
-
//# sourceMappingURL=action.test.js.map
|