@salty-css/core 0.1.0-alpha.16 → 0.1.0-alpha.17

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.
@@ -21,3 +21,14 @@ export interface ConfirmInstallOptions {
21
21
  * (case-insensitive); anything else throws to abort the command.
22
22
  */
23
23
  export declare const confirmInstall: (packages: string[], yes: boolean, options?: ConfirmInstallOptions) => Promise<void>;
24
+ export interface ConfirmYesNoOptions extends ConfirmInstallOptions {
25
+ /** When true, resolves true without prompting. */
26
+ yes?: boolean;
27
+ /** When true, an empty answer counts as yes. Defaults to false (empty = no). */
28
+ defaultYes?: boolean;
29
+ }
30
+ /**
31
+ * Generic yes/no prompt. Unlike `confirmInstall`, non-TTY without `yes`
32
+ * resolves `false` instead of throwing — callers can choose policy.
33
+ */
34
+ export declare const confirmYesNo: (question: string, options?: ConfirmYesNoOptions) => Promise<boolean>;
package/bin/main.cjs CHANGED
@@ -311,7 +311,7 @@ const confirmInstall = async (packages, yes, options = {}) => {
311
311
  if (packages.length === 0) return;
312
312
  const input = options.input ?? process.stdin;
313
313
  const output = options.output ?? process.stdout;
314
- const isTTY = options.isTTY ?? (process.stdin.isTTY ?? false);
314
+ const isTTY = options.isTTY ?? process.stdin.isTTY ?? false;
315
315
  if (!isTTY) {
316
316
  throw new Error("Cannot prompt for install confirmation: stdin is not a TTY. Re-run with --yes to install the listed packages without prompting.");
317
317
  }
@@ -328,6 +328,22 @@ ${renderPackageList(packages)}
328
328
  rl.close();
329
329
  }
330
330
  };
331
+ const confirmYesNo = async (question, options = {}) => {
332
+ if (options.yes) return true;
333
+ const input = options.input ?? process.stdin;
334
+ const output = options.output ?? process.stdout;
335
+ const isTTY = options.isTTY ?? process.stdin.isTTY ?? false;
336
+ if (!isTTY) return false;
337
+ const suffix = options.defaultYes ? "(Y/n)" : "(y/N)";
338
+ const rl = promises$1.createInterface({ input, output, terminal: false });
339
+ try {
340
+ const answer = (await rl.question(`${question} ${suffix} `)).trim().toLowerCase();
341
+ if (answer === "") return !!options.defaultYes;
342
+ return answer === "y" || answer === "yes";
343
+ } finally {
344
+ rl.close();
345
+ }
346
+ };
331
347
  const CSS_FILE_FOLDERS = ["src", "public", "assets", "styles", "css", "app"];
332
348
  const CSS_SECOND_LEVEL_FOLDERS = ["styles", "css", "app", "pages"];
333
349
  const CSS_FILE_NAMES = ["index", "styles", "main", "app", "global", "globals"];
@@ -667,8 +683,8 @@ const getSaltyCssPackages = async () => {
667
683
  return saltyCssPackages;
668
684
  };
669
685
  const registerUpdateCommand = (program) => {
670
- program.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>", "Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", false).option("-y, --yes", "Skip the install confirmation prompt.").action(async function(_version = "latest") {
671
- const { legacyPeerDeps, version = _version, yes = false } = this.opts();
686
+ program.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>", "Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", false).option("-y, --yes", "Skip confirmation prompts (install and rebuild).").option("-d, --dir <dir>", "Project directory to rebuild after updating.").action(async function(_version = "latest") {
687
+ const { legacyPeerDeps, version = _version, yes = false, dir } = this.opts();
672
688
  const saltyCssPackages = await getSaltyCssPackages();
673
689
  if (!saltyCssPackages) return compiler_saltyCompiler.logError("Could not update Salty-CSS packages as any were found in package.json.");
674
690
  const cli = await readThisPackageJson();
@@ -703,6 +719,17 @@ const registerUpdateCommand = (program) => {
703
719
  compiler_saltyCompiler.logger.info(`Updated to ${v.replace(/^\^/, "")}: ${names.join(", ")}`);
704
720
  }
705
721
  }
