ai-project-boilerplate 1.2.0 → 1.3.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/bin/cli.js +78 -0
- package/package.json +6 -2
- package/scripts/preuninstall.js +11 -0
package/bin/cli.js
CHANGED
|
@@ -36,6 +36,72 @@ function compareVersions(a, b) {
|
|
|
36
36
|
return 0;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
function getPrefsPath() {
|
|
40
|
+
const os = require("os");
|
|
41
|
+
return path.join(os.homedir(), ".config", "ai-project", "prefs.json");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function loadPrefs() {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(fs.readFileSync(getPrefsPath(), "utf8"));
|
|
47
|
+
} catch {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function savePrefs(prefs) {
|
|
53
|
+
const prefsPath = getPrefsPath();
|
|
54
|
+
fs.mkdirSync(path.dirname(prefsPath), { recursive: true });
|
|
55
|
+
fs.writeFileSync(prefsPath, JSON.stringify(prefs, null, 2));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function checkPackageManager() {
|
|
59
|
+
const isPnpm = __filename.includes("pnpm");
|
|
60
|
+
if (isPnpm) return;
|
|
61
|
+
|
|
62
|
+
const prefs = loadPrefs();
|
|
63
|
+
if (prefs.suppressPnpmWarning) return;
|
|
64
|
+
|
|
65
|
+
const yellow = (s) => `\x1b[33m${s}\x1b[0m`;
|
|
66
|
+
const cyan = (s) => `\x1b[36m${s}\x1b[0m`;
|
|
67
|
+
const bold = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
68
|
+
const dim = (s) => `\x1b[2m${s}\x1b[0m`;
|
|
69
|
+
|
|
70
|
+
const hasPnpm = (() => {
|
|
71
|
+
try { require("child_process").execSync("pnpm --version", { stdio: "ignore" }); return true; } catch { return false; }
|
|
72
|
+
})();
|
|
73
|
+
|
|
74
|
+
const strip = (s) => s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
75
|
+
|
|
76
|
+
let lines;
|
|
77
|
+
if (hasPnpm) {
|
|
78
|
+
const cmd = bold(cyan("pnpm add -g ai-project-boilerplate"));
|
|
79
|
+
lines = [
|
|
80
|
+
` ${bold(yellow("RECOMMENDED:"))} install via pnpm for best compatibility`,
|
|
81
|
+
` Run ${cmd}`,
|
|
82
|
+
` To suppress this warning: ${bold(cyan("ai-project --no-pnpm-warning"))}`,
|
|
83
|
+
];
|
|
84
|
+
} else {
|
|
85
|
+
const installCmd = bold(cyan("npm install -g pnpm"));
|
|
86
|
+
const migrateCmd = bold(cyan("pnpm add -g ai-project-boilerplate"));
|
|
87
|
+
lines = [
|
|
88
|
+
` ${bold(yellow("RECOMMENDED:"))} install via pnpm for best compatibility`,
|
|
89
|
+
` 1. Install pnpm: ${installCmd}`,
|
|
90
|
+
` 2. Then migrate: ${migrateCmd}`,
|
|
91
|
+
` To suppress this warning: ${bold(cyan("ai-project --no-pnpm-warning"))}`,
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const width = Math.max(...lines.map(l => strip(l).length)) + 2;
|
|
96
|
+
const border = yellow("─".repeat(width));
|
|
97
|
+
|
|
98
|
+
console.error(`\n${yellow("┌")}${border}${yellow("┐")}`);
|
|
99
|
+
for (const line of lines) {
|
|
100
|
+
console.error(`${yellow("│")} ${line.padEnd(line.length + width - strip(line).length - 1)}${yellow("│")}`);
|
|
101
|
+
}
|
|
102
|
+
console.error(`${yellow("└")}${border}${yellow("┘")}\n`);
|
|
103
|
+
}
|
|
104
|
+
|
|
39
105
|
async function checkForUpdate() {
|
|
40
106
|
const latest = await fetchLatestVersion();
|
|
41
107
|
if (latest && compareVersions(latest, CURRENT_VERSION) > 0) {
|
|
@@ -85,6 +151,18 @@ function copyTemplate(src, dest) {
|
|
|
85
151
|
async function main() {
|
|
86
152
|
const args = process.argv.slice(2);
|
|
87
153
|
|
|
154
|
+
// Handle --no-pnpm-warning
|
|
155
|
+
if (args[0] === '--no-pnpm-warning') {
|
|
156
|
+
const prefs = loadPrefs();
|
|
157
|
+
prefs.suppressPnpmWarning = true;
|
|
158
|
+
savePrefs(prefs);
|
|
159
|
+
console.log("pnpm warning suppressed. To re-enable, delete ~/.config/ai-project/prefs.json");
|
|
160
|
+
process.exit(0);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Check package manager preference
|
|
164
|
+
checkPackageManager();
|
|
165
|
+
|
|
88
166
|
// Always check for updates first
|
|
89
167
|
await checkForUpdate();
|
|
90
168
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-project-boilerplate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "CLI to scaffold AI-collaborated projects with stage-based AI instruction files",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ai-project": "bin/cli.js"
|
|
7
7
|
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"preuninstall": "node scripts/preuninstall.js"
|
|
10
|
+
},
|
|
8
11
|
"files": [
|
|
9
12
|
"bin",
|
|
10
|
-
"template"
|
|
13
|
+
"template",
|
|
14
|
+
"scripts/preuninstall.js"
|
|
11
15
|
],
|
|
12
16
|
"keywords": [
|
|
13
17
|
"ai",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const os = require("os");
|
|
5
|
+
|
|
6
|
+
const prefsPath = path.join(os.homedir(), ".config", "ai-project", "prefs.json");
|
|
7
|
+
try {
|
|
8
|
+
fs.rmSync(prefsPath, { force: true });
|
|
9
|
+
} catch {
|
|
10
|
+
// silently ignore
|
|
11
|
+
}
|