@chris-lally/cli 0.1.0-alpha.29 → 0.1.0-alpha.35

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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2026 Christopher Lally (https://github.com/chrislally)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -6,11 +6,17 @@ CLI for `@chris-lally/cli`.
6
6
 
7
7
  ## Install
8
8
 
9
+ ### Prerequisites
10
+
11
+ - Node.js 20+
12
+ - npm 10+ (or pnpm/yarn/bun)
13
+ - git (for sync workflows)
14
+
9
15
  ```bash
10
16
  pnpm add -D @chris-lally/cli
11
17
  ```
12
18
 
13
- or run with `pnpm dlx`:
19
+ or run without install:
14
20
 
15
21
  ```bash
16
22
  pnpm dlx @chris-lally/cli@alpha --help
package/dist/bin/lally.js CHANGED
@@ -148,8 +148,8 @@ echo "Ensured database exists: $DB_NAME"
148
148
  const scripts = packageJson.scripts ?? {};
149
149
  scripts["db:create:local"] = scripts["db:create:local"] ?? "dotenv -e .env -- bash ./db/scripts/create-local-db.sh";
150
150
  scripts["db:migrate:local"] = scripts["db:migrate:local"] ?? `dotenv -e .env -- sh -c 'psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f db/migrations/tables.sql'`;
151
- scripts["db:reset:local"] = scripts["db:reset:local"] ?? `dotenv -e .env -- sh -c 'psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"' && pnpm run db:migrate:local`;
152
- scripts["db:setup:local"] = scripts["db:setup:local"] ?? "pnpm run db:create:local && pnpm run db:migrate:local";
151
+ scripts["db:reset:local"] = scripts["db:reset:local"] ?? `dotenv -e .env -- sh -c 'psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"' && npm run db:migrate:local`;
152
+ scripts["db:setup:local"] = scripts["db:setup:local"] ?? "npm run db:create:local && npm run db:migrate:local";
153
153
  packageJson.scripts = scripts;
154
154
  const devDependencies = packageJson.devDependencies ?? {};
155
155
  if (!devDependencies["dotenv-cli"])
@@ -201,7 +201,7 @@ echo "Seed complete"
201
201
  if (packageJson) {
202
202
  const scripts = packageJson.scripts ?? {};
203
203
  scripts["db:seed:local"] = scripts["db:seed:local"] ?? "dotenv -e .env -- bash ./db/scripts/seed-local.sh";
204
- scripts["db:setup-and-seed:local"] = scripts["db:setup-and-seed:local"] ?? "pnpm run db:setup:local && pnpm run db:seed:local";
204
+ scripts["db:setup-and-seed:local"] = scripts["db:setup-and-seed:local"] ?? "npm run db:setup:local && npm run db:seed:local";
205
205
  packageJson.scripts = scripts;
206
206
  const devDependencies = packageJson.devDependencies ?? {};
207
207
  if (!devDependencies["dotenv-cli"])
@@ -553,9 +553,11 @@ export default [];
553
553
  (0, exec_1.ensureOk)((0, exec_1.runCommand)("bash", ["-lc", `rsync -a --delete --exclude ".git/" "${exportedPrefix}/" "${cloneDir}/"`], repoRoot), "rsync snapshot");
554
554
  await normalizeStandalonePackage(cloneDir, target.remoteUrl);
555
555
  if (releaseVersion) {
556
+ const packageJsonRelativePath = target.versionPath ?? "package.json";
557
+ const packageJsonPath = (0, node_path_1.resolve)(cloneDir, packageJsonRelativePath);
556
558
  const setVersion = (0, exec_1.runCommand)("node", [
557
559
  "-e",
558
- `const fs=require('fs');const p='${cloneDir.replaceAll("'", "'\\''")}/package.json';const v='${releaseVersion}';const j=JSON.parse(fs.readFileSync(p,'utf8'));j.version=v;fs.writeFileSync(p,JSON.stringify(j,null,2)+'\\n');`
560
+ `const fs=require('fs');const p='${packageJsonPath.replaceAll("'", "'\\''")}';const v='${releaseVersion}';const j=JSON.parse(fs.readFileSync(p,'utf8'));j.version=v;fs.writeFileSync(p,JSON.stringify(j,null,2)+'\\n');`
559
561
  ], repoRoot);
560
562
  (0, exec_1.ensureOk)(setVersion, "set package version");
561
563
  }
@@ -680,7 +682,11 @@ var require_handlers = __commonJS({
680
682
  throw new Error(`Unsupported package version for alpha release: ${current}`);
681
683
  }
682
684
  async function resolveVersionTarget(repoRoot, target) {
683
- const candidates = [(0, node_path_1.resolve)(repoRoot, target.prefix, "packages/cli/package.json"), (0, node_path_1.resolve)(repoRoot, target.prefix, "package.json")];
685
+ const candidates = [
686
+ ...target.versionPath ? [(0, node_path_1.resolve)(repoRoot, target.prefix, target.versionPath)] : [],
687
+ (0, node_path_1.resolve)(repoRoot, target.prefix, "packages/cli/package.json"),
688
+ (0, node_path_1.resolve)(repoRoot, target.prefix, "package.json")
689
+ ];
684
690
  for (const packageJsonPath of candidates) {
685
691
  if (!(0, node_fs_1.existsSync)(packageJsonPath))
686
692
  continue;
@@ -1214,11 +1220,17 @@ CLI for \`${params.packageName}\`.
1214
1220
 
1215
1221
  ## Install
1216
1222
 
1223
+ ### Prerequisites
1224
+
1225
+ - Node.js 20+
1226
+ - npm 10+ (or pnpm/yarn/bun)
1227
+ - git (for sync workflows)
1228
+
1217
1229
  \`\`\`bash
1218
1230
  pnpm add -D ${params.packageName}
1219
1231
  \`\`\`
1220
1232
 
1221
- or run with \`pnpm dlx\`:
1233
+ or run without install:
1222
1234
 
1223
1235
  \`\`\`bash
1224
1236
  pnpm dlx ${params.packageName}@alpha --help
@@ -2882,6 +2894,54 @@ var require_commands4 = __commonJS({
2882
2894
  Object.defineProperty(exports2, "__esModule", { value: true });
2883
2895
  exports2.runOpensrcCommand = runOpensrcCommand2;
2884
2896
  var node_child_process_1 = require("child_process");
2897
+ function hasCommand(command) {
2898
+ try {
2899
+ const result = (0, node_child_process_1.spawnSync)(command, ["--version"], { stdio: "ignore", env: process.env });
2900
+ return result.status === 0 && !result.error;
2901
+ } catch {
2902
+ return false;
2903
+ }
2904
+ }
2905
+ function resolveOpenSrcRunner() {
2906
+ const forced = (process.env.LALLY_PM ?? "").trim().toLowerCase();
2907
+ if (forced === "pnpm" && hasCommand("pnpm"))
2908
+ return { command: "pnpm", prefixArgs: ["dlx", "opensrc"] };
2909
+ if (forced === "npm" && hasCommand("npm"))
2910
+ return { command: "npm", prefixArgs: ["exec", "--yes", "opensrc"] };
2911
+ if (forced === "yarn" && hasCommand("yarn"))
2912
+ return { command: "yarn", prefixArgs: ["dlx", "opensrc"] };
2913
+ if (forced === "bun" && hasCommand("bunx"))
2914
+ return { command: "bunx", prefixArgs: ["opensrc"] };
2915
+ if (forced)
2916
+ throw new Error(`LALLY_PM is set to '${forced}', but the command is not available.`);
2917
+ if (hasCommand("pnpm"))
2918
+ return { command: "pnpm", prefixArgs: ["dlx", "opensrc"] };
2919
+ if (hasCommand("npm"))
2920
+ return { command: "npm", prefixArgs: ["exec", "--yes", "opensrc"] };
2921
+ if (hasCommand("yarn"))
2922
+ return { command: "yarn", prefixArgs: ["dlx", "opensrc"] };
2923
+ if (hasCommand("bunx"))
2924
+ return { command: "bunx", prefixArgs: ["opensrc"] };
2925
+ throw new Error("No supported package manager runtime found. Install pnpm, npm, yarn, or bun.");
2926
+ }
2927
+ function parseModifyFlag(argv) {
2928
+ for (let i = 0; i < argv.length; i += 1) {
2929
+ const token = argv[i];
2930
+ if (!token)
2931
+ continue;
2932
+ if (token === "--modify") {
2933
+ const next = argv[i + 1];
2934
+ if (next && !next.startsWith("--")) {
2935
+ return next;
2936
+ }
2937
+ return true;
2938
+ }
2939
+ if (token.startsWith("--modify=")) {
2940
+ return token.slice("--modify=".length);
2941
+ }
2942
+ }
2943
+ return void 0;
2944
+ }
2885
2945
  function getPositionalArgs(argv) {
2886
2946
  const positional = [];
2887
2947
  for (let i = 0; i < argv.length; i += 1) {
@@ -2889,6 +2949,12 @@ var require_commands4 = __commonJS({
2889
2949
  if (!token)
2890
2950
  continue;
2891
2951
  if (token.startsWith("--")) {
2952
+ if (token === "--modify" || token.startsWith("--modify=")) {
2953
+ const next2 = argv[i + 1];
2954
+ if (token === "--modify" && next2 && !next2.startsWith("--"))
2955
+ i += 1;
2956
+ continue;
2957
+ }
2892
2958
  if (token.includes("="))
2893
2959
  continue;
2894
2960
  const next = argv[i + 1];
@@ -2903,6 +2969,8 @@ var require_commands4 = __commonJS({
2903
2969
  function runOpensrc(commandArgs, modifyFlag) {
2904
2970
  if (modifyFlag === true) {
2905
2971
  commandArgs.push("--modify");
2972
+ } else if (modifyFlag === false) {
2973
+ commandArgs.push("--modify=false");
2906
2974
  } else if (typeof modifyFlag === "string") {
2907
2975
  const normalized = modifyFlag.trim().toLowerCase();
2908
2976
  if (normalized === "true" || normalized === "false") {
@@ -2911,23 +2979,25 @@ var require_commands4 = __commonJS({
2911
2979
  throw new Error("Invalid --modify value. Use --modify, --modify=true, or --modify=false.");
2912
2980
  }
2913
2981
  }
2914
- const result = (0, node_child_process_1.spawnSync)("pnpm", commandArgs, {
2982
+ const runner = resolveOpenSrcRunner();
2983
+ const result = (0, node_child_process_1.spawnSync)(runner.command, [...runner.prefixArgs, ...commandArgs], {
2915
2984
  cwd: process.cwd(),
2916
2985
  env: process.env,
2917
2986
  stdio: "inherit"
2918
2987
  });
2919
2988
  if (result.error) {
2920
- throw new Error(`Failed to run opensrc via pnpm dlx: ${result.error.message}`);
2989
+ throw new Error(`Failed to run opensrc: ${result.error.message}`);
2921
2990
  }
2922
2991
  if (result.status !== 0) {
2923
2992
  throw new Error(`opensrc exited with status ${result.status ?? 1}`);
2924
2993
  }
2925
2994
  }
2926
2995
  function runOpensrcCommand2(argsAfterItem, modifyFlag) {
2996
+ const effectiveModifyFlag = modifyFlag ?? parseModifyFlag(argsAfterItem) ?? false;
2927
2997
  const positional = getPositionalArgs(argsAfterItem);
2928
2998
  const first = positional[0];
2929
2999
  if (first === "list") {
2930
- runOpensrc(["dlx", "opensrc", "list"], modifyFlag);
3000
+ runOpensrc(["list"], effectiveModifyFlag);
2931
3001
  return;
2932
3002
  }
2933
3003
  if (first === "remove") {
@@ -2935,13 +3005,13 @@ var require_commands4 = __commonJS({
2935
3005
  if (targets.length === 0) {
2936
3006
  throw new Error("Missing remove target(s). Usage: lally opensrc remove <target...>");
2937
3007
  }
2938
- runOpensrc(["dlx", "opensrc", "remove", ...targets], modifyFlag);
3008
+ runOpensrc(["remove", ...targets], effectiveModifyFlag);
2939
3009
  return;
2940
3010
  }
2941
3011
  if (positional.length === 0) {
2942
3012
  throw new Error("Missing opensrc target(s). Usage: lally opensrc fetch <target...> | lally opensrc list | lally opensrc remove <target...>");
2943
3013
  }
2944
- runOpensrc(["dlx", "opensrc", ...positional], modifyFlag);
3014
+ runOpensrc([...positional], effectiveModifyFlag);
2945
3015
  }
2946
3016
  }
2947
3017
  });
@@ -3159,6 +3229,84 @@ var require_exec2 = __commonJS({
3159
3229
  }
3160
3230
  });
3161
3231
 
3232
+ // ../npm/dist/commands/release/package-manager.js
3233
+ var require_package_manager = __commonJS({
3234
+ "../npm/dist/commands/release/package-manager.js"(exports2) {
3235
+ "use strict";
3236
+ Object.defineProperty(exports2, "__esModule", { value: true });
3237
+ exports2.resolvePackageManager = resolvePackageManager;
3238
+ exports2.formatRunScriptCommand = formatRunScriptCommand;
3239
+ exports2.runPackageScript = runPackageScript;
3240
+ var node_fs_1 = require("fs");
3241
+ var node_path_1 = require("path");
3242
+ var node_child_process_1 = require("child_process");
3243
+ var exec_1 = require_exec2();
3244
+ var PREFERRED_ORDER = ["pnpm", "npm", "yarn", "bun"];
3245
+ function hasCommand(command) {
3246
+ try {
3247
+ const child = (0, node_child_process_1.spawnSync)(command, ["--version"], {
3248
+ stdio: "ignore",
3249
+ env: process.env
3250
+ });
3251
+ return child.status === 0 && !child.error;
3252
+ } catch {
3253
+ return false;
3254
+ }
3255
+ }
3256
+ function resolvePreferredByLockfile(repoRoot) {
3257
+ if ((0, node_fs_1.existsSync)((0, node_path_1.resolve)(repoRoot, "pnpm-lock.yaml")))
3258
+ return "pnpm";
3259
+ if ((0, node_fs_1.existsSync)((0, node_path_1.resolve)(repoRoot, "package-lock.json")))
3260
+ return "npm";
3261
+ if ((0, node_fs_1.existsSync)((0, node_path_1.resolve)(repoRoot, "yarn.lock")))
3262
+ return "yarn";
3263
+ if ((0, node_fs_1.existsSync)((0, node_path_1.resolve)(repoRoot, "bun.lockb")) || (0, node_fs_1.existsSync)((0, node_path_1.resolve)(repoRoot, "bun.lock")))
3264
+ return "bun";
3265
+ return null;
3266
+ }
3267
+ function resolvePackageManager(repoRoot) {
3268
+ const forced = (process.env.LALLY_PM ?? "").trim().toLowerCase();
3269
+ if (forced === "pnpm" || forced === "npm" || forced === "yarn" || forced === "bun") {
3270
+ if (hasCommand(forced))
3271
+ return forced;
3272
+ throw new Error(`LALLY_PM is set to '${forced}', but that command is not available.`);
3273
+ }
3274
+ const fromLockfile = resolvePreferredByLockfile(repoRoot);
3275
+ if (fromLockfile && hasCommand(fromLockfile))
3276
+ return fromLockfile;
3277
+ for (const candidate of PREFERRED_ORDER) {
3278
+ if (hasCommand(candidate))
3279
+ return candidate;
3280
+ }
3281
+ throw new Error("No supported package manager found. Install one of: pnpm, npm, yarn, bun.");
3282
+ }
3283
+ function formatRunScriptCommand(pm, script, cwd) {
3284
+ if (pm === "pnpm")
3285
+ return `pnpm --dir ${cwd} run ${script}`;
3286
+ if (pm === "npm")
3287
+ return `npm --prefix ${cwd} run ${script}`;
3288
+ if (pm === "yarn")
3289
+ return `yarn --cwd ${cwd} run ${script}`;
3290
+ return `bun run ${script} (cwd=${cwd})`;
3291
+ }
3292
+ function runPackageScript(pm, script, packageDir, repoRoot, env) {
3293
+ if (pm === "pnpm") {
3294
+ (0, exec_1.runOrThrow)("pnpm", ["--dir", packageDir, "run", script], repoRoot, env);
3295
+ return;
3296
+ }
3297
+ if (pm === "npm") {
3298
+ (0, exec_1.runOrThrow)("npm", ["--prefix", packageDir, "run", script], repoRoot, env);
3299
+ return;
3300
+ }
3301
+ if (pm === "yarn") {
3302
+ (0, exec_1.runOrThrow)("yarn", ["--cwd", packageDir, "run", script], repoRoot, env);
3303
+ return;
3304
+ }
3305
+ (0, exec_1.runOrThrow)("bun", ["run", script], packageDir, env);
3306
+ }
3307
+ }
3308
+ });
3309
+
3162
3310
  // ../npm/dist/commands/release/version.js
3163
3311
  var require_version = __commonJS({
3164
3312
  "../npm/dist/commands/release/version.js"(exports2) {
@@ -3203,6 +3351,7 @@ var require_release = __commonJS({
3203
3351
  var args_1 = require_args2();
3204
3352
  var env_1 = require_env();
3205
3353
  var exec_1 = require_exec2();
3354
+ var package_manager_1 = require_package_manager();
3206
3355
  var version_1 = require_version();
3207
3356
  function resolveTargetDir(repoRoot, target) {
3208
3357
  if (target === "fumadocs")
@@ -3229,6 +3378,7 @@ var require_release = __commonJS({
3229
3378
  const json = (0, args_1.hasFlag)(flags, "json");
3230
3379
  const repoRoot = (0, env_1.findRepoRoot)(process.cwd());
3231
3380
  await (0, env_1.loadRootEnv)(repoRoot);
3381
+ const packageManager = (0, package_manager_1.resolvePackageManager)(repoRoot);
3232
3382
  const packageDir = resolveTargetDir(repoRoot, target);
3233
3383
  const packageJsonPath = (0, node_path_1.resolve)(packageDir, "package.json");
3234
3384
  const originalPackageJsonText = await (0, promises_1.readFile)(packageJsonPath, "utf8");
@@ -3259,9 +3409,9 @@ var require_release = __commonJS({
3259
3409
  tag,
3260
3410
  commands: [
3261
3411
  target === "cli" ? "lally repo readme --target cli" : null,
3262
- `pnpm -C ${packageDir} run build`,
3263
- packageJson.scripts?.["check-types"] ? `pnpm -C ${packageDir} run check-types` : null,
3264
- packageJson.scripts?.["test"] ? `pnpm -C ${packageDir} run test` : null,
3412
+ (0, package_manager_1.formatRunScriptCommand)(packageManager, "build", packageDir),
3413
+ packageJson.scripts?.["check-types"] ? (0, package_manager_1.formatRunScriptCommand)(packageManager, "check-types", packageDir) : null,
3414
+ packageJson.scripts?.["test"] ? (0, package_manager_1.formatRunScriptCommand)(packageManager, "test", packageDir) : null,
3265
3415
  `npm publish --tag ${tag} --access public`
3266
3416
  ].filter(Boolean)
3267
3417
  };
@@ -3290,12 +3440,12 @@ var require_release = __commonJS({
3290
3440
  if (target === "cli") {
3291
3441
  await (0, cli_repo_1.runRepoReadmeCommand)(["--target", "cli"]);
3292
3442
  }
3293
- (0, exec_1.runOrThrow)("pnpm", ["-C", packageDir, "run", "build"], repoRoot, auth.commandEnv);
3443
+ (0, package_manager_1.runPackageScript)(packageManager, "build", packageDir, repoRoot, auth.commandEnv);
3294
3444
  if (packageJson.scripts?.["check-types"]) {
3295
- (0, exec_1.runOrThrow)("pnpm", ["-C", packageDir, "run", "check-types"], repoRoot, auth.commandEnv);
3445
+ (0, package_manager_1.runPackageScript)(packageManager, "check-types", packageDir, repoRoot, auth.commandEnv);
3296
3446
  }
3297
3447
  if (packageJson.scripts?.["test"]) {
3298
- (0, exec_1.runOrThrow)("pnpm", ["-C", packageDir, "run", "test"], repoRoot, auth.commandEnv);
3448
+ (0, package_manager_1.runPackageScript)(packageManager, "test", packageDir, repoRoot, auth.commandEnv);
3299
3449
  }
3300
3450
  if (!process.env.NPM_TOKEN) {
3301
3451
  console.warn("NPM_TOKEN is not set.");