@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/index.mjs
CHANGED
|
@@ -17,22 +17,6 @@ import AdmZip from 'adm-zip';
|
|
|
17
17
|
|
|
18
18
|
var __defProp = Object.defineProperty;
|
|
19
19
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
20
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
21
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
22
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
23
|
-
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
24
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
25
|
-
var __spreadValues = (a, b) => {
|
|
26
|
-
for (var prop in b || (b = {}))
|
|
27
|
-
if (__hasOwnProp.call(b, prop))
|
|
28
|
-
__defNormalProp(a, prop, b[prop]);
|
|
29
|
-
if (__getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
31
|
-
if (__propIsEnum.call(b, prop))
|
|
32
|
-
__defNormalProp(a, prop, b[prop]);
|
|
33
|
-
}
|
|
34
|
-
return a;
|
|
35
|
-
};
|
|
36
20
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
37
21
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
38
22
|
}) : x)(function(x) {
|
|
@@ -46,7 +30,6 @@ var __export = (target, all) => {
|
|
|
46
30
|
for (var name in all)
|
|
47
31
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
48
32
|
};
|
|
49
|
-
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);
|
|
50
33
|
var Logger, logger;
|
|
51
34
|
var init_logger = __esm({
|
|
52
35
|
"src/utils/logger.ts"() {
|
|
@@ -119,7 +102,7 @@ async function resolveNodeModulesFile(startDir, relativePath) {
|
|
|
119
102
|
try {
|
|
120
103
|
await fs6.access(candidate);
|
|
121
104
|
return candidate;
|
|
122
|
-
} catch
|
|
105
|
+
} catch {
|
|
123
106
|
const parent = path.dirname(dir);
|
|
124
107
|
if (parent === dir) break;
|
|
125
108
|
dir = parent;
|
|
@@ -138,7 +121,7 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
138
121
|
}));
|
|
139
122
|
build2.onLoad({ filter: /.*/, namespace: "core-global" }, async (args) => {
|
|
140
123
|
const match = args.path.match(/^@onexapis\/core(\/(.+))?$/);
|
|
141
|
-
const subpath =
|
|
124
|
+
const subpath = match?.[2] || "";
|
|
142
125
|
const moduleAccess = subpath ? `['${subpath}']` : "";
|
|
143
126
|
let namedExports = [];
|
|
144
127
|
const cacheKey = subpath || "__root__";
|
|
@@ -162,7 +145,7 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
162
145
|
namedExports.push(...names);
|
|
163
146
|
}
|
|
164
147
|
namedExports = [...new Set(namedExports)];
|
|
165
|
-
} catch
|
|
148
|
+
} catch {
|
|
166
149
|
}
|
|
167
150
|
exportsBySubpath[cacheKey] = namedExports;
|
|
168
151
|
}
|
|
@@ -196,7 +179,7 @@ ${namedExportLines}
|
|
|
196
179
|
}
|
|
197
180
|
async function generateThemeData(themePath, outputDir, themeId) {
|
|
198
181
|
const { createJiti } = await import('jiti');
|
|
199
|
-
const jiti = createJiti(
|
|
182
|
+
const jiti = createJiti(import.meta.url);
|
|
200
183
|
let themeConfig = null;
|
|
201
184
|
let layoutConfig = null;
|
|
202
185
|
const pages = {};
|
|
@@ -205,7 +188,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
205
188
|
const mod = await jiti.import(path.join(themePath, `theme.config${ext}`));
|
|
206
189
|
themeConfig = mod.default || mod;
|
|
207
190
|
break;
|
|
208
|
-
} catch
|
|
191
|
+
} catch {
|
|
209
192
|
}
|
|
210
193
|
}
|
|
211
194
|
for (const ext of [".ts", ".js"]) {
|
|
@@ -213,7 +196,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
213
196
|
const mod = await jiti.import(path.join(themePath, `theme.layout${ext}`));
|
|
214
197
|
layoutConfig = mod.default || mod;
|
|
215
198
|
break;
|
|
216
|
-
} catch
|
|
199
|
+
} catch {
|
|
217
200
|
}
|
|
218
201
|
}
|
|
219
202
|
const pagesDir = path.join(themePath, "pages");
|
|
@@ -229,14 +212,14 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
229
212
|
id: name,
|
|
230
213
|
name: config.title || name,
|
|
231
214
|
path: config.path || `/${name}`,
|
|
232
|
-
config:
|
|
215
|
+
config: { id: name, ...config },
|
|
233
216
|
sections: config.sections || [],
|
|
234
217
|
seo: config.seo
|
|
235
218
|
};
|
|
236
|
-
} catch
|
|
219
|
+
} catch {
|
|
237
220
|
}
|
|
238
221
|
}
|
|
239
|
-
} catch
|
|
222
|
+
} catch {
|
|
240
223
|
}
|
|
241
224
|
await fs6.writeFile(
|
|
242
225
|
path.join(outputDir, "theme-data.json"),
|
|
@@ -245,11 +228,11 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
245
228
|
themeId,
|
|
246
229
|
theme: {
|
|
247
230
|
id: themeId,
|
|
248
|
-
name:
|
|
231
|
+
name: themeConfig?.name || themeId,
|
|
249
232
|
config: themeConfig,
|
|
250
233
|
layout: {
|
|
251
|
-
header:
|
|
252
|
-
footer:
|
|
234
|
+
header: layoutConfig?.headerSections || [],
|
|
235
|
+
footer: layoutConfig?.footerSections || []
|
|
253
236
|
},
|
|
254
237
|
pages: Object.keys(pages)
|
|
255
238
|
},
|
|
@@ -259,9 +242,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
259
242
|
2
|
|
260
243
|
)
|
|
261
244
|
);
|
|
262
|
-
logger.info(
|
|
263
|
-
`Generated theme-data.json (${Object.keys(pages).length} pages)`
|
|
264
|
-
);
|
|
245
|
+
logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
|
|
265
246
|
}
|
|
266
247
|
async function contentHashEntry(outputDir) {
|
|
267
248
|
const entryPath = path.join(outputDir, "bundle-entry.js");
|
|
@@ -273,11 +254,11 @@ async function contentHashEntry(outputDir) {
|
|
|
273
254
|
let entryContent;
|
|
274
255
|
try {
|
|
275
256
|
entryContent = await fs6.readFile(entryPath, "utf-8");
|
|
276
|
-
} catch
|
|
257
|
+
} catch {
|
|
277
258
|
const indexPath = path.join(outputDir, "index.js");
|
|
278
259
|
try {
|
|
279
260
|
entryContent = await fs6.readFile(indexPath, "utf-8");
|
|
280
|
-
} catch
|
|
261
|
+
} catch {
|
|
281
262
|
logger.warning("No entry file found in output, skipping content hash");
|
|
282
263
|
return;
|
|
283
264
|
}
|
|
@@ -294,7 +275,7 @@ async function contentHashEntry(outputDir) {
|
|
|
294
275
|
try {
|
|
295
276
|
await fs6.access(indexMapPath);
|
|
296
277
|
await fs6.rename(indexMapPath, path.join(outputDir, hashedMapName2));
|
|
297
|
-
} catch
|
|
278
|
+
} catch {
|
|
298
279
|
}
|
|
299
280
|
logger.info(`Entry hashed: ${hashedName2}`);
|
|
300
281
|
return;
|
|
@@ -311,10 +292,32 @@ async function contentHashEntry(outputDir) {
|
|
|
311
292
|
try {
|
|
312
293
|
await fs6.access(mapPath);
|
|
313
294
|
await fs6.rename(mapPath, path.join(outputDir, hashedMapName));
|
|
314
|
-
} catch
|
|
295
|
+
} catch {
|
|
315
296
|
}
|
|
316
297
|
logger.info(`Entry hashed: ${hashedName}`);
|
|
317
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
|
+
}
|
|
318
321
|
async function generateManifest2(themeName, themePath, outputDir) {
|
|
319
322
|
let version = "1.0.0";
|
|
320
323
|
let themeId = themeName;
|
|
@@ -328,18 +331,19 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
328
331
|
if (pkg.name) {
|
|
329
332
|
themeId = pkg.name.replace(/^@onex-themes\//, "");
|
|
330
333
|
}
|
|
331
|
-
} catch
|
|
334
|
+
} catch {
|
|
332
335
|
}
|
|
333
336
|
const [sectionFiles, blockFiles, schemaFiles] = await Promise.all([
|
|
334
337
|
glob("sections/**/index.ts", { cwd: themePath }),
|
|
335
338
|
glob("blocks/**/index.ts", { cwd: themePath }),
|
|
336
339
|
glob("**/*.schema.ts", { cwd: themePath })
|
|
337
340
|
]);
|
|
341
|
+
const dataRequirements = await extractDataRequirements(themePath);
|
|
338
342
|
let hasThemeConfig = false;
|
|
339
343
|
try {
|
|
340
344
|
await fs6.access(path.join(themePath, "theme.config.ts"));
|
|
341
345
|
hasThemeConfig = true;
|
|
342
|
-
} catch
|
|
346
|
+
} catch {
|
|
343
347
|
}
|
|
344
348
|
const allFiles = await glob("**/*", { cwd: outputDir, nodir: true });
|
|
345
349
|
const jsFiles = allFiles.filter((f) => f.endsWith(".js"));
|
|
@@ -374,7 +378,9 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
374
378
|
blocks: blockFiles,
|
|
375
379
|
schemas: schemaFiles,
|
|
376
380
|
hasThemeConfig
|
|
377
|
-
}
|
|
381
|
+
},
|
|
382
|
+
// Section data requirements for server-side prefetching (keyed by section type)
|
|
383
|
+
dataRequirements
|
|
378
384
|
};
|
|
379
385
|
await fs6.writeFile(
|
|
380
386
|
path.join(outputDir, "manifest.json"),
|
|
@@ -389,7 +395,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
389
395
|
try {
|
|
390
396
|
await fs6.access(bundleEntry);
|
|
391
397
|
entryPoint = bundleEntry;
|
|
392
|
-
} catch
|
|
398
|
+
} catch {
|
|
393
399
|
}
|
|
394
400
|
const shimPath = path.join(outputDir, ".process-shim.js");
|
|
395
401
|
await fs6.mkdir(outputDir, { recursive: true });
|
|
@@ -440,7 +446,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
440
446
|
const result = await esbuild.build(buildOptions);
|
|
441
447
|
try {
|
|
442
448
|
await fs6.unlink(shimPath);
|
|
443
|
-
} catch
|
|
449
|
+
} catch {
|
|
444
450
|
}
|
|
445
451
|
await contentHashEntry(outputDir);
|
|
446
452
|
await generateManifest2(themeName, themePath, outputDir);
|
|
@@ -458,7 +464,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
458
464
|
} catch (error) {
|
|
459
465
|
try {
|
|
460
466
|
await fs6.unlink(shimPath);
|
|
461
|
-
} catch
|
|
467
|
+
} catch {
|
|
462
468
|
}
|
|
463
469
|
logger.error(`esbuild compilation failed: ${error}`);
|
|
464
470
|
return false;
|
|
@@ -472,7 +478,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
472
478
|
try {
|
|
473
479
|
await fs6.access(bundleEntry);
|
|
474
480
|
entryPoint = bundleEntry;
|
|
475
|
-
} catch
|
|
481
|
+
} catch {
|
|
476
482
|
}
|
|
477
483
|
const shimPath = path.join(outputDir, ".process-shim.js");
|
|
478
484
|
await fs6.mkdir(outputDir, { recursive: true });
|
|
@@ -539,7 +545,7 @@ async function compilePreviewRuntime(themePath) {
|
|
|
539
545
|
await fs6.access(loc);
|
|
540
546
|
previewEntryPath = loc;
|
|
541
547
|
break;
|
|
542
|
-
} catch
|
|
548
|
+
} catch {
|
|
543
549
|
}
|
|
544
550
|
}
|
|
545
551
|
if (!previewEntryPath) {
|
|
@@ -579,10 +585,13 @@ ${locations.join("\n")}`
|
|
|
579
585
|
"zlib"
|
|
580
586
|
];
|
|
581
587
|
for (const mod of nodeBuiltins) {
|
|
582
|
-
build2.onResolve(
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
588
|
+
build2.onResolve(
|
|
589
|
+
{ filter: new RegExp(`^${mod.replace("/", "\\/")}$`) },
|
|
590
|
+
() => ({
|
|
591
|
+
path: mod,
|
|
592
|
+
namespace: "node-stub"
|
|
593
|
+
})
|
|
594
|
+
);
|
|
586
595
|
}
|
|
587
596
|
build2.onLoad({ filter: /.*/, namespace: "node-stub" }, (args) => {
|
|
588
597
|
const stubs = {
|
|
@@ -596,8 +605,7 @@ ${locations.join("\n")}`
|
|
|
596
605
|
};
|
|
597
606
|
});
|
|
598
607
|
build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
|
|
599
|
-
|
|
600
|
-
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
608
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
601
609
|
try {
|
|
602
610
|
const result = await build2.resolve(args.path, {
|
|
603
611
|
kind: args.kind,
|
|
@@ -607,7 +615,7 @@ ${locations.join("\n")}`
|
|
|
607
615
|
pluginData: { skipStub: true }
|
|
608
616
|
});
|
|
609
617
|
if (!result.errors.length) return result;
|
|
610
|
-
} catch
|
|
618
|
+
} catch {
|
|
611
619
|
}
|
|
612
620
|
return { path: args.path, namespace: "lucide-stub" };
|
|
613
621
|
});
|
|
@@ -629,8 +637,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
629
637
|
loader: "jsx"
|
|
630
638
|
}));
|
|
631
639
|
build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
|
|
632
|
-
|
|
633
|
-
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
640
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
634
641
|
try {
|
|
635
642
|
const result = await build2.resolve(args.path, {
|
|
636
643
|
kind: args.kind,
|
|
@@ -640,7 +647,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
640
647
|
pluginData: { skipStub: true }
|
|
641
648
|
});
|
|
642
649
|
if (!result.errors.length) return result;
|
|
643
|
-
} catch
|
|
650
|
+
} catch {
|
|
644
651
|
}
|
|
645
652
|
return { path: args.path, namespace: "motion-stub" };
|
|
646
653
|
});
|
|
@@ -654,8 +661,59 @@ export default { motion, AnimatePresence };
|
|
|
654
661
|
`.trim(),
|
|
655
662
|
loader: "jsx"
|
|
656
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
|
+
});
|
|
657
713
|
}
|
|
658
714
|
};
|
|
715
|
+
const shimPath = path.join(outputDir, ".process-shim-preview.js");
|
|
716
|
+
await fs6.writeFile(shimPath, PROCESS_SHIM);
|
|
659
717
|
await esbuild.build({
|
|
660
718
|
entryPoints: [previewEntryPath],
|
|
661
719
|
bundle: true,
|
|
@@ -665,6 +723,7 @@ export default { motion, AnimatePresence };
|
|
|
665
723
|
// Bundle React + core INTO the output (NOT externalized)
|
|
666
724
|
external: [],
|
|
667
725
|
plugins: [serverStubPlugin],
|
|
726
|
+
inject: [shimPath],
|
|
668
727
|
minify: false,
|
|
669
728
|
sourcemap: true,
|
|
670
729
|
target: "es2020",
|
|
@@ -672,6 +731,12 @@ export default { motion, AnimatePresence };
|
|
|
672
731
|
jsxImportSource: "react",
|
|
673
732
|
define: {
|
|
674
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
|
+
),
|
|
675
740
|
global: "globalThis"
|
|
676
741
|
},
|
|
677
742
|
loader: { ".tsx": "tsx", ".ts": "ts" },
|
|
@@ -682,13 +747,16 @@ export default { motion, AnimatePresence };
|
|
|
682
747
|
"ignored-bare-import": "silent"
|
|
683
748
|
}
|
|
684
749
|
});
|
|
750
|
+
try {
|
|
751
|
+
await fs6.unlink(shimPath);
|
|
752
|
+
} catch {
|
|
753
|
+
}
|
|
685
754
|
return outputPath;
|
|
686
755
|
}
|
|
687
|
-
var
|
|
756
|
+
var PROCESS_SHIM, reactGlobalPlugin;
|
|
688
757
|
var init_compile_theme = __esm({
|
|
689
758
|
"src/utils/compile-theme.ts"() {
|
|
690
759
|
init_logger();
|
|
691
|
-
import_meta = {};
|
|
692
760
|
PROCESS_SHIM = `
|
|
693
761
|
if (typeof process === "undefined") {
|
|
694
762
|
globalThis.process = {
|
|
@@ -1143,7 +1211,7 @@ Add your theme-specific blocks here.
|
|
|
1143
1211
|
stdio: "ignore"
|
|
1144
1212
|
});
|
|
1145
1213
|
logger.stopSpinner(true, "Git repository initialized!");
|
|
1146
|
-
} catch
|
|
1214
|
+
} catch {
|
|
1147
1215
|
logger.stopSpinner(false, "Failed to initialize git");
|
|
1148
1216
|
}
|
|
1149
1217
|
}
|
|
@@ -1154,7 +1222,7 @@ Add your theme-specific blocks here.
|
|
|
1154
1222
|
try {
|
|
1155
1223
|
await installDependencies(projectPath, packageManager);
|
|
1156
1224
|
logger.stopSpinner(true, "Dependencies installed!");
|
|
1157
|
-
} catch
|
|
1225
|
+
} catch {
|
|
1158
1226
|
logger.stopSpinner(false, "Failed to install dependencies");
|
|
1159
1227
|
logger.info(
|
|
1160
1228
|
"You can install dependencies manually by running: cd " + name + " && npm install"
|
|
@@ -2236,7 +2304,6 @@ async function listThemesInfo() {
|
|
|
2236
2304
|
// src/commands/build.ts
|
|
2237
2305
|
init_logger();
|
|
2238
2306
|
async function buildCommand(options) {
|
|
2239
|
-
var _a;
|
|
2240
2307
|
logger.header("Build Theme");
|
|
2241
2308
|
let themePath;
|
|
2242
2309
|
let themeName;
|
|
@@ -2249,7 +2316,7 @@ async function buildCommand(options) {
|
|
|
2249
2316
|
} else {
|
|
2250
2317
|
themePath = path.join(process.cwd(), themeName);
|
|
2251
2318
|
}
|
|
2252
|
-
} catch
|
|
2319
|
+
} catch {
|
|
2253
2320
|
themePath = path.join(process.cwd(), themeName);
|
|
2254
2321
|
}
|
|
2255
2322
|
if (!fs.existsSync(themePath)) {
|
|
@@ -2306,7 +2373,7 @@ async function buildCommand(options) {
|
|
|
2306
2373
|
}
|
|
2307
2374
|
logger.stopSpinner(true, "Lint passed");
|
|
2308
2375
|
const pkgJson = fs.readJsonSync(packageJsonPath);
|
|
2309
|
-
const buildScript =
|
|
2376
|
+
const buildScript = pkgJson.scripts?.build || "";
|
|
2310
2377
|
const isRecursive = buildScript.includes("onex build") || buildScript.includes("onex-cli build");
|
|
2311
2378
|
logger.startSpinner(
|
|
2312
2379
|
options.watch ? "Building (watch mode)..." : "Building..."
|
|
@@ -2414,7 +2481,6 @@ async function findCompiledThemeDir(themeId, version) {
|
|
|
2414
2481
|
return null;
|
|
2415
2482
|
}
|
|
2416
2483
|
async function readManifest() {
|
|
2417
|
-
var _a;
|
|
2418
2484
|
const manifestTsPath = path.resolve(process.cwd(), "manifest.ts");
|
|
2419
2485
|
if (await fs.pathExists(manifestTsPath)) {
|
|
2420
2486
|
try {
|
|
@@ -2428,7 +2494,7 @@ async function readManifest() {
|
|
|
2428
2494
|
if (await fs.pathExists(packageJsonPath)) {
|
|
2429
2495
|
const pkg = await fs.readJson(packageJsonPath);
|
|
2430
2496
|
return {
|
|
2431
|
-
themeId:
|
|
2497
|
+
themeId: pkg.name?.replace("@onex-themes/", "") || "unknown",
|
|
2432
2498
|
version: pkg.version || "1.0.0"
|
|
2433
2499
|
};
|
|
2434
2500
|
}
|
|
@@ -2672,39 +2738,15 @@ function getBucketName2(env) {
|
|
|
2672
2738
|
}
|
|
2673
2739
|
async function streamToString(stream) {
|
|
2674
2740
|
const chunks = [];
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
const chunk = temp.value;
|
|
2678
|
-
chunks.push(Buffer.from(chunk));
|
|
2679
|
-
}
|
|
2680
|
-
} catch (temp) {
|
|
2681
|
-
error = [temp];
|
|
2682
|
-
} finally {
|
|
2683
|
-
try {
|
|
2684
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
2685
|
-
} finally {
|
|
2686
|
-
if (error)
|
|
2687
|
-
throw error[0];
|
|
2688
|
-
}
|
|
2741
|
+
for await (const chunk of stream) {
|
|
2742
|
+
chunks.push(Buffer.from(chunk));
|
|
2689
2743
|
}
|
|
2690
2744
|
return Buffer.concat(chunks).toString("utf-8");
|
|
2691
2745
|
}
|
|
2692
2746
|
async function streamToBuffer(stream) {
|
|
2693
2747
|
const chunks = [];
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
const chunk = temp.value;
|
|
2697
|
-
chunks.push(Buffer.from(chunk));
|
|
2698
|
-
}
|
|
2699
|
-
} catch (temp) {
|
|
2700
|
-
error = [temp];
|
|
2701
|
-
} finally {
|
|
2702
|
-
try {
|
|
2703
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
2704
|
-
} finally {
|
|
2705
|
-
if (error)
|
|
2706
|
-
throw error[0];
|
|
2707
|
-
}
|
|
2748
|
+
for await (const chunk of stream) {
|
|
2749
|
+
chunks.push(Buffer.from(chunk));
|
|
2708
2750
|
}
|
|
2709
2751
|
return Buffer.concat(chunks);
|
|
2710
2752
|
}
|
|
@@ -2726,8 +2768,7 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
|
|
|
2726
2768
|
}
|
|
2727
2769
|
}
|
|
2728
2770
|
async function createCompatibilityFiles(outputDir, manifest) {
|
|
2729
|
-
|
|
2730
|
-
const entryFile = ((_a = manifest.output) == null ? void 0 : _a.entry) || "bundle-entry.js";
|
|
2771
|
+
const entryFile = manifest.output?.entry || "bundle-entry.js";
|
|
2731
2772
|
if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
|
|
2732
2773
|
const hashedPath = path.join(outputDir, entryFile);
|
|
2733
2774
|
const stablePath = path.join(outputDir, "bundle-entry.js");
|
|
@@ -2898,39 +2939,15 @@ function getBucketName3(env) {
|
|
|
2898
2939
|
}
|
|
2899
2940
|
async function streamToString2(stream) {
|
|
2900
2941
|
const chunks = [];
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
const chunk = temp.value;
|
|
2904
|
-
chunks.push(Buffer.from(chunk));
|
|
2905
|
-
}
|
|
2906
|
-
} catch (temp) {
|
|
2907
|
-
error = [temp];
|
|
2908
|
-
} finally {
|
|
2909
|
-
try {
|
|
2910
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
2911
|
-
} finally {
|
|
2912
|
-
if (error)
|
|
2913
|
-
throw error[0];
|
|
2914
|
-
}
|
|
2942
|
+
for await (const chunk of stream) {
|
|
2943
|
+
chunks.push(Buffer.from(chunk));
|
|
2915
2944
|
}
|
|
2916
2945
|
return Buffer.concat(chunks).toString("utf-8");
|
|
2917
2946
|
}
|
|
2918
2947
|
async function streamToBuffer2(stream) {
|
|
2919
2948
|
const chunks = [];
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
const chunk = temp.value;
|
|
2923
|
-
chunks.push(Buffer.from(chunk));
|
|
2924
|
-
}
|
|
2925
|
-
} catch (temp) {
|
|
2926
|
-
error = [temp];
|
|
2927
|
-
} finally {
|
|
2928
|
-
try {
|
|
2929
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
2930
|
-
} finally {
|
|
2931
|
-
if (error)
|
|
2932
|
-
throw error[0];
|
|
2933
|
-
}
|
|
2949
|
+
for await (const chunk of stream) {
|
|
2950
|
+
chunks.push(Buffer.from(chunk));
|
|
2934
2951
|
}
|
|
2935
2952
|
return Buffer.concat(chunks);
|
|
2936
2953
|
}
|
|
@@ -3106,6 +3123,19 @@ async function cloneCommand(themeName, options) {
|
|
|
3106
3123
|
spinner.succeed(
|
|
3107
3124
|
`Renamed theme: ${chalk4.gray(themeName)} \u2192 ${chalk4.cyan(newName)}`
|
|
3108
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
|
+
}
|
|
3109
3139
|
if (options.install !== false) {
|
|
3110
3140
|
const hasPkgJson = await fs.pathExists(
|
|
3111
3141
|
path.join(outputDir, "package.json")
|
|
@@ -3136,6 +3166,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3136
3166
|
console.log();
|
|
3137
3167
|
console.log(chalk4.cyan("Next steps:"));
|
|
3138
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"));
|
|
3139
3170
|
if (options.install === false) {
|
|
3140
3171
|
console.log(chalk4.gray(" pnpm install"));
|
|
3141
3172
|
}
|