commet 1.4.2 → 1.5.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/dist/index.js +109 -2
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var import_commander11 = require("commander");
|
|
|
30
30
|
// package.json
|
|
31
31
|
var package_default = {
|
|
32
32
|
name: "commet",
|
|
33
|
-
version: "1.
|
|
33
|
+
version: "1.5.0",
|
|
34
34
|
description: "Commet CLI - Manage your billing platform from the command line",
|
|
35
35
|
bin: {
|
|
36
36
|
commet: "./bin/commet"
|
|
@@ -45,7 +45,8 @@ var package_default = {
|
|
|
45
45
|
dev: "tsup --watch",
|
|
46
46
|
lint: "biome lint src/",
|
|
47
47
|
"lint:fix": "biome lint --write src/",
|
|
48
|
-
typecheck: "tsc --noEmit"
|
|
48
|
+
typecheck: "tsc --noEmit",
|
|
49
|
+
clean: "rm -rf .turbo node_modules dist"
|
|
49
50
|
},
|
|
50
51
|
keywords: [
|
|
51
52
|
"billing",
|
|
@@ -85,6 +86,7 @@ var package_default = {
|
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
// src/commands/create.ts
|
|
89
|
+
var import_node_child_process = require("child_process");
|
|
88
90
|
var fs2 = __toESM(require("fs"));
|
|
89
91
|
var os2 = __toESM(require("os"));
|
|
90
92
|
var path2 = __toESM(require("path"));
|
|
@@ -398,6 +400,61 @@ function updatePackageJson(dest, projectName) {
|
|
|
398
400
|
fs2.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
399
401
|
`);
|
|
400
402
|
}
|
|
403
|
+
async function fetchLatestVersion(packageName) {
|
|
404
|
+
const response = await fetch(
|
|
405
|
+
`https://registry.npmjs.org/${packageName}/latest`
|
|
406
|
+
);
|
|
407
|
+
if (!response.ok) {
|
|
408
|
+
throw new Error(
|
|
409
|
+
`Failed to fetch version for ${packageName} (HTTP ${response.status})`
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
const data = await response.json();
|
|
413
|
+
return data.version;
|
|
414
|
+
}
|
|
415
|
+
async function resolveWorkspaceDeps(dest) {
|
|
416
|
+
const pkgPath = path2.join(dest, "package.json");
|
|
417
|
+
const pkg = JSON.parse(fs2.readFileSync(pkgPath, "utf-8"));
|
|
418
|
+
const depSections = [
|
|
419
|
+
"dependencies",
|
|
420
|
+
"devDependencies",
|
|
421
|
+
"peerDependencies"
|
|
422
|
+
];
|
|
423
|
+
const workspaceDeps = /* @__PURE__ */ new Map();
|
|
424
|
+
for (const section of depSections) {
|
|
425
|
+
const deps = pkg[section];
|
|
426
|
+
if (!deps) continue;
|
|
427
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
428
|
+
if (typeof version === "string" && version.startsWith("workspace:")) {
|
|
429
|
+
const existing = workspaceDeps.get(name);
|
|
430
|
+
if (existing) {
|
|
431
|
+
existing.push(section);
|
|
432
|
+
} else {
|
|
433
|
+
workspaceDeps.set(name, [section]);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (workspaceDeps.size === 0) return 0;
|
|
439
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
440
|
+
await Promise.all(
|
|
441
|
+
Array.from(workspaceDeps.keys()).map(async (name) => {
|
|
442
|
+
resolved.set(name, await fetchLatestVersion(name));
|
|
443
|
+
})
|
|
444
|
+
);
|
|
445
|
+
for (const [name, sections] of workspaceDeps) {
|
|
446
|
+
const version = resolved.get(name);
|
|
447
|
+
if (!version) {
|
|
448
|
+
throw new Error(`Could not resolve version for ${name}`);
|
|
449
|
+
}
|
|
450
|
+
for (const section of sections) {
|
|
451
|
+
pkg[section][name] = version;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
fs2.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
455
|
+
`);
|
|
456
|
+
return workspaceDeps.size;
|
|
457
|
+
}
|
|
401
458
|
function copyEnvExample(dest) {
|
|
402
459
|
const examplePath = path2.join(dest, ".env.example");
|
|
403
460
|
const envPath = path2.join(dest, ".env");
|
|
@@ -425,6 +482,34 @@ function linkProject(dest, orgId, orgName, environment) {
|
|
|
425
482
|
"utf8"
|
|
426
483
|
);
|
|
427
484
|
}
|
|
485
|
+
async function askSkills() {
|
|
486
|
+
try {
|
|
487
|
+
return await (0, import_prompts.confirm)({
|
|
488
|
+
message: `Add ${commetColor("agent skills")}?`,
|
|
489
|
+
default: true,
|
|
490
|
+
theme: promptTheme
|
|
491
|
+
});
|
|
492
|
+
} catch {
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
async function installSkills(projectRoot) {
|
|
497
|
+
const npx = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
498
|
+
return new Promise((resolve3) => {
|
|
499
|
+
const child = (0, import_node_child_process.spawn)(
|
|
500
|
+
npx,
|
|
501
|
+
["-y", "--loglevel=error", "skills", "add", "commet-labs/commet-skills"],
|
|
502
|
+
{ cwd: projectRoot, stdio: "inherit" }
|
|
503
|
+
);
|
|
504
|
+
child.on("close", (code) => {
|
|
505
|
+
if (code !== 0) {
|
|
506
|
+
console.log(import_chalk3.default.dim(" You can install them manually by running:"));
|
|
507
|
+
console.log(import_chalk3.default.dim(" npx skills add commet-labs/commet-skills"));
|
|
508
|
+
}
|
|
509
|
+
resolve3();
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
}
|
|
428
513
|
var createCommand = new import_commander.Command("create").description("Create a new Commet app from a template").argument("[name]", "Project name").option(
|
|
429
514
|
"-t, --template <template>",
|
|
430
515
|
"Template to use (fixed, seats, metered, credits, balance-ai, balance-fixed)"
|
|
@@ -554,6 +639,7 @@ var createCommand = new import_commander.Command("create").description("Create a
|
|
|
554
639
|
console.log(import_chalk3.default.yellow("\n\u26A0 Cancelled"));
|
|
555
640
|
return;
|
|
556
641
|
}
|
|
642
|
+
const shouldInstallSkills = await askSkills();
|
|
557
643
|
const downloadSpinner = (0, import_ora2.default)("Downloading template...").start();
|
|
558
644
|
try {
|
|
559
645
|
await downloadTemplate(template.dir, dest, opts.ref);
|
|
@@ -570,6 +656,24 @@ var createCommand = new import_commander.Command("create").description("Create a
|
|
|
570
656
|
}
|
|
571
657
|
updatePackageJson(dest, projectName);
|
|
572
658
|
copyEnvExample(dest);
|
|
659
|
+
const resolveSpinner = (0, import_ora2.default)("Resolving package versions...").start();
|
|
660
|
+
try {
|
|
661
|
+
const count = await resolveWorkspaceDeps(dest);
|
|
662
|
+
if (count > 0) {
|
|
663
|
+
resolveSpinner.succeed(`Resolved ${count} package versions`);
|
|
664
|
+
} else {
|
|
665
|
+
resolveSpinner.stop();
|
|
666
|
+
}
|
|
667
|
+
} catch (error) {
|
|
668
|
+
resolveSpinner.fail("Failed to resolve package versions");
|
|
669
|
+
if (error instanceof Error) {
|
|
670
|
+
console.error(import_chalk3.default.red(error.message));
|
|
671
|
+
}
|
|
672
|
+
if (fs2.existsSync(dest)) {
|
|
673
|
+
fs2.rmSync(dest, { recursive: true, force: true });
|
|
674
|
+
}
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
573
677
|
const planSpinner = (0, import_ora2.default)("Creating plans...").start();
|
|
574
678
|
const templateResult = await apiRequest(`${baseURL}/api/cli/templates`, {
|
|
575
679
|
method: "POST",
|
|
@@ -603,6 +707,9 @@ var createCommand = new import_commander.Command("create").description("Create a
|
|
|
603
707
|
keySpinner.succeed("API key created and saved to .env");
|
|
604
708
|
}
|
|
605
709
|
linkProject(dest, selectedOrg.id, selectedOrg.name, auth.environment);
|
|
710
|
+
if (shouldInstallSkills) {
|
|
711
|
+
await installSkills(dest);
|
|
712
|
+
}
|
|
606
713
|
console.log(import_chalk3.default.green(`
|
|
607
714
|
\u2713 Created ${projectName}`));
|
|
608
715
|
console.log(import_chalk3.default.dim(` Template: ${template.name}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Commet CLI - Manage your billing platform from the command line",
|
|
5
5
|
"bin": {
|
|
6
6
|
"commet": "./bin/commet"
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"dev": "tsup --watch",
|
|
51
51
|
"lint": "biome lint src/",
|
|
52
52
|
"lint:fix": "biome lint --write src/",
|
|
53
|
-
"typecheck": "tsc --noEmit"
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"clean": "rm -rf .turbo node_modules dist"
|
|
54
55
|
}
|
|
55
56
|
}
|