722
+ const project = dir ?? await getDefaultProject();
723
+ if (!project) {
724
+ compiler_saltyCompiler.logger.warn("Skipping rebuild: no project directory configured. Run `salty-css build [dir]` manually.");
725
+ return;
726
+ }
727
+ const shouldRebuild = await confirmYesNo("Rebuild Salty CSS now?", { yes });
728
+ if (!shouldRebuild) return;
729
+ const projectDir = resolveProjectDir(project);
730
+ compiler_saltyCompiler.logger.info("Rebuilding Salty-CSS project...");
731
+ await new compiler_saltyCompiler.SaltyCompiler(projectDir).generateCss();
732
+ compiler_saltyCompiler.logger.info("Rebuild complete.");
706
733
  });
707
734
  };
708
735
  const registerVersionOption = (program) => {
package/bin/main.js CHANGED
@@ -308,7 +308,7 @@ const confirmInstall = async (packages, yes, options = {}) => {
308
308
  if (packages.length === 0) return;
309
309
  const input = options.input ?? process.stdin;
310
310
  const output = options.output ?? process.stdout;
311
- const isTTY = options.isTTY ?? (process.stdin.isTTY ?? false);
311
+ const isTTY = options.isTTY ?? process.stdin.isTTY ?? false;
312
312
  if (!isTTY) {
313
313
  throw new Error("Cannot prompt for install confirmation: stdin is not a TTY. Re-run with --yes to install the listed packages without prompting.");
314
314
  }
@@ -325,6 +325,22 @@ ${renderPackageList(packages)}
325
325
  rl.close();
326
326
  }
327
327
  };
328
+ const confirmYesNo = async (question, options = {}) => {
329
+ if (options.yes) return true;
330
+ const input = options.input ?? process.stdin;
331
+ const output = options.output ?? process.stdout;
332
+ const isTTY = options.isTTY ?? process.stdin.isTTY ?? false;
333
+ if (!isTTY) return false;
334
+ const suffix = options.defaultYes ? "(Y/n)" : "(y/N)";
335
+ const rl = createInterface({ input, output, terminal: false });
336
+ try {
337
+ const answer = (await rl.question(`${question} ${suffix} `)).trim().toLowerCase();
338
+ if (answer === "") return !!options.defaultYes;
339
+ return answer === "y" || answer === "yes";
340
+ } finally {
341
+ rl.close();
342
+ }
343
+ };
328
344
  const CSS_FILE_FOLDERS = ["src", "public", "assets", "styles", "css", "app"];
329
345
  const CSS_SECOND_LEVEL_FOLDERS = ["styles", "css", "app", "pages"];
330
346
  const CSS_FILE_NAMES = ["index", "styles", "main", "app", "global", "globals"];
@@ -664,8 +680,8 @@ const getSaltyCssPackages = async () => {
664
680
  return saltyCssPackages;
665
681
  };
666
682
  const registerUpdateCommand = (program) => {
667
- program.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>", "Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", false).option("-y, --yes", "Skip the install confirmation prompt.").action(async function(_version = "latest") {
668
- const { legacyPeerDeps, version = _version, yes = false } = this.opts();
683
+ program.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>", "Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", false).option("-y, --yes", "Skip confirmation prompts (install and rebuild).").option("-d, --dir <dir>", "Project directory to rebuild after updating.").action(async function(_version = "latest") {
684
+ const { legacyPeerDeps, version = _version, yes = false, dir } = this.opts();
669
685
  const saltyCssPackages = await getSaltyCssPackages();
670
686
  if (!saltyCssPackages) return logError("Could not update Salty-CSS packages as any were found in package.json.");
671
687
  const cli = await readThisPackageJson();
@@ -700,6 +716,17 @@ const registerUpdateCommand = (program) => {
700
716
  logger.info(`Updated to ${v.replace(/^\^/, "")}: ${names.join(", ")}`);
701
717
  }
702
718
  }
719
+ const project = dir ?? await getDefaultProject();
720
+ if (!project) {
721
+ logger.warn("Skipping rebuild: no project directory configured. Run `salty-css build [dir]` manually.");
722
+ return;
723
+ }
724
+ const shouldRebuild = await confirmYesNo("Rebuild Salty CSS now?", { yes });
725
+ if (!shouldRebuild) return;
726
+ const projectDir = resolveProjectDir(project);
727
+ logger.info("Rebuilding Salty-CSS project...");
728
+ await new SaltyCompiler(projectDir).generateCss();
729
+ logger.info("Rebuild complete.");
703
730
  });
704
731
  };
705
732
  const registerVersionOption = (program) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.1.0-alpha.16",
3
+ "version": "0.1.0-alpha.17",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",