@onexapis/cli 1.1.3 → 1.1.5
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 +201 -192
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +200 -191
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +157 -148
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +156 -147
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var chalk4 = require('chalk');
|
|
5
5
|
var ora = require('ora');
|
|
6
6
|
var esbuild = require('esbuild');
|
|
7
|
-
var
|
|
7
|
+
var path8 = require('path');
|
|
8
8
|
var fs7 = require('fs/promises');
|
|
9
9
|
var crypto = require('crypto');
|
|
10
10
|
var glob = require('glob');
|
|
@@ -49,7 +49,7 @@ function _interopNamespace(e) {
|
|
|
49
49
|
var chalk4__default = /*#__PURE__*/_interopDefault(chalk4);
|
|
50
50
|
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
51
51
|
var esbuild__namespace = /*#__PURE__*/_interopNamespace(esbuild);
|
|
52
|
-
var
|
|
52
|
+
var path8__default = /*#__PURE__*/_interopDefault(path8);
|
|
53
53
|
var fs7__default = /*#__PURE__*/_interopDefault(fs7);
|
|
54
54
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
55
55
|
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
@@ -142,12 +142,12 @@ __export(compile_theme_exports, {
|
|
|
142
142
|
async function resolveNodeModulesFile(startDir, relativePath) {
|
|
143
143
|
let dir = startDir;
|
|
144
144
|
while (true) {
|
|
145
|
-
const candidate =
|
|
145
|
+
const candidate = path8__default.default.join(dir, "node_modules", relativePath);
|
|
146
146
|
try {
|
|
147
147
|
await fs7__default.default.access(candidate);
|
|
148
148
|
return candidate;
|
|
149
149
|
} catch {
|
|
150
|
-
const parent =
|
|
150
|
+
const parent = path8__default.default.dirname(dir);
|
|
151
151
|
if (parent === dir) break;
|
|
152
152
|
dir = parent;
|
|
153
153
|
}
|
|
@@ -173,10 +173,16 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
173
173
|
namedExports = exportsBySubpath[cacheKey];
|
|
174
174
|
} else {
|
|
175
175
|
const distFileName = subpath ? `${subpath}.mjs` : "index.mjs";
|
|
176
|
-
|
|
176
|
+
let distPath = await resolveNodeModulesFile(
|
|
177
177
|
themePath,
|
|
178
|
-
|
|
178
|
+
path8__default.default.join("@onexapis", "core", "dist", distFileName)
|
|
179
179
|
);
|
|
180
|
+
if (!distPath) {
|
|
181
|
+
distPath = await resolveNodeModulesFile(
|
|
182
|
+
__dirname,
|
|
183
|
+
path8__default.default.join("@onexapis", "core", "dist", distFileName)
|
|
184
|
+
);
|
|
185
|
+
}
|
|
180
186
|
try {
|
|
181
187
|
if (!distPath) throw new Error("not found");
|
|
182
188
|
const distContent = await fs7__default.default.readFile(distPath, "utf-8");
|
|
@@ -229,7 +235,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
229
235
|
const pages = {};
|
|
230
236
|
for (const ext of [".ts", ".js"]) {
|
|
231
237
|
try {
|
|
232
|
-
const mod = await jiti.import(
|
|
238
|
+
const mod = await jiti.import(path8__default.default.join(themePath, `theme.config${ext}`));
|
|
233
239
|
themeConfig = mod.default || mod;
|
|
234
240
|
break;
|
|
235
241
|
} catch {
|
|
@@ -237,20 +243,20 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
237
243
|
}
|
|
238
244
|
for (const ext of [".ts", ".js"]) {
|
|
239
245
|
try {
|
|
240
|
-
const mod = await jiti.import(
|
|
246
|
+
const mod = await jiti.import(path8__default.default.join(themePath, `theme.layout${ext}`));
|
|
241
247
|
layoutConfig = mod.default || mod;
|
|
242
248
|
break;
|
|
243
249
|
} catch {
|
|
244
250
|
}
|
|
245
251
|
}
|
|
246
|
-
const pagesDir =
|
|
252
|
+
const pagesDir = path8__default.default.join(themePath, "pages");
|
|
247
253
|
try {
|
|
248
254
|
const files = await fs7__default.default.readdir(pagesDir);
|
|
249
255
|
for (const file of files) {
|
|
250
256
|
if (!file.match(/\.(ts|js)$/)) continue;
|
|
251
257
|
const name = file.replace(/\.(ts|js)$/, "");
|
|
252
258
|
try {
|
|
253
|
-
const mod = await jiti.import(
|
|
259
|
+
const mod = await jiti.import(path8__default.default.join(pagesDir, file));
|
|
254
260
|
const config = mod.default || mod;
|
|
255
261
|
pages[name] = {
|
|
256
262
|
id: name,
|
|
@@ -266,7 +272,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
266
272
|
} catch {
|
|
267
273
|
}
|
|
268
274
|
await fs7__default.default.writeFile(
|
|
269
|
-
|
|
275
|
+
path8__default.default.join(outputDir, "theme-data.json"),
|
|
270
276
|
JSON.stringify(
|
|
271
277
|
{
|
|
272
278
|
themeId,
|
|
@@ -289,17 +295,17 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
289
295
|
logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
|
|
290
296
|
}
|
|
291
297
|
async function contentHashEntry(outputDir) {
|
|
292
|
-
const entryPath =
|
|
293
|
-
const mapPath =
|
|
298
|
+
const entryPath = path8__default.default.join(outputDir, "bundle-entry.js");
|
|
299
|
+
const mapPath = path8__default.default.join(outputDir, "bundle-entry.js.map");
|
|
294
300
|
const oldFiles = await glob.glob("bundle-entry-*.js*", { cwd: outputDir });
|
|
295
301
|
for (const f of oldFiles) {
|
|
296
|
-
await fs7__default.default.unlink(
|
|
302
|
+
await fs7__default.default.unlink(path8__default.default.join(outputDir, f));
|
|
297
303
|
}
|
|
298
304
|
let entryContent;
|
|
299
305
|
try {
|
|
300
306
|
entryContent = await fs7__default.default.readFile(entryPath, "utf-8");
|
|
301
307
|
} catch {
|
|
302
|
-
const indexPath =
|
|
308
|
+
const indexPath = path8__default.default.join(outputDir, "index.js");
|
|
303
309
|
try {
|
|
304
310
|
entryContent = await fs7__default.default.readFile(indexPath, "utf-8");
|
|
305
311
|
} catch {
|
|
@@ -308,17 +314,17 @@ async function contentHashEntry(outputDir) {
|
|
|
308
314
|
}
|
|
309
315
|
const hash2 = crypto__default.default.createHash("sha256").update(entryContent).digest("hex").slice(0, 8);
|
|
310
316
|
const hashedName2 = `bundle-entry-${hash2}.js`;
|
|
311
|
-
const indexMapPath =
|
|
317
|
+
const indexMapPath = path8__default.default.join(outputDir, "index.js.map");
|
|
312
318
|
const hashedMapName2 = `bundle-entry-${hash2}.js.map`;
|
|
313
319
|
entryContent = entryContent.replace(
|
|
314
320
|
/\/\/# sourceMappingURL=index\.js\.map/,
|
|
315
321
|
`//# sourceMappingURL=${hashedMapName2}`
|
|
316
322
|
);
|
|
317
|
-
await fs7__default.default.writeFile(
|
|
323
|
+
await fs7__default.default.writeFile(path8__default.default.join(outputDir, hashedName2), entryContent);
|
|
318
324
|
await fs7__default.default.unlink(indexPath);
|
|
319
325
|
try {
|
|
320
326
|
await fs7__default.default.access(indexMapPath);
|
|
321
|
-
await fs7__default.default.rename(indexMapPath,
|
|
327
|
+
await fs7__default.default.rename(indexMapPath, path8__default.default.join(outputDir, hashedMapName2));
|
|
322
328
|
} catch {
|
|
323
329
|
}
|
|
324
330
|
logger.info(`Entry hashed: ${hashedName2}`);
|
|
@@ -331,11 +337,11 @@ async function contentHashEntry(outputDir) {
|
|
|
331
337
|
/\/\/# sourceMappingURL=bundle-entry\.js\.map/,
|
|
332
338
|
`//# sourceMappingURL=${hashedMapName}`
|
|
333
339
|
);
|
|
334
|
-
await fs7__default.default.writeFile(
|
|
340
|
+
await fs7__default.default.writeFile(path8__default.default.join(outputDir, hashedName), entryContent);
|
|
335
341
|
await fs7__default.default.unlink(entryPath);
|
|
336
342
|
try {
|
|
337
343
|
await fs7__default.default.access(mapPath);
|
|
338
|
-
await fs7__default.default.rename(mapPath,
|
|
344
|
+
await fs7__default.default.rename(mapPath, path8__default.default.join(outputDir, hashedMapName));
|
|
339
345
|
} catch {
|
|
340
346
|
}
|
|
341
347
|
logger.info(`Entry hashed: ${hashedName}`);
|
|
@@ -347,7 +353,7 @@ async function extractDataRequirements(themePath) {
|
|
|
347
353
|
const requirements = {};
|
|
348
354
|
for (const file of schemaFiles) {
|
|
349
355
|
try {
|
|
350
|
-
const mod = await jiti.import(
|
|
356
|
+
const mod = await jiti.import(path8__default.default.join(themePath, file));
|
|
351
357
|
const exports$1 = mod;
|
|
352
358
|
for (const value of Object.values(exports$1)) {
|
|
353
359
|
if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
|
|
@@ -367,7 +373,7 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
367
373
|
let themeId = themeName;
|
|
368
374
|
try {
|
|
369
375
|
const pkgContent = await fs7__default.default.readFile(
|
|
370
|
-
|
|
376
|
+
path8__default.default.join(themePath, "package.json"),
|
|
371
377
|
"utf-8"
|
|
372
378
|
);
|
|
373
379
|
const pkg = JSON.parse(pkgContent);
|
|
@@ -385,7 +391,7 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
385
391
|
const dataRequirements = await extractDataRequirements(themePath);
|
|
386
392
|
let hasThemeConfig = false;
|
|
387
393
|
try {
|
|
388
|
-
await fs7__default.default.access(
|
|
394
|
+
await fs7__default.default.access(path8__default.default.join(themePath, "theme.config.ts"));
|
|
389
395
|
hasThemeConfig = true;
|
|
390
396
|
} catch {
|
|
391
397
|
}
|
|
@@ -427,21 +433,21 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
427
433
|
dataRequirements
|
|
428
434
|
};
|
|
429
435
|
await fs7__default.default.writeFile(
|
|
430
|
-
|
|
436
|
+
path8__default.default.join(outputDir, "manifest.json"),
|
|
431
437
|
JSON.stringify(manifest, null, 2)
|
|
432
438
|
);
|
|
433
439
|
}
|
|
434
440
|
async function compileStandaloneTheme(themePath, themeName) {
|
|
435
|
-
const outputDir =
|
|
436
|
-
const bundleEntry =
|
|
437
|
-
const indexEntry =
|
|
441
|
+
const outputDir = path8__default.default.join(themePath, "dist");
|
|
442
|
+
const bundleEntry = path8__default.default.join(themePath, "bundle-entry.ts");
|
|
443
|
+
const indexEntry = path8__default.default.join(themePath, "index.ts");
|
|
438
444
|
let entryPoint = indexEntry;
|
|
439
445
|
try {
|
|
440
446
|
await fs7__default.default.access(bundleEntry);
|
|
441
447
|
entryPoint = bundleEntry;
|
|
442
448
|
} catch {
|
|
443
449
|
}
|
|
444
|
-
const shimPath =
|
|
450
|
+
const shimPath = path8__default.default.join(outputDir, ".process-shim.js");
|
|
445
451
|
await fs7__default.default.mkdir(outputDir, { recursive: true });
|
|
446
452
|
await fs7__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
447
453
|
const buildOptions = {
|
|
@@ -515,16 +521,16 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
515
521
|
}
|
|
516
522
|
}
|
|
517
523
|
async function compileStandaloneThemeDev(themePath, themeName) {
|
|
518
|
-
const outputDir =
|
|
519
|
-
const bundleEntry =
|
|
520
|
-
const indexEntry =
|
|
524
|
+
const outputDir = path8__default.default.join(themePath, "dist");
|
|
525
|
+
const bundleEntry = path8__default.default.join(themePath, "bundle-entry.ts");
|
|
526
|
+
const indexEntry = path8__default.default.join(themePath, "index.ts");
|
|
521
527
|
let entryPoint = indexEntry;
|
|
522
528
|
try {
|
|
523
529
|
await fs7__default.default.access(bundleEntry);
|
|
524
530
|
entryPoint = bundleEntry;
|
|
525
531
|
} catch {
|
|
526
532
|
}
|
|
527
|
-
const shimPath =
|
|
533
|
+
const shimPath = path8__default.default.join(outputDir, ".process-shim.js");
|
|
528
534
|
await fs7__default.default.mkdir(outputDir, { recursive: true });
|
|
529
535
|
await fs7__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
530
536
|
const buildOptions = {
|
|
@@ -575,13 +581,13 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
575
581
|
return { context: context2, outputDir };
|
|
576
582
|
}
|
|
577
583
|
async function compilePreviewRuntime(themePath) {
|
|
578
|
-
const outputDir =
|
|
584
|
+
const outputDir = path8__default.default.join(themePath, "dist");
|
|
579
585
|
await fs7__default.default.mkdir(outputDir, { recursive: true });
|
|
580
|
-
const outputPath =
|
|
586
|
+
const outputPath = path8__default.default.join(outputDir, "preview-runtime.js");
|
|
581
587
|
const locations = [
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
588
|
+
path8__default.default.join(__dirname, "..", "preview", "preview-app.tsx"),
|
|
589
|
+
path8__default.default.join(__dirname, "preview", "preview-app.tsx"),
|
|
590
|
+
path8__default.default.join(__dirname, "..", "..", "src", "preview", "preview-app.tsx")
|
|
585
591
|
];
|
|
586
592
|
let previewEntryPath = null;
|
|
587
593
|
for (const loc of locations) {
|
|
@@ -756,7 +762,7 @@ export function headers() { return new Headers(); }
|
|
|
756
762
|
});
|
|
757
763
|
}
|
|
758
764
|
};
|
|
759
|
-
const shimPath =
|
|
765
|
+
const shimPath = path8__default.default.join(outputDir, ".process-shim-preview.js");
|
|
760
766
|
await fs7__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
761
767
|
await esbuild__namespace.build({
|
|
762
768
|
entryPoints: [previewEntryPath],
|
|
@@ -925,18 +931,18 @@ async function renderTemplate(templatePath, data) {
|
|
|
925
931
|
return ejs__default.default.render(template, data);
|
|
926
932
|
}
|
|
927
933
|
async function writeFile(filePath, content) {
|
|
928
|
-
await fs__default.default.ensureDir(
|
|
934
|
+
await fs__default.default.ensureDir(path8__default.default.dirname(filePath));
|
|
929
935
|
await fs__default.default.writeFile(filePath, content, "utf-8");
|
|
930
936
|
}
|
|
931
937
|
function getTemplatesDir() {
|
|
932
938
|
const locations = [
|
|
933
|
-
|
|
939
|
+
path8__default.default.join(__dirname, "../../templates"),
|
|
934
940
|
// Development
|
|
935
|
-
|
|
941
|
+
path8__default.default.join(__dirname, "../templates"),
|
|
936
942
|
// Production (dist/)
|
|
937
|
-
|
|
943
|
+
path8__default.default.join(process.cwd(), "templates"),
|
|
938
944
|
// Fallback
|
|
939
|
-
|
|
945
|
+
path8__default.default.join(process.cwd(), "packages/cli/templates")
|
|
940
946
|
// Monorepo
|
|
941
947
|
];
|
|
942
948
|
for (const location of locations) {
|
|
@@ -948,7 +954,7 @@ function getTemplatesDir() {
|
|
|
948
954
|
}
|
|
949
955
|
async function copyTemplate(templateName, targetDir, data) {
|
|
950
956
|
const templatesDir = getTemplatesDir();
|
|
951
|
-
const templateDir =
|
|
957
|
+
const templateDir = path8__default.default.join(templatesDir, templateName);
|
|
952
958
|
if (!fs__default.default.existsSync(templateDir)) {
|
|
953
959
|
throw new Error(
|
|
954
960
|
`Template "${templateName}" not found at ${templateDir}. Available templates: ${fs__default.default.readdirSync(templatesDir).join(", ")}`
|
|
@@ -957,8 +963,8 @@ async function copyTemplate(templateName, targetDir, data) {
|
|
|
957
963
|
await fs__default.default.ensureDir(targetDir);
|
|
958
964
|
const files = await fs__default.default.readdir(templateDir);
|
|
959
965
|
for (const file of files) {
|
|
960
|
-
const templatePath =
|
|
961
|
-
const targetPath =
|
|
966
|
+
const templatePath = path8__default.default.join(templateDir, file);
|
|
967
|
+
const targetPath = path8__default.default.join(targetDir, file);
|
|
962
968
|
const stat = await fs__default.default.stat(templatePath);
|
|
963
969
|
if (stat.isDirectory()) {
|
|
964
970
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -975,8 +981,8 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
975
981
|
await fs__default.default.ensureDir(targetDir);
|
|
976
982
|
const files = await fs__default.default.readdir(templateDir);
|
|
977
983
|
for (const file of files) {
|
|
978
|
-
const templatePath =
|
|
979
|
-
const targetPath =
|
|
984
|
+
const templatePath = path8__default.default.join(templateDir, file);
|
|
985
|
+
const targetPath = path8__default.default.join(targetDir, file);
|
|
980
986
|
const stat = await fs__default.default.stat(templatePath);
|
|
981
987
|
if (stat.isDirectory()) {
|
|
982
988
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -991,32 +997,32 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
991
997
|
}
|
|
992
998
|
function getProjectRoot() {
|
|
993
999
|
let currentDir = process.cwd();
|
|
994
|
-
while (currentDir !==
|
|
995
|
-
const packageJsonPath =
|
|
1000
|
+
while (currentDir !== path8__default.default.parse(currentDir).root) {
|
|
1001
|
+
const packageJsonPath = path8__default.default.join(currentDir, "package.json");
|
|
996
1002
|
if (fs__default.default.existsSync(packageJsonPath)) {
|
|
997
1003
|
const packageJson = fs__default.default.readJsonSync(packageJsonPath);
|
|
998
|
-
if (packageJson.workspaces || fs__default.default.existsSync(
|
|
1004
|
+
if (packageJson.workspaces || fs__default.default.existsSync(path8__default.default.join(currentDir, "src/themes")) || fs__default.default.existsSync(path8__default.default.join(currentDir, "themes"))) {
|
|
999
1005
|
return currentDir;
|
|
1000
1006
|
}
|
|
1001
1007
|
}
|
|
1002
|
-
currentDir =
|
|
1008
|
+
currentDir = path8__default.default.dirname(currentDir);
|
|
1003
1009
|
}
|
|
1004
1010
|
return process.cwd();
|
|
1005
1011
|
}
|
|
1006
1012
|
function getThemesDir() {
|
|
1007
1013
|
const root = getProjectRoot();
|
|
1008
|
-
if (fs__default.default.existsSync(
|
|
1009
|
-
return
|
|
1010
|
-
if (fs__default.default.existsSync(
|
|
1011
|
-
return
|
|
1012
|
-
return
|
|
1014
|
+
if (fs__default.default.existsSync(path8__default.default.join(root, "themes")))
|
|
1015
|
+
return path8__default.default.join(root, "themes");
|
|
1016
|
+
if (fs__default.default.existsSync(path8__default.default.join(root, "src/themes")))
|
|
1017
|
+
return path8__default.default.join(root, "src/themes");
|
|
1018
|
+
return path8__default.default.dirname(root);
|
|
1013
1019
|
}
|
|
1014
1020
|
function getFeaturesDir() {
|
|
1015
|
-
return
|
|
1021
|
+
return path8__default.default.join(getProjectRoot(), "src/features");
|
|
1016
1022
|
}
|
|
1017
1023
|
function isOneXProject() {
|
|
1018
1024
|
const root = getProjectRoot();
|
|
1019
|
-
return fs__default.default.existsSync(
|
|
1025
|
+
return fs__default.default.existsSync(path8__default.default.join(root, "themes")) || fs__default.default.existsSync(path8__default.default.join(root, "src/themes")) || fs__default.default.existsSync(path8__default.default.join(root, "theme.config.ts")) || fs__default.default.existsSync(path8__default.default.join(root, "bundle-entry.ts"));
|
|
1020
1026
|
}
|
|
1021
1027
|
function ensureOneXProject() {
|
|
1022
1028
|
if (!isOneXProject()) {
|
|
@@ -1032,13 +1038,13 @@ function listThemes() {
|
|
|
1032
1038
|
return [];
|
|
1033
1039
|
}
|
|
1034
1040
|
return fs__default.default.readdirSync(themesDir).filter((name) => {
|
|
1035
|
-
const themePath =
|
|
1036
|
-
return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(
|
|
1041
|
+
const themePath = path8__default.default.join(themesDir, name);
|
|
1042
|
+
return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(path8__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path8__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path8__default.default.join(themePath, "manifest.ts")));
|
|
1037
1043
|
});
|
|
1038
1044
|
}
|
|
1039
1045
|
function themeExists(themeName) {
|
|
1040
|
-
const themePath =
|
|
1041
|
-
return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(
|
|
1046
|
+
const themePath = path8__default.default.join(getThemesDir(), themeName);
|
|
1047
|
+
return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(path8__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path8__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path8__default.default.join(themePath, "manifest.ts")));
|
|
1042
1048
|
}
|
|
1043
1049
|
function detectPackageManager() {
|
|
1044
1050
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
@@ -1046,9 +1052,9 @@ function detectPackageManager() {
|
|
|
1046
1052
|
if (userAgent.includes("yarn")) return "yarn";
|
|
1047
1053
|
if (userAgent.includes("bun")) return "bun";
|
|
1048
1054
|
const cwd = process.cwd();
|
|
1049
|
-
if (fs__default.default.existsSync(
|
|
1050
|
-
if (fs__default.default.existsSync(
|
|
1051
|
-
if (fs__default.default.existsSync(
|
|
1055
|
+
if (fs__default.default.existsSync(path8__default.default.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
1056
|
+
if (fs__default.default.existsSync(path8__default.default.join(cwd, "yarn.lock"))) return "yarn";
|
|
1057
|
+
if (fs__default.default.existsSync(path8__default.default.join(cwd, "bun.lockb"))) return "bun";
|
|
1052
1058
|
return "npm";
|
|
1053
1059
|
}
|
|
1054
1060
|
async function installDependencies(projectPath, packageManager = "npm") {
|
|
@@ -1114,7 +1120,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1114
1120
|
if (!validateThemeName(kebabName)) {
|
|
1115
1121
|
return "Invalid project name. Use lowercase letters, numbers, and hyphens only.";
|
|
1116
1122
|
}
|
|
1117
|
-
if (fs2__default.default.existsSync(
|
|
1123
|
+
if (fs2__default.default.existsSync(path8__default.default.join(process.cwd(), kebabName))) {
|
|
1118
1124
|
return `Directory "${kebabName}" already exists`;
|
|
1119
1125
|
}
|
|
1120
1126
|
return true;
|
|
@@ -1125,7 +1131,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1125
1131
|
} else {
|
|
1126
1132
|
name = toKebabCase(projectName);
|
|
1127
1133
|
}
|
|
1128
|
-
const projectPath =
|
|
1134
|
+
const projectPath = path8__default.default.join(process.cwd(), name);
|
|
1129
1135
|
if (fs2__default.default.existsSync(projectPath)) {
|
|
1130
1136
|
logger.error(`Directory "${name}" already exists.`);
|
|
1131
1137
|
process.exit(1);
|
|
@@ -1188,38 +1194,38 @@ async function initCommand(projectName, options = {}) {
|
|
|
1188
1194
|
try {
|
|
1189
1195
|
fs2__default.default.mkdirSync(projectPath, { recursive: true });
|
|
1190
1196
|
await copyTemplate(template, projectPath, data);
|
|
1191
|
-
const srcPath =
|
|
1197
|
+
const srcPath = path8__default.default.join(projectPath, "src");
|
|
1192
1198
|
fs2__default.default.mkdirSync(srcPath, { recursive: true });
|
|
1193
1199
|
const manifestContent = generateManifest(data);
|
|
1194
|
-
await writeFile(
|
|
1200
|
+
await writeFile(path8__default.default.join(srcPath, "manifest.ts"), manifestContent);
|
|
1195
1201
|
const configContent = generateThemeConfig(data);
|
|
1196
|
-
await writeFile(
|
|
1202
|
+
await writeFile(path8__default.default.join(srcPath, "config.ts"), configContent);
|
|
1197
1203
|
const layoutContent = generateThemeLayout(data);
|
|
1198
|
-
await writeFile(
|
|
1204
|
+
await writeFile(path8__default.default.join(srcPath, "layout.ts"), layoutContent);
|
|
1199
1205
|
const indexContent = generateThemeIndex(data);
|
|
1200
|
-
await writeFile(
|
|
1201
|
-
const sectionsPath =
|
|
1206
|
+
await writeFile(path8__default.default.join(srcPath, "index.ts"), indexContent);
|
|
1207
|
+
const sectionsPath = path8__default.default.join(srcPath, "sections");
|
|
1202
1208
|
fs2__default.default.mkdirSync(sectionsPath, { recursive: true });
|
|
1203
1209
|
await writeFile(
|
|
1204
|
-
|
|
1210
|
+
path8__default.default.join(sectionsPath, "README.md"),
|
|
1205
1211
|
`# ${displayName} Sections
|
|
1206
1212
|
|
|
1207
1213
|
Add your theme-specific sections here.
|
|
1208
1214
|
`
|
|
1209
1215
|
);
|
|
1210
|
-
const blocksPath =
|
|
1216
|
+
const blocksPath = path8__default.default.join(srcPath, "blocks");
|
|
1211
1217
|
fs2__default.default.mkdirSync(blocksPath, { recursive: true });
|
|
1212
1218
|
await writeFile(
|
|
1213
|
-
|
|
1219
|
+
path8__default.default.join(blocksPath, "README.md"),
|
|
1214
1220
|
`# ${displayName} Blocks
|
|
1215
1221
|
|
|
1216
1222
|
Add your theme-specific blocks here.
|
|
1217
1223
|
`
|
|
1218
1224
|
);
|
|
1219
|
-
const pagesPath =
|
|
1225
|
+
const pagesPath = path8__default.default.join(srcPath, "pages");
|
|
1220
1226
|
fs2__default.default.mkdirSync(pagesPath, { recursive: true });
|
|
1221
1227
|
const homePageContent = generateHomePage(data);
|
|
1222
|
-
await writeFile(
|
|
1228
|
+
await writeFile(path8__default.default.join(pagesPath, "home.ts"), homePageContent);
|
|
1223
1229
|
logger.stopSpinner(true, "Project structure created!");
|
|
1224
1230
|
if (options.git) {
|
|
1225
1231
|
logger.startSpinner("Initializing git repository...");
|
|
@@ -1518,10 +1524,10 @@ async function createSectionCommand(name, options) {
|
|
|
1518
1524
|
ensureOneXProject();
|
|
1519
1525
|
if (!options.theme) {
|
|
1520
1526
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
1521
|
-
(f) => fs__default.default.existsSync(
|
|
1527
|
+
(f) => fs__default.default.existsSync(path8__default.default.join(process.cwd(), f))
|
|
1522
1528
|
);
|
|
1523
1529
|
if (isStandaloneTheme) {
|
|
1524
|
-
options.theme =
|
|
1530
|
+
options.theme = path8__default.default.basename(process.cwd());
|
|
1525
1531
|
}
|
|
1526
1532
|
}
|
|
1527
1533
|
const sectionName = toKebabCase(name);
|
|
@@ -1584,35 +1590,35 @@ async function createSectionCommand(name, options) {
|
|
|
1584
1590
|
};
|
|
1585
1591
|
logger.startSpinner("Creating section files...");
|
|
1586
1592
|
try {
|
|
1587
|
-
const themePath =
|
|
1588
|
-
const sectionPath =
|
|
1593
|
+
const themePath = path8__default.default.join(getThemesDir(), themeName);
|
|
1594
|
+
const sectionPath = path8__default.default.join(themePath, "sections", sectionName);
|
|
1589
1595
|
const schemaContent = generateSectionSchema(data);
|
|
1590
1596
|
await writeFile(
|
|
1591
|
-
|
|
1597
|
+
path8__default.default.join(sectionPath, `${sectionName}.schema.ts`),
|
|
1592
1598
|
schemaContent
|
|
1593
1599
|
);
|
|
1594
1600
|
if (createTemplate) {
|
|
1595
1601
|
const templateContent = generateSectionTemplate(data);
|
|
1596
1602
|
await writeFile(
|
|
1597
|
-
|
|
1603
|
+
path8__default.default.join(sectionPath, `${sectionName}-default.tsx`),
|
|
1598
1604
|
templateContent
|
|
1599
1605
|
);
|
|
1600
1606
|
}
|
|
1601
1607
|
const indexContent = generateSectionIndex(data, createTemplate);
|
|
1602
|
-
await writeFile(
|
|
1608
|
+
await writeFile(path8__default.default.join(sectionPath, "index.ts"), indexContent);
|
|
1603
1609
|
logger.stopSpinner(true, "Section files created successfully!");
|
|
1604
1610
|
logger.newLine();
|
|
1605
1611
|
logger.section("Next steps:");
|
|
1606
1612
|
logger.log(
|
|
1607
|
-
` 1. Edit schema: ${
|
|
1613
|
+
` 1. Edit schema: ${path8__default.default.relative(process.cwd(), path8__default.default.join(sectionPath, `${sectionName}.schema.ts`))}`
|
|
1608
1614
|
);
|
|
1609
1615
|
if (createTemplate) {
|
|
1610
1616
|
logger.log(
|
|
1611
|
-
` 2. Edit template: ${
|
|
1617
|
+
` 2. Edit template: ${path8__default.default.relative(process.cwd(), path8__default.default.join(sectionPath, `${sectionName}-default.tsx`))}`
|
|
1612
1618
|
);
|
|
1613
1619
|
}
|
|
1614
1620
|
logger.log(
|
|
1615
|
-
` 3. Add to theme manifest: ${
|
|
1621
|
+
` 3. Add to theme manifest: ${path8__default.default.relative(process.cwd(), path8__default.default.join(themePath, "manifest.ts"))}`
|
|
1616
1622
|
);
|
|
1617
1623
|
logger.newLine();
|
|
1618
1624
|
logger.success("Section created successfully!");
|
|
@@ -1760,10 +1766,10 @@ async function createBlockCommand(name, options) {
|
|
|
1760
1766
|
ensureOneXProject();
|
|
1761
1767
|
if (!options.theme) {
|
|
1762
1768
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
1763
|
-
(f) => fs__default.default.existsSync(
|
|
1769
|
+
(f) => fs__default.default.existsSync(path8__default.default.join(process.cwd(), f))
|
|
1764
1770
|
);
|
|
1765
1771
|
if (isStandaloneTheme) {
|
|
1766
|
-
options.theme =
|
|
1772
|
+
options.theme = path8__default.default.basename(process.cwd());
|
|
1767
1773
|
}
|
|
1768
1774
|
}
|
|
1769
1775
|
const blockName = toKebabCase(name);
|
|
@@ -1838,24 +1844,24 @@ async function createBlockCommand(name, options) {
|
|
|
1838
1844
|
};
|
|
1839
1845
|
logger.startSpinner("Creating block files...");
|
|
1840
1846
|
try {
|
|
1841
|
-
const blockPath = scope === "shared" ?
|
|
1847
|
+
const blockPath = scope === "shared" ? path8__default.default.join(getFeaturesDir(), "blocks", blockName) : path8__default.default.join(getThemesDir(), themeName, "blocks", blockName);
|
|
1842
1848
|
const schemaContent = generateBlockSchema(data);
|
|
1843
1849
|
await writeFile(
|
|
1844
|
-
|
|
1850
|
+
path8__default.default.join(blockPath, `${blockName}.schema.ts`),
|
|
1845
1851
|
schemaContent
|
|
1846
1852
|
);
|
|
1847
1853
|
const componentContent = generateBlockComponent(data);
|
|
1848
|
-
await writeFile(
|
|
1854
|
+
await writeFile(path8__default.default.join(blockPath, `${blockName}.tsx`), componentContent);
|
|
1849
1855
|
const indexContent = generateBlockIndex(data);
|
|
1850
|
-
await writeFile(
|
|
1856
|
+
await writeFile(path8__default.default.join(blockPath, "index.ts"), indexContent);
|
|
1851
1857
|
logger.stopSpinner(true, "Block files created successfully!");
|
|
1852
1858
|
logger.newLine();
|
|
1853
1859
|
logger.section("Next steps:");
|
|
1854
1860
|
logger.log(
|
|
1855
|
-
` 1. Edit schema: ${
|
|
1861
|
+
` 1. Edit schema: ${path8__default.default.relative(process.cwd(), path8__default.default.join(blockPath, `${blockName}.schema.ts`))}`
|
|
1856
1862
|
);
|
|
1857
1863
|
logger.log(
|
|
1858
|
-
` 2. Edit component: ${
|
|
1864
|
+
` 2. Edit component: ${path8__default.default.relative(process.cwd(), path8__default.default.join(blockPath, `${blockName}.tsx`))}`
|
|
1859
1865
|
);
|
|
1860
1866
|
logger.log(
|
|
1861
1867
|
` 3. Register in block registry: src/lib/registry/block-registry.ts`
|
|
@@ -2033,31 +2039,31 @@ async function createComponentCommand(name, options) {
|
|
|
2033
2039
|
};
|
|
2034
2040
|
logger.startSpinner("Creating component files...");
|
|
2035
2041
|
try {
|
|
2036
|
-
const componentPath =
|
|
2042
|
+
const componentPath = path8__default.default.join(
|
|
2037
2043
|
getFeaturesDir(),
|
|
2038
2044
|
"components",
|
|
2039
2045
|
componentName
|
|
2040
2046
|
);
|
|
2041
2047
|
const schemaContent = generateComponentSchema(data);
|
|
2042
2048
|
await writeFile(
|
|
2043
|
-
|
|
2049
|
+
path8__default.default.join(componentPath, `${componentName}.schema.ts`),
|
|
2044
2050
|
schemaContent
|
|
2045
2051
|
);
|
|
2046
2052
|
const componentContent = generateComponent(data);
|
|
2047
2053
|
await writeFile(
|
|
2048
|
-
|
|
2054
|
+
path8__default.default.join(componentPath, `${componentName}.tsx`),
|
|
2049
2055
|
componentContent
|
|
2050
2056
|
);
|
|
2051
2057
|
const indexContent = generateComponentIndex(data);
|
|
2052
|
-
await writeFile(
|
|
2058
|
+
await writeFile(path8__default.default.join(componentPath, "index.ts"), indexContent);
|
|
2053
2059
|
logger.stopSpinner(true, "Component files created successfully!");
|
|
2054
2060
|
logger.newLine();
|
|
2055
2061
|
logger.section("Next steps:");
|
|
2056
2062
|
logger.log(
|
|
2057
|
-
` 1. Edit schema: ${
|
|
2063
|
+
` 1. Edit schema: ${path8__default.default.relative(process.cwd(), path8__default.default.join(componentPath, `${componentName}.schema.ts`))}`
|
|
2058
2064
|
);
|
|
2059
2065
|
logger.log(
|
|
2060
|
-
` 2. Edit component: ${
|
|
2066
|
+
` 2. Edit component: ${path8__default.default.relative(process.cwd(), path8__default.default.join(componentPath, `${componentName}.tsx`))}`
|
|
2061
2067
|
);
|
|
2062
2068
|
logger.log(
|
|
2063
2069
|
` 3. Register in component registry: src/lib/registry/component-registry.ts`
|
|
@@ -2214,13 +2220,13 @@ async function listSections(themeFilter) {
|
|
|
2214
2220
|
return;
|
|
2215
2221
|
}
|
|
2216
2222
|
for (const theme of themes) {
|
|
2217
|
-
const sectionsDir =
|
|
2223
|
+
const sectionsDir = path8__default.default.join(getThemesDir(), theme, "sections");
|
|
2218
2224
|
if (!fs__default.default.existsSync(sectionsDir)) {
|
|
2219
2225
|
continue;
|
|
2220
2226
|
}
|
|
2221
2227
|
const sections = fs__default.default.readdirSync(sectionsDir).filter((name) => {
|
|
2222
|
-
const sectionPath =
|
|
2223
|
-
return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(
|
|
2228
|
+
const sectionPath = path8__default.default.join(sectionsDir, name);
|
|
2229
|
+
return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(path8__default.default.join(sectionPath, "index.ts"));
|
|
2224
2230
|
});
|
|
2225
2231
|
if (sections.length > 0) {
|
|
2226
2232
|
logger.log(chalk4__default.default.cyan(`
|
|
@@ -2234,11 +2240,11 @@ async function listSections(themeFilter) {
|
|
|
2234
2240
|
}
|
|
2235
2241
|
async function listBlocks(themeFilter) {
|
|
2236
2242
|
logger.section("\u{1F9F1} Blocks");
|
|
2237
|
-
const sharedBlocksDir =
|
|
2243
|
+
const sharedBlocksDir = path8__default.default.join(getFeaturesDir(), "blocks");
|
|
2238
2244
|
if (fs__default.default.existsSync(sharedBlocksDir)) {
|
|
2239
2245
|
const sharedBlocks = fs__default.default.readdirSync(sharedBlocksDir).filter((name) => {
|
|
2240
|
-
const blockPath =
|
|
2241
|
-
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(
|
|
2246
|
+
const blockPath = path8__default.default.join(sharedBlocksDir, name);
|
|
2247
|
+
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path8__default.default.join(blockPath, "index.ts"));
|
|
2242
2248
|
});
|
|
2243
2249
|
if (sharedBlocks.length > 0) {
|
|
2244
2250
|
logger.log(chalk4__default.default.cyan("\n Shared:"));
|
|
@@ -2249,13 +2255,13 @@ async function listBlocks(themeFilter) {
|
|
|
2249
2255
|
}
|
|
2250
2256
|
const themes = themeFilter ? [themeFilter] : listThemes();
|
|
2251
2257
|
for (const theme of themes) {
|
|
2252
|
-
const blocksDir =
|
|
2258
|
+
const blocksDir = path8__default.default.join(getThemesDir(), theme, "blocks");
|
|
2253
2259
|
if (!fs__default.default.existsSync(blocksDir)) {
|
|
2254
2260
|
continue;
|
|
2255
2261
|
}
|
|
2256
2262
|
const blocks = fs__default.default.readdirSync(blocksDir).filter((name) => {
|
|
2257
|
-
const blockPath =
|
|
2258
|
-
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(
|
|
2263
|
+
const blockPath = path8__default.default.join(blocksDir, name);
|
|
2264
|
+
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path8__default.default.join(blockPath, "index.ts"));
|
|
2259
2265
|
});
|
|
2260
2266
|
if (blocks.length > 0) {
|
|
2261
2267
|
logger.log(chalk4__default.default.cyan(`
|
|
@@ -2269,14 +2275,14 @@ async function listBlocks(themeFilter) {
|
|
|
2269
2275
|
}
|
|
2270
2276
|
async function listComponents() {
|
|
2271
2277
|
logger.section("\u2699\uFE0F Components");
|
|
2272
|
-
const componentsDir =
|
|
2278
|
+
const componentsDir = path8__default.default.join(getFeaturesDir(), "components");
|
|
2273
2279
|
if (!fs__default.default.existsSync(componentsDir)) {
|
|
2274
2280
|
logger.warning("No components directory found");
|
|
2275
2281
|
return;
|
|
2276
2282
|
}
|
|
2277
2283
|
const components = fs__default.default.readdirSync(componentsDir).filter((name) => {
|
|
2278
|
-
const componentPath =
|
|
2279
|
-
return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(
|
|
2284
|
+
const componentPath = path8__default.default.join(componentsDir, name);
|
|
2285
|
+
return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(path8__default.default.join(componentPath, "index.ts"));
|
|
2280
2286
|
});
|
|
2281
2287
|
if (components.length === 0) {
|
|
2282
2288
|
logger.warning("No components found");
|
|
@@ -2297,11 +2303,11 @@ async function listThemesInfo() {
|
|
|
2297
2303
|
}
|
|
2298
2304
|
logger.log("");
|
|
2299
2305
|
for (const theme of themes) {
|
|
2300
|
-
const themeDir =
|
|
2306
|
+
const themeDir = path8__default.default.join(getThemesDir(), theme);
|
|
2301
2307
|
const candidates = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"];
|
|
2302
2308
|
let manifestContent = "";
|
|
2303
2309
|
for (const candidate of candidates) {
|
|
2304
|
-
const candidatePath =
|
|
2310
|
+
const candidatePath = path8__default.default.join(themeDir, candidate);
|
|
2305
2311
|
if (fs__default.default.existsSync(candidatePath)) {
|
|
2306
2312
|
manifestContent = fs__default.default.readFileSync(candidatePath, "utf-8");
|
|
2307
2313
|
break;
|
|
@@ -2339,9 +2345,9 @@ async function validateCommand(options) {
|
|
|
2339
2345
|
"theme.config.ts",
|
|
2340
2346
|
"bundle-entry.ts",
|
|
2341
2347
|
"manifest.ts"
|
|
2342
|
-
].some((f) => fs__default.default.existsSync(
|
|
2348
|
+
].some((f) => fs__default.default.existsSync(path8__default.default.join(process.cwd(), f)));
|
|
2343
2349
|
if (isThemeDir) {
|
|
2344
|
-
themeToValidate =
|
|
2350
|
+
themeToValidate = path8__default.default.basename(process.cwd());
|
|
2345
2351
|
logger.info(`Validating current theme: ${themeToValidate}`);
|
|
2346
2352
|
} else {
|
|
2347
2353
|
logger.error(
|
|
@@ -2350,11 +2356,11 @@ async function validateCommand(options) {
|
|
|
2350
2356
|
process.exit(1);
|
|
2351
2357
|
}
|
|
2352
2358
|
}
|
|
2353
|
-
const themePath =
|
|
2359
|
+
const themePath = path8__default.default.join(getThemesDir(), themeToValidate);
|
|
2354
2360
|
logger.startSpinner("Running validation checks...");
|
|
2355
2361
|
const entryFiles = ["manifest.ts", "theme.config.ts", "bundle-entry.ts"];
|
|
2356
2362
|
const foundEntry = entryFiles.find(
|
|
2357
|
-
(f) => fs__default.default.existsSync(
|
|
2363
|
+
(f) => fs__default.default.existsSync(path8__default.default.join(themePath, f))
|
|
2358
2364
|
);
|
|
2359
2365
|
if (!foundEntry) {
|
|
2360
2366
|
issues.push({
|
|
@@ -2364,7 +2370,7 @@ async function validateCommand(options) {
|
|
|
2364
2370
|
});
|
|
2365
2371
|
} else if (foundEntry === "manifest.ts") {
|
|
2366
2372
|
const manifestContent = fs__default.default.readFileSync(
|
|
2367
|
-
|
|
2373
|
+
path8__default.default.join(themePath, foundEntry),
|
|
2368
2374
|
"utf-8"
|
|
2369
2375
|
);
|
|
2370
2376
|
if (!manifestContent.includes("export const") && !manifestContent.includes("export default") && !manifestContent.includes("export interface")) {
|
|
@@ -2375,7 +2381,7 @@ async function validateCommand(options) {
|
|
|
2375
2381
|
});
|
|
2376
2382
|
}
|
|
2377
2383
|
}
|
|
2378
|
-
const configPath =
|
|
2384
|
+
const configPath = path8__default.default.join(themePath, "theme.config.ts");
|
|
2379
2385
|
if (!fs__default.default.existsSync(configPath)) {
|
|
2380
2386
|
issues.push({
|
|
2381
2387
|
type: "warning",
|
|
@@ -2383,7 +2389,7 @@ async function validateCommand(options) {
|
|
|
2383
2389
|
message: "Theme config file not found (recommended)"
|
|
2384
2390
|
});
|
|
2385
2391
|
}
|
|
2386
|
-
const indexPath =
|
|
2392
|
+
const indexPath = path8__default.default.join(themePath, "index.ts");
|
|
2387
2393
|
if (!fs__default.default.existsSync(indexPath)) {
|
|
2388
2394
|
issues.push({
|
|
2389
2395
|
type: "warning",
|
|
@@ -2391,7 +2397,7 @@ async function validateCommand(options) {
|
|
|
2391
2397
|
message: "Index file not found (recommended)"
|
|
2392
2398
|
});
|
|
2393
2399
|
}
|
|
2394
|
-
const sectionsDir =
|
|
2400
|
+
const sectionsDir = path8__default.default.join(themePath, "sections");
|
|
2395
2401
|
if (!fs__default.default.existsSync(sectionsDir)) {
|
|
2396
2402
|
issues.push({
|
|
2397
2403
|
type: "warning",
|
|
@@ -2400,16 +2406,16 @@ async function validateCommand(options) {
|
|
|
2400
2406
|
});
|
|
2401
2407
|
} else {
|
|
2402
2408
|
const sections = fs__default.default.readdirSync(sectionsDir).filter(
|
|
2403
|
-
(name) => fs__default.default.statSync(
|
|
2409
|
+
(name) => fs__default.default.statSync(path8__default.default.join(sectionsDir, name)).isDirectory()
|
|
2404
2410
|
);
|
|
2405
2411
|
for (const sectionName of sections) {
|
|
2406
|
-
const sectionPath =
|
|
2407
|
-
const schemaFile =
|
|
2408
|
-
const defaultTemplate =
|
|
2412
|
+
const sectionPath = path8__default.default.join(sectionsDir, sectionName);
|
|
2413
|
+
const schemaFile = path8__default.default.join(sectionPath, `${sectionName}.schema.ts`);
|
|
2414
|
+
const defaultTemplate = path8__default.default.join(
|
|
2409
2415
|
sectionPath,
|
|
2410
2416
|
`${sectionName}-default.tsx`
|
|
2411
2417
|
);
|
|
2412
|
-
const indexFile =
|
|
2418
|
+
const indexFile = path8__default.default.join(sectionPath, "index.ts");
|
|
2413
2419
|
if (!fs__default.default.existsSync(schemaFile)) {
|
|
2414
2420
|
issues.push({
|
|
2415
2421
|
type: "error",
|
|
@@ -2433,14 +2439,14 @@ async function validateCommand(options) {
|
|
|
2433
2439
|
}
|
|
2434
2440
|
}
|
|
2435
2441
|
}
|
|
2436
|
-
const blocksDir =
|
|
2442
|
+
const blocksDir = path8__default.default.join(themePath, "blocks");
|
|
2437
2443
|
if (fs__default.default.existsSync(blocksDir)) {
|
|
2438
|
-
const blocks = fs__default.default.readdirSync(blocksDir).filter((name) => fs__default.default.statSync(
|
|
2444
|
+
const blocks = fs__default.default.readdirSync(blocksDir).filter((name) => fs__default.default.statSync(path8__default.default.join(blocksDir, name)).isDirectory());
|
|
2439
2445
|
for (const blockName of blocks) {
|
|
2440
|
-
const blockPath =
|
|
2441
|
-
const schemaFile =
|
|
2442
|
-
const componentFile =
|
|
2443
|
-
const indexFile =
|
|
2446
|
+
const blockPath = path8__default.default.join(blocksDir, blockName);
|
|
2447
|
+
const schemaFile = path8__default.default.join(blockPath, `${blockName}.schema.ts`);
|
|
2448
|
+
const componentFile = path8__default.default.join(blockPath, `${blockName}.tsx`);
|
|
2449
|
+
const indexFile = path8__default.default.join(blockPath, "index.ts");
|
|
2444
2450
|
if (!fs__default.default.existsSync(schemaFile)) {
|
|
2445
2451
|
issues.push({
|
|
2446
2452
|
type: "error",
|
|
@@ -2512,14 +2518,14 @@ async function buildCommand(options) {
|
|
|
2512
2518
|
if (options.theme) {
|
|
2513
2519
|
themeName = options.theme;
|
|
2514
2520
|
try {
|
|
2515
|
-
const workspaceThemePath =
|
|
2521
|
+
const workspaceThemePath = path8__default.default.join(getThemesDir(), themeName);
|
|
2516
2522
|
if (fs__default.default.existsSync(workspaceThemePath)) {
|
|
2517
2523
|
themePath = workspaceThemePath;
|
|
2518
2524
|
} else {
|
|
2519
|
-
themePath =
|
|
2525
|
+
themePath = path8__default.default.join(process.cwd(), themeName);
|
|
2520
2526
|
}
|
|
2521
2527
|
} catch {
|
|
2522
|
-
themePath =
|
|
2528
|
+
themePath = path8__default.default.join(process.cwd(), themeName);
|
|
2523
2529
|
}
|
|
2524
2530
|
if (!fs__default.default.existsSync(themePath)) {
|
|
2525
2531
|
logger.error(`Theme "${themeName}" not found.`);
|
|
@@ -2530,10 +2536,10 @@ async function buildCommand(options) {
|
|
|
2530
2536
|
"theme.config.ts",
|
|
2531
2537
|
"bundle-entry.ts",
|
|
2532
2538
|
"manifest.ts"
|
|
2533
|
-
].some((f) => fs__default.default.existsSync(
|
|
2539
|
+
].some((f) => fs__default.default.existsSync(path8__default.default.join(process.cwd(), f)));
|
|
2534
2540
|
if (isThemeDir) {
|
|
2535
2541
|
themePath = process.cwd();
|
|
2536
|
-
themeName =
|
|
2542
|
+
themeName = path8__default.default.basename(themePath);
|
|
2537
2543
|
logger.info(`Building current theme: ${themeName}`);
|
|
2538
2544
|
} else {
|
|
2539
2545
|
logger.error(
|
|
@@ -2542,7 +2548,7 @@ async function buildCommand(options) {
|
|
|
2542
2548
|
process.exit(1);
|
|
2543
2549
|
}
|
|
2544
2550
|
}
|
|
2545
|
-
const packageJsonPath =
|
|
2551
|
+
const packageJsonPath = path8__default.default.join(themePath, "package.json");
|
|
2546
2552
|
const hasPkgJson = fs__default.default.existsSync(packageJsonPath);
|
|
2547
2553
|
if (!hasPkgJson) {
|
|
2548
2554
|
logger.warning(
|
|
@@ -2598,9 +2604,9 @@ async function buildCommand(options) {
|
|
|
2598
2604
|
logger.success("\u2713 Theme built successfully!");
|
|
2599
2605
|
logger.newLine();
|
|
2600
2606
|
logger.info(`Theme: ${themeName}`);
|
|
2601
|
-
const distPath =
|
|
2607
|
+
const distPath = path8__default.default.join(themePath, "dist");
|
|
2602
2608
|
if (fs__default.default.existsSync(distPath)) {
|
|
2603
|
-
logger.log(`Output: ${
|
|
2609
|
+
logger.log(`Output: ${path8__default.default.relative(process.cwd(), distPath)}`);
|
|
2604
2610
|
const files = fs__default.default.readdirSync(distPath);
|
|
2605
2611
|
logger.log(`Files: ${files.length}`);
|
|
2606
2612
|
}
|
|
@@ -2638,7 +2644,7 @@ async function packageCommand(options) {
|
|
|
2638
2644
|
let themeName;
|
|
2639
2645
|
if (options.theme) {
|
|
2640
2646
|
themeName = options.theme;
|
|
2641
|
-
themePath =
|
|
2647
|
+
themePath = path8__default.default.join(getThemesDir(), themeName);
|
|
2642
2648
|
if (!fs__default.default.existsSync(themePath)) {
|
|
2643
2649
|
logger.error(`Theme "${themeName}" not found.`);
|
|
2644
2650
|
process.exit(1);
|
|
@@ -2648,10 +2654,10 @@ async function packageCommand(options) {
|
|
|
2648
2654
|
"theme.config.ts",
|
|
2649
2655
|
"bundle-entry.ts",
|
|
2650
2656
|
"manifest.ts"
|
|
2651
|
-
].some((f) => fs__default.default.existsSync(
|
|
2657
|
+
].some((f) => fs__default.default.existsSync(path8__default.default.join(process.cwd(), f)));
|
|
2652
2658
|
if (isThemeDir) {
|
|
2653
2659
|
themePath = process.cwd();
|
|
2654
|
-
themeName =
|
|
2660
|
+
themeName = path8__default.default.basename(themePath);
|
|
2655
2661
|
logger.info(`Packaging current theme: ${themeName}`);
|
|
2656
2662
|
} else {
|
|
2657
2663
|
logger.error(
|
|
@@ -2660,7 +2666,7 @@ async function packageCommand(options) {
|
|
|
2660
2666
|
process.exit(1);
|
|
2661
2667
|
}
|
|
2662
2668
|
}
|
|
2663
|
-
const packageJsonPath =
|
|
2669
|
+
const packageJsonPath = path8__default.default.join(themePath, "package.json");
|
|
2664
2670
|
let version = "1.0.0";
|
|
2665
2671
|
if (fs__default.default.existsSync(packageJsonPath)) {
|
|
2666
2672
|
const packageJson = await fs__default.default.readJson(packageJsonPath);
|
|
@@ -2670,7 +2676,7 @@ async function packageCommand(options) {
|
|
|
2670
2676
|
logger.info(`Theme: ${themeName}`);
|
|
2671
2677
|
logger.info(`Version: ${version}`);
|
|
2672
2678
|
logger.newLine();
|
|
2673
|
-
const compiledThemePath =
|
|
2679
|
+
const compiledThemePath = path8__default.default.join(
|
|
2674
2680
|
process.cwd(),
|
|
2675
2681
|
"themes",
|
|
2676
2682
|
themeName,
|
|
@@ -2704,8 +2710,8 @@ async function packageCommand(options) {
|
|
|
2704
2710
|
logger.newLine();
|
|
2705
2711
|
logger.section("Step 2: Create Package");
|
|
2706
2712
|
const packageName = options.name || `${themeName}-${version}`;
|
|
2707
|
-
const outputDir = options.output ||
|
|
2708
|
-
const outputPath =
|
|
2713
|
+
const outputDir = options.output || path8__default.default.join(process.cwd(), "dist");
|
|
2714
|
+
const outputPath = path8__default.default.join(outputDir, `${packageName}.zip`);
|
|
2709
2715
|
await fs__default.default.ensureDir(outputDir);
|
|
2710
2716
|
logger.startSpinner("Creating zip archive...");
|
|
2711
2717
|
try {
|
|
@@ -2718,11 +2724,11 @@ async function packageCommand(options) {
|
|
|
2718
2724
|
logger.newLine();
|
|
2719
2725
|
logger.info(`Package: ${packageName}.zip`);
|
|
2720
2726
|
logger.log(`Size: ${sizeMB} MB`);
|
|
2721
|
-
logger.log(`Location: ${
|
|
2727
|
+
logger.log(`Location: ${path8__default.default.relative(process.cwd(), outputPath)}`);
|
|
2722
2728
|
logger.newLine();
|
|
2723
2729
|
logger.section("Next steps:");
|
|
2724
2730
|
logger.log(
|
|
2725
|
-
` onex deploy --package ${
|
|
2731
|
+
` onex deploy --package ${path8__default.default.relative(process.cwd(), outputPath)}`
|
|
2726
2732
|
);
|
|
2727
2733
|
} catch (error) {
|
|
2728
2734
|
logger.stopSpinner(false, "Failed to create package");
|
|
@@ -2780,9 +2786,9 @@ async function deployCommand(options) {
|
|
|
2780
2786
|
ensureOneXProject();
|
|
2781
2787
|
let packagePath;
|
|
2782
2788
|
if (options.package) {
|
|
2783
|
-
packagePath =
|
|
2789
|
+
packagePath = path8__default.default.resolve(options.package);
|
|
2784
2790
|
} else if (options.theme) {
|
|
2785
|
-
const distDir =
|
|
2791
|
+
const distDir = path8__default.default.join(process.cwd(), "dist");
|
|
2786
2792
|
if (!fs__default.default.existsSync(distDir)) {
|
|
2787
2793
|
logger.error("No dist/ directory found. Run 'onex package' first.");
|
|
2788
2794
|
process.exit(1);
|
|
@@ -2797,7 +2803,7 @@ async function deployCommand(options) {
|
|
|
2797
2803
|
process.exit(1);
|
|
2798
2804
|
}
|
|
2799
2805
|
packageFiles.sort().reverse();
|
|
2800
|
-
packagePath =
|
|
2806
|
+
packagePath = path8__default.default.join(distDir, packageFiles[0]);
|
|
2801
2807
|
} else {
|
|
2802
2808
|
logger.error("Either --package or --theme must be specified.");
|
|
2803
2809
|
logger.info("Examples:");
|
|
@@ -2811,11 +2817,11 @@ async function deployCommand(options) {
|
|
|
2811
2817
|
}
|
|
2812
2818
|
const stats = await fs__default.default.stat(packagePath);
|
|
2813
2819
|
const sizeMB = (stats.size / 1024 / 1024).toFixed(2);
|
|
2814
|
-
const fileName =
|
|
2820
|
+
const fileName = path8__default.default.basename(packagePath);
|
|
2815
2821
|
logger.newLine();
|
|
2816
2822
|
logger.info(`Package: ${fileName}`);
|
|
2817
2823
|
logger.log(`Size: ${sizeMB} MB`);
|
|
2818
|
-
logger.log(`Path: ${
|
|
2824
|
+
logger.log(`Path: ${path8__default.default.relative(process.cwd(), packagePath)}`);
|
|
2819
2825
|
logger.newLine();
|
|
2820
2826
|
const apiUrl = options.apiUrl || process.env.ONEX_API_URL || "http://localhost:3001";
|
|
2821
2827
|
const uploadEndpoint = `${apiUrl}/api/themes/upload`;
|
|
@@ -2919,11 +2925,11 @@ function getBucketName(env) {
|
|
|
2919
2925
|
return environment === "production" ? "onex-themes-prod" : "onex-themes-staging";
|
|
2920
2926
|
}
|
|
2921
2927
|
async function findCompiledThemeDir(themeId, version) {
|
|
2922
|
-
const searchPaths = [
|
|
2928
|
+
const searchPaths = [path8__default.default.resolve(process.cwd(), "dist")];
|
|
2923
2929
|
for (const dir of searchPaths) {
|
|
2924
2930
|
if (await fs__default.default.pathExists(dir)) {
|
|
2925
|
-
const hasManifest = await fs__default.default.pathExists(
|
|
2926
|
-
const hasThemeEntry = await fs__default.default.pathExists(
|
|
2931
|
+
const hasManifest = await fs__default.default.pathExists(path8__default.default.join(dir, "manifest.json"));
|
|
2932
|
+
const hasThemeEntry = await fs__default.default.pathExists(path8__default.default.join(dir, "bundle-entry.js")) || await fs__default.default.pathExists(path8__default.default.join(dir, "theme.config.js")) || await fs__default.default.pathExists(path8__default.default.join(dir, "index.js"));
|
|
2927
2933
|
if (hasManifest || hasThemeEntry) {
|
|
2928
2934
|
return dir;
|
|
2929
2935
|
}
|
|
@@ -2932,7 +2938,7 @@ async function findCompiledThemeDir(themeId, version) {
|
|
|
2932
2938
|
return null;
|
|
2933
2939
|
}
|
|
2934
2940
|
async function readManifest() {
|
|
2935
|
-
const manifestTsPath =
|
|
2941
|
+
const manifestTsPath = path8__default.default.resolve(process.cwd(), "manifest.ts");
|
|
2936
2942
|
if (await fs__default.default.pathExists(manifestTsPath)) {
|
|
2937
2943
|
try {
|
|
2938
2944
|
const module = await import(manifestTsPath);
|
|
@@ -2941,7 +2947,7 @@ async function readManifest() {
|
|
|
2941
2947
|
logger.warning("Failed to import manifest.ts, trying package.json");
|
|
2942
2948
|
}
|
|
2943
2949
|
}
|
|
2944
|
-
const packageJsonPath =
|
|
2950
|
+
const packageJsonPath = path8__default.default.resolve(process.cwd(), "package.json");
|
|
2945
2951
|
if (await fs__default.default.pathExists(packageJsonPath)) {
|
|
2946
2952
|
const pkg = await fs__default.default.readJson(packageJsonPath);
|
|
2947
2953
|
return {
|
|
@@ -2975,13 +2981,13 @@ async function findSourceDir(themeId, explicitDir) {
|
|
|
2975
2981
|
}
|
|
2976
2982
|
const searchPaths = [
|
|
2977
2983
|
process.cwd(),
|
|
2978
|
-
|
|
2979
|
-
|
|
2984
|
+
path8__default.default.resolve(process.cwd(), `../../themes/${themeId}`),
|
|
2985
|
+
path8__default.default.resolve(process.cwd(), `../themes/${themeId}`)
|
|
2980
2986
|
];
|
|
2981
2987
|
const markers = ["theme.config.ts", "bundle-entry.ts"];
|
|
2982
2988
|
for (const dir of searchPaths) {
|
|
2983
2989
|
for (const marker of markers) {
|
|
2984
|
-
if (await fs__default.default.pathExists(
|
|
2990
|
+
if (await fs__default.default.pathExists(path8__default.default.join(dir, marker))) {
|
|
2985
2991
|
return dir;
|
|
2986
2992
|
}
|
|
2987
2993
|
}
|
|
@@ -3033,7 +3039,7 @@ async function uploadCommand(options) {
|
|
|
3033
3039
|
spinner.succeed(`Found compiled theme at: ${compiledDir}`);
|
|
3034
3040
|
spinner.start("Creating bundle.zip...");
|
|
3035
3041
|
const tmpDir = os__default.default.tmpdir();
|
|
3036
|
-
const bundleZipPath =
|
|
3042
|
+
const bundleZipPath = path8__default.default.join(tmpDir, `${themeId}-${version}-bundle.zip`);
|
|
3037
3043
|
await createZipFromDir(compiledDir, bundleZipPath);
|
|
3038
3044
|
const bundleZipBuffer = await fs__default.default.readFile(bundleZipPath);
|
|
3039
3045
|
const bundleSizeMB = (bundleZipBuffer.length / 1024 / 1024).toFixed(2);
|
|
@@ -3087,7 +3093,7 @@ async function uploadCommand(options) {
|
|
|
3087
3093
|
if (sourceDir) {
|
|
3088
3094
|
spinner.succeed(`Found source at: ${sourceDir}`);
|
|
3089
3095
|
spinner.start("Creating source.zip...");
|
|
3090
|
-
const sourceZipPath =
|
|
3096
|
+
const sourceZipPath = path8__default.default.join(
|
|
3091
3097
|
tmpDir,
|
|
3092
3098
|
`${themeId}-${version}-source.zip`
|
|
3093
3099
|
);
|
|
@@ -3221,8 +3227,8 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
|
|
|
3221
3227
|
async function createCompatibilityFiles(outputDir, manifest) {
|
|
3222
3228
|
const entryFile = manifest.output?.entry || "bundle-entry.js";
|
|
3223
3229
|
if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
|
|
3224
|
-
const hashedPath =
|
|
3225
|
-
const stablePath =
|
|
3230
|
+
const hashedPath = path8__default.default.join(outputDir, entryFile);
|
|
3231
|
+
const stablePath = path8__default.default.join(outputDir, "bundle-entry.js");
|
|
3226
3232
|
if (await fs__default.default.pathExists(hashedPath)) {
|
|
3227
3233
|
await fs__default.default.copy(hashedPath, stablePath);
|
|
3228
3234
|
const mapPath = hashedPath + ".map";
|
|
@@ -3231,13 +3237,13 @@ async function createCompatibilityFiles(outputDir, manifest) {
|
|
|
3231
3237
|
}
|
|
3232
3238
|
}
|
|
3233
3239
|
}
|
|
3234
|
-
const sectionsRegistryPath =
|
|
3240
|
+
const sectionsRegistryPath = path8__default.default.join(outputDir, "sections-registry.js");
|
|
3235
3241
|
const content = `// Re-export all sections from bundle-entry
|
|
3236
3242
|
// This file exists to maintain compatibility with the import path
|
|
3237
3243
|
export * from './bundle-entry.js';
|
|
3238
3244
|
`;
|
|
3239
3245
|
await fs__default.default.writeFile(sectionsRegistryPath, content, "utf-8");
|
|
3240
|
-
const pkgJsonPath =
|
|
3246
|
+
const pkgJsonPath = path8__default.default.join(outputDir, "package.json");
|
|
3241
3247
|
await fs__default.default.writeFile(pkgJsonPath, '{\n "type": "module"\n}\n', "utf-8");
|
|
3242
3248
|
}
|
|
3243
3249
|
function showDownloadFailureHelp(themeId, bucket) {
|
|
@@ -3320,7 +3326,7 @@ async function downloadCommand(options) {
|
|
|
3320
3326
|
zip.extractAllTo(outputDir, true);
|
|
3321
3327
|
const entries = zip.getEntries().filter((e) => !e.isDirectory);
|
|
3322
3328
|
spinner.succeed(`Extracted ${entries.length} files to ${outputDir}`);
|
|
3323
|
-
const manifestPath =
|
|
3329
|
+
const manifestPath = path8__default.default.join(outputDir, "manifest.json");
|
|
3324
3330
|
const manifest = await fs__default.default.readJson(manifestPath);
|
|
3325
3331
|
await createCompatibilityFiles(outputDir, manifest);
|
|
3326
3332
|
console.log();
|
|
@@ -3454,7 +3460,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3454
3460
|
const oldPrefix = `${oldName}-`;
|
|
3455
3461
|
const newPrefix = `${newName}-`;
|
|
3456
3462
|
const newDisplayName = newName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3457
|
-
const pkgPath =
|
|
3463
|
+
const pkgPath = path8__default.default.join(themeDir, "package.json");
|
|
3458
3464
|
if (await fs__default.default.pathExists(pkgPath)) {
|
|
3459
3465
|
const pkg = await fs__default.default.readJson(pkgPath);
|
|
3460
3466
|
pkg.name = `@onex-themes/${newName}`;
|
|
@@ -3465,9 +3471,12 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3465
3471
|
);
|
|
3466
3472
|
}
|
|
3467
3473
|
pkg.version = "1.0.0";
|
|
3474
|
+
if (pkg.devDependencies?.["@onexapis/cli"]) {
|
|
3475
|
+
delete pkg.devDependencies["@onexapis/cli"];
|
|
3476
|
+
}
|
|
3468
3477
|
await fs__default.default.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
3469
3478
|
}
|
|
3470
|
-
const configPath =
|
|
3479
|
+
const configPath = path8__default.default.join(themeDir, "theme.config.ts");
|
|
3471
3480
|
if (await fs__default.default.pathExists(configPath)) {
|
|
3472
3481
|
let content = await fs__default.default.readFile(configPath, "utf-8");
|
|
3473
3482
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -3477,7 +3486,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3477
3486
|
);
|
|
3478
3487
|
await fs__default.default.writeFile(configPath, content);
|
|
3479
3488
|
}
|
|
3480
|
-
const layoutPath =
|
|
3489
|
+
const layoutPath = path8__default.default.join(themeDir, "theme.layout.ts");
|
|
3481
3490
|
if (await fs__default.default.pathExists(layoutPath)) {
|
|
3482
3491
|
let content = await fs__default.default.readFile(layoutPath, "utf-8");
|
|
3483
3492
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -3490,7 +3499,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3490
3499
|
const oldDisplayName = oldName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3491
3500
|
const tsFiles = await glob.glob("**/*.ts", { cwd: themeDir, nodir: true });
|
|
3492
3501
|
for (const file of tsFiles) {
|
|
3493
|
-
const filePath =
|
|
3502
|
+
const filePath = path8__default.default.join(themeDir, file);
|
|
3494
3503
|
let content = await fs__default.default.readFile(filePath, "utf-8");
|
|
3495
3504
|
const original = content;
|
|
3496
3505
|
content = content.replace(
|
|
@@ -3519,7 +3528,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3519
3528
|
const spinner = ora__default.default("Initializing clone...").start();
|
|
3520
3529
|
try {
|
|
3521
3530
|
const bucket = options.bucket || getBucketName3(options.environment);
|
|
3522
|
-
const outputDir = options.output ||
|
|
3531
|
+
const outputDir = options.output || path8__default.default.resolve(process.cwd(), newName);
|
|
3523
3532
|
const s3Client = getS3Client3();
|
|
3524
3533
|
if (await fs__default.default.pathExists(outputDir)) {
|
|
3525
3534
|
spinner.fail(chalk4__default.default.red(`Directory already exists: ${outputDir}`));
|
|
@@ -3574,7 +3583,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3574
3583
|
spinner.succeed(
|
|
3575
3584
|
`Renamed theme: ${chalk4__default.default.gray(themeName)} \u2192 ${chalk4__default.default.cyan(newName)}`
|
|
3576
3585
|
);
|
|
3577
|
-
const envExamplePath =
|
|
3586
|
+
const envExamplePath = path8__default.default.join(outputDir, ".env.example");
|
|
3578
3587
|
if (!await fs__default.default.pathExists(envExamplePath)) {
|
|
3579
3588
|
await fs__default.default.writeFile(
|
|
3580
3589
|
envExamplePath,
|
|
@@ -3589,7 +3598,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3589
3598
|
}
|
|
3590
3599
|
if (options.install !== false) {
|
|
3591
3600
|
const hasPkgJson = await fs__default.default.pathExists(
|
|
3592
|
-
|
|
3601
|
+
path8__default.default.join(outputDir, "package.json")
|
|
3593
3602
|
);
|
|
3594
3603
|
if (hasPkgJson) {
|
|
3595
3604
|
spinner.start("Installing dependencies...");
|
|
@@ -3616,7 +3625,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3616
3625
|
console.log(chalk4__default.default.cyan(" Files: ") + chalk4__default.default.white(entries.length));
|
|
3617
3626
|
console.log();
|
|
3618
3627
|
console.log(chalk4__default.default.cyan("Next steps:"));
|
|
3619
|
-
console.log(chalk4__default.default.gray(` cd ${
|
|
3628
|
+
console.log(chalk4__default.default.gray(` cd ${path8__default.default.relative(process.cwd(), outputDir)}`));
|
|
3620
3629
|
console.log(chalk4__default.default.gray(" cp .env.example .env # then add your Company ID"));
|
|
3621
3630
|
if (options.install === false) {
|
|
3622
3631
|
console.log(chalk4__default.default.gray(" pnpm install"));
|
|
@@ -3669,7 +3678,7 @@ function createDevServer(options) {
|
|
|
3669
3678
|
serveFile(res, options.previewRuntimePath);
|
|
3670
3679
|
return;
|
|
3671
3680
|
}
|
|
3672
|
-
const filePath =
|
|
3681
|
+
const filePath = path8__default.default.join(options.distDir, pathname);
|
|
3673
3682
|
if (!filePath.startsWith(options.distDir)) {
|
|
3674
3683
|
res.writeHead(403);
|
|
3675
3684
|
res.end("Forbidden");
|
|
@@ -3710,7 +3719,7 @@ function serveFile(res, filePath) {
|
|
|
3710
3719
|
res.end("Not Found");
|
|
3711
3720
|
return;
|
|
3712
3721
|
}
|
|
3713
|
-
const ext =
|
|
3722
|
+
const ext = path8__default.default.extname(filePath);
|
|
3714
3723
|
const contentType = MIME_TYPES[ext] || "application/octet-stream";
|
|
3715
3724
|
const content = fs2__default.default.readFileSync(filePath);
|
|
3716
3725
|
res.writeHead(200, { "Content-Type": contentType });
|
|
@@ -3770,14 +3779,14 @@ async function devCommand(options) {
|
|
|
3770
3779
|
if (options.theme) {
|
|
3771
3780
|
themeName = options.theme;
|
|
3772
3781
|
try {
|
|
3773
|
-
const workspaceThemePath =
|
|
3782
|
+
const workspaceThemePath = path8__default.default.join(getThemesDir(), themeName);
|
|
3774
3783
|
if (fs__default.default.existsSync(workspaceThemePath)) {
|
|
3775
3784
|
themePath = workspaceThemePath;
|
|
3776
3785
|
} else {
|
|
3777
|
-
themePath =
|
|
3786
|
+
themePath = path8__default.default.join(process.cwd(), themeName);
|
|
3778
3787
|
}
|
|
3779
3788
|
} catch {
|
|
3780
|
-
themePath =
|
|
3789
|
+
themePath = path8__default.default.join(process.cwd(), themeName);
|
|
3781
3790
|
}
|
|
3782
3791
|
if (!fs__default.default.existsSync(themePath)) {
|
|
3783
3792
|
logger.error(`Theme "${themeName}" not found.`);
|
|
@@ -3788,10 +3797,10 @@ async function devCommand(options) {
|
|
|
3788
3797
|
"theme.config.ts",
|
|
3789
3798
|
"bundle-entry.ts",
|
|
3790
3799
|
"manifest.ts"
|
|
3791
|
-
].some((f) => fs__default.default.existsSync(
|
|
3800
|
+
].some((f) => fs__default.default.existsSync(path8__default.default.join(process.cwd(), f)));
|
|
3792
3801
|
if (isThemeDir) {
|
|
3793
3802
|
themePath = process.cwd();
|
|
3794
|
-
themeName =
|
|
3803
|
+
themeName = path8__default.default.basename(themePath);
|
|
3795
3804
|
} else {
|
|
3796
3805
|
logger.error(
|
|
3797
3806
|
"Not in a theme directory and no --theme specified. Run from theme root or use --theme flag."
|
|
@@ -3859,7 +3868,7 @@ async function devCommand(options) {
|
|
|
3859
3868
|
watcher.close();
|
|
3860
3869
|
await context2.dispose();
|
|
3861
3870
|
server.close();
|
|
3862
|
-
const shimPath =
|
|
3871
|
+
const shimPath = path8__default.default.join(outputDir, ".process-shim.js");
|
|
3863
3872
|
try {
|
|
3864
3873
|
await fs7__default.default.unlink(shimPath);
|
|
3865
3874
|
} catch {
|
|
@@ -3872,14 +3881,14 @@ async function devCommand(options) {
|
|
|
3872
3881
|
try {
|
|
3873
3882
|
const projectRoot = getProjectRoot();
|
|
3874
3883
|
dotenv__default.default.config({
|
|
3875
|
-
path:
|
|
3884
|
+
path: path8__default.default.join(projectRoot, ".env.local"),
|
|
3876
3885
|
quiet: true
|
|
3877
3886
|
});
|
|
3878
|
-
dotenv__default.default.config({ path:
|
|
3887
|
+
dotenv__default.default.config({ path: path8__default.default.join(projectRoot, ".env"), quiet: true });
|
|
3879
3888
|
} catch {
|
|
3880
3889
|
}
|
|
3881
3890
|
dotenv__default.default.config({
|
|
3882
|
-
path:
|
|
3891
|
+
path: path8__default.default.join(os__default.default.homedir(), ".onex", ".env"),
|
|
3883
3892
|
quiet: true
|
|
3884
3893
|
});
|
|
3885
3894
|
var program = new commander.Command();
|