@baton-dx/cli 0.4.3 → 0.4.4
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/{context-detection-DdbrKid3.mjs → context-detection-Ddu0mj_K.mjs} +17 -17
- package/dist/context-detection-Ddu0mj_K.mjs.map +1 -0
- package/dist/{create-C1zm03eE.mjs → create-DEZA3dPb.mjs} +3 -3
- package/dist/{create-C1zm03eE.mjs.map → create-DEZA3dPb.mjs.map} +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{list-BHFeSiTO.mjs → list-BT2zFAVc.mjs} +3 -3
- package/dist/{list-BHFeSiTO.mjs.map → list-BT2zFAVc.mjs.map} +1 -1
- package/dist/{prompt-B0zuVo8N.mjs → prompt-DtgNNhRW.mjs} +8 -8
- package/dist/{prompt-B0zuVo8N.mjs.map → prompt-DtgNNhRW.mjs.map} +1 -1
- package/dist/{remove-iaf_gkie.mjs → remove-BBFBYUPy.mjs} +2 -2
- package/dist/{remove-iaf_gkie.mjs.map → remove-BBFBYUPy.mjs.map} +1 -1
- package/dist/{src-YrWWPWNR.mjs → src-dY02psbw.mjs} +16 -7
- package/dist/src-dY02psbw.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/context-detection-DdbrKid3.mjs.map +0 -1
- package/dist/src-YrWWPWNR.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-
|
|
1
|
+
{"version":3,"file":"remove-BBFBYUPy.mjs","names":["p.confirm","p.isCancel"],"sources":["../src/commands/profile/remove.ts"],"sourcesContent":["import { readFile, readdir, rm, writeFile } from \"node:fs/promises\";\nimport { join, relative } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { defineCommand } from \"citty\";\nimport { parse as parseYaml, stringify as stringifyYaml } from \"yaml\";\nimport { findSourceRoot } from \"../../utils/context-detection.js\";\n\n/**\n * Recursively collect all file paths in a directory (relative to baseDir)\n */\nasync function collectFiles(dir: string, baseDir: string): Promise<string[]> {\n const files: string[] = [];\n const entries = await readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n if (entry.isDirectory()) {\n files.push(...(await collectFiles(fullPath, baseDir)));\n } else {\n files.push(relative(baseDir, fullPath));\n }\n }\n\n return files;\n}\n\n/**\n * Remove a profile entry from baton.source.yaml if it exists in the profiles array\n */\nasync function removeProfileFromSourceManifest(\n sourceRoot: string,\n profileName: string,\n): Promise<void> {\n const manifestPath = join(sourceRoot, \"baton.source.yaml\");\n\n try {\n const content = await readFile(manifestPath, \"utf-8\");\n const manifest = parseYaml(content);\n\n if (manifest?.profiles && Array.isArray(manifest.profiles)) {\n const originalLength = manifest.profiles.length;\n manifest.profiles = manifest.profiles.filter(\n (profile: { name?: string; path?: string }) =>\n profile.name !== profileName && profile.path !== `profiles/${profileName}`,\n );\n\n if (manifest.profiles.length < originalLength) {\n // Remove empty profiles array\n if (manifest.profiles.length === 0) {\n manifest.profiles = undefined;\n }\n await writeFile(manifestPath, stringifyYaml(manifest), \"utf-8\");\n }\n }\n } catch {\n // If manifest can't be read/written, skip — the directory removal is the primary action\n }\n}\n\nexport const profileRemoveCommand = defineCommand({\n meta: {\n name: \"remove\",\n description: \"Remove a profile from the source repository\",\n },\n args: {\n name: {\n type: \"positional\",\n description: \"Profile name to remove\",\n required: true,\n },\n },\n async run({ args }) {\n p.intro(\"Remove 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 const profileName = args.name as string;\n const profileDir = join(sourceRoot, \"profiles\", profileName);\n\n // Check if profile directory exists\n let files: string[];\n try {\n files = await collectFiles(profileDir, sourceRoot);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n p.cancel(`Profile \"${profileName}\" does not exist in profiles/${profileName}/`);\n process.exit(1);\n }\n throw error;\n }\n\n // Warn about files that will be deleted\n if (files.length > 0) {\n p.log.warn(\"The following files will be deleted:\");\n for (const file of files) {\n p.log.info(` ${file}`);\n }\n } else {\n p.log.warn(`Directory profiles/${profileName}/ will be deleted.`);\n }\n\n // Confirm before removing\n const confirmed = await p.confirm({\n message: `Are you sure you want to remove profile \"${profileName}\"?`,\n initialValue: false,\n });\n\n if (p.isCancel(confirmed) || !confirmed) {\n p.cancel(\"Operation cancelled.\");\n process.exit(0);\n }\n\n // Remove the profile directory\n await rm(profileDir, { recursive: true, force: true });\n\n // Remove entry from baton.source.yaml if present\n await removeProfileFromSourceManifest(sourceRoot, profileName);\n\n p.outro(`Profile \"${profileName}\" removed from profiles/${profileName}/`);\n },\n});\n"],"mappings":";;;;;;;;;;AAUA,eAAe,aAAa,KAAa,SAAoC;CAC3E,MAAM,QAAkB,EAAE;CAC1B,MAAM,UAAU,MAAM,QAAQ,KAAK,EAAE,eAAe,MAAM,CAAC;AAE3D,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,WAAW,KAAK,KAAK,MAAM,KAAK;AACtC,MAAI,MAAM,aAAa,CACrB,OAAM,KAAK,GAAI,MAAM,aAAa,UAAU,QAAQ,CAAE;MAEtD,OAAM,KAAK,SAAS,SAAS,SAAS,CAAC;;AAI3C,QAAO;;;;;AAMT,eAAe,gCACb,YACA,aACe;CACf,MAAM,eAAe,KAAK,YAAY,oBAAoB;AAE1D,KAAI;EAEF,MAAM,kCADU,MAAM,SAAS,cAAc,QAAQ,CAClB;AAEnC,MAAI,UAAU,YAAY,MAAM,QAAQ,SAAS,SAAS,EAAE;GAC1D,MAAM,iBAAiB,SAAS,SAAS;AACzC,YAAS,WAAW,SAAS,SAAS,QACnC,YACC,QAAQ,SAAS,eAAe,QAAQ,SAAS,YAAY,cAChE;AAED,OAAI,SAAS,SAAS,SAAS,gBAAgB;AAE7C,QAAI,SAAS,SAAS,WAAW,EAC/B,UAAS,WAAW;AAEtB,UAAM,UAAU,yCAA4B,SAAS,EAAE,QAAQ;;;SAG7D;;AAKV,MAAa,uBAAuB,cAAc;CAChD,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;;EAGjB,MAAM,cAAc,KAAK;EACzB,MAAM,aAAa,KAAK,YAAY,YAAY,YAAY;EAG5D,IAAI;AACJ,MAAI;AACF,WAAQ,MAAM,aAAa,YAAY,WAAW;WAC3C,OAAO;AACd,OAAK,MAAgC,SAAS,UAAU;AACtD,OAAS,YAAY,YAAY,+BAA+B,YAAY,GAAG;AAC/E,YAAQ,KAAK,EAAE;;AAEjB,SAAM;;AAIR,MAAI,MAAM,SAAS,GAAG;AACpB,KAAM,KAAK,uCAAuC;AAClD,QAAK,MAAM,QAAQ,MACjB,GAAM,KAAK,KAAK,OAAO;QAGzB,GAAM,KAAK,sBAAsB,YAAY,oBAAoB;EAInE,MAAM,YAAY,MAAMA,GAAU;GAChC,SAAS,4CAA4C,YAAY;GACjE,cAAc;GACf,CAAC;AAEF,MAAIC,GAAW,UAAU,IAAI,CAAC,WAAW;AACvC,MAAS,uBAAuB;AAChC,WAAQ,KAAK,EAAE;;AAIjB,QAAM,GAAG,YAAY;GAAE,WAAW;GAAM,OAAO;GAAM,CAAC;AAGtD,QAAM,gCAAgC,YAAY,YAAY;AAE9D,KAAQ,YAAY,YAAY,0BAA0B,YAAY,GAAG;;CAE5E,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { n as __require, r as __toESM, t as __commonJSMin } from "./chunk-BbwQpWto.mjs";
|
|
3
|
-
import { m as require_dist } from "./context-detection-
|
|
3
|
+
import { m as require_dist } from "./context-detection-Ddu0mj_K.mjs";
|
|
4
4
|
import { i as AI_TOOL_PATHS, r as evaluateDetection } from "./ai-tool-detection-CMsBNa9e.mjs";
|
|
5
5
|
import { d as esm_default, m as simpleGit } from "./esm-BagM-kVd.mjs";
|
|
6
6
|
import { access, mkdir, readFile, readdir, rm, rmdir, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
@@ -4885,11 +4885,20 @@ async function cloneGitSource(options) {
|
|
|
4885
4885
|
const git = esm_default();
|
|
4886
4886
|
try {
|
|
4887
4887
|
const cloneOptions = ["--depth=1"];
|
|
4888
|
-
|
|
4888
|
+
const isSha = ref && /^[0-9a-f]{7,40}$/i.test(ref);
|
|
4889
|
+
if (ref && !isSha && ref !== "main" && ref !== "master") cloneOptions.push("--branch", ref);
|
|
4889
4890
|
if (subpath) cloneOptions.push("--no-checkout");
|
|
4890
4891
|
await git.clone(url, cachePath, cloneOptions);
|
|
4892
|
+
const repoGit = esm_default(cachePath);
|
|
4893
|
+
if (isSha) {
|
|
4894
|
+
await repoGit.fetch([
|
|
4895
|
+
"--depth=1",
|
|
4896
|
+
"origin",
|
|
4897
|
+
ref
|
|
4898
|
+
]);
|
|
4899
|
+
await repoGit.checkout("FETCH_HEAD");
|
|
4900
|
+
}
|
|
4891
4901
|
if (subpath) {
|
|
4892
|
-
const repoGit = esm_default(cachePath);
|
|
4893
4902
|
await repoGit.raw([
|
|
4894
4903
|
"sparse-checkout",
|
|
4895
4904
|
"init",
|
|
@@ -4900,9 +4909,9 @@ async function cloneGitSource(options) {
|
|
|
4900
4909
|
"set",
|
|
4901
4910
|
subpath
|
|
4902
4911
|
]);
|
|
4903
|
-
await repoGit.checkout(ref || "HEAD");
|
|
4904
|
-
} else if (ref && ref !== "main" && ref !== "master") await
|
|
4905
|
-
const sha = await
|
|
4912
|
+
if (!isSha) await repoGit.checkout(ref || "HEAD");
|
|
4913
|
+
} else if (ref && !isSha && ref !== "main" && ref !== "master") await repoGit.checkout(ref);
|
|
4914
|
+
const sha = await repoGit.revparse(["HEAD"]);
|
|
4906
4915
|
return {
|
|
4907
4916
|
localPath: subpath ? join(cachePath, subpath) : cachePath,
|
|
4908
4917
|
fromCache: false,
|
|
@@ -14879,4 +14888,4 @@ async function resolvePreferences(projectRoot) {
|
|
|
14879
14888
|
|
|
14880
14889
|
//#endregion
|
|
14881
14890
|
export { loadLockfile as $, resolveProfileChain as A, cloneGitSource as B, mergeSkills as C, sortProfilesByWeight as D, isLockedProfile as E, removePlacedFiles as F, getIdePlatformTargetDir as G, ensureBatonDirGitignored as H, generateLock as I, isKnownIdePlatform as J, getRegisteredIdePlatforms as K, readLock as L, placeFile as M, discoverProfilesInSourceRepo as N, mergeContentParts as O, findSourceManifest as P, parseSource as Q, writeLock as R, mergeRulesWithWarnings as S, getProfileWeight as T, removeGitignoreManagedSection as U, collectComprehensivePatterns as V, updateGitignore as W, getAllAIToolAdapters as X, getAIToolAdaptersForKeys as Y, parseFrontmatter as Z, require_lib as _, clearIdeCache as a, getAIToolConfig as at, mergeAgentsWithWarnings as b, getDefaultGlobalSource as c, getGlobalSources as d, loadProfileManifest as et, loadGlobalConfig as f, setGlobalIdePlatforms as g, setGlobalAiTools as h, computeIntersection as i, SourceParseError as it, detectLegacyPaths as j, resolveProfileSupport as k, getGlobalAiTools as l, saveGlobalConfig as m, readProjectPreferences as n, KEBAB_CASE_REGEX as nt, detectInstalledIdes as o, getAIToolPath as ot, removeGlobalSource as p, idePlatformRegistry as q, writeProjectPreferences as r, FileNotFoundError as rt, addGlobalSource as s, getAllAIToolKeys as st, resolvePreferences as t, loadProjectManifest as tt, getGlobalIdePlatforms as u, mergeMemory as v, mergeSkillsWithWarnings as w, mergeRules as x, mergeMemoryWithWarnings as y, resolveVersion as z };
|
|
14882
|
-
//# sourceMappingURL=src-
|
|
14891
|
+
//# sourceMappingURL=src-dY02psbw.mjs.map
|