@baton-dx/cli 0.1.1 → 0.1.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/README.md +66 -0
- package/dist/agent-detection-BW5-jGuR.mjs +4 -0
- package/dist/agent-detection-C5gaTtah.mjs +501 -0
- package/dist/agent-detection-C5gaTtah.mjs.map +1 -0
- package/dist/chunk-BbwQpWto.mjs +33 -0
- package/dist/context-detection-mMNLg_4F.mjs +9841 -0
- package/dist/context-detection-mMNLg_4F.mjs.map +1 -0
- package/dist/{create-CqfUSGj7.mjs → create-Diqnd3ci.mjs} +15 -15
- package/dist/create-Diqnd3ci.mjs.map +1 -0
- package/dist/esm-BagM-kVd.mjs +4526 -0
- package/dist/esm-BagM-kVd.mjs.map +1 -0
- package/dist/esm-CuRZ1S4C.mjs +4 -0
- package/dist/execa-RdtdAT4S.mjs +6343 -0
- package/dist/execa-RdtdAT4S.mjs.map +1 -0
- package/dist/index.mjs +290 -291
- package/dist/index.mjs.map +1 -1
- package/dist/{list-o76RXPxE.mjs → list-B5xUVBTU.mjs} +9 -10
- package/dist/{list-o76RXPxE.mjs.map → list-B5xUVBTU.mjs.map} +1 -1
- package/dist/prompt-CPT4cDau.mjs +849 -0
- package/dist/prompt-CPT4cDau.mjs.map +1 -0
- package/dist/{remove-BB883RDx.mjs → remove-6S8F9xcE.mjs} +15 -17
- package/dist/remove-6S8F9xcE.mjs.map +1 -0
- package/dist/src-Dh0ZvHbV.mjs +14434 -0
- package/dist/src-Dh0ZvHbV.mjs.map +1 -0
- package/package.json +5 -3
- package/dist/context-detection-0m8_Fp0j.mjs +0 -45
- package/dist/context-detection-0m8_Fp0j.mjs.map +0 -1
- package/dist/create-CqfUSGj7.mjs.map +0 -1
- package/dist/remove-BB883RDx.mjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { r as __toESM } from "./chunk-BbwQpWto.mjs";
|
|
3
|
+
import { a as Ne, h as defineCommand, i as Le, l as We, p as Ct, t as findSourceRoot, u as Ze } from "./context-detection-mMNLg_4F.mjs";
|
|
4
|
+
import { K as KEBAB_CASE_REGEX, f as require_lib } from "./src-Dh0ZvHbV.mjs";
|
|
5
|
+
import "./esm-BagM-kVd.mjs";
|
|
3
6
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
4
7
|
import { dirname, join } from "node:path";
|
|
5
8
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { defineCommand } from "citty";
|
|
7
|
-
import { KEBAB_CASE_REGEX } from "@baton-dx/core";
|
|
8
|
-
import * as p from "@clack/prompts";
|
|
9
|
-
import Handlebars from "handlebars";
|
|
10
9
|
|
|
11
10
|
//#region src/commands/profile/create.ts
|
|
11
|
+
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
12
12
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
13
|
const createCommand = defineCommand({
|
|
14
14
|
meta: {
|
|
@@ -21,15 +21,15 @@ const createCommand = defineCommand({
|
|
|
21
21
|
required: false
|
|
22
22
|
} },
|
|
23
23
|
async run({ args }) {
|
|
24
|
-
|
|
24
|
+
We("Create Profile");
|
|
25
25
|
const sourceRoot = await findSourceRoot();
|
|
26
26
|
if (!sourceRoot) {
|
|
27
|
-
|
|
27
|
+
Ne("This command must be run inside a source directory (baton.source.yaml not found)");
|
|
28
28
|
process.exit(1);
|
|
29
29
|
}
|
|
30
30
|
let name = args.name;
|
|
31
31
|
if (!name) {
|
|
32
|
-
const nameInput = await
|
|
32
|
+
const nameInput = await Ze({
|
|
33
33
|
message: "Profile name (kebab-case)",
|
|
34
34
|
placeholder: "e.g., backend, frontend, my-profile",
|
|
35
35
|
validate(value) {
|
|
@@ -37,25 +37,25 @@ const createCommand = defineCommand({
|
|
|
37
37
|
if (!KEBAB_CASE_REGEX.test(value.trim())) return "Profile name must be in kebab-case (e.g., my-profile, backend, frontend)";
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
if (
|
|
41
|
-
|
|
40
|
+
if (Ct(nameInput)) {
|
|
41
|
+
Ne("Cancelled.");
|
|
42
42
|
process.exit(0);
|
|
43
43
|
}
|
|
44
44
|
name = nameInput.trim();
|
|
45
45
|
}
|
|
46
46
|
if (!KEBAB_CASE_REGEX.test(name)) {
|
|
47
|
-
|
|
47
|
+
Ne("Profile name must be in kebab-case (e.g., my-profile, backend, frontend)");
|
|
48
48
|
process.exit(1);
|
|
49
49
|
}
|
|
50
50
|
const targetDir = join(sourceRoot, "profiles", name);
|
|
51
51
|
try {
|
|
52
52
|
await readdir(targetDir);
|
|
53
|
-
|
|
53
|
+
Ne(`Profile '${name}' already exists in profiles/${name}/`);
|
|
54
54
|
process.exit(1);
|
|
55
55
|
} catch {}
|
|
56
56
|
await mkdir(targetDir, { recursive: true });
|
|
57
57
|
await copyProfileTemplate(join(__dirname, "../src/templates/profile", "minimal"), targetDir, { name });
|
|
58
|
-
|
|
58
|
+
Le(`Profile '${name}' created in profiles/${name}/`);
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
/**
|
|
@@ -71,11 +71,11 @@ async function copyProfileTemplate(sourceDir, targetDir, variables) {
|
|
|
71
71
|
await copyProfileTemplate(sourcePath, targetPath, variables);
|
|
72
72
|
} else {
|
|
73
73
|
const content = await readFile(sourcePath, "utf-8");
|
|
74
|
-
await writeFile(targetPath,
|
|
74
|
+
await writeFile(targetPath, import_lib.default.compile(content, { noEscape: true })(variables), "utf-8");
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
//#endregion
|
|
80
80
|
export { createCommand };
|
|
81
|
-
//# sourceMappingURL=create-
|
|
81
|
+
//# sourceMappingURL=create-Diqnd3ci.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-Diqnd3ci.mjs","names":["p.text","p.isCancel","Handlebars"],"sources":["../src/commands/profile/create.ts"],"sourcesContent":["import { mkdir, readFile, readdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { KEBAB_CASE_REGEX } from \"@baton-dx/core\";\nimport * as p from \"@clack/prompts\";\nimport { defineCommand } from \"citty\";\nimport Handlebars from \"handlebars\";\nimport { findSourceRoot } from \"../../utils/context-detection.js\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport const createCommand = defineCommand({\n meta: {\n name: \"create\",\n description: \"Create a new profile in your source repository\",\n },\n args: {\n name: {\n type: \"positional\",\n description: \"Profile name (kebab-case)\",\n required: false,\n },\n },\n async run({ args }) {\n p.intro(\"Create Profile\");\n\n // Check for baton.source.yaml in current or parent directories\n const sourceRoot = await findSourceRoot();\n if (!sourceRoot) {\n p.cancel(\"This command must be run inside a source directory (baton.source.yaml not found)\");\n process.exit(1);\n }\n\n // Get profile name — from argument or wizard prompt\n let name = args.name as string | undefined;\n\n if (!name) {\n const nameInput = await p.text({\n message: \"Profile name (kebab-case)\",\n placeholder: \"e.g., backend, frontend, my-profile\",\n validate(value) {\n if (!value || value.trim().length === 0) {\n return \"Profile name is required\";\n }\n if (!KEBAB_CASE_REGEX.test(value.trim())) {\n return \"Profile name must be in kebab-case (e.g., my-profile, backend, frontend)\";\n }\n },\n });\n\n if (p.isCancel(nameInput)) {\n p.cancel(\"Cancelled.\");\n process.exit(0);\n }\n\n name = (nameInput as string).trim();\n }\n\n // Validate name format (kebab-case)\n if (!KEBAB_CASE_REGEX.test(name)) {\n p.cancel(\"Profile name must be in kebab-case (e.g., my-profile, backend, frontend)\");\n process.exit(1);\n }\n\n // Check if profile already exists in profiles/ directory\n const targetDir = join(sourceRoot, \"profiles\", name);\n try {\n await readdir(targetDir);\n p.cancel(`Profile '${name}' already exists in profiles/${name}/`);\n process.exit(1);\n } catch {\n // Directory doesn't exist - good to proceed\n }\n\n // Create profile directory\n await mkdir(targetDir, { recursive: true });\n\n // Copy minimal template files\n const templateDir = join(__dirname, \"../src/templates/profile\", \"minimal\");\n await copyProfileTemplate(templateDir, targetDir, { name });\n\n p.outro(`Profile '${name}' created in profiles/${name}/`);\n },\n});\n\n/**\n * Recursively copy profile template with variable substitution\n */\nasync function copyProfileTemplate(\n sourceDir: string,\n targetDir: string,\n variables: { name: string },\n): Promise<void> {\n const entries = await readdir(sourceDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const sourcePath = join(sourceDir, entry.name);\n const targetPath = join(targetDir, entry.name);\n\n if (entry.isDirectory()) {\n await mkdir(targetPath, { recursive: true });\n await copyProfileTemplate(sourcePath, targetPath, variables);\n } else {\n // Read file content\n const content = await readFile(sourcePath, \"utf-8\");\n\n // Apply Handlebars substitution for text files\n const processed = Handlebars.compile(content, { noEscape: true })(variables);\n\n // Write processed content\n await writeFile(targetPath, processed, \"utf-8\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAa,gBAAgB,cAAc;CACzC,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAAM,EACJ,MAAM;EACJ,MAAM;EACN,aAAa;EACb,UAAU;EACX,EACF;CACD,MAAM,IAAI,EAAE,QAAQ;AAClB,KAAQ,iBAAiB;EAGzB,MAAM,aAAa,MAAM,gBAAgB;AACzC,MAAI,CAAC,YAAY;AACf,MAAS,mFAAmF;AAC5F,WAAQ,KAAK,EAAE;;EAIjB,IAAI,OAAO,KAAK;AAEhB,MAAI,CAAC,MAAM;GACT,MAAM,YAAY,MAAMA,GAAO;IAC7B,SAAS;IACT,aAAa;IACb,SAAS,OAAO;AACd,SAAI,CAAC,SAAS,MAAM,MAAM,CAAC,WAAW,EACpC,QAAO;AAET,SAAI,CAAC,iBAAiB,KAAK,MAAM,MAAM,CAAC,CACtC,QAAO;;IAGZ,CAAC;AAEF,OAAIC,GAAW,UAAU,EAAE;AACzB,OAAS,aAAa;AACtB,YAAQ,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