@onexapis/cli 1.1.1 → 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/cli.js +94 -2
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +94 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +88 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -1
- package/dist/index.mjs.map +1 -1
- package/dist/preview/preview-app.tsx +91 -24
- package/package.json +4 -3
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) {
|
|
@@ -634,10 +720,11 @@ export default { motion, AnimatePresence };
|
|
|
634
720
|
});
|
|
635
721
|
return outputPath;
|
|
636
722
|
}
|
|
637
|
-
var PROCESS_SHIM, reactGlobalPlugin;
|
|
723
|
+
var import_meta, PROCESS_SHIM, reactGlobalPlugin;
|
|
638
724
|
var init_compile_theme = __esm({
|
|
639
725
|
"src/utils/compile-theme.ts"() {
|
|
640
726
|
init_logger();
|
|
727
|
+
import_meta = {};
|
|
641
728
|
PROCESS_SHIM = `
|
|
642
729
|
if (typeof process === "undefined") {
|
|
643
730
|
globalThis.process = {
|