openspec-playwright 0.2.3 ā 0.2.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/migrate.js +12 -49
- package/dist/commands/migrate.js.map +1 -1
- package/package.json +1 -1
package/dist/commands/migrate.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
2
1
|
import { existsSync, mkdirSync, readdirSync, renameSync, } from "fs";
|
|
3
2
|
import { join } from "path";
|
|
4
3
|
import chalk from "chalk";
|
|
@@ -19,24 +18,7 @@ export async function migrate(options) {
|
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
console.log(chalk.blue("\nš OpenSpec Playwright: Migration\n"));
|
|
22
|
-
// 1.
|
|
23
|
-
let changeNames = [];
|
|
24
|
-
try {
|
|
25
|
-
const result = execSync("npx openspec list --json", {
|
|
26
|
-
cwd: projectRoot,
|
|
27
|
-
encoding: "utf-8",
|
|
28
|
-
timeout: 30000,
|
|
29
|
-
});
|
|
30
|
-
const data = JSON.parse(result);
|
|
31
|
-
changeNames = Array.isArray(data)
|
|
32
|
-
? data.map((c) => c.name)
|
|
33
|
-
: Object.keys(data);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
// If openspec not available or no changes, proceed with empty list
|
|
37
|
-
changeNames = [];
|
|
38
|
-
}
|
|
39
|
-
// 2. Find old-style spec files in root
|
|
21
|
+
// 1. Find old-style spec files in root
|
|
40
22
|
const oldFiles = readdirSync(testsDir)
|
|
41
23
|
.filter((f) => f.endsWith(".spec.ts"))
|
|
42
24
|
.filter((f) => !SHARED_FILES.has(f))
|
|
@@ -51,48 +33,30 @@ export async function migrate(options) {
|
|
|
51
33
|
const oldPath = join(testsDir, fileName);
|
|
52
34
|
const newDir = join(testsDir, "changes", changeName);
|
|
53
35
|
const newPath = join(newDir, fileName);
|
|
54
|
-
|
|
55
|
-
const reason = valid
|
|
56
|
-
? undefined
|
|
57
|
-
: changeNames.length === 0
|
|
58
|
-
? "openspec not initialized or no changes found"
|
|
59
|
-
: `change "${changeName}" not found in openspec`;
|
|
60
|
-
return { fileName, changeName, oldPath, newPath, valid, reason };
|
|
36
|
+
return { fileName, changeName, oldPath, newPath };
|
|
61
37
|
});
|
|
62
|
-
//
|
|
63
|
-
const validItems = items.filter((i) => i.valid);
|
|
64
|
-
const invalidItems = items.filter((i) => !i.valid);
|
|
38
|
+
// 3. Display migration plan
|
|
65
39
|
for (const item of items) {
|
|
66
|
-
|
|
67
|
-
console.log(` ${icon} ${item.fileName} ā changes/${item.changeName}/${item.fileName}`);
|
|
68
|
-
if (item.reason) {
|
|
69
|
-
console.log(chalk.gray(` Skip: ${item.reason}`));
|
|
70
|
-
}
|
|
40
|
+
console.log(` ${chalk.green("ā")} ${item.fileName} ā changes/${item.changeName}/${item.fileName}`);
|
|
71
41
|
}
|
|
72
|
-
|
|
73
|
-
console.log(chalk.yellow(`\n ā ${invalidItems.length} file(s) skipped (no matching OpenSpec change)`));
|
|
74
|
-
}
|
|
75
|
-
if (validItems.length === 0) {
|
|
76
|
-
console.log(chalk.blue("\n No valid migrations to perform.\n"));
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
// 5. Dry run or execute
|
|
42
|
+
// 4. Dry run
|
|
80
43
|
if (options.dryRun) {
|
|
81
44
|
console.log(chalk.blue(`\nāāā Dry run ā no files were moved āāā`));
|
|
82
|
-
console.log(chalk.green(" All
|
|
45
|
+
console.log(chalk.green(" All migrations would succeed.\n"));
|
|
83
46
|
return;
|
|
84
47
|
}
|
|
48
|
+
// 5. Ensure changes/ directory exists
|
|
49
|
+
mkdirSync(join(testsDir, "changes"), { recursive: true });
|
|
50
|
+
// 6. Execute migrations
|
|
85
51
|
console.log(chalk.blue("\nāāā Migrating āāā"));
|
|
86
52
|
let migrated = 0;
|
|
87
53
|
let skipped = 0;
|
|
88
|
-
for (const item of
|
|
89
|
-
// Check if file exists
|
|
54
|
+
for (const item of items) {
|
|
90
55
|
if (!existsSync(item.oldPath)) {
|
|
91
56
|
console.log(chalk.yellow(` ā ${item.fileName} not found, skipping`));
|
|
92
57
|
skipped++;
|
|
93
58
|
continue;
|
|
94
59
|
}
|
|
95
|
-
// Check if new location already has a file
|
|
96
60
|
if (existsSync(item.newPath)) {
|
|
97
61
|
if (!options.force) {
|
|
98
62
|
console.log(chalk.yellow(` ā ${item.newPath} already exists. Use --force to overwrite.`));
|
|
@@ -100,16 +64,15 @@ export async function migrate(options) {
|
|
|
100
64
|
continue;
|
|
101
65
|
}
|
|
102
66
|
}
|
|
103
|
-
// Create directory and move
|
|
104
67
|
mkdirSync(join(testsDir, "changes", item.changeName), {
|
|
105
68
|
recursive: true,
|
|
106
69
|
});
|
|
107
70
|
renameSync(item.oldPath, item.newPath);
|
|
108
71
|
migrated++;
|
|
109
72
|
}
|
|
110
|
-
//
|
|
73
|
+
// 7. Summary
|
|
111
74
|
console.log(chalk.blue("\nāāā Results āāā"));
|
|
112
|
-
console.log(` ${chalk.green(`ā ${migrated} migrated`)} ${chalk.red(`ā ${skipped} skipped`)}`);
|
|
75
|
+
console.log(` ${chalk.green(`ā ${migrated} migrated`)} ${skipped > 0 ? chalk.red(`ā ${skipped} skipped`) : ""}`);
|
|
113
76
|
console.log(chalk.blue("\nāāā Next step āāā"));
|
|
114
77
|
console.log(chalk.green(" Run `openspec-pw run <name>` to verify each migrated change.\n"));
|
|
115
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,GACX,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK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