prjct-cli 0.29.2 → 0.29.3
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/bin/prjct.mjs +4 -0
- package/dist/core/infrastructure/command-installer.js +423 -0
- package/dist/core/infrastructure/editors-config.js +157 -0
- package/dist/core/infrastructure/setup.js +837 -0
- package/dist/core/utils/version.js +111 -0
- package/package.json +5 -1
- package/scripts/build.js +80 -17
- package/scripts/postinstall.js +111 -126
package/dist/bin/prjct.mjs
CHANGED
|
@@ -12525,6 +12525,10 @@ var require_package = __commonJS({
|
|
|
12525
12525
|
build: "node scripts/build.js",
|
|
12526
12526
|
"build:shared": "bun run --filter '@prjct/shared' build",
|
|
12527
12527
|
"build:node": "node scripts/build.js",
|
|
12528
|
+
release: "node scripts/release.js",
|
|
12529
|
+
"release:patch": "node scripts/release.js patch",
|
|
12530
|
+
"release:minor": "node scripts/release.js minor",
|
|
12531
|
+
"release:major": "node scripts/release.js major",
|
|
12528
12532
|
postinstall: "node scripts/postinstall.js",
|
|
12529
12533
|
"update-commands": `bun -e "const installer = require('./core/infrastructure/command-installer'); installer.syncCommands().then(r => console.log('Commands updated:', r)).catch(e => console.error('Error:', e.message))"`,
|
|
12530
12534
|
"install-global": "./scripts/install.sh",
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// core/infrastructure/command-installer.ts
|
|
32
|
+
var command_installer_exports = {};
|
|
33
|
+
__export(command_installer_exports, {
|
|
34
|
+
CommandInstaller: () => CommandInstaller,
|
|
35
|
+
default: () => command_installer_default,
|
|
36
|
+
installDocs: () => installDocs,
|
|
37
|
+
installGlobalConfig: () => installGlobalConfig
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(command_installer_exports);
|
|
40
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
41
|
+
var import_path = __toESM(require("path"));
|
|
42
|
+
var import_os = __toESM(require("os"));
|
|
43
|
+
async function installDocs() {
|
|
44
|
+
try {
|
|
45
|
+
const docsDir = import_path.default.join(import_os.default.homedir(), ".prjct-cli", "docs");
|
|
46
|
+
const templateDocsDir = import_path.default.join(__dirname, "../../templates/global/docs");
|
|
47
|
+
await import_promises.default.mkdir(docsDir, { recursive: true });
|
|
48
|
+
const docFiles = await import_promises.default.readdir(templateDocsDir);
|
|
49
|
+
for (const file of docFiles) {
|
|
50
|
+
if (file.endsWith(".md")) {
|
|
51
|
+
const srcPath = import_path.default.join(templateDocsDir, file);
|
|
52
|
+
const destPath = import_path.default.join(docsDir, file);
|
|
53
|
+
const content = await import_promises.default.readFile(srcPath, "utf-8");
|
|
54
|
+
await import_promises.default.writeFile(destPath, content, "utf-8");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { success: true };
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return { success: false, error: error.message };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
__name(installDocs, "installDocs");
|
|
63
|
+
async function installGlobalConfig(claudeConfigPath, detectClaude) {
|
|
64
|
+
const claudeDetected = await detectClaude();
|
|
65
|
+
if (!claudeDetected) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
error: "Claude not detected",
|
|
69
|
+
action: "skipped"
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const claudeDir = import_path.default.join(import_os.default.homedir(), ".claude");
|
|
74
|
+
await import_promises.default.mkdir(claudeDir, { recursive: true });
|
|
75
|
+
const globalConfigPath = import_path.default.join(claudeDir, "CLAUDE.md");
|
|
76
|
+
const templatePath = import_path.default.join(__dirname, "../../templates/global/CLAUDE.md");
|
|
77
|
+
const templateContent = await import_promises.default.readFile(templatePath, "utf-8");
|
|
78
|
+
let existingContent = "";
|
|
79
|
+
let fileExists = false;
|
|
80
|
+
try {
|
|
81
|
+
existingContent = await import_promises.default.readFile(globalConfigPath, "utf-8");
|
|
82
|
+
fileExists = true;
|
|
83
|
+
} catch {
|
|
84
|
+
fileExists = false;
|
|
85
|
+
}
|
|
86
|
+
if (!fileExists) {
|
|
87
|
+
await import_promises.default.writeFile(globalConfigPath, templateContent, "utf-8");
|
|
88
|
+
return {
|
|
89
|
+
success: true,
|
|
90
|
+
action: "created",
|
|
91
|
+
path: globalConfigPath
|
|
92
|
+
};
|
|
93
|
+
} else {
|
|
94
|
+
const startMarker = "<!-- prjct:start - DO NOT REMOVE THIS MARKER -->";
|
|
95
|
+
const endMarker = "<!-- prjct:end - DO NOT REMOVE THIS MARKER -->";
|
|
96
|
+
const hasMarkers = existingContent.includes(startMarker) && existingContent.includes(endMarker);
|
|
97
|
+
if (!hasMarkers) {
|
|
98
|
+
const updatedContent = existingContent + "\n\n" + templateContent;
|
|
99
|
+
await import_promises.default.writeFile(globalConfigPath, updatedContent, "utf-8");
|
|
100
|
+
return {
|
|
101
|
+
success: true,
|
|
102
|
+
action: "appended",
|
|
103
|
+
path: globalConfigPath
|
|
104
|
+
};
|
|
105
|
+
} else {
|
|
106
|
+
const beforeMarker = existingContent.substring(0, existingContent.indexOf(startMarker));
|
|
107
|
+
const afterMarker = existingContent.substring(
|
|
108
|
+
existingContent.indexOf(endMarker) + endMarker.length
|
|
109
|
+
);
|
|
110
|
+
const prjctSection = templateContent.substring(
|
|
111
|
+
templateContent.indexOf(startMarker),
|
|
112
|
+
templateContent.indexOf(endMarker) + endMarker.length
|
|
113
|
+
);
|
|
114
|
+
const updatedContent = beforeMarker + prjctSection + afterMarker;
|
|
115
|
+
await import_promises.default.writeFile(globalConfigPath, updatedContent, "utf-8");
|
|
116
|
+
return {
|
|
117
|
+
success: true,
|
|
118
|
+
action: "updated",
|
|
119
|
+
path: globalConfigPath
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return {
|
|
125
|
+
success: false,
|
|
126
|
+
error: error.message,
|
|
127
|
+
action: "failed"
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
__name(installGlobalConfig, "installGlobalConfig");
|
|
132
|
+
var CommandInstaller = class {
|
|
133
|
+
static {
|
|
134
|
+
__name(this, "CommandInstaller");
|
|
135
|
+
}
|
|
136
|
+
homeDir;
|
|
137
|
+
claudeCommandsPath;
|
|
138
|
+
claudeConfigPath;
|
|
139
|
+
templatesDir;
|
|
140
|
+
constructor() {
|
|
141
|
+
this.homeDir = import_os.default.homedir();
|
|
142
|
+
this.claudeCommandsPath = import_path.default.join(this.homeDir, ".claude", "commands", "p");
|
|
143
|
+
this.claudeConfigPath = import_path.default.join(this.homeDir, ".claude");
|
|
144
|
+
this.templatesDir = import_path.default.join(__dirname, "..", "..", "templates", "commands");
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Detect if Claude is installed
|
|
148
|
+
*/
|
|
149
|
+
async detectClaude() {
|
|
150
|
+
try {
|
|
151
|
+
await import_promises.default.access(this.claudeConfigPath);
|
|
152
|
+
return true;
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get list of command files to install
|
|
159
|
+
*/
|
|
160
|
+
async getCommandFiles() {
|
|
161
|
+
try {
|
|
162
|
+
const files = await import_promises.default.readdir(this.templatesDir);
|
|
163
|
+
return files.filter((f) => f.endsWith(".md"));
|
|
164
|
+
} catch {
|
|
165
|
+
return [
|
|
166
|
+
"init.md",
|
|
167
|
+
"now.md",
|
|
168
|
+
"done.md",
|
|
169
|
+
"ship.md",
|
|
170
|
+
"next.md",
|
|
171
|
+
"idea.md",
|
|
172
|
+
"recap.md",
|
|
173
|
+
"progress.md",
|
|
174
|
+
"stuck.md",
|
|
175
|
+
"context.md",
|
|
176
|
+
"analyze.md",
|
|
177
|
+
"sync.md",
|
|
178
|
+
"roadmap.md",
|
|
179
|
+
"task.md",
|
|
180
|
+
"git.md",
|
|
181
|
+
"fix.md",
|
|
182
|
+
"test.md",
|
|
183
|
+
"cleanup.md",
|
|
184
|
+
"design.md"
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Install commands to Claude
|
|
190
|
+
*/
|
|
191
|
+
async installCommands() {
|
|
192
|
+
const claudeDetected = await this.detectClaude();
|
|
193
|
+
if (!claudeDetected) {
|
|
194
|
+
return {
|
|
195
|
+
success: false,
|
|
196
|
+
error: "Claude not detected. Please install Claude Code or Claude Desktop first."
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
await this.installRouter();
|
|
201
|
+
await import_promises.default.mkdir(this.claudeCommandsPath, { recursive: true });
|
|
202
|
+
const commandFiles = await this.getCommandFiles();
|
|
203
|
+
const installed = [];
|
|
204
|
+
const errors = [];
|
|
205
|
+
for (const file of commandFiles) {
|
|
206
|
+
try {
|
|
207
|
+
const sourcePath = import_path.default.join(this.templatesDir, file);
|
|
208
|
+
const destPath = import_path.default.join(this.claudeCommandsPath, file);
|
|
209
|
+
const content = await import_promises.default.readFile(sourcePath, "utf-8");
|
|
210
|
+
await import_promises.default.writeFile(destPath, content, "utf-8");
|
|
211
|
+
installed.push(file.replace(".md", ""));
|
|
212
|
+
} catch (error) {
|
|
213
|
+
errors.push({ file, error: error.message });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
success: true,
|
|
218
|
+
installed,
|
|
219
|
+
errors,
|
|
220
|
+
path: this.claudeCommandsPath
|
|
221
|
+
};
|
|
222
|
+
} catch (error) {
|
|
223
|
+
return {
|
|
224
|
+
success: false,
|
|
225
|
+
error: error.message
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Uninstall commands from Claude
|
|
231
|
+
*/
|
|
232
|
+
async uninstallCommands() {
|
|
233
|
+
try {
|
|
234
|
+
const commandFiles = await this.getCommandFiles();
|
|
235
|
+
const uninstalled = [];
|
|
236
|
+
const errors = [];
|
|
237
|
+
for (const file of commandFiles) {
|
|
238
|
+
try {
|
|
239
|
+
const filePath = import_path.default.join(this.claudeCommandsPath, file);
|
|
240
|
+
await import_promises.default.unlink(filePath);
|
|
241
|
+
uninstalled.push(file.replace(".md", ""));
|
|
242
|
+
} catch (error) {
|
|
243
|
+
if (error.code !== "ENOENT") {
|
|
244
|
+
errors.push({ file, error: error.message });
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
await import_promises.default.rmdir(this.claudeCommandsPath);
|
|
250
|
+
} catch {
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
success: true,
|
|
254
|
+
uninstalled,
|
|
255
|
+
errors
|
|
256
|
+
};
|
|
257
|
+
} catch (error) {
|
|
258
|
+
return {
|
|
259
|
+
success: false,
|
|
260
|
+
error: error.message
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Check if commands are already installed
|
|
266
|
+
*/
|
|
267
|
+
async checkInstallation() {
|
|
268
|
+
const claudeDetected = await this.detectClaude();
|
|
269
|
+
if (!claudeDetected) {
|
|
270
|
+
return {
|
|
271
|
+
installed: false,
|
|
272
|
+
claudeDetected: false
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
await import_promises.default.access(this.claudeCommandsPath);
|
|
277
|
+
const files = await import_promises.default.readdir(this.claudeCommandsPath);
|
|
278
|
+
const installedCommands = files.filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", ""));
|
|
279
|
+
return {
|
|
280
|
+
installed: installedCommands.length > 0,
|
|
281
|
+
claudeDetected: true,
|
|
282
|
+
commands: installedCommands,
|
|
283
|
+
path: this.claudeCommandsPath
|
|
284
|
+
};
|
|
285
|
+
} catch {
|
|
286
|
+
return {
|
|
287
|
+
installed: false,
|
|
288
|
+
claudeDetected: true,
|
|
289
|
+
commands: []
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Update commands (reinstall with latest templates)
|
|
295
|
+
*/
|
|
296
|
+
async updateCommands() {
|
|
297
|
+
console.log("Updating commands with latest templates...");
|
|
298
|
+
const result = await this.installCommands();
|
|
299
|
+
if (result.success && result.installed) {
|
|
300
|
+
console.log(`Updated ${result.installed.length} commands`);
|
|
301
|
+
}
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Install to all detected editors (alias for installCommands)
|
|
306
|
+
*/
|
|
307
|
+
async installToAll() {
|
|
308
|
+
return await this.installCommands();
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get installation path for Claude commands
|
|
312
|
+
*/
|
|
313
|
+
getInstallPath() {
|
|
314
|
+
return this.claudeCommandsPath;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Verify command template exists
|
|
318
|
+
*/
|
|
319
|
+
async verifyTemplate(commandName) {
|
|
320
|
+
try {
|
|
321
|
+
const templatePath = import_path.default.join(this.templatesDir, `${commandName}.md`);
|
|
322
|
+
await import_promises.default.access(templatePath);
|
|
323
|
+
return true;
|
|
324
|
+
} catch {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Install the p.md router to ~/.claude/commands/
|
|
330
|
+
* This enables the "p. task" natural language trigger
|
|
331
|
+
* Claude Code bug #2422 prevents subdirectory slash command discovery
|
|
332
|
+
*/
|
|
333
|
+
async installRouter() {
|
|
334
|
+
try {
|
|
335
|
+
const routerSource = import_path.default.join(this.templatesDir, "p.md");
|
|
336
|
+
const routerDest = import_path.default.join(this.homeDir, ".claude", "commands", "p.md");
|
|
337
|
+
const content = await import_promises.default.readFile(routerSource, "utf-8");
|
|
338
|
+
await import_promises.default.writeFile(routerDest, content, "utf-8");
|
|
339
|
+
return true;
|
|
340
|
+
} catch {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Sync commands - intelligent update that detects and removes orphans
|
|
346
|
+
*/
|
|
347
|
+
async syncCommands() {
|
|
348
|
+
const claudeDetected = await this.detectClaude();
|
|
349
|
+
if (!claudeDetected) {
|
|
350
|
+
return {
|
|
351
|
+
success: false,
|
|
352
|
+
error: "Claude not detected",
|
|
353
|
+
added: 0,
|
|
354
|
+
updated: 0,
|
|
355
|
+
removed: 0
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
try {
|
|
359
|
+
await this.installRouter();
|
|
360
|
+
await import_promises.default.mkdir(this.claudeCommandsPath, { recursive: true });
|
|
361
|
+
const templateFiles = await this.getCommandFiles();
|
|
362
|
+
let installedFiles = [];
|
|
363
|
+
try {
|
|
364
|
+
installedFiles = await import_promises.default.readdir(this.claudeCommandsPath);
|
|
365
|
+
installedFiles = installedFiles.filter((f) => f.endsWith(".md"));
|
|
366
|
+
} catch {
|
|
367
|
+
installedFiles = [];
|
|
368
|
+
}
|
|
369
|
+
const results = {
|
|
370
|
+
success: true,
|
|
371
|
+
added: 0,
|
|
372
|
+
updated: 0,
|
|
373
|
+
removed: 0,
|
|
374
|
+
errors: []
|
|
375
|
+
};
|
|
376
|
+
for (const file of templateFiles) {
|
|
377
|
+
try {
|
|
378
|
+
const sourcePath = import_path.default.join(this.templatesDir, file);
|
|
379
|
+
const destPath = import_path.default.join(this.claudeCommandsPath, file);
|
|
380
|
+
const exists = installedFiles.includes(file);
|
|
381
|
+
const content = await import_promises.default.readFile(sourcePath, "utf-8");
|
|
382
|
+
await import_promises.default.writeFile(destPath, content, "utf-8");
|
|
383
|
+
if (!exists) {
|
|
384
|
+
results.added++;
|
|
385
|
+
} else {
|
|
386
|
+
results.updated++;
|
|
387
|
+
}
|
|
388
|
+
} catch (error) {
|
|
389
|
+
results.errors.push({ file, error: error.message });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return results;
|
|
393
|
+
} catch (error) {
|
|
394
|
+
return {
|
|
395
|
+
success: false,
|
|
396
|
+
error: error.message,
|
|
397
|
+
added: 0,
|
|
398
|
+
updated: 0,
|
|
399
|
+
removed: 0
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Install or update global CLAUDE.md configuration
|
|
405
|
+
*/
|
|
406
|
+
async installGlobalConfig() {
|
|
407
|
+
return installGlobalConfig(this.claudeConfigPath, () => this.detectClaude());
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Install documentation files to ~/.prjct-cli/docs/
|
|
411
|
+
*/
|
|
412
|
+
async installDocs() {
|
|
413
|
+
return installDocs();
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
var commandInstaller = new CommandInstaller();
|
|
417
|
+
var command_installer_default = commandInstaller;
|
|
418
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
419
|
+
0 && (module.exports = {
|
|
420
|
+
CommandInstaller,
|
|
421
|
+
installDocs,
|
|
422
|
+
installGlobalConfig
|
|
423
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// core/infrastructure/editors-config.ts
|
|
32
|
+
var editors_config_exports = {};
|
|
33
|
+
__export(editors_config_exports, {
|
|
34
|
+
default: () => editors_config_default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(editors_config_exports);
|
|
37
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
var import_os = __toESM(require("os"));
|
|
40
|
+
var EditorsConfig = class {
|
|
41
|
+
static {
|
|
42
|
+
__name(this, "EditorsConfig");
|
|
43
|
+
}
|
|
44
|
+
homeDir;
|
|
45
|
+
configDir;
|
|
46
|
+
configFile;
|
|
47
|
+
constructor() {
|
|
48
|
+
this.homeDir = import_os.default.homedir();
|
|
49
|
+
this.configDir = import_path.default.join(this.homeDir, ".prjct-cli", "config");
|
|
50
|
+
this.configFile = import_path.default.join(this.configDir, "installed-editors.json");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Ensure config directory exists
|
|
54
|
+
*/
|
|
55
|
+
async ensureConfigDir() {
|
|
56
|
+
try {
|
|
57
|
+
await import_promises.default.mkdir(this.configDir, { recursive: true });
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error("[editors-config] Error creating config directory:", error.message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Load installation configuration
|
|
64
|
+
*/
|
|
65
|
+
async loadConfig() {
|
|
66
|
+
try {
|
|
67
|
+
const content = await import_promises.default.readFile(this.configFile, "utf-8");
|
|
68
|
+
return JSON.parse(content);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error.code === "ENOENT") {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
console.error("[editors-config] Error loading config:", error.message);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Save installation configuration
|
|
79
|
+
*/
|
|
80
|
+
async saveConfig(version, claudePath) {
|
|
81
|
+
try {
|
|
82
|
+
await this.ensureConfigDir();
|
|
83
|
+
const config = {
|
|
84
|
+
version,
|
|
85
|
+
editor: "claude",
|
|
86
|
+
lastInstall: (/* @__PURE__ */ new Date()).toISOString(),
|
|
87
|
+
path: claudePath
|
|
88
|
+
};
|
|
89
|
+
await import_promises.default.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
|
|
90
|
+
return true;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error("[editors-config] Error saving config:", error.message);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get last installed version
|
|
98
|
+
*/
|
|
99
|
+
async getLastVersion() {
|
|
100
|
+
const config = await this.loadConfig();
|
|
101
|
+
return config ? config.version : null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Check if version has changed since last install
|
|
105
|
+
*/
|
|
106
|
+
async hasVersionChanged(currentVersion) {
|
|
107
|
+
const lastVersion = await this.getLastVersion();
|
|
108
|
+
return lastVersion !== null && lastVersion !== currentVersion;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Update version in configuration
|
|
112
|
+
*/
|
|
113
|
+
async updateVersion(version) {
|
|
114
|
+
try {
|
|
115
|
+
const config = await this.loadConfig();
|
|
116
|
+
if (!config) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
config.version = version;
|
|
120
|
+
config.lastInstall = (/* @__PURE__ */ new Date()).toISOString();
|
|
121
|
+
await import_promises.default.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
|
|
122
|
+
return true;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error("[editors-config] Error updating version:", error.message);
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Check if config file exists
|
|
130
|
+
*/
|
|
131
|
+
async configExists() {
|
|
132
|
+
try {
|
|
133
|
+
await import_promises.default.access(this.configFile);
|
|
134
|
+
return true;
|
|
135
|
+
} catch {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Delete configuration file
|
|
141
|
+
* Used during uninstallation to clean up tracking data
|
|
142
|
+
*/
|
|
143
|
+
async deleteConfig() {
|
|
144
|
+
try {
|
|
145
|
+
const exists = await this.configExists();
|
|
146
|
+
if (exists) {
|
|
147
|
+
await import_promises.default.unlink(this.configFile);
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error("[editors-config] Error deleting config:", error.message);
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var editorsConfig = new EditorsConfig();
|
|
157
|
+
var editors_config_default = editorsConfig;
|