@onexapis/cli 1.1.37 → 1.1.38

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 (48) hide show
  1. package/dist/cli.js +688 -454
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +681 -449
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/index.js +343 -256
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +339 -253
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/preview/preview-app.tsx +5 -13
  10. package/package.json +8 -4
  11. package/templates/default/bundle-entry.ts +0 -5
  12. package/templates/default/index.ts +1 -21
  13. package/templates/default/sections-registry.ts +0 -28
  14. package/templates/default/theme.layout.ts +2 -53
  15. package/templates/default/AUTH_AND_PROFILE.md +0 -167
  16. package/templates/default/LAYOUT.md +0 -195
  17. package/templates/default/hooks/index.ts +0 -26
  18. package/templates/default/hooks/use-forgot-password-form.ts +0 -90
  19. package/templates/default/hooks/use-login-form.ts +0 -102
  20. package/templates/default/hooks/use-profile-form.ts +0 -255
  21. package/templates/default/hooks/use-register-form.ts +0 -154
  22. package/templates/default/hooks/use-verify-code-form.ts +0 -224
  23. package/templates/default/pages/forgot-password.ts +0 -41
  24. package/templates/default/pages/login.ts +0 -41
  25. package/templates/default/pages/profile.ts +0 -39
  26. package/templates/default/pages/register.ts +0 -41
  27. package/templates/default/pages/verify-code.ts +0 -41
  28. package/templates/default/sections/auth-forgot-password/auth-forgot-password-default.tsx +0 -192
  29. package/templates/default/sections/auth-forgot-password/auth-forgot-password.schema.ts +0 -150
  30. package/templates/default/sections/auth-forgot-password/index.ts +0 -14
  31. package/templates/default/sections/auth-login/auth-login-default.tsx +0 -238
  32. package/templates/default/sections/auth-login/auth-login.schema.ts +0 -171
  33. package/templates/default/sections/auth-login/index.ts +0 -14
  34. package/templates/default/sections/auth-register/auth-register-default.tsx +0 -327
  35. package/templates/default/sections/auth-register/auth-register.schema.ts +0 -188
  36. package/templates/default/sections/auth-register/index.ts +0 -14
  37. package/templates/default/sections/auth-verify-code/auth-verify-code-default.tsx +0 -209
  38. package/templates/default/sections/auth-verify-code/auth-verify-code.schema.ts +0 -150
  39. package/templates/default/sections/auth-verify-code/index.ts +0 -14
  40. package/templates/default/sections/footer/footer-default.tsx +0 -214
  41. package/templates/default/sections/footer/footer.schema.ts +0 -170
  42. package/templates/default/sections/footer/index.ts +0 -14
  43. package/templates/default/sections/header/header-default.tsx +0 -322
  44. package/templates/default/sections/header/header.schema.ts +0 -168
  45. package/templates/default/sections/header/index.ts +0 -14
  46. package/templates/default/sections/profile/index.ts +0 -14
  47. package/templates/default/sections/profile/profile-default.tsx +0 -522
  48. package/templates/default/sections/profile/profile.schema.ts +0 -228
package/dist/index.js CHANGED
@@ -3,18 +3,18 @@
3
3
  var chalk4 = require('chalk');
4
4
  var ora = require('ora');
5
5
  var esbuild = require('esbuild');
6
- var path7 = require('path');
7
- var fs6 = require('fs/promises');
6
+ var path9 = require('path');
7
+ var fs8 = require('fs/promises');
8
8
  var crypto = require('crypto');
9
9
  var glob = require('glob');
10
10
  var module$1 = require('module');
11
- var fs2 = require('fs');
12
- var child_process = require('child_process');
11
+ var fs4 = require('fs');
12
+ var spawn2 = require('cross-spawn');
13
13
  var inquirer = require('inquirer');
14
14
  var fs = require('fs-extra');
15
15
  var ejs = require('ejs');
16
- var clientS3 = require('@aws-sdk/client-s3');
17
16
  var os = require('os');
17
+ var clientS3 = require('@aws-sdk/client-s3');
18
18
  var archiver = require('archiver');
19
19
  var AdmZip = require('adm-zip');
20
20
 
