@onexapis/cli 1.1.65 → 1.1.66
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/README.md +1 -1
- package/dist/cli.js +1098 -417
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1093 -412
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +413 -194
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +409 -190
- package/dist/index.mjs.map +1 -1
- package/dist/preview/preview-app.tsx +89 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
var chalk4 = require('chalk');
|
|
4
4
|
var ora = require('ora');
|
|
5
|
-
var
|
|
6
|
-
var path8 = require('path');
|
|
7
|
-
var fs7 = require('fs/promises');
|
|
8
|
-
var crypto = require('crypto');
|
|
5
|
+
var path10 = require('path');
|
|
9
6
|
var glob = require('glob');
|
|
7
|
+
var fs = require('fs-extra');
|
|
8
|
+
var crypto = require('crypto');
|
|
9
|
+
var esbuild = require('esbuild');
|
|
10
|
+
var fs8 = require('fs/promises');
|
|
10
11
|
var module$1 = require('module');
|
|
11
12
|
var fs3 = require('fs');
|
|
12
13
|
var child_process = require('child_process');
|
|
13
14
|
var inquirer = require('inquirer');
|
|
14
|
-
var fs = require('fs-extra');
|
|
15
15
|
var ejs = require('ejs');
|
|
16
16
|
var os = require('os');
|
|
17
17
|
var AdmZip = require('adm-zip');
|
|
@@ -39,13 +39,13 @@ function _interopNamespace(e) {
|
|
|
39
39
|
|
|
40
40
|
var chalk4__default = /*#__PURE__*/_interopDefault(chalk4);
|
|
41
41
|
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var fs7__default = /*#__PURE__*/_interopDefault(fs7);
|
|
42
|
+
var path10__default = /*#__PURE__*/_interopDefault(path10);
|
|
43
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
45
44
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
45
|
+
var esbuild__namespace = /*#__PURE__*/_interopNamespace(esbuild);
|
|
46
|
+
var fs8__default = /*#__PURE__*/_interopDefault(fs8);
|
|
46
47
|
var fs3__default = /*#__PURE__*/_interopDefault(fs3);
|
|
47
48
|
var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
|
|
48
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
49
49
|
var ejs__default = /*#__PURE__*/_interopDefault(ejs);
|
|
50
50
|
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
51
51
|
var AdmZip__default = /*#__PURE__*/_interopDefault(AdmZip);
|
|
@@ -121,6 +121,187 @@ var init_logger = __esm({
|
|
|
121
121
|
exports.logger = new exports.Logger();
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
|
+
function sortedCopy(value) {
|
|
125
|
+
if (Array.isArray(value)) {
|
|
126
|
+
return value.map((v) => sortedCopy(v));
|
|
127
|
+
}
|
|
128
|
+
if (value && typeof value === "object") {
|
|
129
|
+
const sorted = {};
|
|
130
|
+
for (const key of Object.keys(value).sort()) {
|
|
131
|
+
sorted[key] = sortedCopy(value[key]);
|
|
132
|
+
}
|
|
133
|
+
return sorted;
|
|
134
|
+
}
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
function normalizeField(raw) {
|
|
138
|
+
const out = {
|
|
139
|
+
id: String(raw.id),
|
|
140
|
+
type: String(raw.type)
|
|
141
|
+
};
|
|
142
|
+
if (raw.required === true) out.required = true;
|
|
143
|
+
if (raw.default !== void 0) out.default = raw.default;
|
|
144
|
+
if (Array.isArray(raw.aliases) && raw.aliases.length > 0) {
|
|
145
|
+
out.aliases = [...raw.aliases].map(String).sort();
|
|
146
|
+
}
|
|
147
|
+
if (typeof raw.maxLength === "number") out.maxLength = raw.maxLength;
|
|
148
|
+
if (typeof raw.min === "number") out.min = raw.min;
|
|
149
|
+
if (typeof raw.max === "number") out.max = raw.max;
|
|
150
|
+
if (typeof raw.step === "number") out.step = raw.step;
|
|
151
|
+
if (Array.isArray(raw.accept)) {
|
|
152
|
+
out.accept = [...raw.accept].map(String).sort();
|
|
153
|
+
}
|
|
154
|
+
if (Array.isArray(raw.options)) {
|
|
155
|
+
out.options = raw.options.map((o) => String(o?.value ?? o)).sort();
|
|
156
|
+
}
|
|
157
|
+
return out;
|
|
158
|
+
}
|
|
159
|
+
function normalizeBlock(raw) {
|
|
160
|
+
return {
|
|
161
|
+
type: String(raw.type),
|
|
162
|
+
settings: Array.isArray(raw.settings) ? raw.settings.map(normalizeField).sort(sortFieldsById) : [],
|
|
163
|
+
defaults: raw.defaults && typeof raw.defaults === "object" ? sortedCopy(raw.defaults) : {},
|
|
164
|
+
...typeof raw.limit === "number" ? { limit: raw.limit } : {},
|
|
165
|
+
...typeof raw.min === "number" ? { min: raw.min } : {},
|
|
166
|
+
...raw.sortable === true ? { sortable: true } : {},
|
|
167
|
+
...raw.baseType ? { baseType: String(raw.baseType) } : {}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function normalizeTemplate(raw) {
|
|
171
|
+
const out = { id: String(raw.id) };
|
|
172
|
+
if (raw.isDefault === true) out.isDefault = true;
|
|
173
|
+
if (Array.isArray(raw.settings)) {
|
|
174
|
+
out.settings = raw.settings.map(normalizeField).sort(sortFieldsById);
|
|
175
|
+
}
|
|
176
|
+
if (raw.defaults && typeof raw.defaults === "object") {
|
|
177
|
+
out.defaults = sortedCopy(raw.defaults);
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
function sortFieldsById(a, b) {
|
|
182
|
+
return a.id.localeCompare(b.id);
|
|
183
|
+
}
|
|
184
|
+
function sortByType(a, b) {
|
|
185
|
+
return a.type.localeCompare(b.type);
|
|
186
|
+
}
|
|
187
|
+
function normalizeSection(raw) {
|
|
188
|
+
return {
|
|
189
|
+
type: String(raw.type),
|
|
190
|
+
settings: Array.isArray(raw.settings) ? raw.settings.map(normalizeField).sort(sortFieldsById) : [],
|
|
191
|
+
defaults: raw.defaults && typeof raw.defaults === "object" ? sortedCopy(raw.defaults) : {},
|
|
192
|
+
blocks: Array.isArray(raw.blocks) ? raw.blocks.map(normalizeBlock).sort(sortByType) : [],
|
|
193
|
+
templates: Array.isArray(raw.templates) ? raw.templates.map(normalizeTemplate).sort(sortFieldsById) : [],
|
|
194
|
+
dataRequirements: raw.dataRequirements && typeof raw.dataRequirements === "object" ? sortedCopy(raw.dataRequirements) : null,
|
|
195
|
+
...raw.global === true ? { global: true } : {},
|
|
196
|
+
...typeof raw.maxBlocks === "number" ? { maxBlocks: raw.maxBlocks } : {}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
async function extractSchemas(themePath) {
|
|
200
|
+
const { createJiti } = await import('jiti');
|
|
201
|
+
const jiti = createJiti((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
202
|
+
const schemaFiles = await glob.glob("sections/**/*.schema.ts", { cwd: themePath });
|
|
203
|
+
const sections = {};
|
|
204
|
+
for (const file of schemaFiles) {
|
|
205
|
+
try {
|
|
206
|
+
const mod = await jiti.import(path10__default.default.join(themePath, file));
|
|
207
|
+
const exports$1 = mod;
|
|
208
|
+
for (const value of Object.values(exports$1)) {
|
|
209
|
+
if (value && typeof value === "object" && typeof value.type === "string" && Array.isArray(value.settings)) {
|
|
210
|
+
const section = normalizeSection(value);
|
|
211
|
+
sections[section.type] = section;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} catch {
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const manifest = {
|
|
218
|
+
manifestVersion: 1,
|
|
219
|
+
sections: {}
|
|
220
|
+
};
|
|
221
|
+
for (const type of Object.keys(sections).sort()) {
|
|
222
|
+
manifest.sections[type] = sections[type];
|
|
223
|
+
}
|
|
224
|
+
return manifest;
|
|
225
|
+
}
|
|
226
|
+
function serializeManifest(manifest) {
|
|
227
|
+
return JSON.stringify(sortedCopy(manifest), null, 2);
|
|
228
|
+
}
|
|
229
|
+
var init_extract_schemas = __esm({
|
|
230
|
+
"src/utils/extract-schemas.ts"() {
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
function mimeFor(filename) {
|
|
234
|
+
const ext = path10__default.default.extname(filename).toLowerCase();
|
|
235
|
+
return MIME_MAP[ext] || "application/octet-stream";
|
|
236
|
+
}
|
|
237
|
+
async function sha256Prefix(absPath, len) {
|
|
238
|
+
const buf = await fs__default.default.readFile(absPath);
|
|
239
|
+
return crypto__default.default.createHash("sha256").update(buf).digest("hex").slice(0, len);
|
|
240
|
+
}
|
|
241
|
+
function insertHashIntoName(relPath, hash) {
|
|
242
|
+
const dir = path10__default.default.posix.dirname(relPath);
|
|
243
|
+
const base = path10__default.default.posix.basename(relPath);
|
|
244
|
+
const ext = path10__default.default.posix.extname(base);
|
|
245
|
+
const stem = ext ? base.slice(0, -ext.length) : base;
|
|
246
|
+
const hashed = `${stem}-${hash}${ext}`;
|
|
247
|
+
return dir === "." ? hashed : `${dir}/${hashed}`;
|
|
248
|
+
}
|
|
249
|
+
async function scanThemeAssets(distDir) {
|
|
250
|
+
const assetsDir = path10__default.default.join(distDir, "theme-assets");
|
|
251
|
+
if (!await fs__default.default.pathExists(assetsDir)) return [];
|
|
252
|
+
const files = await glob.glob("**/*", {
|
|
253
|
+
cwd: assetsDir,
|
|
254
|
+
nodir: true,
|
|
255
|
+
dot: false
|
|
256
|
+
});
|
|
257
|
+
const results = [];
|
|
258
|
+
for (const rel of files) {
|
|
259
|
+
const absPath = path10__default.default.join(assetsDir, rel);
|
|
260
|
+
const stat = await fs__default.default.stat(absPath);
|
|
261
|
+
if (!stat.isFile()) continue;
|
|
262
|
+
const originalPath = rel.split(path10__default.default.sep).join("/");
|
|
263
|
+
const hash = await sha256Prefix(absPath, HASH_LEN);
|
|
264
|
+
const hashedPath = insertHashIntoName(originalPath, hash);
|
|
265
|
+
const contentType = mimeFor(rel);
|
|
266
|
+
results.push({
|
|
267
|
+
originalPath,
|
|
268
|
+
hashedPath,
|
|
269
|
+
hash,
|
|
270
|
+
size: stat.size,
|
|
271
|
+
contentType,
|
|
272
|
+
absPath
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
results.sort((a, b) => a.originalPath.localeCompare(b.originalPath));
|
|
276
|
+
return results;
|
|
277
|
+
}
|
|
278
|
+
var MIME_MAP, HASH_LEN;
|
|
279
|
+
var init_scan_theme_assets = __esm({
|
|
280
|
+
"src/utils/scan-theme-assets.ts"() {
|
|
281
|
+
MIME_MAP = {
|
|
282
|
+
".png": "image/png",
|
|
283
|
+
".jpg": "image/jpeg",
|
|
284
|
+
".jpeg": "image/jpeg",
|
|
285
|
+
".gif": "image/gif",
|
|
286
|
+
".webp": "image/webp",
|
|
287
|
+
".avif": "image/avif",
|
|
288
|
+
".svg": "image/svg+xml",
|
|
289
|
+
".ico": "image/x-icon",
|
|
290
|
+
".bmp": "image/bmp",
|
|
291
|
+
".woff": "font/woff",
|
|
292
|
+
".woff2": "font/woff2",
|
|
293
|
+
".ttf": "font/ttf",
|
|
294
|
+
".otf": "font/otf",
|
|
295
|
+
".eot": "application/vnd.ms-fontobject",
|
|
296
|
+
".mp4": "video/mp4",
|
|
297
|
+
".webm": "video/webm",
|
|
298
|
+
".mov": "video/quicktime",
|
|
299
|
+
".ogg": "video/ogg",
|
|
300
|
+
".json": "application/json"
|
|
301
|
+
};
|
|
302
|
+
HASH_LEN = 8;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
124
305
|
|
|
125
306
|
// src/utils/compile-theme.ts
|
|
126
307
|
var compile_theme_exports = {};
|
|
@@ -136,8 +317,8 @@ async function generateThemeCSS(themePath, outDir) {
|
|
|
136
317
|
const tailwindcss = (await import('tailwindcss')).default;
|
|
137
318
|
const tailwindConfig = {
|
|
138
319
|
content: [
|
|
139
|
-
|
|
140
|
-
|
|
320
|
+
path10__default.default.join(themePath, "sections/**/*.{ts,tsx}"),
|
|
321
|
+
path10__default.default.join(themePath, "components/**/*.{ts,tsx}")
|
|
141
322
|
],
|
|
142
323
|
theme: { extend: {} },
|
|
143
324
|
plugins: []
|
|
@@ -147,7 +328,7 @@ async function generateThemeCSS(themePath, outDir) {
|
|
|
147
328
|
inputCSS,
|
|
148
329
|
{ from: void 0 }
|
|
149
330
|
);
|
|
150
|
-
await
|
|
331
|
+
await fs8__default.default.writeFile(path10__default.default.join(outDir, "bundle.css"), result.css);
|
|
151
332
|
exports.logger.info("Generated bundle.css");
|
|
152
333
|
} catch (err) {
|
|
153
334
|
exports.logger.warning(
|
|
@@ -158,12 +339,12 @@ async function generateThemeCSS(themePath, outDir) {
|
|
|
158
339
|
async function resolveNodeModulesFile(startDir, relativePath) {
|
|
159
340
|
let dir = startDir;
|
|
160
341
|
while (true) {
|
|
161
|
-
const candidate =
|
|
342
|
+
const candidate = path10__default.default.join(dir, "node_modules", relativePath);
|
|
162
343
|
try {
|
|
163
|
-
await
|
|
344
|
+
await fs8__default.default.access(candidate);
|
|
164
345
|
return candidate;
|
|
165
346
|
} catch {
|
|
166
|
-
const parent =
|
|
347
|
+
const parent = path10__default.default.dirname(dir);
|
|
167
348
|
if (parent === dir) break;
|
|
168
349
|
dir = parent;
|
|
169
350
|
}
|
|
@@ -187,7 +368,7 @@ async function scanImportsFromPackage(sourceDir, packageName) {
|
|
|
187
368
|
});
|
|
188
369
|
for (const file of sourceFiles) {
|
|
189
370
|
try {
|
|
190
|
-
const content = await
|
|
371
|
+
const content = await fs8__default.default.readFile(path10__default.default.join(sourceDir, file), "utf-8");
|
|
191
372
|
for (const match of content.matchAll(namespaceImportRegex)) {
|
|
192
373
|
const subpath = match[1] ? match[1].slice(1) : "";
|
|
193
374
|
if (!result[subpath]) result[subpath] = /* @__PURE__ */ new Set();
|
|
@@ -241,17 +422,17 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
241
422
|
const distFileName = subpath ? `${subpath}.mjs` : "index.mjs";
|
|
242
423
|
let distPath = await resolveNodeModulesFile(
|
|
243
424
|
themePath,
|
|
244
|
-
|
|
425
|
+
path10__default.default.join("@onexapis", "core", "dist", distFileName)
|
|
245
426
|
);
|
|
246
427
|
if (!distPath) {
|
|
247
428
|
distPath = await resolveNodeModulesFile(
|
|
248
429
|
__dirname,
|
|
249
|
-
|
|
430
|
+
path10__default.default.join("@onexapis", "core", "dist", distFileName)
|
|
250
431
|
);
|
|
251
432
|
}
|
|
252
433
|
try {
|
|
253
434
|
if (!distPath) throw new Error("not found");
|
|
254
|
-
const distContent = await
|
|
435
|
+
const distContent = await fs8__default.default.readFile(distPath, "utf-8");
|
|
255
436
|
const exportMatches = distContent.matchAll(/export\s*\{([^}]+)\}/g);
|
|
256
437
|
for (const m of exportMatches) {
|
|
257
438
|
const names = m[1].split(",").map((n) => {
|
|
@@ -480,7 +661,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
480
661
|
const pages = {};
|
|
481
662
|
for (const ext of [".ts", ".js"]) {
|
|
482
663
|
try {
|
|
483
|
-
const mod = await jiti.import(
|
|
664
|
+
const mod = await jiti.import(path10__default.default.join(themePath, `theme.config${ext}`));
|
|
484
665
|
themeConfig = mod.default || mod;
|
|
485
666
|
break;
|
|
486
667
|
} catch {
|
|
@@ -488,20 +669,20 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
488
669
|
}
|
|
489
670
|
for (const ext of [".ts", ".js"]) {
|
|
490
671
|
try {
|
|
491
|
-
const mod = await jiti.import(
|
|
672
|
+
const mod = await jiti.import(path10__default.default.join(themePath, `theme.layout${ext}`));
|
|
492
673
|
layoutConfig = mod.default || mod;
|
|
493
674
|
break;
|
|
494
675
|
} catch {
|
|
495
676
|
}
|
|
496
677
|
}
|
|
497
678
|
const schemas = {};
|
|
498
|
-
const sectionsDir =
|
|
679
|
+
const sectionsDir = path10__default.default.join(themePath, "sections");
|
|
499
680
|
try {
|
|
500
|
-
const sectionDirs = await
|
|
681
|
+
const sectionDirs = await fs8__default.default.readdir(sectionsDir);
|
|
501
682
|
for (const dir of sectionDirs) {
|
|
502
|
-
const schemaFile =
|
|
683
|
+
const schemaFile = path10__default.default.join(sectionsDir, dir, `${dir}.schema.ts`);
|
|
503
684
|
try {
|
|
504
|
-
await
|
|
685
|
+
await fs8__default.default.access(schemaFile);
|
|
505
686
|
const mod = await jiti.import(schemaFile);
|
|
506
687
|
for (const [key, value] of Object.entries(mod)) {
|
|
507
688
|
if (key.endsWith("Schema") && value && typeof value === "object" && value.type) {
|
|
@@ -513,14 +694,14 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
513
694
|
}
|
|
514
695
|
} catch {
|
|
515
696
|
}
|
|
516
|
-
const pagesDir =
|
|
697
|
+
const pagesDir = path10__default.default.join(themePath, "pages");
|
|
517
698
|
try {
|
|
518
|
-
const files = await
|
|
699
|
+
const files = await fs8__default.default.readdir(pagesDir);
|
|
519
700
|
for (const file of files) {
|
|
520
701
|
if (!file.match(/\.(ts|js)$/)) continue;
|
|
521
702
|
const name = file.replace(/\.(ts|js)$/, "");
|
|
522
703
|
try {
|
|
523
|
-
const mod = await jiti.import(
|
|
704
|
+
const mod = await jiti.import(path10__default.default.join(pagesDir, file));
|
|
524
705
|
const config = mod.default || mod;
|
|
525
706
|
const sections = (config.sections || []).map((section) => {
|
|
526
707
|
const schema = schemas[section.type];
|
|
@@ -548,8 +729,8 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
548
729
|
}
|
|
549
730
|
} catch {
|
|
550
731
|
}
|
|
551
|
-
await
|
|
552
|
-
|
|
732
|
+
await fs8__default.default.writeFile(
|
|
733
|
+
path10__default.default.join(outputDir, "theme-data.json"),
|
|
553
734
|
JSON.stringify(
|
|
554
735
|
{
|
|
555
736
|
themeId,
|
|
@@ -572,22 +753,22 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
572
753
|
exports.logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
|
|
573
754
|
}
|
|
574
755
|
async function contentHashEntry(outputDir) {
|
|
575
|
-
const entryPath =
|
|
576
|
-
const mapPath =
|
|
756
|
+
const entryPath = path10__default.default.join(outputDir, "bundle-entry.js");
|
|
757
|
+
const mapPath = path10__default.default.join(outputDir, "bundle-entry.js.map");
|
|
577
758
|
let entryContent;
|
|
578
759
|
try {
|
|
579
|
-
entryContent = await
|
|
760
|
+
entryContent = await fs8__default.default.readFile(entryPath, "utf-8");
|
|
580
761
|
} catch {
|
|
581
|
-
const indexPath =
|
|
762
|
+
const indexPath = path10__default.default.join(outputDir, "index.js");
|
|
582
763
|
try {
|
|
583
|
-
entryContent = await
|
|
764
|
+
entryContent = await fs8__default.default.readFile(indexPath, "utf-8");
|
|
584
765
|
} catch {
|
|
585
766
|
exports.logger.warning("No entry file found in output, skipping content hash");
|
|
586
767
|
return;
|
|
587
768
|
}
|
|
588
769
|
const hash2 = crypto__default.default.createHash("sha256").update(entryContent).digest("hex").slice(0, 8);
|
|
589
770
|
const hashedName2 = `bundle-entry-${hash2}.js`;
|
|
590
|
-
const indexMapPath =
|
|
771
|
+
const indexMapPath = path10__default.default.join(outputDir, "index.js.map");
|
|
591
772
|
const hashedMapName2 = `bundle-entry-${hash2}.js.map`;
|
|
592
773
|
entryContent = entryContent.replace(
|
|
593
774
|
/\/\/# sourceMappingURL=index\.js\.map/,
|
|
@@ -595,18 +776,18 @@ async function contentHashEntry(outputDir) {
|
|
|
595
776
|
);
|
|
596
777
|
const oldFiles2 = await glob.glob("bundle-entry-*.js*", { cwd: outputDir });
|
|
597
778
|
for (const f of oldFiles2) {
|
|
598
|
-
await
|
|
779
|
+
await fs8__default.default.unlink(path10__default.default.join(outputDir, f));
|
|
599
780
|
}
|
|
600
|
-
await
|
|
601
|
-
await
|
|
781
|
+
await fs8__default.default.writeFile(path10__default.default.join(outputDir, hashedName2), entryContent);
|
|
782
|
+
await fs8__default.default.unlink(indexPath);
|
|
602
783
|
try {
|
|
603
|
-
await
|
|
784
|
+
await fs8__default.default.unlink(entryPath);
|
|
604
785
|
} catch {
|
|
605
786
|
}
|
|
606
|
-
await
|
|
787
|
+
await fs8__default.default.writeFile(entryPath, entryContent);
|
|
607
788
|
try {
|
|
608
|
-
await
|
|
609
|
-
await
|
|
789
|
+
await fs8__default.default.access(indexMapPath);
|
|
790
|
+
await fs8__default.default.rename(indexMapPath, path10__default.default.join(outputDir, hashedMapName2));
|
|
610
791
|
} catch {
|
|
611
792
|
}
|
|
612
793
|
exports.logger.info(`Entry hashed: ${hashedName2}`);
|
|
@@ -621,17 +802,17 @@ async function contentHashEntry(outputDir) {
|
|
|
621
802
|
);
|
|
622
803
|
const oldFiles = await glob.glob("bundle-entry-*.js*", { cwd: outputDir });
|
|
623
804
|
for (const f of oldFiles) {
|
|
624
|
-
await
|
|
805
|
+
await fs8__default.default.unlink(path10__default.default.join(outputDir, f));
|
|
625
806
|
}
|
|
626
|
-
await
|
|
807
|
+
await fs8__default.default.writeFile(path10__default.default.join(outputDir, hashedName), entryContent);
|
|
627
808
|
try {
|
|
628
|
-
await
|
|
809
|
+
await fs8__default.default.unlink(entryPath);
|
|
629
810
|
} catch {
|
|
630
811
|
}
|
|
631
|
-
await
|
|
812
|
+
await fs8__default.default.writeFile(entryPath, entryContent);
|
|
632
813
|
try {
|
|
633
|
-
await
|
|
634
|
-
await
|
|
814
|
+
await fs8__default.default.access(mapPath);
|
|
815
|
+
await fs8__default.default.rename(mapPath, path10__default.default.join(outputDir, hashedMapName));
|
|
635
816
|
} catch {
|
|
636
817
|
}
|
|
637
818
|
exports.logger.info(`Entry hashed: ${hashedName}`);
|
|
@@ -643,7 +824,7 @@ async function extractDataRequirements(themePath) {
|
|
|
643
824
|
const requirements = {};
|
|
644
825
|
for (const file of schemaFiles) {
|
|
645
826
|
try {
|
|
646
|
-
const mod = await jiti.import(
|
|
827
|
+
const mod = await jiti.import(path10__default.default.join(themePath, file));
|
|
647
828
|
const exports$1 = mod;
|
|
648
829
|
for (const value of Object.values(exports$1)) {
|
|
649
830
|
if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
|
|
@@ -658,12 +839,46 @@ async function extractDataRequirements(themePath) {
|
|
|
658
839
|
}
|
|
659
840
|
return requirements;
|
|
660
841
|
}
|
|
842
|
+
async function writeGateManifests(themePath, outputDir) {
|
|
843
|
+
try {
|
|
844
|
+
const schemas = await extractSchemas(themePath);
|
|
845
|
+
await fs8__default.default.writeFile(
|
|
846
|
+
path10__default.default.join(outputDir, "schemas.json"),
|
|
847
|
+
serializeManifest(schemas)
|
|
848
|
+
);
|
|
849
|
+
exports.logger.info(
|
|
850
|
+
`Generated schemas.json (${Object.keys(schemas.sections).length} sections)`
|
|
851
|
+
);
|
|
852
|
+
} catch (err) {
|
|
853
|
+
exports.logger.warning(
|
|
854
|
+
`schemas.json not written: ${err instanceof Error ? err.message : String(err)}`
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
try {
|
|
858
|
+
const entries = await scanThemeAssets(outputDir);
|
|
859
|
+
const assets = entries.map((e) => ({
|
|
860
|
+
path: e.originalPath,
|
|
861
|
+
hash: e.hash,
|
|
862
|
+
size: e.size,
|
|
863
|
+
contentType: e.contentType
|
|
864
|
+
}));
|
|
865
|
+
await fs8__default.default.writeFile(
|
|
866
|
+
path10__default.default.join(outputDir, "asset-manifest.json"),
|
|
867
|
+
JSON.stringify({ manifestVersion: 1, assets }, null, 2)
|
|
868
|
+
);
|
|
869
|
+
exports.logger.info(`Generated asset-manifest.json (${assets.length} assets)`);
|
|
870
|
+
} catch (err) {
|
|
871
|
+
exports.logger.warning(
|
|
872
|
+
`asset-manifest.json not written: ${err instanceof Error ? err.message : String(err)}`
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
661
876
|
async function generateManifest(themeName, themePath, outputDir) {
|
|
662
877
|
let version = "1.0.0";
|
|
663
878
|
let themeId = themeName;
|
|
664
879
|
try {
|
|
665
|
-
const pkgContent = await
|
|
666
|
-
|
|
880
|
+
const pkgContent = await fs8__default.default.readFile(
|
|
881
|
+
path10__default.default.join(themePath, "package.json"),
|
|
667
882
|
"utf-8"
|
|
668
883
|
);
|
|
669
884
|
const pkg = JSON.parse(pkgContent);
|
|
@@ -681,7 +896,7 @@ async function generateManifest(themeName, themePath, outputDir) {
|
|
|
681
896
|
const dataRequirements = await extractDataRequirements(themePath);
|
|
682
897
|
let hasThemeConfig = false;
|
|
683
898
|
try {
|
|
684
|
-
await
|
|
899
|
+
await fs8__default.default.access(path10__default.default.join(themePath, "theme.config.ts"));
|
|
685
900
|
hasThemeConfig = true;
|
|
686
901
|
} catch {
|
|
687
902
|
}
|
|
@@ -722,24 +937,24 @@ async function generateManifest(themeName, themePath, outputDir) {
|
|
|
722
937
|
// Section data requirements for server-side prefetching (keyed by section type)
|
|
723
938
|
dataRequirements
|
|
724
939
|
};
|
|
725
|
-
await
|
|
726
|
-
|
|
940
|
+
await fs8__default.default.writeFile(
|
|
941
|
+
path10__default.default.join(outputDir, "manifest.json"),
|
|
727
942
|
JSON.stringify(manifest, null, 2)
|
|
728
943
|
);
|
|
729
944
|
}
|
|
730
945
|
async function compileStandaloneTheme(themePath, themeName) {
|
|
731
|
-
const outputDir =
|
|
732
|
-
const bundleEntry =
|
|
733
|
-
const indexEntry =
|
|
946
|
+
const outputDir = path10__default.default.join(themePath, "dist");
|
|
947
|
+
const bundleEntry = path10__default.default.join(themePath, "bundle-entry.ts");
|
|
948
|
+
const indexEntry = path10__default.default.join(themePath, "index.ts");
|
|
734
949
|
let entryPoint = indexEntry;
|
|
735
950
|
try {
|
|
736
|
-
await
|
|
951
|
+
await fs8__default.default.access(bundleEntry);
|
|
737
952
|
entryPoint = bundleEntry;
|
|
738
953
|
} catch {
|
|
739
954
|
}
|
|
740
|
-
const shimPath =
|
|
741
|
-
await
|
|
742
|
-
await
|
|
955
|
+
const shimPath = path10__default.default.join(outputDir, ".process-shim.js");
|
|
956
|
+
await fs8__default.default.mkdir(outputDir, { recursive: true });
|
|
957
|
+
await fs8__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
743
958
|
const buildOptions = {
|
|
744
959
|
entryPoints: [entryPoint],
|
|
745
960
|
bundle: true,
|
|
@@ -790,19 +1005,20 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
790
1005
|
try {
|
|
791
1006
|
const result = await esbuild__namespace.build(buildOptions);
|
|
792
1007
|
try {
|
|
793
|
-
await
|
|
1008
|
+
await fs8__default.default.unlink(shimPath);
|
|
794
1009
|
} catch {
|
|
795
1010
|
}
|
|
796
1011
|
await contentHashEntry(outputDir);
|
|
797
|
-
const themeAssetsDir =
|
|
798
|
-
const distThemeAssets =
|
|
1012
|
+
const themeAssetsDir = path10__default.default.join(themePath, "assets");
|
|
1013
|
+
const distThemeAssets = path10__default.default.join(outputDir, "theme-assets");
|
|
799
1014
|
try {
|
|
800
|
-
await
|
|
801
|
-
await
|
|
1015
|
+
await fs8__default.default.access(themeAssetsDir);
|
|
1016
|
+
await fs8__default.default.cp(themeAssetsDir, distThemeAssets, { recursive: true });
|
|
802
1017
|
exports.logger.info("Copied static assets to dist/theme-assets/");
|
|
803
1018
|
} catch {
|
|
804
1019
|
}
|
|
805
1020
|
await generateManifest(themeName, themePath, outputDir);
|
|
1021
|
+
await writeGateManifests(themePath, outputDir);
|
|
806
1022
|
await generateThemeData(themePath, outputDir, themeName);
|
|
807
1023
|
await generateThemeCSS(themePath, outputDir);
|
|
808
1024
|
if (result.metafile) {
|
|
@@ -817,7 +1033,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
817
1033
|
return true;
|
|
818
1034
|
} catch (error) {
|
|
819
1035
|
try {
|
|
820
|
-
await
|
|
1036
|
+
await fs8__default.default.unlink(shimPath);
|
|
821
1037
|
} catch {
|
|
822
1038
|
}
|
|
823
1039
|
exports.logger.error(`esbuild compilation failed: ${error}`);
|
|
@@ -825,18 +1041,18 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
825
1041
|
}
|
|
826
1042
|
}
|
|
827
1043
|
async function compileStandaloneThemeDev(themePath, themeName) {
|
|
828
|
-
const outputDir =
|
|
829
|
-
const bundleEntry =
|
|
830
|
-
const indexEntry =
|
|
1044
|
+
const outputDir = path10__default.default.join(themePath, "dist");
|
|
1045
|
+
const bundleEntry = path10__default.default.join(themePath, "bundle-entry.ts");
|
|
1046
|
+
const indexEntry = path10__default.default.join(themePath, "index.ts");
|
|
831
1047
|
let entryPoint = indexEntry;
|
|
832
1048
|
try {
|
|
833
|
-
await
|
|
1049
|
+
await fs8__default.default.access(bundleEntry);
|
|
834
1050
|
entryPoint = bundleEntry;
|
|
835
1051
|
} catch {
|
|
836
1052
|
}
|
|
837
|
-
const shimPath =
|
|
838
|
-
await
|
|
839
|
-
await
|
|
1053
|
+
const shimPath = path10__default.default.join(outputDir, ".process-shim.js");
|
|
1054
|
+
await fs8__default.default.mkdir(outputDir, { recursive: true });
|
|
1055
|
+
await fs8__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
840
1056
|
const buildOptions = {
|
|
841
1057
|
entryPoints: [entryPoint],
|
|
842
1058
|
bundle: true,
|
|
@@ -890,18 +1106,18 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
890
1106
|
return { context: context2, outputDir };
|
|
891
1107
|
}
|
|
892
1108
|
async function compilePreviewRuntime(themePath) {
|
|
893
|
-
const outputDir =
|
|
894
|
-
await
|
|
895
|
-
const outputPath =
|
|
1109
|
+
const outputDir = path10__default.default.join(themePath, "dist");
|
|
1110
|
+
await fs8__default.default.mkdir(outputDir, { recursive: true });
|
|
1111
|
+
const outputPath = path10__default.default.join(outputDir, "preview-runtime.js");
|
|
896
1112
|
const locations = [
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1113
|
+
path10__default.default.join(__dirname, "..", "preview", "preview-app.tsx"),
|
|
1114
|
+
path10__default.default.join(__dirname, "preview", "preview-app.tsx"),
|
|
1115
|
+
path10__default.default.join(__dirname, "..", "..", "src", "preview", "preview-app.tsx")
|
|
900
1116
|
];
|
|
901
1117
|
let previewEntryPath = null;
|
|
902
1118
|
for (const loc of locations) {
|
|
903
1119
|
try {
|
|
904
|
-
await
|
|
1120
|
+
await fs8__default.default.access(loc);
|
|
905
1121
|
previewEntryPath = loc;
|
|
906
1122
|
break;
|
|
907
1123
|
} catch {
|
|
@@ -984,10 +1200,10 @@ ${locations.join("\n")}`
|
|
|
984
1200
|
if (!lucideScanned) {
|
|
985
1201
|
lucideScanned = true;
|
|
986
1202
|
const coreSrcCandidates = [
|
|
987
|
-
|
|
988
|
-
|
|
1203
|
+
path10__default.default.join(themePath, "node_modules", "@onexapis", "core", "src"),
|
|
1204
|
+
path10__default.default.join(themePath, "..", "..", "packages", "core", "src"),
|
|
989
1205
|
// monorepo sibling
|
|
990
|
-
|
|
1206
|
+
path10__default.default.join(
|
|
991
1207
|
__dirname,
|
|
992
1208
|
"..",
|
|
993
1209
|
"..",
|
|
@@ -1002,7 +1218,7 @@ ${locations.join("\n")}`
|
|
|
1002
1218
|
let coreSourceDir = null;
|
|
1003
1219
|
for (const candidate of coreSrcCandidates) {
|
|
1004
1220
|
try {
|
|
1005
|
-
await
|
|
1221
|
+
await fs8__default.default.access(candidate);
|
|
1006
1222
|
coreSourceDir = candidate;
|
|
1007
1223
|
break;
|
|
1008
1224
|
} catch {
|
|
@@ -1021,21 +1237,21 @@ ${locations.join("\n")}`
|
|
|
1021
1237
|
}
|
|
1022
1238
|
} else {
|
|
1023
1239
|
const coreDistCandidates = [
|
|
1024
|
-
|
|
1240
|
+
path10__default.default.join(themePath, "node_modules", "@onexapis", "core", "dist")
|
|
1025
1241
|
];
|
|
1026
1242
|
const resolvedDist = await resolveNodeModulesFile(
|
|
1027
1243
|
__dirname,
|
|
1028
|
-
|
|
1244
|
+
path10__default.default.join("@onexapis", "core", "dist")
|
|
1029
1245
|
);
|
|
1030
1246
|
if (resolvedDist) coreDistCandidates.push(resolvedDist);
|
|
1031
1247
|
for (const candidate of coreDistCandidates) {
|
|
1032
1248
|
try {
|
|
1033
|
-
await
|
|
1249
|
+
await fs8__default.default.access(candidate);
|
|
1034
1250
|
const mjsFiles = await glob.glob("*.mjs", { cwd: candidate });
|
|
1035
1251
|
const importRegex = /import\s*\{([^}]+)\}\s*from\s*["']lucide-react["']/g;
|
|
1036
1252
|
for (const file of mjsFiles) {
|
|
1037
|
-
const content = await
|
|
1038
|
-
|
|
1253
|
+
const content = await fs8__default.default.readFile(
|
|
1254
|
+
path10__default.default.join(candidate, file),
|
|
1039
1255
|
"utf-8"
|
|
1040
1256
|
);
|
|
1041
1257
|
for (const match of content.matchAll(importRegex)) {
|
|
@@ -1090,7 +1306,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
1090
1306
|
const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) || __filename);
|
|
1091
1307
|
const cjsPath = req.resolve("framer-motion");
|
|
1092
1308
|
const pkgDir = cjsPath.replace(/[/\\]dist[/\\].*$/, "");
|
|
1093
|
-
const esmEntry =
|
|
1309
|
+
const esmEntry = path10__default.default.join(pkgDir, "dist", "es", "index.mjs");
|
|
1094
1310
|
const { existsSync } = await import('fs');
|
|
1095
1311
|
if (existsSync(esmEntry)) {
|
|
1096
1312
|
return { path: esmEntry, namespace: "file" };
|
|
@@ -1189,8 +1405,8 @@ export function headers() { return new Headers(); }
|
|
|
1189
1405
|
});
|
|
1190
1406
|
}
|
|
1191
1407
|
};
|
|
1192
|
-
const shimPath =
|
|
1193
|
-
await
|
|
1408
|
+
const shimPath = path10__default.default.join(outputDir, ".process-shim-preview.js");
|
|
1409
|
+
await fs8__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
1194
1410
|
await esbuild__namespace.build({
|
|
1195
1411
|
entryPoints: [previewEntryPath],
|
|
1196
1412
|
bundle: true,
|
|
@@ -1225,7 +1441,7 @@ export function headers() { return new Headers(); }
|
|
|
1225
1441
|
}
|
|
1226
1442
|
});
|
|
1227
1443
|
try {
|
|
1228
|
-
await
|
|
1444
|
+
await fs8__default.default.unlink(shimPath);
|
|
1229
1445
|
} catch {
|
|
1230
1446
|
}
|
|
1231
1447
|
return outputPath;
|
|
@@ -1234,6 +1450,8 @@ var PROCESS_SHIM, reactGlobalPlugin, reactQueryGlobalPlugin;
|
|
|
1234
1450
|
var init_compile_theme = __esm({
|
|
1235
1451
|
"src/utils/compile-theme.ts"() {
|
|
1236
1452
|
init_logger();
|
|
1453
|
+
init_extract_schemas();
|
|
1454
|
+
init_scan_theme_assets();
|
|
1237
1455
|
PROCESS_SHIM = `
|
|
1238
1456
|
if (typeof process === "undefined") {
|
|
1239
1457
|
globalThis.process = {
|
|
@@ -1403,8 +1621,8 @@ function validateThemeName(name) {
|
|
|
1403
1621
|
return /^[a-z][a-z0-9-]*$/.test(name);
|
|
1404
1622
|
}
|
|
1405
1623
|
function pathExists(filePath) {
|
|
1406
|
-
const
|
|
1407
|
-
return
|
|
1624
|
+
const fs12 = __require("fs-extra");
|
|
1625
|
+
return fs12.existsSync(filePath);
|
|
1408
1626
|
}
|
|
1409
1627
|
function validateCategory(category) {
|
|
1410
1628
|
const validCategories = [
|
|
@@ -1445,18 +1663,18 @@ async function renderTemplate(templatePath, data) {
|
|
|
1445
1663
|
return ejs__default.default.render(template, data);
|
|
1446
1664
|
}
|
|
1447
1665
|
async function writeFile(filePath, content) {
|
|
1448
|
-
await fs__default.default.ensureDir(
|
|
1666
|
+
await fs__default.default.ensureDir(path10__default.default.dirname(filePath));
|
|
1449
1667
|
await fs__default.default.writeFile(filePath, content, "utf-8");
|
|
1450
1668
|
}
|
|
1451
1669
|
function getTemplatesDir() {
|
|
1452
1670
|
const locations = [
|
|
1453
|
-
|
|
1671
|
+
path10__default.default.join(__dirname, "../../templates"),
|
|
1454
1672
|
// Development
|
|
1455
|
-
|
|
1673
|
+
path10__default.default.join(__dirname, "../templates"),
|
|
1456
1674
|
// Production (dist/)
|
|
1457
|
-
|
|
1675
|
+
path10__default.default.join(process.cwd(), "templates"),
|
|
1458
1676
|
// Fallback
|
|
1459
|
-
|
|
1677
|
+
path10__default.default.join(process.cwd(), "packages/cli/templates")
|
|
1460
1678
|
// Monorepo
|
|
1461
1679
|
];
|
|
1462
1680
|
for (const location of locations) {
|
|
@@ -1468,7 +1686,7 @@ function getTemplatesDir() {
|
|
|
1468
1686
|
}
|
|
1469
1687
|
async function copyTemplate(templateName, targetDir, data) {
|
|
1470
1688
|
const templatesDir = getTemplatesDir();
|
|
1471
|
-
const templateDir =
|
|
1689
|
+
const templateDir = path10__default.default.join(templatesDir, templateName);
|
|
1472
1690
|
if (!fs__default.default.existsSync(templateDir)) {
|
|
1473
1691
|
throw new Error(
|
|
1474
1692
|
`Template "${templateName}" not found at ${templateDir}. Available templates: ${fs__default.default.readdirSync(templatesDir).join(", ")}`
|
|
@@ -1477,8 +1695,8 @@ async function copyTemplate(templateName, targetDir, data) {
|
|
|
1477
1695
|
await fs__default.default.ensureDir(targetDir);
|
|
1478
1696
|
const files = await fs__default.default.readdir(templateDir);
|
|
1479
1697
|
for (const file of files) {
|
|
1480
|
-
const templatePath =
|
|
1481
|
-
const targetPath =
|
|
1698
|
+
const templatePath = path10__default.default.join(templateDir, file);
|
|
1699
|
+
const targetPath = path10__default.default.join(targetDir, file);
|
|
1482
1700
|
const stat = await fs__default.default.stat(templatePath);
|
|
1483
1701
|
if (stat.isDirectory()) {
|
|
1484
1702
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -1495,8 +1713,8 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
1495
1713
|
await fs__default.default.ensureDir(targetDir);
|
|
1496
1714
|
const files = await fs__default.default.readdir(templateDir);
|
|
1497
1715
|
for (const file of files) {
|
|
1498
|
-
const templatePath =
|
|
1499
|
-
const targetPath =
|
|
1716
|
+
const templatePath = path10__default.default.join(templateDir, file);
|
|
1717
|
+
const targetPath = path10__default.default.join(targetDir, file);
|
|
1500
1718
|
const stat = await fs__default.default.stat(templatePath);
|
|
1501
1719
|
if (stat.isDirectory()) {
|
|
1502
1720
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -1511,32 +1729,32 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
1511
1729
|
}
|
|
1512
1730
|
function getProjectRoot() {
|
|
1513
1731
|
let currentDir = process.cwd();
|
|
1514
|
-
while (currentDir !==
|
|
1515
|
-
const packageJsonPath =
|
|
1732
|
+
while (currentDir !== path10__default.default.parse(currentDir).root) {
|
|
1733
|
+
const packageJsonPath = path10__default.default.join(currentDir, "package.json");
|
|
1516
1734
|
if (fs__default.default.existsSync(packageJsonPath)) {
|
|
1517
1735
|
const packageJson = fs__default.default.readJsonSync(packageJsonPath);
|
|
1518
|
-
if (packageJson.workspaces || fs__default.default.existsSync(
|
|
1736
|
+
if (packageJson.workspaces || fs__default.default.existsSync(path10__default.default.join(currentDir, "src/themes")) || fs__default.default.existsSync(path10__default.default.join(currentDir, "themes"))) {
|
|
1519
1737
|
return currentDir;
|
|
1520
1738
|
}
|
|
1521
1739
|
}
|
|
1522
|
-
currentDir =
|
|
1740
|
+
currentDir = path10__default.default.dirname(currentDir);
|
|
1523
1741
|
}
|
|
1524
1742
|
return process.cwd();
|
|
1525
1743
|
}
|
|
1526
1744
|
function getThemesDir() {
|
|
1527
1745
|
const root = getProjectRoot();
|
|
1528
|
-
if (fs__default.default.existsSync(
|
|
1529
|
-
return
|
|
1530
|
-
if (fs__default.default.existsSync(
|
|
1531
|
-
return
|
|
1532
|
-
return
|
|
1746
|
+
if (fs__default.default.existsSync(path10__default.default.join(root, "themes")))
|
|
1747
|
+
return path10__default.default.join(root, "themes");
|
|
1748
|
+
if (fs__default.default.existsSync(path10__default.default.join(root, "src/themes")))
|
|
1749
|
+
return path10__default.default.join(root, "src/themes");
|
|
1750
|
+
return path10__default.default.dirname(root);
|
|
1533
1751
|
}
|
|
1534
1752
|
function getFeaturesDir() {
|
|
1535
|
-
return
|
|
1753
|
+
return path10__default.default.join(getProjectRoot(), "src/features");
|
|
1536
1754
|
}
|
|
1537
1755
|
function isOneXProject() {
|
|
1538
1756
|
const root = getProjectRoot();
|
|
1539
|
-
return fs__default.default.existsSync(
|
|
1757
|
+
return fs__default.default.existsSync(path10__default.default.join(root, "themes")) || fs__default.default.existsSync(path10__default.default.join(root, "src/themes")) || fs__default.default.existsSync(path10__default.default.join(root, "theme.config.ts")) || fs__default.default.existsSync(path10__default.default.join(root, "bundle-entry.ts"));
|
|
1540
1758
|
}
|
|
1541
1759
|
function ensureOneXProject() {
|
|
1542
1760
|
if (!isOneXProject()) {
|
|
@@ -1552,13 +1770,13 @@ function listThemes() {
|
|
|
1552
1770
|
return [];
|
|
1553
1771
|
}
|
|
1554
1772
|
return fs__default.default.readdirSync(themesDir).filter((name) => {
|
|
1555
|
-
const themePath =
|
|
1556
|
-
return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(
|
|
1773
|
+
const themePath = path10__default.default.join(themesDir, name);
|
|
1774
|
+
return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(path10__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path10__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path10__default.default.join(themePath, "manifest.ts")));
|
|
1557
1775
|
});
|
|
1558
1776
|
}
|
|
1559
1777
|
function themeExists(themeName) {
|
|
1560
|
-
const themePath =
|
|
1561
|
-
return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(
|
|
1778
|
+
const themePath = path10__default.default.join(getThemesDir(), themeName);
|
|
1779
|
+
return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(path10__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path10__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path10__default.default.join(themePath, "manifest.ts")));
|
|
1562
1780
|
}
|
|
1563
1781
|
function detectPackageManager() {
|
|
1564
1782
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
@@ -1566,9 +1784,9 @@ function detectPackageManager() {
|
|
|
1566
1784
|
if (userAgent.includes("yarn")) return "yarn";
|
|
1567
1785
|
if (userAgent.includes("bun")) return "bun";
|
|
1568
1786
|
const cwd = process.cwd();
|
|
1569
|
-
if (fs__default.default.existsSync(
|
|
1570
|
-
if (fs__default.default.existsSync(
|
|
1571
|
-
if (fs__default.default.existsSync(
|
|
1787
|
+
if (fs__default.default.existsSync(path10__default.default.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
1788
|
+
if (fs__default.default.existsSync(path10__default.default.join(cwd, "yarn.lock"))) return "yarn";
|
|
1789
|
+
if (fs__default.default.existsSync(path10__default.default.join(cwd, "bun.lockb"))) return "bun";
|
|
1572
1790
|
return "npm";
|
|
1573
1791
|
}
|
|
1574
1792
|
async function installDependencies(projectPath, packageManager = "npm") {
|
|
@@ -1585,15 +1803,16 @@ async function installDependencies(projectPath, packageManager = "npm") {
|
|
|
1585
1803
|
}
|
|
1586
1804
|
});
|
|
1587
1805
|
}
|
|
1588
|
-
var AUTH_DIR =
|
|
1806
|
+
var AUTH_DIR = path10__default.default.join(os__default.default.homedir(), ".onexthm");
|
|
1589
1807
|
var ENV_URLS = {
|
|
1590
1808
|
dev: "https://platform-dev.onexeos.com",
|
|
1591
|
-
|
|
1809
|
+
staging: "https://platform-staging.onexeos.com",
|
|
1810
|
+
prod: "https://platform-apis.onexeos.com"
|
|
1592
1811
|
};
|
|
1593
1812
|
function getAuthFile(env = "dev") {
|
|
1594
|
-
const newFile =
|
|
1813
|
+
const newFile = path10__default.default.join(AUTH_DIR, `auth-${env}.json`);
|
|
1595
1814
|
if (env === "dev") {
|
|
1596
|
-
const legacyFile =
|
|
1815
|
+
const legacyFile = path10__default.default.join(AUTH_DIR, "auth.json");
|
|
1597
1816
|
if (fs__default.default.existsSync(legacyFile) && !fs__default.default.existsSync(newFile)) {
|
|
1598
1817
|
try {
|
|
1599
1818
|
fs__default.default.moveSync(legacyFile, newFile);
|
|
@@ -1735,7 +1954,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1735
1954
|
if (!validateThemeName(kebabName)) {
|
|
1736
1955
|
return "Invalid project name. Use lowercase letters, numbers, and hyphens only.";
|
|
1737
1956
|
}
|
|
1738
|
-
if (fs3__default.default.existsSync(
|
|
1957
|
+
if (fs3__default.default.existsSync(path10__default.default.join(process.cwd(), kebabName))) {
|
|
1739
1958
|
return `Directory "${kebabName}" already exists`;
|
|
1740
1959
|
}
|
|
1741
1960
|
return true;
|
|
@@ -1746,7 +1965,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1746
1965
|
} else {
|
|
1747
1966
|
name = toKebabCase(projectName);
|
|
1748
1967
|
}
|
|
1749
|
-
const projectPath =
|
|
1968
|
+
const projectPath = path10__default.default.join(process.cwd(), name);
|
|
1750
1969
|
if (fs3__default.default.existsSync(projectPath)) {
|
|
1751
1970
|
exports.logger.error(`Directory "${name}" already exists.`);
|
|
1752
1971
|
process.exit(1);
|
|
@@ -1862,7 +2081,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1862
2081
|
description,
|
|
1863
2082
|
author
|
|
1864
2083
|
);
|
|
1865
|
-
const mcpJsonPath =
|
|
2084
|
+
const mcpJsonPath = path10__default.default.join(projectPath, ".mcp.json");
|
|
1866
2085
|
if (fs3__default.default.existsSync(mcpJsonPath)) {
|
|
1867
2086
|
let mcpContent = fs3__default.default.readFileSync(mcpJsonPath, "utf-8");
|
|
1868
2087
|
if (figmaApiKey) {
|
|
@@ -1942,7 +2161,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1942
2161
|
}
|
|
1943
2162
|
}
|
|
1944
2163
|
async function renameThemeInFiles(projectPath, themeName, displayName, description, author) {
|
|
1945
|
-
const configPath =
|
|
2164
|
+
const configPath = path10__default.default.join(projectPath, "theme.config.ts");
|
|
1946
2165
|
if (fs3__default.default.existsSync(configPath)) {
|
|
1947
2166
|
let content = fs3__default.default.readFileSync(configPath, "utf-8");
|
|
1948
2167
|
content = content.replace(
|
|
@@ -1955,7 +2174,7 @@ async function renameThemeInFiles(projectPath, themeName, displayName, descripti
|
|
|
1955
2174
|
);
|
|
1956
2175
|
fs3__default.default.writeFileSync(configPath, content, "utf-8");
|
|
1957
2176
|
}
|
|
1958
|
-
const pkgPath =
|
|
2177
|
+
const pkgPath = path10__default.default.join(projectPath, "package.json");
|
|
1959
2178
|
if (fs3__default.default.existsSync(pkgPath)) {
|
|
1960
2179
|
let content = fs3__default.default.readFileSync(pkgPath, "utf-8");
|
|
1961
2180
|
content = content.replace(
|
|
@@ -1977,10 +2196,10 @@ async function createSectionCommand(name, options) {
|
|
|
1977
2196
|
ensureOneXProject();
|
|
1978
2197
|
if (!options.theme) {
|
|
1979
2198
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
1980
|
-
(f) => fs__default.default.existsSync(
|
|
2199
|
+
(f) => fs__default.default.existsSync(path10__default.default.join(process.cwd(), f))
|
|
1981
2200
|
);
|
|
1982
2201
|
if (isStandaloneTheme) {
|
|
1983
|
-
options.theme =
|
|
2202
|
+
options.theme = path10__default.default.basename(process.cwd());
|
|
1984
2203
|
}
|
|
1985
2204
|
}
|
|
1986
2205
|
const sectionName = toKebabCase(name);
|
|
@@ -2043,35 +2262,35 @@ async function createSectionCommand(name, options) {
|
|
|
2043
2262
|
};
|
|
2044
2263
|
exports.logger.startSpinner("Creating section files...");
|
|
2045
2264
|
try {
|
|
2046
|
-
const themePath =
|
|
2047
|
-
const sectionPath =
|
|
2265
|
+
const themePath = path10__default.default.join(getThemesDir(), themeName);
|
|
2266
|
+
const sectionPath = path10__default.default.join(themePath, "sections", sectionName);
|
|
2048
2267
|
const schemaContent = generateSectionSchema(data);
|
|
2049
2268
|
await writeFile(
|
|
2050
|
-
|
|
2269
|
+
path10__default.default.join(sectionPath, `${sectionName}.schema.ts`),
|
|
2051
2270
|
schemaContent
|
|
2052
2271
|
);
|
|
2053
2272
|
if (createTemplate) {
|
|
2054
2273
|
const templateContent = generateSectionTemplate(data);
|
|
2055
2274
|
await writeFile(
|
|
2056
|
-
|
|
2275
|
+
path10__default.default.join(sectionPath, `${sectionName}-default.tsx`),
|
|
2057
2276
|
templateContent
|
|
2058
2277
|
);
|
|
2059
2278
|
}
|
|
2060
2279
|
const indexContent = generateSectionIndex(data, createTemplate);
|
|
2061
|
-
await writeFile(
|
|
2280
|
+
await writeFile(path10__default.default.join(sectionPath, "index.ts"), indexContent);
|
|
2062
2281
|
exports.logger.stopSpinner(true, "Section files created successfully!");
|
|
2063
2282
|
exports.logger.newLine();
|
|
2064
2283
|
exports.logger.section("Next steps:");
|
|
2065
2284
|
exports.logger.log(
|
|
2066
|
-
` 1. Edit schema: ${
|
|
2285
|
+
` 1. Edit schema: ${path10__default.default.relative(process.cwd(), path10__default.default.join(sectionPath, `${sectionName}.schema.ts`))}`
|
|
2067
2286
|
);
|
|
2068
2287
|
if (createTemplate) {
|
|
2069
2288
|
exports.logger.log(
|
|
2070
|
-
` 2. Edit template: ${
|
|
2289
|
+
` 2. Edit template: ${path10__default.default.relative(process.cwd(), path10__default.default.join(sectionPath, `${sectionName}-default.tsx`))}`
|
|
2071
2290
|
);
|
|
2072
2291
|
}
|
|
2073
2292
|
exports.logger.log(
|
|
2074
|
-
` 3. Add to theme manifest: ${
|
|
2293
|
+
` 3. Add to theme manifest: ${path10__default.default.relative(process.cwd(), path10__default.default.join(themePath, "manifest.ts"))}`
|
|
2075
2294
|
);
|
|
2076
2295
|
exports.logger.newLine();
|
|
2077
2296
|
exports.logger.success("Section created successfully!");
|
|
@@ -2219,10 +2438,10 @@ async function createBlockCommand(name, options) {
|
|
|
2219
2438
|
ensureOneXProject();
|
|
2220
2439
|
if (!options.theme) {
|
|
2221
2440
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
2222
|
-
(f) => fs__default.default.existsSync(
|
|
2441
|
+
(f) => fs__default.default.existsSync(path10__default.default.join(process.cwd(), f))
|
|
2223
2442
|
);
|
|
2224
2443
|
if (isStandaloneTheme) {
|
|
2225
|
-
options.theme =
|
|
2444
|
+
options.theme = path10__default.default.basename(process.cwd());
|
|
2226
2445
|
}
|
|
2227
2446
|
}
|
|
2228
2447
|
const blockName = toKebabCase(name);
|
|
@@ -2297,24 +2516,24 @@ async function createBlockCommand(name, options) {
|
|
|
2297
2516
|
};
|
|
2298
2517
|
exports.logger.startSpinner("Creating block files...");
|
|
2299
2518
|
try {
|
|
2300
|
-
const blockPath = scope === "shared" ?
|
|
2519
|
+
const blockPath = scope === "shared" ? path10__default.default.join(getFeaturesDir(), "blocks", blockName) : path10__default.default.join(getThemesDir(), themeName, "blocks", blockName);
|
|
2301
2520
|
const schemaContent = generateBlockSchema(data);
|
|
2302
2521
|
await writeFile(
|
|
2303
|
-
|
|
2522
|
+
path10__default.default.join(blockPath, `${blockName}.schema.ts`),
|
|
2304
2523
|
schemaContent
|
|
2305
2524
|
);
|
|
2306
2525
|
const componentContent = generateBlockComponent(data);
|
|
2307
|
-
await writeFile(
|
|
2526
|
+
await writeFile(path10__default.default.join(blockPath, `${blockName}.tsx`), componentContent);
|
|
2308
2527
|
const indexContent = generateBlockIndex(data);
|
|
2309
|
-
await writeFile(
|
|
2528
|
+
await writeFile(path10__default.default.join(blockPath, "index.ts"), indexContent);
|
|
2310
2529
|
exports.logger.stopSpinner(true, "Block files created successfully!");
|
|
2311
2530
|
exports.logger.newLine();
|
|
2312
2531
|
exports.logger.section("Next steps:");
|
|
2313
2532
|
exports.logger.log(
|
|
2314
|
-
` 1. Edit schema: ${
|
|
2533
|
+
` 1. Edit schema: ${path10__default.default.relative(process.cwd(), path10__default.default.join(blockPath, `${blockName}.schema.ts`))}`
|
|
2315
2534
|
);
|
|
2316
2535
|
exports.logger.log(
|
|
2317
|
-
` 2. Edit component: ${
|
|
2536
|
+
` 2. Edit component: ${path10__default.default.relative(process.cwd(), path10__default.default.join(blockPath, `${blockName}.tsx`))}`
|
|
2318
2537
|
);
|
|
2319
2538
|
exports.logger.log(
|
|
2320
2539
|
` 3. Register in block registry: src/lib/registry/block-registry.ts`
|
|
@@ -2492,31 +2711,31 @@ async function createComponentCommand(name, options) {
|
|
|
2492
2711
|
};
|
|
2493
2712
|
exports.logger.startSpinner("Creating component files...");
|
|
2494
2713
|
try {
|
|
2495
|
-
const componentPath =
|
|
2714
|
+
const componentPath = path10__default.default.join(
|
|
2496
2715
|
getFeaturesDir(),
|
|
2497
2716
|
"components",
|
|
2498
2717
|
componentName
|
|
2499
2718
|
);
|
|
2500
2719
|
const schemaContent = generateComponentSchema(data);
|
|
2501
2720
|
await writeFile(
|
|
2502
|
-
|
|
2721
|
+
path10__default.default.join(componentPath, `${componentName}.schema.ts`),
|
|
2503
2722
|
schemaContent
|
|
2504
2723
|
);
|
|
2505
2724
|
const componentContent = generateComponent(data);
|
|
2506
2725
|
await writeFile(
|
|
2507
|
-
|
|
2726
|
+
path10__default.default.join(componentPath, `${componentName}.tsx`),
|
|
2508
2727
|
componentContent
|
|
2509
2728
|
);
|
|
2510
2729
|
const indexContent = generateComponentIndex(data);
|
|
2511
|
-
await writeFile(
|
|
2730
|
+
await writeFile(path10__default.default.join(componentPath, "index.ts"), indexContent);
|
|
2512
2731
|
exports.logger.stopSpinner(true, "Component files created successfully!");
|
|
2513
2732
|
exports.logger.newLine();
|
|
2514
2733
|
exports.logger.section("Next steps:");
|
|
2515
2734
|
exports.logger.log(
|
|
2516
|
-
` 1. Edit schema: ${
|
|
2735
|
+
` 1. Edit schema: ${path10__default.default.relative(process.cwd(), path10__default.default.join(componentPath, `${componentName}.schema.ts`))}`
|
|
2517
2736
|
);
|
|
2518
2737
|
exports.logger.log(
|
|
2519
|
-
` 2. Edit component: ${
|
|
2738
|
+
` 2. Edit component: ${path10__default.default.relative(process.cwd(), path10__default.default.join(componentPath, `${componentName}.tsx`))}`
|
|
2520
2739
|
);
|
|
2521
2740
|
exports.logger.log(
|
|
2522
2741
|
` 3. Register in component registry: src/lib/registry/component-registry.ts`
|
|
@@ -2673,13 +2892,13 @@ async function listSections(themeFilter) {
|
|
|
2673
2892
|
return;
|
|
2674
2893
|
}
|
|
2675
2894
|
for (const theme of themes) {
|
|
2676
|
-
const sectionsDir =
|
|
2895
|
+
const sectionsDir = path10__default.default.join(getThemesDir(), theme, "sections");
|
|
2677
2896
|
if (!fs__default.default.existsSync(sectionsDir)) {
|
|
2678
2897
|
continue;
|
|
2679
2898
|
}
|
|
2680
2899
|
const sections = fs__default.default.readdirSync(sectionsDir).filter((name) => {
|
|
2681
|
-
const sectionPath =
|
|
2682
|
-
return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(
|
|
2900
|
+
const sectionPath = path10__default.default.join(sectionsDir, name);
|
|
2901
|
+
return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(path10__default.default.join(sectionPath, "index.ts"));
|
|
2683
2902
|
});
|
|
2684
2903
|
if (sections.length > 0) {
|
|
2685
2904
|
exports.logger.log(chalk4__default.default.cyan(`
|
|
@@ -2693,11 +2912,11 @@ async function listSections(themeFilter) {
|
|
|
2693
2912
|
}
|
|
2694
2913
|
async function listBlocks(themeFilter) {
|
|
2695
2914
|
exports.logger.section("\u{1F9F1} Blocks");
|
|
2696
|
-
const sharedBlocksDir =
|
|
2915
|
+
const sharedBlocksDir = path10__default.default.join(getFeaturesDir(), "blocks");
|
|
2697
2916
|
if (fs__default.default.existsSync(sharedBlocksDir)) {
|
|
2698
2917
|
const sharedBlocks = fs__default.default.readdirSync(sharedBlocksDir).filter((name) => {
|
|
2699
|
-
const blockPath =
|
|
2700
|
-
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(
|
|
2918
|
+
const blockPath = path10__default.default.join(sharedBlocksDir, name);
|
|
2919
|
+
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path10__default.default.join(blockPath, "index.ts"));
|
|
2701
2920
|
});
|
|
2702
2921
|
if (sharedBlocks.length > 0) {
|
|
2703
2922
|
exports.logger.log(chalk4__default.default.cyan("\n Shared:"));
|
|
@@ -2708,13 +2927,13 @@ async function listBlocks(themeFilter) {
|
|
|
2708
2927
|
}
|
|
2709
2928
|
const themes = themeFilter ? [themeFilter] : listThemes();
|
|
2710
2929
|
for (const theme of themes) {
|
|
2711
|
-
const blocksDir =
|
|
2930
|
+
const blocksDir = path10__default.default.join(getThemesDir(), theme, "blocks");
|
|
2712
2931
|
if (!fs__default.default.existsSync(blocksDir)) {
|
|
2713
2932
|
continue;
|
|
2714
2933
|
}
|
|
2715
2934
|
const blocks = fs__default.default.readdirSync(blocksDir).filter((name) => {
|
|
2716
|
-
const blockPath =
|
|
2717
|
-
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(
|
|
2935
|
+
const blockPath = path10__default.default.join(blocksDir, name);
|
|
2936
|
+
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path10__default.default.join(blockPath, "index.ts"));
|
|
2718
2937
|
});
|
|
2719
2938
|
if (blocks.length > 0) {
|
|
2720
2939
|
exports.logger.log(chalk4__default.default.cyan(`
|
|
@@ -2728,14 +2947,14 @@ async function listBlocks(themeFilter) {
|
|
|
2728
2947
|
}
|
|
2729
2948
|
async function listComponents() {
|
|
2730
2949
|
exports.logger.section("\u2699\uFE0F Components");
|
|
2731
|
-
const componentsDir =
|
|
2950
|
+
const componentsDir = path10__default.default.join(getFeaturesDir(), "components");
|
|
2732
2951
|
if (!fs__default.default.existsSync(componentsDir)) {
|
|
2733
2952
|
exports.logger.warning("No components directory found");
|
|
2734
2953
|
return;
|
|
2735
2954
|
}
|
|
2736
2955
|
const components = fs__default.default.readdirSync(componentsDir).filter((name) => {
|
|
2737
|
-
const componentPath =
|
|
2738
|
-
return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(
|
|
2956
|
+
const componentPath = path10__default.default.join(componentsDir, name);
|
|
2957
|
+
return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(path10__default.default.join(componentPath, "index.ts"));
|
|
2739
2958
|
});
|
|
2740
2959
|
if (components.length === 0) {
|
|
2741
2960
|
exports.logger.warning("No components found");
|
|
@@ -2756,11 +2975,11 @@ async function listThemesInfo() {
|
|
|
2756
2975
|
}
|
|
2757
2976
|
exports.logger.log("");
|
|
2758
2977
|
for (const theme of themes) {
|
|
2759
|
-
const themeDir =
|
|
2978
|
+
const themeDir = path10__default.default.join(getThemesDir(), theme);
|
|
2760
2979
|
const candidates = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"];
|
|
2761
2980
|
let manifestContent = "";
|
|
2762
2981
|
for (const candidate of candidates) {
|
|
2763
|
-
const candidatePath =
|
|
2982
|
+
const candidatePath = path10__default.default.join(themeDir, candidate);
|
|
2764
2983
|
if (fs__default.default.existsSync(candidatePath)) {
|
|
2765
2984
|
manifestContent = fs__default.default.readFileSync(candidatePath, "utf-8");
|
|
2766
2985
|
break;
|
|
@@ -2789,14 +3008,14 @@ async function buildCommand(options) {
|
|
|
2789
3008
|
if (options.theme) {
|
|
2790
3009
|
themeName = options.theme;
|
|
2791
3010
|
try {
|
|
2792
|
-
const workspaceThemePath =
|
|
3011
|
+
const workspaceThemePath = path10__default.default.join(getThemesDir(), themeName);
|
|
2793
3012
|
if (fs__default.default.existsSync(workspaceThemePath)) {
|
|
2794
3013
|
themePath = workspaceThemePath;
|
|
2795
3014
|
} else {
|
|
2796
|
-
themePath =
|
|
3015
|
+
themePath = path10__default.default.join(process.cwd(), themeName);
|
|
2797
3016
|
}
|
|
2798
3017
|
} catch {
|
|
2799
|
-
themePath =
|
|
3018
|
+
themePath = path10__default.default.join(process.cwd(), themeName);
|
|
2800
3019
|
}
|
|
2801
3020
|
if (!fs__default.default.existsSync(themePath)) {
|
|
2802
3021
|
exports.logger.error(`Theme "${themeName}" not found.`);
|
|
@@ -2807,10 +3026,10 @@ async function buildCommand(options) {
|
|
|
2807
3026
|
"theme.config.ts",
|
|
2808
3027
|
"bundle-entry.ts",
|
|
2809
3028
|
"manifest.ts"
|
|
2810
|
-
].some((f) => fs__default.default.existsSync(
|
|
3029
|
+
].some((f) => fs__default.default.existsSync(path10__default.default.join(process.cwd(), f)));
|
|
2811
3030
|
if (isThemeDir) {
|
|
2812
3031
|
themePath = process.cwd();
|
|
2813
|
-
themeName =
|
|
3032
|
+
themeName = path10__default.default.basename(themePath);
|
|
2814
3033
|
exports.logger.info(`Building current theme: ${themeName}`);
|
|
2815
3034
|
} else {
|
|
2816
3035
|
exports.logger.error(
|
|
@@ -2819,7 +3038,7 @@ async function buildCommand(options) {
|
|
|
2819
3038
|
process.exit(1);
|
|
2820
3039
|
}
|
|
2821
3040
|
}
|
|
2822
|
-
const packageJsonPath =
|
|
3041
|
+
const packageJsonPath = path10__default.default.join(themePath, "package.json");
|
|
2823
3042
|
const hasPkgJson = fs__default.default.existsSync(packageJsonPath);
|
|
2824
3043
|
if (!hasPkgJson) {
|
|
2825
3044
|
exports.logger.warning(
|
|
@@ -2875,9 +3094,9 @@ async function buildCommand(options) {
|
|
|
2875
3094
|
exports.logger.success("\u2713 Theme built successfully!");
|
|
2876
3095
|
exports.logger.newLine();
|
|
2877
3096
|
exports.logger.info(`Theme: ${themeName}`);
|
|
2878
|
-
const distPath =
|
|
3097
|
+
const distPath = path10__default.default.join(themePath, "dist");
|
|
2879
3098
|
if (fs__default.default.existsSync(distPath)) {
|
|
2880
|
-
exports.logger.log(`Output: ${
|
|
3099
|
+
exports.logger.log(`Output: ${path10__default.default.relative(process.cwd(), distPath)}`);
|
|
2881
3100
|
const files = fs__default.default.readdirSync(distPath);
|
|
2882
3101
|
exports.logger.log(`Files: ${files.length}`);
|
|
2883
3102
|
}
|
|
@@ -3018,8 +3237,8 @@ async function downloadBundleZip(apiUrl, themeId, version) {
|
|
|
3018
3237
|
async function createCompatibilityFiles(outputDir, manifest) {
|
|
3019
3238
|
const entryFile = manifest.output?.entry || "bundle-entry.js";
|
|
3020
3239
|
if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
|
|
3021
|
-
const hashedPath =
|
|
3022
|
-
const stablePath =
|
|
3240
|
+
const hashedPath = path10__default.default.join(outputDir, entryFile);
|
|
3241
|
+
const stablePath = path10__default.default.join(outputDir, "bundle-entry.js");
|
|
3023
3242
|
if (await fs__default.default.pathExists(hashedPath)) {
|
|
3024
3243
|
await fs__default.default.copy(hashedPath, stablePath);
|
|
3025
3244
|
const mapPath = hashedPath + ".map";
|
|
@@ -3028,13 +3247,13 @@ async function createCompatibilityFiles(outputDir, manifest) {
|
|
|
3028
3247
|
}
|
|
3029
3248
|
}
|
|
3030
3249
|
}
|
|
3031
|
-
const sectionsRegistryPath =
|
|
3250
|
+
const sectionsRegistryPath = path10__default.default.join(outputDir, "sections-registry.js");
|
|
3032
3251
|
const content = `// Re-export all sections from bundle-entry
|
|
3033
3252
|
// This file exists to maintain compatibility with the import path
|
|
3034
3253
|
export * from './bundle-entry.js';
|
|
3035
3254
|
`;
|
|
3036
3255
|
await fs__default.default.writeFile(sectionsRegistryPath, content, "utf-8");
|
|
3037
|
-
const pkgJsonPath =
|
|
3256
|
+
const pkgJsonPath = path10__default.default.join(outputDir, "package.json");
|
|
3038
3257
|
await fs__default.default.writeFile(pkgJsonPath, '{\n "type": "module"\n}\n', "utf-8");
|
|
3039
3258
|
}
|
|
3040
3259
|
function showDownloadFailureHelp(themeId, apiUrl) {
|
|
@@ -3133,7 +3352,7 @@ async function downloadCommand(options) {
|
|
|
3133
3352
|
zip.extractAllTo(outputDir, true);
|
|
3134
3353
|
const entries = zip.getEntries().filter((e) => !e.isDirectory);
|
|
3135
3354
|
spinner.succeed(`Extracted ${entries.length} files to ${outputDir}`);
|
|
3136
|
-
const manifestPath =
|
|
3355
|
+
const manifestPath = path10__default.default.join(outputDir, "manifest.json");
|
|
3137
3356
|
const manifest = await fs__default.default.readJson(manifestPath);
|
|
3138
3357
|
await createCompatibilityFiles(outputDir, manifest);
|
|
3139
3358
|
console.log();
|
|
@@ -3254,7 +3473,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3254
3473
|
const oldPrefix = `${oldName}-`;
|
|
3255
3474
|
const newPrefix = `${newName}-`;
|
|
3256
3475
|
const newDisplayName = newName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3257
|
-
const pkgPath =
|
|
3476
|
+
const pkgPath = path10__default.default.join(themeDir, "package.json");
|
|
3258
3477
|
if (await fs__default.default.pathExists(pkgPath)) {
|
|
3259
3478
|
const pkg = await fs__default.default.readJson(pkgPath);
|
|
3260
3479
|
pkg.name = `@onex-themes/${newName}`;
|
|
@@ -3270,7 +3489,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3270
3489
|
}
|
|
3271
3490
|
await fs__default.default.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
3272
3491
|
}
|
|
3273
|
-
const configPath =
|
|
3492
|
+
const configPath = path10__default.default.join(themeDir, "theme.config.ts");
|
|
3274
3493
|
if (await fs__default.default.pathExists(configPath)) {
|
|
3275
3494
|
let content = await fs__default.default.readFile(configPath, "utf-8");
|
|
3276
3495
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -3280,7 +3499,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3280
3499
|
);
|
|
3281
3500
|
await fs__default.default.writeFile(configPath, content);
|
|
3282
3501
|
}
|
|
3283
|
-
const layoutPath =
|
|
3502
|
+
const layoutPath = path10__default.default.join(themeDir, "theme.layout.ts");
|
|
3284
3503
|
if (await fs__default.default.pathExists(layoutPath)) {
|
|
3285
3504
|
let content = await fs__default.default.readFile(layoutPath, "utf-8");
|
|
3286
3505
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -3293,7 +3512,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3293
3512
|
const oldDisplayName = oldName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3294
3513
|
const tsFiles = await glob.glob("**/*.ts", { cwd: themeDir, nodir: true });
|
|
3295
3514
|
for (const file of tsFiles) {
|
|
3296
|
-
const filePath =
|
|
3515
|
+
const filePath = path10__default.default.join(themeDir, file);
|
|
3297
3516
|
let content = await fs__default.default.readFile(filePath, "utf-8");
|
|
3298
3517
|
const original = content;
|
|
3299
3518
|
content = content.replace(
|
|
@@ -3336,7 +3555,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3336
3555
|
}
|
|
3337
3556
|
const spinner = ora__default.default("Initializing clone...").start();
|
|
3338
3557
|
try {
|
|
3339
|
-
const outputDir = options.output ||
|
|
3558
|
+
const outputDir = options.output || path10__default.default.resolve(process.cwd(), newName);
|
|
3340
3559
|
if (await fs__default.default.pathExists(outputDir)) {
|
|
3341
3560
|
spinner.fail(chalk4__default.default.red(`Directory already exists: ${outputDir}`));
|
|
3342
3561
|
exports.logger.info(
|
|
@@ -3382,7 +3601,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3382
3601
|
spinner.succeed(
|
|
3383
3602
|
`Renamed theme: ${chalk4__default.default.gray(themeName)} \u2192 ${chalk4__default.default.cyan(newName)}`
|
|
3384
3603
|
);
|
|
3385
|
-
const envExamplePath =
|
|
3604
|
+
const envExamplePath = path10__default.default.join(outputDir, ".env.example");
|
|
3386
3605
|
if (!await fs__default.default.pathExists(envExamplePath)) {
|
|
3387
3606
|
await fs__default.default.writeFile(
|
|
3388
3607
|
envExamplePath,
|
|
@@ -3395,7 +3614,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3395
3614
|
].join("\n")
|
|
3396
3615
|
);
|
|
3397
3616
|
}
|
|
3398
|
-
const mcpJsonPath =
|
|
3617
|
+
const mcpJsonPath = path10__default.default.join(outputDir, ".mcp.json");
|
|
3399
3618
|
if (await fs__default.default.pathExists(mcpJsonPath)) {
|
|
3400
3619
|
const { default: inquirerMod } = await import('inquirer');
|
|
3401
3620
|
const { figmaApiKey } = await inquirerMod.prompt([
|
|
@@ -3420,7 +3639,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3420
3639
|
}
|
|
3421
3640
|
if (options.install !== false) {
|
|
3422
3641
|
const hasPkgJson = await fs__default.default.pathExists(
|
|
3423
|
-
|
|
3642
|
+
path10__default.default.join(outputDir, "package.json")
|
|
3424
3643
|
);
|
|
3425
3644
|
if (hasPkgJson) {
|
|
3426
3645
|
spinner.start("Installing dependencies...");
|
|
@@ -3448,7 +3667,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3448
3667
|
console.log(chalk4__default.default.cyan(" Files: ") + chalk4__default.default.white(entries.length));
|
|
3449
3668
|
console.log();
|
|
3450
3669
|
console.log(chalk4__default.default.cyan("Next steps:"));
|
|
3451
|
-
console.log(chalk4__default.default.gray(` cd ${
|
|
3670
|
+
console.log(chalk4__default.default.gray(` cd ${path10__default.default.relative(process.cwd(), outputDir)}`));
|
|
3452
3671
|
console.log(
|
|
3453
3672
|
chalk4__default.default.gray(" cp .env.example .env # then add your Company ID")
|
|
3454
3673
|
);
|