@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.mjs
CHANGED
|
@@ -25,22 +25,6 @@ import { WebSocketServer, WebSocket } from 'ws';
|
|
|
25
25
|
|
|
26
26
|
var __defProp = Object.defineProperty;
|
|
27
27
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
28
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
29
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
30
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
31
|
-
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
32
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
33
|
-
var __spreadValues = (a, b) => {
|
|
34
|
-
for (var prop in b || (b = {}))
|
|
35
|
-
if (__hasOwnProp.call(b, prop))
|
|
36
|
-
__defNormalProp(a, prop, b[prop]);
|
|
37
|
-
if (__getOwnPropSymbols)
|
|
38
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
39
|
-
if (__propIsEnum.call(b, prop))
|
|
40
|
-
__defNormalProp(a, prop, b[prop]);
|
|
41
|
-
}
|
|
42
|
-
return a;
|
|
43
|
-
};
|
|
44
28
|
var __esm = (fn, res) => function __init() {
|
|
45
29
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
46
30
|
};
|
|
@@ -48,7 +32,6 @@ var __export = (target, all) => {
|
|
|
48
32
|
for (var name in all)
|
|
49
33
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
50
34
|
};
|
|
51
|
-
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);
|
|
52
35
|
var Logger, logger;
|
|
53
36
|
var init_logger = __esm({
|
|
54
37
|
"src/utils/logger.ts"() {
|
|
@@ -121,7 +104,7 @@ async function resolveNodeModulesFile(startDir, relativePath) {
|
|
|
121
104
|
try {
|
|
122
105
|
await fs7.access(candidate);
|
|
123
106
|
return candidate;
|
|
124
|
-
} catch
|
|
107
|
+
} catch {
|
|
125
108
|
const parent = path.dirname(dir);
|
|
126
109
|
if (parent === dir) break;
|
|
127
110
|
dir = parent;
|
|
@@ -140,7 +123,7 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
140
123
|
}));
|
|
141
124
|
build2.onLoad({ filter: /.*/, namespace: "core-global" }, async (args) => {
|
|
142
125
|
const match = args.path.match(/^@onexapis\/core(\/(.+))?$/);
|
|
143
|
-
const subpath =
|
|
126
|
+
const subpath = match?.[2] || "";
|
|
144
127
|
const moduleAccess = subpath ? `['${subpath}']` : "";
|
|
145
128
|
let namedExports = [];
|
|
146
129
|
const cacheKey = subpath || "__root__";
|
|
@@ -164,7 +147,7 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
164
147
|
namedExports.push(...names);
|
|
165
148
|
}
|
|
166
149
|
namedExports = [...new Set(namedExports)];
|
|
167
|
-
} catch
|
|
150
|
+
} catch {
|
|
168
151
|
}
|
|
169
152
|
exportsBySubpath[cacheKey] = namedExports;
|
|
170
153
|
}
|
|
@@ -198,7 +181,7 @@ ${namedExportLines}
|
|
|
198
181
|
}
|
|
199
182
|
async function generateThemeData(themePath, outputDir, themeId) {
|
|
200
183
|
const { createJiti } = await import('jiti');
|
|
201
|
-
const jiti = createJiti(
|
|
184
|
+
const jiti = createJiti(import.meta.url);
|
|
202
185
|
let themeConfig = null;
|
|
203
186
|
let layoutConfig = null;
|
|
204
187
|
const pages = {};
|
|
@@ -207,7 +190,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
207
190
|
const mod = await jiti.import(path.join(themePath, `theme.config${ext}`));
|
|
208
191
|
themeConfig = mod.default || mod;
|
|
209
192
|
break;
|
|
210
|
-
} catch
|
|
193
|
+
} catch {
|
|
211
194
|
}
|
|
212
195
|
}
|
|
213
196
|
for (const ext of [".ts", ".js"]) {
|
|
@@ -215,7 +198,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
215
198
|
const mod = await jiti.import(path.join(themePath, `theme.layout${ext}`));
|
|
216
199
|
layoutConfig = mod.default || mod;
|
|
217
200
|
break;
|
|
218
|
-
} catch
|
|
201
|
+
} catch {
|
|
219
202
|
}
|
|
220
203
|
}
|
|
221
204
|
const pagesDir = path.join(themePath, "pages");
|
|
@@ -231,14 +214,14 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
231
214
|
id: name,
|
|
232
215
|
name: config.title || name,
|
|
233
216
|
path: config.path || `/${name}`,
|
|
234
|
-
config:
|
|
217
|
+
config: { id: name, ...config },
|
|
235
218
|
sections: config.sections || [],
|
|
236
219
|
seo: config.seo
|
|
237
220
|
};
|
|
238
|
-
} catch
|
|
221
|
+
} catch {
|
|
239
222
|
}
|
|
240
223
|
}
|
|
241
|
-
} catch
|
|
224
|
+
} catch {
|
|
242
225
|
}
|
|
243
226
|
await fs7.writeFile(
|
|
244
227
|
path.join(outputDir, "theme-data.json"),
|
|
@@ -247,11 +230,11 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
247
230
|
themeId,
|
|
248
231
|
theme: {
|
|
249
232
|
id: themeId,
|
|
250
|
-
name:
|
|
233
|
+
name: themeConfig?.name || themeId,
|
|
251
234
|
config: themeConfig,
|
|
252
235
|
layout: {
|
|
253
|
-
header:
|
|
254
|
-
footer:
|
|
236
|
+
header: layoutConfig?.headerSections || [],
|
|
237
|
+
footer: layoutConfig?.footerSections || []
|
|
255
238
|
},
|
|
256
239
|
pages: Object.keys(pages)
|
|
257
240
|
},
|
|
@@ -261,9 +244,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
261
244
|
2
|
|
262
245
|
)
|
|
263
246
|
);
|
|
264
|
-
logger.info(
|
|
265
|
-
`Generated theme-data.json (${Object.keys(pages).length} pages)`
|
|
266
|
-
);
|
|
247
|
+
logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
|
|
267
248
|
}
|
|
268
249
|
async function contentHashEntry(outputDir) {
|
|
269
250
|
const entryPath = path.join(outputDir, "bundle-entry.js");
|
|
@@ -275,11 +256,11 @@ async function contentHashEntry(outputDir) {
|
|
|
275
256
|
let entryContent;
|
|
276
257
|
try {
|
|
277
258
|
entryContent = await fs7.readFile(entryPath, "utf-8");
|
|
278
|
-
} catch
|
|
259
|
+
} catch {
|
|
279
260
|
const indexPath = path.join(outputDir, "index.js");
|
|
280
261
|
try {
|
|
281
262
|
entryContent = await fs7.readFile(indexPath, "utf-8");
|
|
282
|
-
} catch
|
|
263
|
+
} catch {
|
|
283
264
|
logger.warning("No entry file found in output, skipping content hash");
|
|
284
265
|
return;
|
|
285
266
|
}
|
|
@@ -296,7 +277,7 @@ async function contentHashEntry(outputDir) {
|
|
|
296
277
|
try {
|
|
297
278
|
await fs7.access(indexMapPath);
|
|
298
279
|
await fs7.rename(indexMapPath, path.join(outputDir, hashedMapName2));
|
|
299
|
-
} catch
|
|
280
|
+
} catch {
|
|
300
281
|
}
|
|
301
282
|
logger.info(`Entry hashed: ${hashedName2}`);
|
|
302
283
|
return;
|
|
@@ -313,10 +294,32 @@ async function contentHashEntry(outputDir) {
|
|
|
313
294
|
try {
|
|
314
295
|
await fs7.access(mapPath);
|
|
315
296
|
await fs7.rename(mapPath, path.join(outputDir, hashedMapName));
|
|
316
|
-
} catch
|
|
297
|
+
} catch {
|
|
317
298
|
}
|
|
318
299
|
logger.info(`Entry hashed: ${hashedName}`);
|
|
319
300
|
}
|
|
301
|
+
async function extractDataRequirements(themePath) {
|
|
302
|
+
const { createJiti } = await import('jiti');
|
|
303
|
+
const jiti = createJiti(import.meta.url);
|
|
304
|
+
const schemaFiles = await glob("sections/**/*.schema.ts", { cwd: themePath });
|
|
305
|
+
const requirements = {};
|
|
306
|
+
for (const file of schemaFiles) {
|
|
307
|
+
try {
|
|
308
|
+
const mod = await jiti.import(path.join(themePath, file));
|
|
309
|
+
const exports$1 = mod;
|
|
310
|
+
for (const value of Object.values(exports$1)) {
|
|
311
|
+
if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
|
|
312
|
+
requirements[value.type] = value.dataRequirements;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
} catch (err) {
|
|
316
|
+
logger.warning(
|
|
317
|
+
`Could not load schema ${file}: ${err instanceof Error ? err.message : String(err)}`
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return requirements;
|
|
322
|
+
}
|
|
320
323
|
async function generateManifest2(themeName, themePath, outputDir) {
|
|
321
324
|
let version = "1.0.0";
|
|
322
325
|
let themeId = themeName;
|
|
@@ -330,18 +333,19 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
330
333
|
if (pkg.name) {
|
|
331
334
|
themeId = pkg.name.replace(/^@onex-themes\//, "");
|
|
332
335
|
}
|
|
333
|
-
} catch
|
|
336
|
+
} catch {
|
|
334
337
|
}
|
|
335
338
|
const [sectionFiles, blockFiles, schemaFiles] = await Promise.all([
|
|
336
339
|
glob("sections/**/index.ts", { cwd: themePath }),
|
|
337
340
|
glob("blocks/**/index.ts", { cwd: themePath }),
|
|
338
341
|
glob("**/*.schema.ts", { cwd: themePath })
|
|
339
342
|
]);
|
|
343
|
+
const dataRequirements = await extractDataRequirements(themePath);
|
|
340
344
|
let hasThemeConfig = false;
|
|
341
345
|
try {
|
|
342
346
|
await fs7.access(path.join(themePath, "theme.config.ts"));
|
|
343
347
|
hasThemeConfig = true;
|
|
344
|
-
} catch
|
|
348
|
+
} catch {
|
|
345
349
|
}
|
|
346
350
|
const allFiles = await glob("**/*", { cwd: outputDir, nodir: true });
|
|
347
351
|
const jsFiles = allFiles.filter((f) => f.endsWith(".js"));
|
|
@@ -376,7 +380,9 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
376
380
|
blocks: blockFiles,
|
|
377
381
|
schemas: schemaFiles,
|
|
378
382
|
hasThemeConfig
|
|
379
|
-
}
|
|
383
|
+
},
|
|
384
|
+
// Section data requirements for server-side prefetching (keyed by section type)
|
|
385
|
+
dataRequirements
|
|
380
386
|
};
|
|
381
387
|
await fs7.writeFile(
|
|
382
388
|
path.join(outputDir, "manifest.json"),
|
|
@@ -391,7 +397,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
391
397
|
try {
|
|
392
398
|
await fs7.access(bundleEntry);
|
|
393
399
|
entryPoint = bundleEntry;
|
|
394
|
-
} catch
|
|
400
|
+
} catch {
|
|
395
401
|
}
|
|
396
402
|
const shimPath = path.join(outputDir, ".process-shim.js");
|
|
397
403
|
await fs7.mkdir(outputDir, { recursive: true });
|
|
@@ -442,7 +448,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
442
448
|
const result = await esbuild.build(buildOptions);
|
|
443
449
|
try {
|
|
444
450
|
await fs7.unlink(shimPath);
|
|
445
|
-
} catch
|
|
451
|
+
} catch {
|
|
446
452
|
}
|
|
447
453
|
await contentHashEntry(outputDir);
|
|
448
454
|
await generateManifest2(themeName, themePath, outputDir);
|
|
@@ -460,7 +466,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
460
466
|
} catch (error) {
|
|
461
467
|
try {
|
|
462
468
|
await fs7.unlink(shimPath);
|
|
463
|
-
} catch
|
|
469
|
+
} catch {
|
|
464
470
|
}
|
|
465
471
|
logger.error(`esbuild compilation failed: ${error}`);
|
|
466
472
|
return false;
|
|
@@ -474,7 +480,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
474
480
|
try {
|
|
475
481
|
await fs7.access(bundleEntry);
|
|
476
482
|
entryPoint = bundleEntry;
|
|
477
|
-
} catch
|
|
483
|
+
} catch {
|
|
478
484
|
}
|
|
479
485
|
const shimPath = path.join(outputDir, ".process-shim.js");
|
|
480
486
|
await fs7.mkdir(outputDir, { recursive: true });
|
|
@@ -541,7 +547,7 @@ async function compilePreviewRuntime(themePath) {
|
|
|
541
547
|
await fs7.access(loc);
|
|
542
548
|
previewEntryPath = loc;
|
|
543
549
|
break;
|
|
544
|
-
} catch
|
|
550
|
+
} catch {
|
|
545
551
|
}
|
|
546
552
|
}
|
|
547
553
|
if (!previewEntryPath) {
|
|
@@ -581,10 +587,13 @@ ${locations.join("\n")}`
|
|
|
581
587
|
"zlib"
|
|
582
588
|
];
|
|
583
589
|
for (const mod of nodeBuiltins) {
|
|
584
|
-
build2.onResolve(
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
590
|
+
build2.onResolve(
|
|
591
|
+
{ filter: new RegExp(`^${mod.replace("/", "\\/")}$`) },
|
|
592
|
+
() => ({
|
|
593
|
+
path: mod,
|
|
594
|
+
namespace: "node-stub"
|
|
595
|
+
})
|
|
596
|
+
);
|
|
588
597
|
}
|
|
589
598
|
build2.onLoad({ filter: /.*/, namespace: "node-stub" }, (args) => {
|
|
590
599
|
const stubs = {
|
|
@@ -598,8 +607,7 @@ ${locations.join("\n")}`
|
|
|
598
607
|
};
|
|
599
608
|
});
|
|
600
609
|
build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
|
|
601
|
-
|
|
602
|
-
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
610
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
603
611
|
try {
|
|
604
612
|
const result = await build2.resolve(args.path, {
|
|
605
613
|
kind: args.kind,
|
|
@@ -609,7 +617,7 @@ ${locations.join("\n")}`
|
|
|
609
617
|
pluginData: { skipStub: true }
|
|
610
618
|
});
|
|
611
619
|
if (!result.errors.length) return result;
|
|
612
|
-
} catch
|
|
620
|
+
} catch {
|
|
613
621
|
}
|
|
614
622
|
return { path: args.path, namespace: "lucide-stub" };
|
|
615
623
|
});
|
|
@@ -631,8 +639,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
631
639
|
loader: "jsx"
|
|
632
640
|
}));
|
|
633
641
|
build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
|
|
634
|
-
|
|
635
|
-
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
642
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
636
643
|
try {
|
|
637
644
|
const result = await build2.resolve(args.path, {
|
|
638
645
|
kind: args.kind,
|
|
@@ -642,7 +649,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
642
649
|
pluginData: { skipStub: true }
|
|
643
650
|
});
|
|
644
651
|
if (!result.errors.length) return result;
|
|
645
|
-
} catch
|
|
652
|
+
} catch {
|
|
646
653
|
}
|
|
647
654
|
return { path: args.path, namespace: "motion-stub" };
|
|
648
655
|
});
|
|
@@ -656,8 +663,59 @@ export default { motion, AnimatePresence };
|
|
|
656
663
|
`.trim(),
|
|
657
664
|
loader: "jsx"
|
|
658
665
|
}));
|
|
666
|
+
build2.onResolve({ filter: /^next\// }, async (args) => {
|
|
667
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
668
|
+
try {
|
|
669
|
+
const result = await build2.resolve(args.path, {
|
|
670
|
+
kind: args.kind,
|
|
671
|
+
resolveDir: args.resolveDir,
|
|
672
|
+
importer: args.importer,
|
|
673
|
+
namespace: "file",
|
|
674
|
+
pluginData: { skipStub: true }
|
|
675
|
+
});
|
|
676
|
+
if (!result.errors.length) return result;
|
|
677
|
+
} catch {
|
|
678
|
+
}
|
|
679
|
+
return { path: args.path, namespace: "next-stub" };
|
|
680
|
+
});
|
|
681
|
+
build2.onLoad({ filter: /.*/, namespace: "next-stub" }, (args) => {
|
|
682
|
+
const stubs = {
|
|
683
|
+
"next/image": `
|
|
684
|
+
const Image = (props) => {
|
|
685
|
+
const { src, alt, width, height, fill, priority, ...rest } = props;
|
|
686
|
+
const imgSrc = typeof src === 'object' ? src.src : src;
|
|
687
|
+
return React.createElement('img', { src: imgSrc, alt, width: fill ? undefined : width, height: fill ? undefined : height, loading: priority ? 'eager' : 'lazy', ...rest });
|
|
688
|
+
};
|
|
689
|
+
import React from 'react';
|
|
690
|
+
export default Image;
|
|
691
|
+
`,
|
|
692
|
+
"next/link": `
|
|
693
|
+
const Link = ({ href, children, ...rest }) => React.createElement('a', { href, ...rest }, children);
|
|
694
|
+
import React from 'react';
|
|
695
|
+
export default Link;
|
|
696
|
+
`,
|
|
697
|
+
"next/navigation": `
|
|
698
|
+
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(){} }; }
|
|
699
|
+
export function usePathname() { return window.location.pathname; }
|
|
700
|
+
export function useSearchParams() { return new URLSearchParams(window.location.search); }
|
|
701
|
+
export function useParams() { return {}; }
|
|
702
|
+
export function redirect(url) { window.location.href = url; }
|
|
703
|
+
export function notFound() { throw new Error('Not Found'); }
|
|
704
|
+
`,
|
|
705
|
+
"next/headers": `
|
|
706
|
+
export function cookies() { return { get(){}, getAll(){ return []; }, set(){}, delete(){}, has(){ return false; } }; }
|
|
707
|
+
export function headers() { return new Headers(); }
|
|
708
|
+
`
|
|
709
|
+
};
|
|
710
|
+
return {
|
|
711
|
+
contents: stubs[args.path] || "export default {};",
|
|
712
|
+
loader: "jsx"
|
|
713
|
+
};
|
|
714
|
+
});
|
|
659
715
|
}
|
|
660
716
|
};
|
|
717
|
+
const shimPath = path.join(outputDir, ".process-shim-preview.js");
|
|
718
|
+
await fs7.writeFile(shimPath, PROCESS_SHIM);
|
|
661
719
|
await esbuild.build({
|
|
662
720
|
entryPoints: [previewEntryPath],
|
|
663
721
|
bundle: true,
|
|
@@ -667,6 +725,7 @@ export default { motion, AnimatePresence };
|
|
|
667
725
|
// Bundle React + core INTO the output (NOT externalized)
|
|
668
726
|
external: [],
|
|
669
727
|
plugins: [serverStubPlugin],
|
|
728
|
+
inject: [shimPath],
|
|
670
729
|
minify: false,
|
|
671
730
|
sourcemap: true,
|
|
672
731
|
target: "es2020",
|
|
@@ -674,6 +733,12 @@ export default { motion, AnimatePresence };
|
|
|
674
733
|
jsxImportSource: "react",
|
|
675
734
|
define: {
|
|
676
735
|
"process.env.NODE_ENV": JSON.stringify("development"),
|
|
736
|
+
"process.env.NEXT_PUBLIC_API_URL": JSON.stringify(
|
|
737
|
+
process.env.NEXT_PUBLIC_API_URL || ""
|
|
738
|
+
),
|
|
739
|
+
"process.env.NEXT_PUBLIC_COMPANY_ID": JSON.stringify(
|
|
740
|
+
process.env.NEXT_PUBLIC_COMPANY_ID || ""
|
|
741
|
+
),
|
|
677
742
|
global: "globalThis"
|
|
678
743
|
},
|
|
679
744
|
loader: { ".tsx": "tsx", ".ts": "ts" },
|
|
@@ -684,13 +749,16 @@ export default { motion, AnimatePresence };
|
|
|
684
749
|
"ignored-bare-import": "silent"
|
|
685
750
|
}
|
|
686
751
|
});
|
|
752
|
+
try {
|
|
753
|
+
await fs7.unlink(shimPath);
|
|
754
|
+
} catch {
|
|
755
|
+
}
|
|
687
756
|
return outputPath;
|
|
688
757
|
}
|
|
689
|
-
var
|
|
758
|
+
var PROCESS_SHIM, reactGlobalPlugin;
|
|
690
759
|
var init_compile_theme = __esm({
|
|
691
760
|
"src/utils/compile-theme.ts"() {
|
|
692
761
|
init_logger();
|
|
693
|
-
import_meta = {};
|
|
694
762
|
PROCESS_SHIM = `
|
|
695
763
|
if (typeof process === "undefined") {
|
|
696
764
|
globalThis.process = {
|
|
@@ -1121,7 +1189,7 @@ Add your theme-specific blocks here.
|
|
|
1121
1189
|
stdio: "ignore"
|
|
1122
1190
|
});
|
|
1123
1191
|
logger.stopSpinner(true, "Git repository initialized!");
|
|
1124
|
-
} catch
|
|
1192
|
+
} catch {
|
|
1125
1193
|
logger.stopSpinner(false, "Failed to initialize git");
|
|
1126
1194
|
}
|
|
1127
1195
|
}
|
|
@@ -1132,7 +1200,7 @@ Add your theme-specific blocks here.
|
|
|
1132
1200
|
try {
|
|
1133
1201
|
await installDependencies(projectPath, packageManager);
|
|
1134
1202
|
logger.stopSpinner(true, "Dependencies installed!");
|
|
1135
|
-
} catch
|
|
1203
|
+
} catch {
|
|
1136
1204
|
logger.stopSpinner(false, "Failed to install dependencies");
|
|
1137
1205
|
logger.info(
|
|
1138
1206
|
"You can install dependencies manually by running: cd " + name + " && npm install"
|
|
@@ -2396,7 +2464,6 @@ async function validateCommand(options) {
|
|
|
2396
2464
|
// src/commands/build.ts
|
|
2397
2465
|
init_logger();
|
|
2398
2466
|
async function buildCommand(options) {
|
|
2399
|
-
var _a;
|
|
2400
2467
|
logger.header("Build Theme");
|
|
2401
2468
|
let themePath;
|
|
2402
2469
|
let themeName;
|
|
@@ -2409,7 +2476,7 @@ async function buildCommand(options) {
|
|
|
2409
2476
|
} else {
|
|
2410
2477
|
themePath = path.join(process.cwd(), themeName);
|
|
2411
2478
|
}
|
|
2412
|
-
} catch
|
|
2479
|
+
} catch {
|
|
2413
2480
|
themePath = path.join(process.cwd(), themeName);
|
|
2414
2481
|
}
|
|
2415
2482
|
if (!fs.existsSync(themePath)) {
|
|
@@ -2466,7 +2533,7 @@ async function buildCommand(options) {
|
|
|
2466
2533
|
}
|
|
2467
2534
|
logger.stopSpinner(true, "Lint passed");
|
|
2468
2535
|
const pkgJson = fs.readJsonSync(packageJsonPath);
|
|
2469
|
-
const buildScript =
|
|
2536
|
+
const buildScript = pkgJson.scripts?.build || "";
|
|
2470
2537
|
const isRecursive = buildScript.includes("onex build") || buildScript.includes("onex-cli build");
|
|
2471
2538
|
logger.startSpinner(
|
|
2472
2539
|
options.watch ? "Building (watch mode)..." : "Building..."
|
|
@@ -2823,7 +2890,6 @@ async function findCompiledThemeDir(themeId, version) {
|
|
|
2823
2890
|
return null;
|
|
2824
2891
|
}
|
|
2825
2892
|
async function readManifest() {
|
|
2826
|
-
var _a;
|
|
2827
2893
|
const manifestTsPath = path.resolve(process.cwd(), "manifest.ts");
|
|
2828
2894
|
if (await fs.pathExists(manifestTsPath)) {
|
|
2829
2895
|
try {
|
|
@@ -2837,7 +2903,7 @@ async function readManifest() {
|
|
|
2837
2903
|
if (await fs.pathExists(packageJsonPath)) {
|
|
2838
2904
|
const pkg = await fs.readJson(packageJsonPath);
|
|
2839
2905
|
return {
|
|
2840
|
-
themeId:
|
|
2906
|
+
themeId: pkg.name?.replace("@onex-themes/", "") || "unknown",
|
|
2841
2907
|
version: pkg.version || "1.0.0"
|
|
2842
2908
|
};
|
|
2843
2909
|
}
|
|
@@ -3081,39 +3147,15 @@ function getBucketName2(env) {
|
|
|
3081
3147
|
}
|
|
3082
3148
|
async function streamToString(stream) {
|
|
3083
3149
|
const chunks = [];
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
const chunk = temp.value;
|
|
3087
|
-
chunks.push(Buffer.from(chunk));
|
|
3088
|
-
}
|
|
3089
|
-
} catch (temp) {
|
|
3090
|
-
error = [temp];
|
|
3091
|
-
} finally {
|
|
3092
|
-
try {
|
|
3093
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3094
|
-
} finally {
|
|
3095
|
-
if (error)
|
|
3096
|
-
throw error[0];
|
|
3097
|
-
}
|
|
3150
|
+
for await (const chunk of stream) {
|
|
3151
|
+
chunks.push(Buffer.from(chunk));
|
|
3098
3152
|
}
|
|
3099
3153
|
return Buffer.concat(chunks).toString("utf-8");
|
|
3100
3154
|
}
|
|
3101
3155
|
async function streamToBuffer(stream) {
|
|
3102
3156
|
const chunks = [];
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
const chunk = temp.value;
|
|
3106
|
-
chunks.push(Buffer.from(chunk));
|
|
3107
|
-
}
|
|
3108
|
-
} catch (temp) {
|
|
3109
|
-
error = [temp];
|
|
3110
|
-
} finally {
|
|
3111
|
-
try {
|
|
3112
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3113
|
-
} finally {
|
|
3114
|
-
if (error)
|
|
3115
|
-
throw error[0];
|
|
3116
|
-
}
|
|
3157
|
+
for await (const chunk of stream) {
|
|
3158
|
+
chunks.push(Buffer.from(chunk));
|
|
3117
3159
|
}
|
|
3118
3160
|
return Buffer.concat(chunks);
|
|
3119
3161
|
}
|
|
@@ -3135,8 +3177,7 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
|
|
|
3135
3177
|
}
|
|
3136
3178
|
}
|
|
3137
3179
|
async function createCompatibilityFiles(outputDir, manifest) {
|
|
3138
|
-
|
|
3139
|
-
const entryFile = ((_a = manifest.output) == null ? void 0 : _a.entry) || "bundle-entry.js";
|
|
3180
|
+
const entryFile = manifest.output?.entry || "bundle-entry.js";
|
|
3140
3181
|
if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
|
|
3141
3182
|
const hashedPath = path.join(outputDir, entryFile);
|
|
3142
3183
|
const stablePath = path.join(outputDir, "bundle-entry.js");
|
|
@@ -3307,39 +3348,15 @@ function getBucketName3(env) {
|
|
|
3307
3348
|
}
|
|
3308
3349
|
async function streamToString2(stream) {
|
|
3309
3350
|
const chunks = [];
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
const chunk = temp.value;
|
|
3313
|
-
chunks.push(Buffer.from(chunk));
|
|
3314
|
-
}
|
|
3315
|
-
} catch (temp) {
|
|
3316
|
-
error = [temp];
|
|
3317
|
-
} finally {
|
|
3318
|
-
try {
|
|
3319
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3320
|
-
} finally {
|
|
3321
|
-
if (error)
|
|
3322
|
-
throw error[0];
|
|
3323
|
-
}
|
|
3351
|
+
for await (const chunk of stream) {
|
|
3352
|
+
chunks.push(Buffer.from(chunk));
|
|
3324
3353
|
}
|
|
3325
3354
|
return Buffer.concat(chunks).toString("utf-8");
|
|
3326
3355
|
}
|
|
3327
3356
|
async function streamToBuffer2(stream) {
|
|
3328
3357
|
const chunks = [];
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
const chunk = temp.value;
|
|
3332
|
-
chunks.push(Buffer.from(chunk));
|
|
3333
|
-
}
|
|
3334
|
-
} catch (temp) {
|
|
3335
|
-
error = [temp];
|
|
3336
|
-
} finally {
|
|
3337
|
-
try {
|
|
3338
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3339
|
-
} finally {
|
|
3340
|
-
if (error)
|
|
3341
|
-
throw error[0];
|
|
3342
|
-
}
|
|
3358
|
+
for await (const chunk of stream) {
|
|
3359
|
+
chunks.push(Buffer.from(chunk));
|
|
3343
3360
|
}
|
|
3344
3361
|
return Buffer.concat(chunks);
|
|
3345
3362
|
}
|
|
@@ -3515,6 +3532,19 @@ async function cloneCommand(themeName, options) {
|
|
|
3515
3532
|
spinner.succeed(
|
|
3516
3533
|
`Renamed theme: ${chalk4.gray(themeName)} \u2192 ${chalk4.cyan(newName)}`
|
|
3517
3534
|
);
|
|
3535
|
+
const envExamplePath = path.join(outputDir, ".env.example");
|
|
3536
|
+
if (!await fs.pathExists(envExamplePath)) {
|
|
3537
|
+
await fs.writeFile(
|
|
3538
|
+
envExamplePath,
|
|
3539
|
+
[
|
|
3540
|
+
"# API Configuration (enables real data in preview)",
|
|
3541
|
+
"# Get your Company ID from the OneX dashboard",
|
|
3542
|
+
"NEXT_PUBLIC_API_URL=https://api-dev.onexeos.com",
|
|
3543
|
+
"NEXT_PUBLIC_COMPANY_ID=",
|
|
3544
|
+
""
|
|
3545
|
+
].join("\n")
|
|
3546
|
+
);
|
|
3547
|
+
}
|
|
3518
3548
|
if (options.install !== false) {
|
|
3519
3549
|
const hasPkgJson = await fs.pathExists(
|
|
3520
3550
|
path.join(outputDir, "package.json")
|
|
@@ -3545,6 +3575,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3545
3575
|
console.log();
|
|
3546
3576
|
console.log(chalk4.cyan("Next steps:"));
|
|
3547
3577
|
console.log(chalk4.gray(` cd ${path.relative(process.cwd(), outputDir)}`));
|
|
3578
|
+
console.log(chalk4.gray(" cp .env.example .env # then add your Company ID"));
|
|
3548
3579
|
if (options.install === false) {
|
|
3549
3580
|
console.log(chalk4.gray(" pnpm install"));
|
|
3550
3581
|
}
|
|
@@ -3642,7 +3673,7 @@ function serveFile(res, filePath) {
|
|
|
3642
3673
|
const content = fs2.readFileSync(filePath);
|
|
3643
3674
|
res.writeHead(200, { "Content-Type": contentType });
|
|
3644
3675
|
res.end(content);
|
|
3645
|
-
} catch
|
|
3676
|
+
} catch {
|
|
3646
3677
|
res.writeHead(500);
|
|
3647
3678
|
res.end("Internal Server Error");
|
|
3648
3679
|
}
|
|
@@ -3703,7 +3734,7 @@ async function devCommand(options) {
|
|
|
3703
3734
|
} else {
|
|
3704
3735
|
themePath = path.join(process.cwd(), themeName);
|
|
3705
3736
|
}
|
|
3706
|
-
} catch
|
|
3737
|
+
} catch {
|
|
3707
3738
|
themePath = path.join(process.cwd(), themeName);
|
|
3708
3739
|
}
|
|
3709
3740
|
if (!fs.existsSync(themePath)) {
|
|
@@ -3789,7 +3820,7 @@ async function devCommand(options) {
|
|
|
3789
3820
|
const shimPath = path.join(outputDir, ".process-shim.js");
|
|
3790
3821
|
try {
|
|
3791
3822
|
await fs7.unlink(shimPath);
|
|
3792
|
-
} catch
|
|
3823
|
+
} catch {
|
|
3793
3824
|
}
|
|
3794
3825
|
process.exit(0);
|
|
3795
3826
|
});
|
|
@@ -3803,7 +3834,7 @@ try {
|
|
|
3803
3834
|
quiet: true
|
|
3804
3835
|
});
|
|
3805
3836
|
dotenv.config({ path: path.join(projectRoot, ".env"), quiet: true });
|
|
3806
|
-
} catch
|
|
3837
|
+
} catch {
|
|
3807
3838
|
}
|
|
3808
3839
|
dotenv.config({
|
|
3809
3840
|
path: path.join(os.homedir(), ".onex", ".env"),
|