@spicemod/creator 0.0.27 → 0.0.29

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.
Files changed (2) hide show
  1. package/dist/bin.mjs +37 -44
  2. package/package.json +1 -1
package/dist/bin.mjs CHANGED
@@ -144,7 +144,7 @@ const customAppEntryFilePath = dist("templates/customAppEntry.js", import.meta.u
144
144
  //#endregion
145
145
  //#region package.json
146
146
  var name = "@spicemod/creator";
147
- var version = "0.0.27";
147
+ var version = "0.0.29";
148
148
 
149
149
  //#endregion
150
150
  //#region src/utils/common.ts
@@ -409,7 +409,7 @@ const OptionsSchema$1 = v.intersect([
409
409
  //#region src/env.ts
410
410
  const isDev = process.env.IS_DEV === "true";
411
411
  const spicetifyBin = process.env.SPICETIFY_BIN || process.env.SPICE_BIN || "spicetify";
412
- const skipSpicetify = process.env.SPICETIFY_SKIP === "true" || process.env.CI === "true";
412
+ const skipSpicetify = process.env.SPICETIFY_SKIP === "true" || !!process.env.CI;
413
413
  const env = {
414
414
  isDev,
415
415
  spicetifyBin,
@@ -509,6 +509,7 @@ const SpicetifyConfigSchema = v.object({
509
509
  //#endregion
510
510
  //#region src/utils/spicetify/index.ts
511
511
  function runSpice(args) {
512
+ if (env.skipSpicetify) throw new Error("Spicetify operations are disabled in CI");
512
513
  validateSpicetify(env.spicetifyBin);
513
514
  return spawnSync(env.spicetifyBin, args, { encoding: "utf-8" });
514
515
  }
@@ -516,6 +517,7 @@ const getCustomAppsDir = () => join(getSpiceDataPath(), "CustomApps");
516
517
  const getExtensionDir = () => join(getSpiceDataPath(), "Extensions");
517
518
  const getThemesDir = () => join(getSpiceDataPath(), "Themes");
518
519
  async function getSpicetifyConfig() {
520
+ if (env.skipSpicetify) throw new Error("Spicetify operations are disabled in CI");
519
521
  const { stdout, stderr, error } = runSpice(["path", "-c"]);
520
522
  if (error || stderr) throw new Error(`Failed to locate Spicetify config: ${stderr || error?.message}`);
521
523
  const rawConfig = parse(await readFile(stdout.trim(), "utf-8"));
@@ -524,11 +526,13 @@ async function getSpicetifyConfig() {
524
526
  else throw new Error("Spicetify Config Validation Failed:", v.flatten(result.issues).nested);
525
527
  }
526
528
  function getSpiceDataPath() {
529
+ if (env.skipSpicetify) throw new Error("Spicetify operations are disabled in CI");
527
530
  const { stdout, stderr, error } = runSpice(["path", "userdata"]);
528
531
  if (error || stderr) throw new Error(`Failed to locate Spicetify config: ${stderr || error?.message}`);
529
532
  return stdout.trim();
530
533
  }
531
534
  function validateSpicetify(bin) {
535
+ if (env.skipSpicetify) return;
532
536
  const result = spawnSync(bin, ["--version"], { encoding: "utf-8" });
533
537
  if (result.error) throw result.error;
534
538
  if (result.status !== 0) throw new Error(`Invalid spicetify binary "${bin}": ${result.stderr || "unknown error"}`);
@@ -922,50 +926,38 @@ const spicetifyHandler = ({ config, options, cache, logger = createLogger("plugi
922
926
  const identifier = isExtension ? `${urlSlugify(config.name)}.js` : urlSlugify(getEnName(config.name));
923
927
  const getDestDirs = () => {
924
928
  const dirs = [resolve(outDir)];
925
- if (copy) dirs.push(isExtension ? getExtensionDir() : isCustomApp ? resolve(getCustomAppsDir(), identifier) : resolve(getThemesDir(), identifier));
929
+ if (copy && !env.skipSpicetify) dirs.push(isExtension ? getExtensionDir() : isCustomApp ? resolve(getCustomAppsDir(), identifier) : resolve(getThemesDir(), identifier));
926
930
  return dirs;
927
931
  };
928
- if (env.skipSpicetify) {
929
- logger.info(pc.yellow("skipping spicetify operations"));
930
- build.onEnd(async (result) => {
931
- if (result.errors.length > 0) return;
932
- const destDirs = getDestDirs();
933
- await copyFiles(logger, destDirs, cache.files);
934
- logger.debug(pc.green(`${CHECK} Built files written to ${outDir}`));
935
- if (cache.removed.size > 0) {
936
- await removeDeletedFiles(logger, destDirs, cache.removed);
937
- cache.hasChanges = true;
932
+ if (env.skipSpicetify) logger.info(pc.yellow("Skipping Spicetify operations..."));
933
+ else {
934
+ const spiceConfig = await getSpicetifyConfig();
935
+ logger.debug(pc.green("Spicetify Config: "), spiceConfig);
936
+ if (apply) {
937
+ const defaultTheme = spiceConfig?.Setting?.current_theme || "SpicetifyDefault";
938
+ const spiceIdentifier = remove ? `${identifier}-` : identifier;
939
+ runSpice([
940
+ "config",
941
+ isExtension ? "extensions" : isCustomApp ? "custom_apps" : "current_theme",
942
+ spiceIdentifier
943
+ ]);
944
+ if (!isExtension && !remove) {
945
+ const cleanup = () => {
946
+ if (isCustomApp) runSpice([
947
+ "config",
948
+ "custom_apps",
949
+ `${identifier}-`
950
+ ]);
951
+ else runSpice([
952
+ "config",
953
+ "current_theme",
954
+ defaultTheme
955
+ ]);
956
+ process.exit();
957
+ };
958
+ process.once("SIGINT", cleanup);
959
+ process.once("SIGTERM", cleanup);
938
960
  }
939
- cache.removed.clear();
940
- });
941
- return;
942
- }
943
- const spiceConfig = await getSpicetifyConfig();
944
- logger.debug(pc.green("Spicetify Config: "), spiceConfig);
945
- if (apply) {
946
- const defaultTheme = spiceConfig?.Setting?.current_theme || "SpicetifyDefault";
947
- const spiceIdentifier = remove ? `${identifier}-` : identifier;
948
- runSpice([
949
- "config",
950
- isExtension ? "extensions" : isCustomApp ? "custom_apps" : "current_theme",
951
- spiceIdentifier
952
- ]);
953
- if (!isExtension && !remove) {
954
- const cleanup = () => {
955
- if (isCustomApp) runSpice([
956
- "config",
957
- "custom_apps",
958
- `${identifier}-`
959
- ]);
960
- else runSpice([
961
- "config",
962
- "current_theme",
963
- defaultTheme
964
- ]);
965
- process.exit();
966
- };
967
- process.once("SIGINT", cleanup);
968
- process.once("SIGTERM", cleanup);
969
961
  }
970
962
  }
971
963
  build.onEnd(async (result) => {
@@ -973,7 +965,7 @@ const spicetifyHandler = ({ config, options, cache, logger = createLogger("plugi
973
965
  const destDirs = getDestDirs();
974
966
  try {
975
967
  await copyFiles(logger, destDirs, cache.files);
976
- logger.debug(pc.green(`${CHECK} Changed files copied.`));
968
+ logger.debug(pc.green(`${CHECK} Built files written to ${outDir}`));
977
969
  } catch (err) {
978
970
  logger.error(pc.red(`${CROSS} Failed to copy files: ${err instanceof Error ? err.message : String(err)}`));
979
971
  return;
@@ -983,6 +975,7 @@ const spicetifyHandler = ({ config, options, cache, logger = createLogger("plugi
983
975
  cache.hasChanges = true;
984
976
  }
985
977
  cache.removed.clear();
978
+ if (env.skipSpicetify) return;
986
979
  if (apply && cache.hasChanges && (!applyOnce || !hasAppliedOnce)) {
987
980
  const { stdout, stderr, status } = runSpice(["apply"]);
988
981
  if (status !== 0) logger.error(pc.red(`${CROSS} Spicetify apply failed:`), stdout, stderr);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicemod/creator",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "description": "Easily make Spicetify extensions and themes",
5
5
  "keywords": [
6
6
  "cli",