@onexapis/cli 1.1.0 → 1.1.2

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
@@ -53,7 +53,22 @@ var AdmZip__default = /*#__PURE__*/_interopDefault(AdmZip);
53
53
 
54
54
  var __defProp = Object.defineProperty;
55
55
  var __getOwnPropNames = Object.getOwnPropertyNames;
56
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
57
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
58
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
56
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
+ };
57
72
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
58
73
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
59
74
  }) : x)(function(x) {
@@ -215,6 +230,75 @@ ${namedExportLines}
215
230
  }
216
231
  };
217
232
  }
233
+ async function generateThemeData(themePath, outputDir, themeId) {
234
+ const { createJiti } = await import('jiti');
235
+ const jiti = createJiti(import_meta.url);
236
+ let themeConfig = null;
237
+ let layoutConfig = null;
238
+ const pages = {};
239
+ for (const ext of [".ts", ".js"]) {
240
+ try {
241
+ const mod = await jiti.import(path__default.default.join(themePath, `theme.config${ext}`));
242
+ themeConfig = mod.default || mod;
243
+ break;
244
+ } catch (e) {
245
+ }
246
+ }
247
+ for (const ext of [".ts", ".js"]) {
248
+ try {
249
+ const mod = await jiti.import(path__default.default.join(themePath, `theme.layout${ext}`));
250
+ layoutConfig = mod.default || mod;
251
+ break;
252
+ } catch (e) {
253
+ }
254
+ }
255
+ const pagesDir = path__default.default.join(themePath, "pages");
256
+ try {
257
+ const files = await fs6__default.default.readdir(pagesDir);
258
+ for (const file of files) {
259
+ if (!file.match(/\.(ts|js)$/)) continue;
260
+ const name = file.replace(/\.(ts|js)$/, "");
261
+ try {
262
+ const mod = await jiti.import(path__default.default.join(pagesDir, file));
263
+ const config = mod.default || mod;
264
+ pages[name] = {
265
+ id: name,
266
+ name: config.title || name,
267
+ path: config.path || `/${name}`,
268
+ config: __spreadValues({ id: name }, config),
269
+ sections: config.sections || [],
270
+ seo: config.seo
271
+ };
272
+ } catch (e) {
273
+ }
274
+ }
275
+ } catch (e) {
276
+ }
277
+ await fs6__default.default.writeFile(
278
+ path__default.default.join(outputDir, "theme-data.json"),
279
+ JSON.stringify(
280
+ {
281
+ themeId,
282
+ theme: {
283
+ id: themeId,
284
+ name: (themeConfig == null ? void 0 : themeConfig.name) || themeId,
285
+ config: themeConfig,
286
+ layout: {
287
+ header: (layoutConfig == null ? void 0 : layoutConfig.headerSections) || [],
288
+ footer: (layoutConfig == null ? void 0 : layoutConfig.footerSections) || []
289
+ },
290
+ pages: Object.keys(pages)
291
+ },
292
+ pages
293
+ },
294
+ null,
295
+ 2
296
+ )
297
+ );
298
+ exports.logger.info(
299
+ `Generated theme-data.json (${Object.keys(pages).length} pages)`
300
+ );
301
+ }
218
302
  async function contentHashEntry(outputDir) {
219
303
  const entryPath = path__default.default.join(outputDir, "bundle-entry.js");
220
304
  const mapPath = path__default.default.join(outputDir, "bundle-entry.js.map");
@@ -396,6 +480,7 @@ async function compileStandaloneTheme(themePath, themeName) {
396
480
  }
397
481
  await contentHashEntry(outputDir);
398
482
  await generateManifest2(themeName, themePath, outputDir);
483
+ await generateThemeData(themePath, outputDir, themeName);
399
484
  if (result.metafile) {
400
485
  const outputs = result.metafile.outputs;
401
486
  let totalSize = 0;
@@ -472,6 +557,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
472
557
  const context2 = await esbuild__namespace.context(buildOptions);
473
558
  await context2.rebuild();
474
559
  await generateManifest2(themeName, themePath, outputDir);
560
+ await generateThemeData(themePath, outputDir, themeName);
475
561
  return { context: context2, outputDir };
476
562
  }
477
563
  async function compilePreviewRuntime(themePath) {
@@ -545,6 +631,65 @@ ${locations.join("\n")}`
545
631
  loader: "js"
546
632
  };
547
633
  });
634
+ build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
635
+ var _a;
636
+ if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
637
+ try {
638
+ const result = await build2.resolve(args.path, {
639
+ kind: args.kind,
640
+ resolveDir: args.resolveDir,
641
+ importer: args.importer,
642
+ namespace: "file",
643
+ pluginData: { skipStub: true }
644
+ });
645
+ if (!result.errors.length) return result;
646
+ } catch (e) {
647
+ }
648
+ return { path: args.path, namespace: "lucide-stub" };
649
+ });
650
+ build2.onLoad({ filter: /.*/, namespace: "lucide-stub" }, () => ({
651
+ // Provide all icon names used by @onexapis/core as no-op SVG stub components
652
+ contents: `
653
+ const icon = (props) => null;
654
+ export { icon as Check, icon as ChevronDown, icon as XCircle, icon as AlertTriangle };
655
+ export { icon as CheckCircle, icon as Info, icon as X, icon as XIcon };
656
+ export { icon as CircleIcon, icon as Star, icon as ShoppingCart };
657
+ export { icon as ChevronRight, icon as ChevronLeft, icon as ChevronUp };
658
+ export { icon as Search, icon as Menu, icon as Heart, icon as User };
659
+ export { icon as Trash2, icon as Plus, icon as Minus, icon as Eye, icon as EyeOff };
660
+ export { icon as ArrowRight, icon as ArrowLeft, icon as ExternalLink, icon as Mail };
661
+ export { icon as Phone, icon as MapPin, icon as Calendar, icon as Clock };
662
+ export { icon as Facebook, icon as Twitter, icon as Instagram, icon as Linkedin, icon as Github };
663
+ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true : icon });
664
+ `.trim(),
665
+ loader: "jsx"
666
+ }));
667
+ build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
668
+ var _a;
669
+ if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
670
+ try {
671
+ const result = await build2.resolve(args.path, {
672
+ kind: args.kind,
673
+ resolveDir: args.resolveDir,
674
+ importer: args.importer,
675
+ namespace: "file",
676
+ pluginData: { skipStub: true }
677
+ });
678
+ if (!result.errors.length) return result;
679
+ } catch (e) {
680
+ }
681
+ return { path: args.path, namespace: "motion-stub" };
682
+ });
683
+ build2.onLoad({ filter: /.*/, namespace: "motion-stub" }, () => ({
684
+ contents: `
685
+ const stub = (props) => props.children || null;
686
+ const handler = { get: (_, name) => name === '__esModule' ? true : stub };
687
+ export const motion = new Proxy({}, handler);
688
+ export const AnimatePresence = stub;
689
+ export default { motion, AnimatePresence };
690
+ `.trim(),
691
+ loader: "jsx"
692
+ }));
548
693
  }
549
694
  };
550
695
  await esbuild__namespace.build({
@@ -575,10 +720,11 @@ ${locations.join("\n")}`
575
720
  });
576
721
  return outputPath;
577
722
  }
578
- var PROCESS_SHIM, reactGlobalPlugin;
723
+ var import_meta, PROCESS_SHIM, reactGlobalPlugin;
579
724
  var init_compile_theme = __esm({
580
725
  "src/utils/compile-theme.ts"() {
581
726
  init_logger();
727
+ import_meta = {};
582
728
  PROCESS_SHIM = `
583
729
  if (typeof process === "undefined") {
584
730
  globalThis.process = {