@planningcenter/tapestry-migration-cli 4.10.0 → 4.10.1-qa-1450.0
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/package.json +3 -3
- package/src/index.test.ts +63 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-migration-cli",
|
|
3
|
-
"version": "4.10.0",
|
|
3
|
+
"version": "4.10.1-qa-1450.0",
|
|
4
4
|
"description": "CLI tool for Tapestry migrations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@emotion/react": "^11.14.0",
|
|
33
33
|
"@planningcenter/tapestry-react": "^4.11.5",
|
|
34
|
-
"@planningcenter/tapestry-tokens": "^4.
|
|
34
|
+
"@planningcenter/tapestry-tokens": "^4.10.1-qa-1450.0",
|
|
35
35
|
"@types/jscodeshift": "^17.3.0",
|
|
36
36
|
"@types/node": "^20.0.0",
|
|
37
37
|
"typescript": "^5.8.3",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "c2f44c24a37c0284f83986a1fb540cb24bdbb425"
|
|
54
54
|
}
|
package/src/index.test.ts
CHANGED
|
@@ -13,67 +13,80 @@ import { describe, expect, it } from "vitest"
|
|
|
13
13
|
import { buildMigrationList } from "./migrationList"
|
|
14
14
|
|
|
15
15
|
const CLI_PATH = fileURLToPath(new URL("./index.ts", import.meta.url))
|
|
16
|
+
// tsx cold-start can take a few seconds; allow up to 30 s.
|
|
17
|
+
const CLI_TIMEOUT_MS = 30_000
|
|
16
18
|
|
|
17
19
|
function runCli(args: string[]) {
|
|
18
20
|
return spawnSync("npx", ["tsx", CLI_PATH, ...args], {
|
|
19
21
|
encoding: "utf8",
|
|
20
|
-
|
|
21
|
-
timeout: 30_000,
|
|
22
|
+
timeout: CLI_TIMEOUT_MS,
|
|
22
23
|
})
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
describe(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
describe(
|
|
27
|
+
"list --json (stdout/exit-code contract)",
|
|
28
|
+
{ timeout: CLI_TIMEOUT_MS },
|
|
29
|
+
() => {
|
|
30
|
+
it("exits with code 0", () => {
|
|
31
|
+
const result = runCli(["list", "--json"])
|
|
32
|
+
expect(result.status).toBe(0)
|
|
33
|
+
})
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
it("emits valid JSON as the entire stdout (no stray lines)", () => {
|
|
36
|
+
const result = runCli(["list", "--json"])
|
|
37
|
+
// JSON.parse throws if there is ANY non-JSON content on stdout.
|
|
38
|
+
expect(() => JSON.parse(result.stdout)).not.toThrow()
|
|
39
|
+
})
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
it("payload matches buildMigrationList() (schemaVersion + migrations)", () => {
|
|
42
|
+
const result = runCli(["list", "--json"])
|
|
43
|
+
const payload = JSON.parse(result.stdout)
|
|
44
|
+
expect(payload).toEqual(buildMigrationList())
|
|
45
|
+
})
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
it("schemaVersion is exactly the integer 1", () => {
|
|
48
|
+
const result = runCli(["list", "--json"])
|
|
49
|
+
const { schemaVersion } = JSON.parse(result.stdout)
|
|
50
|
+
expect(schemaVersion).toBe(1)
|
|
51
|
+
expect(Number.isInteger(schemaVersion)).toBe(true)
|
|
52
|
+
})
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
it("stderr is empty on success", () => {
|
|
55
|
+
const result = runCli(["list", "--json"])
|
|
56
|
+
expect(result.stderr).toBe("")
|
|
57
|
+
})
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
59
|
+
it("does not require --path and makes no filesystem writes", () => {
|
|
60
|
+
// If --path were required, commander would write an error to stderr and exit 1.
|
|
61
|
+
// We assert the happy path — exit 0 with no --path — proving the flag is absent.
|
|
62
|
+
const result = runCli(["list", "--json"])
|
|
63
|
+
expect(result.status).toBe(0)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
)
|
|
62
67
|
|
|
63
|
-
describe(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
describe(
|
|
69
|
+
"list (human-readable, non-contractual)",
|
|
70
|
+
{ timeout: CLI_TIMEOUT_MS },
|
|
71
|
+
() => {
|
|
72
|
+
it("exits with code 0 and writes component ids to stdout", () => {
|
|
73
|
+
const result = runCli(["list"])
|
|
74
|
+
expect(result.status).toBe(0)
|
|
75
|
+
expect(result.stdout).toContain("button")
|
|
76
|
+
expect(result.stdout).toContain("toggle-switch")
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
)
|
|
71
80
|
|
|
72
|
-
describe(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
describe(
|
|
82
|
+
"diagnostics contract (nonzero exit → stderr)",
|
|
83
|
+
{ timeout: CLI_TIMEOUT_MS },
|
|
84
|
+
() => {
|
|
85
|
+
it("exits nonzero and writes to stderr for an unknown subcommand", () => {
|
|
86
|
+
const result = runCli(["unknown-subcommand"])
|
|
87
|
+
// Commander writes "error: unknown command 'unknown-subcommand'" to stderr.
|
|
88
|
+
expect(result.status).not.toBe(0)
|
|
89
|
+
expect(result.stderr.length).toBeGreaterThan(0)
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
)
|