@onexapis/cli 1.1.2 → 1.1.4
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 +352 -314
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +350 -313
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +304 -266
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +302 -265
- package/dist/index.mjs.map +1 -1
- package/dist/preview/preview-app.tsx +112 -21
- package/package.json +3 -1
- package/templates/default/.env.example +4 -0
- package/templates/default/package.json.ejs +2 -1
package/dist/cli.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import chalk4 from 'chalk';
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
import * as esbuild from 'esbuild';
|
|
5
|
-
import
|
|
5
|
+
import path8 from 'path';
|
|
6
6
|
import fs7 from 'fs/promises';
|
|
7
7
|
import crypto from 'crypto';
|
|
8
8
|
import { glob } from 'glob';
|
|
@@ -25,22 +25,6 @@ import { WebSocketServer, WebSocket } from 'ws';
|
|
|
25
25
|
|
|
26
26
|
var __defProp = Object.defineProperty;
|
|
27
27
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
28
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
29
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
30
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
31
|
-
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
32
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
33
|
-
var __spreadValues = (a, b) => {
|
|
34
|
-
for (var prop in b || (b = {}))
|
|
35
|
-
if (__hasOwnProp.call(b, prop))
|
|
36
|
-
__defNormalProp(a, prop, b[prop]);
|
|
37
|
-
if (__getOwnPropSymbols)
|
|
38
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
39
|
-
if (__propIsEnum.call(b, prop))
|
|
40
|
-
__defNormalProp(a, prop, b[prop]);
|
|
41
|
-
}
|
|
42
|
-
return a;
|
|
43
|
-
};
|
|
44
28
|
var __esm = (fn, res) => function __init() {
|
|
45
29
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
46
30
|
};
|
|
@@ -48,7 +32,6 @@ var __export = (target, all) => {
|
|
|
48
32
|
for (var name in all)
|
|
49
33
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
50
34
|
};
|
|
51
|
-
var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
|
|
52
35
|
var Logger, logger;
|
|
53
36
|
var init_logger = __esm({
|
|
54
37
|
"src/utils/logger.ts"() {
|
|
@@ -117,12 +100,12 @@ __export(compile_theme_exports, {
|
|
|
117
100
|
async function resolveNodeModulesFile(startDir, relativePath) {
|
|
118
101
|
let dir = startDir;
|
|
119
102
|
while (true) {
|
|
120
|
-
const candidate =
|
|
103
|
+
const candidate = path8.join(dir, "node_modules", relativePath);
|
|
121
104
|
try {
|
|
122
105
|
await fs7.access(candidate);
|
|
123
106
|
return candidate;
|
|
124
|
-
} catch
|
|
125
|
-
const parent =
|
|
107
|
+
} catch {
|
|
108
|
+
const parent = path8.dirname(dir);
|
|
126
109
|
if (parent === dir) break;
|
|
127
110
|
dir = parent;
|
|
128
111
|
}
|
|
@@ -140,7 +123,7 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
140
123
|
}));
|
|
141
124
|
build2.onLoad({ filter: /.*/, namespace: "core-global" }, async (args) => {
|
|
142
125
|
const match = args.path.match(/^@onexapis\/core(\/(.+))?$/);
|
|
143
|
-
const subpath =
|
|
126
|
+
const subpath = match?.[2] || "";
|
|
144
127
|
const moduleAccess = subpath ? `['${subpath}']` : "";
|
|
145
128
|
let namedExports = [];
|
|
146
129
|
const cacheKey = subpath || "__root__";
|
|
@@ -148,10 +131,16 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
148
131
|
namedExports = exportsBySubpath[cacheKey];
|
|
149
132
|
} else {
|
|
150
133
|
const distFileName = subpath ? `${subpath}.mjs` : "index.mjs";
|
|
151
|
-
|
|
134
|
+
let distPath = await resolveNodeModulesFile(
|
|
152
135
|
themePath,
|
|
153
|
-
|
|
136
|
+
path8.join("@onexapis", "core", "dist", distFileName)
|
|
154
137
|
);
|
|
138
|
+
if (!distPath) {
|
|
139
|
+
distPath = await resolveNodeModulesFile(
|
|
140
|
+
__dirname,
|
|
141
|
+
path8.join("@onexapis", "core", "dist", distFileName)
|
|
142
|
+
);
|
|
143
|
+
}
|
|
155
144
|
try {
|
|
156
145
|
if (!distPath) throw new Error("not found");
|
|
157
146
|
const distContent = await fs7.readFile(distPath, "utf-8");
|
|
@@ -164,7 +153,7 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
164
153
|
namedExports.push(...names);
|
|
165
154
|
}
|
|
166
155
|
namedExports = [...new Set(namedExports)];
|
|
167
|
-
} catch
|
|
156
|
+
} catch {
|
|
168
157
|
}
|
|
169
158
|
exportsBySubpath[cacheKey] = namedExports;
|
|
170
159
|
}
|
|
@@ -198,60 +187,60 @@ ${namedExportLines}
|
|
|
198
187
|
}
|
|
199
188
|
async function generateThemeData(themePath, outputDir, themeId) {
|
|
200
189
|
const { createJiti } = await import('jiti');
|
|
201
|
-
const jiti = createJiti(
|
|
190
|
+
const jiti = createJiti(import.meta.url);
|
|
202
191
|
let themeConfig = null;
|
|
203
192
|
let layoutConfig = null;
|
|
204
193
|
const pages = {};
|
|
205
194
|
for (const ext of [".ts", ".js"]) {
|
|
206
195
|
try {
|
|
207
|
-
const mod = await jiti.import(
|
|
196
|
+
const mod = await jiti.import(path8.join(themePath, `theme.config${ext}`));
|
|
208
197
|
themeConfig = mod.default || mod;
|
|
209
198
|
break;
|
|
210
|
-
} catch
|
|
199
|
+
} catch {
|
|
211
200
|
}
|
|
212
201
|
}
|
|
213
202
|
for (const ext of [".ts", ".js"]) {
|
|
214
203
|
try {
|
|
215
|
-
const mod = await jiti.import(
|
|
204
|
+
const mod = await jiti.import(path8.join(themePath, `theme.layout${ext}`));
|
|
216
205
|
layoutConfig = mod.default || mod;
|
|
217
206
|
break;
|
|
218
|
-
} catch
|
|
207
|
+
} catch {
|
|
219
208
|
}
|
|
220
209
|
}
|
|
221
|
-
const pagesDir =
|
|
210
|
+
const pagesDir = path8.join(themePath, "pages");
|
|
222
211
|
try {
|
|
223
212
|
const files = await fs7.readdir(pagesDir);
|
|
224
213
|
for (const file of files) {
|
|
225
214
|
if (!file.match(/\.(ts|js)$/)) continue;
|
|
226
215
|
const name = file.replace(/\.(ts|js)$/, "");
|
|
227
216
|
try {
|
|
228
|
-
const mod = await jiti.import(
|
|
217
|
+
const mod = await jiti.import(path8.join(pagesDir, file));
|
|
229
218
|
const config = mod.default || mod;
|
|
230
219
|
pages[name] = {
|
|
231
220
|
id: name,
|
|
232
221
|
name: config.title || name,
|
|
233
222
|
path: config.path || `/${name}`,
|
|
234
|
-
config:
|
|
223
|
+
config: { id: name, ...config },
|
|
235
224
|
sections: config.sections || [],
|
|
236
225
|
seo: config.seo
|
|
237
226
|
};
|
|
238
|
-
} catch
|
|
227
|
+
} catch {
|
|
239
228
|
}
|
|
240
229
|
}
|
|
241
|
-
} catch
|
|
230
|
+
} catch {
|
|
242
231
|
}
|
|
243
232
|
await fs7.writeFile(
|
|
244
|
-
|
|
233
|
+
path8.join(outputDir, "theme-data.json"),
|
|
245
234
|
JSON.stringify(
|
|
246
235
|
{
|
|
247
236
|
themeId,
|
|
248
237
|
theme: {
|
|
249
238
|
id: themeId,
|
|
250
|
-
name:
|
|
239
|
+
name: themeConfig?.name || themeId,
|
|
251
240
|
config: themeConfig,
|
|
252
241
|
layout: {
|
|
253
|
-
header:
|
|
254
|
-
footer:
|
|
242
|
+
header: layoutConfig?.headerSections || [],
|
|
243
|
+
footer: layoutConfig?.footerSections || []
|
|
255
244
|
},
|
|
256
245
|
pages: Object.keys(pages)
|
|
257
246
|
},
|
|
@@ -261,42 +250,40 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
261
250
|
2
|
|
262
251
|
)
|
|
263
252
|
);
|
|
264
|
-
logger.info(
|
|
265
|
-
`Generated theme-data.json (${Object.keys(pages).length} pages)`
|
|
266
|
-
);
|
|
253
|
+
logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
|
|
267
254
|
}
|
|
268
255
|
async function contentHashEntry(outputDir) {
|
|
269
|
-
const entryPath =
|
|
270
|
-
const mapPath =
|
|
256
|
+
const entryPath = path8.join(outputDir, "bundle-entry.js");
|
|
257
|
+
const mapPath = path8.join(outputDir, "bundle-entry.js.map");
|
|
271
258
|
const oldFiles = await glob("bundle-entry-*.js*", { cwd: outputDir });
|
|
272
259
|
for (const f of oldFiles) {
|
|
273
|
-
await fs7.unlink(
|
|
260
|
+
await fs7.unlink(path8.join(outputDir, f));
|
|
274
261
|
}
|
|
275
262
|
let entryContent;
|
|
276
263
|
try {
|
|
277
264
|
entryContent = await fs7.readFile(entryPath, "utf-8");
|
|
278
|
-
} catch
|
|
279
|
-
const indexPath =
|
|
265
|
+
} catch {
|
|
266
|
+
const indexPath = path8.join(outputDir, "index.js");
|
|
280
267
|
try {
|
|
281
268
|
entryContent = await fs7.readFile(indexPath, "utf-8");
|
|
282
|
-
} catch
|
|
269
|
+
} catch {
|
|
283
270
|
logger.warning("No entry file found in output, skipping content hash");
|
|
284
271
|
return;
|
|
285
272
|
}
|
|
286
273
|
const hash2 = crypto.createHash("sha256").update(entryContent).digest("hex").slice(0, 8);
|
|
287
274
|
const hashedName2 = `bundle-entry-${hash2}.js`;
|
|
288
|
-
const indexMapPath =
|
|
275
|
+
const indexMapPath = path8.join(outputDir, "index.js.map");
|
|
289
276
|
const hashedMapName2 = `bundle-entry-${hash2}.js.map`;
|
|
290
277
|
entryContent = entryContent.replace(
|
|
291
278
|
/\/\/# sourceMappingURL=index\.js\.map/,
|
|
292
279
|
`//# sourceMappingURL=${hashedMapName2}`
|
|
293
280
|
);
|
|
294
|
-
await fs7.writeFile(
|
|
281
|
+
await fs7.writeFile(path8.join(outputDir, hashedName2), entryContent);
|
|
295
282
|
await fs7.unlink(indexPath);
|
|
296
283
|
try {
|
|
297
284
|
await fs7.access(indexMapPath);
|
|
298
|
-
await fs7.rename(indexMapPath,
|
|
299
|
-
} catch
|
|
285
|
+
await fs7.rename(indexMapPath, path8.join(outputDir, hashedMapName2));
|
|
286
|
+
} catch {
|
|
300
287
|
}
|
|
301
288
|
logger.info(`Entry hashed: ${hashedName2}`);
|
|
302
289
|
return;
|
|
@@ -308,21 +295,43 @@ async function contentHashEntry(outputDir) {
|
|
|
308
295
|
/\/\/# sourceMappingURL=bundle-entry\.js\.map/,
|
|
309
296
|
`//# sourceMappingURL=${hashedMapName}`
|
|
310
297
|
);
|
|
311
|
-
await fs7.writeFile(
|
|
298
|
+
await fs7.writeFile(path8.join(outputDir, hashedName), entryContent);
|
|
312
299
|
await fs7.unlink(entryPath);
|
|
313
300
|
try {
|
|
314
301
|
await fs7.access(mapPath);
|
|
315
|
-
await fs7.rename(mapPath,
|
|
316
|
-
} catch
|
|
302
|
+
await fs7.rename(mapPath, path8.join(outputDir, hashedMapName));
|
|
303
|
+
} catch {
|
|
317
304
|
}
|
|
318
305
|
logger.info(`Entry hashed: ${hashedName}`);
|
|
319
306
|
}
|
|
307
|
+
async function extractDataRequirements(themePath) {
|
|
308
|
+
const { createJiti } = await import('jiti');
|
|
309
|
+
const jiti = createJiti(import.meta.url);
|
|
310
|
+
const schemaFiles = await glob("sections/**/*.schema.ts", { cwd: themePath });
|
|
311
|
+
const requirements = {};
|
|
312
|
+
for (const file of schemaFiles) {
|
|
313
|
+
try {
|
|
314
|
+
const mod = await jiti.import(path8.join(themePath, file));
|
|
315
|
+
const exports$1 = mod;
|
|
316
|
+
for (const value of Object.values(exports$1)) {
|
|
317
|
+
if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
|
|
318
|
+
requirements[value.type] = value.dataRequirements;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} catch (err) {
|
|
322
|
+
logger.warning(
|
|
323
|
+
`Could not load schema ${file}: ${err instanceof Error ? err.message : String(err)}`
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return requirements;
|
|
328
|
+
}
|
|
320
329
|
async function generateManifest2(themeName, themePath, outputDir) {
|
|
321
330
|
let version = "1.0.0";
|
|
322
331
|
let themeId = themeName;
|
|
323
332
|
try {
|
|
324
333
|
const pkgContent = await fs7.readFile(
|
|
325
|
-
|
|
334
|
+
path8.join(themePath, "package.json"),
|
|
326
335
|
"utf-8"
|
|
327
336
|
);
|
|
328
337
|
const pkg = JSON.parse(pkgContent);
|
|
@@ -330,18 +339,19 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
330
339
|
if (pkg.name) {
|
|
331
340
|
themeId = pkg.name.replace(/^@onex-themes\//, "");
|
|
332
341
|
}
|
|
333
|
-
} catch
|
|
342
|
+
} catch {
|
|
334
343
|
}
|
|
335
344
|
const [sectionFiles, blockFiles, schemaFiles] = await Promise.all([
|
|
336
345
|
glob("sections/**/index.ts", { cwd: themePath }),
|
|
337
346
|
glob("blocks/**/index.ts", { cwd: themePath }),
|
|
338
347
|
glob("**/*.schema.ts", { cwd: themePath })
|
|
339
348
|
]);
|
|
349
|
+
const dataRequirements = await extractDataRequirements(themePath);
|
|
340
350
|
let hasThemeConfig = false;
|
|
341
351
|
try {
|
|
342
|
-
await fs7.access(
|
|
352
|
+
await fs7.access(path8.join(themePath, "theme.config.ts"));
|
|
343
353
|
hasThemeConfig = true;
|
|
344
|
-
} catch
|
|
354
|
+
} catch {
|
|
345
355
|
}
|
|
346
356
|
const allFiles = await glob("**/*", { cwd: outputDir, nodir: true });
|
|
347
357
|
const jsFiles = allFiles.filter((f) => f.endsWith(".js"));
|
|
@@ -376,24 +386,26 @@ async function generateManifest2(themeName, themePath, outputDir) {
|
|
|
376
386
|
blocks: blockFiles,
|
|
377
387
|
schemas: schemaFiles,
|
|
378
388
|
hasThemeConfig
|
|
379
|
-
}
|
|
389
|
+
},
|
|
390
|
+
// Section data requirements for server-side prefetching (keyed by section type)
|
|
391
|
+
dataRequirements
|
|
380
392
|
};
|
|
381
393
|
await fs7.writeFile(
|
|
382
|
-
|
|
394
|
+
path8.join(outputDir, "manifest.json"),
|
|
383
395
|
JSON.stringify(manifest, null, 2)
|
|
384
396
|
);
|
|
385
397
|
}
|
|
386
398
|
async function compileStandaloneTheme(themePath, themeName) {
|
|
387
|
-
const outputDir =
|
|
388
|
-
const bundleEntry =
|
|
389
|
-
const indexEntry =
|
|
399
|
+
const outputDir = path8.join(themePath, "dist");
|
|
400
|
+
const bundleEntry = path8.join(themePath, "bundle-entry.ts");
|
|
401
|
+
const indexEntry = path8.join(themePath, "index.ts");
|
|
390
402
|
let entryPoint = indexEntry;
|
|
391
403
|
try {
|
|
392
404
|
await fs7.access(bundleEntry);
|
|
393
405
|
entryPoint = bundleEntry;
|
|
394
|
-
} catch
|
|
406
|
+
} catch {
|
|
395
407
|
}
|
|
396
|
-
const shimPath =
|
|
408
|
+
const shimPath = path8.join(outputDir, ".process-shim.js");
|
|
397
409
|
await fs7.mkdir(outputDir, { recursive: true });
|
|
398
410
|
await fs7.writeFile(shimPath, PROCESS_SHIM);
|
|
399
411
|
const buildOptions = {
|
|
@@ -442,7 +454,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
442
454
|
const result = await esbuild.build(buildOptions);
|
|
443
455
|
try {
|
|
444
456
|
await fs7.unlink(shimPath);
|
|
445
|
-
} catch
|
|
457
|
+
} catch {
|
|
446
458
|
}
|
|
447
459
|
await contentHashEntry(outputDir);
|
|
448
460
|
await generateManifest2(themeName, themePath, outputDir);
|
|
@@ -460,23 +472,23 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
460
472
|
} catch (error) {
|
|
461
473
|
try {
|
|
462
474
|
await fs7.unlink(shimPath);
|
|
463
|
-
} catch
|
|
475
|
+
} catch {
|
|
464
476
|
}
|
|
465
477
|
logger.error(`esbuild compilation failed: ${error}`);
|
|
466
478
|
return false;
|
|
467
479
|
}
|
|
468
480
|
}
|
|
469
481
|
async function compileStandaloneThemeDev(themePath, themeName) {
|
|
470
|
-
const outputDir =
|
|
471
|
-
const bundleEntry =
|
|
472
|
-
const indexEntry =
|
|
482
|
+
const outputDir = path8.join(themePath, "dist");
|
|
483
|
+
const bundleEntry = path8.join(themePath, "bundle-entry.ts");
|
|
484
|
+
const indexEntry = path8.join(themePath, "index.ts");
|
|
473
485
|
let entryPoint = indexEntry;
|
|
474
486
|
try {
|
|
475
487
|
await fs7.access(bundleEntry);
|
|
476
488
|
entryPoint = bundleEntry;
|
|
477
|
-
} catch
|
|
489
|
+
} catch {
|
|
478
490
|
}
|
|
479
|
-
const shimPath =
|
|
491
|
+
const shimPath = path8.join(outputDir, ".process-shim.js");
|
|
480
492
|
await fs7.mkdir(outputDir, { recursive: true });
|
|
481
493
|
await fs7.writeFile(shimPath, PROCESS_SHIM);
|
|
482
494
|
const buildOptions = {
|
|
@@ -527,13 +539,13 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
527
539
|
return { context: context2, outputDir };
|
|
528
540
|
}
|
|
529
541
|
async function compilePreviewRuntime(themePath) {
|
|
530
|
-
const outputDir =
|
|
542
|
+
const outputDir = path8.join(themePath, "dist");
|
|
531
543
|
await fs7.mkdir(outputDir, { recursive: true });
|
|
532
|
-
const outputPath =
|
|
544
|
+
const outputPath = path8.join(outputDir, "preview-runtime.js");
|
|
533
545
|
const locations = [
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
546
|
+
path8.join(__dirname, "..", "preview", "preview-app.tsx"),
|
|
547
|
+
path8.join(__dirname, "preview", "preview-app.tsx"),
|
|
548
|
+
path8.join(__dirname, "..", "..", "src", "preview", "preview-app.tsx")
|
|
537
549
|
];
|
|
538
550
|
let previewEntryPath = null;
|
|
539
551
|
for (const loc of locations) {
|
|
@@ -541,7 +553,7 @@ async function compilePreviewRuntime(themePath) {
|
|
|
541
553
|
await fs7.access(loc);
|
|
542
554
|
previewEntryPath = loc;
|
|
543
555
|
break;
|
|
544
|
-
} catch
|
|
556
|
+
} catch {
|
|
545
557
|
}
|
|
546
558
|
}
|
|
547
559
|
if (!previewEntryPath) {
|
|
@@ -581,10 +593,13 @@ ${locations.join("\n")}`
|
|
|
581
593
|
"zlib"
|
|
582
594
|
];
|
|
583
595
|
for (const mod of nodeBuiltins) {
|
|
584
|
-
build2.onResolve(
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
596
|
+
build2.onResolve(
|
|
597
|
+
{ filter: new RegExp(`^${mod.replace("/", "\\/")}$`) },
|
|
598
|
+
() => ({
|
|
599
|
+
path: mod,
|
|
600
|
+
namespace: "node-stub"
|
|
601
|
+
})
|
|
602
|
+
);
|
|
588
603
|
}
|
|
589
604
|
build2.onLoad({ filter: /.*/, namespace: "node-stub" }, (args) => {
|
|
590
605
|
const stubs = {
|
|
@@ -598,8 +613,7 @@ ${locations.join("\n")}`
|
|
|
598
613
|
};
|
|
599
614
|
});
|
|
600
615
|
build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
|
|
601
|
-
|
|
602
|
-
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
616
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
603
617
|
try {
|
|
604
618
|
const result = await build2.resolve(args.path, {
|
|
605
619
|
kind: args.kind,
|
|
@@ -609,7 +623,7 @@ ${locations.join("\n")}`
|
|
|
609
623
|
pluginData: { skipStub: true }
|
|
610
624
|
});
|
|
611
625
|
if (!result.errors.length) return result;
|
|
612
|
-
} catch
|
|
626
|
+
} catch {
|
|
613
627
|
}
|
|
614
628
|
return { path: args.path, namespace: "lucide-stub" };
|
|
615
629
|
});
|
|
@@ -631,8 +645,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
631
645
|
loader: "jsx"
|
|
632
646
|
}));
|
|
633
647
|
build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
|
|
634
|
-
|
|
635
|
-
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
648
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
636
649
|
try {
|
|
637
650
|
const result = await build2.resolve(args.path, {
|
|
638
651
|
kind: args.kind,
|
|
@@ -642,7 +655,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
642
655
|
pluginData: { skipStub: true }
|
|
643
656
|
});
|
|
644
657
|
if (!result.errors.length) return result;
|
|
645
|
-
} catch
|
|
658
|
+
} catch {
|
|
646
659
|
}
|
|
647
660
|
return { path: args.path, namespace: "motion-stub" };
|
|
648
661
|
});
|
|
@@ -656,8 +669,59 @@ export default { motion, AnimatePresence };
|
|
|
656
669
|
`.trim(),
|
|
657
670
|
loader: "jsx"
|
|
658
671
|
}));
|
|
672
|
+
build2.onResolve({ filter: /^next\// }, async (args) => {
|
|
673
|
+
if (args.pluginData?.skipStub) return void 0;
|
|
674
|
+
try {
|
|
675
|
+
const result = await build2.resolve(args.path, {
|
|
676
|
+
kind: args.kind,
|
|
677
|
+
resolveDir: args.resolveDir,
|
|
678
|
+
importer: args.importer,
|
|
679
|
+
namespace: "file",
|
|
680
|
+
pluginData: { skipStub: true }
|
|
681
|
+
});
|
|
682
|
+
if (!result.errors.length) return result;
|
|
683
|
+
} catch {
|
|
684
|
+
}
|
|
685
|
+
return { path: args.path, namespace: "next-stub" };
|
|
686
|
+
});
|
|
687
|
+
build2.onLoad({ filter: /.*/, namespace: "next-stub" }, (args) => {
|
|
688
|
+
const stubs = {
|
|
689
|
+
"next/image": `
|
|
690
|
+
const Image = (props) => {
|
|
691
|
+
const { src, alt, width, height, fill, priority, ...rest } = props;
|
|
692
|
+
const imgSrc = typeof src === 'object' ? src.src : src;
|
|
693
|
+
return React.createElement('img', { src: imgSrc, alt, width: fill ? undefined : width, height: fill ? undefined : height, loading: priority ? 'eager' : 'lazy', ...rest });
|
|
694
|
+
};
|
|
695
|
+
import React from 'react';
|
|
696
|
+
export default Image;
|
|
697
|
+
`,
|
|
698
|
+
"next/link": `
|
|
699
|
+
const Link = ({ href, children, ...rest }) => React.createElement('a', { href, ...rest }, children);
|
|
700
|
+
import React from 'react';
|
|
701
|
+
export default Link;
|
|
702
|
+
`,
|
|
703
|
+
"next/navigation": `
|
|
704
|
+
export function useRouter() { return { push(u){window.location.href=u}, replace(u){window.location.href=u}, back(){window.history.back()}, forward(){window.history.forward()}, refresh(){window.location.reload()}, prefetch(){} }; }
|
|
705
|
+
export function usePathname() { return window.location.pathname; }
|
|
706
|
+
export function useSearchParams() { return new URLSearchParams(window.location.search); }
|
|
707
|
+
export function useParams() { return {}; }
|
|
708
|
+
export function redirect(url) { window.location.href = url; }
|
|
709
|
+
export function notFound() { throw new Error('Not Found'); }
|
|
710
|
+
`,
|
|
711
|
+
"next/headers": `
|
|
712
|
+
export function cookies() { return { get(){}, getAll(){ return []; }, set(){}, delete(){}, has(){ return false; } }; }
|
|
713
|
+
export function headers() { return new Headers(); }
|
|
714
|
+
`
|
|
715
|
+
};
|
|
716
|
+
return {
|
|
717
|
+
contents: stubs[args.path] || "export default {};",
|
|
718
|
+
loader: "jsx"
|
|
719
|
+
};
|
|
720
|
+
});
|
|
659
721
|
}
|
|
660
722
|
};
|
|
723
|
+
const shimPath = path8.join(outputDir, ".process-shim-preview.js");
|
|
724
|
+
await fs7.writeFile(shimPath, PROCESS_SHIM);
|
|
661
725
|
await esbuild.build({
|
|
662
726
|
entryPoints: [previewEntryPath],
|
|
663
727
|
bundle: true,
|
|
@@ -667,6 +731,7 @@ export default { motion, AnimatePresence };
|
|
|
667
731
|
// Bundle React + core INTO the output (NOT externalized)
|
|
668
732
|
external: [],
|
|
669
733
|
plugins: [serverStubPlugin],
|
|
734
|
+
inject: [shimPath],
|
|
670
735
|
minify: false,
|
|
671
736
|
sourcemap: true,
|
|
672
737
|
target: "es2020",
|
|
@@ -674,6 +739,12 @@ export default { motion, AnimatePresence };
|
|
|
674
739
|
jsxImportSource: "react",
|
|
675
740
|
define: {
|
|
676
741
|
"process.env.NODE_ENV": JSON.stringify("development"),
|
|
742
|
+
"process.env.NEXT_PUBLIC_API_URL": JSON.stringify(
|
|
743
|
+
process.env.NEXT_PUBLIC_API_URL || ""
|
|
744
|
+
),
|
|
745
|
+
"process.env.NEXT_PUBLIC_COMPANY_ID": JSON.stringify(
|
|
746
|
+
process.env.NEXT_PUBLIC_COMPANY_ID || ""
|
|
747
|
+
),
|
|
677
748
|
global: "globalThis"
|
|
678
749
|
},
|
|
679
750
|
loader: { ".tsx": "tsx", ".ts": "ts" },
|
|
@@ -684,13 +755,16 @@ export default { motion, AnimatePresence };
|
|
|
684
755
|
"ignored-bare-import": "silent"
|
|
685
756
|
}
|
|
686
757
|
});
|
|
758
|
+
try {
|
|
759
|
+
await fs7.unlink(shimPath);
|
|
760
|
+
} catch {
|
|
761
|
+
}
|
|
687
762
|
return outputPath;
|
|
688
763
|
}
|
|
689
|
-
var
|
|
764
|
+
var PROCESS_SHIM, reactGlobalPlugin;
|
|
690
765
|
var init_compile_theme = __esm({
|
|
691
766
|
"src/utils/compile-theme.ts"() {
|
|
692
767
|
init_logger();
|
|
693
|
-
import_meta = {};
|
|
694
768
|
PROCESS_SHIM = `
|
|
695
769
|
if (typeof process === "undefined") {
|
|
696
770
|
globalThis.process = {
|
|
@@ -815,18 +889,18 @@ async function renderTemplate(templatePath, data) {
|
|
|
815
889
|
return ejs.render(template, data);
|
|
816
890
|
}
|
|
817
891
|
async function writeFile(filePath, content) {
|
|
818
|
-
await fs.ensureDir(
|
|
892
|
+
await fs.ensureDir(path8.dirname(filePath));
|
|
819
893
|
await fs.writeFile(filePath, content, "utf-8");
|
|
820
894
|
}
|
|
821
895
|
function getTemplatesDir() {
|
|
822
896
|
const locations = [
|
|
823
|
-
|
|
897
|
+
path8.join(__dirname, "../../templates"),
|
|
824
898
|
// Development
|
|
825
|
-
|
|
899
|
+
path8.join(__dirname, "../templates"),
|
|
826
900
|
// Production (dist/)
|
|
827
|
-
|
|
901
|
+
path8.join(process.cwd(), "templates"),
|
|
828
902
|
// Fallback
|
|
829
|
-
|
|
903
|
+
path8.join(process.cwd(), "packages/cli/templates")
|
|
830
904
|
// Monorepo
|
|
831
905
|
];
|
|
832
906
|
for (const location of locations) {
|
|
@@ -838,7 +912,7 @@ function getTemplatesDir() {
|
|
|
838
912
|
}
|
|
839
913
|
async function copyTemplate(templateName, targetDir, data) {
|
|
840
914
|
const templatesDir = getTemplatesDir();
|
|
841
|
-
const templateDir =
|
|
915
|
+
const templateDir = path8.join(templatesDir, templateName);
|
|
842
916
|
if (!fs.existsSync(templateDir)) {
|
|
843
917
|
throw new Error(
|
|
844
918
|
`Template "${templateName}" not found at ${templateDir}. Available templates: ${fs.readdirSync(templatesDir).join(", ")}`
|
|
@@ -847,8 +921,8 @@ async function copyTemplate(templateName, targetDir, data) {
|
|
|
847
921
|
await fs.ensureDir(targetDir);
|
|
848
922
|
const files = await fs.readdir(templateDir);
|
|
849
923
|
for (const file of files) {
|
|
850
|
-
const templatePath =
|
|
851
|
-
const targetPath =
|
|
924
|
+
const templatePath = path8.join(templateDir, file);
|
|
925
|
+
const targetPath = path8.join(targetDir, file);
|
|
852
926
|
const stat = await fs.stat(templatePath);
|
|
853
927
|
if (stat.isDirectory()) {
|
|
854
928
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -865,8 +939,8 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
865
939
|
await fs.ensureDir(targetDir);
|
|
866
940
|
const files = await fs.readdir(templateDir);
|
|
867
941
|
for (const file of files) {
|
|
868
|
-
const templatePath =
|
|
869
|
-
const targetPath =
|
|
942
|
+
const templatePath = path8.join(templateDir, file);
|
|
943
|
+
const targetPath = path8.join(targetDir, file);
|
|
870
944
|
const stat = await fs.stat(templatePath);
|
|
871
945
|
if (stat.isDirectory()) {
|
|
872
946
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -881,32 +955,32 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
881
955
|
}
|
|
882
956
|
function getProjectRoot() {
|
|
883
957
|
let currentDir = process.cwd();
|
|
884
|
-
while (currentDir !==
|
|
885
|
-
const packageJsonPath =
|
|
958
|
+
while (currentDir !== path8.parse(currentDir).root) {
|
|
959
|
+
const packageJsonPath = path8.join(currentDir, "package.json");
|
|
886
960
|
if (fs.existsSync(packageJsonPath)) {
|
|
887
961
|
const packageJson = fs.readJsonSync(packageJsonPath);
|
|
888
|
-
if (packageJson.workspaces || fs.existsSync(
|
|
962
|
+
if (packageJson.workspaces || fs.existsSync(path8.join(currentDir, "src/themes")) || fs.existsSync(path8.join(currentDir, "themes"))) {
|
|
889
963
|
return currentDir;
|
|
890
964
|
}
|
|
891
965
|
}
|
|
892
|
-
currentDir =
|
|
966
|
+
currentDir = path8.dirname(currentDir);
|
|
893
967
|
}
|
|
894
968
|
return process.cwd();
|
|
895
969
|
}
|
|
896
970
|
function getThemesDir() {
|
|
897
971
|
const root = getProjectRoot();
|
|
898
|
-
if (fs.existsSync(
|
|
899
|
-
return
|
|
900
|
-
if (fs.existsSync(
|
|
901
|
-
return
|
|
902
|
-
return
|
|
972
|
+
if (fs.existsSync(path8.join(root, "themes")))
|
|
973
|
+
return path8.join(root, "themes");
|
|
974
|
+
if (fs.existsSync(path8.join(root, "src/themes")))
|
|
975
|
+
return path8.join(root, "src/themes");
|
|
976
|
+
return path8.dirname(root);
|
|
903
977
|
}
|
|
904
978
|
function getFeaturesDir() {
|
|
905
|
-
return
|
|
979
|
+
return path8.join(getProjectRoot(), "src/features");
|
|
906
980
|
}
|
|
907
981
|
function isOneXProject() {
|
|
908
982
|
const root = getProjectRoot();
|
|
909
|
-
return fs.existsSync(
|
|
983
|
+
return fs.existsSync(path8.join(root, "themes")) || fs.existsSync(path8.join(root, "src/themes")) || fs.existsSync(path8.join(root, "theme.config.ts")) || fs.existsSync(path8.join(root, "bundle-entry.ts"));
|
|
910
984
|
}
|
|
911
985
|
function ensureOneXProject() {
|
|
912
986
|
if (!isOneXProject()) {
|
|
@@ -922,13 +996,13 @@ function listThemes() {
|
|
|
922
996
|
return [];
|
|
923
997
|
}
|
|
924
998
|
return fs.readdirSync(themesDir).filter((name) => {
|
|
925
|
-
const themePath =
|
|
926
|
-
return fs.statSync(themePath).isDirectory() && (fs.existsSync(
|
|
999
|
+
const themePath = path8.join(themesDir, name);
|
|
1000
|
+
return fs.statSync(themePath).isDirectory() && (fs.existsSync(path8.join(themePath, "theme.config.ts")) || fs.existsSync(path8.join(themePath, "bundle-entry.ts")) || fs.existsSync(path8.join(themePath, "manifest.ts")));
|
|
927
1001
|
});
|
|
928
1002
|
}
|
|
929
1003
|
function themeExists(themeName) {
|
|
930
|
-
const themePath =
|
|
931
|
-
return fs.existsSync(themePath) && (fs.existsSync(
|
|
1004
|
+
const themePath = path8.join(getThemesDir(), themeName);
|
|
1005
|
+
return fs.existsSync(themePath) && (fs.existsSync(path8.join(themePath, "theme.config.ts")) || fs.existsSync(path8.join(themePath, "bundle-entry.ts")) || fs.existsSync(path8.join(themePath, "manifest.ts")));
|
|
932
1006
|
}
|
|
933
1007
|
function detectPackageManager() {
|
|
934
1008
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
@@ -936,9 +1010,9 @@ function detectPackageManager() {
|
|
|
936
1010
|
if (userAgent.includes("yarn")) return "yarn";
|
|
937
1011
|
if (userAgent.includes("bun")) return "bun";
|
|
938
1012
|
const cwd = process.cwd();
|
|
939
|
-
if (fs.existsSync(
|
|
940
|
-
if (fs.existsSync(
|
|
941
|
-
if (fs.existsSync(
|
|
1013
|
+
if (fs.existsSync(path8.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
1014
|
+
if (fs.existsSync(path8.join(cwd, "yarn.lock"))) return "yarn";
|
|
1015
|
+
if (fs.existsSync(path8.join(cwd, "bun.lockb"))) return "bun";
|
|
942
1016
|
return "npm";
|
|
943
1017
|
}
|
|
944
1018
|
async function installDependencies(projectPath, packageManager = "npm") {
|
|
@@ -1004,7 +1078,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1004
1078
|
if (!validateThemeName(kebabName)) {
|
|
1005
1079
|
return "Invalid project name. Use lowercase letters, numbers, and hyphens only.";
|
|
1006
1080
|
}
|
|
1007
|
-
if (fs2.existsSync(
|
|
1081
|
+
if (fs2.existsSync(path8.join(process.cwd(), kebabName))) {
|
|
1008
1082
|
return `Directory "${kebabName}" already exists`;
|
|
1009
1083
|
}
|
|
1010
1084
|
return true;
|
|
@@ -1015,7 +1089,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1015
1089
|
} else {
|
|
1016
1090
|
name = toKebabCase(projectName);
|
|
1017
1091
|
}
|
|
1018
|
-
const projectPath =
|
|
1092
|
+
const projectPath = path8.join(process.cwd(), name);
|
|
1019
1093
|
if (fs2.existsSync(projectPath)) {
|
|
1020
1094
|
logger.error(`Directory "${name}" already exists.`);
|
|
1021
1095
|
process.exit(1);
|
|
@@ -1078,38 +1152,38 @@ async function initCommand(projectName, options = {}) {
|
|
|
1078
1152
|
try {
|
|
1079
1153
|
fs2.mkdirSync(projectPath, { recursive: true });
|
|
1080
1154
|
await copyTemplate(template, projectPath, data);
|
|
1081
|
-
const srcPath =
|
|
1155
|
+
const srcPath = path8.join(projectPath, "src");
|
|
1082
1156
|
fs2.mkdirSync(srcPath, { recursive: true });
|
|
1083
1157
|
const manifestContent = generateManifest(data);
|
|
1084
|
-
await writeFile(
|
|
1158
|
+
await writeFile(path8.join(srcPath, "manifest.ts"), manifestContent);
|
|
1085
1159
|
const configContent = generateThemeConfig(data);
|
|
1086
|
-
await writeFile(
|
|
1160
|
+
await writeFile(path8.join(srcPath, "config.ts"), configContent);
|
|
1087
1161
|
const layoutContent = generateThemeLayout(data);
|
|
1088
|
-
await writeFile(
|
|
1162
|
+
await writeFile(path8.join(srcPath, "layout.ts"), layoutContent);
|
|
1089
1163
|
const indexContent = generateThemeIndex(data);
|
|
1090
|
-
await writeFile(
|
|
1091
|
-
const sectionsPath =
|
|
1164
|
+
await writeFile(path8.join(srcPath, "index.ts"), indexContent);
|
|
1165
|
+
const sectionsPath = path8.join(srcPath, "sections");
|
|
1092
1166
|
fs2.mkdirSync(sectionsPath, { recursive: true });
|
|
1093
1167
|
await writeFile(
|
|
1094
|
-
|
|
1168
|
+
path8.join(sectionsPath, "README.md"),
|
|
1095
1169
|
`# ${displayName} Sections
|
|
1096
1170
|
|
|
1097
1171
|
Add your theme-specific sections here.
|
|
1098
1172
|
`
|
|
1099
1173
|
);
|
|
1100
|
-
const blocksPath =
|
|
1174
|
+
const blocksPath = path8.join(srcPath, "blocks");
|
|
1101
1175
|
fs2.mkdirSync(blocksPath, { recursive: true });
|
|
1102
1176
|
await writeFile(
|
|
1103
|
-
|
|
1177
|
+
path8.join(blocksPath, "README.md"),
|
|
1104
1178
|
`# ${displayName} Blocks
|
|
1105
1179
|
|
|
1106
1180
|
Add your theme-specific blocks here.
|
|
1107
1181
|
`
|
|
1108
1182
|
);
|
|
1109
|
-
const pagesPath =
|
|
1183
|
+
const pagesPath = path8.join(srcPath, "pages");
|
|
1110
1184
|
fs2.mkdirSync(pagesPath, { recursive: true });
|
|
1111
1185
|
const homePageContent = generateHomePage(data);
|
|
1112
|
-
await writeFile(
|
|
1186
|
+
await writeFile(path8.join(pagesPath, "home.ts"), homePageContent);
|
|
1113
1187
|
logger.stopSpinner(true, "Project structure created!");
|
|
1114
1188
|
if (options.git) {
|
|
1115
1189
|
logger.startSpinner("Initializing git repository...");
|
|
@@ -1121,7 +1195,7 @@ Add your theme-specific blocks here.
|
|
|
1121
1195
|
stdio: "ignore"
|
|
1122
1196
|
});
|
|
1123
1197
|
logger.stopSpinner(true, "Git repository initialized!");
|
|
1124
|
-
} catch
|
|
1198
|
+
} catch {
|
|
1125
1199
|
logger.stopSpinner(false, "Failed to initialize git");
|
|
1126
1200
|
}
|
|
1127
1201
|
}
|
|
@@ -1132,7 +1206,7 @@ Add your theme-specific blocks here.
|
|
|
1132
1206
|
try {
|
|
1133
1207
|
await installDependencies(projectPath, packageManager);
|
|
1134
1208
|
logger.stopSpinner(true, "Dependencies installed!");
|
|
1135
|
-
} catch
|
|
1209
|
+
} catch {
|
|
1136
1210
|
logger.stopSpinner(false, "Failed to install dependencies");
|
|
1137
1211
|
logger.info(
|
|
1138
1212
|
"You can install dependencies manually by running: cd " + name + " && npm install"
|
|
@@ -1408,10 +1482,10 @@ async function createSectionCommand(name, options) {
|
|
|
1408
1482
|
ensureOneXProject();
|
|
1409
1483
|
if (!options.theme) {
|
|
1410
1484
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
1411
|
-
(f) => fs.existsSync(
|
|
1485
|
+
(f) => fs.existsSync(path8.join(process.cwd(), f))
|
|
1412
1486
|
);
|
|
1413
1487
|
if (isStandaloneTheme) {
|
|
1414
|
-
options.theme =
|
|
1488
|
+
options.theme = path8.basename(process.cwd());
|
|
1415
1489
|
}
|
|
1416
1490
|
}
|
|
1417
1491
|
const sectionName = toKebabCase(name);
|
|
@@ -1474,35 +1548,35 @@ async function createSectionCommand(name, options) {
|
|
|
1474
1548
|
};
|
|
1475
1549
|
logger.startSpinner("Creating section files...");
|
|
1476
1550
|
try {
|
|
1477
|
-
const themePath =
|
|
1478
|
-
const sectionPath =
|
|
1551
|
+
const themePath = path8.join(getThemesDir(), themeName);
|
|
1552
|
+
const sectionPath = path8.join(themePath, "sections", sectionName);
|
|
1479
1553
|
const schemaContent = generateSectionSchema(data);
|
|
1480
1554
|
await writeFile(
|
|
1481
|
-
|
|
1555
|
+
path8.join(sectionPath, `${sectionName}.schema.ts`),
|
|
1482
1556
|
schemaContent
|
|
1483
1557
|
);
|
|
1484
1558
|
if (createTemplate) {
|
|
1485
1559
|
const templateContent = generateSectionTemplate(data);
|
|
1486
1560
|
await writeFile(
|
|
1487
|
-
|
|
1561
|
+
path8.join(sectionPath, `${sectionName}-default.tsx`),
|
|
1488
1562
|
templateContent
|
|
1489
1563
|
);
|
|
1490
1564
|
}
|
|
1491
1565
|
const indexContent = generateSectionIndex(data, createTemplate);
|
|
1492
|
-
await writeFile(
|
|
1566
|
+
await writeFile(path8.join(sectionPath, "index.ts"), indexContent);
|
|
1493
1567
|
logger.stopSpinner(true, "Section files created successfully!");
|
|
1494
1568
|
logger.newLine();
|
|
1495
1569
|
logger.section("Next steps:");
|
|
1496
1570
|
logger.log(
|
|
1497
|
-
` 1. Edit schema: ${
|
|
1571
|
+
` 1. Edit schema: ${path8.relative(process.cwd(), path8.join(sectionPath, `${sectionName}.schema.ts`))}`
|
|
1498
1572
|
);
|
|
1499
1573
|
if (createTemplate) {
|
|
1500
1574
|
logger.log(
|
|
1501
|
-
` 2. Edit template: ${
|
|
1575
|
+
` 2. Edit template: ${path8.relative(process.cwd(), path8.join(sectionPath, `${sectionName}-default.tsx`))}`
|
|
1502
1576
|
);
|
|
1503
1577
|
}
|
|
1504
1578
|
logger.log(
|
|
1505
|
-
` 3. Add to theme manifest: ${
|
|
1579
|
+
` 3. Add to theme manifest: ${path8.relative(process.cwd(), path8.join(themePath, "manifest.ts"))}`
|
|
1506
1580
|
);
|
|
1507
1581
|
logger.newLine();
|
|
1508
1582
|
logger.success("Section created successfully!");
|
|
@@ -1650,10 +1724,10 @@ async function createBlockCommand(name, options) {
|
|
|
1650
1724
|
ensureOneXProject();
|
|
1651
1725
|
if (!options.theme) {
|
|
1652
1726
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
1653
|
-
(f) => fs.existsSync(
|
|
1727
|
+
(f) => fs.existsSync(path8.join(process.cwd(), f))
|
|
1654
1728
|
);
|
|
1655
1729
|
if (isStandaloneTheme) {
|
|
1656
|
-
options.theme =
|
|
1730
|
+
options.theme = path8.basename(process.cwd());
|
|
1657
1731
|
}
|
|
1658
1732
|
}
|
|
1659
1733
|
const blockName = toKebabCase(name);
|
|
@@ -1728,24 +1802,24 @@ async function createBlockCommand(name, options) {
|
|
|
1728
1802
|
};
|
|
1729
1803
|
logger.startSpinner("Creating block files...");
|
|
1730
1804
|
try {
|
|
1731
|
-
const blockPath = scope === "shared" ?
|
|
1805
|
+
const blockPath = scope === "shared" ? path8.join(getFeaturesDir(), "blocks", blockName) : path8.join(getThemesDir(), themeName, "blocks", blockName);
|
|
1732
1806
|
const schemaContent = generateBlockSchema(data);
|
|
1733
1807
|
await writeFile(
|
|
1734
|
-
|
|
1808
|
+
path8.join(blockPath, `${blockName}.schema.ts`),
|
|
1735
1809
|
schemaContent
|
|
1736
1810
|
);
|
|
1737
1811
|
const componentContent = generateBlockComponent(data);
|
|
1738
|
-
await writeFile(
|
|
1812
|
+
await writeFile(path8.join(blockPath, `${blockName}.tsx`), componentContent);
|
|
1739
1813
|
const indexContent = generateBlockIndex(data);
|
|
1740
|
-
await writeFile(
|
|
1814
|
+
await writeFile(path8.join(blockPath, "index.ts"), indexContent);
|
|
1741
1815
|
logger.stopSpinner(true, "Block files created successfully!");
|
|
1742
1816
|
logger.newLine();
|
|
1743
1817
|
logger.section("Next steps:");
|
|
1744
1818
|
logger.log(
|
|
1745
|
-
` 1. Edit schema: ${
|
|
1819
|
+
` 1. Edit schema: ${path8.relative(process.cwd(), path8.join(blockPath, `${blockName}.schema.ts`))}`
|
|
1746
1820
|
);
|
|
1747
1821
|
logger.log(
|
|
1748
|
-
` 2. Edit component: ${
|
|
1822
|
+
` 2. Edit component: ${path8.relative(process.cwd(), path8.join(blockPath, `${blockName}.tsx`))}`
|
|
1749
1823
|
);
|
|
1750
1824
|
logger.log(
|
|
1751
1825
|
` 3. Register in block registry: src/lib/registry/block-registry.ts`
|
|
@@ -1923,31 +1997,31 @@ async function createComponentCommand(name, options) {
|
|
|
1923
1997
|
};
|
|
1924
1998
|
logger.startSpinner("Creating component files...");
|
|
1925
1999
|
try {
|
|
1926
|
-
const componentPath =
|
|
2000
|
+
const componentPath = path8.join(
|
|
1927
2001
|
getFeaturesDir(),
|
|
1928
2002
|
"components",
|
|
1929
2003
|
componentName
|
|
1930
2004
|
);
|
|
1931
2005
|
const schemaContent = generateComponentSchema(data);
|
|
1932
2006
|
await writeFile(
|
|
1933
|
-
|
|
2007
|
+
path8.join(componentPath, `${componentName}.schema.ts`),
|
|
1934
2008
|
schemaContent
|
|
1935
2009
|
);
|
|
1936
2010
|
const componentContent = generateComponent(data);
|
|
1937
2011
|
await writeFile(
|
|
1938
|
-
|
|
2012
|
+
path8.join(componentPath, `${componentName}.tsx`),
|
|
1939
2013
|
componentContent
|
|
1940
2014
|
);
|
|
1941
2015
|
const indexContent = generateComponentIndex(data);
|
|
1942
|
-
await writeFile(
|
|
2016
|
+
await writeFile(path8.join(componentPath, "index.ts"), indexContent);
|
|
1943
2017
|
logger.stopSpinner(true, "Component files created successfully!");
|
|
1944
2018
|
logger.newLine();
|
|
1945
2019
|
logger.section("Next steps:");
|
|
1946
2020
|
logger.log(
|
|
1947
|
-
` 1. Edit schema: ${
|
|
2021
|
+
` 1. Edit schema: ${path8.relative(process.cwd(), path8.join(componentPath, `${componentName}.schema.ts`))}`
|
|
1948
2022
|
);
|
|
1949
2023
|
logger.log(
|
|
1950
|
-
` 2. Edit component: ${
|
|
2024
|
+
` 2. Edit component: ${path8.relative(process.cwd(), path8.join(componentPath, `${componentName}.tsx`))}`
|
|
1951
2025
|
);
|
|
1952
2026
|
logger.log(
|
|
1953
2027
|
` 3. Register in component registry: src/lib/registry/component-registry.ts`
|
|
@@ -2104,13 +2178,13 @@ async function listSections(themeFilter) {
|
|
|
2104
2178
|
return;
|
|
2105
2179
|
}
|
|
2106
2180
|
for (const theme of themes) {
|
|
2107
|
-
const sectionsDir =
|
|
2181
|
+
const sectionsDir = path8.join(getThemesDir(), theme, "sections");
|
|
2108
2182
|
if (!fs.existsSync(sectionsDir)) {
|
|
2109
2183
|
continue;
|
|
2110
2184
|
}
|
|
2111
2185
|
const sections = fs.readdirSync(sectionsDir).filter((name) => {
|
|
2112
|
-
const sectionPath =
|
|
2113
|
-
return fs.statSync(sectionPath).isDirectory() && fs.existsSync(
|
|
2186
|
+
const sectionPath = path8.join(sectionsDir, name);
|
|
2187
|
+
return fs.statSync(sectionPath).isDirectory() && fs.existsSync(path8.join(sectionPath, "index.ts"));
|
|
2114
2188
|
});
|
|
2115
2189
|
if (sections.length > 0) {
|
|
2116
2190
|
logger.log(chalk4.cyan(`
|
|
@@ -2124,11 +2198,11 @@ async function listSections(themeFilter) {
|
|
|
2124
2198
|
}
|
|
2125
2199
|
async function listBlocks(themeFilter) {
|
|
2126
2200
|
logger.section("\u{1F9F1} Blocks");
|
|
2127
|
-
const sharedBlocksDir =
|
|
2201
|
+
const sharedBlocksDir = path8.join(getFeaturesDir(), "blocks");
|
|
2128
2202
|
if (fs.existsSync(sharedBlocksDir)) {
|
|
2129
2203
|
const sharedBlocks = fs.readdirSync(sharedBlocksDir).filter((name) => {
|
|
2130
|
-
const blockPath =
|
|
2131
|
-
return fs.statSync(blockPath).isDirectory() && fs.existsSync(
|
|
2204
|
+
const blockPath = path8.join(sharedBlocksDir, name);
|
|
2205
|
+
return fs.statSync(blockPath).isDirectory() && fs.existsSync(path8.join(blockPath, "index.ts"));
|
|
2132
2206
|
});
|
|
2133
2207
|
if (sharedBlocks.length > 0) {
|
|
2134
2208
|
logger.log(chalk4.cyan("\n Shared:"));
|
|
@@ -2139,13 +2213,13 @@ async function listBlocks(themeFilter) {
|
|
|
2139
2213
|
}
|
|
2140
2214
|
const themes = themeFilter ? [themeFilter] : listThemes();
|
|
2141
2215
|
for (const theme of themes) {
|
|
2142
|
-
const blocksDir =
|
|
2216
|
+
const blocksDir = path8.join(getThemesDir(), theme, "blocks");
|
|
2143
2217
|
if (!fs.existsSync(blocksDir)) {
|
|
2144
2218
|
continue;
|
|
2145
2219
|
}
|
|
2146
2220
|
const blocks = fs.readdirSync(blocksDir).filter((name) => {
|
|
2147
|
-
const blockPath =
|
|
2148
|
-
return fs.statSync(blockPath).isDirectory() && fs.existsSync(
|
|
2221
|
+
const blockPath = path8.join(blocksDir, name);
|
|
2222
|
+
return fs.statSync(blockPath).isDirectory() && fs.existsSync(path8.join(blockPath, "index.ts"));
|
|
2149
2223
|
});
|
|
2150
2224
|
if (blocks.length > 0) {
|
|
2151
2225
|
logger.log(chalk4.cyan(`
|
|
@@ -2159,14 +2233,14 @@ async function listBlocks(themeFilter) {
|
|
|
2159
2233
|
}
|
|
2160
2234
|
async function listComponents() {
|
|
2161
2235
|
logger.section("\u2699\uFE0F Components");
|
|
2162
|
-
const componentsDir =
|
|
2236
|
+
const componentsDir = path8.join(getFeaturesDir(), "components");
|
|
2163
2237
|
if (!fs.existsSync(componentsDir)) {
|
|
2164
2238
|
logger.warning("No components directory found");
|
|
2165
2239
|
return;
|
|
2166
2240
|
}
|
|
2167
2241
|
const components = fs.readdirSync(componentsDir).filter((name) => {
|
|
2168
|
-
const componentPath =
|
|
2169
|
-
return fs.statSync(componentPath).isDirectory() && fs.existsSync(
|
|
2242
|
+
const componentPath = path8.join(componentsDir, name);
|
|
2243
|
+
return fs.statSync(componentPath).isDirectory() && fs.existsSync(path8.join(componentPath, "index.ts"));
|
|
2170
2244
|
});
|
|
2171
2245
|
if (components.length === 0) {
|
|
2172
2246
|
logger.warning("No components found");
|
|
@@ -2187,11 +2261,11 @@ async function listThemesInfo() {
|
|
|
2187
2261
|
}
|
|
2188
2262
|
logger.log("");
|
|
2189
2263
|
for (const theme of themes) {
|
|
2190
|
-
const themeDir =
|
|
2264
|
+
const themeDir = path8.join(getThemesDir(), theme);
|
|
2191
2265
|
const candidates = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"];
|
|
2192
2266
|
let manifestContent = "";
|
|
2193
2267
|
for (const candidate of candidates) {
|
|
2194
|
-
const candidatePath =
|
|
2268
|
+
const candidatePath = path8.join(themeDir, candidate);
|
|
2195
2269
|
if (fs.existsSync(candidatePath)) {
|
|
2196
2270
|
manifestContent = fs.readFileSync(candidatePath, "utf-8");
|
|
2197
2271
|
break;
|
|
@@ -2229,9 +2303,9 @@ async function validateCommand(options) {
|
|
|
2229
2303
|
"theme.config.ts",
|
|
2230
2304
|
"bundle-entry.ts",
|
|
2231
2305
|
"manifest.ts"
|
|
2232
|
-
].some((f) => fs.existsSync(
|
|
2306
|
+
].some((f) => fs.existsSync(path8.join(process.cwd(), f)));
|
|
2233
2307
|
if (isThemeDir) {
|
|
2234
|
-
themeToValidate =
|
|
2308
|
+
themeToValidate = path8.basename(process.cwd());
|
|
2235
2309
|
logger.info(`Validating current theme: ${themeToValidate}`);
|
|
2236
2310
|
} else {
|
|
2237
2311
|
logger.error(
|
|
@@ -2240,11 +2314,11 @@ async function validateCommand(options) {
|
|
|
2240
2314
|
process.exit(1);
|
|
2241
2315
|
}
|
|
2242
2316
|
}
|
|
2243
|
-
const themePath =
|
|
2317
|
+
const themePath = path8.join(getThemesDir(), themeToValidate);
|
|
2244
2318
|
logger.startSpinner("Running validation checks...");
|
|
2245
2319
|
const entryFiles = ["manifest.ts", "theme.config.ts", "bundle-entry.ts"];
|
|
2246
2320
|
const foundEntry = entryFiles.find(
|
|
2247
|
-
(f) => fs.existsSync(
|
|
2321
|
+
(f) => fs.existsSync(path8.join(themePath, f))
|
|
2248
2322
|
);
|
|
2249
2323
|
if (!foundEntry) {
|
|
2250
2324
|
issues.push({
|
|
@@ -2254,7 +2328,7 @@ async function validateCommand(options) {
|
|
|
2254
2328
|
});
|
|
2255
2329
|
} else if (foundEntry === "manifest.ts") {
|
|
2256
2330
|
const manifestContent = fs.readFileSync(
|
|
2257
|
-
|
|
2331
|
+
path8.join(themePath, foundEntry),
|
|
2258
2332
|
"utf-8"
|
|
2259
2333
|
);
|
|
2260
2334
|
if (!manifestContent.includes("export const") && !manifestContent.includes("export default") && !manifestContent.includes("export interface")) {
|
|
@@ -2265,7 +2339,7 @@ async function validateCommand(options) {
|
|
|
2265
2339
|
});
|
|
2266
2340
|
}
|
|
2267
2341
|
}
|
|
2268
|
-
const configPath =
|
|
2342
|
+
const configPath = path8.join(themePath, "theme.config.ts");
|
|
2269
2343
|
if (!fs.existsSync(configPath)) {
|
|
2270
2344
|
issues.push({
|
|
2271
2345
|
type: "warning",
|
|
@@ -2273,7 +2347,7 @@ async function validateCommand(options) {
|
|
|
2273
2347
|
message: "Theme config file not found (recommended)"
|
|
2274
2348
|
});
|
|
2275
2349
|
}
|
|
2276
|
-
const indexPath =
|
|
2350
|
+
const indexPath = path8.join(themePath, "index.ts");
|
|
2277
2351
|
if (!fs.existsSync(indexPath)) {
|
|
2278
2352
|
issues.push({
|
|
2279
2353
|
type: "warning",
|
|
@@ -2281,7 +2355,7 @@ async function validateCommand(options) {
|
|
|
2281
2355
|
message: "Index file not found (recommended)"
|
|
2282
2356
|
});
|
|
2283
2357
|
}
|
|
2284
|
-
const sectionsDir =
|
|
2358
|
+
const sectionsDir = path8.join(themePath, "sections");
|
|
2285
2359
|
if (!fs.existsSync(sectionsDir)) {
|
|
2286
2360
|
issues.push({
|
|
2287
2361
|
type: "warning",
|
|
@@ -2290,16 +2364,16 @@ async function validateCommand(options) {
|
|
|
2290
2364
|
});
|
|
2291
2365
|
} else {
|
|
2292
2366
|
const sections = fs.readdirSync(sectionsDir).filter(
|
|
2293
|
-
(name) => fs.statSync(
|
|
2367
|
+
(name) => fs.statSync(path8.join(sectionsDir, name)).isDirectory()
|
|
2294
2368
|
);
|
|
2295
2369
|
for (const sectionName of sections) {
|
|
2296
|
-
const sectionPath =
|
|
2297
|
-
const schemaFile =
|
|
2298
|
-
const defaultTemplate =
|
|
2370
|
+
const sectionPath = path8.join(sectionsDir, sectionName);
|
|
2371
|
+
const schemaFile = path8.join(sectionPath, `${sectionName}.schema.ts`);
|
|
2372
|
+
const defaultTemplate = path8.join(
|
|
2299
2373
|
sectionPath,
|
|
2300
2374
|
`${sectionName}-default.tsx`
|
|
2301
2375
|
);
|
|
2302
|
-
const indexFile =
|
|
2376
|
+
const indexFile = path8.join(sectionPath, "index.ts");
|
|
2303
2377
|
if (!fs.existsSync(schemaFile)) {
|
|
2304
2378
|
issues.push({
|
|
2305
2379
|
type: "error",
|
|
@@ -2323,14 +2397,14 @@ async function validateCommand(options) {
|
|
|
2323
2397
|
}
|
|
2324
2398
|
}
|
|
2325
2399
|
}
|
|
2326
|
-
const blocksDir =
|
|
2400
|
+
const blocksDir = path8.join(themePath, "blocks");
|
|
2327
2401
|
if (fs.existsSync(blocksDir)) {
|
|
2328
|
-
const blocks = fs.readdirSync(blocksDir).filter((name) => fs.statSync(
|
|
2402
|
+
const blocks = fs.readdirSync(blocksDir).filter((name) => fs.statSync(path8.join(blocksDir, name)).isDirectory());
|
|
2329
2403
|
for (const blockName of blocks) {
|
|
2330
|
-
const blockPath =
|
|
2331
|
-
const schemaFile =
|
|
2332
|
-
const componentFile =
|
|
2333
|
-
const indexFile =
|
|
2404
|
+
const blockPath = path8.join(blocksDir, blockName);
|
|
2405
|
+
const schemaFile = path8.join(blockPath, `${blockName}.schema.ts`);
|
|
2406
|
+
const componentFile = path8.join(blockPath, `${blockName}.tsx`);
|
|
2407
|
+
const indexFile = path8.join(blockPath, "index.ts");
|
|
2334
2408
|
if (!fs.existsSync(schemaFile)) {
|
|
2335
2409
|
issues.push({
|
|
2336
2410
|
type: "error",
|
|
@@ -2396,21 +2470,20 @@ async function validateCommand(options) {
|
|
|
2396
2470
|
// src/commands/build.ts
|
|
2397
2471
|
init_logger();
|
|
2398
2472
|
async function buildCommand(options) {
|
|
2399
|
-
var _a;
|
|
2400
2473
|
logger.header("Build Theme");
|
|
2401
2474
|
let themePath;
|
|
2402
2475
|
let themeName;
|
|
2403
2476
|
if (options.theme) {
|
|
2404
2477
|
themeName = options.theme;
|
|
2405
2478
|
try {
|
|
2406
|
-
const workspaceThemePath =
|
|
2479
|
+
const workspaceThemePath = path8.join(getThemesDir(), themeName);
|
|
2407
2480
|
if (fs.existsSync(workspaceThemePath)) {
|
|
2408
2481
|
themePath = workspaceThemePath;
|
|
2409
2482
|
} else {
|
|
2410
|
-
themePath =
|
|
2483
|
+
themePath = path8.join(process.cwd(), themeName);
|
|
2411
2484
|
}
|
|
2412
|
-
} catch
|
|
2413
|
-
themePath =
|
|
2485
|
+
} catch {
|
|
2486
|
+
themePath = path8.join(process.cwd(), themeName);
|
|
2414
2487
|
}
|
|
2415
2488
|
if (!fs.existsSync(themePath)) {
|
|
2416
2489
|
logger.error(`Theme "${themeName}" not found.`);
|
|
@@ -2421,10 +2494,10 @@ async function buildCommand(options) {
|
|
|
2421
2494
|
"theme.config.ts",
|
|
2422
2495
|
"bundle-entry.ts",
|
|
2423
2496
|
"manifest.ts"
|
|
2424
|
-
].some((f) => fs.existsSync(
|
|
2497
|
+
].some((f) => fs.existsSync(path8.join(process.cwd(), f)));
|
|
2425
2498
|
if (isThemeDir) {
|
|
2426
2499
|
themePath = process.cwd();
|
|
2427
|
-
themeName =
|
|
2500
|
+
themeName = path8.basename(themePath);
|
|
2428
2501
|
logger.info(`Building current theme: ${themeName}`);
|
|
2429
2502
|
} else {
|
|
2430
2503
|
logger.error(
|
|
@@ -2433,7 +2506,7 @@ async function buildCommand(options) {
|
|
|
2433
2506
|
process.exit(1);
|
|
2434
2507
|
}
|
|
2435
2508
|
}
|
|
2436
|
-
const packageJsonPath =
|
|
2509
|
+
const packageJsonPath = path8.join(themePath, "package.json");
|
|
2437
2510
|
const hasPkgJson = fs.existsSync(packageJsonPath);
|
|
2438
2511
|
if (!hasPkgJson) {
|
|
2439
2512
|
logger.warning(
|
|
@@ -2466,7 +2539,7 @@ async function buildCommand(options) {
|
|
|
2466
2539
|
}
|
|
2467
2540
|
logger.stopSpinner(true, "Lint passed");
|
|
2468
2541
|
const pkgJson = fs.readJsonSync(packageJsonPath);
|
|
2469
|
-
const buildScript =
|
|
2542
|
+
const buildScript = pkgJson.scripts?.build || "";
|
|
2470
2543
|
const isRecursive = buildScript.includes("onex build") || buildScript.includes("onex-cli build");
|
|
2471
2544
|
logger.startSpinner(
|
|
2472
2545
|
options.watch ? "Building (watch mode)..." : "Building..."
|
|
@@ -2489,9 +2562,9 @@ async function buildCommand(options) {
|
|
|
2489
2562
|
logger.success("\u2713 Theme built successfully!");
|
|
2490
2563
|
logger.newLine();
|
|
2491
2564
|
logger.info(`Theme: ${themeName}`);
|
|
2492
|
-
const distPath =
|
|
2565
|
+
const distPath = path8.join(themePath, "dist");
|
|
2493
2566
|
if (fs.existsSync(distPath)) {
|
|
2494
|
-
logger.log(`Output: ${
|
|
2567
|
+
logger.log(`Output: ${path8.relative(process.cwd(), distPath)}`);
|
|
2495
2568
|
const files = fs.readdirSync(distPath);
|
|
2496
2569
|
logger.log(`Files: ${files.length}`);
|
|
2497
2570
|
}
|
|
@@ -2529,7 +2602,7 @@ async function packageCommand(options) {
|
|
|
2529
2602
|
let themeName;
|
|
2530
2603
|
if (options.theme) {
|
|
2531
2604
|
themeName = options.theme;
|
|
2532
|
-
themePath =
|
|
2605
|
+
themePath = path8.join(getThemesDir(), themeName);
|
|
2533
2606
|
if (!fs.existsSync(themePath)) {
|
|
2534
2607
|
logger.error(`Theme "${themeName}" not found.`);
|
|
2535
2608
|
process.exit(1);
|
|
@@ -2539,10 +2612,10 @@ async function packageCommand(options) {
|
|
|
2539
2612
|
"theme.config.ts",
|
|
2540
2613
|
"bundle-entry.ts",
|
|
2541
2614
|
"manifest.ts"
|
|
2542
|
-
].some((f) => fs.existsSync(
|
|
2615
|
+
].some((f) => fs.existsSync(path8.join(process.cwd(), f)));
|
|
2543
2616
|
if (isThemeDir) {
|
|
2544
2617
|
themePath = process.cwd();
|
|
2545
|
-
themeName =
|
|
2618
|
+
themeName = path8.basename(themePath);
|
|
2546
2619
|
logger.info(`Packaging current theme: ${themeName}`);
|
|
2547
2620
|
} else {
|
|
2548
2621
|
logger.error(
|
|
@@ -2551,7 +2624,7 @@ async function packageCommand(options) {
|
|
|
2551
2624
|
process.exit(1);
|
|
2552
2625
|
}
|
|
2553
2626
|
}
|
|
2554
|
-
const packageJsonPath =
|
|
2627
|
+
const packageJsonPath = path8.join(themePath, "package.json");
|
|
2555
2628
|
let version = "1.0.0";
|
|
2556
2629
|
if (fs.existsSync(packageJsonPath)) {
|
|
2557
2630
|
const packageJson = await fs.readJson(packageJsonPath);
|
|
@@ -2561,7 +2634,7 @@ async function packageCommand(options) {
|
|
|
2561
2634
|
logger.info(`Theme: ${themeName}`);
|
|
2562
2635
|
logger.info(`Version: ${version}`);
|
|
2563
2636
|
logger.newLine();
|
|
2564
|
-
const compiledThemePath =
|
|
2637
|
+
const compiledThemePath = path8.join(
|
|
2565
2638
|
process.cwd(),
|
|
2566
2639
|
"themes",
|
|
2567
2640
|
themeName,
|
|
@@ -2595,8 +2668,8 @@ async function packageCommand(options) {
|
|
|
2595
2668
|
logger.newLine();
|
|
2596
2669
|
logger.section("Step 2: Create Package");
|
|
2597
2670
|
const packageName = options.name || `${themeName}-${version}`;
|
|
2598
|
-
const outputDir = options.output ||
|
|
2599
|
-
const outputPath =
|
|
2671
|
+
const outputDir = options.output || path8.join(process.cwd(), "dist");
|
|
2672
|
+
const outputPath = path8.join(outputDir, `${packageName}.zip`);
|
|
2600
2673
|
await fs.ensureDir(outputDir);
|
|
2601
2674
|
logger.startSpinner("Creating zip archive...");
|
|
2602
2675
|
try {
|
|
@@ -2609,11 +2682,11 @@ async function packageCommand(options) {
|
|
|
2609
2682
|
logger.newLine();
|
|
2610
2683
|
logger.info(`Package: ${packageName}.zip`);
|
|
2611
2684
|
logger.log(`Size: ${sizeMB} MB`);
|
|
2612
|
-
logger.log(`Location: ${
|
|
2685
|
+
logger.log(`Location: ${path8.relative(process.cwd(), outputPath)}`);
|
|
2613
2686
|
logger.newLine();
|
|
2614
2687
|
logger.section("Next steps:");
|
|
2615
2688
|
logger.log(
|
|
2616
|
-
` onex deploy --package ${
|
|
2689
|
+
` onex deploy --package ${path8.relative(process.cwd(), outputPath)}`
|
|
2617
2690
|
);
|
|
2618
2691
|
} catch (error) {
|
|
2619
2692
|
logger.stopSpinner(false, "Failed to create package");
|
|
@@ -2671,9 +2744,9 @@ async function deployCommand(options) {
|
|
|
2671
2744
|
ensureOneXProject();
|
|
2672
2745
|
let packagePath;
|
|
2673
2746
|
if (options.package) {
|
|
2674
|
-
packagePath =
|
|
2747
|
+
packagePath = path8.resolve(options.package);
|
|
2675
2748
|
} else if (options.theme) {
|
|
2676
|
-
const distDir =
|
|
2749
|
+
const distDir = path8.join(process.cwd(), "dist");
|
|
2677
2750
|
if (!fs.existsSync(distDir)) {
|
|
2678
2751
|
logger.error("No dist/ directory found. Run 'onex package' first.");
|
|
2679
2752
|
process.exit(1);
|
|
@@ -2688,7 +2761,7 @@ async function deployCommand(options) {
|
|
|
2688
2761
|
process.exit(1);
|
|
2689
2762
|
}
|
|
2690
2763
|
packageFiles.sort().reverse();
|
|
2691
|
-
packagePath =
|
|
2764
|
+
packagePath = path8.join(distDir, packageFiles[0]);
|
|
2692
2765
|
} else {
|
|
2693
2766
|
logger.error("Either --package or --theme must be specified.");
|
|
2694
2767
|
logger.info("Examples:");
|
|
@@ -2702,11 +2775,11 @@ async function deployCommand(options) {
|
|
|
2702
2775
|
}
|
|
2703
2776
|
const stats = await fs.stat(packagePath);
|
|
2704
2777
|
const sizeMB = (stats.size / 1024 / 1024).toFixed(2);
|
|
2705
|
-
const fileName =
|
|
2778
|
+
const fileName = path8.basename(packagePath);
|
|
2706
2779
|
logger.newLine();
|
|
2707
2780
|
logger.info(`Package: ${fileName}`);
|
|
2708
2781
|
logger.log(`Size: ${sizeMB} MB`);
|
|
2709
|
-
logger.log(`Path: ${
|
|
2782
|
+
logger.log(`Path: ${path8.relative(process.cwd(), packagePath)}`);
|
|
2710
2783
|
logger.newLine();
|
|
2711
2784
|
const apiUrl = options.apiUrl || process.env.ONEX_API_URL || "http://localhost:3001";
|
|
2712
2785
|
const uploadEndpoint = `${apiUrl}/api/themes/upload`;
|
|
@@ -2810,11 +2883,11 @@ function getBucketName(env) {
|
|
|
2810
2883
|
return environment === "production" ? "onex-themes-prod" : "onex-themes-staging";
|
|
2811
2884
|
}
|
|
2812
2885
|
async function findCompiledThemeDir(themeId, version) {
|
|
2813
|
-
const searchPaths = [
|
|
2886
|
+
const searchPaths = [path8.resolve(process.cwd(), "dist")];
|
|
2814
2887
|
for (const dir of searchPaths) {
|
|
2815
2888
|
if (await fs.pathExists(dir)) {
|
|
2816
|
-
const hasManifest = await fs.pathExists(
|
|
2817
|
-
const hasThemeEntry = await fs.pathExists(
|
|
2889
|
+
const hasManifest = await fs.pathExists(path8.join(dir, "manifest.json"));
|
|
2890
|
+
const hasThemeEntry = await fs.pathExists(path8.join(dir, "bundle-entry.js")) || await fs.pathExists(path8.join(dir, "theme.config.js")) || await fs.pathExists(path8.join(dir, "index.js"));
|
|
2818
2891
|
if (hasManifest || hasThemeEntry) {
|
|
2819
2892
|
return dir;
|
|
2820
2893
|
}
|
|
@@ -2823,8 +2896,7 @@ async function findCompiledThemeDir(themeId, version) {
|
|
|
2823
2896
|
return null;
|
|
2824
2897
|
}
|
|
2825
2898
|
async function readManifest() {
|
|
2826
|
-
|
|
2827
|
-
const manifestTsPath = path.resolve(process.cwd(), "manifest.ts");
|
|
2899
|
+
const manifestTsPath = path8.resolve(process.cwd(), "manifest.ts");
|
|
2828
2900
|
if (await fs.pathExists(manifestTsPath)) {
|
|
2829
2901
|
try {
|
|
2830
2902
|
const module = await import(manifestTsPath);
|
|
@@ -2833,11 +2905,11 @@ async function readManifest() {
|
|
|
2833
2905
|
logger.warning("Failed to import manifest.ts, trying package.json");
|
|
2834
2906
|
}
|
|
2835
2907
|
}
|
|
2836
|
-
const packageJsonPath =
|
|
2908
|
+
const packageJsonPath = path8.resolve(process.cwd(), "package.json");
|
|
2837
2909
|
if (await fs.pathExists(packageJsonPath)) {
|
|
2838
2910
|
const pkg = await fs.readJson(packageJsonPath);
|
|
2839
2911
|
return {
|
|
2840
|
-
themeId:
|
|
2912
|
+
themeId: pkg.name?.replace("@onex-themes/", "") || "unknown",
|
|
2841
2913
|
version: pkg.version || "1.0.0"
|
|
2842
2914
|
};
|
|
2843
2915
|
}
|
|
@@ -2867,13 +2939,13 @@ async function findSourceDir(themeId, explicitDir) {
|
|
|
2867
2939
|
}
|
|
2868
2940
|
const searchPaths = [
|
|
2869
2941
|
process.cwd(),
|
|
2870
|
-
|
|
2871
|
-
|
|
2942
|
+
path8.resolve(process.cwd(), `../../themes/${themeId}`),
|
|
2943
|
+
path8.resolve(process.cwd(), `../themes/${themeId}`)
|
|
2872
2944
|
];
|
|
2873
2945
|
const markers = ["theme.config.ts", "bundle-entry.ts"];
|
|
2874
2946
|
for (const dir of searchPaths) {
|
|
2875
2947
|
for (const marker of markers) {
|
|
2876
|
-
if (await fs.pathExists(
|
|
2948
|
+
if (await fs.pathExists(path8.join(dir, marker))) {
|
|
2877
2949
|
return dir;
|
|
2878
2950
|
}
|
|
2879
2951
|
}
|
|
@@ -2925,7 +2997,7 @@ async function uploadCommand(options) {
|
|
|
2925
2997
|
spinner.succeed(`Found compiled theme at: ${compiledDir}`);
|
|
2926
2998
|
spinner.start("Creating bundle.zip...");
|
|
2927
2999
|
const tmpDir = os.tmpdir();
|
|
2928
|
-
const bundleZipPath =
|
|
3000
|
+
const bundleZipPath = path8.join(tmpDir, `${themeId}-${version}-bundle.zip`);
|
|
2929
3001
|
await createZipFromDir(compiledDir, bundleZipPath);
|
|
2930
3002
|
const bundleZipBuffer = await fs.readFile(bundleZipPath);
|
|
2931
3003
|
const bundleSizeMB = (bundleZipBuffer.length / 1024 / 1024).toFixed(2);
|
|
@@ -2979,7 +3051,7 @@ async function uploadCommand(options) {
|
|
|
2979
3051
|
if (sourceDir) {
|
|
2980
3052
|
spinner.succeed(`Found source at: ${sourceDir}`);
|
|
2981
3053
|
spinner.start("Creating source.zip...");
|
|
2982
|
-
const sourceZipPath =
|
|
3054
|
+
const sourceZipPath = path8.join(
|
|
2983
3055
|
tmpDir,
|
|
2984
3056
|
`${themeId}-${version}-source.zip`
|
|
2985
3057
|
);
|
|
@@ -3081,39 +3153,15 @@ function getBucketName2(env) {
|
|
|
3081
3153
|
}
|
|
3082
3154
|
async function streamToString(stream) {
|
|
3083
3155
|
const chunks = [];
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
const chunk = temp.value;
|
|
3087
|
-
chunks.push(Buffer.from(chunk));
|
|
3088
|
-
}
|
|
3089
|
-
} catch (temp) {
|
|
3090
|
-
error = [temp];
|
|
3091
|
-
} finally {
|
|
3092
|
-
try {
|
|
3093
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3094
|
-
} finally {
|
|
3095
|
-
if (error)
|
|
3096
|
-
throw error[0];
|
|
3097
|
-
}
|
|
3156
|
+
for await (const chunk of stream) {
|
|
3157
|
+
chunks.push(Buffer.from(chunk));
|
|
3098
3158
|
}
|
|
3099
3159
|
return Buffer.concat(chunks).toString("utf-8");
|
|
3100
3160
|
}
|
|
3101
3161
|
async function streamToBuffer(stream) {
|
|
3102
3162
|
const chunks = [];
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
const chunk = temp.value;
|
|
3106
|
-
chunks.push(Buffer.from(chunk));
|
|
3107
|
-
}
|
|
3108
|
-
} catch (temp) {
|
|
3109
|
-
error = [temp];
|
|
3110
|
-
} finally {
|
|
3111
|
-
try {
|
|
3112
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3113
|
-
} finally {
|
|
3114
|
-
if (error)
|
|
3115
|
-
throw error[0];
|
|
3116
|
-
}
|
|
3163
|
+
for await (const chunk of stream) {
|
|
3164
|
+
chunks.push(Buffer.from(chunk));
|
|
3117
3165
|
}
|
|
3118
3166
|
return Buffer.concat(chunks);
|
|
3119
3167
|
}
|
|
@@ -3135,11 +3183,10 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
|
|
|
3135
3183
|
}
|
|
3136
3184
|
}
|
|
3137
3185
|
async function createCompatibilityFiles(outputDir, manifest) {
|
|
3138
|
-
|
|
3139
|
-
const entryFile = ((_a = manifest.output) == null ? void 0 : _a.entry) || "bundle-entry.js";
|
|
3186
|
+
const entryFile = manifest.output?.entry || "bundle-entry.js";
|
|
3140
3187
|
if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
|
|
3141
|
-
const hashedPath =
|
|
3142
|
-
const stablePath =
|
|
3188
|
+
const hashedPath = path8.join(outputDir, entryFile);
|
|
3189
|
+
const stablePath = path8.join(outputDir, "bundle-entry.js");
|
|
3143
3190
|
if (await fs.pathExists(hashedPath)) {
|
|
3144
3191
|
await fs.copy(hashedPath, stablePath);
|
|
3145
3192
|
const mapPath = hashedPath + ".map";
|
|
@@ -3148,13 +3195,13 @@ async function createCompatibilityFiles(outputDir, manifest) {
|
|
|
3148
3195
|
}
|
|
3149
3196
|
}
|
|
3150
3197
|
}
|
|
3151
|
-
const sectionsRegistryPath =
|
|
3198
|
+
const sectionsRegistryPath = path8.join(outputDir, "sections-registry.js");
|
|
3152
3199
|
const content = `// Re-export all sections from bundle-entry
|
|
3153
3200
|
// This file exists to maintain compatibility with the import path
|
|
3154
3201
|
export * from './bundle-entry.js';
|
|
3155
3202
|
`;
|
|
3156
3203
|
await fs.writeFile(sectionsRegistryPath, content, "utf-8");
|
|
3157
|
-
const pkgJsonPath =
|
|
3204
|
+
const pkgJsonPath = path8.join(outputDir, "package.json");
|
|
3158
3205
|
await fs.writeFile(pkgJsonPath, '{\n "type": "module"\n}\n', "utf-8");
|
|
3159
3206
|
}
|
|
3160
3207
|
function showDownloadFailureHelp(themeId, bucket) {
|
|
@@ -3237,7 +3284,7 @@ async function downloadCommand(options) {
|
|
|
3237
3284
|
zip.extractAllTo(outputDir, true);
|
|
3238
3285
|
const entries = zip.getEntries().filter((e) => !e.isDirectory);
|
|
3239
3286
|
spinner.succeed(`Extracted ${entries.length} files to ${outputDir}`);
|
|
3240
|
-
const manifestPath =
|
|
3287
|
+
const manifestPath = path8.join(outputDir, "manifest.json");
|
|
3241
3288
|
const manifest = await fs.readJson(manifestPath);
|
|
3242
3289
|
await createCompatibilityFiles(outputDir, manifest);
|
|
3243
3290
|
console.log();
|
|
@@ -3307,39 +3354,15 @@ function getBucketName3(env) {
|
|
|
3307
3354
|
}
|
|
3308
3355
|
async function streamToString2(stream) {
|
|
3309
3356
|
const chunks = [];
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
const chunk = temp.value;
|
|
3313
|
-
chunks.push(Buffer.from(chunk));
|
|
3314
|
-
}
|
|
3315
|
-
} catch (temp) {
|
|
3316
|
-
error = [temp];
|
|
3317
|
-
} finally {
|
|
3318
|
-
try {
|
|
3319
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3320
|
-
} finally {
|
|
3321
|
-
if (error)
|
|
3322
|
-
throw error[0];
|
|
3323
|
-
}
|
|
3357
|
+
for await (const chunk of stream) {
|
|
3358
|
+
chunks.push(Buffer.from(chunk));
|
|
3324
3359
|
}
|
|
3325
3360
|
return Buffer.concat(chunks).toString("utf-8");
|
|
3326
3361
|
}
|
|
3327
3362
|
async function streamToBuffer2(stream) {
|
|
3328
3363
|
const chunks = [];
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
const chunk = temp.value;
|
|
3332
|
-
chunks.push(Buffer.from(chunk));
|
|
3333
|
-
}
|
|
3334
|
-
} catch (temp) {
|
|
3335
|
-
error = [temp];
|
|
3336
|
-
} finally {
|
|
3337
|
-
try {
|
|
3338
|
-
more && (temp = iter.return) && await temp.call(iter);
|
|
3339
|
-
} finally {
|
|
3340
|
-
if (error)
|
|
3341
|
-
throw error[0];
|
|
3342
|
-
}
|
|
3364
|
+
for await (const chunk of stream) {
|
|
3365
|
+
chunks.push(Buffer.from(chunk));
|
|
3343
3366
|
}
|
|
3344
3367
|
return Buffer.concat(chunks);
|
|
3345
3368
|
}
|
|
@@ -3395,7 +3418,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3395
3418
|
const oldPrefix = `${oldName}-`;
|
|
3396
3419
|
const newPrefix = `${newName}-`;
|
|
3397
3420
|
const newDisplayName = newName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3398
|
-
const pkgPath =
|
|
3421
|
+
const pkgPath = path8.join(themeDir, "package.json");
|
|
3399
3422
|
if (await fs.pathExists(pkgPath)) {
|
|
3400
3423
|
const pkg = await fs.readJson(pkgPath);
|
|
3401
3424
|
pkg.name = `@onex-themes/${newName}`;
|
|
@@ -3408,7 +3431,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3408
3431
|
pkg.version = "1.0.0";
|
|
3409
3432
|
await fs.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
3410
3433
|
}
|
|
3411
|
-
const configPath =
|
|
3434
|
+
const configPath = path8.join(themeDir, "theme.config.ts");
|
|
3412
3435
|
if (await fs.pathExists(configPath)) {
|
|
3413
3436
|
let content = await fs.readFile(configPath, "utf-8");
|
|
3414
3437
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -3418,7 +3441,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3418
3441
|
);
|
|
3419
3442
|
await fs.writeFile(configPath, content);
|
|
3420
3443
|
}
|
|
3421
|
-
const layoutPath =
|
|
3444
|
+
const layoutPath = path8.join(themeDir, "theme.layout.ts");
|
|
3422
3445
|
if (await fs.pathExists(layoutPath)) {
|
|
3423
3446
|
let content = await fs.readFile(layoutPath, "utf-8");
|
|
3424
3447
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -3431,7 +3454,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3431
3454
|
const oldDisplayName = oldName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3432
3455
|
const tsFiles = await glob("**/*.ts", { cwd: themeDir, nodir: true });
|
|
3433
3456
|
for (const file of tsFiles) {
|
|
3434
|
-
const filePath =
|
|
3457
|
+
const filePath = path8.join(themeDir, file);
|
|
3435
3458
|
let content = await fs.readFile(filePath, "utf-8");
|
|
3436
3459
|
const original = content;
|
|
3437
3460
|
content = content.replace(
|
|
@@ -3460,7 +3483,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3460
3483
|
const spinner = ora("Initializing clone...").start();
|
|
3461
3484
|
try {
|
|
3462
3485
|
const bucket = options.bucket || getBucketName3(options.environment);
|
|
3463
|
-
const outputDir = options.output ||
|
|
3486
|
+
const outputDir = options.output || path8.resolve(process.cwd(), newName);
|
|
3464
3487
|
const s3Client = getS3Client3();
|
|
3465
3488
|
if (await fs.pathExists(outputDir)) {
|
|
3466
3489
|
spinner.fail(chalk4.red(`Directory already exists: ${outputDir}`));
|
|
@@ -3515,9 +3538,22 @@ async function cloneCommand(themeName, options) {
|
|
|
3515
3538
|
spinner.succeed(
|
|
3516
3539
|
`Renamed theme: ${chalk4.gray(themeName)} \u2192 ${chalk4.cyan(newName)}`
|
|
3517
3540
|
);
|
|
3541
|
+
const envExamplePath = path8.join(outputDir, ".env.example");
|
|
3542
|
+
if (!await fs.pathExists(envExamplePath)) {
|
|
3543
|
+
await fs.writeFile(
|
|
3544
|
+
envExamplePath,
|
|
3545
|
+
[
|
|
3546
|
+
"# API Configuration (enables real data in preview)",
|
|
3547
|
+
"# Get your Company ID from the OneX dashboard",
|
|
3548
|
+
"NEXT_PUBLIC_API_URL=https://api-dev.onexeos.com",
|
|
3549
|
+
"NEXT_PUBLIC_COMPANY_ID=",
|
|
3550
|
+
""
|
|
3551
|
+
].join("\n")
|
|
3552
|
+
);
|
|
3553
|
+
}
|
|
3518
3554
|
if (options.install !== false) {
|
|
3519
3555
|
const hasPkgJson = await fs.pathExists(
|
|
3520
|
-
|
|
3556
|
+
path8.join(outputDir, "package.json")
|
|
3521
3557
|
);
|
|
3522
3558
|
if (hasPkgJson) {
|
|
3523
3559
|
spinner.start("Installing dependencies...");
|
|
@@ -3544,7 +3580,8 @@ async function cloneCommand(themeName, options) {
|
|
|
3544
3580
|
console.log(chalk4.cyan(" Files: ") + chalk4.white(entries.length));
|
|
3545
3581
|
console.log();
|
|
3546
3582
|
console.log(chalk4.cyan("Next steps:"));
|
|
3547
|
-
console.log(chalk4.gray(` cd ${
|
|
3583
|
+
console.log(chalk4.gray(` cd ${path8.relative(process.cwd(), outputDir)}`));
|
|
3584
|
+
console.log(chalk4.gray(" cp .env.example .env # then add your Company ID"));
|
|
3548
3585
|
if (options.install === false) {
|
|
3549
3586
|
console.log(chalk4.gray(" pnpm install"));
|
|
3550
3587
|
}
|
|
@@ -3596,7 +3633,7 @@ function createDevServer(options) {
|
|
|
3596
3633
|
serveFile(res, options.previewRuntimePath);
|
|
3597
3634
|
return;
|
|
3598
3635
|
}
|
|
3599
|
-
const filePath =
|
|
3636
|
+
const filePath = path8.join(options.distDir, pathname);
|
|
3600
3637
|
if (!filePath.startsWith(options.distDir)) {
|
|
3601
3638
|
res.writeHead(403);
|
|
3602
3639
|
res.end("Forbidden");
|
|
@@ -3637,12 +3674,12 @@ function serveFile(res, filePath) {
|
|
|
3637
3674
|
res.end("Not Found");
|
|
3638
3675
|
return;
|
|
3639
3676
|
}
|
|
3640
|
-
const ext =
|
|
3677
|
+
const ext = path8.extname(filePath);
|
|
3641
3678
|
const contentType = MIME_TYPES[ext] || "application/octet-stream";
|
|
3642
3679
|
const content = fs2.readFileSync(filePath);
|
|
3643
3680
|
res.writeHead(200, { "Content-Type": contentType });
|
|
3644
3681
|
res.end(content);
|
|
3645
|
-
} catch
|
|
3682
|
+
} catch {
|
|
3646
3683
|
res.writeHead(500);
|
|
3647
3684
|
res.end("Internal Server Error");
|
|
3648
3685
|
}
|
|
@@ -3697,14 +3734,14 @@ async function devCommand(options) {
|
|
|
3697
3734
|
if (options.theme) {
|
|
3698
3735
|
themeName = options.theme;
|
|
3699
3736
|
try {
|
|
3700
|
-
const workspaceThemePath =
|
|
3737
|
+
const workspaceThemePath = path8.join(getThemesDir(), themeName);
|
|
3701
3738
|
if (fs.existsSync(workspaceThemePath)) {
|
|
3702
3739
|
themePath = workspaceThemePath;
|
|
3703
3740
|
} else {
|
|
3704
|
-
themePath =
|
|
3741
|
+
themePath = path8.join(process.cwd(), themeName);
|
|
3705
3742
|
}
|
|
3706
|
-
} catch
|
|
3707
|
-
themePath =
|
|
3743
|
+
} catch {
|
|
3744
|
+
themePath = path8.join(process.cwd(), themeName);
|
|
3708
3745
|
}
|
|
3709
3746
|
if (!fs.existsSync(themePath)) {
|
|
3710
3747
|
logger.error(`Theme "${themeName}" not found.`);
|
|
@@ -3715,10 +3752,10 @@ async function devCommand(options) {
|
|
|
3715
3752
|
"theme.config.ts",
|
|
3716
3753
|
"bundle-entry.ts",
|
|
3717
3754
|
"manifest.ts"
|
|
3718
|
-
].some((f) => fs.existsSync(
|
|
3755
|
+
].some((f) => fs.existsSync(path8.join(process.cwd(), f)));
|
|
3719
3756
|
if (isThemeDir) {
|
|
3720
3757
|
themePath = process.cwd();
|
|
3721
|
-
themeName =
|
|
3758
|
+
themeName = path8.basename(themePath);
|
|
3722
3759
|
} else {
|
|
3723
3760
|
logger.error(
|
|
3724
3761
|
"Not in a theme directory and no --theme specified. Run from theme root or use --theme flag."
|
|
@@ -3786,10 +3823,10 @@ async function devCommand(options) {
|
|
|
3786
3823
|
watcher.close();
|
|
3787
3824
|
await context2.dispose();
|
|
3788
3825
|
server.close();
|
|
3789
|
-
const shimPath =
|
|
3826
|
+
const shimPath = path8.join(outputDir, ".process-shim.js");
|
|
3790
3827
|
try {
|
|
3791
3828
|
await fs7.unlink(shimPath);
|
|
3792
|
-
} catch
|
|
3829
|
+
} catch {
|
|
3793
3830
|
}
|
|
3794
3831
|
process.exit(0);
|
|
3795
3832
|
});
|
|
@@ -3799,14 +3836,14 @@ async function devCommand(options) {
|
|
|
3799
3836
|
try {
|
|
3800
3837
|
const projectRoot = getProjectRoot();
|
|
3801
3838
|
dotenv.config({
|
|
3802
|
-
path:
|
|
3839
|
+
path: path8.join(projectRoot, ".env.local"),
|
|
3803
3840
|
quiet: true
|
|
3804
3841
|
});
|
|
3805
|
-
dotenv.config({ path:
|
|
3806
|
-
} catch
|
|
3842
|
+
dotenv.config({ path: path8.join(projectRoot, ".env"), quiet: true });
|
|
3843
|
+
} catch {
|
|
3807
3844
|
}
|
|
3808
3845
|
dotenv.config({
|
|
3809
|
-
path:
|
|
3846
|
+
path: path8.join(os.homedir(), ".onex", ".env"),
|
|
3810
3847
|
quiet: true
|
|
3811
3848
|
});
|
|
3812
3849
|
var program = new Command();
|