productkit 1.6.0 → 1.6.1
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 +1 -1
- package/src/cli.js +1 -0
- package/src/commands/reset.js +47 -13
package/package.json
CHANGED
package/src/cli.js
CHANGED
package/src/commands/reset.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const fs = require('fs-extra');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const chalk = require('chalk');
|
|
4
|
+
const readline = require('readline');
|
|
4
5
|
|
|
5
6
|
const ARTIFACTS = [
|
|
6
7
|
'constitution.md',
|
|
@@ -12,7 +13,20 @@ const ARTIFACTS = [
|
|
|
12
13
|
'spec.md',
|
|
13
14
|
];
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
function confirm(question) {
|
|
17
|
+
const rl = readline.createInterface({
|
|
18
|
+
input: process.stdin,
|
|
19
|
+
output: process.stdout,
|
|
20
|
+
});
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
rl.question(question, (answer) => {
|
|
23
|
+
rl.close();
|
|
24
|
+
resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function reset(options) {
|
|
16
30
|
const root = process.cwd();
|
|
17
31
|
const configPath = path.join(root, '.productkit', 'config.json');
|
|
18
32
|
|
|
@@ -22,24 +36,44 @@ async function reset() {
|
|
|
22
36
|
process.exit(1);
|
|
23
37
|
}
|
|
24
38
|
|
|
25
|
-
|
|
39
|
+
// Find existing artifacts
|
|
40
|
+
const existing = ARTIFACTS.filter(file =>
|
|
41
|
+
fs.existsSync(path.join(root, file))
|
|
42
|
+
);
|
|
26
43
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
removed++;
|
|
33
|
-
}
|
|
44
|
+
if (existing.length === 0) {
|
|
45
|
+
console.log();
|
|
46
|
+
console.log(chalk.green.bold('Nothing to reset — no artifacts found.'));
|
|
47
|
+
console.log();
|
|
48
|
+
return;
|
|
34
49
|
}
|
|
35
50
|
|
|
51
|
+
// Show what will be deleted
|
|
36
52
|
console.log();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
console.log(chalk.green.bold('Nothing to reset — no artifacts found.'));
|
|
53
|
+
console.log(chalk.yellow.bold(`Found ${existing.length} artifact${existing.length === 1 ? '' : 's'}:`));
|
|
54
|
+
for (const file of existing) {
|
|
55
|
+
console.log(chalk.yellow(` ${file}`));
|
|
41
56
|
}
|
|
42
57
|
console.log();
|
|
58
|
+
|
|
59
|
+
// Confirm unless --force
|
|
60
|
+
if (!options.force) {
|
|
61
|
+
const yes = await confirm(chalk.red('Delete these artifacts? (y/N) '));
|
|
62
|
+
if (!yes) {
|
|
63
|
+
console.log('Reset cancelled.');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
console.log();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
for (const file of existing) {
|
|
70
|
+
fs.removeSync(path.join(root, file));
|
|
71
|
+
console.log(chalk.yellow(` removed ${file}`));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.log();
|
|
75
|
+
console.log(chalk.green.bold(`Reset complete. ${existing.length} artifact${existing.length === 1 ? '' : 's'} removed.`));
|
|
76
|
+
console.log();
|
|
43
77
|
}
|
|
44
78
|
|
|
45
79
|
module.exports = reset;
|