@@ -42,10 +42,11 @@ function _interopNamespace(e) {
42
42
  var chalk4__default = /*#__PURE__*/_interopDefault(chalk4);
43
43
  var ora__default = /*#__PURE__*/_interopDefault(ora);
44
44
  var esbuild__namespace = /*#__PURE__*/_interopNamespace(esbuild);
45
- var path7__default = /*#__PURE__*/_interopDefault(path7);
46
- var fs6__default = /*#__PURE__*/_interopDefault(fs6);
45
+ var path9__default = /*#__PURE__*/_interopDefault(path9);
46
+ var fs8__default = /*#__PURE__*/_interopDefault(fs8);
47
47
  var crypto__default = /*#__PURE__*/_interopDefault(crypto);
48
- var fs2__default = /*#__PURE__*/_interopDefault(fs2);
48
+ var fs4__default = /*#__PURE__*/_interopDefault(fs4);
49
+ var spawn2__default = /*#__PURE__*/_interopDefault(spawn2);
49
50
  var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
50
51
  var fs__default = /*#__PURE__*/_interopDefault(fs);
51
52
  var ejs__default = /*#__PURE__*/_interopDefault(ejs);
@@ -139,8 +140,8 @@ async function generateThemeCSS(themePath, outDir) {
139
140
  const tailwindcss = (await import('tailwindcss')).default;
140
141
  const tailwindConfig = {
141
142
  content: [
142
- path7__default.default.join(themePath, "sections/**/*.{ts,tsx}"),
143
- path7__default.default.join(themePath, "components/**/*.{ts,tsx}")
143
+ path9__default.default.join(themePath, "sections/**/*.{ts,tsx}"),
144
+ path9__default.default.join(themePath, "components/**/*.{ts,tsx}")
144
145
  ],
145
146
  theme: { extend: {} },
146
147
  plugins: []
@@ -150,7 +151,7 @@ async function generateThemeCSS(themePath, outDir) {
150
151
  inputCSS,
151
152
  { from: void 0 }
152
153
  );
153
- await fs6__default.default.writeFile(path7__default.default.join(outDir, "bundle.css"), result.css);
154
+ await fs8__default.default.writeFile(path9__default.default.join(outDir, "bundle.css"), result.css);
154
155
  exports.logger.info("Generated bundle.css");
155
156
  } catch (err) {
156
157
  exports.logger.warning(
@@ -161,12 +162,12 @@ async function generateThemeCSS(themePath, outDir) {
161
162
  async function resolveNodeModulesFile(startDir, relativePath) {
162
163
  let dir = startDir;
163
164
  while (true) {
164
- const candidate = path7__default.default.join(dir, "node_modules", relativePath);
165
+ const candidate = path9__default.default.join(dir, "node_modules", relativePath);
165
166
  try {
166
- await fs6__default.default.access(candidate);
167
+ await fs8__default.default.access(candidate);
167
168
  return candidate;
168
169
  } catch {
169
- const parent = path7__default.default.dirname(dir);
170
+ const parent = path9__default.default.dirname(dir);
170
171
  if (parent === dir) break;
171
172
  dir = parent;
172
173
  }
@@ -190,7 +191,7 @@ async function scanImportsFromPackage(sourceDir, packageName) {
190
191
  });
191
192
  for (const file of sourceFiles) {
192
193
  try {
193
- const content = await fs6__default.default.readFile(path7__default.default.join(sourceDir, file), "utf-8");
194
+ const content = await fs8__default.default.readFile(path9__default.default.join(sourceDir, file), "utf-8");
194
195
  for (const match of content.matchAll(namespaceImportRegex)) {
195
196
  const subpath = match[1] ? match[1].slice(1) : "";
196
197
  if (!result[subpath]) result[subpath] = /* @__PURE__ */ new Set();
@@ -244,17 +245,17 @@ function createCoreGlobalPlugin(themePath) {
244
245
  const distFileName = subpath ? `${subpath}.mjs` : "index.mjs";
245
246
  let distPath = await resolveNodeModulesFile(
246
247
  themePath,
247
- path7__default.default.join("@onexapis", "core", "dist", distFileName)
248
+ path9__default.default.join("@onexapis", "core", "dist", distFileName)
248
249
  );
249
250
  if (!distPath) {
250
251
  distPath = await resolveNodeModulesFile(
251
252
  __dirname,
252
- path7__default.default.join("@onexapis", "core", "dist", distFileName)
253
+ path9__default.default.join("@onexapis", "core", "dist", distFileName)
253
254
  );
254
255
  }
255
256
  try {
256
257
  if (!distPath) throw new Error("not found");
257
- const distContent = await fs6__default.default.readFile(distPath, "utf-8");
258
+ const distContent = await fs8__default.default.readFile(distPath, "utf-8");
258
259
  const exportMatches = distContent.matchAll(/export\s*\{([^}]+)\}/g);
259
260
  for (const m of exportMatches) {
260
261
  const names = m[1].split(",").map((n) => {
@@ -483,7 +484,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
483
484
  const pages = {};
484
485
  for (const ext of [".ts", ".js"]) {
485
486
  try {
486
- const mod = await jiti.import(path7__default.default.join(themePath, `theme.config${ext}`));
487
+ const mod = await jiti.import(path9__default.default.join(themePath, `theme.config${ext}`));
487
488
  themeConfig = mod.default || mod;
488
489
  break;
489
490
  } catch {
@@ -491,20 +492,20 @@ async function generateThemeData(themePath, outputDir, themeId) {
491
492
  }
492
493
  for (const ext of [".ts", ".js"]) {
493
494
  try {
494
- const mod = await jiti.import(path7__default.default.join(themePath, `theme.layout${ext}`));
495
+ const mod = await jiti.import(path9__default.default.join(themePath, `theme.layout${ext}`));
495
496
  layoutConfig = mod.default || mod;
496
497
  break;
497
498
  } catch {
498
499
  }
499
500
  }
500
501
  const schemas = {};
501
- const sectionsDir = path7__default.default.join(themePath, "sections");
502
+ const sectionsDir = path9__default.default.join(themePath, "sections");
502
503
  try {
503
- const sectionDirs = await fs6__default.default.readdir(sectionsDir);
504
+ const sectionDirs = await fs8__default.default.readdir(sectionsDir);
504
505
  for (const dir of sectionDirs) {
505
- const schemaFile = path7__default.default.join(sectionsDir, dir, `${dir}.schema.ts`);
506
+ const schemaFile = path9__default.default.join(sectionsDir, dir, `${dir}.schema.ts`);
506
507
  try {
507
- await fs6__default.default.access(schemaFile);
508
+ await fs8__default.default.access(schemaFile);
508
509
  const mod = await jiti.import(schemaFile);
509
510
  for (const [key, value] of Object.entries(mod)) {
510
511
  if (key.endsWith("Schema") && value && typeof value === "object" && value.type) {
@@ -516,14 +517,14 @@ async function generateThemeData(themePath, outputDir, themeId) {
516
517
  }
517
518
  } catch {
518
519
  }
519
- const pagesDir = path7__default.default.join(themePath, "pages");
520
+ const pagesDir = path9__default.default.join(themePath, "pages");
520
521
  try {
521
- const files = await fs6__default.default.readdir(pagesDir);
522
+ const files = await fs8__default.default.readdir(pagesDir);
522
523
  for (const file of files) {
523
524
  if (!file.match(/\.(ts|js)$/)) continue;
524
525
  const name = file.replace(/\.(ts|js)$/, "");
525
526
  try {
526
- const mod = await jiti.import(path7__default.default.join(pagesDir, file));
527
+ const mod = await jiti.import(path9__default.default.join(pagesDir, file));
527
528
  const config = mod.default || mod;
528
529
  const sections = (config.sections || []).map((section) => {
529
530
  const schema = schemas[section.type];
@@ -551,8 +552,8 @@ async function generateThemeData(themePath, outputDir, themeId) {
551
552
  }
552
553
  } catch {
553
554
  }
554
- await fs6__default.default.writeFile(
555
- path7__default.default.join(outputDir, "theme-data.json"),
555
+ await fs8__default.default.writeFile(
556
+ path9__default.default.join(outputDir, "theme-data.json"),
556
557
  JSON.stringify(
557
558
  {
558
559
  themeId,
@@ -575,36 +576,36 @@ async function generateThemeData(themePath, outputDir, themeId) {
575
576
  exports.logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
576
577
  }
577
578
  async function contentHashEntry(outputDir) {
578
- const entryPath = path7__default.default.join(outputDir, "bundle-entry.js");
579
- const mapPath = path7__default.default.join(outputDir, "bundle-entry.js.map");
579
+ const entryPath = path9__default.default.join(outputDir, "bundle-entry.js");
580
+ const mapPath = path9__default.default.join(outputDir, "bundle-entry.js.map");
580
581
  const oldFiles = await glob.glob("bundle-entry-*.js*", { cwd: outputDir });
581
582
  for (const f of oldFiles) {
582
- await fs6__default.default.unlink(path7__default.default.join(outputDir, f));
583
+ await fs8__default.default.unlink(path9__default.default.join(outputDir, f));
583
584
  }
584
585
  let entryContent;
585
586
  try {
586
- entryContent = await fs6__default.default.readFile(entryPath, "utf-8");
587
+ entryContent = await fs8__default.default.readFile(entryPath, "utf-8");
587
588
  } catch {
588
- const indexPath = path7__default.default.join(outputDir, "index.js");
589
+ const indexPath = path9__default.default.join(outputDir, "index.js");
589
590
  try {
590
- entryContent = await fs6__default.default.readFile(indexPath, "utf-8");
591
+ entryContent = await fs8__default.default.readFile(indexPath, "utf-8");
591
592
  } catch {
592
593
  exports.logger.warning("No entry file found in output, skipping content hash");
593
594
  return;
594
595
  }
595
596
  const hash2 = crypto__default.default.createHash("sha256").update(entryContent).digest("hex").slice(0, 8);
596
597
  const hashedName2 = `bundle-entry-${hash2}.js`;
597
- const indexMapPath = path7__default.default.join(outputDir, "index.js.map");
598
+ const indexMapPath = path9__default.default.join(outputDir, "index.js.map");
598
599
  const hashedMapName2 = `bundle-entry-${hash2}.js.map`;
599
600
  entryContent = entryContent.replace(
600
601
  /\/\/# sourceMappingURL=index\.js\.map/,
601
602
  `//# sourceMappingURL=${hashedMapName2}`
602
603
  );
603
- await fs6__default.default.writeFile(path7__default.default.join(outputDir, hashedName2), entryContent);
604
- await fs6__default.default.unlink(indexPath);
604
+ await fs8__default.default.writeFile(path9__default.default.join(outputDir, hashedName2), entryContent);
605
+ await fs8__default.default.unlink(indexPath);
605
606
  try {
606
- await fs6__default.default.access(indexMapPath);
607
- await fs6__default.default.rename(indexMapPath, path7__default.default.join(outputDir, hashedMapName2));
607
+ await fs8__default.default.access(indexMapPath);
608
+ await fs8__default.default.rename(indexMapPath, path9__default.default.join(outputDir, hashedMapName2));
608
609
  } catch {
609
610
  }
610
611
  exports.logger.info(`Entry hashed: ${hashedName2}`);
@@ -617,11 +618,11 @@ async function contentHashEntry(outputDir) {
617
618
  /\/\/# sourceMappingURL=bundle-entry\.js\.map/,
618
619
  `//# sourceMappingURL=${hashedMapName}`
619
620
  );
620
- await fs6__default.default.writeFile(path7__default.default.join(outputDir, hashedName), entryContent);
621
- await fs6__default.default.unlink(entryPath);
621
+ await fs8__default.default.writeFile(path9__default.default.join(outputDir, hashedName), entryContent);
622
+ await fs8__default.default.unlink(entryPath);
622
623
  try {
623
- await fs6__default.default.access(mapPath);
624
- await fs6__default.default.rename(mapPath, path7__default.default.join(outputDir, hashedMapName));
624
+ await fs8__default.default.access(mapPath);
625
+ await fs8__default.default.rename(mapPath, path9__default.default.join(outputDir, hashedMapName));
625
626
  } catch {
626
627
  }
627
628
  exports.logger.info(`Entry hashed: ${hashedName}`);
@@ -633,7 +634,7 @@ async function extractDataRequirements(themePath) {
633
634
  const requirements = {};
634
635
  for (const file of schemaFiles) {
635
636
  try {
636
- const mod = await jiti.import(path7__default.default.join(themePath, file));
637
+ const mod = await jiti.import(path9__default.default.join(themePath, file));
637
638
  const exports$1 = mod;
638
639
  for (const value of Object.values(exports$1)) {
639
640
  if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
@@ -652,8 +653,8 @@ async function generateManifest(themeName, themePath, outputDir) {
652
653
  let version = "1.0.0";
653
654
  let themeId = themeName;
654
655
  try {
655
- const pkgContent = await fs6__default.default.readFile(
656
- path7__default.default.join(themePath, "package.json"),
656
+ const pkgContent = await fs8__default.default.readFile(
657
+ path9__default.default.join(themePath, "package.json"),
657
658
  "utf-8"
658
659
  );
659
660
  const pkg = JSON.parse(pkgContent);
@@ -671,7 +672,7 @@ async function generateManifest(themeName, themePath, outputDir) {
671
672
  const dataRequirements = await extractDataRequirements(themePath);
672
673
  let hasThemeConfig = false;
673
674
  try {
674
- await fs6__default.default.access(path7__default.default.join(themePath, "theme.config.ts"));
675
+ await fs8__default.default.access(path9__default.default.join(themePath, "theme.config.ts"));
675
676
  hasThemeConfig = true;
676
677
  } catch {
677
678
  }
@@ -712,24 +713,24 @@ async function generateManifest(themeName, themePath, outputDir) {
712
713
  // Section data requirements for server-side prefetching (keyed by section type)
713
714
  dataRequirements
714
715
  };
715
- await fs6__default.default.writeFile(
716
- path7__default.default.join(outputDir, "manifest.json"),
716
+ await fs8__default.default.writeFile(
717
+ path9__default.default.join(outputDir, "manifest.json"),
717
718
  JSON.stringify(manifest, null, 2)
718
719
  );
719
720
  }
720
721
  async function compileStandaloneTheme(themePath, themeName) {
721
- const outputDir = path7__default.default.join(themePath, "dist");
722
- const bundleEntry = path7__default.default.join(themePath, "bundle-entry.ts");
723
- const indexEntry = path7__default.default.join(themePath, "index.ts");
722
+ const outputDir = path9__default.default.join(themePath, "dist");
723
+ const bundleEntry = path9__default.default.join(themePath, "bundle-entry.ts");
724
+ const indexEntry = path9__default.default.join(themePath, "index.ts");
724
725
  let entryPoint = indexEntry;
725
726
  try {
726
- await fs6__default.default.access(bundleEntry);
727
+ await fs8__default.default.access(bundleEntry);
727
728
  entryPoint = bundleEntry;
728
729
  } catch {
729
730
  }
730
- const shimPath = path7__default.default.join(outputDir, ".process-shim.js");
731
- await fs6__default.default.mkdir(outputDir, { recursive: true });
732
- await fs6__default.default.writeFile(shimPath, PROCESS_SHIM);
731
+ const shimPath = path9__default.default.join(outputDir, ".process-shim.js");
732
+ await fs8__default.default.mkdir(outputDir, { recursive: true });
733
+ await fs8__default.default.writeFile(shimPath, PROCESS_SHIM);
733
734
  const buildOptions = {
734
735
  entryPoints: [entryPoint],
735
736
  bundle: true,
@@ -779,7 +780,7 @@ async function compileStandaloneTheme(themePath, themeName) {
779
780
  try {
780
781
  const result = await esbuild__namespace.build(buildOptions);
781
782
  try {
782
- await fs6__default.default.unlink(shimPath);
783
+ await fs8__default.default.unlink(shimPath);
783
784
  } catch {
784
785
  }
785
786
  await contentHashEntry(outputDir);
@@ -798,7 +799,7 @@ async function compileStandaloneTheme(themePath, themeName) {
798
799
  return true;
799
800
  } catch (error) {
800
801
  try {
801
- await fs6__default.default.unlink(shimPath);
802
+ await fs8__default.default.unlink(shimPath);
802
803
  } catch {
803
804
  }
804
805
  exports.logger.error(`esbuild compilation failed: ${error}`);
@@ -806,18 +807,18 @@ async function compileStandaloneTheme(themePath, themeName) {
806
807
  }
807
808
  }
808
809
  async function compileStandaloneThemeDev(themePath, themeName) {
809
- const outputDir = path7__default.default.join(themePath, "dist");
810
- const bundleEntry = path7__default.default.join(themePath, "bundle-entry.ts");
811
- const indexEntry = path7__default.default.join(themePath, "index.ts");
810
+ const outputDir = path9__default.default.join(themePath, "dist");
811
+ const bundleEntry = path9__default.default.join(themePath, "bundle-entry.ts");
812
+ const indexEntry = path9__default.default.join(themePath, "index.ts");
812
813
  let entryPoint = indexEntry;
813
814
  try {
814
- await fs6__default.default.access(bundleEntry);
815
+ await fs8__default.default.access(bundleEntry);
815
816
  entryPoint = bundleEntry;
816
817
  } catch {
817
818
  }
818
- const shimPath = path7__default.default.join(outputDir, ".process-shim.js");
819
- await fs6__default.default.mkdir(outputDir, { recursive: true });
820
- await fs6__default.default.writeFile(shimPath, PROCESS_SHIM);
819
+ const shimPath = path9__default.default.join(outputDir, ".process-shim.js");
820
+ await fs8__default.default.mkdir(outputDir, { recursive: true });
821
+ await fs8__default.default.writeFile(shimPath, PROCESS_SHIM);
821
822
  const buildOptions = {
822
823
  entryPoints: [entryPoint],
823
824
  bundle: true,
@@ -870,18 +871,18 @@ async function compileStandaloneThemeDev(themePath, themeName) {
870
871
  return { context: context2, outputDir };
871
872
  }
872
873
  async function compilePreviewRuntime(themePath) {
873
- const outputDir = path7__default.default.join(themePath, "dist");
874
- await fs6__default.default.mkdir(outputDir, { recursive: true });
875
- const outputPath = path7__default.default.join(outputDir, "preview-runtime.js");
874
+ const outputDir = path9__default.default.join(themePath, "dist");
875
+ await fs8__default.default.mkdir(outputDir, { recursive: true });
876
+ const outputPath = path9__default.default.join(outputDir, "preview-runtime.js");
876
877
  const locations = [
877
- path7__default.default.join(__dirname, "..", "preview", "preview-app.tsx"),
878
- path7__default.default.join(__dirname, "preview", "preview-app.tsx"),
879
- path7__default.default.join(__dirname, "..", "..", "src", "preview", "preview-app.tsx")
878
+ path9__default.default.join(__dirname, "..", "preview", "preview-app.tsx"),
879
+ path9__default.default.join(__dirname, "preview", "preview-app.tsx"),
880
+ path9__default.default.join(__dirname, "..", "..", "src", "preview", "preview-app.tsx")
880
881
  ];
881
882
  let previewEntryPath = null;
882
883
  for (const loc of locations) {
883
884
  try {
884
- await fs6__default.default.access(loc);
885
+ await fs8__default.default.access(loc);
885
886
  previewEntryPath = loc;
886
887
  break;
887
888
  } catch {
@@ -964,10 +965,10 @@ ${locations.join("\n")}`
964
965
  if (!lucideScanned) {
965
966
  lucideScanned = true;
966
967
  const coreSrcCandidates = [
967
- path7__default.default.join(themePath, "node_modules", "@onexapis", "core", "src"),
968
- path7__default.default.join(themePath, "..", "..", "packages", "core", "src"),
968
+ path9__default.default.join(themePath, "node_modules", "@onexapis", "core", "src"),
969
+ path9__default.default.join(themePath, "..", "..", "packages", "core", "src"),
969
970
  // monorepo sibling
970
- path7__default.default.join(
971
+ path9__default.default.join(
971
972
  __dirname,
972
973
  "..",
973
974
  "..",
@@ -982,7 +983,7 @@ ${locations.join("\n")}`
982
983
  let coreSourceDir = null;
983
984
  for (const candidate of coreSrcCandidates) {
984
985
  try {
985
- await fs6__default.default.access(candidate);
986
+ await fs8__default.default.access(candidate);
986
987
  coreSourceDir = candidate;
987
988
  break;
988
989
  } catch {
@@ -1001,21 +1002,21 @@ ${locations.join("\n")}`
1001
1002
  }
1002
1003
  } else {
1003
1004
  const coreDistCandidates = [
1004
- path7__default.default.join(themePath, "node_modules", "@onexapis", "core", "dist")
1005
+ path9__default.default.join(themePath, "node_modules", "@onexapis", "core", "dist")
1005
1006
  ];
1006
1007
  const resolvedDist = await resolveNodeModulesFile(
1007
1008
  __dirname,
1008
- path7__default.default.join("@onexapis", "core", "dist")
1009
+ path9__default.default.join("@onexapis", "core", "dist")
1009
1010
  );
1010
1011
  if (resolvedDist) coreDistCandidates.push(resolvedDist);
1011
1012
  for (const candidate of coreDistCandidates) {
1012
1013
  try {
1013
- await fs6__default.default.access(candidate);
1014
+ await fs8__default.default.access(candidate);
1014
1015
  const mjsFiles = await glob.glob("*.mjs", { cwd: candidate });
1015
1016
  const importRegex = /import\s*\{([^}]+)\}\s*from\s*["']lucide-react["']/g;
1016
1017
  for (const file of mjsFiles) {
1017
- const content = await fs6__default.default.readFile(
1018
- path7__default.default.join(candidate, file),
1018
+ const content = await fs8__default.default.readFile(
1019
+ path9__default.default.join(candidate, file),
1019
1020
  "utf-8"
1020
1021
  );
1021
1022
  for (const match of content.matchAll(importRegex)) {
@@ -1070,7 +1071,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
1070
1071
  const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) || __filename);
1071
1072
  const cjsPath = req.resolve("framer-motion");
1072
1073
  const pkgDir = cjsPath.replace(/[/\\]dist[/\\].*$/, "");
1073
- const esmEntry = path7__default.default.join(pkgDir, "dist", "es", "index.mjs");
1074
+ const esmEntry = path9__default.default.join(pkgDir, "dist", "es", "index.mjs");
1074
1075
  const { existsSync } = await import('fs');
1075
1076
  if (existsSync(esmEntry)) {
1076
1077
  return { path: esmEntry, namespace: "file" };
@@ -1169,8 +1170,8 @@ export function headers() { return new Headers(); }
1169
1170
  });
1170
1171
  }
1171
1172
  };
1172
- const shimPath = path7__default.default.join(outputDir, ".process-shim-preview.js");
1173
- await fs6__default.default.writeFile(shimPath, PROCESS_SHIM);
1173
+ const shimPath = path9__default.default.join(outputDir, ".process-shim-preview.js");
1174
+ await fs8__default.default.writeFile(shimPath, PROCESS_SHIM);
1174
1175
  await esbuild__namespace.build({
1175
1176
  entryPoints: [previewEntryPath],
1176
1177
  bundle: true,
@@ -1205,7 +1206,7 @@ export function headers() { return new Headers(); }
1205
1206
  }
1206
1207
  });
1207
1208
  try {
1208
- await fs6__default.default.unlink(shimPath);
1209
+ await fs8__default.default.unlink(shimPath);
1209
1210
  } catch {
1210
1211
  }
1211
1212
  return outputPath;
@@ -1352,8 +1353,8 @@ function validateThemeName(name) {
1352
1353
  return /^[a-z][a-z0-9-]*$/.test(name);
1353
1354
  }
1354
1355
  function pathExists(filePath) {
1355
- const fs11 = __require("fs-extra");
1356
- return fs11.existsSync(filePath);
1356
+ const fs13 = __require("fs-extra");
1357
+ return fs13.existsSync(filePath);
1357
1358
  }
1358
1359
  function validateCategory(category) {
1359
1360
  const validCategories = [
@@ -1394,18 +1395,18 @@ async function renderTemplate(templatePath, data) {
1394
1395
  return ejs__default.default.render(template, data);
1395
1396
  }
1396
1397
  async function writeFile(filePath, content) {
1397
- await fs__default.default.ensureDir(path7__default.default.dirname(filePath));
1398
+ await fs__default.default.ensureDir(path9__default.default.dirname(filePath));
1398
1399
  await fs__default.default.writeFile(filePath, content, "utf-8");
1399
1400
  }
1400
1401
  function getTemplatesDir() {
1401
1402
  const locations = [
1402
- path7__default.default.join(__dirname, "../../templates"),
1403
+ path9__default.default.join(__dirname, "../../templates"),
1403
1404
  // Development
1404
- path7__default.default.join(__dirname, "../templates"),
1405
+ path9__default.default.join(__dirname, "../templates"),
1405
1406
  // Production (dist/)
1406
- path7__default.default.join(process.cwd(), "templates"),
1407
+ path9__default.default.join(process.cwd(), "templates"),
1407
1408
  // Fallback
1408
- path7__default.default.join(process.cwd(), "packages/cli/templates")
1409
+ path9__default.default.join(process.cwd(), "packages/cli/templates")
1409
1410
  // Monorepo
1410
1411
  ];
1411
1412
  for (const location of locations) {
@@ -1417,7 +1418,7 @@ function getTemplatesDir() {
1417
1418
  }
1418
1419
  async function copyTemplate(templateName, targetDir, data) {
1419
1420
  const templatesDir = getTemplatesDir();
1420
- const templateDir = path7__default.default.join(templatesDir, templateName);
1421
+ const templateDir = path9__default.default.join(templatesDir, templateName);
1421
1422
  if (!fs__default.default.existsSync(templateDir)) {
1422
1423
  throw new Error(
1423
1424
  `Template "${templateName}" not found at ${templateDir}. Available templates: ${fs__default.default.readdirSync(templatesDir).join(", ")}`
@@ -1426,8 +1427,8 @@ async function copyTemplate(templateName, targetDir, data) {
1426
1427
  await fs__default.default.ensureDir(targetDir);
1427
1428
  const files = await fs__default.default.readdir(templateDir);
1428
1429
  for (const file of files) {
1429
- const templatePath = path7__default.default.join(templateDir, file);
1430
- const targetPath = path7__default.default.join(targetDir, file);
1430
+ const templatePath = path9__default.default.join(templateDir, file);
1431
+ const targetPath = path9__default.default.join(targetDir, file);
1431
1432
  const stat = await fs__default.default.stat(templatePath);
1432
1433
  if (stat.isDirectory()) {
1433
1434
  await copyTemplateDir(templatePath, targetPath, data);
@@ -1444,8 +1445,8 @@ async function copyTemplateDir(templateDir, targetDir, data) {
1444
1445
  await fs__default.default.ensureDir(targetDir);
1445
1446
  const files = await fs__default.default.readdir(templateDir);
1446
1447
  for (const file of files) {
1447
- const templatePath = path7__default.default.join(templateDir, file);
1448
- const targetPath = path7__default.default.join(targetDir, file);
1448
+ const templatePath = path9__default.default.join(templateDir, file);
1449
+ const targetPath = path9__default.default.join(targetDir, file);
1449
1450
  const stat = await fs__default.default.stat(templatePath);
1450
1451
  if (stat.isDirectory()) {
1451
1452
  await copyTemplateDir(templatePath, targetPath, data);
@@ -1460,32 +1461,32 @@ async function copyTemplateDir(templateDir, targetDir, data) {
1460
1461
  }
1461
1462
  function getProjectRoot() {
1462
1463
  let currentDir = process.cwd();
1463
- while (currentDir !== path7__default.default.parse(currentDir).root) {
1464
- const packageJsonPath = path7__default.default.join(currentDir, "package.json");
1464
+ while (currentDir !== path9__default.default.parse(currentDir).root) {
1465
+ const packageJsonPath = path9__default.default.join(currentDir, "package.json");
1465
1466
  if (fs__default.default.existsSync(packageJsonPath)) {
1466
1467
  const packageJson = fs__default.default.readJsonSync(packageJsonPath);
1467
- if (packageJson.workspaces || fs__default.default.existsSync(path7__default.default.join(currentDir, "src/themes")) || fs__default.default.existsSync(path7__default.default.join(currentDir, "themes"))) {
1468
+ if (packageJson.workspaces || fs__default.default.existsSync(path9__default.default.join(currentDir, "src/themes")) || fs__default.default.existsSync(path9__default.default.join(currentDir, "themes"))) {
1468
1469
  return currentDir;
1469
1470
  }
1470
1471
  }
1471
- currentDir = path7__default.default.dirname(currentDir);
1472
+ currentDir = path9__default.default.dirname(currentDir);
1472
1473
  }
1473
1474
  return process.cwd();
1474
1475
  }
1475
1476
  function getThemesDir() {
1476
1477
  const root = getProjectRoot();
1477
- if (fs__default.default.existsSync(path7__default.default.join(root, "themes")))
1478
- return path7__default.default.join(root, "themes");
1479
- if (fs__default.default.existsSync(path7__default.default.join(root, "src/themes")))
1480
- return path7__default.default.join(root, "src/themes");
1481
- return path7__default.default.dirname(root);
1478
+ if (fs__default.default.existsSync(path9__default.default.join(root, "themes")))
1479
+ return path9__default.default.join(root, "themes");
1480
+ if (fs__default.default.existsSync(path9__default.default.join(root, "src/themes")))
1481
+ return path9__default.default.join(root, "src/themes");
1482
+ return path9__default.default.dirname(root);
1482
1483
  }
1483
1484
  function getFeaturesDir() {
1484
- return path7__default.default.join(getProjectRoot(), "src/features");
1485
+ return path9__default.default.join(getProjectRoot(), "src/features");
1485
1486
  }
1486
1487
  function isOneXProject() {
1487
1488
  const root = getProjectRoot();
1488
- return fs__default.default.existsSync(path7__default.default.join(root, "themes")) || fs__default.default.existsSync(path7__default.default.join(root, "src/themes")) || fs__default.default.existsSync(path7__default.default.join(root, "theme.config.ts")) || fs__default.default.existsSync(path7__default.default.join(root, "bundle-entry.ts"));
1489
+ return fs__default.default.existsSync(path9__default.default.join(root, "themes")) || fs__default.default.existsSync(path9__default.default.join(root, "src/themes")) || fs__default.default.existsSync(path9__default.default.join(root, "theme.config.ts")) || fs__default.default.existsSync(path9__default.default.join(root, "bundle-entry.ts"));
1489
1490
  }
1490
1491
  function ensureOneXProject() {
1491
1492
  if (!isOneXProject()) {
@@ -1501,13 +1502,13 @@ function listThemes() {
1501
1502
  return [];
1502
1503
  }
1503
1504
  return fs__default.default.readdirSync(themesDir).filter((name) => {
1504
- const themePath = path7__default.default.join(themesDir, name);
1505
- return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(path7__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path7__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path7__default.default.join(themePath, "manifest.ts")));
1505
+ const themePath = path9__default.default.join(themesDir, name);
1506
+ return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(path9__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path9__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path9__default.default.join(themePath, "manifest.ts")));
1506
1507
  });
1507
1508
  }
1508
1509
  function themeExists(themeName) {
1509
- const themePath = path7__default.default.join(getThemesDir(), themeName);
1510
- return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(path7__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path7__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path7__default.default.join(themePath, "manifest.ts")));
1510
+ const themePath = path9__default.default.join(getThemesDir(), themeName);
1511
+ return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(path9__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path9__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path9__default.default.join(themePath, "manifest.ts")));
1511
1512
  }
1512
1513
  function detectPackageManager() {
1513
1514
  const userAgent = process.env.npm_config_user_agent || "";
@@ -1515,24 +1516,91 @@ function detectPackageManager() {
1515
1516
  if (userAgent.includes("yarn")) return "yarn";
1516
1517
  if (userAgent.includes("bun")) return "bun";
1517
1518
  const cwd = process.cwd();
1518
- if (fs__default.default.existsSync(path7__default.default.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
1519
- if (fs__default.default.existsSync(path7__default.default.join(cwd, "yarn.lock"))) return "yarn";
1520
- if (fs__default.default.existsSync(path7__default.default.join(cwd, "bun.lockb"))) return "bun";
1519
+ if (fs__default.default.existsSync(path9__default.default.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
1520
+ if (fs__default.default.existsSync(path9__default.default.join(cwd, "yarn.lock"))) return "yarn";
1521
+ if (fs__default.default.existsSync(path9__default.default.join(cwd, "bun.lockb"))) return "bun";
1521
1522
  return "npm";
1522
1523
  }
1523
1524
  async function installDependencies(projectPath, packageManager = "npm") {
1524
- return new Promise((resolve, reject) => {
1525
+ const args = packageManager === "yarn" ? [] : ["install"];
1526
+ const result = spawn2__default.default.sync(packageManager, args, {
1527
+ cwd: projectPath,
1528
+ stdio: "inherit"
1529
+ });
1530
+ if (result.status !== 0) {
1531
+ throw new Error(
1532
+ `${packageManager} install failed with exit code ${result.status}`
1533
+ );
1534
+ }
1535
+ }
1536
+ var AUTH_DIR = path9__default.default.join(os__default.default.homedir(), ".onexthm");
1537
+ path9__default.default.join(AUTH_DIR, "auth.json");
1538
+ function getApiUrl() {
1539
+ return process.env.ONEXTHM_API_URL || process.env.NEXT_PUBLIC_API_URL || "https://platform-dev.onexeos.com";
1540
+ }
1541
+ function getNpxCommand() {
1542
+ return process.platform === "win32" ? "npx.cmd" : "npx";
1543
+ }
1544
+ function getDefaultMcpConfig() {
1545
+ return {
1546
+ mcpServers: {
1547
+ onexthm: {
1548
+ command: getNpxCommand(),
1549
+ args: ["-y", "@onexapis/theme-mcp"]
1550
+ }
1551
+ }
1552
+ };
1553
+ }
1554
+ function ensureMcpJson(projectPath, figmaApiKey) {
1555
+ const mcpJsonPath = path9__default.default.join(projectPath, ".mcp.json");
1556
+ const npx = getNpxCommand();
1557
+ let mcpConfig;
1558
+ if (fs4__default.default.existsSync(mcpJsonPath)) {
1525
1559
  try {
1526
- const installCmd = packageManager === "yarn" ? "yarn" : `${packageManager} install`;
1527
- child_process.execSync(installCmd, {
1528
- cwd: projectPath,
1529
- stdio: "inherit"
1530
- });
1531
- resolve();
1532
- } catch (error) {
1533
- reject(error);
1560
+ mcpConfig = JSON.parse(fs4__default.default.readFileSync(mcpJsonPath, "utf-8"));
1561
+ if (!mcpConfig.mcpServers) {
1562
+ mcpConfig.mcpServers = {};
1563
+ }
1564
+ } catch {
1565
+ mcpConfig = getDefaultMcpConfig();
1534
1566
  }
1535
- });
1567
+ } else {
1568
+ mcpConfig = getDefaultMcpConfig();
1569
+ }
1570
+ mcpConfig.mcpServers.onexthm = {
1571
+ command: npx,
1572
+ args: ["-y", "@onexapis/theme-mcp"]
1573
+ };
1574
+ if (figmaApiKey) {
1575
+ mcpConfig.mcpServers.figma = {
1576
+ command: npx,
1577
+ args: [
1578
+ "-y",
1579
+ "figma-developer-mcp",
1580
+ `--figma-api-key=${figmaApiKey}`,
1581
+ "--stdio"
1582
+ ]
1583
+ };
1584
+ } else {
1585
+ delete mcpConfig.mcpServers.figma;
1586
+ }
1587
+ fs4__default.default.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2) + "\n");
1588
+ ensureThemeMcpDependency(projectPath);
1589
+ }
1590
+ function ensureThemeMcpDependency(projectPath) {
1591
+ const pkgJsonPath = path9__default.default.join(projectPath, "package.json");
1592
+ if (!fs4__default.default.existsSync(pkgJsonPath)) return;
1593
+ try {
1594
+ const pkg = JSON.parse(fs4__default.default.readFileSync(pkgJsonPath, "utf-8"));
1595
+ if (!pkg.devDependencies) {
1596
+ pkg.devDependencies = {};
1597
+ }
1598
+ if (!pkg.devDependencies["@onexapis/theme-mcp"]) {
1599
+ pkg.devDependencies["@onexapis/theme-mcp"] = "^0.1.0";
1600
+ fs4__default.default.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + "\n");
1601
+ }
1602
+ } catch {
1603
+ }
1536
1604
  }
1537
1605
 
1538
1606
  // src/commands/init.ts
@@ -1551,7 +1619,7 @@ async function initCommand(projectName, options = {}) {
1551
1619
  if (!validateThemeName(kebabName)) {
1552
1620
  return "Invalid project name. Use lowercase letters, numbers, and hyphens only.";
1553
1621
  }
1554
- if (fs2__default.default.existsSync(path7__default.default.join(process.cwd(), kebabName))) {
1622
+ if (fs4__default.default.existsSync(path9__default.default.join(process.cwd(), kebabName))) {
1555
1623
  return `Directory "${kebabName}" already exists`;
1556
1624
  }
1557
1625
  return true;
@@ -1562,11 +1630,46 @@ async function initCommand(projectName, options = {}) {
1562
1630
  } else {
1563
1631
  name = toKebabCase(projectName);
1564
1632
  }
1565
- const projectPath = path7__default.default.join(process.cwd(), name);
1566
- if (fs2__default.default.existsSync(projectPath)) {
1633
+ const projectPath = path9__default.default.join(process.cwd(), name);
1634
+ if (fs4__default.default.existsSync(projectPath)) {
1567
1635
  exports.logger.error(`Directory "${name}" already exists.`);
1568
1636
  process.exit(1);
1569
1637
  }
1638
+ if (!options.yes) {
1639
+ try {
1640
+ const apiUrl = getApiUrl();
1641
+ const controller = new AbortController();
1642
+ const timeout = setTimeout(() => controller.abort(), 3e3);
1643
+ const response = await fetch(
1644
+ `${apiUrl}/website-api/themes/${encodeURIComponent(name)}/exists`,
1645
+ { signal: controller.signal }
1646
+ );
1647
+ clearTimeout(timeout);
1648
+ if (response.ok) {
1649
+ const data2 = await response.json();
1650
+ const body = data2.statusCode ? data2.body : data2;
1651
+ if (body.exists && body.owner === "other") {
1652
+ exports.logger.warning(
1653
+ `Theme ID "${name}" is already registered by another developer.
1654
+ You can still create this locally, but publishing will fail.
1655
+ Consider using a different name.`
1656
+ );
1657
+ const { proceed } = await inquirer__default.default.prompt([
1658
+ {
1659
+ type: "confirm",
1660
+ name: "proceed",
1661
+ message: "Continue anyway?",
1662
+ default: false
1663
+ }
1664
+ ]);
1665
+ if (!proceed) {
1666
+ process.exit(0);
1667
+ }
1668
+ }
1669
+ }
1670
+ } catch {
1671
+ }
1672
+ }
1570
1673
  let displayName;
1571
1674
  let description;
1572
1675
  let author;
@@ -1634,7 +1737,7 @@ async function initCommand(projectName, options = {}) {
1634
1737
  }
1635
1738
  exports.logger.startSpinner("Creating project structure...");
1636
1739
  try {
1637
- fs2__default.default.mkdirSync(projectPath, { recursive: true });
1740
+ fs4__default.default.mkdirSync(projectPath, { recursive: true });
1638
1741
  await copyTemplate(template, projectPath, data);
1639
1742
  await renameThemeInFiles(
1640
1743
  projectPath,
@@ -1643,28 +1746,14 @@ async function initCommand(projectName, options = {}) {
1643
1746
  description,
1644
1747
  author
1645
1748
  );
1646
- const mcpJsonPath = path7__default.default.join(projectPath, ".mcp.json");
1647
- if (fs2__default.default.existsSync(mcpJsonPath)) {
1648
- let mcpContent = fs2__default.default.readFileSync(mcpJsonPath, "utf-8");
1649
- if (figmaApiKey) {
1650
- mcpContent = mcpContent.replace("__FIGMA_API_KEY__", figmaApiKey);
1651
- } else {
1652
- try {
1653
- const mcpJson = JSON.parse(mcpContent);
1654
- delete mcpJson.mcpServers.figma;
1655
- mcpContent = JSON.stringify(mcpJson, null, 2) + "\n";
1656
- } catch {
1657
- }
1658
- }
1659
- fs2__default.default.writeFileSync(mcpJsonPath, mcpContent, "utf-8");
1660
- }
1749
+ ensureMcpJson(projectPath, figmaApiKey || void 0);
1661
1750
  exports.logger.stopSpinner(true, "Project structure created!");
1662
1751
  if (options.git) {
1663
1752
  exports.logger.startSpinner("Initializing git repository...");
1664
1753
  try {
1665
- child_process.execSync("git init", { cwd: projectPath, stdio: "ignore" });
1666
- child_process.execSync("git add .", { cwd: projectPath, stdio: "ignore" });
1667
- child_process.execSync('git commit -m "Initial commit from onexthm init"', {
1754
+ spawn2__default.default.sync("git", ["init"], { cwd: projectPath, stdio: "ignore" });
1755
+ spawn2__default.default.sync("git", ["add", "."], { cwd: projectPath, stdio: "ignore" });
1756
+ spawn2__default.default.sync("git", ["commit", "-m", "Initial commit from onexthm init"], {
1668
1757
  cwd: projectPath,
1669
1758
  stdio: "ignore"
1670
1759
  });
@@ -1716,16 +1805,16 @@ async function initCommand(projectName, options = {}) {
1716
1805
  exports.logger.error(
1717
1806
  error instanceof Error ? error.message : "Unknown error occurred"
1718
1807
  );
1719
- if (fs2__default.default.existsSync(projectPath)) {
1720
- fs2__default.default.rmSync(projectPath, { recursive: true, force: true });
1808
+ if (fs4__default.default.existsSync(projectPath)) {
1809
+ fs4__default.default.rmSync(projectPath, { recursive: true, force: true });
1721
1810
  }
1722
1811
  process.exit(1);
1723
1812
  }
1724
1813
  }
1725
1814
  async function renameThemeInFiles(projectPath, themeName, displayName, description, author) {
1726
- const configPath = path7__default.default.join(projectPath, "theme.config.ts");
1727
- if (fs2__default.default.existsSync(configPath)) {
1728
- let content = fs2__default.default.readFileSync(configPath, "utf-8");
1815
+ const configPath = path9__default.default.join(projectPath, "theme.config.ts");
1816
+ if (fs4__default.default.existsSync(configPath)) {
1817
+ let content = fs4__default.default.readFileSync(configPath, "utf-8");
1729
1818
  content = content.replace(
1730
1819
  /name: "My Simple Theme"/,
1731
1820
  `name: "${displayName}"`
@@ -1734,11 +1823,11 @@ async function renameThemeInFiles(projectPath, themeName, displayName, descripti
1734
1823
  /description: ".*?"/,
1735
1824
  `description: "${description}"`
1736
1825
  );
1737
- fs2__default.default.writeFileSync(configPath, content, "utf-8");
1826
+ fs4__default.default.writeFileSync(configPath, content, "utf-8");
1738
1827
  }
1739
- const pkgPath = path7__default.default.join(projectPath, "package.json");
1740
- if (fs2__default.default.existsSync(pkgPath)) {
1741
- let content = fs2__default.default.readFileSync(pkgPath, "utf-8");
1828
+ const pkgPath = path9__default.default.join(projectPath, "package.json");
1829
+ if (fs4__default.default.existsSync(pkgPath)) {
1830
+ let content = fs4__default.default.readFileSync(pkgPath, "utf-8");
1742
1831
  content = content.replace(
1743
1832
  /@onex-themes\/my-simple/g,
1744
1833
  `@onex-themes/${themeName}`
@@ -1747,7 +1836,7 @@ async function renameThemeInFiles(projectPath, themeName, displayName, descripti
1747
1836
  /"description": ".*?"/,
1748
1837
  `"description": "${description}"`
1749
1838
  );
1750
- fs2__default.default.writeFileSync(pkgPath, content, "utf-8");
1839
+ fs4__default.default.writeFileSync(pkgPath, content, "utf-8");
1751
1840
  }
1752
1841
  }
1753
1842
 
@@ -1758,10 +1847,10 @@ async function createSectionCommand(name, options) {
1758
1847
  ensureOneXProject();
1759
1848
  if (!options.theme) {
1760
1849
  const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
1761
- (f) => fs__default.default.existsSync(path7__default.default.join(process.cwd(), f))
1850
+ (f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f))
1762
1851
  );
1763
1852
  if (isStandaloneTheme) {
1764
- options.theme = path7__default.default.basename(process.cwd());
1853
+ options.theme = path9__default.default.basename(process.cwd());
1765
1854
  }
1766
1855
  }
1767
1856
  const sectionName = toKebabCase(name);
@@ -1824,35 +1913,35 @@ async function createSectionCommand(name, options) {
1824
1913
  };
1825
1914
  exports.logger.startSpinner("Creating section files...");
1826
1915
  try {
1827
- const themePath = path7__default.default.join(getThemesDir(), themeName);
1828
- const sectionPath = path7__default.default.join(themePath, "sections", sectionName);
1916
+ const themePath = path9__default.default.join(getThemesDir(), themeName);
1917
+ const sectionPath = path9__default.default.join(themePath, "sections", sectionName);
1829
1918
  const schemaContent = generateSectionSchema(data);
1830
1919
  await writeFile(
1831
- path7__default.default.join(sectionPath, `${sectionName}.schema.ts`),
1920
+ path9__default.default.join(sectionPath, `${sectionName}.schema.ts`),
1832
1921
  schemaContent
1833
1922
  );
1834
1923
  if (createTemplate) {
1835
1924
  const templateContent = generateSectionTemplate(data);
1836
1925
  await writeFile(
1837
- path7__default.default.join(sectionPath, `${sectionName}-default.tsx`),
1926
+ path9__default.default.join(sectionPath, `${sectionName}-default.tsx`),
1838
1927
  templateContent
1839
1928
  );
1840
1929
  }
1841
1930
  const indexContent = generateSectionIndex(data, createTemplate);
1842
- await writeFile(path7__default.default.join(sectionPath, "index.ts"), indexContent);
1931
+ await writeFile(path9__default.default.join(sectionPath, "index.ts"), indexContent);
1843
1932
  exports.logger.stopSpinner(true, "Section files created successfully!");
1844
1933
  exports.logger.newLine();
1845
1934
  exports.logger.section("Next steps:");
1846
1935
  exports.logger.log(
1847
- ` 1. Edit schema: ${path7__default.default.relative(process.cwd(), path7__default.default.join(sectionPath, `${sectionName}.schema.ts`))}`
1936
+ ` 1. Edit schema: ${path9__default.default.relative(process.cwd(), path9__default.default.join(sectionPath, `${sectionName}.schema.ts`))}`
1848
1937
  );
1849
1938
  if (createTemplate) {
1850
1939
  exports.logger.log(
1851
- ` 2. Edit template: ${path7__default.default.relative(process.cwd(), path7__default.default.join(sectionPath, `${sectionName}-default.tsx`))}`
1940
+ ` 2. Edit template: ${path9__default.default.relative(process.cwd(), path9__default.default.join(sectionPath, `${sectionName}-default.tsx`))}`
1852
1941
  );
1853
1942
  }
1854
1943
  exports.logger.log(
1855
- ` 3. Add to theme manifest: ${path7__default.default.relative(process.cwd(), path7__default.default.join(themePath, "manifest.ts"))}`
1944
+ ` 3. Add to theme manifest: ${path9__default.default.relative(process.cwd(), path9__default.default.join(themePath, "manifest.ts"))}`
1856
1945
  );
1857
1946
  exports.logger.newLine();
1858
1947
  exports.logger.success("Section created successfully!");
@@ -2000,10 +2089,10 @@ async function createBlockCommand(name, options) {
2000
2089
  ensureOneXProject();
2001
2090
  if (!options.theme) {
2002
2091
  const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
2003
- (f) => fs__default.default.existsSync(path7__default.default.join(process.cwd(), f))
2092
+ (f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f))
2004
2093
  );
2005
2094
  if (isStandaloneTheme) {
2006
- options.theme = path7__default.default.basename(process.cwd());
2095
+ options.theme = path9__default.default.basename(process.cwd());
2007
2096
  }
2008
2097
  }
2009
2098
  const blockName = toKebabCase(name);
@@ -2078,24 +2167,24 @@ async function createBlockCommand(name, options) {
2078
2167
  };
2079
2168
  exports.logger.startSpinner("Creating block files...");
2080
2169
  try {
2081
- const blockPath = scope === "shared" ? path7__default.default.join(getFeaturesDir(), "blocks", blockName) : path7__default.default.join(getThemesDir(), themeName, "blocks", blockName);
2170
+ const blockPath = scope === "shared" ? path9__default.default.join(getFeaturesDir(), "blocks", blockName) : path9__default.default.join(getThemesDir(), themeName, "blocks", blockName);
2082
2171
  const schemaContent = generateBlockSchema(data);
2083
2172
  await writeFile(
2084
- path7__default.default.join(blockPath, `${blockName}.schema.ts`),
2173
+ path9__default.default.join(blockPath, `${blockName}.schema.ts`),
2085
2174
  schemaContent
2086
2175
  );
2087
2176
  const componentContent = generateBlockComponent(data);
2088
- await writeFile(path7__default.default.join(blockPath, `${blockName}.tsx`), componentContent);
2177
+ await writeFile(path9__default.default.join(blockPath, `${blockName}.tsx`), componentContent);
2089
2178
  const indexContent = generateBlockIndex(data);
2090
- await writeFile(path7__default.default.join(blockPath, "index.ts"), indexContent);
2179
+ await writeFile(path9__default.default.join(blockPath, "index.ts"), indexContent);
2091
2180
  exports.logger.stopSpinner(true, "Block files created successfully!");
2092
2181
  exports.logger.newLine();
2093
2182
  exports.logger.section("Next steps:");
2094
2183
  exports.logger.log(
2095
- ` 1. Edit schema: ${path7__default.default.relative(process.cwd(), path7__default.default.join(blockPath, `${blockName}.schema.ts`))}`
2184
+ ` 1. Edit schema: ${path9__default.default.relative(process.cwd(), path9__default.default.join(blockPath, `${blockName}.schema.ts`))}`
2096
2185
  );
2097
2186
  exports.logger.log(
2098
- ` 2. Edit component: ${path7__default.default.relative(process.cwd(), path7__default.default.join(blockPath, `${blockName}.tsx`))}`
2187
+ ` 2. Edit component: ${path9__default.default.relative(process.cwd(), path9__default.default.join(blockPath, `${blockName}.tsx`))}`
2099
2188
  );
2100
2189
  exports.logger.log(
2101
2190
  ` 3. Register in block registry: src/lib/registry/block-registry.ts`
@@ -2273,31 +2362,31 @@ async function createComponentCommand(name, options) {
2273
2362
  };
2274
2363
  exports.logger.startSpinner("Creating component files...");
2275
2364
  try {
2276
- const componentPath = path7__default.default.join(
2365
+ const componentPath = path9__default.default.join(
2277
2366
  getFeaturesDir(),
2278
2367
  "components",
2279
2368
  componentName
2280
2369
  );
2281
2370
  const schemaContent = generateComponentSchema(data);
2282
2371
  await writeFile(
2283
- path7__default.default.join(componentPath, `${componentName}.schema.ts`),
2372
+ path9__default.default.join(componentPath, `${componentName}.schema.ts`),
2284
2373
  schemaContent
2285
2374
  );
2286
2375
  const componentContent = generateComponent(data);
2287
2376
  await writeFile(
2288
- path7__default.default.join(componentPath, `${componentName}.tsx`),
2377
+ path9__default.default.join(componentPath, `${componentName}.tsx`),
2289
2378
  componentContent
2290
2379
  );
2291
2380
  const indexContent = generateComponentIndex(data);
2292
- await writeFile(path7__default.default.join(componentPath, "index.ts"), indexContent);
2381
+ await writeFile(path9__default.default.join(componentPath, "index.ts"), indexContent);
2293
2382
  exports.logger.stopSpinner(true, "Component files created successfully!");
2294
2383
  exports.logger.newLine();
2295
2384
  exports.logger.section("Next steps:");
2296
2385
  exports.logger.log(
2297
- ` 1. Edit schema: ${path7__default.default.relative(process.cwd(), path7__default.default.join(componentPath, `${componentName}.schema.ts`))}`
2386
+ ` 1. Edit schema: ${path9__default.default.relative(process.cwd(), path9__default.default.join(componentPath, `${componentName}.schema.ts`))}`
2298
2387
  );
2299
2388
  exports.logger.log(
2300
- ` 2. Edit component: ${path7__default.default.relative(process.cwd(), path7__default.default.join(componentPath, `${componentName}.tsx`))}`
2389
+ ` 2. Edit component: ${path9__default.default.relative(process.cwd(), path9__default.default.join(componentPath, `${componentName}.tsx`))}`
2301
2390
  );
2302
2391
  exports.logger.log(
2303
2392
  ` 3. Register in component registry: src/lib/registry/component-registry.ts`
@@ -2454,13 +2543,13 @@ async function listSections(themeFilter) {
2454
2543
  return;
2455
2544
  }
2456
2545
  for (const theme of themes) {
2457
- const sectionsDir = path7__default.default.join(getThemesDir(), theme, "sections");
2546
+ const sectionsDir = path9__default.default.join(getThemesDir(), theme, "sections");
2458
2547
  if (!fs__default.default.existsSync(sectionsDir)) {
2459
2548
  continue;
2460
2549
  }
2461
2550
  const sections = fs__default.default.readdirSync(sectionsDir).filter((name) => {
2462
- const sectionPath = path7__default.default.join(sectionsDir, name);
2463
- return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(path7__default.default.join(sectionPath, "index.ts"));
2551
+ const sectionPath = path9__default.default.join(sectionsDir, name);
2552
+ return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(path9__default.default.join(sectionPath, "index.ts"));
2464
2553
  });
2465
2554
  if (sections.length > 0) {
2466
2555
  exports.logger.log(chalk4__default.default.cyan(`
@@ -2474,11 +2563,11 @@ async function listSections(themeFilter) {
2474
2563
  }
2475
2564
  async function listBlocks(themeFilter) {
2476
2565
  exports.logger.section("\u{1F9F1} Blocks");
2477
- const sharedBlocksDir = path7__default.default.join(getFeaturesDir(), "blocks");
2566
+ const sharedBlocksDir = path9__default.default.join(getFeaturesDir(), "blocks");
2478
2567
  if (fs__default.default.existsSync(sharedBlocksDir)) {
2479
2568
  const sharedBlocks = fs__default.default.readdirSync(sharedBlocksDir).filter((name) => {
2480
- const blockPath = path7__default.default.join(sharedBlocksDir, name);
2481
- return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path7__default.default.join(blockPath, "index.ts"));
2569
+ const blockPath = path9__default.default.join(sharedBlocksDir, name);
2570
+ return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path9__default.default.join(blockPath, "index.ts"));
2482
2571
  });
2483
2572
  if (sharedBlocks.length > 0) {
2484
2573
  exports.logger.log(chalk4__default.default.cyan("\n Shared:"));
@@ -2489,13 +2578,13 @@ async function listBlocks(themeFilter) {
2489
2578
  }
2490
2579
  const themes = themeFilter ? [themeFilter] : listThemes();
2491
2580
  for (const theme of themes) {
2492
- const blocksDir = path7__default.default.join(getThemesDir(), theme, "blocks");
2581
+ const blocksDir = path9__default.default.join(getThemesDir(), theme, "blocks");
2493
2582
  if (!fs__default.default.existsSync(blocksDir)) {
2494
2583
  continue;
2495
2584
  }
2496
2585
  const blocks = fs__default.default.readdirSync(blocksDir).filter((name) => {
2497
- const blockPath = path7__default.default.join(blocksDir, name);
2498
- return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path7__default.default.join(blockPath, "index.ts"));
2586
+ const blockPath = path9__default.default.join(blocksDir, name);
2587
+ return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path9__default.default.join(blockPath, "index.ts"));
2499
2588
  });
2500
2589
  if (blocks.length > 0) {
2501
2590
  exports.logger.log(chalk4__default.default.cyan(`
@@ -2509,14 +2598,14 @@ async function listBlocks(themeFilter) {
2509
2598
  }
2510
2599
  async function listComponents() {
2511
2600
  exports.logger.section("\u2699\uFE0F Components");
2512
- const componentsDir = path7__default.default.join(getFeaturesDir(), "components");
2601
+ const componentsDir = path9__default.default.join(getFeaturesDir(), "components");
2513
2602
  if (!fs__default.default.existsSync(componentsDir)) {
2514
2603
  exports.logger.warning("No components directory found");
2515
2604
  return;
2516
2605
  }
2517
2606
  const components = fs__default.default.readdirSync(componentsDir).filter((name) => {
2518
- const componentPath = path7__default.default.join(componentsDir, name);
2519
- return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(path7__default.default.join(componentPath, "index.ts"));
2607
+ const componentPath = path9__default.default.join(componentsDir, name);
2608
+ return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(path9__default.default.join(componentPath, "index.ts"));
2520
2609
  });
2521
2610
  if (components.length === 0) {
2522
2611
  exports.logger.warning("No components found");
@@ -2537,11 +2626,11 @@ async function listThemesInfo() {
2537
2626
  }
2538
2627
  exports.logger.log("");
2539
2628
  for (const theme of themes) {
2540
- const themeDir = path7__default.default.join(getThemesDir(), theme);
2629
+ const themeDir = path9__default.default.join(getThemesDir(), theme);
2541
2630
  const candidates = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"];
2542
2631
  let manifestContent = "";
2543
2632
  for (const candidate of candidates) {
2544
- const candidatePath = path7__default.default.join(themeDir, candidate);
2633
+ const candidatePath = path9__default.default.join(themeDir, candidate);
2545
2634
  if (fs__default.default.existsSync(candidatePath)) {
2546
2635
  manifestContent = fs__default.default.readFileSync(candidatePath, "utf-8");
2547
2636
  break;
@@ -2570,14 +2659,14 @@ async function buildCommand(options) {
2570
2659
  if (options.theme) {
2571
2660
  themeName = options.theme;
2572
2661
  try {
2573
- const workspaceThemePath = path7__default.default.join(getThemesDir(), themeName);
2662
+ const workspaceThemePath = path9__default.default.join(getThemesDir(), themeName);
2574
2663
  if (fs__default.default.existsSync(workspaceThemePath)) {
2575
2664
  themePath = workspaceThemePath;
2576
2665
  } else {
2577
- themePath = path7__default.default.join(process.cwd(), themeName);
2666
+ themePath = path9__default.default.join(process.cwd(), themeName);
2578
2667
  }
2579
2668
  } catch {
2580
- themePath = path7__default.default.join(process.cwd(), themeName);
2669
+ themePath = path9__default.default.join(process.cwd(), themeName);
2581
2670
  }
2582
2671
  if (!fs__default.default.existsSync(themePath)) {
2583
2672
  exports.logger.error(`Theme "${themeName}" not found.`);
@@ -2588,10 +2677,10 @@ async function buildCommand(options) {
2588
2677
  "theme.config.ts",
2589
2678
  "bundle-entry.ts",
2590
2679
  "manifest.ts"
2591
- ].some((f) => fs__default.default.existsSync(path7__default.default.join(process.cwd(), f)));
2680
+ ].some((f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f)));
2592
2681
  if (isThemeDir) {
2593
2682
  themePath = process.cwd();
2594
- themeName = path7__default.default.basename(themePath);
2683
+ themeName = path9__default.default.basename(themePath);
2595
2684
  exports.logger.info(`Building current theme: ${themeName}`);
2596
2685
  } else {
2597
2686
  exports.logger.error(
@@ -2600,7 +2689,7 @@ async function buildCommand(options) {
2600
2689
  process.exit(1);
2601
2690
  }
2602
2691
  }
2603
- const packageJsonPath = path7__default.default.join(themePath, "package.json");
2692
+ const packageJsonPath = path9__default.default.join(themePath, "package.json");
2604
2693
  const hasPkgJson = fs__default.default.existsSync(packageJsonPath);
2605
2694
  if (!hasPkgJson) {
2606
2695
  exports.logger.warning(
@@ -2656,9 +2745,9 @@ async function buildCommand(options) {
2656
2745
  exports.logger.success("\u2713 Theme built successfully!");
2657
2746
  exports.logger.newLine();
2658
2747
  exports.logger.info(`Theme: ${themeName}`);
2659
- const distPath = path7__default.default.join(themePath, "dist");
2748
+ const distPath = path9__default.default.join(themePath, "dist");
2660
2749
  if (fs__default.default.existsSync(distPath)) {
2661
- exports.logger.log(`Output: ${path7__default.default.relative(process.cwd(), distPath)}`);
2750
+ exports.logger.log(`Output: ${path9__default.default.relative(process.cwd(), distPath)}`);
2662
2751
  const files = fs__default.default.readdirSync(distPath);
2663
2752
  exports.logger.log(`Files: ${files.length}`);
2664
2753
  }
@@ -2666,17 +2755,17 @@ async function buildCommand(options) {
2666
2755
  }
2667
2756
  function runCommand(command, args, cwd) {
2668
2757
  return new Promise((resolve) => {
2669
- const proc = child_process.spawn(command, args, {
2758
+ const proc = spawn2__default.default(command, args, {
2670
2759
  cwd,
2671
2760
  stdio: ["pipe", "pipe", "pipe"],
2672
2761
  shell: true
2673
2762
  });
2674
2763
  let stdout = "";
2675
2764
  let stderr = "";
2676
- proc.stdout.on("data", (data) => {
2765
+ proc.stdout?.on("data", (data) => {
2677
2766
  stdout += data.toString();
2678
2767
  });
2679
- proc.stderr.on("data", (data) => {
2768
+ proc.stderr?.on("data", (data) => {
2680
2769
  stderr += data.toString();
2681
2770
  });
2682
2771
  proc.on("close", (code) => {
@@ -2746,11 +2835,11 @@ function getBucketName(env) {
2746
2835
  return environment === "production" ? "theme-s3-bucket" : "theme-s3-bucket";
2747
2836
  }
2748
2837
  async function findCompiledThemeDir(themeId, version) {
2749
- const searchPaths = [path7__default.default.resolve(process.cwd(), "dist")];
2838
+ const searchPaths = [path9__default.default.resolve(process.cwd(), "dist")];
2750
2839
  for (const dir of searchPaths) {
2751
2840
  if (await fs__default.default.pathExists(dir)) {
2752
- const hasManifest = await fs__default.default.pathExists(path7__default.default.join(dir, "manifest.json"));
2753
- const hasThemeEntry = await fs__default.default.pathExists(path7__default.default.join(dir, "bundle-entry.js")) || await fs__default.default.pathExists(path7__default.default.join(dir, "theme.config.js")) || await fs__default.default.pathExists(path7__default.default.join(dir, "index.js"));
2841
+ const hasManifest = await fs__default.default.pathExists(path9__default.default.join(dir, "manifest.json"));
2842
+ const hasThemeEntry = await fs__default.default.pathExists(path9__default.default.join(dir, "bundle-entry.js")) || await fs__default.default.pathExists(path9__default.default.join(dir, "theme.config.js")) || await fs__default.default.pathExists(path9__default.default.join(dir, "index.js"));
2754
2843
  if (hasManifest || hasThemeEntry) {
2755
2844
  return dir;
2756
2845
  }
@@ -2759,7 +2848,7 @@ async function findCompiledThemeDir(themeId, version) {
2759
2848
  return null;
2760
2849
  }
2761
2850
  async function readManifest() {
2762
- const manifestTsPath = path7__default.default.resolve(process.cwd(), "manifest.ts");
2851
+ const manifestTsPath = path9__default.default.resolve(process.cwd(), "manifest.ts");
2763
2852
  if (await fs__default.default.pathExists(manifestTsPath)) {
2764
2853
  try {
2765
2854
  const module = await import(manifestTsPath);
@@ -2768,7 +2857,7 @@ async function readManifest() {
2768
2857
  exports.logger.warning("Failed to import manifest.ts, trying package.json");
2769
2858
  }
2770
2859
  }
2771
- const packageJsonPath = path7__default.default.resolve(process.cwd(), "package.json");
2860
+ const packageJsonPath = path9__default.default.resolve(process.cwd(), "package.json");
2772
2861
  if (await fs__default.default.pathExists(packageJsonPath)) {
2773
2862
  const pkg = await fs__default.default.readJson(packageJsonPath);
2774
2863
  return {
@@ -2802,13 +2891,13 @@ async function findSourceDir(themeId, explicitDir) {
2802
2891
  }
2803
2892
  const searchPaths = [
2804
2893
  process.cwd(),
2805
- path7__default.default.resolve(process.cwd(), `../../themes/${themeId}`),
2806
- path7__default.default.resolve(process.cwd(), `../themes/${themeId}`)
2894
+ path9__default.default.resolve(process.cwd(), `../../themes/${themeId}`),
2895
+ path9__default.default.resolve(process.cwd(), `../themes/${themeId}`)
2807
2896
  ];
2808
2897
  const markers = ["theme.config.ts", "bundle-entry.ts"];
2809
2898
  for (const dir of searchPaths) {
2810
2899
  for (const marker of markers) {
2811
- if (await fs__default.default.pathExists(path7__default.default.join(dir, marker))) {
2900
+ if (await fs__default.default.pathExists(path9__default.default.join(dir, marker))) {
2812
2901
  return dir;
2813
2902
  }
2814
2903
  }
@@ -2860,7 +2949,7 @@ async function uploadCommand(options) {
2860
2949
  spinner.succeed(`Found compiled theme at: ${compiledDir}`);
2861
2950
  spinner.start("Creating bundle.zip...");
2862
2951
  const tmpDir = os__default.default.tmpdir();
2863
- const bundleZipPath = path7__default.default.join(tmpDir, `${themeId}-${version}-bundle.zip`);
2952
+ const bundleZipPath = path9__default.default.join(tmpDir, `${themeId}-${version}-bundle.zip`);
2864
2953
  await createZipFromDir(compiledDir, bundleZipPath);
2865
2954
  const bundleZipBuffer = await fs__default.default.readFile(bundleZipPath);
2866
2955
  const bundleSizeMB = (bundleZipBuffer.length / 1024 / 1024).toFixed(2);
@@ -2914,7 +3003,7 @@ async function uploadCommand(options) {
2914
3003
  if (sourceDir) {
2915
3004
  spinner.succeed(`Found source at: ${sourceDir}`);
2916
3005
  spinner.start("Creating source.zip...");
2917
- const sourceZipPath = path7__default.default.join(
3006
+ const sourceZipPath = path9__default.default.join(
2918
3007
  tmpDir,
2919
3008
  `${themeId}-${version}-source.zip`
2920
3009
  );
@@ -3048,8 +3137,8 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
3048
3137
  async function createCompatibilityFiles(outputDir, manifest) {
3049
3138
  const entryFile = manifest.output?.entry || "bundle-entry.js";
3050
3139
  if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
3051
- const hashedPath = path7__default.default.join(outputDir, entryFile);
3052
- const stablePath = path7__default.default.join(outputDir, "bundle-entry.js");
3140
+ const hashedPath = path9__default.default.join(outputDir, entryFile);
3141
+ const stablePath = path9__default.default.join(outputDir, "bundle-entry.js");
3053
3142
  if (await fs__default.default.pathExists(hashedPath)) {
3054
3143
  await fs__default.default.copy(hashedPath, stablePath);
3055
3144
  const mapPath = hashedPath + ".map";
@@ -3058,13 +3147,13 @@ async function createCompatibilityFiles(outputDir, manifest) {
3058
3147
  }
3059
3148
  }
3060
3149
  }
3061
- const sectionsRegistryPath = path7__default.default.join(outputDir, "sections-registry.js");
3150
+ const sectionsRegistryPath = path9__default.default.join(outputDir, "sections-registry.js");
3062
3151
  const content = `// Re-export all sections from bundle-entry
3063
3152
  // This file exists to maintain compatibility with the import path
3064
3153
  export * from './bundle-entry.js';
3065
3154
  `;
3066
3155
  await fs__default.default.writeFile(sectionsRegistryPath, content, "utf-8");
3067
- const pkgJsonPath = path7__default.default.join(outputDir, "package.json");
3156
+ const pkgJsonPath = path9__default.default.join(outputDir, "package.json");
3068
3157
  await fs__default.default.writeFile(pkgJsonPath, '{\n "type": "module"\n}\n', "utf-8");
3069
3158
  }
3070
3159
  function showDownloadFailureHelp(themeId, bucket) {
@@ -3126,6 +3215,18 @@ async function downloadCommand(options) {
3126
3215
  spinner.succeed(
3127
3216
  `Resolved latest version: ${chalk4__default.default.cyan(resolvedVersion)}`
3128
3217
  );
3218
+ const isCI = !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.VERCEL);
3219
+ if (isCI) {
3220
+ console.log(
3221
+ chalk4__default.default.yellow(
3222
+ `
3223
+ Warning: Resolved "latest" to ${resolvedVersion} in CI environment.
3224
+ For production builds, pin to a specific version:
3225
+ THEME_VERSION=${resolvedVersion}
3226
+ `
3227
+ )
3228
+ );
3229
+ }
3129
3230
  }
3130
3231
  spinner.start(
3131
3232
  `Downloading bundle.zip for ${themeId}@${resolvedVersion}...`
@@ -3147,7 +3248,7 @@ async function downloadCommand(options) {
3147
3248
  zip.extractAllTo(outputDir, true);
3148
3249
  const entries = zip.getEntries().filter((e) => !e.isDirectory);
3149
3250
  spinner.succeed(`Extracted ${entries.length} files to ${outputDir}`);
3150
- const manifestPath = path7__default.default.join(outputDir, "manifest.json");
3251
+ const manifestPath = path9__default.default.join(outputDir, "manifest.json");
3151
3252
  const manifest = await fs__default.default.readJson(manifestPath);
3152
3253
  await createCompatibilityFiles(outputDir, manifest);
3153
3254
  console.log();
@@ -3247,10 +3348,9 @@ async function resolveLatestVersion2(s3Client, bucket, themeId) {
3247
3348
  }
3248
3349
  function runInstall(cwd) {
3249
3350
  return new Promise((resolve) => {
3250
- const proc = child_process.spawn("pnpm", ["install"], {
3351
+ const proc = spawn2__default.default("pnpm", ["install"], {
3251
3352
  cwd,
3252
- stdio: "inherit",
3253
- shell: true
3353
+ stdio: "inherit"
3254
3354
  });
3255
3355
  proc.on("close", (code) => resolve(code === 0));
3256
3356
  proc.on("error", () => resolve(false));
@@ -3281,7 +3381,7 @@ async function renameTheme(themeDir, oldName, newName) {
3281
3381
  const oldPrefix = `${oldName}-`;
3282
3382
  const newPrefix = `${newName}-`;
3283
3383
  const newDisplayName = newName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
3284
- const pkgPath = path7__default.default.join(themeDir, "package.json");
3384
+ const pkgPath = path9__default.default.join(themeDir, "package.json");
3285
3385
  if (await fs__default.default.pathExists(pkgPath)) {
3286
3386
  const pkg = await fs__default.default.readJson(pkgPath);
3287
3387
  pkg.name = `@onex-themes/${newName}`;
@@ -3297,7 +3397,7 @@ async function renameTheme(themeDir, oldName, newName) {
3297
3397
  }
3298
3398
  await fs__default.default.writeJson(pkgPath, pkg, { spaces: 2 });
3299
3399
  }
3300
- const configPath = path7__default.default.join(themeDir, "theme.config.ts");
3400
+ const configPath = path9__default.default.join(themeDir, "theme.config.ts");
3301
3401
  if (await fs__default.default.pathExists(configPath)) {
3302
3402
  let content = await fs__default.default.readFile(configPath, "utf-8");
3303
3403
  content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
@@ -3307,7 +3407,7 @@ async function renameTheme(themeDir, oldName, newName) {
3307
3407
  );
3308
3408
  await fs__default.default.writeFile(configPath, content);
3309
3409
  }
3310
- const layoutPath = path7__default.default.join(themeDir, "theme.layout.ts");
3410
+ const layoutPath = path9__default.default.join(themeDir, "theme.layout.ts");
3311
3411
  if (await fs__default.default.pathExists(layoutPath)) {
3312
3412
  let content = await fs__default.default.readFile(layoutPath, "utf-8");
3313
3413
  content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
@@ -3320,7 +3420,7 @@ async function renameTheme(themeDir, oldName, newName) {
3320
3420
  const oldDisplayName = oldName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
3321
3421
  const tsFiles = await glob.glob("**/*.ts", { cwd: themeDir, nodir: true });
3322
3422
  for (const file of tsFiles) {
3323
- const filePath = path7__default.default.join(themeDir, file);
3423
+ const filePath = path9__default.default.join(themeDir, file);
3324
3424
  let content = await fs__default.default.readFile(filePath, "utf-8");
3325
3425
  const original = content;
3326
3426
  content = content.replace(
@@ -3349,7 +3449,7 @@ async function cloneCommand(themeName, options) {
3349
3449
  const spinner = ora__default.default("Initializing clone...").start();
3350
3450
  try {
3351
3451
  const bucket = options.bucket || getBucketName3(options.environment);
3352
- const outputDir = options.output || path7__default.default.resolve(process.cwd(), newName);
3452
+ const outputDir = options.output || path9__default.default.resolve(process.cwd(), newName);
3353
3453
  const s3Client = getS3Client3();
3354
3454
  if (await fs__default.default.pathExists(outputDir)) {
3355
3455
  spinner.fail(chalk4__default.default.red(`Directory already exists: ${outputDir}`));
@@ -3404,7 +3504,7 @@ async function cloneCommand(themeName, options) {
3404
3504
  spinner.succeed(
3405
3505
  `Renamed theme: ${chalk4__default.default.gray(themeName)} \u2192 ${chalk4__default.default.cyan(newName)}`
3406
3506
  );
3407
- const envExamplePath = path7__default.default.join(outputDir, ".env.example");
3507
+ const envExamplePath = path9__default.default.join(outputDir, ".env.example");
3408
3508
  if (!await fs__default.default.pathExists(envExamplePath)) {
3409
3509
  await fs__default.default.writeFile(
3410
3510
  envExamplePath,
@@ -3417,32 +3517,18 @@ async function cloneCommand(themeName, options) {
3417
3517
  ].join("\n")
3418
3518
  );
3419
3519
  }
3420
- const mcpJsonPath = path7__default.default.join(outputDir, ".mcp.json");
3421
- if (await fs__default.default.pathExists(mcpJsonPath)) {
3422
- const { default: inquirerMod } = await import('inquirer');
3423
- const { figmaApiKey } = await inquirerMod.prompt([
3424
- {
3425
- type: "password",
3426
- name: "figmaApiKey",
3427
- message: "Figma API Key (optional, for Figma-to-code MCP \u2014 press Enter to skip):"
3428
- }
3429
- ]);
3430
- let mcpContent = await fs__default.default.readFile(mcpJsonPath, "utf-8");
3431
- if (figmaApiKey) {
3432
- mcpContent = mcpContent.replace("__FIGMA_API_KEY__", figmaApiKey);
3433
- } else {
3434
- try {
3435
- const mcpJson = JSON.parse(mcpContent);
3436
- delete mcpJson.mcpServers?.figma;
3437
- mcpContent = JSON.stringify(mcpJson, null, 2) + "\n";
3438
- } catch {
3439
- }
3520
+ const { default: inquirerMod } = await import('inquirer');
3521
+ const { figmaApiKey } = await inquirerMod.prompt([
3522
+ {
3523
+ type: "password",
3524
+ name: "figmaApiKey",
3525
+ message: "Figma API Key (optional, for Figma-to-code MCP \u2014 press Enter to skip):"
3440
3526
  }
3441
- await fs__default.default.writeFile(mcpJsonPath, mcpContent, "utf-8");
3442
- }
3527
+ ]);
3528
+ ensureMcpJson(outputDir, figmaApiKey || void 0);
3443
3529
  if (options.install !== false) {
3444
3530
  const hasPkgJson = await fs__default.default.pathExists(
3445
- path7__default.default.join(outputDir, "package.json")
3531
+ path9__default.default.join(outputDir, "package.json")
3446
3532
  );
3447
3533
  if (hasPkgJson) {
3448
3534
  spinner.start("Installing dependencies...");
@@ -3469,9 +3555,10 @@ async function cloneCommand(themeName, options) {
3469
3555
  console.log(chalk4__default.default.cyan(" Files: ") + chalk4__default.default.white(entries.length));
3470
3556
  console.log();
3471
3557
  console.log(chalk4__default.default.cyan("Next steps:"));
3472
- console.log(chalk4__default.default.gray(` cd ${path7__default.default.relative(process.cwd(), outputDir)}`));
3558
+ console.log(chalk4__default.default.gray(` cd ${path9__default.default.relative(process.cwd(), outputDir)}`));
3559
+ const copyCmd = process.platform === "win32" ? "copy .env.example .env" : "cp .env.example .env";
3473
3560
  console.log(
3474
- chalk4__default.default.gray(" cp .env.example .env # then add your Company ID")
3561
+ chalk4__default.default.gray(` ${copyCmd} # then add your Company ID`)
3475
3562
  );
3476
3563
  if (options.install === false) {
3477
3564
  console.log(chalk4__default.default.gray(" pnpm install"));