@onexapis/cli 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ var os = require('os');
17
17
  var archiver = require('archiver');
18
18
  var AdmZip = require('adm-zip');
19
19
 
20
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
20
21
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
22
 
22
23
  function _interopNamespace(e) {
@@ -53,7 +54,6 @@ var AdmZip__default = /*#__PURE__*/_interopDefault(AdmZip);
53
54
 
54
55
  var __defProp = Object.defineProperty;
55
56
  var __getOwnPropNames = Object.getOwnPropertyNames;
56
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
57
57
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
58
58
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
59
59
  }) : x)(function(x) {
@@ -67,7 +67,6 @@ var __export = (target, all) => {
67
67
  for (var name in all)
68
68
  __defProp(target, name, { get: all[name], enumerable: true });
69
69
  };
70
- var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
71
70
  exports.Logger = void 0; exports.logger = void 0;
72
71
  var init_logger = __esm({
73
72
  "src/utils/logger.ts"() {
@@ -140,7 +139,7 @@ async function resolveNodeModulesFile(startDir, relativePath) {
140
139
  try {
141
140
  await fs6__default.default.access(candidate);
142
141
  return candidate;
143
- } catch (e) {
142
+ } catch {
144
143
  const parent = path__default.default.dirname(dir);
145
144
  if (parent === dir) break;
146
145
  dir = parent;
@@ -159,7 +158,7 @@ function createCoreGlobalPlugin(themePath) {
159
158
  }));
160
159
  build2.onLoad({ filter: /.*/, namespace: "core-global" }, async (args) => {
161
160
  const match = args.path.match(/^@onexapis\/core(\/(.+))?$/);
162
- const subpath = (match == null ? void 0 : match[2]) || "";
161
+ const subpath = match?.[2] || "";
163
162
  const moduleAccess = subpath ? `['${subpath}']` : "";
164
163
  let namedExports = [];
165
164
  const cacheKey = subpath || "__root__";
@@ -183,7 +182,7 @@ function createCoreGlobalPlugin(themePath) {
183
182
  namedExports.push(...names);
184
183
  }
185
184
  namedExports = [...new Set(namedExports)];
186
- } catch (e) {
185
+ } catch {
187
186
  }
188
187
  exportsBySubpath[cacheKey] = namedExports;
189
188
  }
@@ -215,6 +214,73 @@ ${namedExportLines}
215
214
  }
216
215
  };
217
216
  }
217
+ async function generateThemeData(themePath, outputDir, themeId) {
218
+ const { createJiti } = await import('jiti');
219
+ const jiti = createJiti((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
220
+ let themeConfig = null;
221
+ let layoutConfig = null;
222
+ const pages = {};
223
+ for (const ext of [".ts", ".js"]) {
224
+ try {
225
+ const mod = await jiti.import(path__default.default.join(themePath, `theme.config${ext}`));
226
+ themeConfig = mod.default || mod;
227
+ break;
228
+ } catch {
229
+ }
230
+ }
231
+ for (const ext of [".ts", ".js"]) {
232
+ try {
233
+ const mod = await jiti.import(path__default.default.join(themePath, `theme.layout${ext}`));
234
+ layoutConfig = mod.default || mod;
235
+ break;
236
+ } catch {
237
+ }
238
+ }
239
+ const pagesDir = path__default.default.join(themePath, "pages");
240
+ try {
241
+ const files = await fs6__default.default.readdir(pagesDir);
242
+ for (const file of files) {
243
+ if (!file.match(/\.(ts|js)$/)) continue;
244
+ const name = file.replace(/\.(ts|js)$/, "");
245
+ try {
246
+ const mod = await jiti.import(path__default.default.join(pagesDir, file));
247
+ const config = mod.default || mod;
248
+ pages[name] = {
249
+ id: name,
250
+ name: config.title || name,
251
+ path: config.path || `/${name}`,
252
+ config: { id: name, ...config },
253
+ sections: config.sections || [],
254
+ seo: config.seo
255
+ };
256
+ } catch {
257
+ }
258
+ }
259
+ } catch {
260
+ }
261
+ await fs6__default.default.writeFile(
262
+ path__default.default.join(outputDir, "theme-data.json"),
263
+ JSON.stringify(
264
+ {
265
+ themeId,
266
+ theme: {
267
+ id: themeId,
268
+ name: themeConfig?.name || themeId,
269
+ config: themeConfig,
270
+ layout: {
271
+ header: layoutConfig?.headerSections || [],
272
+ footer: layoutConfig?.footerSections || []
273
+ },
274
+ pages: Object.keys(pages)
275
+ },
276
+ pages
277
+ },
278
+ null,
279
+ 2
280
+ )
281
+ );
282
+ exports.logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
283
+ }
218
284
  async function contentHashEntry(outputDir) {
219
285
  const entryPath = path__default.default.join(outputDir, "bundle-entry.js");
220
286
  const mapPath = path__default.default.join(outputDir, "bundle-entry.js.map");
@@ -225,11 +291,11 @@ async function contentHashEntry(outputDir) {
225
291
  let entryContent;
226
292
  try {
227
293
  entryContent = await fs6__default.default.readFile(entryPath, "utf-8");
228
- } catch (e) {
294
+ } catch {
229
295
  const indexPath = path__default.default.join(outputDir, "index.js");
230
296
  try {
231
297
  entryContent = await fs6__default.default.readFile(indexPath, "utf-8");
232
- } catch (e2) {
298
+ } catch {
233
299
  exports.logger.warning("No entry file found in output, skipping content hash");
234
300
  return;
235
301
  }
@@ -246,7 +312,7 @@ async function contentHashEntry(outputDir) {
246
312
  try {
247
313
  await fs6__default.default.access(indexMapPath);
248
314
  await fs6__default.default.rename(indexMapPath, path__default.default.join(outputDir, hashedMapName2));
249
- } catch (e2) {
315
+ } catch {
250
316
  }
251
317
  exports.logger.info(`Entry hashed: ${hashedName2}`);
252
318
  return;
@@ -263,10 +329,32 @@ async function contentHashEntry(outputDir) {
263
329
  try {
264
330
  await fs6__default.default.access(mapPath);
265
331
  await fs6__default.default.rename(mapPath, path__default.default.join(outputDir, hashedMapName));
266
- } catch (e) {
332
+ } catch {
267
333
  }
268
334
  exports.logger.info(`Entry hashed: ${hashedName}`);
269
335
  }
336
+ async function extractDataRequirements(themePath) {
337
+ const { createJiti } = await import('jiti');
338
+ const jiti = createJiti((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
339
+ const schemaFiles = await glob.glob("sections/**/*.schema.ts", { cwd: themePath });
340
+ const requirements = {};
341
+ for (const file of schemaFiles) {
342
+ try {
343
+ const mod = await jiti.import(path__default.default.join(themePath, file));
344
+ const exports$1 = mod;
345
+ for (const value of Object.values(exports$1)) {
346
+ if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
347
+ requirements[value.type] = value.dataRequirements;
348
+ }
349
+ }
350
+ } catch (err) {
351
+ exports.logger.warning(
352
+ `Could not load schema ${file}: ${err instanceof Error ? err.message : String(err)}`
353
+ );
354
+ }
355
+ }
356
+ return requirements;
357
+ }
270
358
  async function generateManifest2(themeName, themePath, outputDir) {
271
359
  let version = "1.0.0";
272
360
  let themeId = themeName;
@@ -280,18 +368,19 @@ async function generateManifest2(themeName, themePath, outputDir) {
280
368
  if (pkg.name) {
281
369
  themeId = pkg.name.replace(/^@onex-themes\//, "");
282
370
  }
283
- } catch (e) {
371
+ } catch {
284
372
  }
285
373
  const [sectionFiles, blockFiles, schemaFiles] = await Promise.all([
286
374
  glob.glob("sections/**/index.ts", { cwd: themePath }),
287
375
  glob.glob("blocks/**/index.ts", { cwd: themePath }),
288
376
  glob.glob("**/*.schema.ts", { cwd: themePath })
289
377
  ]);
378
+ const dataRequirements = await extractDataRequirements(themePath);
290
379
  let hasThemeConfig = false;
291
380
  try {
292
381
  await fs6__default.default.access(path__default.default.join(themePath, "theme.config.ts"));
293
382
  hasThemeConfig = true;
294
- } catch (e) {
383
+ } catch {
295
384
  }
296
385
  const allFiles = await glob.glob("**/*", { cwd: outputDir, nodir: true });
297
386
  const jsFiles = allFiles.filter((f) => f.endsWith(".js"));
@@ -326,7 +415,9 @@ async function generateManifest2(themeName, themePath, outputDir) {
326
415
  blocks: blockFiles,
327
416
  schemas: schemaFiles,
328
417
  hasThemeConfig
329
- }
418
+ },
419
+ // Section data requirements for server-side prefetching (keyed by section type)
420
+ dataRequirements
330
421
  };
331
422
  await fs6__default.default.writeFile(
332
423
  path__default.default.join(outputDir, "manifest.json"),
@@ -341,7 +432,7 @@ async function compileStandaloneTheme(themePath, themeName) {
341
432
  try {
342
433
  await fs6__default.default.access(bundleEntry);
343
434
  entryPoint = bundleEntry;
344
- } catch (e) {
435
+ } catch {
345
436
  }
346
437
  const shimPath = path__default.default.join(outputDir, ".process-shim.js");
347
438
  await fs6__default.default.mkdir(outputDir, { recursive: true });
@@ -392,10 +483,11 @@ async function compileStandaloneTheme(themePath, themeName) {
392
483
  const result = await esbuild__namespace.build(buildOptions);
393
484
  try {
394
485
  await fs6__default.default.unlink(shimPath);
395
- } catch (e) {
486
+ } catch {
396
487
  }
397
488
  await contentHashEntry(outputDir);
398
489
  await generateManifest2(themeName, themePath, outputDir);
490
+ await generateThemeData(themePath, outputDir, themeName);
399
491
  if (result.metafile) {
400
492
  const outputs = result.metafile.outputs;
401
493
  let totalSize = 0;
@@ -409,7 +501,7 @@ async function compileStandaloneTheme(themePath, themeName) {
409
501
  } catch (error) {
410
502
  try {
411
503
  await fs6__default.default.unlink(shimPath);
412
- } catch (e) {
504
+ } catch {
413
505
  }
414
506
  exports.logger.error(`esbuild compilation failed: ${error}`);
415
507
  return false;
@@ -423,7 +515,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
423
515
  try {
424
516
  await fs6__default.default.access(bundleEntry);
425
517
  entryPoint = bundleEntry;
426
- } catch (e) {
518
+ } catch {
427
519
  }
428
520
  const shimPath = path__default.default.join(outputDir, ".process-shim.js");
429
521
  await fs6__default.default.mkdir(outputDir, { recursive: true });
@@ -472,6 +564,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
472
564
  const context2 = await esbuild__namespace.context(buildOptions);
473
565
  await context2.rebuild();
474
566
  await generateManifest2(themeName, themePath, outputDir);
567
+ await generateThemeData(themePath, outputDir, themeName);
475
568
  return { context: context2, outputDir };
476
569
  }
477
570
  async function compilePreviewRuntime(themePath) {
@@ -489,7 +582,7 @@ async function compilePreviewRuntime(themePath) {
489
582
  await fs6__default.default.access(loc);
490
583
  previewEntryPath = loc;
491
584
  break;
492
- } catch (e) {
585
+ } catch {
493
586
  }
494
587
  }
495
588
  if (!previewEntryPath) {
@@ -529,10 +622,13 @@ ${locations.join("\n")}`
529
622
  "zlib"
530
623
  ];
531
624
  for (const mod of nodeBuiltins) {
532
- build2.onResolve({ filter: new RegExp(`^${mod.replace("/", "\\/")}$`) }, () => ({
533
- path: mod,
534
- namespace: "node-stub"
535
- }));
625
+ build2.onResolve(
626
+ { filter: new RegExp(`^${mod.replace("/", "\\/")}$`) },
627
+ () => ({
628
+ path: mod,
629
+ namespace: "node-stub"
630
+ })
631
+ );
536
632
  }
537
633
  build2.onLoad({ filter: /.*/, namespace: "node-stub" }, (args) => {
538
634
  const stubs = {
@@ -546,8 +642,7 @@ ${locations.join("\n")}`
546
642
  };
547
643
  });
548
644
  build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
549
- var _a;
550
- if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
645
+ if (args.pluginData?.skipStub) return void 0;
551
646
  try {
552
647
  const result = await build2.resolve(args.path, {
553
648
  kind: args.kind,
@@ -557,7 +652,7 @@ ${locations.join("\n")}`
557
652
  pluginData: { skipStub: true }
558
653
  });
559
654
  if (!result.errors.length) return result;
560
- } catch (e) {
655
+ } catch {
561
656
  }
562
657
  return { path: args.path, namespace: "lucide-stub" };
563
658
  });
@@ -579,8 +674,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
579
674
  loader: "jsx"
580
675
  }));
581
676
  build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
582
- var _a;
583
- if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
677
+ if (args.pluginData?.skipStub) return void 0;
584
678
  try {
585
679
  const result = await build2.resolve(args.path, {
586
680
  kind: args.kind,
@@ -590,7 +684,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
590
684
  pluginData: { skipStub: true }
591
685
  });
592
686
  if (!result.errors.length) return result;
593
- } catch (e) {
687
+ } catch {
594
688
  }
595
689
  return { path: args.path, namespace: "motion-stub" };
596
690
  });
@@ -604,8 +698,59 @@ export default { motion, AnimatePresence };
604
698
  `.trim(),
605
699
  loader: "jsx"
606
700
  }));
701
+ build2.onResolve({ filter: /^next\// }, async (args) => {
702
+ if (args.pluginData?.skipStub) return void 0;
703
+ try {
704
+ const result = await build2.resolve(args.path, {
705
+ kind: args.kind,
706
+ resolveDir: args.resolveDir,
707
+ importer: args.importer,
708
+ namespace: "file",
709
+ pluginData: { skipStub: true }
710
+ });
711
+ if (!result.errors.length) return result;
712
+ } catch {
713
+ }
714
+ return { path: args.path, namespace: "next-stub" };
715
+ });
716
+ build2.onLoad({ filter: /.*/, namespace: "next-stub" }, (args) => {
717
+ const stubs = {
718
+ "next/image": `
719
+ const Image = (props) => {
720
+ const { src, alt, width, height, fill, priority, ...rest } = props;
721
+ const imgSrc = typeof src === 'object' ? src.src : src;
722
+ return React.createElement('img', { src: imgSrc, alt, width: fill ? undefined : width, height: fill ? undefined : height, loading: priority ? 'eager' : 'lazy', ...rest });
723
+ };
724
+ import React from 'react';
725
+ export default Image;
726
+ `,
727
+ "next/link": `
728
+ const Link = ({ href, children, ...rest }) => React.createElement('a', { href, ...rest }, children);
729
+ import React from 'react';
730
+ export default Link;
731
+ `,
732
+ "next/navigation": `
733
+ export function useRouter() { return { push(u){window.location.href=u}, replace(u){window.location.href=u}, back(){window.history.back()}, forward(){window.history.forward()}, refresh(){window.location.reload()}, prefetch(){} }; }
734
+ export function usePathname() { return window.location.pathname; }
735
+ export function useSearchParams() { return new URLSearchParams(window.location.search); }
736
+ export function useParams() { return {}; }
737
+ export function redirect(url) { window.location.href = url; }
738
+ export function notFound() { throw new Error('Not Found'); }
739
+ `,
740
+ "next/headers": `
741
+ export function cookies() { return { get(){}, getAll(){ return []; }, set(){}, delete(){}, has(){ return false; } }; }
742
+ export function headers() { return new Headers(); }
743
+ `
744
+ };
745
+ return {
746
+ contents: stubs[args.path] || "export default {};",
747
+ loader: "jsx"
748
+ };
749
+ });
607
750
  }
608
751
  };
752
+ const shimPath = path__default.default.join(outputDir, ".process-shim-preview.js");
753
+ await fs6__default.default.writeFile(shimPath, PROCESS_SHIM);
609
754
  await esbuild__namespace.build({
610
755
  entryPoints: [previewEntryPath],
611
756
  bundle: true,
@@ -615,6 +760,7 @@ export default { motion, AnimatePresence };
615
760
  // Bundle React + core INTO the output (NOT externalized)
616
761
  external: [],
617
762
  plugins: [serverStubPlugin],
763
+ inject: [shimPath],
618
764
  minify: false,
619
765
  sourcemap: true,
620
766
  target: "es2020",
@@ -622,6 +768,12 @@ export default { motion, AnimatePresence };
622
768
  jsxImportSource: "react",
623
769
  define: {
624
770
  "process.env.NODE_ENV": JSON.stringify("development"),
771
+ "process.env.NEXT_PUBLIC_API_URL": JSON.stringify(
772
+ process.env.NEXT_PUBLIC_API_URL || ""
773
+ ),
774
+ "process.env.NEXT_PUBLIC_COMPANY_ID": JSON.stringify(
775
+ process.env.NEXT_PUBLIC_COMPANY_ID || ""
776
+ ),
625
777
  global: "globalThis"
626
778
  },
627
779
  loader: { ".tsx": "tsx", ".ts": "ts" },
@@ -632,6 +784,10 @@ export default { motion, AnimatePresence };
632
784
  "ignored-bare-import": "silent"
633
785
  }
634
786
  });
787
+ try {
788
+ await fs6__default.default.unlink(shimPath);
789
+ } catch {
790
+ }
635
791
  return outputPath;
636
792
  }
637
793
  var PROCESS_SHIM, reactGlobalPlugin;
@@ -1092,7 +1248,7 @@ Add your theme-specific blocks here.
1092
1248
  stdio: "ignore"
1093
1249
  });
1094
1250
  exports.logger.stopSpinner(true, "Git repository initialized!");
1095
- } catch (e) {
1251
+ } catch {
1096
1252
  exports.logger.stopSpinner(false, "Failed to initialize git");
1097
1253
  }
1098
1254
  }
@@ -1103,7 +1259,7 @@ Add your theme-specific blocks here.
1103
1259
  try {
1104
1260
  await installDependencies(projectPath, packageManager);
1105
1261
  exports.logger.stopSpinner(true, "Dependencies installed!");
1106
- } catch (e) {
1262
+ } catch {
1107
1263
  exports.logger.stopSpinner(false, "Failed to install dependencies");
1108
1264
  exports.logger.info(
1109
1265
  "You can install dependencies manually by running: cd " + name + " && npm install"
@@ -2185,7 +2341,6 @@ async function listThemesInfo() {
2185
2341
  // src/commands/build.ts
2186
2342
  init_logger();
2187
2343
  async function buildCommand(options) {
2188
- var _a;
2189
2344
  exports.logger.header("Build Theme");
2190
2345
  let themePath;
2191
2346
  let themeName;
@@ -2198,7 +2353,7 @@ async function buildCommand(options) {
2198
2353
  } else {
2199
2354
  themePath = path__default.default.join(process.cwd(), themeName);
2200
2355
  }
2201
- } catch (e) {
2356
+ } catch {
2202
2357
  themePath = path__default.default.join(process.cwd(), themeName);
2203
2358
  }
2204
2359
  if (!fs__default.default.existsSync(themePath)) {
@@ -2255,7 +2410,7 @@ async function buildCommand(options) {
2255
2410
  }
2256
2411
  exports.logger.stopSpinner(true, "Lint passed");
2257
2412
  const pkgJson = fs__default.default.readJsonSync(packageJsonPath);
2258
- const buildScript = ((_a = pkgJson.scripts) == null ? void 0 : _a.build) || "";
2413
+ const buildScript = pkgJson.scripts?.build || "";
2259
2414
  const isRecursive = buildScript.includes("onex build") || buildScript.includes("onex-cli build");
2260
2415
  exports.logger.startSpinner(
2261
2416
  options.watch ? "Building (watch mode)..." : "Building..."
@@ -2363,7 +2518,6 @@ async function findCompiledThemeDir(themeId, version) {
2363
2518
  return null;
2364
2519
  }
2365
2520
  async function readManifest() {
2366
- var _a;
2367
2521
  const manifestTsPath = path__default.default.resolve(process.cwd(), "manifest.ts");
2368
2522
  if (await fs__default.default.pathExists(manifestTsPath)) {
2369
2523
  try {
@@ -2377,7 +2531,7 @@ async function readManifest() {
2377
2531
  if (await fs__default.default.pathExists(packageJsonPath)) {
2378
2532
  const pkg = await fs__default.default.readJson(packageJsonPath);
2379
2533
  return {
2380
- themeId: ((_a = pkg.name) == null ? void 0 : _a.replace("@onex-themes/", "")) || "unknown",
2534
+ themeId: pkg.name?.replace("@onex-themes/", "") || "unknown",
2381
2535
  version: pkg.version || "1.0.0"
2382
2536
  };
2383
2537
  }
@@ -2621,39 +2775,15 @@ function getBucketName2(env) {
2621
2775
  }
2622
2776
  async function streamToString(stream) {
2623
2777
  const chunks = [];
2624
- try {
2625
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2626
- const chunk = temp.value;
2627
- chunks.push(Buffer.from(chunk));
2628
- }
2629
- } catch (temp) {
2630
- error = [temp];
2631
- } finally {
2632
- try {
2633
- more && (temp = iter.return) && await temp.call(iter);
2634
- } finally {
2635
- if (error)
2636
- throw error[0];
2637
- }
2778
+ for await (const chunk of stream) {
2779
+ chunks.push(Buffer.from(chunk));
2638
2780
  }
2639
2781
  return Buffer.concat(chunks).toString("utf-8");
2640
2782
  }
2641
2783
  async function streamToBuffer(stream) {
2642
2784
  const chunks = [];
2643
- try {
2644
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2645
- const chunk = temp.value;
2646
- chunks.push(Buffer.from(chunk));
2647
- }
2648
- } catch (temp) {
2649
- error = [temp];
2650
- } finally {
2651
- try {
2652
- more && (temp = iter.return) && await temp.call(iter);
2653
- } finally {
2654
- if (error)
2655
- throw error[0];
2656
- }
2785
+ for await (const chunk of stream) {
2786
+ chunks.push(Buffer.from(chunk));
2657
2787
  }
2658
2788
  return Buffer.concat(chunks);
2659
2789
  }
@@ -2675,8 +2805,7 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
2675
2805
  }
2676
2806
  }
2677
2807
  async function createCompatibilityFiles(outputDir, manifest) {
2678
- var _a;
2679
- const entryFile = ((_a = manifest.output) == null ? void 0 : _a.entry) || "bundle-entry.js";
2808
+ const entryFile = manifest.output?.entry || "bundle-entry.js";
2680
2809
  if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
2681
2810
  const hashedPath = path__default.default.join(outputDir, entryFile);
2682
2811
  const stablePath = path__default.default.join(outputDir, "bundle-entry.js");
@@ -2847,39 +2976,15 @@ function getBucketName3(env) {
2847
2976
  }
2848
2977
  async function streamToString2(stream) {
2849
2978
  const chunks = [];
2850
- try {
2851
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2852
- const chunk = temp.value;
2853
- chunks.push(Buffer.from(chunk));
2854
- }
2855
- } catch (temp) {
2856
- error = [temp];
2857
- } finally {
2858
- try {
2859
- more && (temp = iter.return) && await temp.call(iter);
2860
- } finally {
2861
- if (error)
2862
- throw error[0];
2863
- }
2979
+ for await (const chunk of stream) {
2980
+ chunks.push(Buffer.from(chunk));
2864
2981
  }
2865
2982
  return Buffer.concat(chunks).toString("utf-8");
2866
2983
  }
2867
2984
  async function streamToBuffer2(stream) {
2868
2985
  const chunks = [];
2869
- try {
2870
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2871
- const chunk = temp.value;
2872
- chunks.push(Buffer.from(chunk));
2873
- }
2874
- } catch (temp) {
2875
- error = [temp];
2876
- } finally {
2877
- try {
2878
- more && (temp = iter.return) && await temp.call(iter);
2879
- } finally {
2880
- if (error)
2881
- throw error[0];
2882
- }
2986
+ for await (const chunk of stream) {
2987
+ chunks.push(Buffer.from(chunk));
2883
2988
  }
2884
2989
  return Buffer.concat(chunks);
2885
2990
  }
@@ -3055,6 +3160,19 @@ async function cloneCommand(themeName, options) {
3055
3160
  spinner.succeed(
3056
3161
  `Renamed theme: ${chalk4__default.default.gray(themeName)} \u2192 ${chalk4__default.default.cyan(newName)}`
3057
3162
  );
3163
+ const envExamplePath = path__default.default.join(outputDir, ".env.example");
3164
+ if (!await fs__default.default.pathExists(envExamplePath)) {
3165
+ await fs__default.default.writeFile(
3166
+ envExamplePath,
3167
+ [
3168
+ "# API Configuration (enables real data in preview)",
3169
+ "# Get your Company ID from the OneX dashboard",
3170
+ "NEXT_PUBLIC_API_URL=https://api-dev.onexeos.com",
3171
+ "NEXT_PUBLIC_COMPANY_ID=",
3172
+ ""
3173
+ ].join("\n")
3174
+ );
3175
+ }
3058
3176
  if (options.install !== false) {
3059
3177
  const hasPkgJson = await fs__default.default.pathExists(
3060
3178
  path__default.default.join(outputDir, "package.json")
@@ -3085,6 +3203,7 @@ async function cloneCommand(themeName, options) {
3085
3203
  console.log();
3086
3204
  console.log(chalk4__default.default.cyan("Next steps:"));
3087
3205
  console.log(chalk4__default.default.gray(` cd ${path__default.default.relative(process.cwd(), outputDir)}`));
3206
+ console.log(chalk4__default.default.gray(" cp .env.example .env # then add your Company ID"));
3088
3207
  if (options.install === false) {
3089
3208
  console.log(chalk4__default.default.gray(" pnpm install"));
3090
3209
  }