@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/cli.js +157 -125
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +156 -125
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +153 -121
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -121
- package/dist/index.mjs.map +1 -1
- package/dist/preview/preview-app.tsx +112 -21
- package/package.json +3 -1
- package/templates/default/.env.example +4 -0
- package/templates/default/package.json.ejs +2 -1
package/dist/cli.js
CHANGED
|
@@ -25,6 +25,7 @@ var chokidar = require('chokidar');
|
|
|
25
25
|
var http = require('http');
|
|
26
26
|
var ws = require('ws');
|
|
27
27
|
|
|
28
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
28
29
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
29
30
|
|
|
30
31
|
function _interopNamespace(e) {
|
|
@@ -66,22 +67,6 @@ var http__default = /*#__PURE__*/_interopDefault(http);
|
|
|
66
67
|
|
|
67
68
|
var __defProp = Object.defineProperty;
|
|
68
69
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
69
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
70
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
71
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
72
|
-
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
73
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
74
|
-
var __spreadValues = (a, b) => {
|
|
75
|
-
for (var prop in b || (b = {}))
|
|
76
|
-
if (__hasOwnProp.call(b, prop))
|
|
77
|
-
__defNormalProp(a, prop, b[prop]);
|
|
78
|
-
if (__getOwnPropSymbols)
|
|
79
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
80
|
-
if (__propIsEnum.call(b, prop))
|
|
81
|
-
__defNormalProp(a, prop, b[prop]);
|
|
82
|
-
}
|
|
83
|
-
return a;
|
|
84
|
-
};
|
|
85
70
|
var __esm = (fn, res) => function __init() {
|
|
86
71
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
87
72
|
};
|
|
@@ -89,7 +74,6 @@ var __export = (target, all) => {
|
|
|
89
74
|
for (var name in all)
|
|
90
75
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
91
76
|
};
|
|
92
|
-
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);
|
|
93
77
|
var Logger, logger;
|
|
94
78
|
var init_logger = __esm({
|
|
95
79
|
"src/utils/logger.ts"() {
|
|
@@ -162,7 +146,7 @@ async function resolveNodeModulesFile(startDir, relativePath) {
|
|
|
162
146
|
try {
|
|
163
147
|
await fs7__default.default.access(candidate);
|
|
164
148
|
return candidate;
|
|
165
|
-
} catch
|
|
149
|
+
} catch {
|
|
166
150
|
const parent = path__default.default.dirname(dir);
|
|
167
151
|
if (parent === dir) break;
|
|
168
152
|
dir = parent;
|
|
@@ -181,7 +165,7 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
181
165
|
}));
|
|
182
166
|
build2.onLoad({ filter: /.*/, namespace: "core-global" }, async (args) => {
|
|
183
167
|
const match = args.path.match(/^@onexapis\/core(\/(.+))?$/);
|
|
184
|
-
const subpath =
|
|
168
|
+
const subpath = match?.[2] || "";
|
|
185
169
|
const moduleAccess = subpath ? `['${subpath}']` : "";
|
|
186
170
|
let namedExports = [];
|
|
187
171
|
const cacheKey = subpath || "__root__";
|
|
@@ -205,7 +189,7 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
205
189
|
namedExports.push(...names);
|
|
206
190
|
}
|
|
207
191
|
namedExports = [...new Set(namedExports)];
|
|
208
|
-
} catch
|
|
192
|
+
} catch {
|
|
209
193
|
}
|
|
210
194
|
exportsBySubpath[cacheKey] = namedExports;
|
|
211
195
|
}
|
|
@@ -239,7 +223,7 @@ ${namedExportLines}
|
|
|
239
223
|
}
|
|
240
224
|
async function generateThemeData(themePath, outputDir, themeId) {
|
|
241
225
|
const { createJiti } = await import('jiti');
|
|
242
|
-
const jiti = createJiti(
|
|
226
|
+
const jiti = createJiti((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
243
227
|
let themeConfig = null;
|
|
244
228
|
let layoutConfig = null;
|
|
245
229
|
const pages = {};
|
|
@@ -248,7 +232,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
248
232
|
const mod = await jiti.import(path__default.default.join(themePath, `theme.config${ext}`));
|
|
249
233
|
themeConfig = mod.default || mod;
|
|
250
234
|
break;
|
|
251
|
-
} catch
|
|
235
|
+
} catch {
|
|
252
236
|
}
|
|
253
237
|
}
|
|
254
238
|
for (const ext of [".ts", ".js"]) {
|
|
@@ -256,7 +240,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
256
240
|
const mod = await jiti.import(path__default.default.join(themePath, `theme.layout${ext}`));
|
|
257
241
|
layoutConfig = mod.default || mod;
|
|
258
242
|
break;
|
|
259
|
-
} catch
|
|
243
|
+
} catch {
|
|
260
244
|
}
|
|
261
245
|
}
|
|
262
246
|
const pagesDir = path__default.default.join(themePath, "pages");
|
|
@@ -272,14 +256,14 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
272
256
|
id: name,
|
|
273
257
|
name: config.title || name,
|
|
274
258
|
path: config.path || `/${name}`,
|
|
275
|
-
config:
|
|
259
|
+
config: { id: name, ...config },
|
|
276
260
|
sections: config.sections || [],
|
|
277
261
|
seo: config.seo
|
|
278
262
|
};
|
|
279
|
-
} catch
|
|
263
|
+
} catch {
|
|
280
264
|
}
|
|
281
265
|
}
|
|
282
|
-
} catch
|
|
266
|
+
} catch {
|
|
283
267
|
}
|
|
284
268
|
await fs7__default.default.writeFile(
|
|
285
269
|
path__default.default.join(outputDir, "theme-data.json"),
|
|
@@ -288,11 +272,11 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
288
272
|
themeId,
|
|
289
273
|
theme: {
|
|
290
274
|
id: themeId,
|
|
291
|
-
name:
|
|
275
|
+
name: themeConfig?.name || themeId,
|
|
292
276
|
config: themeConfig,
|
|
293
277
|
layout: {
|
|
294
|
-
header:
|
|
295
|
-
footer:
|
|
278
|
+
header: layoutConfig?.headerSections || [],
|
|
279
|
+
footer: layoutConfig?.footerSections || []
|
|
296
280
|
},
|
|
297
281
|
pages: Object.keys(pages)
|
|
298
282
|
},
|
|
@@ -302,9 +286,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
302
286
|
2
|
|
303
287
|
)
|
|
304
288
|
);
|
|
305
|
-
logger.info(
|
|
306
|
-
`Generated theme-data.json (${Object.keys(pages).length} pages)`
|
|
307
|
-
);
|
|
289
|
+
logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
|
|
308
290
|
}
|
|
309
291
|
async function contentHashEntry(outputDir) {
|
|
310
292
|
const entryPath = path__default.default.join(outputDir, "bundle-entry.js");
|
|
@@ -316,11 +298,11 @@ async function contentHashEntry(outputDir) {
|
|
|
316
298
|
let entryContent;
|
|
317
299
|
try {
|
|
318
300
|
entryContent = await fs7__default.default.readFile(entryPath, "utf-8");
|
|
319
|
-
} catch
|
|
301
|
+
} catch {
|
|
320
302
|
const indexPath = path__default.default.join(outputDir, "index.js");
|
|
321
303
|
try {
|
|
322
304
|
entryContent = await fs7__default.default.readFile(indexPath, "utf-8");
|
|
323
|
-
} catch
|
|
305
|
+
} catch {
|
|
324
306
|
logger.warning("No entry file found in output, skipping content hash");
|
|
325
307
|
return;
|
|
326
308
|
}
|
|
@@ -337,7 +319,7 @@ async function contentHashEntry(outputDir) {
|
|
|
337
319
|
try {
|
|
338
320
|
await fs7__default.default.access(indexMapPath);
|
|
339
321
|
await fs7__default.default.rename(indexMapPath, path__default.default.join(outputDir, hashedMapName2));
|
|
340
|
-
} catch
|
|
322
|
+
} catch {
|
|
341
323
|
}
|
|
342
324
|
logger.info(`Entry hashed: ${hashedName2}`);
|
|
343
325
|
return;
|
|
@@ -354,10 +336,32 @@ async function contentHashEntry(outputDir) {
|
|
|
354
336
|
try {
|
|
355
337
|
await fs7__default.default.access(mapPath);
|
|
356
338
|
await fs7__default.default.rename(mapPath, path__default.default.join(outputDir, hashedMapName));
|
|
357
|
-
} catch
|
|
339
|
+
} catch {
|
|
358
340
|
}
|
|
359
341
|
logger.info(`Entry hashed: ${hashedName}`);
|
|
360
342
|
}
|
|
343
|
+
async function extractDataRequirements(themePath) {
|
|
344
|
+
const { createJiti } = await import('jiti');
|
|
345
|
+
const jiti = createJiti((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
346
|
+
const schemaFiles = await glob.glob("sections/**/*.schema.ts", { cwd: themePath });
|
|
347
|
+
const requirements = {};
|
|
348
|
+
for (const file of schemaFiles) {
|
|
349
|
+
try {
|
|
350
|
+
const mod = await jiti.import(path__default.default.join(themePath, file));
|
|
351
|
+
const exports$1 = mod;
|
|
352
|
+
for (const value of Object.values(exports$1)) {
|
|
353
|
+
if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
|
|
354
|
+
requirements[value.type] = value.dataRequirements;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
} catch (err) {
|
|
358
|
+
logger.warning(
|
|
359
|
+
`Could not load schema ${file}: ${err instanceof Error ? err.message : String(err)}`
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return requirements;
|
|
364
|
+
}
|
|
361
365
|
async function generateManifest2(themeName, themePath, outputDir) {
|
|
362
366
|
let version = "1.0.0";
|
|
363
367
|
let themeId = themeName;
|
|
@@ -371,18 +375,19 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
371
375
|
if (pkg.name) {
|
|
372
376
|
themeId = pkg.name.replace(/^@onex-themes\//, "");
|
|
373
377
|
}
|
|
374
|
-
} catch
|
|
378
|
+
} catch {
|
|
375
379
|
}
|
|
376
380
|
const [sectionFiles, blockFiles, schemaFiles] = await Promise.all([
|
|
377
381
|
glob.glob("sections/**/index.ts", { cwd: themePath }),
|
|
378
382
|
glob.glob("blocks/**/index.ts", { cwd: themePath }),
|
|
379
383
|
glob.glob("**/*.schema.ts", { cwd: themePath })
|
|
380
384
|
]);
|
|
385
|
+
const dataRequirements = await extractDataRequirements(themePath);
|
|
381
386
|
let hasThemeConfig = false;
|
|
382
387
|
try {
|
|
383
388
|
await fs7__default.default.access(path__default.default.join(themePath, "theme.config.ts"));
|
|
384
389
|
hasThemeConfig = true;
|
|
385
|
-
} catch
|
|
390
|
+
} catch {
|
|
386
391
|
}
|
|
387
392
|
const allFiles = await glob.glob("**/*", { cwd: outputDir, nodir: true });
|
|
388
393
|
const jsFiles = allFiles.filter((f) => f.endsWith(".js"));
|
|
@@ -417,7 +422,9 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
417
422
|
blocks: blockFiles,
|
|
418
423
|
schemas: schemaFiles,
|
|
419
424
|
hasThemeConfig
|
|
420
|
-
}
|
|
425
|
+
},
|
|
426
|
+
// Section data requirements for server-side prefetching (keyed by section type)
|
|
427
|
+
dataRequirements
|
|
421
428
|
};
|
|
422
429
|
await fs7__default.default.writeFile(
|
|
423
430
|
path__default.default.join(outputDir, "manifest.json"),
|
|
@@ -432,7 +439,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
432
439
|
try {
|
|
433
440
|
await fs7__default.default.access(bundleEntry);
|
|
434
441
|
entryPoint = bundleEntry;
|
|
435
|
-
} catch
|
|
442
|
+
} catch {
|
|
436
443
|
}
|
|
437
444
|
const shimPath = path__default.default.join(outputDir, ".process-shim.js");
|
|
438
445
|
await fs7__default.default.mkdir(outputDir, { recursive: true });
|
|
@@ -483,7 +490,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
483
490
|
const result = await esbuild__namespace.build(buildOptions);
|
|
484
491
|
try {
|
|
485
492
|
await fs7__default.default.unlink(shimPath);
|
|
486
|
-
} catch
|
|
493
|
+
} catch {
|
|
487
494
|
}
|
|
488
495
|
await contentHashEntry(outputDir);
|
|
489
496
|
await generateManifest2(themeName, themePath, outputDir);
|
|
@@ -501,7 +508,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
501
508
|
} catch (error) {
|
|
502
509
|
try {
|
|
503
510
|
await fs7__default.default.unlink(shimPath);
|
|
504
|
-
} catch
|
|
511
|
+
} catch {
|
|
505
512
|
}
|
|
506
513
|
logger.error(`esbuild compilation failed: ${error}`);
|
|
507
514
|
return false;
|
|
@@ -515,7 +522,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
515
522
|
try {
|
|
516
523
|
await fs7__default.default.access(bundleEntry);
|
|
517
524
|
entryPoint = bundleEntry;
|
|
518
|
-
} catch
|
|
525
|
+
} catch {
|
|
519
526
|
}
|
|
520
527
|
const shimPath = path__default.default.join(outputDir, ".process-shim.js");
|
|
521
528
|
await fs7__default.default.mkdir(outputDir, { recursive: true });
|
|
@@ -582,7 +589,7 @@ async function compilePreviewRuntime(themePath) {
|
|
|
582
589
|
await fs7__default.default.access(loc);
|
|
583
590
|
previewEntryPath = loc;
|
|
584
591
|
break;
|
|
585
|
-
} catch
|
|
592
|
+
} catch {
|
|
586
593
|
}
|
|
587
594
|
}
|
|
588
595
|
if (!previewEntryPath) {
|
|
@@ -622,10 +629,13 @@ ${locations.join("\n")}`
|
|
|
622
629
|
"zlib"
|
|
623
630
|
];
|
|
624
631
|
for (const mod of nodeBuiltins) {
|
|
625
|
-
build2.onResolve(
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
632
|
+
build2.onResolve(
|
|
633
|
+
{ filter: new RegExp(`^${mod.replace("/", "\\/")}$`) },
|
|
634
|
+
() => ({
|
|
635
|
+
path: mod,
|
|
636
|
+
namespace: "node-stub"
|
|
637
|
+
})
|
|
638
|
+
);
|
|
629
639
|
}
|
|
630
640
|
build2.onLoad({ filter: /.*/, namespace: "node-stub" }, (args) => {
|
|
631
641
|
const stubs = {
|
|
@@ -639,8 +649,7 @@ ${locations.join("\n")}`
|
|
|
639
649
|
};
|
|
640
650
|
});
|
|
641
651
|
build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
|
|
642
|
-
|
|
643
|
-
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
652
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
644
653
|
try {
|
|
645
654
|
const result = await build2.resolve(args.path, {
|
|
646
655
|
kind: args.kind,
|
|
@@ -650,7 +659,7 @@ ${locations.join("\n")}`
|
|
|
650
659
|
pluginData: { skipStub: true }
|
|
651
660
|
});
|
|
652
661
|
if (!result.errors.length) return result;
|
|
653
|
-
} catch
|
|
662
|
+
} catch {
|
|
654
663
|
}
|
|
655
664
|
return { path: args.path, namespace: "lucide-stub" };
|
|
656
665
|
});
|
|
@@ -672,8 +681,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
672
681
|
loader: "jsx"
|
|
673
682
|
}));
|
|
674
683
|
build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
|
|
675
|
-
|
|
676
|
-
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
684
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
677
685
|
try {
|
|
678
686
|
const result = await build2.resolve(args.path, {
|
|
679
687
|
kind: args.kind,
|
|
@@ -683,7 +691,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
683
691
|
pluginData: { skipStub: true }
|
|
684
692
|
});
|
|
685
693
|
if (!result.errors.length) return result;
|
|
686
|
-
} catch
|
|
694
|
+
} catch {
|
|
687
695
|
}
|
|
688
696
|
return { path: args.path, namespace: "motion-stub" };
|
|
689
697
|
});
|
|
@@ -697,8 +705,59 @@ export default { motion, AnimatePresence };
|
|
|
697
705
|
`.trim(),
|
|
698
706
|
loader: "jsx"
|
|
699
707
|
}));
|
|
708
|
+
build2.onResolve({ filter: /^next\// }, async (args) => {
|
|
709
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
710
|
+
try {
|
|
711
|
+
const result = await build2.resolve(args.path, {
|
|
712
|
+
kind: args.kind,
|
|
713
|
+
resolveDir: args.resolveDir,
|
|
714
|
+
importer: args.importer,
|
|
715
|
+
namespace: "file",
|
|
716
|
+
pluginData: { skipStub: true }
|
|
717
|
+
});
|
|
718
|
+
if (!result.errors.length) return result;
|
|
719
|
+
} catch {
|
|
720
|
+
}
|
|
721
|
+
return { path: args.path, namespace: "next-stub" };
|
|
722
|
+
});
|
|
723
|
+
build2.onLoad({ filter: /.*/, namespace: "next-stub" }, (args) => {
|
|
724
|
+
const stubs = {
|
|
725
|
+
"next/image": `
|
|
726
|
+
const Image = (props) => {
|
|
727
|
+
const { src, alt, width, height, fill, priority, ...rest } = props;
|
|
728
|
+
const imgSrc = typeof src === 'object' ? src.src : src;
|
|
729
|
+
return React.createElement('img', { src: imgSrc, alt, width: fill ? undefined : width, height: fill ? undefined : height, loading: priority ? 'eager' : 'lazy', ...rest });
|
|
730
|
+
};
|
|
731
|
+
import React from 'react';
|
|
732
|
+
export default Image;
|
|
733
|
+
`,
|
|
734
|
+
"next/link": `
|
|
735
|
+
const Link = ({ href, children, ...rest }) => React.createElement('a', { href, ...rest }, children);
|
|
736
|
+
import React from 'react';
|
|
737
|
+
export default Link;
|
|
738
|
+
`,
|
|
739
|
+
"next/navigation": `
|
|
740
|
+
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(){} }; }
|
|
741
|
+
export function usePathname() { return window.location.pathname; }
|
|
742
|
+
export function useSearchParams() { return new URLSearchParams(window.location.search); }
|
|
743
|
+
export function useParams() { return {}; }
|
|
744
|
+
export function redirect(url) { window.location.href = url; }
|
|
745
|
+
export function notFound() { throw new Error('Not Found'); }
|
|
746
|
+
`,
|
|
747
|
+
"next/headers": `
|
|
748
|
+
export function cookies() { return { get(){}, getAll(){ return []; }, set(){}, delete(){}, has(){ return false; } }; }
|
|
749
|
+
export function headers() { return new Headers(); }
|
|
750
|
+
`
|
|
751
|
+
};
|
|
752
|
+
return {
|
|
753
|
+
contents: stubs[args.path] || "export default {};",
|
|
754
|
+
loader: "jsx"
|
|
755
|
+
};
|
|
756
|
+
});
|
|
700
757
|
}
|
|
701
758
|
};
|
|
759
|
+
const shimPath = path__default.default.join(outputDir, ".process-shim-preview.js");
|
|
760
|
+
await fs7__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
702
761
|
await esbuild__namespace.build({
|
|
703
762
|
entryPoints: [previewEntryPath],
|
|
704
763
|
bundle: true,
|
|
@@ -708,6 +767,7 @@ export default { motion, AnimatePresence };
|
|
|
708
767
|
// Bundle React + core INTO the output (NOT externalized)
|
|
709
768
|
external: [],
|
|
710
769
|
plugins: [serverStubPlugin],
|
|
770
|
+
inject: [shimPath],
|
|
711
771
|
minify: false,
|
|
712
772
|
sourcemap: true,
|
|
713
773
|
target: "es2020",
|
|
@@ -715,6 +775,12 @@ export default { motion, AnimatePresence };
|
|
|
715
775
|
jsxImportSource: "react",
|
|
716
776
|
define: {
|
|
717
777
|
"process.env.NODE_ENV": JSON.stringify("development"),
|
|
778
|
+
"process.env.NEXT_PUBLIC_API_URL": JSON.stringify(
|
|
779
|
+
process.env.NEXT_PUBLIC_API_URL || ""
|
|
780
|
+
),
|
|
781
|
+
"process.env.NEXT_PUBLIC_COMPANY_ID": JSON.stringify(
|
|
782
|
+
process.env.NEXT_PUBLIC_COMPANY_ID || ""
|
|
783
|
+
),
|
|
718
784
|
global: "globalThis"
|
|
719
785
|
},
|
|
720
786
|
loader: { ".tsx": "tsx", ".ts": "ts" },
|
|
@@ -725,13 +791,16 @@ export default { motion, AnimatePresence };
|
|
|
725
791
|
"ignored-bare-import": "silent"
|
|
726
792
|
}
|
|
727
793
|
});
|
|
794
|
+
try {
|
|
795
|
+
await fs7__default.default.unlink(shimPath);
|
|
796
|
+
} catch {
|
|
797
|
+
}
|
|
728
798
|
return outputPath;
|
|
729
799
|
}
|
|
730
|
-
var
|
|
800
|
+
var PROCESS_SHIM, reactGlobalPlugin;
|
|
731
801
|
var init_compile_theme = __esm({
|
|
732
802
|
"src/utils/compile-theme.ts"() {
|
|
733
803
|
init_logger();
|
|
734
|
-
import_meta = {};
|
|
735
804
|
PROCESS_SHIM = `
|
|
736
805
|
if (typeof process === "undefined") {
|
|
737
806
|
globalThis.process = {
|
|
@@ -1162,7 +1231,7 @@ Add your theme-specific blocks here.
|
|
|
1162
1231
|
stdio: "ignore"
|
|
1163
1232
|
});
|
|
1164
1233
|
logger.stopSpinner(true, "Git repository initialized!");
|
|
1165
|
-
} catch
|
|
1234
|
+
} catch {
|
|
1166
1235
|
logger.stopSpinner(false, "Failed to initialize git");
|
|
1167
1236
|
}
|
|
1168
1237
|
}
|
|
@@ -1173,7 +1242,7 @@ Add your theme-specific blocks here.
|
|
|
1173
1242
|
try {
|
|
1174
1243
|
await installDependencies(projectPath, packageManager);
|
|
1175
1244
|
logger.stopSpinner(true, "Dependencies installed!");
|
|
1176
|
-
} catch
|
|
1245
|
+
} catch {
|
|
1177
1246
|
logger.stopSpinner(false, "Failed to install dependencies");
|
|
1178
1247
|
logger.info(
|
|
1179
1248
|
"You can install dependencies manually by running: cd " + name + " && npm install"
|
|
@@ -2437,7 +2506,6 @@ async function validateCommand(options) {
|
|
|
2437
2506
|
// src/commands/build.ts
|
|
2438
2507
|
init_logger();
|
|
2439
2508
|
async function buildCommand(options) {
|
|
2440
|
-
var _a;
|
|
2441
2509
|
logger.header("Build Theme");
|
|
2442
2510
|
let themePath;
|
|
2443
2511
|
let themeName;
|
|
@@ -2450,7 +2518,7 @@ async function buildCommand(options) {
|
|
|
2450
2518
|
} else {
|
|
2451
2519
|
themePath = path__default.default.join(process.cwd(), themeName);
|
|
2452
2520
|
}
|
|
2453
|
-
} catch
|
|
2521
|
+
} catch {
|
|
2454
2522
|
themePath = path__default.default.join(process.cwd(), themeName);
|
|
2455
2523
|
}
|
|
2456
2524
|
if (!fs__default.default.existsSync(themePath)) {
|
|
@@ -2507,7 +2575,7 @@ async function buildCommand(options) {
|
|
|
2507
2575
|
}
|
|
2508
2576
|
logger.stopSpinner(true, "Lint passed");
|
|
2509
2577
|
const pkgJson = fs__default.default.readJsonSync(packageJsonPath);
|
|
2510
|
-
const buildScript =
|
|
2578
|
+
const buildScript = pkgJson.scripts?.build || "";
|
|
2511
2579
|
const isRecursive = buildScript.includes("onex build") || buildScript.includes("onex-cli build");
|
|
2512
2580
|
logger.startSpinner(
|
|
2513
2581
|
options.watch ? "Building (watch mode)..." : "Building..."
|
|
@@ -2864,7 +2932,6 @@ async function findCompiledThemeDir(themeId, version) {
|
|
|
2864
2932
|
return null;
|
|
2865
2933
|
}
|
|
2866
2934
|
async function readManifest() {
|
|
2867
|
-
var _a;
|
|
2868
2935
|
const manifestTsPath = path__default.default.resolve(process.cwd(), "manifest.ts");
|
|
2869
2936
|
if (await fs__default.default.pathExists(manifestTsPath)) {
|
|
2870
2937
|
try {
|
|
@@ -2878,7 +2945,7 @@ async function readManifest() {
|
|
|
2878
2945
|
if (await fs__default.default.pathExists(packageJsonPath)) {
|
|
2879
2946
|
const pkg = await fs__default.default.readJson(packageJsonPath);
|
|
2880
2947
|
return {
|
|
2881
|
-
themeId:
|
|
2948
|
+
themeId: pkg.name?.replace("@onex-themes/", "") || "unknown",
|
|
2882
2949
|
version: pkg.version || "1.0.0"
|
|
2883
2950
|
};
|
|
2884
2951
|
}
|
|
@@ -3122,39 +3189,15 @@ function getBucketName2(env) {
|
|
|
3122
3189
|
}
|
|
3123
3190
|
async function streamToString(stream) {
|
|
3124
3191
|
const chunks = [];
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
const chunk = temp.value;
|
|
3128
|
-
chunks.push(Buffer.from(chunk));
|
|
3129
|
-
}
|
|
3130
|
-
} catch (temp) {
|
|
3131
|
-
error = [temp];
|
|
3132
|
-
} finally {
|
|
3133
|
-
try {
|
|
3134
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3135
|
-
} finally {
|
|
3136
|
-
if (error)
|
|
3137
|
-
throw error[0];
|
|
3138
|
-
}
|
|
3192
|
+
for await (const chunk of stream) {
|
|
3193
|
+
chunks.push(Buffer.from(chunk));
|
|
3139
3194
|
}
|
|
3140
3195
|
return Buffer.concat(chunks).toString("utf-8");
|
|
3141
3196
|
}
|
|
3142
3197
|
async function streamToBuffer(stream) {
|
|
3143
3198
|
const chunks = [];
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
const chunk = temp.value;
|
|
3147
|
-
chunks.push(Buffer.from(chunk));
|
|
3148
|
-
}
|
|
3149
|
-
} catch (temp) {
|
|
3150
|
-
error = [temp];
|
|
3151
|
-
} finally {
|
|
3152
|
-
try {
|
|
3153
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3154
|
-
} finally {
|
|
3155
|
-
if (error)
|
|
3156
|
-
throw error[0];
|
|
3157
|
-
}
|
|
3199
|
+
for await (const chunk of stream) {
|
|
3200
|
+
chunks.push(Buffer.from(chunk));
|
|
3158
3201
|
}
|
|
3159
3202
|
return Buffer.concat(chunks);
|
|
3160
3203
|
}
|
|
@@ -3176,8 +3219,7 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
|
|
|
3176
3219
|
}
|
|
3177
3220
|
}
|
|
3178
3221
|
async function createCompatibilityFiles(outputDir, manifest) {
|
|
3179
|
-
|
|
3180
|
-
const entryFile = ((_a = manifest.output) == null ? void 0 : _a.entry) || "bundle-entry.js";
|
|
3222
|
+
const entryFile = manifest.output?.entry || "bundle-entry.js";
|
|
3181
3223
|
if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
|
|
3182
3224
|
const hashedPath = path__default.default.join(outputDir, entryFile);
|
|
3183
3225
|
const stablePath = path__default.default.join(outputDir, "bundle-entry.js");
|
|
@@ -3348,39 +3390,15 @@ function getBucketName3(env) {
|
|
|
3348
3390
|
}
|
|
3349
3391
|
async function streamToString2(stream) {
|
|
3350
3392
|
const chunks = [];
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
const chunk = temp.value;
|
|
3354
|
-
chunks.push(Buffer.from(chunk));
|
|
3355
|
-
}
|
|
3356
|
-
} catch (temp) {
|
|
3357
|
-
error = [temp];
|
|
3358
|
-
} finally {
|
|
3359
|
-
try {
|
|
3360
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3361
|
-
} finally {
|
|
3362
|
-
if (error)
|
|
3363
|
-
throw error[0];
|
|
3364
|
-
}
|
|
3393
|
+
for await (const chunk of stream) {
|
|
3394
|
+
chunks.push(Buffer.from(chunk));
|
|
3365
3395
|
}
|
|
3366
3396
|
return Buffer.concat(chunks).toString("utf-8");
|
|
3367
3397
|
}
|
|
3368
3398
|
async function streamToBuffer2(stream) {
|
|
3369
3399
|
const chunks = [];
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
const chunk = temp.value;
|
|
3373
|
-
chunks.push(Buffer.from(chunk));
|
|
3374
|
-
}
|
|
3375
|
-
} catch (temp) {
|
|
3376
|
-
error = [temp];
|
|
3377
|
-
} finally {
|
|
3378
|
-
try {
|
|
3379
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3380
|
-
} finally {
|
|
3381
|
-
if (error)
|
|
3382
|
-
throw error[0];
|
|
3383
|
-
}
|
|
3400
|
+
for await (const chunk of stream) {
|
|
3401
|
+
chunks.push(Buffer.from(chunk));
|
|
3384
3402
|
}
|
|
3385
3403
|
return Buffer.concat(chunks);
|
|
3386
3404
|
}
|
|
@@ -3556,6 +3574,19 @@ async function cloneCommand(themeName, options) {
|
|
|
3556
3574
|
spinner.succeed(
|
|
3557
3575
|
`Renamed theme: ${chalk4__default.default.gray(themeName)} \u2192 ${chalk4__default.default.cyan(newName)}`
|
|
3558
3576
|
);
|
|
3577
|
+
const envExamplePath = path__default.default.join(outputDir, ".env.example");
|
|
3578
|
+
if (!await fs__default.default.pathExists(envExamplePath)) {
|
|
3579
|
+
await fs__default.default.writeFile(
|
|
3580
|
+
envExamplePath,
|
|
3581
|
+
[
|
|
3582
|
+
"# API Configuration (enables real data in preview)",
|
|
3583
|
+
"# Get your Company ID from the OneX dashboard",
|
|
3584
|
+
"NEXT_PUBLIC_API_URL=https://api-dev.onexeos.com",
|
|
3585
|
+
"NEXT_PUBLIC_COMPANY_ID=",
|
|
3586
|
+
""
|
|
3587
|
+
].join("\n")
|
|
3588
|
+
);
|
|
3589
|
+
}
|
|
3559
3590
|
if (options.install !== false) {
|
|
3560
3591
|
const hasPkgJson = await fs__default.default.pathExists(
|
|
3561
3592
|
path__default.default.join(outputDir, "package.json")
|
|
@@ -3586,6 +3617,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3586
3617
|
console.log();
|
|
3587
3618
|
console.log(chalk4__default.default.cyan("Next steps:"));
|
|
3588
3619
|
console.log(chalk4__default.default.gray(` cd ${path__default.default.relative(process.cwd(), outputDir)}`));
|
|
3620
|
+
console.log(chalk4__default.default.gray(" cp .env.example .env # then add your Company ID"));
|
|
3589
3621
|
if (options.install === false) {
|
|
3590
3622
|
console.log(chalk4__default.default.gray(" pnpm install"));
|
|
3591
3623
|
}
|
|
@@ -3683,7 +3715,7 @@ function serveFile(res, filePath) {
|
|
|
3683
3715
|
const content = fs2__default.default.readFileSync(filePath);
|
|
3684
3716
|
res.writeHead(200, { "Content-Type": contentType });
|
|
3685
3717
|
res.end(content);
|
|
3686
|
-
} catch
|
|
3718
|
+
} catch {
|
|
3687
3719
|
res.writeHead(500);
|
|
3688
3720
|
res.end("Internal Server Error");
|
|
3689
3721
|
}
|
|
@@ -3744,7 +3776,7 @@ async function devCommand(options) {
|
|
|
3744
3776
|
} else {
|
|
3745
3777
|
themePath = path__default.default.join(process.cwd(), themeName);
|
|
3746
3778
|
}
|
|
3747
|
-
} catch
|
|
3779
|
+
} catch {
|
|
3748
3780
|
themePath = path__default.default.join(process.cwd(), themeName);
|
|
3749
3781
|
}
|
|
3750
3782
|
if (!fs__default.default.existsSync(themePath)) {
|
|
@@ -3830,7 +3862,7 @@ async function devCommand(options) {
|
|
|
3830
3862
|
const shimPath = path__default.default.join(outputDir, ".process-shim.js");
|
|
3831
3863
|
try {
|
|
3832
3864
|
await fs7__default.default.unlink(shimPath);
|
|
3833
|
-
} catch
|
|
3865
|
+
} catch {
|
|
3834
3866
|
}
|
|
3835
3867
|
process.exit(0);
|
|
3836
3868
|
});
|
|
@@ -3844,7 +3876,7 @@ try {
|
|
|
3844
3876
|
quiet: true
|
|
3845
3877
|
});
|
|
3846
3878
|
dotenv__default.default.config({ path: path__default.default.join(projectRoot, ".env"), quiet: true });
|
|
3847
|
-
} catch
|
|
3879
|
+
} catch {
|
|
3848
3880
|
}
|
|
3849
3881
|
dotenv__default.default.config({
|
|
3850
3882
|
path: path__default.default.join(os__default.default.homedir(), ".onex", ".env"),
|