@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.mjs
CHANGED
|
@@ -17,7 +17,22 @@ 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;
|
|
20
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
|
+
};
|
|
21
36
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
22
37
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
23
38
|
}) : x)(function(x) {
|
|
@@ -179,6 +194,75 @@ ${namedExportLines}
|
|
|
179
194
|
}
|
|
180
195
|
};
|
|
181
196
|
}
|
|
197
|
+
async function generateThemeData(themePath, outputDir, themeId) {
|
|
198
|
+
const { createJiti } = await import('jiti');
|
|
199
|
+
const jiti = createJiti(import_meta.url);
|
|
200
|
+
let themeConfig = null;
|
|
201
|
+
let layoutConfig = null;
|
|
202
|
+
const pages = {};
|
|
203
|
+
for (const ext of [".ts", ".js"]) {
|
|
204
|
+
try {
|
|
205
|
+
const mod = await jiti.import(path.join(themePath, `theme.config${ext}`));
|
|
206
|
+
themeConfig = mod.default || mod;
|
|
207
|
+
break;
|
|
208
|
+
} catch (e) {
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const ext of [".ts", ".js"]) {
|
|
212
|
+
try {
|
|
213
|
+
const mod = await jiti.import(path.join(themePath, `theme.layout${ext}`));
|
|
214
|
+
layoutConfig = mod.default || mod;
|
|
215
|
+
break;
|
|
216
|
+
} catch (e) {
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const pagesDir = path.join(themePath, "pages");
|
|
220
|
+
try {
|
|
221
|
+
const files = await fs6.readdir(pagesDir);
|
|
222
|
+
for (const file of files) {
|
|
223
|
+
if (!file.match(/\.(ts|js)$/)) continue;
|
|
224
|
+
const name = file.replace(/\.(ts|js)$/, "");
|
|
225
|
+
try {
|
|
226
|
+
const mod = await jiti.import(path.join(pagesDir, file));
|
|
227
|
+
const config = mod.default || mod;
|
|
228
|
+
pages[name] = {
|
|
229
|
+
id: name,
|
|
230
|
+
name: config.title || name,
|
|
231
|
+
path: config.path || `/${name}`,
|
|
232
|
+
config: __spreadValues({ id: name }, config),
|
|
233
|
+
sections: config.sections || [],
|
|
234
|
+
seo: config.seo
|
|
235
|
+
};
|
|
236
|
+
} catch (e) {
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} catch (e) {
|
|
240
|
+
}
|
|
241
|
+
await fs6.writeFile(
|
|
242
|
+
path.join(outputDir, "theme-data.json"),
|
|
243
|
+
JSON.stringify(
|
|
244
|
+
{
|
|
245
|
+
themeId,
|
|
246
|
+
theme: {
|
|
247
|
+
id: themeId,
|
|
248
|
+
name: (themeConfig == null ? void 0 : themeConfig.name) || themeId,
|
|
249
|
+
config: themeConfig,
|
|
250
|
+
layout: {
|
|
251
|
+
header: (layoutConfig == null ? void 0 : layoutConfig.headerSections) || [],
|
|
252
|
+
footer: (layoutConfig == null ? void 0 : layoutConfig.footerSections) || []
|
|
253
|
+
},
|
|
254
|
+
pages: Object.keys(pages)
|
|
255
|
+
},
|
|
256
|
+
pages
|
|
257
|
+
},
|
|
258
|
+
null,
|
|
259
|
+
2
|
|
260
|
+
)
|
|
261
|
+
);
|
|
262
|
+
logger.info(
|
|
263
|
+
`Generated theme-data.json (${Object.keys(pages).length} pages)`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
182
266
|
async function contentHashEntry(outputDir) {
|
|
183
267
|
const entryPath = path.join(outputDir, "bundle-entry.js");
|
|
184
268
|
const mapPath = path.join(outputDir, "bundle-entry.js.map");
|
|
@@ -360,6 +444,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
360
444
|
}
|
|
361
445
|
await contentHashEntry(outputDir);
|
|
362
446
|
await generateManifest2(themeName, themePath, outputDir);
|
|
447
|
+
await generateThemeData(themePath, outputDir, themeName);
|
|
363
448
|
if (result.metafile) {
|
|
364
449
|
const outputs = result.metafile.outputs;
|
|
365
450
|
let totalSize = 0;
|
|
@@ -436,6 +521,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
436
521
|
const context2 = await esbuild.context(buildOptions);
|
|
437
522
|
await context2.rebuild();
|
|
438
523
|
await generateManifest2(themeName, themePath, outputDir);
|
|
524
|
+
await generateThemeData(themePath, outputDir, themeName);
|
|
439
525
|
return { context: context2, outputDir };
|
|
440
526
|
}
|
|
441
527
|
async function compilePreviewRuntime(themePath) {
|
|
@@ -598,10 +684,11 @@ export default { motion, AnimatePresence };
|
|
|
598
684
|
});
|
|
599
685
|
return outputPath;
|
|
600
686
|
}
|
|
601
|
-
var PROCESS_SHIM, reactGlobalPlugin;
|
|
687
|
+
var import_meta, PROCESS_SHIM, reactGlobalPlugin;
|
|
602
688
|
var init_compile_theme = __esm({
|
|
603
689
|
"src/utils/compile-theme.ts"() {
|
|
604
690
|
init_logger();
|
|
691
|
+
import_meta = {};
|
|
605
692
|
PROCESS_SHIM = `
|
|
606
693
|
if (typeof process === "undefined") {
|
|
607
694
|
globalThis.process = {
|