@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.mjs CHANGED
@@ -17,7 +17,6 @@ import AdmZip from 'adm-zip';
17
17
 
18
18
  var __defProp = Object.defineProperty;
19
19
  var __getOwnPropNames = Object.getOwnPropertyNames;
20
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
21
20
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
22
21
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
23
22
  }) : x)(function(x) {
@@ -31,7 +30,6 @@ var __export = (target, all) => {
31
30
  for (var name in all)
32
31
  __defProp(target, name, { get: all[name], enumerable: true });
33
32
  };
34
- 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);
35
33
  var Logger, logger;
36
34
  var init_logger = __esm({
37
35
  "src/utils/logger.ts"() {
@@ -104,7 +102,7 @@ async function resolveNodeModulesFile(startDir, relativePath) {
104
102
  try {
105
103
  await fs6.access(candidate);
106
104
  return candidate;
107
- } catch (e) {
105
+ } catch {
108
106
  const parent = path.dirname(dir);
109
107
  if (parent === dir) break;
110
108
  dir = parent;
@@ -123,7 +121,7 @@ function createCoreGlobalPlugin(themePath) {
123
121
  }));
124
122
  build2.onLoad({ filter: /.*/, namespace: "core-global" }, async (args) => {
125
123
  const match = args.path.match(/^@onexapis\/core(\/(.+))?$/);
126
- const subpath = (match == null ? void 0 : match[2]) || "";
124
+ const subpath = match?.[2] || "";
127
125
  const moduleAccess = subpath ? `['${subpath}']` : "";
128
126
  let namedExports = [];
129
127
  const cacheKey = subpath || "__root__";
@@ -147,7 +145,7 @@ function createCoreGlobalPlugin(themePath) {
147
145
  namedExports.push(...names);
148
146
  }
149
147
  namedExports = [...new Set(namedExports)];
150
- } catch (e) {
148
+ } catch {
151
149
  }
152
150
  exportsBySubpath[cacheKey] = namedExports;
153
151
  }
@@ -179,6 +177,73 @@ ${namedExportLines}
179
177
  }
180
178
  };
181
179
  }
180
+ async function generateThemeData(themePath, outputDir, themeId) {
181
+ const { createJiti } = await import('jiti');
182
+ const jiti = createJiti(import.meta.url);
183
+ let themeConfig = null;
184
+ let layoutConfig = null;
185
+ const pages = {};
186
+ for (const ext of [".ts", ".js"]) {
187
+ try {
188
+ const mod = await jiti.import(path.join(themePath, `theme.config${ext}`));
189
+ themeConfig = mod.default || mod;
190
+ break;
191
+ } catch {
192
+ }
193
+ }
194
+ for (const ext of [".ts", ".js"]) {
195
+ try {
196
+ const mod = await jiti.import(path.join(themePath, `theme.layout${ext}`));
197
+ layoutConfig = mod.default || mod;
198
+ break;
199
+ } catch {
200
+ }
201
+ }
202
+ const pagesDir = path.join(themePath, "pages");
203
+ try {
204
+ const files = await fs6.readdir(pagesDir);
205
+ for (const file of files) {
206
+ if (!file.match(/\.(ts|js)$/)) continue;
207
+ const name = file.replace(/\.(ts|js)$/, "");
208
+ try {
209
+ const mod = await jiti.import(path.join(pagesDir, file));
210
+ const config = mod.default || mod;
211
+ pages[name] = {
212
+ id: name,
213
+ name: config.title || name,
214
+ path: config.path || `/${name}`,
215
+ config: { id: name, ...config },
216
+ sections: config.sections || [],
217
+ seo: config.seo
218
+ };
219
+ } catch {
220
+ }
221
+ }
222
+ } catch {
223
+ }
224
+ await fs6.writeFile(
225
+ path.join(outputDir, "theme-data.json"),
226
+ JSON.stringify(
227
+ {
228
+ themeId,
229
+ theme: {
230
+ id: themeId,
231
+ name: themeConfig?.name || themeId,
232
+ config: themeConfig,
233
+ layout: {
234
+ header: layoutConfig?.headerSections || [],
235
+ footer: layoutConfig?.footerSections || []
236
+ },
237
+ pages: Object.keys(pages)
238
+ },
239
+ pages
240
+ },
241
+ null,
242
+ 2
243
+ )
244
+ );
245
+ logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
246
+ }
182
247
  async function contentHashEntry(outputDir) {
183
248
  const entryPath = path.join(outputDir, "bundle-entry.js");
184
249
  const mapPath = path.join(outputDir, "bundle-entry.js.map");
@@ -189,11 +254,11 @@ async function contentHashEntry(outputDir) {
189
254
  let entryContent;
190
255
  try {
191
256
  entryContent = await fs6.readFile(entryPath, "utf-8");
192
- } catch (e) {
257
+ } catch {
193
258
  const indexPath = path.join(outputDir, "index.js");
194
259
  try {
195
260
  entryContent = await fs6.readFile(indexPath, "utf-8");
196
- } catch (e2) {
261
+ } catch {
197
262
  logger.warning("No entry file found in output, skipping content hash");
198
263
  return;
199
264
  }
@@ -210,7 +275,7 @@ async function contentHashEntry(outputDir) {
210
275
  try {
211
276
  await fs6.access(indexMapPath);
212
277
  await fs6.rename(indexMapPath, path.join(outputDir, hashedMapName2));
213
- } catch (e2) {
278
+ } catch {
214
279
  }
215
280
  logger.info(`Entry hashed: ${hashedName2}`);
216
281
  return;
@@ -227,10 +292,32 @@ async function contentHashEntry(outputDir) {
227
292
  try {
228
293
  await fs6.access(mapPath);
229
294
  await fs6.rename(mapPath, path.join(outputDir, hashedMapName));
230
- } catch (e) {
295
+ } catch {
231
296
  }
232
297
  logger.info(`Entry hashed: ${hashedName}`);
233
298
  }
299
+ async function extractDataRequirements(themePath) {
300
+ const { createJiti } = await import('jiti');
301
+ const jiti = createJiti(import.meta.url);
302
+ const schemaFiles = await glob("sections/**/*.schema.ts", { cwd: themePath });
303
+ const requirements = {};
304
+ for (const file of schemaFiles) {
305
+ try {
306
+ const mod = await jiti.import(path.join(themePath, file));
307
+ const exports$1 = mod;
308
+ for (const value of Object.values(exports$1)) {
309
+ if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
310
+ requirements[value.type] = value.dataRequirements;
311
+ }
312
+ }
313
+ } catch (err) {
314
+ logger.warning(
315
+ `Could not load schema ${file}: ${err instanceof Error ? err.message : String(err)}`
316
+ );
317
+ }
318
+ }
319
+ return requirements;
320
+ }
234
321
  async function generateManifest2(themeName, themePath, outputDir) {
235
322
  let version = "1.0.0";
236
323
  let themeId = themeName;
@@ -244,18 +331,19 @@ async function generateManifest2(themeName, themePath, outputDir) {
244
331
  if (pkg.name) {
245
332
  themeId = pkg.name.replace(/^@onex-themes\//, "");
246
333
  }
247
- } catch (e) {
334
+ } catch {
248
335
  }
249
336
  const [sectionFiles, blockFiles, schemaFiles] = await Promise.all([
250
337
  glob("sections/**/index.ts", { cwd: themePath }),
251
338
  glob("blocks/**/index.ts", { cwd: themePath }),
252
339
  glob("**/*.schema.ts", { cwd: themePath })
253
340
  ]);
341
+ const dataRequirements = await extractDataRequirements(themePath);
254
342
  let hasThemeConfig = false;
255
343
  try {
256
344
  await fs6.access(path.join(themePath, "theme.config.ts"));
257
345
  hasThemeConfig = true;
258
- } catch (e) {
346
+ } catch {
259
347
  }
260
348
  const allFiles = await glob("**/*", { cwd: outputDir, nodir: true });
261
349
  const jsFiles = allFiles.filter((f) => f.endsWith(".js"));
@@ -290,7 +378,9 @@ async function generateManifest2(themeName, themePath, outputDir) {
290
378
  blocks: blockFiles,
291
379
  schemas: schemaFiles,
292
380
  hasThemeConfig
293
- }
381
+ },
382
+ // Section data requirements for server-side prefetching (keyed by section type)
383
+ dataRequirements
294
384
  };
295
385
  await fs6.writeFile(
296
386
  path.join(outputDir, "manifest.json"),
@@ -305,7 +395,7 @@ async function compileStandaloneTheme(themePath, themeName) {
305
395
  try {
306
396
  await fs6.access(bundleEntry);
307
397
  entryPoint = bundleEntry;
308
- } catch (e) {
398
+ } catch {
309
399
  }
310
400
  const shimPath = path.join(outputDir, ".process-shim.js");
311
401
  await fs6.mkdir(outputDir, { recursive: true });
@@ -356,10 +446,11 @@ async function compileStandaloneTheme(themePath, themeName) {
356
446
  const result = await esbuild.build(buildOptions);
357
447
  try {
358
448
  await fs6.unlink(shimPath);
359
- } catch (e) {
449
+ } catch {
360
450
  }
361
451
  await contentHashEntry(outputDir);
362
452
  await generateManifest2(themeName, themePath, outputDir);
453
+ await generateThemeData(themePath, outputDir, themeName);
363
454
  if (result.metafile) {
364
455
  const outputs = result.metafile.outputs;
365
456
  let totalSize = 0;
@@ -373,7 +464,7 @@ async function compileStandaloneTheme(themePath, themeName) {
373
464
  } catch (error) {
374
465
  try {
375
466
  await fs6.unlink(shimPath);
376
- } catch (e) {
467
+ } catch {
377
468
  }
378
469
  logger.error(`esbuild compilation failed: ${error}`);
379
470
  return false;
@@ -387,7 +478,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
387
478
  try {
388
479
  await fs6.access(bundleEntry);
389
480
  entryPoint = bundleEntry;
390
- } catch (e) {
481
+ } catch {
391
482
  }
392
483
  const shimPath = path.join(outputDir, ".process-shim.js");
393
484
  await fs6.mkdir(outputDir, { recursive: true });
@@ -436,6 +527,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
436
527
  const context2 = await esbuild.context(buildOptions);
437
528
  await context2.rebuild();
438
529
  await generateManifest2(themeName, themePath, outputDir);
530
+ await generateThemeData(themePath, outputDir, themeName);
439
531
  return { context: context2, outputDir };
440
532
  }
441
533
  async function compilePreviewRuntime(themePath) {
@@ -453,7 +545,7 @@ async function compilePreviewRuntime(themePath) {
453
545
  await fs6.access(loc);
454
546
  previewEntryPath = loc;
455
547
  break;
456
- } catch (e) {
548
+ } catch {
457
549
  }
458
550
  }
459
551
  if (!previewEntryPath) {
@@ -493,10 +585,13 @@ ${locations.join("\n")}`
493
585
  "zlib"
494
586
  ];
495
587
  for (const mod of nodeBuiltins) {
496
- build2.onResolve({ filter: new RegExp(`^${mod.replace("/", "\\/")}$`) }, () => ({
497
- path: mod,
498
- namespace: "node-stub"
499
- }));
588
+ build2.onResolve(
589
+ { filter: new RegExp(`^${mod.replace("/", "\\/")}$`) },
590
+ () => ({
591
+ path: mod,
592
+ namespace: "node-stub"
593
+ })
594
+ );
500
595
  }
501
596
  build2.onLoad({ filter: /.*/, namespace: "node-stub" }, (args) => {
502
597
  const stubs = {
@@ -510,8 +605,7 @@ ${locations.join("\n")}`
510
605
  };
511
606
  });
512
607
  build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
513
- var _a;
514
- if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
608
+ if (args.pluginData?.skipStub) return void 0;
515
609
  try {
516
610
  const result = await build2.resolve(args.path, {
517
611
  kind: args.kind,
@@ -521,7 +615,7 @@ ${locations.join("\n")}`
521
615
  pluginData: { skipStub: true }
522
616
  });
523
617
  if (!result.errors.length) return result;
524
- } catch (e) {
618
+ } catch {
525
619
  }
526
620
  return { path: args.path, namespace: "lucide-stub" };
527
621
  });
@@ -543,8 +637,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
543
637
  loader: "jsx"
544
638
  }));
545
639
  build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
546
- var _a;
547
- if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
640
+ if (args.pluginData?.skipStub) return void 0;
548
641
  try {
549
642
  const result = await build2.resolve(args.path, {
550
643
  kind: args.kind,
@@ -554,7 +647,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
554
647
  pluginData: { skipStub: true }
555
648
  });
556
649
  if (!result.errors.length) return result;
557
- } catch (e) {
650
+ } catch {
558
651
  }
559
652
  return { path: args.path, namespace: "motion-stub" };
560
653
  });
@@ -568,8 +661,59 @@ export default { motion, AnimatePresence };
568
661
  `.trim(),
569
662
  loader: "jsx"
570
663
  }));
664
+ build2.onResolve({ filter: /^next\// }, async (args) => {
665
+ if (args.pluginData?.skipStub) return void 0;
666
+ try {
667
+ const result = await build2.resolve(args.path, {
668
+ kind: args.kind,
669
+ resolveDir: args.resolveDir,
670
+ importer: args.importer,
671
+ namespace: "file",
672
+ pluginData: { skipStub: true }
673
+ });
674
+ if (!result.errors.length) return result;
675
+ } catch {
676
+ }
677
+ return { path: args.path, namespace: "next-stub" };
678
+ });
679
+ build2.onLoad({ filter: /.*/, namespace: "next-stub" }, (args) => {
680
+ const stubs = {
681
+ "next/image": `
682
+ const Image = (props) => {
683
+ const { src, alt, width, height, fill, priority, ...rest } = props;
684
+ const imgSrc = typeof src === 'object' ? src.src : src;
685
+ return React.createElement('img', { src: imgSrc, alt, width: fill ? undefined : width, height: fill ? undefined : height, loading: priority ? 'eager' : 'lazy', ...rest });
686
+ };
687
+ import React from 'react';
688
+ export default Image;
689
+ `,
690
+ "next/link": `
691
+ const Link = ({ href, children, ...rest }) => React.createElement('a', { href, ...rest }, children);
692
+ import React from 'react';
693
+ export default Link;
694
+ `,
695
+ "next/navigation": `
696
+ 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(){} }; }
697
+ export function usePathname() { return window.location.pathname; }
698
+ export function useSearchParams() { return new URLSearchParams(window.location.search); }
699
+ export function useParams() { return {}; }
700
+ export function redirect(url) { window.location.href = url; }
701
+ export function notFound() { throw new Error('Not Found'); }
702
+ `,
703
+ "next/headers": `
704
+ export function cookies() { return { get(){}, getAll(){ return []; }, set(){}, delete(){}, has(){ return false; } }; }
705
+ export function headers() { return new Headers(); }
706
+ `
707
+ };
708
+ return {
709
+ contents: stubs[args.path] || "export default {};",
710
+ loader: "jsx"
711
+ };
712
+ });
571
713
  }
572
714
  };
715
+ const shimPath = path.join(outputDir, ".process-shim-preview.js");
716
+ await fs6.writeFile(shimPath, PROCESS_SHIM);
573
717
  await esbuild.build({
574
718
  entryPoints: [previewEntryPath],
575
719
  bundle: true,
@@ -579,6 +723,7 @@ export default { motion, AnimatePresence };
579
723
  // Bundle React + core INTO the output (NOT externalized)
580
724
  external: [],
581
725
  plugins: [serverStubPlugin],
726
+ inject: [shimPath],
582
727
  minify: false,
583
728
  sourcemap: true,
584
729
  target: "es2020",
@@ -586,6 +731,12 @@ export default { motion, AnimatePresence };
586
731
  jsxImportSource: "react",
587
732
  define: {
588
733
  "process.env.NODE_ENV": JSON.stringify("development"),
734
+ "process.env.NEXT_PUBLIC_API_URL": JSON.stringify(
735
+ process.env.NEXT_PUBLIC_API_URL || ""
736
+ ),
737
+ "process.env.NEXT_PUBLIC_COMPANY_ID": JSON.stringify(
738
+ process.env.NEXT_PUBLIC_COMPANY_ID || ""
739
+ ),
589
740
  global: "globalThis"
590
741
  },
591
742
  loader: { ".tsx": "tsx", ".ts": "ts" },
@@ -596,6 +747,10 @@ export default { motion, AnimatePresence };
596
747
  "ignored-bare-import": "silent"
597
748
  }
598
749
  });
750
+ try {
751
+ await fs6.unlink(shimPath);
752
+ } catch {
753
+ }
599
754
  return outputPath;
600
755
  }
601
756
  var PROCESS_SHIM, reactGlobalPlugin;
@@ -1056,7 +1211,7 @@ Add your theme-specific blocks here.
1056
1211
  stdio: "ignore"
1057
1212
  });
