@dedesfr/prompter 0.3.1 → 0.3.2
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/cli/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAMA,qBAAa,aAAa;IAChB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YA8DhB,UAAU;YASV,qBAAqB;CAuBtC"}
|
package/dist/commands/update.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
import path from 'path';
|
|
2
4
|
import { PrompterConfig } from '../core/config.js';
|
|
3
5
|
import { registry } from '../core/configurators/slash/index.js';
|
|
4
6
|
export class UpdateCommand {
|
|
@@ -12,27 +14,80 @@ export class UpdateCommand {
|
|
|
12
14
|
process.exitCode = 1;
|
|
13
15
|
return;
|
|
14
16
|
}
|
|
17
|
+
// Detect configured tools
|
|
18
|
+
const configuredTools = await this.detectConfiguredTools(projectPath);
|
|
19
|
+
if (configuredTools.length === 0) {
|
|
20
|
+
console.log(chalk.yellow('⚠️ No configured tools found.'));
|
|
21
|
+
console.log(chalk.gray(' Run `prompter init` to configure tools.\n'));
|
|
22
|
+
process.exitCode = 1;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
15
25
|
let updatedCount = 0;
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
let createdCount = 0;
|
|
27
|
+
// Update and add missing workflow files for configured tools only
|
|
28
|
+
for (const toolId of configuredTools) {
|
|
29
|
+
const configurator = registry.get(toolId);
|
|
30
|
+
if (!configurator)
|
|
31
|
+
continue;
|
|
18
32
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
// Update existing files
|
|
34
|
+
const updatedFiles = await configurator.updateExisting(projectPath);
|
|
35
|
+
for (const file of updatedFiles) {
|
|
21
36
|
console.log(chalk.green('✓') + ` Updated ${chalk.cyan(file)}`);
|
|
22
37
|
updatedCount++;
|
|
23
38
|
}
|
|
39
|
+
// Generate all workflow files (including missing ones)
|
|
40
|
+
const allFiles = await configurator.generateAll(projectPath);
|
|
41
|
+
const newFiles = allFiles.filter(f => !updatedFiles.includes(f));
|
|
42
|
+
for (const file of newFiles) {
|
|
43
|
+
console.log(chalk.green('✓') + ` Created ${chalk.cyan(file)}`);
|
|
44
|
+
createdCount++;
|
|
45
|
+
}
|
|
24
46
|
}
|
|
25
47
|
catch (error) {
|
|
26
48
|
console.log(chalk.red('✗') + ` Failed to update ${configurator.toolId}: ${error}`);
|
|
27
49
|
}
|
|
28
50
|
}
|
|
29
|
-
if (updatedCount === 0) {
|
|
51
|
+
if (updatedCount === 0 && createdCount === 0) {
|
|
30
52
|
console.log(chalk.yellow('⚠️ No workflow files found to update.'));
|
|
31
53
|
console.log(chalk.gray(' Run `prompter init` to create them.\n'));
|
|
32
54
|
}
|
|
33
55
|
else {
|
|
34
|
-
|
|
56
|
+
const summary = [];
|
|
57
|
+
if (updatedCount > 0)
|
|
58
|
+
summary.push(`${updatedCount} updated`);
|
|
59
|
+
if (createdCount > 0)
|
|
60
|
+
summary.push(`${createdCount} created`);
|
|
61
|
+
console.log(chalk.green(`\n✅ ${summary.join(', ')}.\n`));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async fileExists(filePath) {
|
|
65
|
+
try {
|
|
66
|
+
await fs.access(filePath);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async detectConfiguredTools(projectPath) {
|
|
74
|
+
const configuredTools = [];
|
|
75
|
+
const allConfigurators = registry.getAll();
|
|
76
|
+
for (const configurator of allConfigurators) {
|
|
77
|
+
const targets = configurator.getTargets();
|
|
78
|
+
let hasFiles = false;
|
|
79
|
+
for (const target of targets) {
|
|
80
|
+
const filePath = path.join(projectPath, target.path);
|
|
81
|
+
if (await this.fileExists(filePath)) {
|
|
82
|
+
hasFiles = true;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (hasFiles) {
|
|
87
|
+
configuredTools.push(configurator.toolId);
|
|
88
|
+
}
|
|
35
89
|
}
|
|
90
|
+
return configuredTools;
|
|
36
91
|
}
|
|
37
92
|
}
|
|
38
93
|
//# sourceMappingURL=update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAEhE,MAAM,OAAO,aAAa;IACtB,KAAK,CAAC,OAAO;QACT,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAElC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC,CAAC;QAEtE,uBAAuB;QACvB,IAAI,CAAC,MAAM,cAAc,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;YACvD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC,CAAC;YACzE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC,CAAC;YAC3D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACX,CAAC;QAED,IAAI,YAAY,GAAG,CAAC,CAAC;QAErB,
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAA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ACL,CAAC;YAED,IAAI,QAAQ,EAAE,CAAC;gBACX,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC;QACL,CAAC;QAED,OAAO,eAAe,CAAC;IAC3B,CAAC;CACJ"}
|
package/package.json
CHANGED
package/src/cli/index.ts
CHANGED
package/src/commands/update.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
import path from 'path';
|
|
2
4
|
import { PrompterConfig } from '../core/config.js';
|
|
3
5
|
import { registry } from '../core/configurators/slash/index.js';
|
|
4
6
|
|
|
@@ -16,26 +18,85 @@ export class UpdateCommand {
|
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
// Detect configured tools
|
|
22
|
+
const configuredTools = await this.detectConfiguredTools(projectPath);
|
|
23
|
+
|
|
24
|
+
if (configuredTools.length === 0) {
|
|
25
|
+
console.log(chalk.yellow('⚠️ No configured tools found.'));
|
|
26
|
+
console.log(chalk.gray(' Run `prompter init` to configure tools.\n'));
|
|
27
|
+
process.exitCode = 1;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
let updatedCount = 0;
|
|
32
|
+
let createdCount = 0;
|
|
33
|
+
|
|
34
|
+
// Update and add missing workflow files for configured tools only
|
|
35
|
+
for (const toolId of configuredTools) {
|
|
36
|
+
const configurator = registry.get(toolId);
|
|
37
|
+
if (!configurator) continue;
|
|
20
38
|
|
|
21
|
-
// Update workflow files for all tools
|
|
22
|
-
for (const configurator of registry.getAvailable()) {
|
|
23
39
|
try {
|
|
24
|
-
|
|
25
|
-
|
|
40
|
+
// Update existing files
|
|
41
|
+
const updatedFiles = await configurator.updateExisting(projectPath);
|
|
42
|
+
for (const file of updatedFiles) {
|
|
26
43
|
console.log(chalk.green('✓') + ` Updated ${chalk.cyan(file)}`);
|
|
27
44
|
updatedCount++;
|
|
28
45
|
}
|
|
46
|
+
|
|
47
|
+
// Generate all workflow files (including missing ones)
|
|
48
|
+
const allFiles = await configurator.generateAll(projectPath);
|
|
49
|
+
const newFiles = allFiles.filter(f => !updatedFiles.includes(f));
|
|
50
|
+
for (const file of newFiles) {
|
|
51
|
+
console.log(chalk.green('✓') + ` Created ${chalk.cyan(file)}`);
|
|
52
|
+
createdCount++;
|
|
53
|
+
}
|
|
29
54
|
} catch (error) {
|
|
30
55
|
console.log(chalk.red('✗') + ` Failed to update ${configurator.toolId}: ${error}`);
|
|
31
56
|
}
|
|
32
57
|
}
|
|
33
58
|
|
|
34
|
-
if (updatedCount === 0) {
|
|
59
|
+
if (updatedCount === 0 && createdCount === 0) {
|
|
35
60
|
console.log(chalk.yellow('⚠️ No workflow files found to update.'));
|
|
36
61
|
console.log(chalk.gray(' Run `prompter init` to create them.\n'));
|
|
37
62
|
} else {
|
|
38
|
-
|
|
63
|
+
const summary: string[] = [];
|
|
64
|
+
if (updatedCount > 0) summary.push(`${updatedCount} updated`);
|
|
65
|
+
if (createdCount > 0) summary.push(`${createdCount} created`);
|
|
66
|
+
console.log(chalk.green(`\n✅ ${summary.join(', ')}.\n`));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private async fileExists(filePath: string): Promise<boolean> {
|
|
71
|
+
try {
|
|
72
|
+
await fs.access(filePath);
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
39
76
|
}
|
|
40
77
|
}
|
|
78
|
+
|
|
79
|
+
private async detectConfiguredTools(projectPath: string): Promise<string[]> {
|
|
80
|
+
const configuredTools: string[] = [];
|
|
81
|
+
const allConfigurators = registry.getAll();
|
|
82
|
+
|
|
83
|
+
for (const configurator of allConfigurators) {
|
|
84
|
+
const targets = configurator.getTargets();
|
|
85
|
+
let hasFiles = false;
|
|
86
|
+
|
|
87
|
+
for (const target of targets) {
|
|
88
|
+
const filePath = path.join(projectPath, target.path);
|
|
89
|
+
if (await this.fileExists(filePath)) {
|
|
90
|
+
hasFiles = true;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (hasFiles) {
|
|
96
|
+
configuredTools.push(configurator.toolId);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return configuredTools;
|
|
101
|
+
}
|
|
41
102
|
}
|