@onexapis/cli 1.1.2 → 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,22 +54,6 @@ var AdmZip__default = /*#__PURE__*/_interopDefault(AdmZip);
53
54
 
54
55
  var __defProp = Object.defineProperty;
55
56
  var __getOwnPropNames = Object.getOwnPropertyNames;
56
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
57
- var __hasOwnProp = Object.prototype.hasOwnProperty;
58
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
59
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
60
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
61
- var __spreadValues = (a, b) => {
62
- for (var prop in b || (b = {}))
63
- if (__hasOwnProp.call(b, prop))
64
- __defNormalProp(a, prop, b[prop]);
65
- if (__getOwnPropSymbols)
66
- for (var prop of __getOwnPropSymbols(b)) {
67
- if (__propIsEnum.call(b, prop))
68
- __defNormalProp(a, prop, b[prop]);
69
- }
70
- return a;
71
- };
72
57
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
73
58
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
74
59
  }) : x)(function(x) {
@@ -82,7 +67,6 @@ var __export = (target, all) => {
82
67
  for (var name in all)
83
68
  __defProp(target, name, { get: all[name], enumerable: true });
84
69
  };
85
- 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);
86
70
  exports.Logger = void 0; exports.logger = void 0;
87
71
  var init_logger = __esm({
88
72
  "src/utils/logger.ts"() {
@@ -155,7 +139,7 @@ async function resolveNodeModulesFile(startDir, relativePath) {
155
139
  try {
156
140
  await fs6__default.default.access(candidate);
157
141
  return candidate;
158
- } catch (e) {
142
+ } catch {
159
143
  const parent = path__default.default.dirname(dir);
160
144
  if (parent === dir) break;
161
145
  dir = parent;
@@ -174,7 +158,7 @@ function createCoreGlobalPlugin(themePath) {
174
158
  }));
175
159
  build2.onLoad({ filter: /.*/, namespace: "core-global" }, async (args) => {
176
160
  const match = args.path.match(/^@onexapis\/core(\/(.+))?$/);
177
- const subpath = (match == null ? void 0 : match[2]) || "";
161
+ const subpath = match?.[2] || "";
178
162
  const moduleAccess = subpath ? `['${subpath}']` : "";
179
163
  let namedExports = [];
180
164
  const cacheKey = subpath || "__root__";
@@ -198,7 +182,7 @@ function createCoreGlobalPlugin(themePath) {
198
182
  namedExports.push(...names);
199
183
  }
200
184
  namedExports = [...new Set(namedExports)];
201
- } catch (e) {
185
+ } catch {
202
186
  }
203
187
  exportsBySubpath[cacheKey] = namedExports;
204
188
  }
@@ -232,7 +216,7 @@ ${namedExportLines}
232
216
  }
233
217
  async function generateThemeData(themePath, outputDir, themeId) {
234
218
  const { createJiti } = await import('jiti');
235
- const jiti = createJiti(import_meta.url);
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)));
236
220
  let themeConfig = null;
237
221
  let layoutConfig = null;
238
222
  const pages = {};
@@ -241,7 +225,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
241
225
  const mod = await jiti.import(path__default.default.join(themePath, `theme.config${ext}`));
242
226
  themeConfig = mod.default || mod;
243
227
  break;
244
- } catch (e) {
228
+ } catch {
245
229
  }
246
230
  }
247
231
  for (const ext of [".ts", ".js"]) {
@@ -249,7 +233,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
249
233
  const mod = await jiti.import(path__default.default.join(themePath, `theme.layout${ext}`));
250
234
  layoutConfig = mod.default || mod;
251
235
  break;
252
- } catch (e) {
236
+ } catch {
253
237
  }
254
238
  }
255
239
  const pagesDir = path__default.default.join(themePath, "pages");
@@ -265,14 +249,14 @@ async function generateThemeData(themePath, outputDir, themeId) {
265
249
  id: name,
266
250
  name: config.title || name,
267
251
  path: config.path || `/${name}`,
268
- config: __spreadValues({ id: name }, config),
252
+ config: { id: name, ...config },
269
253
  sections: config.sections || [],
270
254
  seo: config.seo
271
255
  };
272
- } catch (e) {
256
+ } catch {
273
257
  }
274
258
  }
275
- } catch (e) {
259
+ } catch {
276
260
  }
