@ariestools/toolchain 8.7.28 → 9.0.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/README.md +27 -0
- package/dist/actions/analyze.d.ts.map +1 -1
- package/dist/actions/api-exposure/apiExposure.d.ts.map +1 -1
- package/dist/actions/build.d.ts.map +1 -1
- package/dist/actions/clean.d.ts.map +1 -1
- package/dist/actions/compile.d.ts +9 -3
- package/dist/actions/compile.d.ts.map +1 -1
- package/dist/actions/copy-assets.d.ts.map +1 -1
- package/dist/actions/dead/dead.d.ts.map +1 -1
- package/dist/actions/deplint/deplint.d.ts.map +1 -1
- package/dist/actions/deplint/deplintPick.d.ts.map +1 -1
- package/dist/actions/deplint/editXyConfigPackages.d.ts +1 -1
- package/dist/actions/deplint/editXyConfigPackages.d.ts.map +1 -1
- package/dist/actions/deplint/implicitDevDependencies.d.ts.map +1 -1
- package/dist/actions/deplint/packageEditor.d.ts.map +1 -1
- package/dist/actions/fix.d.ts.map +1 -1
- package/dist/actions/license.d.ts.map +1 -1
- package/dist/actions/lint-config.d.ts +1 -1
- package/dist/actions/lint-config.d.ts.map +1 -1
- package/dist/actions/lint.d.ts.map +1 -1
- package/dist/actions/lintNextWorker.d.ts.map +1 -1
- package/dist/actions/npmignore-gen.d.ts.map +1 -1
- package/dist/actions/package/clean-outputs.d.ts.map +1 -1
- package/dist/actions/package/clean-typescript.d.ts.map +1 -1
- package/dist/actions/package/clean.d.ts.map +1 -1
- package/dist/actions/package/cleanPlan.d.ts +1 -1
- package/dist/actions/package/cleanPlan.d.ts.map +1 -1
- package/dist/actions/package/cleanRules.d.ts +6 -6
- package/dist/actions/package/cleanRules.d.ts.map +1 -1
- package/dist/actions/package/compile/XyConfig.d.ts +21 -0
- package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/buildEntries.d.ts.map +1 -1
- package/dist/actions/package/compile/compile.d.ts.map +1 -1
- package/dist/actions/package/compile/createTypescriptConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/entryOutputName.d.ts +1 -1
- package/dist/actions/package/compile/entryOutputName.d.ts.map +1 -1
- package/dist/actions/package/compile/getCompilerOptions.d.ts.map +1 -1
- package/dist/actions/package/compile/inputs.d.ts.map +1 -1
- package/dist/actions/package/compile/monolithCompileLayout.d.ts +1 -1
- package/dist/actions/package/compile/monolithCompileLayout.d.ts.map +1 -1
- package/dist/actions/package/compile/packageCompileEsbuild.d.ts +2 -2
- package/dist/actions/package/compile/packageCompileEsbuild.d.ts.map +1 -1
- package/dist/actions/package/compile/packageCompileMonolith.d.ts.map +1 -1
- package/dist/actions/package/compile/packageCompileTsc.d.ts +1 -1
- package/dist/actions/package/compile/packageCompileTsc.d.ts.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.d.ts.map +1 -1
- package/dist/actions/package/compile/packageCompileVendor.d.ts.map +1 -1
- package/dist/actions/package/compile/resolveCompilePlatforms.d.ts.map +1 -1
- package/dist/actions/package/compile/resolvePlatformTypes.d.ts.map +1 -1
- package/dist/actions/package/compile/resolveTscBin.d.ts +46 -0
- package/dist/actions/package/compile/resolveTscBin.d.ts.map +1 -0
- package/dist/actions/package/compile/runTsc.d.ts +14 -1
- package/dist/actions/package/compile/runTsc.d.ts.map +1 -1
- package/dist/actions/package/compile/validateFullPackage.d.ts +2 -1
- package/dist/actions/package/compile/validateFullPackage.d.ts.map +1 -1
- package/dist/actions/package/compile/vendorCompileInternals.d.ts.map +1 -1
- package/dist/actions/package/compile/vendorCompileTypes.d.ts +1 -1
- package/dist/actions/package/compile/vendorCompileTypes.d.ts.map +1 -1
- package/dist/actions/package/copy-assets.d.ts.map +1 -1
- package/dist/actions/package/lint.d.ts.map +1 -1
- package/dist/actions/package/publint.d.ts.map +1 -1
- package/dist/actions/package/recompile.d.ts.map +1 -1
- package/dist/actions/publint.d.ts.map +1 -1
- package/dist/actions/publish.d.ts.map +1 -1
- package/dist/actions/rebuild.d.ts.map +1 -1
- package/dist/actions/recompile.d.ts.map +1 -1
- package/dist/actions/reinstall.d.ts.map +1 -1
- package/dist/actions/releaseAgeExcludeScopes.d.ts +1 -1
- package/dist/actions/releaseAgeExcludeScopes.d.ts.map +1 -1
- package/dist/actions/relint.d.ts.map +1 -1
- package/dist/actions/repo-init/index.d.ts +7 -0
- package/dist/actions/repo-init/index.d.ts.map +1 -0
- package/dist/actions/repo-init/prompts.d.ts +4 -0
- package/dist/actions/repo-init/prompts.d.ts.map +1 -0
- package/dist/actions/repo-init/resolvePlan.d.ts +7 -0
- package/dist/actions/repo-init/resolvePlan.d.ts.map +1 -0
- package/dist/actions/repo-init/scaffold.d.ts +10 -0
- package/dist/actions/repo-init/scaffold.d.ts.map +1 -0
- package/dist/actions/repo-init/skillsInstall.d.ts +12 -0
- package/dist/actions/repo-init/skillsInstall.d.ts.map +1 -0
- package/dist/actions/repo-init/templateVars.d.ts +5 -0
- package/dist/actions/repo-init/templateVars.d.ts.map +1 -0
- package/dist/actions/repo-init/types.d.ts +40 -0
- package/dist/actions/repo-init/types.d.ts.map +1 -0
- package/dist/actions/repo-init.d.ts +1 -13
- package/dist/actions/repo-init.d.ts.map +1 -1
- package/dist/actions/republint.d.ts.map +1 -1
- package/dist/actions/retest.d.ts.map +1 -1
- package/dist/actions/secure.d.ts.map +1 -1
- package/dist/actions/skills/defaults.d.ts +2 -2
- package/dist/actions/skills/defaults.d.ts.map +1 -1
- package/dist/actions/skills/detectProfile.d.ts.map +1 -1
- package/dist/actions/skills/installed.d.ts +1 -1
- package/dist/actions/skills/installed.d.ts.map +1 -1
- package/dist/actions/skills/lint.d.ts.map +1 -1
- package/dist/actions/skills/passthrough.d.ts +4 -0
- package/dist/actions/skills/passthrough.d.ts.map +1 -1
- package/dist/actions/skills/skillRules.d.ts.map +1 -1
- package/dist/actions/skills/updo.d.ts.map +1 -1
- package/dist/actions/skills/versions.d.ts.map +1 -1
- package/dist/actions/test.d.ts.map +1 -1
- package/dist/actions/tsc-validate/tscValidate.d.ts.map +1 -1
- package/dist/actions/updo.d.ts.map +1 -1
- package/dist/actions/work/github.d.ts +2 -2
- package/dist/actions/work/github.d.ts.map +1 -1
- package/dist/actions/work/helpers.d.ts +1 -1
- package/dist/actions/work/helpers.d.ts.map +1 -1
- package/dist/actions/work/id.d.ts.map +1 -1
- package/dist/actions/work/index.d.ts.map +1 -1
- package/dist/actions/work/inline.d.ts.map +1 -1
- package/dist/actions/work/lifecycle.d.ts.map +1 -1
- package/dist/actions/work/lint.d.ts.map +1 -1
- package/dist/actions/work/list.d.ts.map +1 -1
- package/dist/actions/work/move.d.ts.map +1 -1
- package/dist/actions/work/priority.d.ts.map +1 -1
- package/dist/actions/work/queue.d.ts.map +1 -1
- package/dist/actions/work/render.d.ts.map +1 -1
- package/dist/actions/work/result.d.ts.map +1 -1
- package/dist/actions/work/schema.d.ts +3 -3
- package/dist/actions/work/schema.d.ts.map +1 -1
- package/dist/actions/work/store.d.ts.map +1 -1
- package/dist/actions/work/sync.d.ts.map +1 -1
- package/dist/actions/work/workspace.d.ts +1 -1
- package/dist/actions/work/workspace.d.ts.map +1 -1
- package/dist/bin/package/build.mjs +113 -19
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +113 -19
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +113 -19
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/xy.mjs +876 -357
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/lib/aliasSpec.d.ts +28 -0
- package/dist/lib/aliasSpec.d.ts.map +1 -0
- package/dist/lib/checkResult.d.ts +1 -1
- package/dist/lib/checkResult.d.ts.map +1 -1
- package/dist/lib/createBuildConfig.d.ts +1 -1
- package/dist/lib/createBuildConfig.d.ts.map +1 -1
- package/dist/lib/defaultBuildConfig.d.ts.map +1 -1
- package/dist/lib/deleteGlob.d.ts.map +1 -1
- package/dist/lib/dependencies/DuplicateDetector.d.ts.map +1 -1
- package/dist/lib/dependencies/detectDuplicateDependencies.d.ts.map +1 -1
- package/dist/lib/file/fileLines.d.ts.map +1 -1
- package/dist/lib/file/tryReadFileSync.d.ts.map +1 -1
- package/dist/lib/generateIgnoreFiles.d.ts.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/jsonFormatters.d.ts.map +1 -1
- package/dist/lib/latestVersions.d.ts +5 -5
- package/dist/lib/latestVersions.d.ts.map +1 -1
- package/dist/lib/loadConfig.d.ts.map +1 -1
- package/dist/lib/parsedPackageJson.d.ts.map +1 -1
- package/dist/lib/processEx.d.ts.map +1 -1
- package/dist/lib/ruleCommandRegistry.d.ts +44 -44
- package/dist/lib/ruleCommandRegistry.d.ts.map +1 -1
- package/dist/lib/runSteps.d.ts.map +1 -1
- package/dist/lib/runStepsAsync.d.ts.map +1 -1
- package/dist/lib/runXy.d.ts.map +1 -1
- package/dist/lib/runXyWithWarning.d.ts.map +1 -1
- package/dist/lib/safeExit.d.ts.map +1 -1
- package/dist/lib/string/empty.d.ts.map +1 -1
- package/dist/lib/string/union.d.ts.map +1 -1
- package/dist/lib/updo/collectWorkspaceDeps.d.ts.map +1 -1
- package/dist/lib/updo/index.d.ts +1 -0
- package/dist/lib/updo/index.d.ts.map +1 -1
- package/dist/lib/updo/interactiveSelect.d.ts.map +1 -1
- package/dist/lib/updo/interfaces.d.ts +20 -0
- package/dist/lib/updo/interfaces.d.ts.map +1 -1
- package/dist/lib/updo/majorCeiling.d.ts +21 -0
- package/dist/lib/updo/majorCeiling.d.ts.map +1 -0
- package/dist/lib/updo/resolveVersions.d.ts.map +1 -1
- package/dist/lib/updo/runUpdo.d.ts.map +1 -1
- package/dist/lib/withErrnoException.d.ts.map +1 -1
- package/dist/lib/withError.d.ts.map +1 -1
- package/dist/lib/yarn/isYarnVersionOrGreater.d.ts.map +1 -1
- package/dist/lib/yarn/workspace/yarnWorkspace.d.ts.map +1 -1
- package/dist/pm/bunPackageManager.d.ts +1 -1
- package/dist/pm/bunPackageManager.d.ts.map +1 -1
- package/dist/pm/npmPackageManager.d.ts +1 -1
- package/dist/pm/npmPackageManager.d.ts.map +1 -1
- package/dist/pm/pnpmPackageManager.d.ts +1 -1
- package/dist/pm/pnpmPackageManager.d.ts.map +1 -1
- package/dist/pm/yarnPackageManager.d.ts +1 -1
- package/dist/pm/yarnPackageManager.d.ts.map +1 -1
- package/dist/xy/build/index.d.ts.map +1 -1
- package/dist/xy/common/index.d.ts.map +1 -1
- package/dist/xy/common/repo/initCommand.d.ts.map +1 -1
- package/dist/xy/common/work/options.d.ts.map +1 -1
- package/dist/xy/deploy/index.d.ts.map +1 -1
- package/dist/xy/install/index.d.ts.map +1 -1
- package/dist/xy/lint/index.d.ts.map +1 -1
- package/dist/xy/param.d.ts.map +1 -1
- package/dist/xy/react/index.d.ts.map +1 -1
- package/dist/xy/xy.d.ts +2 -2
- package/dist/xy/xy.d.ts.map +1 -1
- package/package.json +9 -8
- package/templates/repo/cli/package/package.json.tmpl +5 -5
- package/templates/repo/cli/package/tsconfig.json.tmpl +4 -0
- package/templates/repo/cli/root/AGENTS.md.tmpl +34 -0
- package/templates/repo/cli/root/CLAUDE.md.tmpl +15 -15
- package/templates/repo/cli/root/eslint.config.ts.tmpl +16 -0
- package/templates/repo/cli/root/gitignore.tmpl +6 -9
- package/templates/repo/cli/root/package.json.tmpl +16 -14
- package/templates/repo/cli/root/tsconfig.json.tmpl +4 -0
- package/templates/repo/cli/root/{vitest.config.ts → vitest.config.ts.tmpl} +2 -2
- package/templates/repo/cli/package/tsconfig.json +0 -4
- package/templates/repo/cli/root/eslint.config.ts +0 -20
- package/templates/repo/cli/root/tsconfig.json +0 -4
package/dist/bin/xy.mjs
CHANGED
|
@@ -71,6 +71,40 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
71
71
|
}) : target, mod));
|
|
72
72
|
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
73
73
|
//#endregion
|
|
74
|
+
//#region src/lib/aliasSpec.ts
|
|
75
|
+
const ALIAS_PREFIX = "npm:";
|
|
76
|
+
/**
|
|
77
|
+
* Splits an `npm:` alias spec into the registry name and the semver range it
|
|
78
|
+
* carries: `npm:typescript@~7.0.2` → `{ registryName: 'typescript', range: '~7.0.2' }`.
|
|
79
|
+
*
|
|
80
|
+
* Aliases exist so two releases of one package can be installed side by side —
|
|
81
|
+
* `typescript` (the compiler API) alongside `npm:typescript@7` (the native
|
|
82
|
+
* compiler). Without this, the declaration key is the only name updo sees, and
|
|
83
|
+
* a key like `typescript-native` is not a real package: the registry lookup
|
|
84
|
+
* 404s and the dependency is silently never updated.
|
|
85
|
+
*
|
|
86
|
+
* Returns undefined for non-alias specs and for alias specs carrying no range
|
|
87
|
+
* (`npm:typescript`), which express no version intent to move.
|
|
88
|
+
*/
|
|
89
|
+
function parseAliasSpec(spec) {
|
|
90
|
+
if (!spec.startsWith(ALIAS_PREFIX)) return void 0;
|
|
91
|
+
const target = spec.slice(4);
|
|
92
|
+
const separator = target.indexOf("@", 1);
|
|
93
|
+
if (separator <= 0 || separator === target.length - 1) return void 0;
|
|
94
|
+
return {
|
|
95
|
+
range: target.slice(separator + 1),
|
|
96
|
+
registryName: target.slice(0, separator)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Re-wraps a resolved range in its `npm:` alias spec, so an update to an
|
|
101
|
+
* aliased declaration is written back in the form the package manager expects.
|
|
102
|
+
* Non-aliased declarations pass through untouched.
|
|
103
|
+
*/
|
|
104
|
+
function formatDeclaredRange(dep, range) {
|
|
105
|
+
return dep.registryName === dep.name ? range : `${ALIAS_PREFIX}${dep.registryName}@${range}`;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
74
108
|
//#region src/lib/bundledCliPath.ts
|
|
75
109
|
const require$8 = createRequire(import.meta.url);
|
|
76
110
|
function toolchainPackageRoot() {
|
|
@@ -19106,6 +19140,9 @@ function collectFiles$1(dir, prefix) {
|
|
|
19106
19140
|
function loadRepoTemplateFiles(template, section) {
|
|
19107
19141
|
return collectFiles$1(PATH.resolve(repoTemplatesDir, template, section), "");
|
|
19108
19142
|
}
|
|
19143
|
+
function listRepoTemplates() {
|
|
19144
|
+
return readdirSync(repoTemplatesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
19145
|
+
}
|
|
19109
19146
|
//#endregion
|
|
19110
19147
|
//#region src/lib/runSteps.ts
|
|
19111
19148
|
const packageManagers$1 = /* @__PURE__ */ new Set([
|
|
@@ -19727,10 +19764,12 @@ function collectExternalWorkspaceDeps(deps, depField, ws, workspaceNames, declar
|
|
|
19727
19764
|
for (const [name, range] of Object.entries(deps)) {
|
|
19728
19765
|
if (workspaceNames.has(name)) continue;
|
|
19729
19766
|
if (range.startsWith("workspace:")) continue;
|
|
19767
|
+
const alias = parseAliasSpec(range);
|
|
19730
19768
|
declaredDeps.push({
|
|
19731
19769
|
depType: depField,
|
|
19732
19770
|
name,
|
|
19733
|
-
range,
|
|
19771
|
+
range: alias?.range ?? range,
|
|
19772
|
+
registryName: alias?.registryName ?? name,
|
|
19734
19773
|
workspaceLocation: ws.location,
|
|
19735
19774
|
workspaceName: ws.name
|
|
19736
19775
|
});
|
|
@@ -20077,13 +20116,13 @@ async function fetchAllRegistryInfo(packageNames, options = {}) {
|
|
|
20077
20116
|
return await fetchAllRegistryInfoDirect(packageNames, options);
|
|
20078
20117
|
}
|
|
20079
20118
|
//#endregion
|
|
20080
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20119
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/key.js
|
|
20081
20120
|
const isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
|
|
20082
20121
|
const isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
|
|
20083
20122
|
const isSpaceKey = (key) => key.name === "space";
|
|
20084
20123
|
const isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
20085
20124
|
//#endregion
|
|
20086
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20125
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/errors.js
|
|
20087
20126
|
var AbortPromptError = class extends Error {
|
|
20088
20127
|
name = "AbortPromptError";
|
|
20089
20128
|
message = "Prompt was aborted";
|
|
@@ -20106,7 +20145,7 @@ var ValidationError = class extends Error {
|
|
|
20106
20145
|
name = "ValidationError";
|
|
20107
20146
|
};
|
|
20108
20147
|
//#endregion
|
|
20109
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20148
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
20110
20149
|
const hookStorage = new AsyncLocalStorage();
|
|
20111
20150
|
function createStore(rl) {
|
|
20112
20151
|
return {
|
|
@@ -20202,7 +20241,7 @@ const effectScheduler = {
|
|
|
20202
20241
|
}
|
|
20203
20242
|
};
|
|
20204
20243
|
//#endregion
|
|
20205
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20244
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
20206
20245
|
function isFactory(value) {
|
|
20207
20246
|
return typeof value === "function";
|
|
20208
20247
|
}
|
|
@@ -20221,7 +20260,7 @@ function useState(defaultValue) {
|
|
|
20221
20260
|
});
|
|
20222
20261
|
}
|
|
20223
20262
|
//#endregion
|
|
20224
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20263
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
20225
20264
|
function useEffect(cb, depArray) {
|
|
20226
20265
|
withPointer((pointer) => {
|
|
20227
20266
|
const oldDeps = pointer.get();
|
|
@@ -20230,12 +20269,12 @@ function useEffect(cb, depArray) {
|
|
|
20230
20269
|
});
|
|
20231
20270
|
}
|
|
20232
20271
|
//#endregion
|
|
20233
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20272
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
20234
20273
|
function useRef(val) {
|
|
20235
20274
|
return useState({ current: val })[0];
|
|
20236
20275
|
}
|
|
20237
20276
|
//#endregion
|
|
20238
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20277
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
20239
20278
|
function useKeypress(userHandler) {
|
|
20240
20279
|
const signal = useRef(userHandler);
|
|
20241
20280
|
signal.current = userHandler;
|
|
@@ -20563,7 +20602,7 @@ function wrapAnsi$1(string, columns, options) {
|
|
|
20563
20602
|
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec$1(line, columns, options)).join("\n");
|
|
20564
20603
|
}
|
|
20565
20604
|
//#endregion
|
|
20566
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20605
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
20567
20606
|
var import_cli_width = /* @__PURE__ */ __toESM(require_cli_width(), 1);
|
|
20568
20607
|
/**
|
|
20569
20608
|
* Force line returns at specific width. This function is ANSI code friendly and it'll
|
|
@@ -20903,7 +20942,7 @@ const eraseLine = "\x1B[2K";
|
|
|
20903
20942
|
/** Erase the specified number of lines above the cursor */
|
|
20904
20943
|
const eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + "\x1B[2K\x1B[G" : "";
|
|
20905
20944
|
//#endregion
|
|
20906
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
20945
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
20907
20946
|
const height = (content) => content.split("\n").length;
|
|
20908
20947
|
const lastLine = (content) => content.split("\n").pop() ?? "";
|
|
20909
20948
|
var ScreenManager = class {
|
|
@@ -20960,7 +20999,7 @@ var ScreenManager = class {
|
|
|
20960
20999
|
}
|
|
20961
21000
|
};
|
|
20962
21001
|
//#endregion
|
|
20963
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
21002
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
20964
21003
|
var PromisePolyfill = class extends Promise {
|
|
20965
21004
|
static withResolver() {
|
|
20966
21005
|
let resolve;
|
|
@@ -20976,7 +21015,7 @@ var PromisePolyfill = class extends Promise {
|
|
|
20976
21015
|
}
|
|
20977
21016
|
};
|
|
20978
21017
|
//#endregion
|
|
20979
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
21018
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
20980
21019
|
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
20981
21020
|
const nativeSetImmediate = globalThis.setImmediate;
|
|
20982
21021
|
function getCallSites() {
|
|
@@ -21281,7 +21320,7 @@ const updoPrompt = createPrompt((config, done) => {
|
|
|
21281
21320
|
const version = getTargetVersion(dep, selectionsRef.current[i]);
|
|
21282
21321
|
if (version != null && version.length > 0) results.push({
|
|
21283
21322
|
name: dep.name,
|
|
21284
|
-
targetRange: version,
|
|
21323
|
+
targetRange: formatDeclaredRange(dep, version),
|
|
21285
21324
|
workspaces: dep.workspaces
|
|
21286
21325
|
});
|
|
21287
21326
|
}
|
|
@@ -21328,6 +21367,36 @@ async function interactiveSelect(deps, options = {}) {
|
|
|
21328
21367
|
}
|
|
21329
21368
|
}
|
|
21330
21369
|
//#endregion
|
|
21370
|
+
//#region src/lib/updo/majorCeiling.ts
|
|
21371
|
+
/**
|
|
21372
|
+
* Packages whose next major is not the same thing further along, but a
|
|
21373
|
+
* different distribution published under the same name. updo will not offer a
|
|
21374
|
+
* bump across the ceiling — not even under `--latest`, whose whole job is to
|
|
21375
|
+
* pick the highest available bump.
|
|
21376
|
+
*
|
|
21377
|
+
* A declaration already anchored above the ceiling is left alone: that is the
|
|
21378
|
+
* deliberate side-by-side install (`"typescript-native": "npm:typescript@7"`),
|
|
21379
|
+
* which should keep receiving updates like anything else.
|
|
21380
|
+
*/
|
|
21381
|
+
const MAJOR_CEILINGS = /* @__PURE__ */ new Map([["typescript", {
|
|
21382
|
+
maxMajor: 6,
|
|
21383
|
+
reason: [
|
|
21384
|
+
"typescript@7 is the native compiler and exports no compiler API —",
|
|
21385
|
+
"ESLint, deplint, dead-code and api-exposure all load it from `typescript`.",
|
|
21386
|
+
"Install it side by side instead: `\"typescript-native\": \"npm:typescript@7\"`",
|
|
21387
|
+
"with `compile.compiler: \"native\"`."
|
|
21388
|
+
].join(" ")
|
|
21389
|
+
}]]);
|
|
21390
|
+
/**
|
|
21391
|
+
* The ceiling in force for a declaration, or undefined when none applies —
|
|
21392
|
+
* including when the declaration is already above its ceiling.
|
|
21393
|
+
*/
|
|
21394
|
+
function majorCeilingFor(registryName, anchorMajor) {
|
|
21395
|
+
const ceiling = MAJOR_CEILINGS.get(registryName);
|
|
21396
|
+
if (ceiling === void 0) return void 0;
|
|
21397
|
+
return anchorMajor <= ceiling.maxMajor ? ceiling : void 0;
|
|
21398
|
+
}
|
|
21399
|
+
//#endregion
|
|
21331
21400
|
//#region src/lib/updo/resolveVersions.ts
|
|
21332
21401
|
function parseExclude(pattern) {
|
|
21333
21402
|
const sep = pattern.indexOf("@", 1);
|
|
@@ -21442,7 +21511,7 @@ function differentFromCurrent(value, current) {
|
|
|
21442
21511
|
if (value == null || value.length === 0) return void 0;
|
|
21443
21512
|
return value === current ? void 0 : value;
|
|
21444
21513
|
}
|
|
21445
|
-
function unresolvedDep(name, current, declaredRanges, preferredRangePrefix, workspaces) {
|
|
21514
|
+
function unresolvedDep(name, registryName, current, declaredRanges, preferredRangePrefix, workspaces) {
|
|
21446
21515
|
return {
|
|
21447
21516
|
current,
|
|
21448
21517
|
declaredRanges,
|
|
@@ -21453,10 +21522,23 @@ function unresolvedDep(name, current, declaredRanges, preferredRangePrefix, work
|
|
|
21453
21522
|
next: void 0,
|
|
21454
21523
|
patch: void 0,
|
|
21455
21524
|
preferredRangePrefix,
|
|
21525
|
+
registryName,
|
|
21456
21526
|
updateAvailable: false,
|
|
21457
21527
|
workspaces
|
|
21458
21528
|
};
|
|
21459
21529
|
}
|
|
21530
|
+
function majorOf(version) {
|
|
21531
|
+
return import_semver.default.parse(version)?.major;
|
|
21532
|
+
}
|
|
21533
|
+
function underCeiling(version, ceiling) {
|
|
21534
|
+
const major = majorOf(version);
|
|
21535
|
+
return major === void 0 || major <= ceiling.maxMajor;
|
|
21536
|
+
}
|
|
21537
|
+
function ceilingFilteredDistTags(distTags, ceiling) {
|
|
21538
|
+
const filtered = {};
|
|
21539
|
+
for (const [tag, version] of Object.entries(distTags)) if (underCeiling(version, ceiling)) filtered[tag] = version;
|
|
21540
|
+
return filtered;
|
|
21541
|
+
}
|
|
21460
21542
|
function normalizedMixedPatch(patch, declaredRanges, preferredRangePrefix, anchor) {
|
|
21461
21543
|
if (patch != null && patch.length > 0 || declaredRanges.length <= 1) return patch;
|
|
21462
21544
|
if (!declaredRanges.every((range) => {
|
|
@@ -21466,6 +21548,25 @@ function normalizedMixedPatch(patch, declaredRanges, preferredRangePrefix, ancho
|
|
|
21466
21548
|
const normalized = `${preferredRangePrefix}${anchor.version}`;
|
|
21467
21549
|
return declaredRanges.some((r) => r !== normalized) ? normalized : patch;
|
|
21468
21550
|
}
|
|
21551
|
+
/**
|
|
21552
|
+
* Removes candidate versions above the package's major ceiling, and reports
|
|
21553
|
+
* when doing so hid a major bump that would otherwise have been offered.
|
|
21554
|
+
*/
|
|
21555
|
+
function applyMajorCeiling(registryName, stable, distTags, anchor) {
|
|
21556
|
+
const ceiling = majorCeilingFor(registryName, anchor.major);
|
|
21557
|
+
if (ceiling === void 0) return {
|
|
21558
|
+
distTags,
|
|
21559
|
+
eligible: stable,
|
|
21560
|
+
withheldMajorReason: void 0
|
|
21561
|
+
};
|
|
21562
|
+
const eligible = stable.filter((v) => underCeiling(v, ceiling));
|
|
21563
|
+
const isMajorWithheld = pickBuckets(eligible, anchor).major === void 0 && pickBuckets(stable, anchor).major !== void 0;
|
|
21564
|
+
return {
|
|
21565
|
+
distTags: ceilingFilteredDistTags(distTags, ceiling),
|
|
21566
|
+
eligible,
|
|
21567
|
+
withheldMajorReason: isMajorWithheld ? ceiling.reason : void 0
|
|
21568
|
+
};
|
|
21569
|
+
}
|
|
21469
21570
|
function resolveOne(name, group, info, options, excludeRules) {
|
|
21470
21571
|
const nonPeer = group.filter((d) => d.depType !== "peerDependencies");
|
|
21471
21572
|
const sourceForRange = nonPeer.length > 0 ? nonPeer : group;
|
|
@@ -21474,15 +21575,16 @@ function resolveOne(name, group, info, options, excludeRules) {
|
|
|
21474
21575
|
const current = declaredRanges.length === 1 ? declaredRanges[0] : "mixed";
|
|
21475
21576
|
const preferredRangePrefix = pickPrefix(declaredRanges);
|
|
21476
21577
|
const anchor = lowestAnchor(declaredRanges);
|
|
21477
|
-
|
|
21478
|
-
|
|
21479
|
-
const
|
|
21480
|
-
const
|
|
21481
|
-
const
|
|
21578
|
+
const registryName = group[0].registryName;
|
|
21579
|
+
if (info === void 0 || anchor === void 0) return unresolvedDep(name, registryName, current, declaredRanges, preferredRangePrefix, workspaces);
|
|
21580
|
+
const effectiveInfo = options.minReleaseAge ? filterRegistryInfo(registryName, info, options.minReleaseAge, excludeRules) : info;
|
|
21581
|
+
const { distTags, eligible, withheldMajorReason } = applyMajorCeiling(registryName, effectiveInfo.versions.filter((v) => import_semver.default.valid(v) !== null && isStable(v)), effectiveInfo.distTags, anchor);
|
|
21582
|
+
const downgrade = options.minReleaseAge && !isDeclaredRangeSatisfiable(declaredRanges, eligible) ? format$1(preferredRangePrefix, pickDowngrade(eligible, anchor)) : void 0;
|
|
21583
|
+
const buckets = pickBuckets(eligible, anchor);
|
|
21482
21584
|
const patchRaw = format$1(preferredRangePrefix, buckets.patch);
|
|
21483
21585
|
const minorRaw = format$1(preferredRangePrefix, buckets.minor);
|
|
21484
21586
|
const majorRaw = format$1(preferredRangePrefix, buckets.major);
|
|
21485
|
-
const nextRaw = options.shouldIncludeNext ?? false ? format$1(preferredRangePrefix, pickPrerelease(
|
|
21587
|
+
const nextRaw = options.shouldIncludeNext ?? false ? format$1(preferredRangePrefix, pickPrerelease(distTags, anchor)) : void 0;
|
|
21486
21588
|
const patch = normalizedMixedPatch(differentFromCurrent(patchRaw, current), declaredRanges, preferredRangePrefix, anchor);
|
|
21487
21589
|
const minor = differentFromCurrent(minorRaw, current);
|
|
21488
21590
|
const major = differentFromCurrent(majorRaw, current);
|
|
@@ -21498,7 +21600,9 @@ function resolveOne(name, group, info, options, excludeRules) {
|
|
|
21498
21600
|
next,
|
|
21499
21601
|
patch,
|
|
21500
21602
|
preferredRangePrefix,
|
|
21603
|
+
registryName,
|
|
21501
21604
|
updateAvailable: availableVersion !== void 0 && availableVersion.length > 0,
|
|
21605
|
+
withheldMajorReason,
|
|
21502
21606
|
workspaces
|
|
21503
21607
|
};
|
|
21504
21608
|
}
|
|
@@ -21511,7 +21615,7 @@ function resolveVersions(deps, registry, options = {}) {
|
|
|
21511
21615
|
}
|
|
21512
21616
|
const excludeRules = options.minReleaseAge ? buildExcludeRules(options.minReleaseAge.exclude) : [];
|
|
21513
21617
|
const resolved = [];
|
|
21514
|
-
for (const [name, group] of grouped) resolved.push(resolveOne(name, group, registry.get(
|
|
21618
|
+
for (const [name, group] of grouped) resolved.push(resolveOne(name, group, registry.get(group[0].registryName), options, excludeRules));
|
|
21515
21619
|
return resolved.toSorted((a, b) => {
|
|
21516
21620
|
if (a.updateAvailable !== b.updateAvailable) return a.updateAvailable ? -1 : 1;
|
|
21517
21621
|
return a.name.localeCompare(b.name);
|
|
@@ -21562,7 +21666,7 @@ async function runUpdo(pm, options = {}) {
|
|
|
21562
21666
|
const uniqueDependencyNames = /* @__PURE__ */ new Set();
|
|
21563
21667
|
console.log(chalk.gray("Scanning workspace dependencies..."));
|
|
21564
21668
|
const declaredDeps = collectWorkspaceDeps(cwd, workspaces, workspaceNames);
|
|
21565
|
-
for (const dep of declaredDeps) uniqueDependencyNames.add(dep.
|
|
21669
|
+
for (const dep of declaredDeps) uniqueDependencyNames.add(dep.registryName);
|
|
21566
21670
|
console.log(chalk.gray(` Found ${uniqueDependencyNames.size} unique dependencies across ${workspaces.length} workspaces`));
|
|
21567
21671
|
const minReleaseAge = resolveMinReleaseAgeFilter(pm.name, cwd);
|
|
21568
21672
|
console.log(chalk.gray("Fetching registry info..."));
|
|
@@ -21580,6 +21684,10 @@ async function runUpdo(pm, options = {}) {
|
|
|
21580
21684
|
});
|
|
21581
21685
|
const downgradeCount = resolved.filter((r) => r.downgrade !== void 0).length;
|
|
21582
21686
|
if (downgradeCount > 0) console.log(chalk.yellow(` ${downgradeCount} package(s) have a current range that pnpm will reject — see the red "Down" column for downgrade suggestions.`));
|
|
21687
|
+
for (const dep of resolved) {
|
|
21688
|
+
if (dep.withheldMajorReason === void 0) continue;
|
|
21689
|
+
console.log(chalk.gray(` ${dep.name}: major bump withheld — ${dep.withheldMajorReason}`));
|
|
21690
|
+
}
|
|
21583
21691
|
const updates = await interactiveSelect(resolved, {
|
|
21584
21692
|
shouldIncludeNext: isIncludeNext,
|
|
21585
21693
|
latest: isLatest,
|
|
@@ -25465,11 +25573,22 @@ function shouldUseIncremental$3(incremental) {
|
|
|
25465
25573
|
return incremental !== false;
|
|
25466
25574
|
}
|
|
25467
25575
|
/**
|
|
25468
|
-
CLI flag wins, then root `compile.validator`, then per-package spawns.
|
|
25576
|
+
* CLI flag wins, then root `compile.validator`, then per-package spawns.
|
|
25577
|
+
*
|
|
25578
|
+
* The shared validator runs every package through one `ts.Program` host so
|
|
25579
|
+
* dependency declarations are parsed once. That cache only exists in the JS
|
|
25580
|
+
* compiler API, which `compile.compiler: 'native'` does not have — so the two
|
|
25581
|
+
* cannot be combined, and the native compiler's own parallelism is the
|
|
25582
|
+
* intended replacement for the shared cache.
|
|
25469
25583
|
*/
|
|
25470
25584
|
async function resolveCompileValidator(override) {
|
|
25471
|
-
|
|
25472
|
-
|
|
25585
|
+
const rootConfig = await loadConfig();
|
|
25586
|
+
const requested = override ?? rootConfig.compile?.validator ?? "per-package";
|
|
25587
|
+
if (requested === "shared" && rootConfig.compile?.compiler === "native") {
|
|
25588
|
+
console.warn(chalk.yellow("Compile: compile.validator \"shared\" is not available with compile.compiler \"native\" — validating per package."));
|
|
25589
|
+
return "per-package";
|
|
25590
|
+
}
|
|
25591
|
+
return requested;
|
|
25473
25592
|
}
|
|
25474
25593
|
function createCompilePlan({ incrementalPlan, pm, shouldUseIncremental, isVerbose, workspaces }) {
|
|
25475
25594
|
if (!shouldUseIncremental) return void 0;
|
|
@@ -28318,9 +28437,36 @@ const rules = [
|
|
|
28318
28437
|
isNeeded: hasTypescriptFiles
|
|
28319
28438
|
}
|
|
28320
28439
|
];
|
|
28440
|
+
/**
|
|
28441
|
+
* Packages the toolchain runs as a binary rather than imports, and which are
|
|
28442
|
+
* therefore installed under an `npm:` alias. Today that is the native
|
|
28443
|
+
* TypeScript compiler: `typescript@7` shares the `typescript` package name and
|
|
28444
|
+
* `tsc` bin with the compiler API package, so it can only be installed
|
|
28445
|
+
* alongside as `"typescript-native": "npm:typescript@7"`.
|
|
28446
|
+
*
|
|
28447
|
+
* Static analysis can never justify such a declaration — nothing imports the
|
|
28448
|
+
* alias key, and nothing could, since TypeScript@7 exports no API. `xy compile`
|
|
28449
|
+
* resolves it by path when `compile.compiler` is `native`.
|
|
28450
|
+
*/
|
|
28451
|
+
const spawnedAliasTargets = /* @__PURE__ */ new Set(["typescript"]);
|
|
28452
|
+
function getSpawnedAliasDependencies({ location }) {
|
|
28453
|
+
const implicit = /* @__PURE__ */ new Set();
|
|
28454
|
+
let devDependencies;
|
|
28455
|
+
try {
|
|
28456
|
+
devDependencies = JSON.parse(fs.readFileSync(`${location}/package.json`, "utf8")).devDependencies ?? {};
|
|
28457
|
+
} catch {
|
|
28458
|
+
return implicit;
|
|
28459
|
+
}
|
|
28460
|
+
for (const [name, spec] of Object.entries(devDependencies)) {
|
|
28461
|
+
const alias = parseAliasSpec(spec);
|
|
28462
|
+
if (alias !== void 0 && spawnedAliasTargets.has(alias.registryName)) implicit.add(name);
|
|
28463
|
+
}
|
|
28464
|
+
return implicit;
|
|
28465
|
+
}
|
|
28321
28466
|
function getImplicitDevDependencies(context) {
|
|
28322
28467
|
const implicit = /* @__PURE__ */ new Set();
|
|
28323
28468
|
for (const rule of rules) if (rule.isNeeded(context)) implicit.add(rule.package);
|
|
28469
|
+
for (const name of getSpawnedAliasDependencies(context)) implicit.add(name);
|
|
28324
28470
|
return implicit;
|
|
28325
28471
|
}
|
|
28326
28472
|
//#endregion
|
|
@@ -40712,7 +40858,7 @@ function addGitignoreConfig(source) {
|
|
|
40712
40858
|
}
|
|
40713
40859
|
//#endregion
|
|
40714
40860
|
//#region src/actions/lint-init.ts
|
|
40715
|
-
function askConfirmation(question) {
|
|
40861
|
+
function askConfirmation$1(question) {
|
|
40716
40862
|
const rl = createInterface({
|
|
40717
40863
|
input: process.stdin,
|
|
40718
40864
|
output: process.stdout
|
|
@@ -40858,7 +41004,7 @@ async function lintInit({ isVerbose } = {}) {
|
|
|
40858
41004
|
const existingPath = findExistingConfig(configPath, legacyConfigPath);
|
|
40859
41005
|
if (existingPath !== void 0) {
|
|
40860
41006
|
const filename = PATH.basename(existingPath);
|
|
40861
|
-
if (!await askConfirmation(chalk.yellow(`${filename} already exists. Replace it with eslint.config.ts? (y/N) `))) {
|
|
41007
|
+
if (!await askConfirmation$1(chalk.yellow(`${filename} already exists. Replace it with eslint.config.ts? (y/N) `))) {
|
|
40862
41008
|
console.log(chalk.gray(`Skipped — existing ${filename} preserved`));
|
|
40863
41009
|
return 0;
|
|
40864
41010
|
}
|
|
@@ -40867,7 +41013,7 @@ async function lintInit({ isVerbose } = {}) {
|
|
|
40867
41013
|
if (isReact) console.log(chalk.cyan("Detected React packages — using @ariestools/eslint-config-react-flat"));
|
|
40868
41014
|
else if (isVerbose === true) console.log(chalk.gray(" No React packages detected — using @ariestools/eslint-config-flat"));
|
|
40869
41015
|
const enabledBarrels = [];
|
|
40870
|
-
for (const descriptor of getBarrelDescriptorsForRepo(isReact)) if (await askConfirmation(chalk.cyan(`Disallow ${descriptor.pkg} barrel imports? (y/N) `))) enabledBarrels.push(descriptor);
|
|
41016
|
+
for (const descriptor of getBarrelDescriptorsForRepo(isReact)) if (await askConfirmation$1(chalk.cyan(`Disallow ${descriptor.pkg} barrel imports? (y/N) `))) enabledBarrels.push(descriptor);
|
|
40871
41017
|
const config = generateEslintConfig({
|
|
40872
41018
|
barrels: resolveEnabledBarrels(cwd, enabledBarrels, isVerbose),
|
|
40873
41019
|
hasGitignore: existsSync(PATH.resolve(cwd, ".gitignore")),
|
|
@@ -43398,7 +43544,7 @@ const relintAllPackages = ({ fix = false } = {}) => {
|
|
|
43398
43544
|
return runSteps(`${fix ? "Fix" : "Lint"} [All-Packages]`, [["eslint", fix ? ["--fix"] : []]]);
|
|
43399
43545
|
};
|
|
43400
43546
|
//#endregion
|
|
43401
|
-
//#region src/actions/repo-init.ts
|
|
43547
|
+
//#region src/actions/repo-init/prompts.ts
|
|
43402
43548
|
function askQuestion(question) {
|
|
43403
43549
|
const rl = createInterface({
|
|
43404
43550
|
input: process.stdin,
|
|
@@ -43411,6 +43557,262 @@ function askQuestion(question) {
|
|
|
43411
43557
|
});
|
|
43412
43558
|
});
|
|
43413
43559
|
}
|
|
43560
|
+
async function askConfirmation(question, defaultYes = false) {
|
|
43561
|
+
const hint = defaultYes ? "Y/n" : "y/N";
|
|
43562
|
+
const answer = await askQuestion(chalk.cyan(`${question} (${hint}) `));
|
|
43563
|
+
if (answer.length === 0) return defaultYes;
|
|
43564
|
+
return answer.toLowerCase() === "y" || answer.toLowerCase() === "yes";
|
|
43565
|
+
}
|
|
43566
|
+
async function askChoice(question, choices, defaultChoice) {
|
|
43567
|
+
const labels = choices.map((choice) => {
|
|
43568
|
+
return choice === defaultChoice ? chalk.bold(choice) : choice;
|
|
43569
|
+
}).join("/");
|
|
43570
|
+
const answer = await askQuestion(chalk.cyan(`${question} [${labels}]: `));
|
|
43571
|
+
if (answer.length === 0) return defaultChoice;
|
|
43572
|
+
const match = choices.find((choice) => choice.toLowerCase() === answer.toLowerCase());
|
|
43573
|
+
if (match === void 0) {
|
|
43574
|
+
console.warn(chalk.yellow(`Unknown choice "${answer}", using ${defaultChoice}`));
|
|
43575
|
+
return defaultChoice;
|
|
43576
|
+
}
|
|
43577
|
+
return match;
|
|
43578
|
+
}
|
|
43579
|
+
//#endregion
|
|
43580
|
+
//#region src/actions/repo-init/resolvePlan.ts
|
|
43581
|
+
const PMS = [
|
|
43582
|
+
"pnpm",
|
|
43583
|
+
"yarn",
|
|
43584
|
+
"npm",
|
|
43585
|
+
"bun"
|
|
43586
|
+
];
|
|
43587
|
+
const TIERS = [
|
|
43588
|
+
"none",
|
|
43589
|
+
"xy",
|
|
43590
|
+
"xyo",
|
|
43591
|
+
"xl1"
|
|
43592
|
+
];
|
|
43593
|
+
function isPackageManagerName(value) {
|
|
43594
|
+
return PMS.includes(value);
|
|
43595
|
+
}
|
|
43596
|
+
function isSkillTier(value) {
|
|
43597
|
+
return TIERS.includes(value);
|
|
43598
|
+
}
|
|
43599
|
+
function printSummary(plan) {
|
|
43600
|
+
console.log("");
|
|
43601
|
+
console.log(chalk.bold("Scaffold plan"));
|
|
43602
|
+
console.log(chalk.gray(` name: ${plan.name}`));
|
|
43603
|
+
console.log(chalk.gray(` template: ${plan.template}`));
|
|
43604
|
+
console.log(chalk.gray(` package: ${plan.packageName}`));
|
|
43605
|
+
console.log(chalk.gray(` scope: ${plan.scope || "(none)"}`));
|
|
43606
|
+
console.log(chalk.gray(` pm: ${plan.pm}`));
|
|
43607
|
+
console.log(chalk.gray(` monorepo: ${String(plan.monorepo)}`));
|
|
43608
|
+
console.log(chalk.gray(` react: ${String(plan.react)}`));
|
|
43609
|
+
console.log(chalk.gray(` skills: ${plan.skillsTier}${plan.skillsOptional ? " (+optional)" : ""}`));
|
|
43610
|
+
console.log("");
|
|
43611
|
+
}
|
|
43612
|
+
function reassignUnknownTemplateAsName(templates, template, name) {
|
|
43613
|
+
if (template != null && template.length > 0 && !templates.includes(template) && (name == null || name.length === 0)) return {
|
|
43614
|
+
name: template,
|
|
43615
|
+
template: void 0
|
|
43616
|
+
};
|
|
43617
|
+
return {
|
|
43618
|
+
name,
|
|
43619
|
+
template
|
|
43620
|
+
};
|
|
43621
|
+
}
|
|
43622
|
+
async function resolveTemplateName(templates, template, wizard, useDefaults) {
|
|
43623
|
+
if (template != null && template.length > 0) return template;
|
|
43624
|
+
if (useDefaults) return templates.includes("cli") ? "cli" : templates[0];
|
|
43625
|
+
if (wizard) return askChoice("Template", templates, templates.includes("cli") ? "cli" : templates[0]);
|
|
43626
|
+
return "cli";
|
|
43627
|
+
}
|
|
43628
|
+
async function resolveProjectName(name, useDefaults) {
|
|
43629
|
+
if (name != null && name.length > 0) return name;
|
|
43630
|
+
if (useDefaults) {
|
|
43631
|
+
console.error(chalk.red("Project name is required (pass a name or omit --yes)"));
|
|
43632
|
+
return;
|
|
43633
|
+
}
|
|
43634
|
+
const answer = await askQuestion(chalk.cyan("Project name: "));
|
|
43635
|
+
if (!answer) {
|
|
43636
|
+
console.error(chalk.red("Project name is required"));
|
|
43637
|
+
return;
|
|
43638
|
+
}
|
|
43639
|
+
return answer;
|
|
43640
|
+
}
|
|
43641
|
+
async function resolveWizardBoolean(provided, question, defaultYes, wizard, useDefaults) {
|
|
43642
|
+
if (provided !== void 0) return provided;
|
|
43643
|
+
if (!wizard || useDefaults) return defaultYes;
|
|
43644
|
+
return askConfirmation(question, defaultYes);
|
|
43645
|
+
}
|
|
43646
|
+
async function resolvePackageManager(provided, wizard, useDefaults) {
|
|
43647
|
+
if (provided !== void 0) return provided;
|
|
43648
|
+
if (!wizard || useDefaults) return "pnpm";
|
|
43649
|
+
return askChoice("Package manager", PMS, "pnpm");
|
|
43650
|
+
}
|
|
43651
|
+
async function resolveScope(provided, wizard, useDefaults) {
|
|
43652
|
+
const fallback = provided ?? "@xylabs";
|
|
43653
|
+
if (provided !== void 0 || !wizard || useDefaults) return fallback;
|
|
43654
|
+
const answer = await askQuestion(chalk.cyan(`npm scope [${fallback}]: `));
|
|
43655
|
+
return answer.length > 0 ? answer : fallback;
|
|
43656
|
+
}
|
|
43657
|
+
async function resolveDescription(provided, wizard, useDefaults) {
|
|
43658
|
+
if (useDefaults || !wizard || provided != null && provided.length > 0) return provided ?? "";
|
|
43659
|
+
return askQuestion(chalk.cyan("Description (optional): "));
|
|
43660
|
+
}
|
|
43661
|
+
async function resolveSkillsTier(provided, wizard, useDefaults) {
|
|
43662
|
+
if (provided !== void 0) {
|
|
43663
|
+
if (!isSkillTier(provided)) {
|
|
43664
|
+
console.error(chalk.red(`Invalid skills tier "${provided}"`));
|
|
43665
|
+
return;
|
|
43666
|
+
}
|
|
43667
|
+
return provided;
|
|
43668
|
+
}
|
|
43669
|
+
if (!wizard || useDefaults) return wizard ? "xy" : "none";
|
|
43670
|
+
return askChoice("Skills tier (agent skills to install)", TIERS, "xy");
|
|
43671
|
+
}
|
|
43672
|
+
async function resolveSkillsOptional(provided, skillsTier, wizard, useDefaults) {
|
|
43673
|
+
if (provided !== void 0) return provided;
|
|
43674
|
+
if (skillsTier !== "xl1" || !wizard || useDefaults) return false;
|
|
43675
|
+
return askConfirmation("Install optional XL1 skills (xl1-scaffold, xl1-build)?", true);
|
|
43676
|
+
}
|
|
43677
|
+
async function resolveCore(params, templates, useDefaults) {
|
|
43678
|
+
const reassigned = reassignUnknownTemplateAsName(templates, params.template, params.name);
|
|
43679
|
+
const wizard = reassigned.template == null || reassigned.template.length === 0;
|
|
43680
|
+
const template = await resolveTemplateName(templates, reassigned.template, wizard, useDefaults);
|
|
43681
|
+
if (template === void 0 || !templates.includes(template)) {
|
|
43682
|
+
console.error(chalk.red(`Unknown template "${template ?? ""}". Available: ${templates.join(", ")}`));
|
|
43683
|
+
return;
|
|
43684
|
+
}
|
|
43685
|
+
const name = await resolveProjectName(reassigned.name, useDefaults);
|
|
43686
|
+
if (name === void 0) return void 0;
|
|
43687
|
+
return {
|
|
43688
|
+
name,
|
|
43689
|
+
template,
|
|
43690
|
+
wizard
|
|
43691
|
+
};
|
|
43692
|
+
}
|
|
43693
|
+
async function resolvePlanOptions(params, wizard, useDefaults) {
|
|
43694
|
+
const pm = await resolvePackageManager(params.pm, wizard, useDefaults);
|
|
43695
|
+
if (!isPackageManagerName(pm)) {
|
|
43696
|
+
console.error(chalk.red(`Invalid package manager "${pm}"`));
|
|
43697
|
+
return;
|
|
43698
|
+
}
|
|
43699
|
+
const monorepo = await resolveWizardBoolean(params.monorepo, "Monorepo (packages/* workspaces)?", true, wizard, useDefaults);
|
|
43700
|
+
const react = await resolveWizardBoolean(params.react, "React project (eslint-config-react-flat + tsconfig-react)?", false, wizard, useDefaults);
|
|
43701
|
+
const scope = await resolveScope(params.scope, wizard, useDefaults);
|
|
43702
|
+
const description = await resolveDescription(params.description, wizard, useDefaults);
|
|
43703
|
+
const skillsTier = await resolveSkillsTier(params.skillsTier, wizard, useDefaults);
|
|
43704
|
+
if (skillsTier === void 0) return void 0;
|
|
43705
|
+
return {
|
|
43706
|
+
description,
|
|
43707
|
+
monorepo,
|
|
43708
|
+
pm,
|
|
43709
|
+
react,
|
|
43710
|
+
scope,
|
|
43711
|
+
skillsOptional: await resolveSkillsOptional(params.skillsOptional, skillsTier, wizard, useDefaults),
|
|
43712
|
+
skillsTier
|
|
43713
|
+
};
|
|
43714
|
+
}
|
|
43715
|
+
function buildPlan(params, core, options) {
|
|
43716
|
+
const projectName = PATH.basename(core.name);
|
|
43717
|
+
return {
|
|
43718
|
+
description: options.description,
|
|
43719
|
+
githubOrg: params.githubOrg ?? (options.scope.replace(/^@/, "") || projectName),
|
|
43720
|
+
isVerbose: params.isVerbose ?? false,
|
|
43721
|
+
monorepo: options.monorepo,
|
|
43722
|
+
name: core.name,
|
|
43723
|
+
packageName: params.packageName ?? projectName,
|
|
43724
|
+
pm: options.pm,
|
|
43725
|
+
projectName,
|
|
43726
|
+
react: options.react,
|
|
43727
|
+
scope: options.scope,
|
|
43728
|
+
skillsOptional: options.skillsOptional,
|
|
43729
|
+
skillsTier: options.skillsTier,
|
|
43730
|
+
skipGit: params.skipGit ?? false,
|
|
43731
|
+
skipInstall: params.skipInstall ?? false,
|
|
43732
|
+
template: core.template
|
|
43733
|
+
};
|
|
43734
|
+
}
|
|
43735
|
+
/**
|
|
43736
|
+
* When template is provided, fill only missing fields (legacy non-wizard path).
|
|
43737
|
+
* When template is omitted, run the interactive wizard (unless --yes supplies defaults).
|
|
43738
|
+
*/
|
|
43739
|
+
async function resolveRepoInitPlan(params) {
|
|
43740
|
+
const templates = listRepoTemplates();
|
|
43741
|
+
if (templates.length === 0) {
|
|
43742
|
+
console.error(chalk.red("No repo templates found under templates/repo"));
|
|
43743
|
+
return;
|
|
43744
|
+
}
|
|
43745
|
+
const useDefaults = params.yes === true;
|
|
43746
|
+
const core = await resolveCore(params, templates, useDefaults);
|
|
43747
|
+
if (core === void 0) return void 0;
|
|
43748
|
+
const options = await resolvePlanOptions(params, core.wizard, useDefaults);
|
|
43749
|
+
if (options === void 0) return void 0;
|
|
43750
|
+
const plan = buildPlan(params, core, options);
|
|
43751
|
+
if (!useDefaults && core.wizard) {
|
|
43752
|
+
printSummary(plan);
|
|
43753
|
+
if (!await askConfirmation("Proceed?", true)) {
|
|
43754
|
+
console.log(chalk.yellow("Cancelled"));
|
|
43755
|
+
return;
|
|
43756
|
+
}
|
|
43757
|
+
}
|
|
43758
|
+
return plan;
|
|
43759
|
+
}
|
|
43760
|
+
//#endregion
|
|
43761
|
+
//#region src/actions/repo-init/templateVars.ts
|
|
43762
|
+
function packageManagerField(pm) {
|
|
43763
|
+
switch (pm) {
|
|
43764
|
+
case "pnpm": return "pnpm@11.13.1";
|
|
43765
|
+
case "yarn": return "yarn@4.13.0";
|
|
43766
|
+
case "npm": return "npm@10.9.4";
|
|
43767
|
+
case "bun": return "bun@1.3.3";
|
|
43768
|
+
}
|
|
43769
|
+
}
|
|
43770
|
+
function xyCommandForPm(pm) {
|
|
43771
|
+
switch (pm) {
|
|
43772
|
+
case "bun": return "bun run xy";
|
|
43773
|
+
case "npm": return "npm exec -- xy";
|
|
43774
|
+
default: return `${pm} xy`;
|
|
43775
|
+
}
|
|
43776
|
+
}
|
|
43777
|
+
function buildTemplateVariables(plan) {
|
|
43778
|
+
const { description, githubOrg, monorepo, packageName, pm, projectName, react, scope } = plan;
|
|
43779
|
+
const identifierName = packageName.replaceAll(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
43780
|
+
const npmScope = scope.startsWith("@") || scope.length === 0 ? scope : `@${scope}`;
|
|
43781
|
+
const scopedPackageName = npmScope.length > 0 ? `${npmScope}/${packageName}` : packageName;
|
|
43782
|
+
const rootPackageName = monorepo ? npmScope.length > 0 ? `${npmScope}/${projectName}-build` : `${projectName}-build` : scopedPackageName;
|
|
43783
|
+
const eslintConfigPackage = react ? "@ariestools/eslint-config-react-flat" : "@ariestools/eslint-config-flat";
|
|
43784
|
+
const tsconfigPackage = react ? "@ariestools/tsconfig-react" : "@ariestools/tsconfig";
|
|
43785
|
+
const coverageInclude = monorepo ? "packages/*/src/**/*.{ts,tsx,mts,cts}" : "src/**/*.{ts,tsx,mts,cts}";
|
|
43786
|
+
const testInclude = monorepo ? "packages/*/src/spec/**/*.spec.{ts,tsx,mts,cts}" : "src/spec/**/*.spec.{ts,tsx,mts,cts}";
|
|
43787
|
+
const srcPrefix = monorepo ? `packages/${packageName}/src/` : "src/";
|
|
43788
|
+
const layoutLabel = monorepo ? "monorepo (pnpm/yarn/npm workspaces)" : "single package";
|
|
43789
|
+
return {
|
|
43790
|
+
coverageInclude,
|
|
43791
|
+
description,
|
|
43792
|
+
eslintConfigPackage,
|
|
43793
|
+
githubOrg,
|
|
43794
|
+
identifierName,
|
|
43795
|
+
layoutDescription: monorepo ? `Monorepo for ${projectName} (\`${scopedPackageName}\`). Package sources live under \`packages/${packageName}\`.` : `Single-package repo for ${projectName} (\`${scopedPackageName}\`). Sources live under \`src/\`.`,
|
|
43796
|
+
layoutLabel,
|
|
43797
|
+
npmScope,
|
|
43798
|
+
packageDirNote: monorepo ? ", never from inside a package directory" : "",
|
|
43799
|
+
packageManager: packageManagerField(pm),
|
|
43800
|
+
packageName,
|
|
43801
|
+
pmName: pm,
|
|
43802
|
+
projectName,
|
|
43803
|
+
rootPackageName,
|
|
43804
|
+
rootPrivate: monorepo ? "true" : "false",
|
|
43805
|
+
scopedPackageName,
|
|
43806
|
+
srcPrefix,
|
|
43807
|
+
testInclude,
|
|
43808
|
+
toolchainRange: bundledToolchainRange(),
|
|
43809
|
+
toolchainVersion: bundledToolchainVersion(),
|
|
43810
|
+
tsconfigPackage,
|
|
43811
|
+
xyCommand: xyCommandForPm(pm)
|
|
43812
|
+
};
|
|
43813
|
+
}
|
|
43814
|
+
//#endregion
|
|
43815
|
+
//#region src/actions/repo-init/scaffold.ts
|
|
43414
43816
|
function mapOutputPath(relativePath, variables) {
|
|
43415
43817
|
let result = relativePath;
|
|
43416
43818
|
if (result.endsWith(".tmpl")) result = result.slice(0, -5);
|
|
@@ -43419,8 +43821,8 @@ function mapOutputPath(relativePath, variables) {
|
|
|
43419
43821
|
result = result.replaceAll("__packageName__", () => variables.packageName);
|
|
43420
43822
|
return result;
|
|
43421
43823
|
}
|
|
43422
|
-
function isPmSpecificFile(relativePath, pm) {
|
|
43423
|
-
if (relativePath === "pnpm-workspace.yaml" && pm !== "pnpm") return true;
|
|
43824
|
+
function isPmSpecificFile(relativePath, pm, monorepo) {
|
|
43825
|
+
if (relativePath === "pnpm-workspace.yaml" && (pm !== "pnpm" || !monorepo)) return true;
|
|
43424
43826
|
if (pm !== "pnpm" && relativePath.includes("build-pnpm")) return true;
|
|
43425
43827
|
if (pm !== "npm" && relativePath.includes("build-npm")) return true;
|
|
43426
43828
|
if (pm !== "bun" && relativePath.includes("build-bun")) return true;
|
|
@@ -43429,25 +43831,6 @@ function isPmSpecificFile(relativePath, pm) {
|
|
|
43429
43831
|
function mapBuildWorkflowName(outputPath) {
|
|
43430
43832
|
return outputPath.replace(/build-(bun|npm|pnpm|yarn)\.yml/, "build.yml");
|
|
43431
43833
|
}
|
|
43432
|
-
function buildVariables(params) {
|
|
43433
|
-
const { description, githubOrg, packageName, pm, projectName, scope } = params;
|
|
43434
|
-
const identifierName = packageName.replaceAll(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
43435
|
-
const packageManager = pm === "pnpm" ? "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319" : pm === "yarn" ? "yarn@4.13.0" : pm === "npm" ? "npm@10.9.4" : "bun@1.3.3";
|
|
43436
|
-
const xyCommand = pm === "npm" ? "npm exec -- xy" : pm === "bun" ? "bun run xy" : `${pm} xy`;
|
|
43437
|
-
return {
|
|
43438
|
-
description,
|
|
43439
|
-
githubOrg,
|
|
43440
|
-
identifierName,
|
|
43441
|
-
npmScope: scope,
|
|
43442
|
-
packageName,
|
|
43443
|
-
packageManager,
|
|
43444
|
-
pmName: pm,
|
|
43445
|
-
projectName,
|
|
43446
|
-
toolchainRange: bundledToolchainRange(),
|
|
43447
|
-
toolchainVersion: bundledToolchainVersion(),
|
|
43448
|
-
xyCommand
|
|
43449
|
-
};
|
|
43450
|
-
}
|
|
43451
43834
|
function didEnsureEmptyDir(projectDir, name) {
|
|
43452
43835
|
if (existsSync(projectDir)) {
|
|
43453
43836
|
if (readdirSync(projectDir).length > 0) {
|
|
@@ -43458,11 +43841,12 @@ function didEnsureEmptyDir(projectDir, name) {
|
|
|
43458
43841
|
mkdirSync(projectDir, { recursive: true });
|
|
43459
43842
|
return true;
|
|
43460
43843
|
}
|
|
43461
|
-
function scaffoldFiles(templateName, layer, outputDir, pm, variables, isVerbose) {
|
|
43844
|
+
function scaffoldFiles(templateName, layer, outputDir, pm, monorepo, variables, isVerbose, skipRelativePaths = /* @__PURE__ */ new Set()) {
|
|
43462
43845
|
const files = loadRepoTemplateFiles(templateName, layer);
|
|
43463
43846
|
let count = 0;
|
|
43464
43847
|
for (const file of files) {
|
|
43465
|
-
if (
|
|
43848
|
+
if (skipRelativePaths.has(file.relativePath)) continue;
|
|
43849
|
+
if (isPmSpecificFile(file.relativePath, pm, monorepo)) continue;
|
|
43466
43850
|
const content = fillTemplate(file.content, variables);
|
|
43467
43851
|
let outputPath = mapOutputPath(file.relativePath, variables);
|
|
43468
43852
|
if (outputPath == null || outputPath.length === 0) continue;
|
|
@@ -43471,7 +43855,10 @@ function scaffoldFiles(templateName, layer, outputDir, pm, variables, isVerbose)
|
|
|
43471
43855
|
mkdirSync(PATH.dirname(fullPath), { recursive: true });
|
|
43472
43856
|
writeFileSync(fullPath, content);
|
|
43473
43857
|
count++;
|
|
43474
|
-
if (isVerbose ?? false)
|
|
43858
|
+
if (isVerbose ?? false) {
|
|
43859
|
+
const label = layer === "root" || !monorepo ? outputPath : `packages/${variables.packageName}/${outputPath}`;
|
|
43860
|
+
console.log(chalk.gray(` ${label}`));
|
|
43861
|
+
}
|
|
43475
43862
|
}
|
|
43476
43863
|
return count;
|
|
43477
43864
|
}
|
|
@@ -43504,60 +43891,412 @@ function didInstallDependencies(projectDir, pm) {
|
|
|
43504
43891
|
console.log(chalk.green("Dependencies installed"));
|
|
43505
43892
|
return true;
|
|
43506
43893
|
}
|
|
43507
|
-
function
|
|
43894
|
+
function mergePackageJsonRecords(rootPkg, packagePkg) {
|
|
43895
|
+
const rootDev = rootPkg.devDependencies ?? {};
|
|
43896
|
+
const pkgDev = packagePkg.devDependencies ?? {};
|
|
43897
|
+
const pkgDeps = packagePkg.dependencies ?? {};
|
|
43898
|
+
const rootScripts = rootPkg.scripts ?? {};
|
|
43899
|
+
const pkgScripts = packagePkg.scripts ?? {};
|
|
43900
|
+
return {
|
|
43901
|
+
...packagePkg,
|
|
43902
|
+
dependencies: pkgDeps,
|
|
43903
|
+
devDependencies: {
|
|
43904
|
+
...rootDev,
|
|
43905
|
+
...pkgDev
|
|
43906
|
+
},
|
|
43907
|
+
private: false,
|
|
43908
|
+
scripts: {
|
|
43909
|
+
...rootScripts,
|
|
43910
|
+
...pkgScripts
|
|
43911
|
+
}
|
|
43912
|
+
};
|
|
43913
|
+
}
|
|
43914
|
+
function normalizeRootPackageJson(projectDir, plan, packagePkg) {
|
|
43508
43915
|
const pkgPath = PATH.resolve(projectDir, "package.json");
|
|
43509
43916
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
43510
|
-
if (
|
|
43917
|
+
if (!plan.monorepo) {
|
|
43918
|
+
if (packagePkg !== void 0) {
|
|
43919
|
+
const merged = mergePackageJsonRecords(pkg, packagePkg);
|
|
43920
|
+
writeFileSync(pkgPath, `${JSON.stringify(merged, null, 2)}\n`, "utf8");
|
|
43921
|
+
return;
|
|
43922
|
+
}
|
|
43923
|
+
delete pkg.workspaces;
|
|
43924
|
+
pkg.private = false;
|
|
43925
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
|
43926
|
+
return;
|
|
43927
|
+
}
|
|
43928
|
+
if (plan.pm === "pnpm") delete pkg.workspaces;
|
|
43511
43929
|
else pkg.workspaces ??= ["packages/*"];
|
|
43512
43930
|
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
|
43513
43931
|
}
|
|
43514
|
-
function
|
|
43515
|
-
const
|
|
43516
|
-
|
|
43517
|
-
|
|
43518
|
-
|
|
43519
|
-
|
|
43932
|
+
function renderNextSteps(plan) {
|
|
43933
|
+
const lines = [`cd ${plan.name}`];
|
|
43934
|
+
if (plan.skipInstall) lines.push(`${plan.pm} install`);
|
|
43935
|
+
lines.push(`${xyCommandForPm(plan.pm)} build`);
|
|
43936
|
+
if (plan.skillsTier !== "none" && plan.skipInstall) lines.push(`${xyCommandForPm(plan.pm)} skills lint --fix`);
|
|
43937
|
+
return lines;
|
|
43938
|
+
}
|
|
43939
|
+
function scaffoldProject(plan) {
|
|
43940
|
+
const variables = buildTemplateVariables(plan);
|
|
43941
|
+
if (plan.isVerbose) {
|
|
43942
|
+
console.log(chalk.gray("Template variables:"));
|
|
43943
|
+
for (const [key, value] of Object.entries(variables)) console.log(chalk.gray(` ${key}: ${value}`));
|
|
43520
43944
|
}
|
|
43945
|
+
const projectDir = PATH.resolve(process.cwd(), plan.name);
|
|
43946
|
+
if (!didEnsureEmptyDir(projectDir, plan.name)) return void 0;
|
|
43947
|
+
let count = 0;
|
|
43948
|
+
if (plan.monorepo) {
|
|
43949
|
+
count += scaffoldFiles(plan.template, "root", projectDir, plan.pm, true, variables, plan.isVerbose);
|
|
43950
|
+
const pkgDir = PATH.resolve(projectDir, "packages", plan.packageName);
|
|
43951
|
+
count += scaffoldFiles(plan.template, "package", pkgDir, plan.pm, true, variables, plan.isVerbose);
|
|
43952
|
+
normalizeRootPackageJson(projectDir, plan);
|
|
43953
|
+
} else {
|
|
43954
|
+
count += scaffoldFiles(plan.template, "package", projectDir, plan.pm, false, variables, plan.isVerbose);
|
|
43955
|
+
const packagePkgPath = PATH.resolve(projectDir, "package.json");
|
|
43956
|
+
const packagePkg = JSON.parse(readFileSync(packagePkgPath, "utf8"));
|
|
43957
|
+
count += scaffoldFiles(plan.template, "root", projectDir, plan.pm, false, variables, plan.isVerbose);
|
|
43958
|
+
normalizeRootPackageJson(projectDir, plan, packagePkg);
|
|
43959
|
+
const mergeTmp = PATH.resolve(projectDir, ".package.json.merge");
|
|
43960
|
+
if (existsSync(mergeTmp)) unlinkSync(mergeTmp);
|
|
43961
|
+
}
|
|
43962
|
+
console.log(chalk.green(`Scaffolded ${count} files into ${plan.name}/`));
|
|
43963
|
+
return {
|
|
43964
|
+
count,
|
|
43965
|
+
projectDir
|
|
43966
|
+
};
|
|
43521
43967
|
}
|
|
43522
|
-
|
|
43523
|
-
|
|
43524
|
-
|
|
43525
|
-
|
|
43526
|
-
|
|
43527
|
-
|
|
43528
|
-
|
|
43529
|
-
|
|
43968
|
+
function runPostScaffold(plan, projectDir) {
|
|
43969
|
+
if (!plan.skipGit) initGitRepo(projectDir, plan.isVerbose);
|
|
43970
|
+
if (!plan.skipInstall) return { installOk: didInstallDependencies(projectDir, plan.pm) };
|
|
43971
|
+
return { installOk: true };
|
|
43972
|
+
}
|
|
43973
|
+
//#endregion
|
|
43974
|
+
//#region src/actions/skills/passthrough.ts
|
|
43975
|
+
const ANSI_PREFIX = String.raw`\x1B\[[\d;]*m`;
|
|
43976
|
+
const COMMAND_PREFIX = String.raw`(^|[\s$()\x60>]|${ANSI_PREFIX})`;
|
|
43977
|
+
const SKILLS_COMMANDS = [
|
|
43978
|
+
"<command>",
|
|
43979
|
+
"add",
|
|
43980
|
+
"a",
|
|
43981
|
+
"use",
|
|
43982
|
+
"remove",
|
|
43983
|
+
"rm",
|
|
43984
|
+
"list",
|
|
43985
|
+
"ls",
|
|
43986
|
+
"find",
|
|
43987
|
+
"update",
|
|
43988
|
+
"upgrade",
|
|
43989
|
+
"experimental_install",
|
|
43990
|
+
"init",
|
|
43991
|
+
"experimental_sync",
|
|
43992
|
+
"defaults",
|
|
43993
|
+
"lint",
|
|
43994
|
+
"updo"
|
|
43995
|
+
].join("|");
|
|
43996
|
+
const NPX_SKILLS_PATTERN = new RegExp(String.raw`${COMMAND_PREFIX}npx(?:\s+-y)?\s+skills(?:@latest)?(?=\W|$)`, "g");
|
|
43997
|
+
const BARE_USAGE_SKILLS_PATTERN = new RegExp(String.raw`^(\s*(?:${ANSI_PREFIX})*Usage:(?:${ANSI_PREFIX})*\s*)skills(?=\s+<command>)`, "gm");
|
|
43998
|
+
const BARE_PROMPT_SKILLS_PATTERN = new RegExp(String.raw`^(\s*(?:${ANSI_PREFIX})*\$(?:${ANSI_PREFIX})*\s*)skills(?=\s+(?:${SKILLS_COMMANDS})(?:\W|$))`, "gm");
|
|
43999
|
+
const require$3 = createRequire(import.meta.url);
|
|
44000
|
+
const YES_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes"]);
|
|
44001
|
+
const SCOPE_FLAGS$1 = /* @__PURE__ */ new Set([
|
|
44002
|
+
"-g",
|
|
44003
|
+
"--global",
|
|
44004
|
+
"-p",
|
|
44005
|
+
"--project"
|
|
44006
|
+
]);
|
|
44007
|
+
const INTERACTIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
44008
|
+
"add",
|
|
44009
|
+
"a",
|
|
44010
|
+
"experimental_sync",
|
|
44011
|
+
"find",
|
|
44012
|
+
"remove",
|
|
44013
|
+
"rm",
|
|
44014
|
+
"update",
|
|
44015
|
+
"upgrade"
|
|
44016
|
+
]);
|
|
44017
|
+
const skillsPositionalArgs = (args) => {
|
|
44018
|
+
return args.filter((arg) => !arg.startsWith("-"));
|
|
44019
|
+
};
|
|
44020
|
+
const hasSkillsFlag = (args, flags) => {
|
|
44021
|
+
return args.some((arg) => flags.has(arg));
|
|
44022
|
+
};
|
|
44023
|
+
const needsSkillsInteractive = (args) => {
|
|
44024
|
+
const [command, ...tail] = args;
|
|
44025
|
+
if (command === void 0 || !INTERACTIVE_COMMANDS.has(command)) return false;
|
|
44026
|
+
switch (command) {
|
|
44027
|
+
case "update":
|
|
44028
|
+
case "upgrade": return !hasSkillsFlag(tail, SCOPE_FLAGS$1) && !hasSkillsFlag(tail, YES_FLAGS) && skillsPositionalArgs(tail).length === 0;
|
|
44029
|
+
case "add":
|
|
44030
|
+
case "a":
|
|
44031
|
+
case "experimental_sync": return !hasSkillsFlag(tail, YES_FLAGS);
|
|
44032
|
+
case "remove":
|
|
44033
|
+
case "rm": return !hasSkillsFlag(tail, YES_FLAGS) && skillsPositionalArgs(tail).length === 0;
|
|
44034
|
+
case "find": return skillsPositionalArgs(tail).length === 0;
|
|
44035
|
+
default: return false;
|
|
44036
|
+
}
|
|
44037
|
+
};
|
|
44038
|
+
const rewriteSkillsRefs = (text) => {
|
|
44039
|
+
return text.replaceAll(NPX_SKILLS_PATTERN, (_match, prefix) => `${prefix}xy skills`).replaceAll(BARE_USAGE_SKILLS_PATTERN, "$1xy skills").replaceAll(BARE_PROMPT_SKILLS_PATTERN, "$1xy skills");
|
|
44040
|
+
};
|
|
44041
|
+
const resolveBundledSkillsCli = () => {
|
|
44042
|
+
return resolvePublishedOrDevCli("skills.mjs", () => require$3.resolve("skills/bin/cli.mjs"));
|
|
44043
|
+
};
|
|
44044
|
+
const resolveSkillsInvocation = async (args, options = {}) => {
|
|
44045
|
+
const resolveCli = options.resolveBundledCli ?? resolveBundledSkillsCli;
|
|
44046
|
+
const writeNotice = options.writeNotice ?? ((message) => console.error(message));
|
|
44047
|
+
try {
|
|
44048
|
+
return {
|
|
44049
|
+
args: [resolveCli(), ...args],
|
|
44050
|
+
command: process.execPath,
|
|
44051
|
+
fallback: false
|
|
44052
|
+
};
|
|
44053
|
+
} catch {
|
|
44054
|
+
writeNotice(chalk.red("skills package not found. Reinstall @ariestools/toolchain dependencies."));
|
|
44055
|
+
return;
|
|
44056
|
+
}
|
|
44057
|
+
};
|
|
44058
|
+
const runSkills = async (args, options = {}) => {
|
|
44059
|
+
const invocation = await resolveSkillsInvocation(args, options);
|
|
44060
|
+
if (invocation === void 0) return 1;
|
|
44061
|
+
const isInteractive = options.interactive ?? (process.stdin.isTTY && needsSkillsInteractive(args));
|
|
44062
|
+
const stdio = isInteractive ? "inherit" : [
|
|
44063
|
+
"inherit",
|
|
44064
|
+
"pipe",
|
|
44065
|
+
"pipe"
|
|
44066
|
+
];
|
|
44067
|
+
return new Promise((resolve) => {
|
|
44068
|
+
const child = spawn$1(invocation.command, invocation.args, {
|
|
44069
|
+
cwd: options.cwd,
|
|
44070
|
+
env: {
|
|
44071
|
+
FORCE_COLOR: "3",
|
|
44072
|
+
...process.env
|
|
44073
|
+
},
|
|
44074
|
+
stdio
|
|
44075
|
+
});
|
|
44076
|
+
if (!isInteractive) {
|
|
44077
|
+
child.stdout?.setEncoding("utf8");
|
|
44078
|
+
child.stderr?.setEncoding("utf8");
|
|
44079
|
+
child.stdout?.on("data", (chunk) => {
|
|
44080
|
+
process.stdout.write(rewriteSkillsRefs(chunk));
|
|
44081
|
+
});
|
|
44082
|
+
child.stderr?.on("data", (chunk) => {
|
|
44083
|
+
process.stderr.write(rewriteSkillsRefs(chunk));
|
|
44084
|
+
});
|
|
43530
44085
|
}
|
|
44086
|
+
child.on("error", () => resolve(1));
|
|
44087
|
+
child.on("close", (code) => resolve(code ?? 1));
|
|
44088
|
+
});
|
|
44089
|
+
};
|
|
44090
|
+
const argvAfterCommand = (command) => {
|
|
44091
|
+
const argv = process.argv;
|
|
44092
|
+
const commandIdx = argv.indexOf(command);
|
|
44093
|
+
if (commandIdx === -1) return [];
|
|
44094
|
+
return argv.slice(commandIdx + 1);
|
|
44095
|
+
};
|
|
44096
|
+
//#endregion
|
|
44097
|
+
//#region src/actions/skills/defaults.ts
|
|
44098
|
+
/**
|
|
44099
|
+
Source of truth for xy-development, xy-toolchain, and ariestools-sdk.
|
|
44100
|
+
*/
|
|
44101
|
+
const ARIESTOOLS_SKILLS_SOURCE = "ariestools/ariestools-skills";
|
|
44102
|
+
/**
|
|
44103
|
+
Source of truth for xyo-knowledge and xl1-* skills.
|
|
44104
|
+
*/
|
|
44105
|
+
const XYO_SKILLS_SOURCE = "XYOracleNetwork/xyo-skills";
|
|
44106
|
+
const ARIESTOOLS_SKILLS = [
|
|
44107
|
+
"ariestools-sdk",
|
|
44108
|
+
"xy-development",
|
|
44109
|
+
"xy-toolchain"
|
|
44110
|
+
];
|
|
44111
|
+
const XYO_STACK_SKILLS = [
|
|
44112
|
+
"xl1-build",
|
|
44113
|
+
"xl1-knowledge",
|
|
44114
|
+
"xl1-patterns",
|
|
44115
|
+
"xl1-scaffold",
|
|
44116
|
+
"xl1-testing",
|
|
44117
|
+
"xyo-knowledge"
|
|
44118
|
+
];
|
|
44119
|
+
/**
|
|
44120
|
+
All skills managed by `xy skills` conveniences (both sources).
|
|
44121
|
+
*/
|
|
44122
|
+
const XYO_DEFAULT_SKILLS = [...ARIESTOOLS_SKILLS, ...XYO_STACK_SKILLS];
|
|
44123
|
+
const AGENT_FLAGS = /* @__PURE__ */ new Set(["-a", "--agent"]);
|
|
44124
|
+
const hasSkillsAgentFlag = (args) => {
|
|
44125
|
+
return args.some((arg) => AGENT_FLAGS.has(arg) || arg.startsWith("--agent="));
|
|
44126
|
+
};
|
|
44127
|
+
/**
|
|
44128
|
+
* Returns install argument plans for `xy skills defaults`.
|
|
44129
|
+
* Aries Tools base skills install from ariestools-skills; XYO/XL1 skills from xyo-skills.
|
|
44130
|
+
*/
|
|
44131
|
+
const skillsDefaultsInstallPlans = (args) => {
|
|
44132
|
+
const installSelector = hasSkillsAgentFlag(args) ? ["--skill", "*"] : ["--all"];
|
|
44133
|
+
const xyoSelector = XYO_STACK_SKILLS.flatMap((skill) => ["--skill", skill]);
|
|
44134
|
+
return [{
|
|
44135
|
+
selector: installSelector,
|
|
44136
|
+
source: ARIESTOOLS_SKILLS_SOURCE
|
|
44137
|
+
}, {
|
|
44138
|
+
selector: xyoSelector,
|
|
44139
|
+
source: XYO_SKILLS_SOURCE
|
|
44140
|
+
}];
|
|
44141
|
+
};
|
|
44142
|
+
const skillSourceForName = (skillName) => {
|
|
44143
|
+
if (ARIESTOOLS_SKILLS.includes(skillName)) return ARIESTOOLS_SKILLS_SOURCE;
|
|
44144
|
+
return XYO_SKILLS_SOURCE;
|
|
44145
|
+
};
|
|
44146
|
+
const skillsDefaults = async (args) => {
|
|
44147
|
+
for (const plan of skillsDefaultsInstallPlans(args)) {
|
|
44148
|
+
const code = await runSkills([
|
|
44149
|
+
"add",
|
|
44150
|
+
plan.source,
|
|
44151
|
+
...plan.selector,
|
|
44152
|
+
...args
|
|
44153
|
+
]);
|
|
44154
|
+
if (code !== 0) return code;
|
|
43531
44155
|
}
|
|
43532
|
-
|
|
43533
|
-
|
|
43534
|
-
|
|
43535
|
-
|
|
43536
|
-
|
|
43537
|
-
|
|
43538
|
-
|
|
43539
|
-
|
|
43540
|
-
|
|
44156
|
+
return 0;
|
|
44157
|
+
};
|
|
44158
|
+
//#endregion
|
|
44159
|
+
//#region src/actions/skills/skillRules.ts
|
|
44160
|
+
const XYO_SKILL_NAMES = [...XYO_DEFAULT_SKILLS];
|
|
44161
|
+
const SKILL_ORDER = [
|
|
44162
|
+
"xy-development",
|
|
44163
|
+
"xy-toolchain",
|
|
44164
|
+
"ariestools-sdk",
|
|
44165
|
+
"xyo-knowledge",
|
|
44166
|
+
"xl1-knowledge",
|
|
44167
|
+
"xl1-patterns",
|
|
44168
|
+
"xl1-testing",
|
|
44169
|
+
"xl1-scaffold",
|
|
44170
|
+
"xl1-build"
|
|
44171
|
+
];
|
|
44172
|
+
const skillOrderIndex = (name) => {
|
|
44173
|
+
const index = SKILL_ORDER.indexOf(name);
|
|
44174
|
+
return index === -1 ? SKILL_ORDER.length : index;
|
|
44175
|
+
};
|
|
44176
|
+
const sortSkills = (skills) => {
|
|
44177
|
+
return [...skills].toSorted((a, b) => skillOrderIndex(a) - skillOrderIndex(b) || a.localeCompare(b));
|
|
44178
|
+
};
|
|
44179
|
+
const XY_SKILLS = ["xy-development", "xy-toolchain"];
|
|
44180
|
+
const XYO_SKILLS = ["xyo-knowledge"];
|
|
44181
|
+
const XL1_SKILLS = [
|
|
44182
|
+
"xl1-knowledge",
|
|
44183
|
+
"xl1-patterns",
|
|
44184
|
+
"xl1-testing"
|
|
44185
|
+
];
|
|
44186
|
+
const XL1_OPTIONAL_SKILLS = ["xl1-scaffold", "xl1-build"];
|
|
44187
|
+
const TIER_REQUIRED_SKILLS = {
|
|
44188
|
+
xy: XY_SKILLS,
|
|
44189
|
+
xyo: [...XY_SKILLS, ...XYO_SKILLS],
|
|
44190
|
+
xl1: [
|
|
44191
|
+
...XY_SKILLS,
|
|
44192
|
+
...XYO_SKILLS,
|
|
44193
|
+
...XL1_SKILLS
|
|
44194
|
+
]
|
|
44195
|
+
};
|
|
44196
|
+
const requiredSkillsForTier = (tier) => {
|
|
44197
|
+
if (tier === "none") return [];
|
|
44198
|
+
return TIER_REQUIRED_SKILLS[tier];
|
|
44199
|
+
};
|
|
44200
|
+
/**
|
|
44201
|
+
* Required skills for a detected repo profile.
|
|
44202
|
+
* Adds `ariestools-sdk` when the repo depends on or produces packages from ariestools/sdk-js.
|
|
44203
|
+
*/
|
|
44204
|
+
const requiredSkillsForProfile = (profile) => {
|
|
44205
|
+
const base = requiredSkillsForTier(profile.tier);
|
|
44206
|
+
if (!profile.isUsingAriestoolsSdk) return base;
|
|
44207
|
+
if (base.length === 0) return sortSkills([
|
|
44208
|
+
"xy-development",
|
|
44209
|
+
"xy-toolchain",
|
|
44210
|
+
"ariestools-sdk"
|
|
44211
|
+
]);
|
|
44212
|
+
if (base.includes("ariestools-sdk")) return base;
|
|
44213
|
+
return sortSkills([...base, "ariestools-sdk"]);
|
|
44214
|
+
};
|
|
44215
|
+
const optionalSkillsForTier = (tier) => {
|
|
44216
|
+
if (tier !== "xl1") return [];
|
|
44217
|
+
return XL1_OPTIONAL_SKILLS;
|
|
44218
|
+
};
|
|
44219
|
+
const isXyoSkillName = (name) => {
|
|
44220
|
+
return XYO_SKILL_NAMES.includes(name);
|
|
44221
|
+
};
|
|
44222
|
+
const unnecessarySkillsForProfile = (profile, installed) => {
|
|
44223
|
+
const required = new Set(requiredSkillsForProfile(profile));
|
|
44224
|
+
const optional = new Set(optionalSkillsForTier(profile.tier));
|
|
44225
|
+
return installed.filter(isXyoSkillName).filter((name) => !required.has(name) && !optional.has(name)).toSorted((a, b) => a.localeCompare(b));
|
|
44226
|
+
};
|
|
44227
|
+
//#endregion
|
|
44228
|
+
//#region src/actions/repo-init/skillsInstall.ts
|
|
44229
|
+
/**
|
|
44230
|
+
* Tier-scoped skills install plans for `xy repo init` (project-local).
|
|
44231
|
+
* Unlike `skills defaults`, this only installs skills needed for the chosen tier.
|
|
44232
|
+
*/
|
|
44233
|
+
function skillsInstallPlansForTier(tier, includeOptional) {
|
|
44234
|
+
if (tier === "none") return [];
|
|
44235
|
+
const required = [...requiredSkillsForTier(tier)];
|
|
44236
|
+
const optional = includeOptional ? [...optionalSkillsForTier(tier)] : [];
|
|
44237
|
+
const names = [.../* @__PURE__ */ new Set([...required, ...optional])];
|
|
44238
|
+
const ariestoolsNames = /* @__PURE__ */ new Set([
|
|
44239
|
+
"xy-development",
|
|
44240
|
+
"xy-toolchain",
|
|
44241
|
+
"ariestools-sdk"
|
|
44242
|
+
]);
|
|
44243
|
+
const ariestools = names.filter((name) => ariestoolsNames.has(name));
|
|
44244
|
+
const xyo = names.filter((name) => !ariestoolsNames.has(name));
|
|
44245
|
+
const plans = [];
|
|
44246
|
+
if (ariestools.length > 0) plans.push({
|
|
44247
|
+
selector: ariestools.flatMap((skill) => ["--skill", skill]),
|
|
44248
|
+
source: ARIESTOOLS_SKILLS_SOURCE
|
|
43541
44249
|
});
|
|
43542
|
-
if (
|
|
43543
|
-
|
|
43544
|
-
|
|
44250
|
+
if (xyo.length > 0) plans.push({
|
|
44251
|
+
selector: xyo.flatMap((skill) => ["--skill", skill]),
|
|
44252
|
+
source: XYO_SKILLS_SOURCE
|
|
44253
|
+
});
|
|
44254
|
+
return plans;
|
|
44255
|
+
}
|
|
44256
|
+
async function installSkillsForTier(projectDir, tier, includeOptional, isVerbose) {
|
|
44257
|
+
const plans = skillsInstallPlansForTier(tier, includeOptional);
|
|
44258
|
+
if (plans.length === 0) return 0;
|
|
44259
|
+
console.log(chalk.gray(`Installing skills for tier "${tier}"...`));
|
|
44260
|
+
for (const plan of plans) {
|
|
44261
|
+
if (isVerbose ?? false) console.log(chalk.gray(` skills add ${plan.source} ${plan.selector.join(" ")}`));
|
|
44262
|
+
const code = await runSkills([
|
|
44263
|
+
"add",
|
|
44264
|
+
plan.source,
|
|
44265
|
+
...plan.selector,
|
|
44266
|
+
"-y"
|
|
44267
|
+
], {
|
|
44268
|
+
cwd: projectDir,
|
|
44269
|
+
interactive: false
|
|
44270
|
+
});
|
|
44271
|
+
if (code !== 0) {
|
|
44272
|
+
console.warn(chalk.yellow(`Skills install failed for ${plan.source} (exit ${code})`));
|
|
44273
|
+
return code;
|
|
44274
|
+
}
|
|
44275
|
+
}
|
|
44276
|
+
console.log(chalk.green("Skills installed"));
|
|
44277
|
+
return 0;
|
|
44278
|
+
}
|
|
44279
|
+
//#endregion
|
|
44280
|
+
//#region src/actions/repo-init/index.ts
|
|
44281
|
+
async function repoInit(params) {
|
|
44282
|
+
const plan = await resolveRepoInitPlan(params);
|
|
44283
|
+
if (plan === void 0) return 1;
|
|
44284
|
+
const scaffolded = scaffoldProject(plan);
|
|
44285
|
+
if (scaffolded === void 0) return 1;
|
|
44286
|
+
const { projectDir } = scaffolded;
|
|
44287
|
+
const { installOk } = runPostScaffold(plan, projectDir);
|
|
44288
|
+
if (!installOk) return 1;
|
|
44289
|
+
if (plan.skillsTier !== "none") {
|
|
44290
|
+
if (plan.skipInstall) {
|
|
44291
|
+
console.log(chalk.yellow("Skipping skills install because --skip-install was set"));
|
|
44292
|
+
console.log(chalk.gray(" After install, run: xy skills lint --fix"));
|
|
44293
|
+
} else if (await installSkillsForTier(projectDir, plan.skillsTier, plan.skillsOptional, plan.isVerbose) !== 0) console.warn(chalk.yellow("Project was created but skills install failed"));
|
|
43545
44294
|
}
|
|
43546
|
-
const projectDir = PATH.resolve(process.cwd(), name);
|
|
43547
|
-
if (!didEnsureEmptyDir(projectDir, name)) return 1;
|
|
43548
|
-
const rootCount = scaffoldFiles(template, "root", projectDir, pm, variables, isVerbose);
|
|
43549
|
-
const pkgCount = scaffoldFiles(template, "package", PATH.resolve(projectDir, "packages", packageName), pm, variables, isVerbose);
|
|
43550
|
-
normalizeRootPackageJson(projectDir, pm);
|
|
43551
|
-
console.log(chalk.green(`Scaffolded ${rootCount + pkgCount} files into ${name}/`));
|
|
43552
|
-
if (!(skipGit ?? false)) initGitRepo(projectDir, isVerbose);
|
|
43553
|
-
if (!(skipInstall ?? false) && !didInstallDependencies(projectDir, pm)) return 1;
|
|
43554
44295
|
console.log("");
|
|
43555
|
-
console.log(chalk.cyan(`Project ${name} created successfully!`));
|
|
44296
|
+
console.log(chalk.cyan(`Project ${plan.name} created successfully!`));
|
|
43556
44297
|
console.log("");
|
|
43557
44298
|
console.log(chalk.gray("Next steps:"));
|
|
43558
|
-
console.log(chalk.gray(`
|
|
43559
|
-
if (skipInstall ?? false) console.log(chalk.gray(` ${pm} install`));
|
|
43560
|
-
console.log(chalk.gray(` ${renderXyCommand(pm, ["build"])}`));
|
|
44299
|
+
for (const line of renderNextSteps(plan)) console.log(chalk.gray(` ${line}`));
|
|
43561
44300
|
return 0;
|
|
43562
44301
|
}
|
|
43563
44302
|
//#endregion
|
|
@@ -49687,190 +50426,6 @@ function ruleCatalogResult(rules, title) {
|
|
|
49687
50426
|
};
|
|
49688
50427
|
}
|
|
49689
50428
|
//#endregion
|
|
49690
|
-
//#region src/actions/skills/passthrough.ts
|
|
49691
|
-
const ANSI_PREFIX = String.raw`\x1B\[[\d;]*m`;
|
|
49692
|
-
const COMMAND_PREFIX = String.raw`(^|[\s$()\x60>]|${ANSI_PREFIX})`;
|
|
49693
|
-
const SKILLS_COMMANDS = [
|
|
49694
|
-
"<command>",
|
|
49695
|
-
"add",
|
|
49696
|
-
"a",
|
|
49697
|
-
"use",
|
|
49698
|
-
"remove",
|
|
49699
|
-
"rm",
|
|
49700
|
-
"list",
|
|
49701
|
-
"ls",
|
|
49702
|
-
"find",
|
|
49703
|
-
"update",
|
|
49704
|
-
"upgrade",
|
|
49705
|
-
"experimental_install",
|
|
49706
|
-
"init",
|
|
49707
|
-
"experimental_sync",
|
|
49708
|
-
"defaults",
|
|
49709
|
-
"lint",
|
|
49710
|
-
"updo"
|
|
49711
|
-
].join("|");
|
|
49712
|
-
const NPX_SKILLS_PATTERN = new RegExp(String.raw`${COMMAND_PREFIX}npx(?:\s+-y)?\s+skills(?:@latest)?(?=\W|$)`, "g");
|
|
49713
|
-
const BARE_USAGE_SKILLS_PATTERN = new RegExp(String.raw`^(\s*(?:${ANSI_PREFIX})*Usage:(?:${ANSI_PREFIX})*\s*)skills(?=\s+<command>)`, "gm");
|
|
49714
|
-
const BARE_PROMPT_SKILLS_PATTERN = new RegExp(String.raw`^(\s*(?:${ANSI_PREFIX})*\$(?:${ANSI_PREFIX})*\s*)skills(?=\s+(?:${SKILLS_COMMANDS})(?:\W|$))`, "gm");
|
|
49715
|
-
const require$3 = createRequire(import.meta.url);
|
|
49716
|
-
const YES_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes"]);
|
|
49717
|
-
const SCOPE_FLAGS$1 = /* @__PURE__ */ new Set([
|
|
49718
|
-
"-g",
|
|
49719
|
-
"--global",
|
|
49720
|
-
"-p",
|
|
49721
|
-
"--project"
|
|
49722
|
-
]);
|
|
49723
|
-
const INTERACTIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
49724
|
-
"add",
|
|
49725
|
-
"a",
|
|
49726
|
-
"experimental_sync",
|
|
49727
|
-
"find",
|
|
49728
|
-
"remove",
|
|
49729
|
-
"rm",
|
|
49730
|
-
"update",
|
|
49731
|
-
"upgrade"
|
|
49732
|
-
]);
|
|
49733
|
-
const skillsPositionalArgs = (args) => {
|
|
49734
|
-
return args.filter((arg) => !arg.startsWith("-"));
|
|
49735
|
-
};
|
|
49736
|
-
const hasSkillsFlag = (args, flags) => {
|
|
49737
|
-
return args.some((arg) => flags.has(arg));
|
|
49738
|
-
};
|
|
49739
|
-
const needsSkillsInteractive = (args) => {
|
|
49740
|
-
const [command, ...tail] = args;
|
|
49741
|
-
if (command === void 0 || !INTERACTIVE_COMMANDS.has(command)) return false;
|
|
49742
|
-
switch (command) {
|
|
49743
|
-
case "update":
|
|
49744
|
-
case "upgrade": return !hasSkillsFlag(tail, SCOPE_FLAGS$1) && !hasSkillsFlag(tail, YES_FLAGS) && skillsPositionalArgs(tail).length === 0;
|
|
49745
|
-
case "add":
|
|
49746
|
-
case "a":
|
|
49747
|
-
case "experimental_sync": return !hasSkillsFlag(tail, YES_FLAGS);
|
|
49748
|
-
case "remove":
|
|
49749
|
-
case "rm": return !hasSkillsFlag(tail, YES_FLAGS) && skillsPositionalArgs(tail).length === 0;
|
|
49750
|
-
case "find": return skillsPositionalArgs(tail).length === 0;
|
|
49751
|
-
default: return false;
|
|
49752
|
-
}
|
|
49753
|
-
};
|
|
49754
|
-
const rewriteSkillsRefs = (text) => {
|
|
49755
|
-
return text.replaceAll(NPX_SKILLS_PATTERN, (_match, prefix) => `${prefix}xy skills`).replaceAll(BARE_USAGE_SKILLS_PATTERN, "$1xy skills").replaceAll(BARE_PROMPT_SKILLS_PATTERN, "$1xy skills");
|
|
49756
|
-
};
|
|
49757
|
-
const resolveBundledSkillsCli = () => {
|
|
49758
|
-
return resolvePublishedOrDevCli("skills.mjs", () => require$3.resolve("skills/bin/cli.mjs"));
|
|
49759
|
-
};
|
|
49760
|
-
const resolveSkillsInvocation = async (args, options = {}) => {
|
|
49761
|
-
const resolveCli = options.resolveBundledCli ?? resolveBundledSkillsCli;
|
|
49762
|
-
const writeNotice = options.writeNotice ?? ((message) => console.error(message));
|
|
49763
|
-
try {
|
|
49764
|
-
return {
|
|
49765
|
-
args: [resolveCli(), ...args],
|
|
49766
|
-
command: process.execPath,
|
|
49767
|
-
fallback: false
|
|
49768
|
-
};
|
|
49769
|
-
} catch {
|
|
49770
|
-
writeNotice(chalk.red("skills package not found. Reinstall @ariestools/toolchain dependencies."));
|
|
49771
|
-
return;
|
|
49772
|
-
}
|
|
49773
|
-
};
|
|
49774
|
-
const runSkills = async (args, options = {}) => {
|
|
49775
|
-
const invocation = await resolveSkillsInvocation(args, options);
|
|
49776
|
-
if (invocation === void 0) return 1;
|
|
49777
|
-
const isInteractive = options.interactive ?? (process.stdin.isTTY && needsSkillsInteractive(args));
|
|
49778
|
-
const stdio = isInteractive ? "inherit" : [
|
|
49779
|
-
"inherit",
|
|
49780
|
-
"pipe",
|
|
49781
|
-
"pipe"
|
|
49782
|
-
];
|
|
49783
|
-
return new Promise((resolve) => {
|
|
49784
|
-
const child = spawn$1(invocation.command, invocation.args, {
|
|
49785
|
-
env: {
|
|
49786
|
-
FORCE_COLOR: "3",
|
|
49787
|
-
...process.env
|
|
49788
|
-
},
|
|
49789
|
-
stdio
|
|
49790
|
-
});
|
|
49791
|
-
if (!isInteractive) {
|
|
49792
|
-
child.stdout?.setEncoding("utf8");
|
|
49793
|
-
child.stderr?.setEncoding("utf8");
|
|
49794
|
-
child.stdout?.on("data", (chunk) => {
|
|
49795
|
-
process.stdout.write(rewriteSkillsRefs(chunk));
|
|
49796
|
-
});
|
|
49797
|
-
child.stderr?.on("data", (chunk) => {
|
|
49798
|
-
process.stderr.write(rewriteSkillsRefs(chunk));
|
|
49799
|
-
});
|
|
49800
|
-
}
|
|
49801
|
-
child.on("error", () => resolve(1));
|
|
49802
|
-
child.on("close", (code) => resolve(code ?? 1));
|
|
49803
|
-
});
|
|
49804
|
-
};
|
|
49805
|
-
const argvAfterCommand = (command) => {
|
|
49806
|
-
const argv = process.argv;
|
|
49807
|
-
const commandIdx = argv.indexOf(command);
|
|
49808
|
-
if (commandIdx === -1) return [];
|
|
49809
|
-
return argv.slice(commandIdx + 1);
|
|
49810
|
-
};
|
|
49811
|
-
//#endregion
|
|
49812
|
-
//#region src/actions/skills/defaults.ts
|
|
49813
|
-
/**
|
|
49814
|
-
Source of truth for xy-development, xy-toolchain, and ariestools-sdk.
|
|
49815
|
-
*/
|
|
49816
|
-
const ARIESTOOLS_SKILLS_SOURCE = "ariestools/ariestools-skills";
|
|
49817
|
-
/**
|
|
49818
|
-
Source of truth for xyo-knowledge and xl1-* skills.
|
|
49819
|
-
*/
|
|
49820
|
-
const XYO_SKILLS_SOURCE = "XYOracleNetwork/xyo-skills";
|
|
49821
|
-
const ARIESTOOLS_SKILLS = [
|
|
49822
|
-
"ariestools-sdk",
|
|
49823
|
-
"xy-development",
|
|
49824
|
-
"xy-toolchain"
|
|
49825
|
-
];
|
|
49826
|
-
const XYO_STACK_SKILLS = [
|
|
49827
|
-
"xl1-build",
|
|
49828
|
-
"xl1-knowledge",
|
|
49829
|
-
"xl1-patterns",
|
|
49830
|
-
"xl1-scaffold",
|
|
49831
|
-
"xl1-testing",
|
|
49832
|
-
"xyo-knowledge"
|
|
49833
|
-
];
|
|
49834
|
-
/**
|
|
49835
|
-
All skills managed by `xy skills` conveniences (both sources).
|
|
49836
|
-
*/
|
|
49837
|
-
const XYO_DEFAULT_SKILLS = [...ARIESTOOLS_SKILLS, ...XYO_STACK_SKILLS];
|
|
49838
|
-
const AGENT_FLAGS = /* @__PURE__ */ new Set(["-a", "--agent"]);
|
|
49839
|
-
const hasSkillsAgentFlag = (args) => {
|
|
49840
|
-
return args.some((arg) => AGENT_FLAGS.has(arg) || arg.startsWith("--agent="));
|
|
49841
|
-
};
|
|
49842
|
-
/**
|
|
49843
|
-
* Returns install argument plans for `xy skills defaults`.
|
|
49844
|
-
* Aries Tools base skills install from ariestools-skills; XYO/XL1 skills from xyo-skills.
|
|
49845
|
-
*/
|
|
49846
|
-
const skillsDefaultsInstallPlans = (args) => {
|
|
49847
|
-
const installSelector = hasSkillsAgentFlag(args) ? ["--skill", "*"] : ["--all"];
|
|
49848
|
-
const xyoSelector = XYO_STACK_SKILLS.flatMap((skill) => ["--skill", skill]);
|
|
49849
|
-
return [{
|
|
49850
|
-
selector: installSelector,
|
|
49851
|
-
source: ARIESTOOLS_SKILLS_SOURCE
|
|
49852
|
-
}, {
|
|
49853
|
-
selector: xyoSelector,
|
|
49854
|
-
source: XYO_SKILLS_SOURCE
|
|
49855
|
-
}];
|
|
49856
|
-
};
|
|
49857
|
-
const skillSourceForName = (skillName) => {
|
|
49858
|
-
if (ARIESTOOLS_SKILLS.includes(skillName)) return ARIESTOOLS_SKILLS_SOURCE;
|
|
49859
|
-
return XYO_SKILLS_SOURCE;
|
|
49860
|
-
};
|
|
49861
|
-
const skillsDefaults = async (args) => {
|
|
49862
|
-
for (const plan of skillsDefaultsInstallPlans(args)) {
|
|
49863
|
-
const code = await runSkills([
|
|
49864
|
-
"add",
|
|
49865
|
-
plan.source,
|
|
49866
|
-
...plan.selector,
|
|
49867
|
-
...args
|
|
49868
|
-
]);
|
|
49869
|
-
if (code !== 0) return code;
|
|
49870
|
-
}
|
|
49871
|
-
return 0;
|
|
49872
|
-
};
|
|
49873
|
-
//#endregion
|
|
49874
50429
|
//#region src/actions/skills/detectProfile.ts
|
|
49875
50430
|
const XYLABS_SCOPE = "@xylabs/";
|
|
49876
50431
|
const ARIESTOOLS_SCOPE = "@ariestools/";
|
|
@@ -50071,75 +50626,6 @@ const listSkillDirsAt = (root) => {
|
|
|
50071
50626
|
return listSkillDirs(root);
|
|
50072
50627
|
};
|
|
50073
50628
|
//#endregion
|
|
50074
|
-
//#region src/actions/skills/skillRules.ts
|
|
50075
|
-
const XYO_SKILL_NAMES = [...XYO_DEFAULT_SKILLS];
|
|
50076
|
-
const SKILL_ORDER = [
|
|
50077
|
-
"xy-development",
|
|
50078
|
-
"xy-toolchain",
|
|
50079
|
-
"ariestools-sdk",
|
|
50080
|
-
"xyo-knowledge",
|
|
50081
|
-
"xl1-knowledge",
|
|
50082
|
-
"xl1-patterns",
|
|
50083
|
-
"xl1-testing",
|
|
50084
|
-
"xl1-scaffold",
|
|
50085
|
-
"xl1-build"
|
|
50086
|
-
];
|
|
50087
|
-
const skillOrderIndex = (name) => {
|
|
50088
|
-
const index = SKILL_ORDER.indexOf(name);
|
|
50089
|
-
return index === -1 ? SKILL_ORDER.length : index;
|
|
50090
|
-
};
|
|
50091
|
-
const sortSkills = (skills) => {
|
|
50092
|
-
return [...skills].toSorted((a, b) => skillOrderIndex(a) - skillOrderIndex(b) || a.localeCompare(b));
|
|
50093
|
-
};
|
|
50094
|
-
const XY_SKILLS = ["xy-development", "xy-toolchain"];
|
|
50095
|
-
const XYO_SKILLS = ["xyo-knowledge"];
|
|
50096
|
-
const XL1_SKILLS = [
|
|
50097
|
-
"xl1-knowledge",
|
|
50098
|
-
"xl1-patterns",
|
|
50099
|
-
"xl1-testing"
|
|
50100
|
-
];
|
|
50101
|
-
const XL1_OPTIONAL_SKILLS = ["xl1-scaffold", "xl1-build"];
|
|
50102
|
-
const TIER_REQUIRED_SKILLS = {
|
|
50103
|
-
xy: XY_SKILLS,
|
|
50104
|
-
xyo: [...XY_SKILLS, ...XYO_SKILLS],
|
|
50105
|
-
xl1: [
|
|
50106
|
-
...XY_SKILLS,
|
|
50107
|
-
...XYO_SKILLS,
|
|
50108
|
-
...XL1_SKILLS
|
|
50109
|
-
]
|
|
50110
|
-
};
|
|
50111
|
-
const requiredSkillsForTier = (tier) => {
|
|
50112
|
-
if (tier === "none") return [];
|
|
50113
|
-
return TIER_REQUIRED_SKILLS[tier];
|
|
50114
|
-
};
|
|
50115
|
-
/**
|
|
50116
|
-
* Required skills for a detected repo profile.
|
|
50117
|
-
* Adds `ariestools-sdk` when the repo depends on or produces packages from ariestools/sdk-js.
|
|
50118
|
-
*/
|
|
50119
|
-
const requiredSkillsForProfile = (profile) => {
|
|
50120
|
-
const base = requiredSkillsForTier(profile.tier);
|
|
50121
|
-
if (!profile.isUsingAriestoolsSdk) return base;
|
|
50122
|
-
if (base.length === 0) return sortSkills([
|
|
50123
|
-
"xy-development",
|
|
50124
|
-
"xy-toolchain",
|
|
50125
|
-
"ariestools-sdk"
|
|
50126
|
-
]);
|
|
50127
|
-
if (base.includes("ariestools-sdk")) return base;
|
|
50128
|
-
return sortSkills([...base, "ariestools-sdk"]);
|
|
50129
|
-
};
|
|
50130
|
-
const optionalSkillsForTier = (tier) => {
|
|
50131
|
-
if (tier !== "xl1") return [];
|
|
50132
|
-
return XL1_OPTIONAL_SKILLS;
|
|
50133
|
-
};
|
|
50134
|
-
const isXyoSkillName = (name) => {
|
|
50135
|
-
return XYO_SKILL_NAMES.includes(name);
|
|
50136
|
-
};
|
|
50137
|
-
const unnecessarySkillsForProfile = (profile, installed) => {
|
|
50138
|
-
const required = new Set(requiredSkillsForProfile(profile));
|
|
50139
|
-
const optional = new Set(optionalSkillsForTier(profile.tier));
|
|
50140
|
-
return installed.filter(isXyoSkillName).filter((name) => !required.has(name) && !optional.has(name)).toSorted((a, b) => a.localeCompare(b));
|
|
50141
|
-
};
|
|
50142
|
-
//#endregion
|
|
50143
50629
|
//#region src/actions/skills/versions.ts
|
|
50144
50630
|
const VERSION_PATTERN = /metadata:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+version:\s*([^\s#]+)/;
|
|
50145
50631
|
const upstreamSkillUrl = (skillName) => {
|
|
@@ -53345,20 +53831,26 @@ const packmanCommand = {
|
|
|
53345
53831
|
};
|
|
53346
53832
|
//#endregion
|
|
53347
53833
|
//#region src/xy/common/repo/initCommand.ts
|
|
53834
|
+
const templates = (() => {
|
|
53835
|
+
try {
|
|
53836
|
+
return listRepoTemplates();
|
|
53837
|
+
} catch {
|
|
53838
|
+
return ["cli"];
|
|
53839
|
+
}
|
|
53840
|
+
})();
|
|
53348
53841
|
const initCommand$2 = {
|
|
53349
|
-
command: "init
|
|
53350
|
-
describe: "Scaffold a new
|
|
53842
|
+
command: "init [template] [name]",
|
|
53843
|
+
describe: "Scaffold a new repo from a template (interactive when template is omitted)",
|
|
53351
53844
|
builder: (yargs) => {
|
|
53352
53845
|
return yargs.positional("template", {
|
|
53353
|
-
choices:
|
|
53354
|
-
describe: "Template to use",
|
|
53846
|
+
choices: templates.length > 0 ? templates : void 0,
|
|
53847
|
+
describe: "Template to use (omit to answer setup questions)",
|
|
53355
53848
|
type: "string"
|
|
53356
53849
|
}).positional("name", {
|
|
53357
53850
|
describe: "Project name (also used as directory name)",
|
|
53358
53851
|
type: "string"
|
|
53359
53852
|
}).option("scope", {
|
|
53360
|
-
default:
|
|
53361
|
-
describe: "npm scope for packages",
|
|
53853
|
+
describe: "npm scope for packages (default: @xylabs; wizard may prompt)",
|
|
53362
53854
|
type: "string"
|
|
53363
53855
|
}).option("package", {
|
|
53364
53856
|
describe: "Package name within the monorepo (defaults to project name)",
|
|
@@ -53377,9 +53869,31 @@ const initCommand$2 = {
|
|
|
53377
53869
|
"pnpm",
|
|
53378
53870
|
"yarn"
|
|
53379
53871
|
],
|
|
53380
|
-
default:
|
|
53381
|
-
|
|
53872
|
+
describe: "Package manager to configure (default: pnpm)",
|
|
53873
|
+
type: "string"
|
|
53874
|
+
}).option("monorepo", {
|
|
53875
|
+
describe: "Scaffold as a monorepo with packages/* (default: true)",
|
|
53876
|
+
type: "boolean"
|
|
53877
|
+
}).option("react", {
|
|
53878
|
+
describe: "Use React ESLint/tsconfig packages (default: false)",
|
|
53879
|
+
type: "boolean"
|
|
53880
|
+
}).option("skills-tier", {
|
|
53881
|
+
choices: [
|
|
53882
|
+
"none",
|
|
53883
|
+
"xy",
|
|
53884
|
+
"xyo",
|
|
53885
|
+
"xl1"
|
|
53886
|
+
],
|
|
53887
|
+
describe: "Agent skills to install after scaffold (wizard default: xy)",
|
|
53382
53888
|
type: "string"
|
|
53889
|
+
}).option("skills-optional", {
|
|
53890
|
+
describe: "Include optional XL1 skills (scaffold/build) when skills-tier is xl1",
|
|
53891
|
+
type: "boolean"
|
|
53892
|
+
}).option("yes", {
|
|
53893
|
+
alias: "y",
|
|
53894
|
+
default: false,
|
|
53895
|
+
describe: "Accept defaults for omitted wizard questions (name still required)",
|
|
53896
|
+
type: "boolean"
|
|
53383
53897
|
}).option("skip-install", {
|
|
53384
53898
|
default: false,
|
|
53385
53899
|
describe: "Skip dependency installation after scaffolding",
|
|
@@ -53395,14 +53909,19 @@ const initCommand$2 = {
|
|
|
53395
53909
|
await withEnvelope("repo init", () => repoInit({
|
|
53396
53910
|
description: argv.description,
|
|
53397
53911
|
githubOrg: argv["github-org"],
|
|
53912
|
+
isVerbose: Boolean(argv.verbose),
|
|
53913
|
+
monorepo: argv.monorepo,
|
|
53398
53914
|
name: argv.name,
|
|
53399
53915
|
packageName: argv.package,
|
|
53400
53916
|
pm: argv.pm,
|
|
53917
|
+
react: argv.react,
|
|
53401
53918
|
scope: argv.scope,
|
|
53402
|
-
skipGit:
|
|
53403
|
-
skipInstall:
|
|
53919
|
+
skipGit: Boolean(argv.skipGit),
|
|
53920
|
+
skipInstall: Boolean(argv.skipInstall),
|
|
53921
|
+
skillsOptional: argv["skills-optional"],
|
|
53922
|
+
skillsTier: argv["skills-tier"],
|
|
53404
53923
|
template: argv.template,
|
|
53405
|
-
|
|
53924
|
+
yes: Boolean(argv.yes)
|
|
53406
53925
|
}));
|
|
53407
53926
|
}
|
|
53408
53927
|
};
|