@karmaniverous/stan-cli 0.11.4 → 0.11.6
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/cjs/index.js +1 -1
- package/dist/cli/stan.js +43 -16
- package/dist/mjs/index.js +1 -1
- package/package.json +1 -1
package/dist/cli/stan.js
CHANGED
|
@@ -18135,6 +18135,7 @@ const writeConfigToDisk = async (args) => {
|
|
|
18135
18135
|
// src/runner/init/service/service.main.ts
|
|
18136
18136
|
const performInitService = async ({ cwd = process.cwd(), force = false, preserveScripts = false, dryRun = false, }) => {
|
|
18137
18137
|
const existingPath = ke(cwd);
|
|
18138
|
+
const hasExisting = Boolean(existingPath);
|
|
18138
18139
|
const defaultStanPath = '.stan';
|
|
18139
18140
|
// Load existing config (raw) preserving key order; fallback to empty object.
|
|
18140
18141
|
let base = await readExistingConfig(existingPath);
|
|
@@ -18144,6 +18145,7 @@ const performInitService = async ({ cwd = process.cwd(), force = false, preserve
|
|
|
18144
18145
|
force: force || dryRun,
|
|
18145
18146
|
});
|
|
18146
18147
|
const namespaced = isObj$2(base['stan-core']) || isObj$2(base['stan-cli']);
|
|
18148
|
+
const namespacedTarget = namespaced || !hasExisting;
|
|
18147
18149
|
// UI seeds (best-effort) for interactive mode
|
|
18148
18150
|
const uiSeeds = await deriveUiSeeds(cwd, base, defaultStanPath);
|
|
18149
18151
|
// Idempotency guard: under --force with an existing, already namespaced config,
|
|
@@ -18166,7 +18168,7 @@ const performInitService = async ({ cwd = process.cwd(), force = false, preserve
|
|
|
18166
18168
|
await applyInteractiveChoices({
|
|
18167
18169
|
cwd,
|
|
18168
18170
|
base,
|
|
18169
|
-
namespaced,
|
|
18171
|
+
namespaced: namespacedTarget,
|
|
18170
18172
|
uiSeeds: {
|
|
18171
18173
|
stanPath: uiSeeds.stanPath,
|
|
18172
18174
|
includes: uiSeeds.includes,
|
|
@@ -18180,7 +18182,7 @@ const performInitService = async ({ cwd = process.cwd(), force = false, preserve
|
|
|
18180
18182
|
const poc = cliCfg?.patchOpenCommand && typeof cliCfg.patchOpenCommand === 'string'
|
|
18181
18183
|
? cliCfg.patchOpenCommand
|
|
18182
18184
|
: 'code -g {file}';
|
|
18183
|
-
if (
|
|
18185
|
+
if (namespacedTarget) {
|
|
18184
18186
|
const cli = ensureNsNode(base, 'stan-cli');
|
|
18185
18187
|
if (!hasOwn$2(cli, 'patchOpenCommand'))
|
|
18186
18188
|
cli.patchOpenCommand = poc;
|
|
@@ -18201,15 +18203,20 @@ const performInitService = async ({ cwd = process.cwd(), force = false, preserve
|
|
|
18201
18203
|
cliCfg = undefined;
|
|
18202
18204
|
}
|
|
18203
18205
|
if (!existingPath) {
|
|
18206
|
+
// First-time creation: seed a namespaced config immediately.
|
|
18204
18207
|
base = {
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18208
|
+
'stan-core': {
|
|
18209
|
+
stanPath: defaultStanPath,
|
|
18210
|
+
includes: [],
|
|
18211
|
+
excludes: [],
|
|
18212
|
+
},
|
|
18213
|
+
'stan-cli': {
|
|
18214
|
+
// Narrow safely instead of relying on a cast + “?? {}”.
|
|
18215
|
+
scripts: cliCfg && typeof cliCfg.scripts === 'object'
|
|
18216
|
+
? cliCfg.scripts
|
|
18217
|
+
: {},
|
|
18218
|
+
patchOpenCommand: cliCfg?.patchOpenCommand ?? 'code -g {file}',
|
|
18219
|
+
},
|
|
18213
18220
|
};
|
|
18214
18221
|
}
|
|
18215
18222
|
else if (!namespaced) {
|
|
@@ -28946,17 +28953,37 @@ const stanDirs = (cwd, stanPath) => {
|
|
|
28946
28953
|
|
|
28947
28954
|
// src/stan/run/archive/util.ts
|
|
28948
28955
|
/**
|
|
28949
|
-
* Stage imports
|
|
28950
|
-
*
|
|
28956
|
+
* Stage imports under <stanPath>/imports so both full and diff archives see the same
|
|
28957
|
+
* staged context.
|
|
28958
|
+
*
|
|
28959
|
+
* Behavior:
|
|
28960
|
+
* - Always clear the entire <stanPath>/imports directory first (best‑effort).
|
|
28961
|
+
* - Then, if a map is provided, call core.prepareImports to stage the current labels.
|
|
28962
|
+
*
|
|
28963
|
+
* Notes:
|
|
28964
|
+
* - Core's prepareImports also clears each label directory; we keep that as a
|
|
28965
|
+
* belt‑and‑suspenders for non‑CLI callers while the CLI clears the root up front
|
|
28966
|
+
* to remove labels that were dropped from config.
|
|
28967
|
+
* - All operations are best‑effort and swallow errors to avoid impacting the run.
|
|
28951
28968
|
*/
|
|
28952
28969
|
const stageImports = async (cwd, stanPath, imports) => {
|
|
28953
|
-
|
|
28954
|
-
|
|
28970
|
+
// 1) Clear the entire imports root first (best‑effort).
|
|
28971
|
+
const importsAbs = path.join(cwd, stanPath, 'imports');
|
|
28955
28972
|
try {
|
|
28956
|
-
await
|
|
28973
|
+
const entries = await readdir(importsAbs, { withFileTypes: true });
|
|
28974
|
+
await Promise.all(entries.map((e) => rm(resolve(importsAbs, e.name), { recursive: true, force: true })));
|
|
28957
28975
|
}
|
|
28958
28976
|
catch {
|
|
28959
|
-
// best‑effort;
|
|
28977
|
+
// best‑effort; root may not exist yet.
|
|
28978
|
+
}
|
|
28979
|
+
// 2) Stage current map (if any).
|
|
28980
|
+
if (imports && typeof imports === 'object') {
|
|
28981
|
+
try {
|
|
28982
|
+
await yh({ cwd, stanPath, map: imports });
|
|
28983
|
+
}
|
|
28984
|
+
catch {
|
|
28985
|
+
// best‑effort; continue without imports
|
|
28986
|
+
}
|
|
28960
28987
|
}
|
|
28961
28988
|
};
|
|
28962
28989
|
/**
|