277
261
  await fs6__default.default.writeFile(
278
262
  path__default.default.join(outputDir, "theme-data.json"),
@@ -281,11 +265,11 @@ async function generateThemeData(themePath, outputDir, themeId) {
281
265
  themeId,
282
266
  theme: {
283
267
  id: themeId,
284
- name: (themeConfig == null ? void 0 : themeConfig.name) || themeId,
268
+ name: themeConfig?.name || themeId,
285
269
  config: themeConfig,
286
270
  layout: {
287
- header: (layoutConfig == null ? void 0 : layoutConfig.headerSections) || [],
288
- footer: (layoutConfig == null ? void 0 : layoutConfig.footerSections) || []
271
+ header: layoutConfig?.headerSections || [],
272
+ footer: layoutConfig?.footerSections || []
289
273
  },
290
274
  pages: Object.keys(pages)
291
275
  },
@@ -295,9 +279,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
295
279
  2
296
280
  )
297
281
  );
298
- exports.logger.info(
299
- `Generated theme-data.json (${Object.keys(pages).length} pages)`
300
- );
282
+ exports.logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
301
283
  }
302
284
  async function contentHashEntry(outputDir) {
303
285
  const entryPath = path__default.default.join(outputDir, "bundle-entry.js");
@@ -309,11 +291,11 @@ async function contentHashEntry(outputDir) {
309
291
  let entryContent;
310
292
  try {
311
293
  entryContent = await fs6__default.default.readFile(entryPath, "utf-8");
312
- } catch (e) {
294
+ } catch {
313
295
  const indexPath = path__default.default.join(outputDir, "index.js");
314
296
  try {
315
297
  entryContent = await fs6__default.default.readFile(indexPath, "utf-8");
316
- } catch (e2) {
298
+ } catch {
317
299
  exports.logger.warning("No entry file found in output, skipping content hash");
318
300
  return;
319
301
  }
@@ -330,7 +312,7 @@ async function contentHashEntry(outputDir) {
330
312
  try {
331
313
  await fs6__default.default.access(indexMapPath);
332
314
  await fs6__default.default.rename(indexMapPath, path__default.default.join(outputDir, hashedMapName2));
333
- } catch (e2) {
315
+ } catch {
334
316
  }
335
317
  exports.logger.info(`Entry hashed: ${hashedName2}`);
336
318
  return;
@@ -347,10 +329,32 @@ async function contentHashEntry(outputDir) {
347
329
  try {
348
330
  await fs6__default.default.access(mapPath);
349
331
  await fs6__default.default.rename(mapPath, path__default.default.join(outputDir, hashedMapName));
350
- } catch (e) {
332
+ } catch {
351
333
  }
352
334
  exports.logger.info(`Entry hashed: ${hashedName}`);
353
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
+ }
354
358
  async function generateManifest2(themeName, themePath, outputDir) {
355
359
  let version = "1.0.0";
356
360
  let themeId = themeName;
@@ -364,18 +368,19 @@ async function generateManifest2(themeName, themePath, outputDir) {
364
368
  if (pkg.name) {
365
369
  themeId = pkg.name.replace(/^@onex-themes\//, "");
366
370
  }
367
- } catch (e) {
371
+ } catch {
368
372
  }
369
373
  const [sectionFiles, blockFiles, schemaFiles] = await Promise.all([
370
374
  glob.glob("sections/**/index.ts", { cwd: themePath }),
371
375
  glob.glob("blocks/**/index.ts", { cwd: themePath }),
372
376
  glob.glob("**/*.schema.ts", { cwd: themePath })
373
377
  ]);
378
+ const dataRequirements = await extractDataRequirements(themePath);
374
379
  let hasThemeConfig = false;
375
380
  try {
376
381
  await fs6__default.default.access(path__default.default.join(themePath, "theme.config.ts"));
377
382
  hasThemeConfig = true;
378
- } catch (e) {
383
+ } catch {
379
384
  }
380
385
  const allFiles = await glob.glob("**/*", { cwd: outputDir, nodir: true });
381
386
  const jsFiles = allFiles.filter((f) => f.endsWith(".js"));
@@ -410,7 +415,9 @@ async function generateManifest2(themeName, themePath, outputDir) {
410
415
  blocks: blockFiles,
411
416
  schemas: schemaFiles,
412
417
  hasThemeConfig
413
- }
418
+ },
419
+ // Section data requirements for server-side prefetching (keyed by section type)
420
+ dataRequirements
414
421
  };
415
422
  await fs6__default.default.writeFile(
416
423
  path__default.default.join(outputDir, "manifest.json"),
@@ -425,7 +432,7 @@ async function compileStandaloneTheme(themePath, themeName) {
425
432
  try {
426
433
  await fs6__default.default.access(bundleEntry);
427
434
  entryPoint = bundleEntry;
428
- } catch (e) {
435
+ } catch {
429
436
  }
430
437
  const shimPath = path__default.default.join(outputDir, ".process-shim.js");
431
438
  await fs6__default.default.mkdir(outputDir, { recursive: true });
@@ -476,7 +483,7 @@ async function compileStandaloneTheme(themePath, themeName) {
476
483
  const result = await esbuild__namespace.build(buildOptions);
477
484
  try {
478
485
  await fs6__default.default.unlink(shimPath);
479
- } catch (e) {
486
+ } catch {
480
487
  }
481
488
  await contentHashEntry(outputDir);
482
489
  await generateManifest2(themeName, themePath, outputDir);
@@ -494,7 +501,7 @@ async function compileStandaloneTheme(themePath, themeName) {
494
501
  } catch (error) {
495
502
  try {
496
503
  await fs6__default.default.unlink(shimPath);
497
- } catch (e) {
504
+ } catch {
498
505
  }
499
506
  exports.logger.error(`esbuild compilation failed: ${error}`);
500
507
  return false;
@@ -508,7 +515,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
508
515
  try {
509
516
  await fs6__default.default.access(bundleEntry);
510
517
  entryPoint = bundleEntry;
511
- } catch (e) {
518
+ } catch {
512
519
  }
513
520
  const shimPath = path__default.default.join(outputDir, ".process-shim.js");
514
521
  await fs6__default.default.mkdir(outputDir, { recursive: true });
@@ -575,7 +582,7 @@ async function compilePreviewRuntime(themePath) {
575
582
  await fs6__default.default.access(loc);
576
583
  previewEntryPath = loc;
577
584
  break;
578
- } catch (e) {
585
+ } catch {
579
586
  }
580
587
  }
581
588
  if (!previewEntryPath) {
@@ -615,10 +622,13 @@ ${locations.join("\n")}`
615
622
  "zlib"
616
623
  ];
617
624
  for (const mod of nodeBuiltins) {
618
- build2.onResolve({ filter: new RegExp(`^${mod.replace("/", "\\/")}$`) }, () => ({
619
- path: mod,
620
- namespace: "node-stub"
621
- }));
625
+ build2.onResolve(
626
+ { filter: new RegExp(`^${mod.replace("/", "\\/")}$`) },
627
+ () => ({
628
+ path: mod,
629
+ namespace: "node-stub"
630
+ })
631
+ );
622
632
  }
623
633
  build2.onLoad({ filter: /.*/, namespace: "node-stub" }, (args) => {
624
634
  const stubs = {
@@ -632,8 +642,7 @@ ${locations.join("\n")}`
632
642
  };
633
643
  });
634
644
  build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
635
- var _a;
636
- if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
645
+ if (args.pluginData?.skipStub) return void 0;
637
646
  try {
638
647
  const result = await build2.resolve(args.path, {
639
648
  kind: args.kind,
@@ -643,7 +652,7 @@ ${locations.join("\n")}`
643
652
  pluginData: { skipStub: true }
644
653
  });
645
654
  if (!result.errors.length) return result;
646
- } catch (e) {
655
+ } catch {
647
656
  }
648
657
  return { path: args.path, namespace: "lucide-stub" };
649
658
  });
@@ -665,8 +674,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
665
674
  loader: "jsx"
666
675
  }));
667
676
  build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
668
- var _a;
669
- if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
677
+ if (args.pluginData?.skipStub) return void 0;
670
678
  try {
671
679
  const result = await build2.resolve(args.path, {
672
680
  kind: args.kind,
@@ -676,7 +684,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
676
684
  pluginData: { skipStub: true }
677
685
  });
678
686
  if (!result.errors.length) return result;
679
- } catch (e) {
687
+ } catch {
680
688
  }
681
689
  return { path: args.path, namespace: "motion-stub" };
682
690
  });
@@ -690,8 +698,59 @@ export default { motion, AnimatePresence };
690
698
  `.trim(),
691
699
  loader: "jsx"
692
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
+ });
693
750
  }
694
751
  };
752
+ const shimPath = path__default.default.join(outputDir, ".process-shim-preview.js");
753
+ await fs6__default.default.writeFile(shimPath, PROCESS_SHIM);
695
754
  await esbuild__namespace.build({
696
755
  entryPoints: [previewEntryPath],
697
756
  bundle: true,
@@ -701,6 +760,7 @@ export default { motion, AnimatePresence };
701
760
  // Bundle React + core INTO the output (NOT externalized)
702
761
  external: [],
703
762
  plugins: [serverStubPlugin],
763
+ inject: [shimPath],
704
764
  minify: false,
705
765
  sourcemap: true,
706
766
  target: "es2020",
@@ -708,6 +768,12 @@ export default { motion, AnimatePresence };
708
768
  jsxImportSource: "react",
709
769
  define: {
710
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
+ ),
711
777
  global: "globalThis"
712
778
  },
713
779
  loader: { ".tsx": "tsx", ".ts": "ts" },
@@ -718,13 +784,16 @@ export default { motion, AnimatePresence };
718
784
  "ignored-bare-import": "silent"
719
785
  }
720
786
  });
787
+ try {
788
+ await fs6__default.default.unlink(shimPath);
789
+ } catch {
790
+ }
721
791
  return outputPath;
722
792
  }
723
- var import_meta, PROCESS_SHIM, reactGlobalPlugin;
793
+ var PROCESS_SHIM, reactGlobalPlugin;
724
794
  var init_compile_theme = __esm({
725
795
  "src/utils/compile-theme.ts"() {
726
796
  init_logger();
727
- import_meta = {};
728
797
  PROCESS_SHIM = `
729
798
  if (typeof process === "undefined") {
730
799
  globalThis.process = {
@@ -1179,7 +1248,7 @@ Add your theme-specific blocks here.
1179
1248
  stdio: "ignore"
1180
1249
  });
1181
1250
  exports.logger.stopSpinner(true, "Git repository initialized!");
1182
- } catch (e) {
1251
+ } catch {
1183
1252
  exports.logger.stopSpinner(false, "Failed to initialize git");
1184
1253
  }
1185
1254
  }
@@ -1190,7 +1259,7 @@ Add your theme-specific blocks here.
1190
1259
  try {
1191
1260
  await installDependencies(projectPath, packageManager);
1192
1261
  exports.logger.stopSpinner(true, "Dependencies installed!");
1193
- } catch (e) {
1262
+ } catch {
1194
1263
  exports.logger.stopSpinner(false, "Failed to install dependencies");
1195
1264
  exports.logger.info(
1196
1265
  "You can install dependencies manually by running: cd " + name + " && npm install"
@@ -2272,7 +2341,6 @@ async function listThemesInfo() {
2272
2341
  // src/commands/build.ts
2273
2342
  init_logger();
2274
2343
  async function buildCommand(options) {
2275
- var _a;
2276
2344
  exports.logger.header("Build Theme");
2277
2345
  let themePath;
2278
2346
  let themeName;
@@ -2285,7 +2353,7 @@ async function buildCommand(options) {
2285
2353
  } else {
2286
2354
  themePath = path__default.default.join(process.cwd(), themeName);
2287
2355
  }
2288
- } catch (e) {
2356
+ } catch {
2289
2357
  themePath = path__default.default.join(process.cwd(), themeName);
2290
2358
  }
2291
2359
  if (!fs__default.default.existsSync(themePath)) {
@@ -2342,7 +2410,7 @@ async function buildCommand(options) {
2342
2410
  }
2343
2411
  exports.logger.stopSpinner(true, "Lint passed");
2344
2412
  const pkgJson = fs__default.default.readJsonSync(packageJsonPath);
2345
- const buildScript = ((_a = pkgJson.scripts) == null ? void 0 : _a.build) || "";
2413
+ const buildScript = pkgJson.scripts?.build || "";
2346
2414
  const isRecursive = buildScript.includes("onex build") || buildScript.includes("onex-cli build");
2347
2415
  exports.logger.startSpinner(
2348
2416
  options.watch ? "Building (watch mode)..." : "Building..."
@@ -2450,7 +2518,6 @@ async function findCompiledThemeDir(themeId, version) {
2450
2518
  return null;
2451
2519
  }
2452
2520
  async function readManifest() {
2453
- var _a;
2454
2521
  const manifestTsPath = path__default.default.resolve(process.cwd(), "manifest.ts");
2455
2522
  if (await fs__default.default.pathExists(manifestTsPath)) {
2456
2523
  try {
@@ -2464,7 +2531,7 @@ async function readManifest() {
2464
2531
  if (await fs__default.default.pathExists(packageJsonPath)) {
2465
2532
  const pkg = await fs__default.default.readJson(packageJsonPath);
2466
2533
  return {
2467
- themeId: ((_a = pkg.name) == null ? void 0 : _a.replace("@onex-themes/", "")) || "unknown",
2534
+ themeId: pkg.name?.replace("@onex-themes/", "") || "unknown",
2468
2535
  version: pkg.version || "1.0.0"
2469
2536
  };
2470
2537
  }
@@ -2708,39 +2775,15 @@ function getBucketName2(env) {
2708
2775
  }
2709
2776
  async function streamToString(stream) {
2710
2777
  const chunks = [];
2711
- try {
2712
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2713
- const chunk = temp.value;
2714
- chunks.push(Buffer.from(chunk));
2715
- }
2716
- } catch (temp) {
2717
- error = [temp];
2718
- } finally {
2719
- try {
2720
- more && (temp = iter.return) && await temp.call(iter);
2721
- } finally {
2722
- if (error)
2723
- throw error[0];
2724
- }
2778
+ for await (const chunk of stream) {
2779
+ chunks.push(Buffer.from(chunk));
2725
2780
  }
2726
2781
  return Buffer.concat(chunks).toString("utf-8");
2727
2782
  }
2728
2783
  async function streamToBuffer(stream) {
2729
2784
  const chunks = [];
2730
- try {
2731
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2732
- const chunk = temp.value;
2733
- chunks.push(Buffer.from(chunk));
2734
- }
2735
- } catch (temp) {
2736
- error = [temp];
2737
- } finally {
2738
- try {
2739
- more && (temp = iter.return) && await temp.call(iter);
2740
- } finally {
2741
- if (error)
2742
- throw error[0];
2743
- }
2785
+ for await (const chunk of stream) {
2786
+ chunks.push(Buffer.from(chunk));
2744
2787
  }
2745
2788
  return Buffer.concat(chunks);
2746
2789
  }
@@ -2762,8 +2805,7 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
2762
2805
  }
2763
2806
  }
2764
2807
  async function createCompatibilityFiles(outputDir, manifest) {
2765
- var _a;
2766
- const entryFile = ((_a = manifest.output) == null ? void 0 : _a.entry) || "bundle-entry.js";
2808
+ const entryFile = manifest.output?.entry || "bundle-entry.js";
2767
2809
  if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
2768
2810
  const hashedPath = path__default.default.join(outputDir, entryFile);
2769
2811
  const stablePath = path__default.default.join(outputDir, "bundle-entry.js");
@@ -2934,39 +2976,15 @@ function getBucketName3(env) {
2934
2976
  }
2935
2977
  async function streamToString2(stream) {
2936
2978
  const chunks = [];
2937
- try {
2938
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2939
- const chunk = temp.value;
2940
- chunks.push(Buffer.from(chunk));
2941
- }
2942
- } catch (temp) {
2943
- error = [temp];
2944
- } finally {
2945
- try {
2946
- more && (temp = iter.return) && await temp.call(iter);
2947
- } finally {
2948
- if (error)
2949
- throw error[0];
2950
- }
2979
+ for await (const chunk of stream) {
2980
+ chunks.push(Buffer.from(chunk));
2951
2981
  }
2952
2982
  return Buffer.concat(chunks).toString("utf-8");
2953
2983
  }
2954
2984
  async function streamToBuffer2(stream) {
2955
2985
  const chunks = [];
2956
- try {
2957
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2958
- const chunk = temp.value;
2959
- chunks.push(Buffer.from(chunk));
2960
- }
2961
- } catch (temp) {
2962
- error = [temp];
2963
- } finally {
2964
- try {
2965
- more && (temp = iter.return) && await temp.call(iter);
2966
- } finally {
2967
- if (error)
2968
- throw error[0];
2969
- }
2986
+ for await (const chunk of stream) {
2987
+ chunks.push(Buffer.from(chunk));
2970
2988
  }
2971
2989
  return Buffer.concat(chunks);
2972
2990
  }
@@ -3142,6 +3160,19 @@ async function cloneCommand(themeName, options) {
3142
3160
  spinner.succeed(
3143
3161
  `Renamed theme: ${chalk4__default.default.gray(themeName)} \u2192 ${chalk4__default.default.cyan(newName)}`
3144
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
+ }
3145
3176
  if (options.install !== false) {
3146
3177
  const hasPkgJson = await fs__default.default.pathExists(
3147
3178
  path__default.default.join(outputDir, "package.json")
@@ -3172,6 +3203,7 @@ async function cloneCommand(themeName, options) {
3172
3203
  console.log();
3173
3204
  console.log(chalk4__default.default.cyan("Next steps:"));
3174
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"));
3175
3207
  if (options.install === false) {
3176
3208
  console.log(chalk4__default.default.gray(" pnpm install"));
3177
3209
  }