1058
1213
  logger.stopSpinner(true, "Git repository initialized!");
1059
- } catch (e) {
1214
+ } catch {
1060
1215
  logger.stopSpinner(false, "Failed to initialize git");
1061
1216
  }
1062
1217
  }
@@ -1067,7 +1222,7 @@ Add your theme-specific blocks here.
1067
1222
  try {
1068
1223
  await installDependencies(projectPath, packageManager);
1069
1224
  logger.stopSpinner(true, "Dependencies installed!");
1070
- } catch (e) {
1225
+ } catch {
1071
1226
  logger.stopSpinner(false, "Failed to install dependencies");
1072
1227
  logger.info(
1073
1228
  "You can install dependencies manually by running: cd " + name + " && npm install"
@@ -2149,7 +2304,6 @@ async function listThemesInfo() {
2149
2304
  // src/commands/build.ts
2150
2305
  init_logger();
2151
2306
  async function buildCommand(options) {
2152
- var _a;
2153
2307
  logger.header("Build Theme");
2154
2308
  let themePath;
2155
2309
  let themeName;
@@ -2162,7 +2316,7 @@ async function buildCommand(options) {
2162
2316
  } else {
2163
2317
  themePath = path.join(process.cwd(), themeName);
2164
2318
  }
2165
- } catch (e) {
2319
+ } catch {
2166
2320
  themePath = path.join(process.cwd(), themeName);
2167
2321
  }
2168
2322
  if (!fs.existsSync(themePath)) {
@@ -2219,7 +2373,7 @@ async function buildCommand(options) {
2219
2373
  }
2220
2374
  logger.stopSpinner(true, "Lint passed");
2221
2375
  const pkgJson = fs.readJsonSync(packageJsonPath);
2222
- const buildScript = ((_a = pkgJson.scripts) == null ? void 0 : _a.build) || "";
2376
+ const buildScript = pkgJson.scripts?.build || "";
2223
2377
  const isRecursive = buildScript.includes("onex build") || buildScript.includes("onex-cli build");
2224
2378
  logger.startSpinner(
2225
2379
  options.watch ? "Building (watch mode)..." : "Building..."
@@ -2327,7 +2481,6 @@ async function findCompiledThemeDir(themeId, version) {
2327
2481
  return null;
2328
2482
  }
2329
2483
  async function readManifest() {
2330
- var _a;
2331
2484
  const manifestTsPath = path.resolve(process.cwd(), "manifest.ts");
2332
2485
  if (await fs.pathExists(manifestTsPath)) {
2333
2486
  try {
@@ -2341,7 +2494,7 @@ async function readManifest() {
2341
2494
  if (await fs.pathExists(packageJsonPath)) {
2342
2495
  const pkg = await fs.readJson(packageJsonPath);
2343
2496
  return {
2344
- themeId: ((_a = pkg.name) == null ? void 0 : _a.replace("@onex-themes/", "")) || "unknown",
2497
+ themeId: pkg.name?.replace("@onex-themes/", "") || "unknown",
2345
2498
  version: pkg.version || "1.0.0"
2346
2499
  };
2347
2500
  }
@@ -2585,39 +2738,15 @@ function getBucketName2(env) {
2585
2738
  }
2586
2739
  async function streamToString(stream) {
2587
2740
  const chunks = [];
2588
- try {
2589
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2590
- const chunk = temp.value;
2591
- chunks.push(Buffer.from(chunk));
2592
- }
2593
- } catch (temp) {
2594
- error = [temp];
2595
- } finally {
2596
- try {
2597
- more && (temp = iter.return) && await temp.call(iter);
2598
- } finally {
2599
- if (error)
2600
- throw error[0];
2601
- }
2741
+ for await (const chunk of stream) {
2742
+ chunks.push(Buffer.from(chunk));
2602
2743
  }
2603
2744
  return Buffer.concat(chunks).toString("utf-8");
2604
2745
  }
2605
2746
  async function streamToBuffer(stream) {
2606
2747
  const chunks = [];
2607
- try {
2608
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2609
- const chunk = temp.value;
2610
- chunks.push(Buffer.from(chunk));
2611
- }
2612
- } catch (temp) {
2613
- error = [temp];
2614
- } finally {
2615
- try {
2616
- more && (temp = iter.return) && await temp.call(iter);
2617
- } finally {
2618
- if (error)
2619
- throw error[0];
2620
- }
2748
+ for await (const chunk of stream) {
2749
+ chunks.push(Buffer.from(chunk));
2621
2750
  }
2622
2751
  return Buffer.concat(chunks);
2623
2752
  }
@@ -2639,8 +2768,7 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
2639
2768
  }
2640
2769
  }
2641
2770
  async function createCompatibilityFiles(outputDir, manifest) {
2642
- var _a;
2643
- const entryFile = ((_a = manifest.output) == null ? void 0 : _a.entry) || "bundle-entry.js";
2771
+ const entryFile = manifest.output?.entry || "bundle-entry.js";
2644
2772
  if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
2645
2773
  const hashedPath = path.join(outputDir, entryFile);
2646
2774
  const stablePath = path.join(outputDir, "bundle-entry.js");
@@ -2811,39 +2939,15 @@ function getBucketName3(env) {
2811
2939
  }
2812
2940
  async function streamToString2(stream) {
2813
2941
  const chunks = [];
2814
- try {
2815
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2816
- const chunk = temp.value;
2817
- chunks.push(Buffer.from(chunk));
2818
- }
2819
- } catch (temp) {
2820
- error = [temp];
2821
- } finally {
2822
- try {
2823
- more && (temp = iter.return) && await temp.call(iter);
2824
- } finally {
2825
- if (error)
2826
- throw error[0];
2827
- }
2942
+ for await (const chunk of stream) {
2943
+ chunks.push(Buffer.from(chunk));
2828
2944
  }
2829
2945
  return Buffer.concat(chunks).toString("utf-8");
2830
2946
  }
2831
2947
  async function streamToBuffer2(stream) {
2832
2948
  const chunks = [];
2833
- try {
2834
- for (var iter = __forAwait(stream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
2835
- const chunk = temp.value;
2836
- chunks.push(Buffer.from(chunk));
2837
- }
2838
- } catch (temp) {
2839
- error = [temp];
2840
- } finally {
2841
- try {
2842
- more && (temp = iter.return) && await temp.call(iter);
2843
- } finally {
2844
- if (error)
2845
- throw error[0];
2846
- }
2949
+ for await (const chunk of stream) {
2950
+ chunks.push(Buffer.from(chunk));
2847
2951
  }
2848
2952
  return Buffer.concat(chunks);
2849
2953
  }
@@ -3019,6 +3123,19 @@ async function cloneCommand(themeName, options) {
3019
3123
  spinner.succeed(
3020
3124
  `Renamed theme: ${chalk4.gray(themeName)} \u2192 ${chalk4.cyan(newName)}`
3021
3125
  );
3126
+ const envExamplePath = path.join(outputDir, ".env.example");
3127
+ if (!await fs.pathExists(envExamplePath)) {
3128
+ await fs.writeFile(
3129
+ envExamplePath,
3130
+ [
3131
+ "# API Configuration (enables real data in preview)",
3132
+ "# Get your Company ID from the OneX dashboard",
3133
+ "NEXT_PUBLIC_API_URL=https://api-dev.onexeos.com",
3134
+ "NEXT_PUBLIC_COMPANY_ID=",
3135
+ ""
3136
+ ].join("\n")
3137
+ );
3138
+ }
3022
3139
  if (options.install !== false) {
3023
3140
  const hasPkgJson = await fs.pathExists(
3024
3141
  path.join(outputDir, "package.json")
@@ -3049,6 +3166,7 @@ async function cloneCommand(themeName, options) {
3049
3166
  console.log();
3050
3167
  console.log(chalk4.cyan("Next steps:"));
3051
3168
  console.log(chalk4.gray(` cd ${path.relative(process.cwd(), outputDir)}`));
3169
+ console.log(chalk4.gray(" cp .env.example .env # then add your Company ID"));
3052
3170
  if (options.install === false) {
3053
3171
  console.log(chalk4.gray(" pnpm install"));
3054
3172
  }