@onexapis/cli 1.1.38 → 1.1.40
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 +384 -380
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +381 -376
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +258 -293
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +255 -289
- package/dist/index.mjs.map +1 -1
- package/dist/preview/preview-app.tsx +13 -5
- package/package.json +1 -3
- package/templates/default/AUTH_AND_PROFILE.md +167 -0
- package/templates/default/CLAUDE.md +435 -6
- package/templates/default/LAYOUT.md +195 -0
- package/templates/default/bundle-entry.ts +5 -0
- package/templates/default/esbuild.config.js +20 -0
- package/templates/default/hooks/index.ts +26 -0
- package/templates/default/hooks/use-forgot-password-form.ts +90 -0
- package/templates/default/hooks/use-login-form.ts +102 -0
- package/templates/default/hooks/use-profile-form.ts +255 -0
- package/templates/default/hooks/use-register-form.ts +154 -0
- package/templates/default/hooks/use-verify-code-form.ts +224 -0
- package/templates/default/index.ts +21 -1
- package/templates/default/pages/about.ts +2 -2
- package/templates/default/pages/forgot-password.ts +39 -0
- package/templates/default/pages/home.ts +4 -4
- package/templates/default/pages/login.ts +39 -0
- package/templates/default/pages/profile.ts +39 -0
- package/templates/default/pages/register.ts +39 -0
- package/templates/default/pages/showcase.ts +7 -7
- package/templates/default/pages/verify-code.ts +39 -0
- package/templates/default/sections/about/about.schema.ts +1 -1
- package/templates/default/sections/auth-forgot-password/auth-forgot-password-default.tsx +192 -0
- package/templates/default/sections/auth-forgot-password/auth-forgot-password.schema.ts +150 -0
- package/templates/default/sections/auth-forgot-password/index.ts +14 -0
- package/templates/default/sections/auth-login/auth-login-default.tsx +238 -0
- package/templates/default/sections/auth-login/auth-login.schema.ts +171 -0
- package/templates/default/sections/auth-login/index.ts +14 -0
- package/templates/default/sections/auth-register/auth-register-default.tsx +327 -0
- package/templates/default/sections/auth-register/auth-register.schema.ts +188 -0
- package/templates/default/sections/auth-register/index.ts +14 -0
- package/templates/default/sections/auth-verify-code/auth-verify-code-default.tsx +209 -0
- package/templates/default/sections/auth-verify-code/auth-verify-code.schema.ts +150 -0
- package/templates/default/sections/auth-verify-code/index.ts +14 -0
- package/templates/default/sections/cta/cta.schema.ts +1 -1
- package/templates/default/sections/features/features.schema.ts +1 -1
- package/templates/default/sections/footer/footer-default.tsx +214 -0
- package/templates/default/sections/footer/footer.schema.ts +170 -0
- package/templates/default/sections/footer/index.ts +14 -0
- package/templates/default/sections/gallery/gallery.schema.ts +1 -1
- package/templates/default/sections/header/header-default.tsx +322 -0
- package/templates/default/sections/header/header.schema.ts +168 -0
- package/templates/default/sections/header/index.ts +14 -0
- package/templates/default/sections/hero/hero.schema.ts +1 -1
- package/templates/default/sections/profile/index.ts +14 -0
- package/templates/default/sections/profile/profile-default.tsx +522 -0
- package/templates/default/sections/profile/profile.schema.ts +228 -0
- package/templates/default/sections/stats/stats.schema.ts +1 -1
- package/templates/default/sections/testimonials/testimonials.schema.ts +1 -1
- package/templates/default/sections-registry.ts +28 -0
- package/templates/default/theme.layout.ts +71 -2
package/dist/cli.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
var chalk4 = require('chalk');
|
|
5
5
|
var ora = require('ora');
|
|
6
6
|
var esbuild = require('esbuild');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var path9 = require('path');
|
|
8
|
+
var fs8 = require('fs/promises');
|
|
9
9
|
var crypto = require('crypto');
|
|
10
10
|
var glob = require('glob');
|
|
11
11
|
var module$1 = require('module');
|
|
@@ -13,9 +13,9 @@ var os = require('os');
|
|
|
13
13
|
var dotenv = require('dotenv');
|
|
14
14
|
var fs = require('fs-extra');
|
|
15
15
|
var ejs = require('ejs');
|
|
16
|
-
var
|
|
16
|
+
var child_process = require('child_process');
|
|
17
17
|
var commander = require('commander');
|
|
18
|
-
var
|
|
18
|
+
var fs3 = require('fs');
|
|
19
19
|
var inquirer = require('inquirer');
|
|
20
20
|
var archiver = require('archiver');
|
|
21
21
|
var FormData = require('form-data');
|
|
@@ -51,15 +51,14 @@ function _interopNamespace(e) {
|
|
|
51
51
|
var chalk4__default = /*#__PURE__*/_interopDefault(chalk4);
|
|
52
52
|
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
53
53
|
var esbuild__namespace = /*#__PURE__*/_interopNamespace(esbuild);
|
|
54
|
-
var
|
|
55
|
-
var
|
|
54
|
+
var path9__default = /*#__PURE__*/_interopDefault(path9);
|
|
55
|
+
var fs8__default = /*#__PURE__*/_interopDefault(fs8);
|
|
56
56
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
57
57
|
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
58
58
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
59
59
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
60
60
|
var ejs__default = /*#__PURE__*/_interopDefault(ejs);
|
|
61
|
-
var
|
|
62
|
-
var fs4__default = /*#__PURE__*/_interopDefault(fs4);
|
|
61
|
+
var fs3__default = /*#__PURE__*/_interopDefault(fs3);
|
|
63
62
|
var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
|
|
64
63
|
var archiver__default = /*#__PURE__*/_interopDefault(archiver);
|
|
65
64
|
var FormData__default = /*#__PURE__*/_interopDefault(FormData);
|
|
@@ -149,8 +148,8 @@ async function generateThemeCSS(themePath, outDir) {
|
|
|
149
148
|
const tailwindcss = (await import('tailwindcss')).default;
|
|
150
149
|
const tailwindConfig = {
|
|
151
150
|
content: [
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
path9__default.default.join(themePath, "sections/**/*.{ts,tsx}"),
|
|
152
|
+
path9__default.default.join(themePath, "components/**/*.{ts,tsx}")
|
|
154
153
|
],
|
|
155
154
|
theme: { extend: {} },
|
|
156
155
|
plugins: []
|
|
@@ -160,7 +159,7 @@ async function generateThemeCSS(themePath, outDir) {
|
|
|
160
159
|
inputCSS,
|
|
161
160
|
{ from: void 0 }
|
|
162
161
|
);
|
|
163
|
-
await
|
|
162
|
+
await fs8__default.default.writeFile(path9__default.default.join(outDir, "bundle.css"), result.css);
|
|
164
163
|
logger.info("Generated bundle.css");
|
|
165
164
|
} catch (err) {
|
|
166
165
|
logger.warning(
|
|
@@ -171,12 +170,12 @@ async function generateThemeCSS(themePath, outDir) {
|
|
|
171
170
|
async function resolveNodeModulesFile(startDir, relativePath) {
|
|
172
171
|
let dir = startDir;
|
|
173
172
|
while (true) {
|
|
174
|
-
const candidate =
|
|
173
|
+
const candidate = path9__default.default.join(dir, "node_modules", relativePath);
|
|
175
174
|
try {
|
|
176
|
-
await
|
|
175
|
+
await fs8__default.default.access(candidate);
|
|
177
176
|
return candidate;
|
|
178
177
|
} catch {
|
|
179
|
-
const parent =
|
|
178
|
+
const parent = path9__default.default.dirname(dir);
|
|
180
179
|
if (parent === dir) break;
|
|
181
180
|
dir = parent;
|
|
182
181
|
}
|
|
@@ -200,7 +199,7 @@ async function scanImportsFromPackage(sourceDir, packageName) {
|
|
|
200
199
|
});
|
|
201
200
|
for (const file of sourceFiles) {
|
|
202
201
|
try {
|
|
203
|
-
const content = await
|
|
202
|
+
const content = await fs8__default.default.readFile(path9__default.default.join(sourceDir, file), "utf-8");
|
|
204
203
|
for (const match of content.matchAll(namespaceImportRegex)) {
|
|
205
204
|
const subpath = match[1] ? match[1].slice(1) : "";
|
|
206
205
|
if (!result[subpath]) result[subpath] = /* @__PURE__ */ new Set();
|
|
@@ -254,17 +253,17 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
254
253
|
const distFileName = subpath ? `${subpath}.mjs` : "index.mjs";
|
|
255
254
|
let distPath = await resolveNodeModulesFile(
|
|
256
255
|
themePath,
|
|
257
|
-
|
|
256
|
+
path9__default.default.join("@onexapis", "core", "dist", distFileName)
|
|
258
257
|
);
|
|
259
258
|
if (!distPath) {
|
|
260
259
|
distPath = await resolveNodeModulesFile(
|
|
261
260
|
__dirname,
|
|
262
|
-
|
|
261
|
+
path9__default.default.join("@onexapis", "core", "dist", distFileName)
|
|
263
262
|
);
|
|
264
263
|
}
|
|
265
264
|
try {
|
|
266
265
|
if (!distPath) throw new Error("not found");
|
|
267
|
-
const distContent = await
|
|
266
|
+
const distContent = await fs8__default.default.readFile(distPath, "utf-8");
|
|
268
267
|
const exportMatches = distContent.matchAll(/export\s*\{([^}]+)\}/g);
|
|
269
268
|
for (const m of exportMatches) {
|
|
270
269
|
const names = m[1].split(",").map((n) => {
|
|
@@ -493,7 +492,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
493
492
|
const pages = {};
|
|
494
493
|
for (const ext of [".ts", ".js"]) {
|
|
495
494
|
try {
|
|
496
|
-
const mod = await jiti.import(
|
|
495
|
+
const mod = await jiti.import(path9__default.default.join(themePath, `theme.config${ext}`));
|
|
497
496
|
themeConfig = mod.default || mod;
|
|
498
497
|
break;
|
|
499
498
|
} catch {
|
|
@@ -501,20 +500,20 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
501
500
|
}
|
|
502
501
|
for (const ext of [".ts", ".js"]) {
|
|
503
502
|
try {
|
|
504
|
-
const mod = await jiti.import(
|
|
503
|
+
const mod = await jiti.import(path9__default.default.join(themePath, `theme.layout${ext}`));
|
|
505
504
|
layoutConfig = mod.default || mod;
|
|
506
505
|
break;
|
|
507
506
|
} catch {
|
|
508
507
|
}
|
|
509
508
|
}
|
|
510
509
|
const schemas = {};
|
|
511
|
-
const sectionsDir =
|
|
510
|
+
const sectionsDir = path9__default.default.join(themePath, "sections");
|
|
512
511
|
try {
|
|
513
|
-
const sectionDirs = await
|
|
512
|
+
const sectionDirs = await fs8__default.default.readdir(sectionsDir);
|
|
514
513
|
for (const dir of sectionDirs) {
|
|
515
|
-
const schemaFile =
|
|
514
|
+
const schemaFile = path9__default.default.join(sectionsDir, dir, `${dir}.schema.ts`);
|
|
516
515
|
try {
|
|
517
|
-
await
|
|
516
|
+
await fs8__default.default.access(schemaFile);
|
|
518
517
|
const mod = await jiti.import(schemaFile);
|
|
519
518
|
for (const [key, value] of Object.entries(mod)) {
|
|
520
519
|
if (key.endsWith("Schema") && value && typeof value === "object" && value.type) {
|
|
@@ -526,14 +525,14 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
526
525
|
}
|
|
527
526
|
} catch {
|
|
528
527
|
}
|
|
529
|
-
const pagesDir =
|
|
528
|
+
const pagesDir = path9__default.default.join(themePath, "pages");
|
|
530
529
|
try {
|
|
531
|
-
const files = await
|
|
530
|
+
const files = await fs8__default.default.readdir(pagesDir);
|
|
532
531
|
for (const file of files) {
|
|
533
532
|
if (!file.match(/\.(ts|js)$/)) continue;
|
|
534
533
|
const name = file.replace(/\.(ts|js)$/, "");
|
|
535
534
|
try {
|
|
536
|
-
const mod = await jiti.import(
|
|
535
|
+
const mod = await jiti.import(path9__default.default.join(pagesDir, file));
|
|
537
536
|
const config = mod.default || mod;
|
|
538
537
|
const sections = (config.sections || []).map((section) => {
|
|
539
538
|
const schema = schemas[section.type];
|
|
@@ -561,8 +560,8 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
561
560
|
}
|
|
562
561
|
} catch {
|
|
563
562
|
}
|
|
564
|
-
await
|
|
565
|
-
|
|
563
|
+
await fs8__default.default.writeFile(
|
|
564
|
+
path9__default.default.join(outputDir, "theme-data.json"),
|
|
566
565
|
JSON.stringify(
|
|
567
566
|
{
|
|
568
567
|
themeId,
|
|
@@ -585,36 +584,36 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
585
584
|
logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
|
|
586
585
|
}
|
|
587
586
|
async function contentHashEntry(outputDir) {
|
|
588
|
-
const entryPath =
|
|
589
|
-
const mapPath =
|
|
587
|
+
const entryPath = path9__default.default.join(outputDir, "bundle-entry.js");
|
|
588
|
+
const mapPath = path9__default.default.join(outputDir, "bundle-entry.js.map");
|
|
590
589
|
const oldFiles = await glob.glob("bundle-entry-*.js*", { cwd: outputDir });
|
|
591
590
|
for (const f of oldFiles) {
|
|
592
|
-
await
|
|
591
|
+
await fs8__default.default.unlink(path9__default.default.join(outputDir, f));
|
|
593
592
|
}
|
|
594
593
|
let entryContent;
|
|
595
594
|
try {
|
|
596
|
-
entryContent = await
|
|
595
|
+
entryContent = await fs8__default.default.readFile(entryPath, "utf-8");
|
|
597
596
|
} catch {
|
|
598
|
-
const indexPath =
|
|
597
|
+
const indexPath = path9__default.default.join(outputDir, "index.js");
|
|
599
598
|
try {
|
|
600
|
-
entryContent = await
|
|
599
|
+
entryContent = await fs8__default.default.readFile(indexPath, "utf-8");
|
|
601
600
|
} catch {
|
|
602
601
|
logger.warning("No entry file found in output, skipping content hash");
|
|
603
602
|
return;
|
|
604
603
|
}
|
|
605
604
|
const hash2 = crypto__default.default.createHash("sha256").update(entryContent).digest("hex").slice(0, 8);
|
|
606
605
|
const hashedName2 = `bundle-entry-${hash2}.js`;
|
|
607
|
-
const indexMapPath =
|
|
606
|
+
const indexMapPath = path9__default.default.join(outputDir, "index.js.map");
|
|
608
607
|
const hashedMapName2 = `bundle-entry-${hash2}.js.map`;
|
|
609
608
|
entryContent = entryContent.replace(
|
|
610
609
|
/\/\/# sourceMappingURL=index\.js\.map/,
|
|
611
610
|
`//# sourceMappingURL=${hashedMapName2}`
|
|
612
611
|
);
|
|
613
|
-
await
|
|
614
|
-
await
|
|
612
|
+
await fs8__default.default.writeFile(path9__default.default.join(outputDir, hashedName2), entryContent);
|
|
613
|
+
await fs8__default.default.unlink(indexPath);
|
|
615
614
|
try {
|
|
616
|
-
await
|
|
617
|
-
await
|
|
615
|
+
await fs8__default.default.access(indexMapPath);
|
|
616
|
+
await fs8__default.default.rename(indexMapPath, path9__default.default.join(outputDir, hashedMapName2));
|
|
618
617
|
} catch {
|
|
619
618
|
}
|
|
620
619
|
logger.info(`Entry hashed: ${hashedName2}`);
|
|
@@ -627,11 +626,11 @@ async function contentHashEntry(outputDir) {
|
|
|
627
626
|
/\/\/# sourceMappingURL=bundle-entry\.js\.map/,
|
|
628
627
|
`//# sourceMappingURL=${hashedMapName}`
|
|
629
628
|
);
|
|
630
|
-
await
|
|
631
|
-
await
|
|
629
|
+
await fs8__default.default.writeFile(path9__default.default.join(outputDir, hashedName), entryContent);
|
|
630
|
+
await fs8__default.default.unlink(entryPath);
|
|
632
631
|
try {
|
|
633
|
-
await
|
|
634
|
-
await
|
|
632
|
+
await fs8__default.default.access(mapPath);
|
|
633
|
+
await fs8__default.default.rename(mapPath, path9__default.default.join(outputDir, hashedMapName));
|
|
635
634
|
} catch {
|
|
636
635
|
}
|
|
637
636
|
logger.info(`Entry hashed: ${hashedName}`);
|
|
@@ -643,7 +642,7 @@ async function extractDataRequirements(themePath) {
|
|
|
643
642
|
const requirements = {};
|
|
644
643
|
for (const file of schemaFiles) {
|
|
645
644
|
try {
|
|
646
|
-
const mod = await jiti.import(
|
|
645
|
+
const mod = await jiti.import(path9__default.default.join(themePath, file));
|
|
647
646
|
const exports$1 = mod;
|
|
648
647
|
for (const value of Object.values(exports$1)) {
|
|
649
648
|
if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
|
|
@@ -662,8 +661,8 @@ async function generateManifest(themeName, themePath, outputDir) {
|
|
|
662
661
|
let version2 = "1.0.0";
|
|
663
662
|
let themeId = themeName;
|
|
664
663
|
try {
|
|
665
|
-
const pkgContent = await
|
|
666
|
-
|
|
664
|
+
const pkgContent = await fs8__default.default.readFile(
|
|
665
|
+
path9__default.default.join(themePath, "package.json"),
|
|
667
666
|
"utf-8"
|
|
668
667
|
);
|
|
669
668
|
const pkg = JSON.parse(pkgContent);
|
|
@@ -681,7 +680,7 @@ async function generateManifest(themeName, themePath, outputDir) {
|
|
|
681
680
|
const dataRequirements = await extractDataRequirements(themePath);
|
|
682
681
|
let hasThemeConfig = false;
|
|
683
682
|
try {
|
|
684
|
-
await
|
|
683
|
+
await fs8__default.default.access(path9__default.default.join(themePath, "theme.config.ts"));
|
|
685
684
|
hasThemeConfig = true;
|
|
686
685
|
} catch {
|
|
687
686
|
}
|
|
@@ -722,24 +721,24 @@ async function generateManifest(themeName, themePath, outputDir) {
|
|
|
722
721
|
// Section data requirements for server-side prefetching (keyed by section type)
|
|
723
722
|
dataRequirements
|
|
724
723
|
};
|
|
725
|
-
await
|
|
726
|
-
|
|
724
|
+
await fs8__default.default.writeFile(
|
|
725
|
+
path9__default.default.join(outputDir, "manifest.json"),
|
|
727
726
|
JSON.stringify(manifest, null, 2)
|
|
728
727
|
);
|
|
729
728
|
}
|
|
730
729
|
async function compileStandaloneTheme(themePath, themeName) {
|
|
731
|
-
const outputDir =
|
|
732
|
-
const bundleEntry =
|
|
733
|
-
const indexEntry =
|
|
730
|
+
const outputDir = path9__default.default.join(themePath, "dist");
|
|
731
|
+
const bundleEntry = path9__default.default.join(themePath, "bundle-entry.ts");
|
|
732
|
+
const indexEntry = path9__default.default.join(themePath, "index.ts");
|
|
734
733
|
let entryPoint = indexEntry;
|
|
735
734
|
try {
|
|
736
|
-
await
|
|
735
|
+
await fs8__default.default.access(bundleEntry);
|
|
737
736
|
entryPoint = bundleEntry;
|
|
738
737
|
} catch {
|
|
739
738
|
}
|
|
740
|
-
const shimPath =
|
|
741
|
-
await
|
|
742
|
-
await
|
|
739
|
+
const shimPath = path9__default.default.join(outputDir, ".process-shim.js");
|
|
740
|
+
await fs8__default.default.mkdir(outputDir, { recursive: true });
|
|
741
|
+
await fs8__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
743
742
|
const buildOptions = {
|
|
744
743
|
entryPoints: [entryPoint],
|
|
745
744
|
bundle: true,
|
|
@@ -789,7 +788,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
789
788
|
try {
|
|
790
789
|
const result = await esbuild__namespace.build(buildOptions);
|
|
791
790
|
try {
|
|
792
|
-
await
|
|
791
|
+
await fs8__default.default.unlink(shimPath);
|
|
793
792
|
} catch {
|
|
794
793
|
}
|
|
795
794
|
await contentHashEntry(outputDir);
|
|
@@ -808,7 +807,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
808
807
|
return true;
|
|
809
808
|
} catch (error) {
|
|
810
809
|
try {
|
|
811
|
-
await
|
|
810
|
+
await fs8__default.default.unlink(shimPath);
|
|
812
811
|
} catch {
|
|
813
812
|
}
|
|
814
813
|
logger.error(`esbuild compilation failed: ${error}`);
|
|
@@ -816,18 +815,18 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
816
815
|
}
|
|
817
816
|
}
|
|
818
817
|
async function compileStandaloneThemeDev(themePath, themeName) {
|
|
819
|
-
const outputDir =
|
|
820
|
-
const bundleEntry =
|
|
821
|
-
const indexEntry =
|
|
818
|
+
const outputDir = path9__default.default.join(themePath, "dist");
|
|
819
|
+
const bundleEntry = path9__default.default.join(themePath, "bundle-entry.ts");
|
|
820
|
+
const indexEntry = path9__default.default.join(themePath, "index.ts");
|
|
822
821
|
let entryPoint = indexEntry;
|
|
823
822
|
try {
|
|
824
|
-
await
|
|
823
|
+
await fs8__default.default.access(bundleEntry);
|
|
825
824
|
entryPoint = bundleEntry;
|
|
826
825
|
} catch {
|
|
827
826
|
}
|
|
828
|
-
const shimPath =
|
|
829
|
-
await
|
|
830
|
-
await
|
|
827
|
+
const shimPath = path9__default.default.join(outputDir, ".process-shim.js");
|
|
828
|
+
await fs8__default.default.mkdir(outputDir, { recursive: true });
|
|
829
|
+
await fs8__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
831
830
|
const buildOptions = {
|
|
832
831
|
entryPoints: [entryPoint],
|
|
833
832
|
bundle: true,
|
|
@@ -880,18 +879,18 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
880
879
|
return { context: context2, outputDir };
|
|
881
880
|
}
|
|
882
881
|
async function compilePreviewRuntime(themePath) {
|
|
883
|
-
const outputDir =
|
|
884
|
-
await
|
|
885
|
-
const outputPath =
|
|
882
|
+
const outputDir = path9__default.default.join(themePath, "dist");
|
|
883
|
+
await fs8__default.default.mkdir(outputDir, { recursive: true });
|
|
884
|
+
const outputPath = path9__default.default.join(outputDir, "preview-runtime.js");
|
|
886
885
|
const locations = [
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
886
|
+
path9__default.default.join(__dirname, "..", "preview", "preview-app.tsx"),
|
|
887
|
+
path9__default.default.join(__dirname, "preview", "preview-app.tsx"),
|
|
888
|
+
path9__default.default.join(__dirname, "..", "..", "src", "preview", "preview-app.tsx")
|
|
890
889
|
];
|
|
891
890
|
let previewEntryPath = null;
|
|
892
891
|
for (const loc of locations) {
|
|
893
892
|
try {
|
|
894
|
-
await
|
|
893
|
+
await fs8__default.default.access(loc);
|
|
895
894
|
previewEntryPath = loc;
|
|
896
895
|
break;
|
|
897
896
|
} catch {
|
|
@@ -974,10 +973,10 @@ ${locations.join("\n")}`
|
|
|
974
973
|
if (!lucideScanned) {
|
|
975
974
|
lucideScanned = true;
|
|
976
975
|
const coreSrcCandidates = [
|
|
977
|
-
|
|
978
|
-
|
|
976
|
+
path9__default.default.join(themePath, "node_modules", "@onexapis", "core", "src"),
|
|
977
|
+
path9__default.default.join(themePath, "..", "..", "packages", "core", "src"),
|
|
979
978
|
// monorepo sibling
|
|
980
|
-
|
|
979
|
+
path9__default.default.join(
|
|
981
980
|
__dirname,
|
|
982
981
|
"..",
|
|
983
982
|
"..",
|
|
@@ -992,7 +991,7 @@ ${locations.join("\n")}`
|
|
|
992
991
|
let coreSourceDir = null;
|
|
993
992
|
for (const candidate of coreSrcCandidates) {
|
|
994
993
|
try {
|
|
995
|
-
await
|
|
994
|
+
await fs8__default.default.access(candidate);
|
|
996
995
|
coreSourceDir = candidate;
|
|
997
996
|
break;
|
|
998
997
|
} catch {
|
|
@@ -1011,21 +1010,21 @@ ${locations.join("\n")}`
|
|
|
1011
1010
|
}
|
|
1012
1011
|
} else {
|
|
1013
1012
|
const coreDistCandidates = [
|
|
1014
|
-
|
|
1013
|
+
path9__default.default.join(themePath, "node_modules", "@onexapis", "core", "dist")
|
|
1015
1014
|
];
|
|
1016
1015
|
const resolvedDist = await resolveNodeModulesFile(
|
|
1017
1016
|
__dirname,
|
|
1018
|
-
|
|
1017
|
+
path9__default.default.join("@onexapis", "core", "dist")
|
|
1019
1018
|
);
|
|
1020
1019
|
if (resolvedDist) coreDistCandidates.push(resolvedDist);
|
|
1021
1020
|
for (const candidate of coreDistCandidates) {
|
|
1022
1021
|
try {
|
|
1023
|
-
await
|
|
1022
|
+
await fs8__default.default.access(candidate);
|
|
1024
1023
|
const mjsFiles = await glob.glob("*.mjs", { cwd: candidate });
|
|
1025
1024
|
const importRegex = /import\s*\{([^}]+)\}\s*from\s*["']lucide-react["']/g;
|
|
1026
1025
|
for (const file of mjsFiles) {
|
|
1027
|
-
const content = await
|
|
1028
|
-
|
|
1026
|
+
const content = await fs8__default.default.readFile(
|
|
1027
|
+
path9__default.default.join(candidate, file),
|
|
1029
1028
|
"utf-8"
|
|
1030
1029
|
);
|
|
1031
1030
|
for (const match of content.matchAll(importRegex)) {
|
|
@@ -1080,7 +1079,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
1080
1079
|
const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)) || __filename);
|
|
1081
1080
|
const cjsPath = req.resolve("framer-motion");
|
|
1082
1081
|
const pkgDir = cjsPath.replace(/[/\\]dist[/\\].*$/, "");
|
|
1083
|
-
const esmEntry =
|
|
1082
|
+
const esmEntry = path9__default.default.join(pkgDir, "dist", "es", "index.mjs");
|
|
1084
1083
|
const { existsSync } = await import('fs');
|
|
1085
1084
|
if (existsSync(esmEntry)) {
|
|
1086
1085
|
return { path: esmEntry, namespace: "file" };
|
|
@@ -1179,8 +1178,8 @@ export function headers() { return new Headers(); }
|
|
|
1179
1178
|
});
|
|
1180
1179
|
}
|
|
1181
1180
|
};
|
|
1182
|
-
const shimPath =
|
|
1183
|
-
await
|
|
1181
|
+
const shimPath = path9__default.default.join(outputDir, ".process-shim-preview.js");
|
|
1182
|
+
await fs8__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
1184
1183
|
await esbuild__namespace.build({
|
|
1185
1184
|
entryPoints: [previewEntryPath],
|
|
1186
1185
|
bundle: true,
|
|
@@ -1215,7 +1214,7 @@ export function headers() { return new Headers(); }
|
|
|
1215
1214
|
}
|
|
1216
1215
|
});
|
|
1217
1216
|
try {
|
|
1218
|
-
await
|
|
1217
|
+
await fs8__default.default.unlink(shimPath);
|
|
1219
1218
|
} catch {
|
|
1220
1219
|
}
|
|
1221
1220
|
return outputPath;
|
|
@@ -1348,18 +1347,18 @@ async function renderTemplate(templatePath, data) {
|
|
|
1348
1347
|
return ejs__default.default.render(template, data);
|
|
1349
1348
|
}
|
|
1350
1349
|
async function writeFile(filePath, content) {
|
|
1351
|
-
await fs__default.default.ensureDir(
|
|
1350
|
+
await fs__default.default.ensureDir(path9__default.default.dirname(filePath));
|
|
1352
1351
|
await fs__default.default.writeFile(filePath, content, "utf-8");
|
|
1353
1352
|
}
|
|
1354
1353
|
function getTemplatesDir() {
|
|
1355
1354
|
const locations = [
|
|
1356
|
-
|
|
1355
|
+
path9__default.default.join(__dirname, "../../templates"),
|
|
1357
1356
|
// Development
|
|
1358
|
-
|
|
1357
|
+
path9__default.default.join(__dirname, "../templates"),
|
|
1359
1358
|
// Production (dist/)
|
|
1360
|
-
|
|
1359
|
+
path9__default.default.join(process.cwd(), "templates"),
|
|
1361
1360
|
// Fallback
|
|
1362
|
-
|
|
1361
|
+
path9__default.default.join(process.cwd(), "packages/cli/templates")
|
|
1363
1362
|
// Monorepo
|
|
1364
1363
|
];
|
|
1365
1364
|
for (const location of locations) {
|
|
@@ -1371,7 +1370,7 @@ function getTemplatesDir() {
|
|
|
1371
1370
|
}
|
|
1372
1371
|
async function copyTemplate(templateName, targetDir, data) {
|
|
1373
1372
|
const templatesDir = getTemplatesDir();
|
|
1374
|
-
const templateDir =
|
|
1373
|
+
const templateDir = path9__default.default.join(templatesDir, templateName);
|
|
1375
1374
|
if (!fs__default.default.existsSync(templateDir)) {
|
|
1376
1375
|
throw new Error(
|
|
1377
1376
|
`Template "${templateName}" not found at ${templateDir}. Available templates: ${fs__default.default.readdirSync(templatesDir).join(", ")}`
|
|
@@ -1380,8 +1379,8 @@ async function copyTemplate(templateName, targetDir, data) {
|
|
|
1380
1379
|
await fs__default.default.ensureDir(targetDir);
|
|
1381
1380
|
const files = await fs__default.default.readdir(templateDir);
|
|
1382
1381
|
for (const file of files) {
|
|
1383
|
-
const templatePath =
|
|
1384
|
-
const targetPath =
|
|
1382
|
+
const templatePath = path9__default.default.join(templateDir, file);
|
|
1383
|
+
const targetPath = path9__default.default.join(targetDir, file);
|
|
1385
1384
|
const stat = await fs__default.default.stat(templatePath);
|
|
1386
1385
|
if (stat.isDirectory()) {
|
|
1387
1386
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -1398,8 +1397,8 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
1398
1397
|
await fs__default.default.ensureDir(targetDir);
|
|
1399
1398
|
const files = await fs__default.default.readdir(templateDir);
|
|
1400
1399
|
for (const file of files) {
|
|
1401
|
-
const templatePath =
|
|
1402
|
-
const targetPath =
|
|
1400
|
+
const templatePath = path9__default.default.join(templateDir, file);
|
|
1401
|
+
const targetPath = path9__default.default.join(targetDir, file);
|
|
1403
1402
|
const stat = await fs__default.default.stat(templatePath);
|
|
1404
1403
|
if (stat.isDirectory()) {
|
|
1405
1404
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -1414,32 +1413,32 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
1414
1413
|
}
|
|
1415
1414
|
function getProjectRoot() {
|
|
1416
1415
|
let currentDir = process.cwd();
|
|
1417
|
-
while (currentDir !==
|
|
1418
|
-
const packageJsonPath =
|
|
1416
|
+
while (currentDir !== path9__default.default.parse(currentDir).root) {
|
|
1417
|
+
const packageJsonPath = path9__default.default.join(currentDir, "package.json");
|
|
1419
1418
|
if (fs__default.default.existsSync(packageJsonPath)) {
|
|
1420
1419
|
const packageJson = fs__default.default.readJsonSync(packageJsonPath);
|
|
1421
|
-
if (packageJson.workspaces || fs__default.default.existsSync(
|
|
1420
|
+
if (packageJson.workspaces || fs__default.default.existsSync(path9__default.default.join(currentDir, "src/themes")) || fs__default.default.existsSync(path9__default.default.join(currentDir, "themes"))) {
|
|
1422
1421
|
return currentDir;
|
|
1423
1422
|
}
|
|
1424
1423
|
}
|
|
1425
|
-
currentDir =
|
|
1424
|
+
currentDir = path9__default.default.dirname(currentDir);
|
|
1426
1425
|
}
|
|
1427
1426
|
return process.cwd();
|
|
1428
1427
|
}
|
|
1429
1428
|
function getThemesDir() {
|
|
1430
1429
|
const root = getProjectRoot();
|
|
1431
|
-
if (fs__default.default.existsSync(
|
|
1432
|
-
return
|
|
1433
|
-
if (fs__default.default.existsSync(
|
|
1434
|
-
return
|
|
1435
|
-
return
|
|
1430
|
+
if (fs__default.default.existsSync(path9__default.default.join(root, "themes")))
|
|
1431
|
+
return path9__default.default.join(root, "themes");
|
|
1432
|
+
if (fs__default.default.existsSync(path9__default.default.join(root, "src/themes")))
|
|
1433
|
+
return path9__default.default.join(root, "src/themes");
|
|
1434
|
+
return path9__default.default.dirname(root);
|
|
1436
1435
|
}
|
|
1437
1436
|
function getFeaturesDir() {
|
|
1438
|
-
return
|
|
1437
|
+
return path9__default.default.join(getProjectRoot(), "src/features");
|
|
1439
1438
|
}
|
|
1440
1439
|
function isOneXProject() {
|
|
1441
1440
|
const root = getProjectRoot();
|
|
1442
|
-
return fs__default.default.existsSync(
|
|
1441
|
+
return fs__default.default.existsSync(path9__default.default.join(root, "themes")) || fs__default.default.existsSync(path9__default.default.join(root, "src/themes")) || fs__default.default.existsSync(path9__default.default.join(root, "theme.config.ts")) || fs__default.default.existsSync(path9__default.default.join(root, "bundle-entry.ts"));
|
|
1443
1442
|
}
|
|
1444
1443
|
function ensureOneXProject() {
|
|
1445
1444
|
if (!isOneXProject()) {
|
|
@@ -1455,13 +1454,13 @@ function listThemes() {
|
|
|
1455
1454
|
return [];
|
|
1456
1455
|
}
|
|
1457
1456
|
return fs__default.default.readdirSync(themesDir).filter((name) => {
|
|
1458
|
-
const themePath =
|
|
1459
|
-
return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(
|
|
1457
|
+
const themePath = path9__default.default.join(themesDir, name);
|
|
1458
|
+
return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(path9__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path9__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path9__default.default.join(themePath, "manifest.ts")));
|
|
1460
1459
|
});
|
|
1461
1460
|
}
|
|
1462
1461
|
function themeExists(themeName) {
|
|
1463
|
-
const themePath =
|
|
1464
|
-
return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(
|
|
1462
|
+
const themePath = path9__default.default.join(getThemesDir(), themeName);
|
|
1463
|
+
return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(path9__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path9__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path9__default.default.join(themePath, "manifest.ts")));
|
|
1465
1464
|
}
|
|
1466
1465
|
function detectPackageManager() {
|
|
1467
1466
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
@@ -1469,22 +1468,24 @@ function detectPackageManager() {
|
|
|
1469
1468
|
if (userAgent.includes("yarn")) return "yarn";
|
|
1470
1469
|
if (userAgent.includes("bun")) return "bun";
|
|
1471
1470
|
const cwd = process.cwd();
|
|
1472
|
-
if (fs__default.default.existsSync(
|
|
1473
|
-
if (fs__default.default.existsSync(
|
|
1474
|
-
if (fs__default.default.existsSync(
|
|
1471
|
+
if (fs__default.default.existsSync(path9__default.default.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
1472
|
+
if (fs__default.default.existsSync(path9__default.default.join(cwd, "yarn.lock"))) return "yarn";
|
|
1473
|
+
if (fs__default.default.existsSync(path9__default.default.join(cwd, "bun.lockb"))) return "bun";
|
|
1475
1474
|
return "npm";
|
|
1476
1475
|
}
|
|
1477
1476
|
async function installDependencies(projectPath, packageManager = "npm") {
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1477
|
+
return new Promise((resolve, reject) => {
|
|
1478
|
+
try {
|
|
1479
|
+
const installCmd = packageManager === "yarn" ? "yarn" : `${packageManager} install`;
|
|
1480
|
+
child_process.execSync(installCmd, {
|
|
1481
|
+
cwd: projectPath,
|
|
1482
|
+
stdio: "inherit"
|
|
1483
|
+
});
|
|
1484
|
+
resolve();
|
|
1485
|
+
} catch (error) {
|
|
1486
|
+
reject(error);
|
|
1487
|
+
}
|
|
1482
1488
|
});
|
|
1483
|
-
if (result.status !== 0) {
|
|
1484
|
-
throw new Error(
|
|
1485
|
-
`${packageManager} install failed with exit code ${result.status}`
|
|
1486
|
-
);
|
|
1487
|
-
}
|
|
1488
1489
|
}
|
|
1489
1490
|
|
|
1490
1491
|
// src/commands/init.ts
|
|
@@ -1518,8 +1519,8 @@ function getValidCategories() {
|
|
|
1518
1519
|
"contact"
|
|
1519
1520
|
];
|
|
1520
1521
|
}
|
|
1521
|
-
var AUTH_DIR =
|
|
1522
|
-
var AUTH_FILE =
|
|
1522
|
+
var AUTH_DIR = path9__default.default.join(os__default.default.homedir(), ".onexthm");
|
|
1523
|
+
var AUTH_FILE = path9__default.default.join(AUTH_DIR, "auth.json");
|
|
1523
1524
|
function getApiUrl() {
|
|
1524
1525
|
return process.env.ONEXTHM_API_URL || process.env.NEXT_PUBLIC_API_URL || "https://platform-dev.onexeos.com";
|
|
1525
1526
|
}
|
|
@@ -1632,70 +1633,6 @@ function parseJwtClaims(idToken) {
|
|
|
1632
1633
|
return {};
|
|
1633
1634
|
}
|
|
1634
1635
|
}
|
|
1635
|
-
function getNpxCommand() {
|
|
1636
|
-
return process.platform === "win32" ? "npx.cmd" : "npx";
|
|
1637
|
-
}
|
|
1638
|
-
function getDefaultMcpConfig() {
|
|
1639
|
-
return {
|
|
1640
|
-
mcpServers: {
|
|
1641
|
-
onexthm: {
|
|
1642
|
-
command: getNpxCommand(),
|
|
1643
|
-
args: ["-y", "@onexapis/theme-mcp"]
|
|
1644
|
-
}
|
|
1645
|
-
}
|
|
1646
|
-
};
|
|
1647
|
-
}
|
|
1648
|
-
function ensureMcpJson(projectPath, figmaApiKey) {
|
|
1649
|
-
const mcpJsonPath = path10__default.default.join(projectPath, ".mcp.json");
|
|
1650
|
-
const npx = getNpxCommand();
|
|
1651
|
-
let mcpConfig;
|
|
1652
|
-
if (fs4__default.default.existsSync(mcpJsonPath)) {
|
|
1653
|
-
try {
|
|
1654
|
-
mcpConfig = JSON.parse(fs4__default.default.readFileSync(mcpJsonPath, "utf-8"));
|
|
1655
|
-
if (!mcpConfig.mcpServers) {
|
|
1656
|
-
mcpConfig.mcpServers = {};
|
|
1657
|
-
}
|
|
1658
|
-
} catch {
|
|
1659
|
-
mcpConfig = getDefaultMcpConfig();
|
|
1660
|
-
}
|
|
1661
|
-
} else {
|
|
1662
|
-
mcpConfig = getDefaultMcpConfig();
|
|
1663
|
-
}
|
|
1664
|
-
mcpConfig.mcpServers.onexthm = {
|
|
1665
|
-
command: npx,
|
|
1666
|
-
args: ["-y", "@onexapis/theme-mcp"]
|
|
1667
|
-
};
|
|
1668
|
-
if (figmaApiKey) {
|
|
1669
|
-
mcpConfig.mcpServers.figma = {
|
|
1670
|
-
command: npx,
|
|
1671
|
-
args: [
|
|
1672
|
-
"-y",
|
|
1673
|
-
"figma-developer-mcp",
|
|
1674
|
-
`--figma-api-key=${figmaApiKey}`,
|
|
1675
|
-
"--stdio"
|
|
1676
|
-
]
|
|
1677
|
-
};
|
|
1678
|
-
} else {
|
|
1679
|
-
delete mcpConfig.mcpServers.figma;
|
|
1680
|
-
}
|
|
1681
|
-
fs4__default.default.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2) + "\n");
|
|
1682
|
-
ensureThemeMcpDependency(projectPath);
|
|
1683
|
-
}
|
|
1684
|
-
function ensureThemeMcpDependency(projectPath) {
|
|
1685
|
-
const pkgJsonPath = path10__default.default.join(projectPath, "package.json");
|
|
1686
|
-
if (!fs4__default.default.existsSync(pkgJsonPath)) return;
|
|
1687
|
-
try {
|
|
1688
|
-
const pkg = JSON.parse(fs4__default.default.readFileSync(pkgJsonPath, "utf-8"));
|
|
1689
|
-
if (!pkg.devDependencies) {
|
|
1690
|
-
pkg.devDependencies = {};
|
|
1691
|
-
}
|
|
1692
|
-
if (!pkg.devDependencies["@onexapis/theme-mcp"]) {
|
|
1693
|
-
pkg.devDependencies["@onexapis/theme-mcp"] = "^0.1.0";
|
|
1694
|
-
fs4__default.default.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
1695
|
-
}
|
|
1696
|
-
} catch {
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
1636
|
|
|
1700
1637
|
// src/commands/init.ts
|
|
1701
1638
|
async function initCommand(projectName, options = {}) {
|
|
@@ -1713,7 +1650,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1713
1650
|
if (!validateThemeName(kebabName)) {
|
|
1714
1651
|
return "Invalid project name. Use lowercase letters, numbers, and hyphens only.";
|
|
1715
1652
|
}
|
|
1716
|
-
if (
|
|
1653
|
+
if (fs3__default.default.existsSync(path9__default.default.join(process.cwd(), kebabName))) {
|
|
1717
1654
|
return `Directory "${kebabName}" already exists`;
|
|
1718
1655
|
}
|
|
1719
1656
|
return true;
|
|
@@ -1724,8 +1661,8 @@ async function initCommand(projectName, options = {}) {
|
|
|
1724
1661
|
} else {
|
|
1725
1662
|
name = toKebabCase(projectName);
|
|
1726
1663
|
}
|
|
1727
|
-
const projectPath =
|
|
1728
|
-
if (
|
|
1664
|
+
const projectPath = path9__default.default.join(process.cwd(), name);
|
|
1665
|
+
if (fs3__default.default.existsSync(projectPath)) {
|
|
1729
1666
|
logger.error(`Directory "${name}" already exists.`);
|
|
1730
1667
|
process.exit(1);
|
|
1731
1668
|
}
|
|
@@ -1831,7 +1768,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1831
1768
|
}
|
|
1832
1769
|
logger.startSpinner("Creating project structure...");
|
|
1833
1770
|
try {
|
|
1834
|
-
|
|
1771
|
+
fs3__default.default.mkdirSync(projectPath, { recursive: true });
|
|
1835
1772
|
await copyTemplate(template, projectPath, data);
|
|
1836
1773
|
await renameThemeInFiles(
|
|
1837
1774
|
projectPath,
|
|
@@ -1840,14 +1777,28 @@ async function initCommand(projectName, options = {}) {
|
|
|
1840
1777
|
description,
|
|
1841
1778
|
author
|
|
1842
1779
|
);
|
|
1843
|
-
|
|
1780
|
+
const mcpJsonPath = path9__default.default.join(projectPath, ".mcp.json");
|
|
1781
|
+
if (fs3__default.default.existsSync(mcpJsonPath)) {
|
|
1782
|
+
let mcpContent = fs3__default.default.readFileSync(mcpJsonPath, "utf-8");
|
|
1783
|
+
if (figmaApiKey) {
|
|
1784
|
+
mcpContent = mcpContent.replace("__FIGMA_API_KEY__", figmaApiKey);
|
|
1785
|
+
} else {
|
|
1786
|
+
try {
|
|
1787
|
+
const mcpJson = JSON.parse(mcpContent);
|
|
1788
|
+
delete mcpJson.mcpServers.figma;
|
|
1789
|
+
mcpContent = JSON.stringify(mcpJson, null, 2) + "\n";
|
|
1790
|
+
} catch {
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
fs3__default.default.writeFileSync(mcpJsonPath, mcpContent, "utf-8");
|
|
1794
|
+
}
|
|
1844
1795
|
logger.stopSpinner(true, "Project structure created!");
|
|
1845
1796
|
if (options.git) {
|
|
1846
1797
|
logger.startSpinner("Initializing git repository...");
|
|
1847
1798
|
try {
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1799
|
+
child_process.execSync("git init", { cwd: projectPath, stdio: "ignore" });
|
|
1800
|
+
child_process.execSync("git add .", { cwd: projectPath, stdio: "ignore" });
|
|
1801
|
+
child_process.execSync('git commit -m "Initial commit from onexthm init"', {
|
|
1851
1802
|
cwd: projectPath,
|
|
1852
1803
|
stdio: "ignore"
|
|
1853
1804
|
});
|
|
@@ -1899,16 +1850,16 @@ async function initCommand(projectName, options = {}) {
|
|
|
1899
1850
|
logger.error(
|
|
1900
1851
|
error instanceof Error ? error.message : "Unknown error occurred"
|
|
1901
1852
|
);
|
|
1902
|
-
if (
|
|
1903
|
-
|
|
1853
|
+
if (fs3__default.default.existsSync(projectPath)) {
|
|
1854
|
+
fs3__default.default.rmSync(projectPath, { recursive: true, force: true });
|
|
1904
1855
|
}
|
|
1905
1856
|
process.exit(1);
|
|
1906
1857
|
}
|
|
1907
1858
|
}
|
|
1908
1859
|
async function renameThemeInFiles(projectPath, themeName, displayName, description, author) {
|
|
1909
|
-
const configPath =
|
|
1910
|
-
if (
|
|
1911
|
-
let content =
|
|
1860
|
+
const configPath = path9__default.default.join(projectPath, "theme.config.ts");
|
|
1861
|
+
if (fs3__default.default.existsSync(configPath)) {
|
|
1862
|
+
let content = fs3__default.default.readFileSync(configPath, "utf-8");
|
|
1912
1863
|
content = content.replace(
|
|
1913
1864
|
/name: "My Simple Theme"/,
|
|
1914
1865
|
`name: "${displayName}"`
|
|
@@ -1917,11 +1868,11 @@ async function renameThemeInFiles(projectPath, themeName, displayName, descripti
|
|
|
1917
1868
|
/description: ".*?"/,
|
|
1918
1869
|
`description: "${description}"`
|
|
1919
1870
|
);
|
|
1920
|
-
|
|
1871
|
+
fs3__default.default.writeFileSync(configPath, content, "utf-8");
|
|
1921
1872
|
}
|
|
1922
|
-
const pkgPath =
|
|
1923
|
-
if (
|
|
1924
|
-
let content =
|
|
1873
|
+
const pkgPath = path9__default.default.join(projectPath, "package.json");
|
|
1874
|
+
if (fs3__default.default.existsSync(pkgPath)) {
|
|
1875
|
+
let content = fs3__default.default.readFileSync(pkgPath, "utf-8");
|
|
1925
1876
|
content = content.replace(
|
|
1926
1877
|
/@onex-themes\/my-simple/g,
|
|
1927
1878
|
`@onex-themes/${themeName}`
|
|
@@ -1930,7 +1881,7 @@ async function renameThemeInFiles(projectPath, themeName, displayName, descripti
|
|
|
1930
1881
|
/"description": ".*?"/,
|
|
1931
1882
|
`"description": "${description}"`
|
|
1932
1883
|
);
|
|
1933
|
-
|
|
1884
|
+
fs3__default.default.writeFileSync(pkgPath, content, "utf-8");
|
|
1934
1885
|
}
|
|
1935
1886
|
}
|
|
1936
1887
|
|
|
@@ -1941,10 +1892,10 @@ async function createSectionCommand(name, options) {
|
|
|
1941
1892
|
ensureOneXProject();
|
|
1942
1893
|
if (!options.theme) {
|
|
1943
1894
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
1944
|
-
(f) => fs__default.default.existsSync(
|
|
1895
|
+
(f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f))
|
|
1945
1896
|
);
|
|
1946
1897
|
if (isStandaloneTheme) {
|
|
1947
|
-
options.theme =
|
|
1898
|
+
options.theme = path9__default.default.basename(process.cwd());
|
|
1948
1899
|
}
|
|
1949
1900
|
}
|
|
1950
1901
|
const sectionName = toKebabCase(name);
|
|
@@ -2007,35 +1958,35 @@ async function createSectionCommand(name, options) {
|
|
|
2007
1958
|
};
|
|
2008
1959
|
logger.startSpinner("Creating section files...");
|
|
2009
1960
|
try {
|
|
2010
|
-
const themePath =
|
|
2011
|
-
const sectionPath =
|
|
1961
|
+
const themePath = path9__default.default.join(getThemesDir(), themeName);
|
|
1962
|
+
const sectionPath = path9__default.default.join(themePath, "sections", sectionName);
|
|
2012
1963
|
const schemaContent = generateSectionSchema(data);
|
|
2013
1964
|
await writeFile(
|
|
2014
|
-
|
|
1965
|
+
path9__default.default.join(sectionPath, `${sectionName}.schema.ts`),
|
|
2015
1966
|
schemaContent
|
|
2016
1967
|
);
|
|
2017
1968
|
if (createTemplate) {
|
|
2018
1969
|
const templateContent = generateSectionTemplate(data);
|
|
2019
1970
|
await writeFile(
|
|
2020
|
-
|
|
1971
|
+
path9__default.default.join(sectionPath, `${sectionName}-default.tsx`),
|
|
2021
1972
|
templateContent
|
|
2022
1973
|
);
|
|
2023
1974
|
}
|
|
2024
1975
|
const indexContent = generateSectionIndex(data, createTemplate);
|
|
2025
|
-
await writeFile(
|
|
1976
|
+
await writeFile(path9__default.default.join(sectionPath, "index.ts"), indexContent);
|
|
2026
1977
|
logger.stopSpinner(true, "Section files created successfully!");
|
|
2027
1978
|
logger.newLine();
|
|
2028
1979
|
logger.section("Next steps:");
|
|
2029
1980
|
logger.log(
|
|
2030
|
-
` 1. Edit schema: ${
|
|
1981
|
+
` 1. Edit schema: ${path9__default.default.relative(process.cwd(), path9__default.default.join(sectionPath, `${sectionName}.schema.ts`))}`
|
|
2031
1982
|
);
|
|
2032
1983
|
if (createTemplate) {
|
|
2033
1984
|
logger.log(
|
|
2034
|
-
` 2. Edit template: ${
|
|
1985
|
+
` 2. Edit template: ${path9__default.default.relative(process.cwd(), path9__default.default.join(sectionPath, `${sectionName}-default.tsx`))}`
|
|
2035
1986
|
);
|
|
2036
1987
|
}
|
|
2037
1988
|
logger.log(
|
|
2038
|
-
` 3. Add to theme manifest: ${
|
|
1989
|
+
` 3. Add to theme manifest: ${path9__default.default.relative(process.cwd(), path9__default.default.join(themePath, "manifest.ts"))}`
|
|
2039
1990
|
);
|
|
2040
1991
|
logger.newLine();
|
|
2041
1992
|
logger.success("Section created successfully!");
|
|
@@ -2183,10 +2134,10 @@ async function createBlockCommand(name, options) {
|
|
|
2183
2134
|
ensureOneXProject();
|
|
2184
2135
|
if (!options.theme) {
|
|
2185
2136
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
2186
|
-
(f) => fs__default.default.existsSync(
|
|
2137
|
+
(f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f))
|
|
2187
2138
|
);
|
|
2188
2139
|
if (isStandaloneTheme) {
|
|
2189
|
-
options.theme =
|
|
2140
|
+
options.theme = path9__default.default.basename(process.cwd());
|
|
2190
2141
|
}
|
|
2191
2142
|
}
|
|
2192
2143
|
const blockName = toKebabCase(name);
|
|
@@ -2261,24 +2212,24 @@ async function createBlockCommand(name, options) {
|
|
|
2261
2212
|
};
|
|
2262
2213
|
logger.startSpinner("Creating block files...");
|
|
2263
2214
|
try {
|
|
2264
|
-
const blockPath = scope === "shared" ?
|
|
2215
|
+
const blockPath = scope === "shared" ? path9__default.default.join(getFeaturesDir(), "blocks", blockName) : path9__default.default.join(getThemesDir(), themeName, "blocks", blockName);
|
|
2265
2216
|
const schemaContent = generateBlockSchema(data);
|
|
2266
2217
|
await writeFile(
|
|
2267
|
-
|
|
2218
|
+
path9__default.default.join(blockPath, `${blockName}.schema.ts`),
|
|
2268
2219
|
schemaContent
|
|
2269
2220
|
);
|
|
2270
2221
|
const componentContent = generateBlockComponent(data);
|
|
2271
|
-
await writeFile(
|
|
2222
|
+
await writeFile(path9__default.default.join(blockPath, `${blockName}.tsx`), componentContent);
|
|
2272
2223
|
const indexContent = generateBlockIndex(data);
|
|
2273
|
-
await writeFile(
|
|
2224
|
+
await writeFile(path9__default.default.join(blockPath, "index.ts"), indexContent);
|
|
2274
2225
|
logger.stopSpinner(true, "Block files created successfully!");
|
|
2275
2226
|
logger.newLine();
|
|
2276
2227
|
logger.section("Next steps:");
|
|
2277
2228
|
logger.log(
|
|
2278
|
-
` 1. Edit schema: ${
|
|
2229
|
+
` 1. Edit schema: ${path9__default.default.relative(process.cwd(), path9__default.default.join(blockPath, `${blockName}.schema.ts`))}`
|
|
2279
2230
|
);
|
|
2280
2231
|
logger.log(
|
|
2281
|
-
` 2. Edit component: ${
|
|
2232
|
+
` 2. Edit component: ${path9__default.default.relative(process.cwd(), path9__default.default.join(blockPath, `${blockName}.tsx`))}`
|
|
2282
2233
|
);
|
|
2283
2234
|
logger.log(
|
|
2284
2235
|
` 3. Register in block registry: src/lib/registry/block-registry.ts`
|
|
@@ -2456,31 +2407,31 @@ async function createComponentCommand(name, options) {
|
|
|
2456
2407
|
};
|
|
2457
2408
|
logger.startSpinner("Creating component files...");
|
|
2458
2409
|
try {
|
|
2459
|
-
const componentPath =
|
|
2410
|
+
const componentPath = path9__default.default.join(
|
|
2460
2411
|
getFeaturesDir(),
|
|
2461
2412
|
"components",
|
|
2462
2413
|
componentName
|
|
2463
2414
|
);
|
|
2464
2415
|
const schemaContent = generateComponentSchema(data);
|
|
2465
2416
|
await writeFile(
|
|
2466
|
-
|
|
2417
|
+
path9__default.default.join(componentPath, `${componentName}.schema.ts`),
|
|
2467
2418
|
schemaContent
|
|
2468
2419
|
);
|
|
2469
2420
|
const componentContent = generateComponent(data);
|
|
2470
2421
|
await writeFile(
|
|
2471
|
-
|
|
2422
|
+
path9__default.default.join(componentPath, `${componentName}.tsx`),
|
|
2472
2423
|
componentContent
|
|
2473
2424
|
);
|
|
2474
2425
|
const indexContent = generateComponentIndex(data);
|
|
2475
|
-
await writeFile(
|
|
2426
|
+
await writeFile(path9__default.default.join(componentPath, "index.ts"), indexContent);
|
|
2476
2427
|
logger.stopSpinner(true, "Component files created successfully!");
|
|
2477
2428
|
logger.newLine();
|
|
2478
2429
|
logger.section("Next steps:");
|
|
2479
2430
|
logger.log(
|
|
2480
|
-
` 1. Edit schema: ${
|
|
2431
|
+
` 1. Edit schema: ${path9__default.default.relative(process.cwd(), path9__default.default.join(componentPath, `${componentName}.schema.ts`))}`
|
|
2481
2432
|
);
|
|
2482
2433
|
logger.log(
|
|
2483
|
-
` 2. Edit component: ${
|
|
2434
|
+
` 2. Edit component: ${path9__default.default.relative(process.cwd(), path9__default.default.join(componentPath, `${componentName}.tsx`))}`
|
|
2484
2435
|
);
|
|
2485
2436
|
logger.log(
|
|
2486
2437
|
` 3. Register in component registry: src/lib/registry/component-registry.ts`
|
|
@@ -2637,13 +2588,13 @@ async function listSections(themeFilter) {
|
|
|
2637
2588
|
return;
|
|
2638
2589
|
}
|
|
2639
2590
|
for (const theme of themes) {
|
|
2640
|
-
const sectionsDir =
|
|
2591
|
+
const sectionsDir = path9__default.default.join(getThemesDir(), theme, "sections");
|
|
2641
2592
|
if (!fs__default.default.existsSync(sectionsDir)) {
|
|
2642
2593
|
continue;
|
|
2643
2594
|
}
|
|
2644
2595
|
const sections = fs__default.default.readdirSync(sectionsDir).filter((name) => {
|
|
2645
|
-
const sectionPath =
|
|
2646
|
-
return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(
|
|
2596
|
+
const sectionPath = path9__default.default.join(sectionsDir, name);
|
|
2597
|
+
return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(path9__default.default.join(sectionPath, "index.ts"));
|
|
2647
2598
|
});
|
|
2648
2599
|
if (sections.length > 0) {
|
|
2649
2600
|
logger.log(chalk4__default.default.cyan(`
|
|
@@ -2657,11 +2608,11 @@ async function listSections(themeFilter) {
|
|
|
2657
2608
|
}
|
|
2658
2609
|
async function listBlocks(themeFilter) {
|
|
2659
2610
|
logger.section("\u{1F9F1} Blocks");
|
|
2660
|
-
const sharedBlocksDir =
|
|
2611
|
+
const sharedBlocksDir = path9__default.default.join(getFeaturesDir(), "blocks");
|
|
2661
2612
|
if (fs__default.default.existsSync(sharedBlocksDir)) {
|
|
2662
2613
|
const sharedBlocks = fs__default.default.readdirSync(sharedBlocksDir).filter((name) => {
|
|
2663
|
-
const blockPath =
|
|
2664
|
-
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(
|
|
2614
|
+
const blockPath = path9__default.default.join(sharedBlocksDir, name);
|
|
2615
|
+
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path9__default.default.join(blockPath, "index.ts"));
|
|
2665
2616
|
});
|
|
2666
2617
|
if (sharedBlocks.length > 0) {
|
|
2667
2618
|
logger.log(chalk4__default.default.cyan("\n Shared:"));
|
|
@@ -2672,13 +2623,13 @@ async function listBlocks(themeFilter) {
|
|
|
2672
2623
|
}
|
|
2673
2624
|
const themes = themeFilter ? [themeFilter] : listThemes();
|
|
2674
2625
|
for (const theme of themes) {
|
|
2675
|
-
const blocksDir =
|
|
2626
|
+
const blocksDir = path9__default.default.join(getThemesDir(), theme, "blocks");
|
|
2676
2627
|
if (!fs__default.default.existsSync(blocksDir)) {
|
|
2677
2628
|
continue;
|
|
2678
2629
|
}
|
|
2679
2630
|
const blocks = fs__default.default.readdirSync(blocksDir).filter((name) => {
|
|
2680
|
-
const blockPath =
|
|
2681
|
-
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(
|
|
2631
|
+
const blockPath = path9__default.default.join(blocksDir, name);
|
|
2632
|
+
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path9__default.default.join(blockPath, "index.ts"));
|
|
2682
2633
|
});
|
|
2683
2634
|
if (blocks.length > 0) {
|
|
2684
2635
|
logger.log(chalk4__default.default.cyan(`
|
|
@@ -2692,14 +2643,14 @@ async function listBlocks(themeFilter) {
|
|
|
2692
2643
|
}
|
|
2693
2644
|
async function listComponents() {
|
|
2694
2645
|
logger.section("\u2699\uFE0F Components");
|
|
2695
|
-
const componentsDir =
|
|
2646
|
+
const componentsDir = path9__default.default.join(getFeaturesDir(), "components");
|
|
2696
2647
|
if (!fs__default.default.existsSync(componentsDir)) {
|
|
2697
2648
|
logger.warning("No components directory found");
|
|
2698
2649
|
return;
|
|
2699
2650
|
}
|
|
2700
2651
|
const components = fs__default.default.readdirSync(componentsDir).filter((name) => {
|
|
2701
|
-
const componentPath =
|
|
2702
|
-
return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(
|
|
2652
|
+
const componentPath = path9__default.default.join(componentsDir, name);
|
|
2653
|
+
return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(path9__default.default.join(componentPath, "index.ts"));
|
|
2703
2654
|
});
|
|
2704
2655
|
if (components.length === 0) {
|
|
2705
2656
|
logger.warning("No components found");
|
|
@@ -2720,11 +2671,11 @@ async function listThemesInfo() {
|
|
|
2720
2671
|
}
|
|
2721
2672
|
logger.log("");
|
|
2722
2673
|
for (const theme of themes) {
|
|
2723
|
-
const themeDir =
|
|
2674
|
+
const themeDir = path9__default.default.join(getThemesDir(), theme);
|
|
2724
2675
|
const candidates = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"];
|
|
2725
2676
|
let manifestContent = "";
|
|
2726
2677
|
for (const candidate of candidates) {
|
|
2727
|
-
const candidatePath =
|
|
2678
|
+
const candidatePath = path9__default.default.join(themeDir, candidate);
|
|
2728
2679
|
if (fs__default.default.existsSync(candidatePath)) {
|
|
2729
2680
|
manifestContent = fs__default.default.readFileSync(candidatePath, "utf-8");
|
|
2730
2681
|
break;
|
|
@@ -2762,9 +2713,9 @@ async function validateCommand(options) {
|
|
|
2762
2713
|
"theme.config.ts",
|
|
2763
2714
|
"bundle-entry.ts",
|
|
2764
2715
|
"manifest.ts"
|
|
2765
|
-
].some((f) => fs__default.default.existsSync(
|
|
2716
|
+
].some((f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f)));
|
|
2766
2717
|
if (isThemeDir) {
|
|
2767
|
-
themeToValidate =
|
|
2718
|
+
themeToValidate = path9__default.default.basename(process.cwd());
|
|
2768
2719
|
logger.info(`Validating current theme: ${themeToValidate}`);
|
|
2769
2720
|
} else {
|
|
2770
2721
|
logger.error(
|
|
@@ -2773,11 +2724,11 @@ async function validateCommand(options) {
|
|
|
2773
2724
|
process.exit(1);
|
|
2774
2725
|
}
|
|
2775
2726
|
}
|
|
2776
|
-
const themePath =
|
|
2727
|
+
const themePath = path9__default.default.join(getThemesDir(), themeToValidate);
|
|
2777
2728
|
logger.startSpinner("Running validation checks...");
|
|
2778
2729
|
const entryFiles = ["manifest.ts", "theme.config.ts", "bundle-entry.ts"];
|
|
2779
2730
|
const foundEntry = entryFiles.find(
|
|
2780
|
-
(f) => fs__default.default.existsSync(
|
|
2731
|
+
(f) => fs__default.default.existsSync(path9__default.default.join(themePath, f))
|
|
2781
2732
|
);
|
|
2782
2733
|
if (!foundEntry) {
|
|
2783
2734
|
issues.push({
|
|
@@ -2787,7 +2738,7 @@ async function validateCommand(options) {
|
|
|
2787
2738
|
});
|
|
2788
2739
|
} else if (foundEntry === "manifest.ts") {
|
|
2789
2740
|
const manifestContent = fs__default.default.readFileSync(
|
|
2790
|
-
|
|
2741
|
+
path9__default.default.join(themePath, foundEntry),
|
|
2791
2742
|
"utf-8"
|
|
2792
2743
|
);
|
|
2793
2744
|
if (!manifestContent.includes("export const") && !manifestContent.includes("export default") && !manifestContent.includes("export interface")) {
|
|
@@ -2798,7 +2749,7 @@ async function validateCommand(options) {
|
|
|
2798
2749
|
});
|
|
2799
2750
|
}
|
|
2800
2751
|
}
|
|
2801
|
-
const configPath =
|
|
2752
|
+
const configPath = path9__default.default.join(themePath, "theme.config.ts");
|
|
2802
2753
|
if (!fs__default.default.existsSync(configPath)) {
|
|
2803
2754
|
issues.push({
|
|
2804
2755
|
type: "warning",
|
|
@@ -2806,7 +2757,7 @@ async function validateCommand(options) {
|
|
|
2806
2757
|
message: "Theme config file not found (recommended)"
|
|
2807
2758
|
});
|
|
2808
2759
|
}
|
|
2809
|
-
const indexPath =
|
|
2760
|
+
const indexPath = path9__default.default.join(themePath, "index.ts");
|
|
2810
2761
|
if (!fs__default.default.existsSync(indexPath)) {
|
|
2811
2762
|
issues.push({
|
|
2812
2763
|
type: "warning",
|
|
@@ -2814,7 +2765,7 @@ async function validateCommand(options) {
|
|
|
2814
2765
|
message: "Index file not found (recommended)"
|
|
2815
2766
|
});
|
|
2816
2767
|
}
|
|
2817
|
-
const sectionsDir =
|
|
2768
|
+
const sectionsDir = path9__default.default.join(themePath, "sections");
|
|
2818
2769
|
if (!fs__default.default.existsSync(sectionsDir)) {
|
|
2819
2770
|
issues.push({
|
|
2820
2771
|
type: "warning",
|
|
@@ -2823,16 +2774,16 @@ async function validateCommand(options) {
|
|
|
2823
2774
|
});
|
|
2824
2775
|
} else {
|
|
2825
2776
|
const sections = fs__default.default.readdirSync(sectionsDir).filter(
|
|
2826
|
-
(name) => fs__default.default.statSync(
|
|
2777
|
+
(name) => fs__default.default.statSync(path9__default.default.join(sectionsDir, name)).isDirectory()
|
|
2827
2778
|
);
|
|
2828
2779
|
for (const sectionName of sections) {
|
|
2829
|
-
const sectionPath =
|
|
2830
|
-
const schemaFile =
|
|
2831
|
-
const defaultTemplate =
|
|
2780
|
+
const sectionPath = path9__default.default.join(sectionsDir, sectionName);
|
|
2781
|
+
const schemaFile = path9__default.default.join(sectionPath, `${sectionName}.schema.ts`);
|
|
2782
|
+
const defaultTemplate = path9__default.default.join(
|
|
2832
2783
|
sectionPath,
|
|
2833
2784
|
`${sectionName}-default.tsx`
|
|
2834
2785
|
);
|
|
2835
|
-
const indexFile =
|
|
2786
|
+
const indexFile = path9__default.default.join(sectionPath, "index.ts");
|
|
2836
2787
|
if (!fs__default.default.existsSync(schemaFile)) {
|
|
2837
2788
|
issues.push({
|
|
2838
2789
|
type: "error",
|
|
@@ -2856,14 +2807,14 @@ async function validateCommand(options) {
|
|
|
2856
2807
|
}
|
|
2857
2808
|
}
|
|
2858
2809
|
}
|
|
2859
|
-
const blocksDir =
|
|
2810
|
+
const blocksDir = path9__default.default.join(themePath, "blocks");
|
|
2860
2811
|
if (fs__default.default.existsSync(blocksDir)) {
|
|
2861
|
-
const blocks = fs__default.default.readdirSync(blocksDir).filter((name) => fs__default.default.statSync(
|
|
2812
|
+
const blocks = fs__default.default.readdirSync(blocksDir).filter((name) => fs__default.default.statSync(path9__default.default.join(blocksDir, name)).isDirectory());
|
|
2862
2813
|
for (const blockName of blocks) {
|
|
2863
|
-
const blockPath =
|
|
2864
|
-
const schemaFile =
|
|
2865
|
-
const componentFile =
|
|
2866
|
-
const indexFile =
|
|
2814
|
+
const blockPath = path9__default.default.join(blocksDir, blockName);
|
|
2815
|
+
const schemaFile = path9__default.default.join(blockPath, `${blockName}.schema.ts`);
|
|
2816
|
+
const componentFile = path9__default.default.join(blockPath, `${blockName}.tsx`);
|
|
2817
|
+
const indexFile = path9__default.default.join(blockPath, "index.ts");
|
|
2867
2818
|
if (!fs__default.default.existsSync(schemaFile)) {
|
|
2868
2819
|
issues.push({
|
|
2869
2820
|
type: "error",
|
|
@@ -2889,13 +2840,13 @@ async function validateCommand(options) {
|
|
|
2889
2840
|
}
|
|
2890
2841
|
if (fs__default.default.existsSync(sectionsDir)) {
|
|
2891
2842
|
const sections = fs__default.default.readdirSync(sectionsDir).filter(
|
|
2892
|
-
(name) => fs__default.default.statSync(
|
|
2843
|
+
(name) => fs__default.default.statSync(path9__default.default.join(sectionsDir, name)).isDirectory()
|
|
2893
2844
|
);
|
|
2894
2845
|
for (const sectionName of sections) {
|
|
2895
|
-
const sectionPath =
|
|
2846
|
+
const sectionPath = path9__default.default.join(sectionsDir, sectionName);
|
|
2896
2847
|
const tsxFiles = fs__default.default.readdirSync(sectionPath).filter((f) => f.endsWith(".tsx") && !f.endsWith(".schema.ts"));
|
|
2897
2848
|
for (const tsxFile of tsxFiles) {
|
|
2898
|
-
const filePath =
|
|
2849
|
+
const filePath = path9__default.default.join(sectionPath, tsxFile);
|
|
2899
2850
|
const content = fs__default.default.readFileSync(filePath, "utf-8");
|
|
2900
2851
|
const relPath = `sections/${sectionName}/${tsxFile}`;
|
|
2901
2852
|
if (!content.includes('"use client"') && !content.includes("'use client'")) {
|
|
@@ -2943,12 +2894,12 @@ async function validateCommand(options) {
|
|
|
2943
2894
|
}
|
|
2944
2895
|
}
|
|
2945
2896
|
}
|
|
2946
|
-
const registryPath =
|
|
2947
|
-
const bundleEntryPath =
|
|
2897
|
+
const registryPath = path9__default.default.join(themePath, "sections-registry.ts");
|
|
2898
|
+
const bundleEntryPath = path9__default.default.join(themePath, "bundle-entry.ts");
|
|
2948
2899
|
const registryContent = fs__default.default.existsSync(registryPath) ? fs__default.default.readFileSync(registryPath, "utf-8") : fs__default.default.existsSync(bundleEntryPath) ? fs__default.default.readFileSync(bundleEntryPath, "utf-8") : "";
|
|
2949
2900
|
if (fs__default.default.existsSync(sectionsDir) && registryContent) {
|
|
2950
2901
|
const sections = fs__default.default.readdirSync(sectionsDir).filter(
|
|
2951
|
-
(name) => fs__default.default.statSync(
|
|
2902
|
+
(name) => fs__default.default.statSync(path9__default.default.join(sectionsDir, name)).isDirectory()
|
|
2952
2903
|
);
|
|
2953
2904
|
for (const sectionName of sections) {
|
|
2954
2905
|
if (!registryContent.includes(`sections/${sectionName}`) && !registryContent.includes(`"${sectionName}"`)) {
|
|
@@ -2971,7 +2922,7 @@ async function validateCommand(options) {
|
|
|
2971
2922
|
});
|
|
2972
2923
|
}
|
|
2973
2924
|
}
|
|
2974
|
-
const pagesDir =
|
|
2925
|
+
const pagesDir = path9__default.default.join(themePath, "pages");
|
|
2975
2926
|
if (fs__default.default.existsSync(pagesDir)) {
|
|
2976
2927
|
const allSchemaTypeSet = new Set(
|
|
2977
2928
|
schemaTypes.map((s) => s.schemaType || s.folderName)
|
|
@@ -3023,9 +2974,9 @@ async function validateCommand(options) {
|
|
|
3023
2974
|
}
|
|
3024
2975
|
async function loadSchemaTypes(themePath, sectionsDir) {
|
|
3025
2976
|
const results = [];
|
|
3026
|
-
const sections = fs__default.default.readdirSync(sectionsDir).filter((name) => fs__default.default.statSync(
|
|
2977
|
+
const sections = fs__default.default.readdirSync(sectionsDir).filter((name) => fs__default.default.statSync(path9__default.default.join(sectionsDir, name)).isDirectory());
|
|
3027
2978
|
for (const sectionName of sections) {
|
|
3028
|
-
const schemaFile =
|
|
2979
|
+
const schemaFile = path9__default.default.join(
|
|
3029
2980
|
sectionsDir,
|
|
3030
2981
|
sectionName,
|
|
3031
2982
|
`${sectionName}.schema.ts`
|
|
@@ -3035,10 +2986,26 @@ async function loadSchemaTypes(themePath, sectionsDir) {
|
|
|
3035
2986
|
continue;
|
|
3036
2987
|
}
|
|
3037
2988
|
const content = fs__default.default.readFileSync(schemaFile, "utf-8");
|
|
3038
|
-
|
|
2989
|
+
let schemaType = null;
|
|
2990
|
+
const schemaExportMatch = content.match(
|
|
2991
|
+
/:\s*SectionSchema\s*=\s*\{[\s\S]*?\btype:\s*["']([^"']+)["']/
|
|
2992
|
+
);
|
|
2993
|
+
if (schemaExportMatch) {
|
|
2994
|
+
schemaType = schemaExportMatch[1];
|
|
2995
|
+
} else {
|
|
2996
|
+
const allTypeMatches = [
|
|
2997
|
+
...content.matchAll(/\btype:\s*["']([^"']+)["']/g)
|
|
2998
|
+
];
|
|
2999
|
+
for (const m of allTypeMatches) {
|
|
3000
|
+
if (!FIELD_TYPES.has(m[1])) {
|
|
3001
|
+
schemaType = m[1];
|
|
3002
|
+
break;
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3039
3006
|
results.push({
|
|
3040
3007
|
folderName: sectionName,
|
|
3041
|
-
schemaType
|
|
3008
|
+
schemaType
|
|
3042
3009
|
});
|
|
3043
3010
|
}
|
|
3044
3011
|
return results;
|
|
@@ -3047,12 +3014,22 @@ async function validatePageSectionTypes(pagesDir, validTypes) {
|
|
|
3047
3014
|
const issues = [];
|
|
3048
3015
|
const files = fs__default.default.readdirSync(pagesDir).filter((f) => f.match(/\.(ts|js)$/));
|
|
3049
3016
|
for (const file of files) {
|
|
3050
|
-
const content = fs__default.default.readFileSync(
|
|
3017
|
+
const content = fs__default.default.readFileSync(path9__default.default.join(pagesDir, file), "utf-8");
|
|
3051
3018
|
const pageName = file.replace(/\.(ts|js)$/, "");
|
|
3052
|
-
const
|
|
3019
|
+
const sectionsMatch = content.match(/\bsections:\s*\[/);
|
|
3020
|
+
if (!sectionsMatch || sectionsMatch.index === void 0) continue;
|
|
3021
|
+
const startIdx = sectionsMatch.index + sectionsMatch[0].length;
|
|
3022
|
+
let depth = 1;
|
|
3023
|
+
let endIdx = startIdx;
|
|
3024
|
+
for (let i = startIdx; i < content.length && depth > 0; i++) {
|
|
3025
|
+
if (content[i] === "[") depth++;
|
|
3026
|
+
else if (content[i] === "]") depth--;
|
|
3027
|
+
endIdx = i;
|
|
3028
|
+
}
|
|
3029
|
+
const sectionsBlock = content.slice(startIdx, endIdx);
|
|
3030
|
+
const typeMatches = sectionsBlock.matchAll(/\btype:\s*["']([^"']+)["']/g);
|
|
3053
3031
|
for (const match of typeMatches) {
|
|
3054
3032
|
const sectionType = match[1];
|
|
3055
|
-
if (isFieldType(sectionType)) continue;
|
|
3056
3033
|
if (!validTypes.has(sectionType)) {
|
|
3057
3034
|
issues.push({
|
|
3058
3035
|
type: "error",
|
|
@@ -3093,11 +3070,18 @@ var FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
|
3093
3070
|
"array",
|
|
3094
3071
|
"object",
|
|
3095
3072
|
"group",
|
|
3096
|
-
"section"
|
|
3073
|
+
"section",
|
|
3074
|
+
"boolean",
|
|
3075
|
+
"color_token",
|
|
3076
|
+
"color_background",
|
|
3077
|
+
"image_picker",
|
|
3078
|
+
"video_url",
|
|
3079
|
+
"font",
|
|
3080
|
+
"font_picker",
|
|
3081
|
+
"text_alignment",
|
|
3082
|
+
"inline_richtext",
|
|
3083
|
+
"repeater"
|
|
3097
3084
|
]);
|
|
3098
|
-
function isFieldType(type) {
|
|
3099
|
-
return FIELD_TYPES.has(type);
|
|
3100
|
-
}
|
|
3101
3085
|
|
|
3102
3086
|
// src/commands/build.ts
|
|
3103
3087
|
init_logger();
|
|
@@ -3108,14 +3092,14 @@ async function buildCommand(options) {
|
|
|
3108
3092
|
if (options.theme) {
|
|
3109
3093
|
themeName = options.theme;
|
|
3110
3094
|
try {
|
|
3111
|
-
const workspaceThemePath =
|
|
3095
|
+
const workspaceThemePath = path9__default.default.join(getThemesDir(), themeName);
|
|
3112
3096
|
if (fs__default.default.existsSync(workspaceThemePath)) {
|
|
3113
3097
|
themePath = workspaceThemePath;
|
|
3114
3098
|
} else {
|
|
3115
|
-
themePath =
|
|
3099
|
+
themePath = path9__default.default.join(process.cwd(), themeName);
|
|
3116
3100
|
}
|
|
3117
3101
|
} catch {
|
|
3118
|
-
themePath =
|
|
3102
|
+
themePath = path9__default.default.join(process.cwd(), themeName);
|
|
3119
3103
|
}
|
|
3120
3104
|
if (!fs__default.default.existsSync(themePath)) {
|
|
3121
3105
|
logger.error(`Theme "${themeName}" not found.`);
|
|
@@ -3126,10 +3110,10 @@ async function buildCommand(options) {
|
|
|
3126
3110
|
"theme.config.ts",
|
|
3127
3111
|
"bundle-entry.ts",
|
|
3128
3112
|
"manifest.ts"
|
|
3129
|
-
].some((f) => fs__default.default.existsSync(
|
|
3113
|
+
].some((f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f)));
|
|
3130
3114
|
if (isThemeDir) {
|
|
3131
3115
|
themePath = process.cwd();
|
|
3132
|
-
themeName =
|
|
3116
|
+
themeName = path9__default.default.basename(themePath);
|
|
3133
3117
|
logger.info(`Building current theme: ${themeName}`);
|
|
3134
3118
|
} else {
|
|
3135
3119
|
logger.error(
|
|
@@ -3138,7 +3122,7 @@ async function buildCommand(options) {
|
|
|
3138
3122
|
process.exit(1);
|
|
3139
3123
|
}
|
|
3140
3124
|
}
|
|
3141
|
-
const packageJsonPath =
|
|
3125
|
+
const packageJsonPath = path9__default.default.join(themePath, "package.json");
|
|
3142
3126
|
const hasPkgJson = fs__default.default.existsSync(packageJsonPath);
|
|
3143
3127
|
if (!hasPkgJson) {
|
|
3144
3128
|
logger.warning(
|
|
@@ -3194,9 +3178,9 @@ async function buildCommand(options) {
|
|
|
3194
3178
|
logger.success("\u2713 Theme built successfully!");
|
|
3195
3179
|
logger.newLine();
|
|
3196
3180
|
logger.info(`Theme: ${themeName}`);
|
|
3197
|
-
const distPath =
|
|
3181
|
+
const distPath = path9__default.default.join(themePath, "dist");
|
|
3198
3182
|
if (fs__default.default.existsSync(distPath)) {
|
|
3199
|
-
logger.log(`Output: ${
|
|
3183
|
+
logger.log(`Output: ${path9__default.default.relative(process.cwd(), distPath)}`);
|
|
3200
3184
|
const files = fs__default.default.readdirSync(distPath);
|
|
3201
3185
|
logger.log(`Files: ${files.length}`);
|
|
3202
3186
|
}
|
|
@@ -3204,17 +3188,17 @@ async function buildCommand(options) {
|
|
|
3204
3188
|
}
|
|
3205
3189
|
function runCommand(command, args, cwd) {
|
|
3206
3190
|
return new Promise((resolve) => {
|
|
3207
|
-
const proc =
|
|
3191
|
+
const proc = child_process.spawn(command, args, {
|
|
3208
3192
|
cwd,
|
|
3209
3193
|
stdio: ["pipe", "pipe", "pipe"],
|
|
3210
3194
|
shell: true
|
|
3211
3195
|
});
|
|
3212
3196
|
let stdout = "";
|
|
3213
3197
|
let stderr = "";
|
|
3214
|
-
proc.stdout
|
|
3198
|
+
proc.stdout.on("data", (data) => {
|
|
3215
3199
|
stdout += data.toString();
|
|
3216
3200
|
});
|
|
3217
|
-
proc.stderr
|
|
3201
|
+
proc.stderr.on("data", (data) => {
|
|
3218
3202
|
stderr += data.toString();
|
|
3219
3203
|
});
|
|
3220
3204
|
proc.on("close", (code) => {
|
|
@@ -3252,7 +3236,7 @@ async function packageCommand(options) {
|
|
|
3252
3236
|
let themeName;
|
|
3253
3237
|
if (options.theme) {
|
|
3254
3238
|
themeName = options.theme;
|
|
3255
|
-
themePath =
|
|
3239
|
+
themePath = path9__default.default.join(getThemesDir(), themeName);
|
|
3256
3240
|
if (!fs__default.default.existsSync(themePath)) {
|
|
3257
3241
|
logger.error(`Theme "${themeName}" not found.`);
|
|
3258
3242
|
process.exit(1);
|
|
@@ -3262,10 +3246,10 @@ async function packageCommand(options) {
|
|
|
3262
3246
|
"theme.config.ts",
|
|
3263
3247
|
"bundle-entry.ts",
|
|
3264
3248
|
"manifest.ts"
|
|
3265
|
-
].some((f) => fs__default.default.existsSync(
|
|
3249
|
+
].some((f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f)));
|
|
3266
3250
|
if (isThemeDir) {
|
|
3267
3251
|
themePath = process.cwd();
|
|
3268
|
-
themeName =
|
|
3252
|
+
themeName = path9__default.default.basename(themePath);
|
|
3269
3253
|
logger.info(`Packaging current theme: ${themeName}`);
|
|
3270
3254
|
} else {
|
|
3271
3255
|
logger.error(
|
|
@@ -3274,7 +3258,7 @@ async function packageCommand(options) {
|
|
|
3274
3258
|
process.exit(1);
|
|
3275
3259
|
}
|
|
3276
3260
|
}
|
|
3277
|
-
const packageJsonPath =
|
|
3261
|
+
const packageJsonPath = path9__default.default.join(themePath, "package.json");
|
|
3278
3262
|
let version2 = "1.0.0";
|
|
3279
3263
|
if (fs__default.default.existsSync(packageJsonPath)) {
|
|
3280
3264
|
const packageJson = await fs__default.default.readJson(packageJsonPath);
|
|
@@ -3284,7 +3268,7 @@ async function packageCommand(options) {
|
|
|
3284
3268
|
logger.info(`Theme: ${themeName}`);
|
|
3285
3269
|
logger.info(`Version: ${version2}`);
|
|
3286
3270
|
logger.newLine();
|
|
3287
|
-
const compiledThemePath =
|
|
3271
|
+
const compiledThemePath = path9__default.default.join(
|
|
3288
3272
|
process.cwd(),
|
|
3289
3273
|
"themes",
|
|
3290
3274
|
themeName,
|
|
@@ -3318,8 +3302,8 @@ async function packageCommand(options) {
|
|
|
3318
3302
|
logger.newLine();
|
|
3319
3303
|
logger.section("Step 2: Create Package");
|
|
3320
3304
|
const packageName = options.name || `${themeName}-${version2}`;
|
|
3321
|
-
const outputDir = options.output ||
|
|
3322
|
-
const outputPath =
|
|
3305
|
+
const outputDir = options.output || path9__default.default.join(process.cwd(), "dist");
|
|
3306
|
+
const outputPath = path9__default.default.join(outputDir, `${packageName}.zip`);
|
|
3323
3307
|
await fs__default.default.ensureDir(outputDir);
|
|
3324
3308
|
logger.startSpinner("Creating zip archive...");
|
|
3325
3309
|
try {
|
|
@@ -3332,11 +3316,11 @@ async function packageCommand(options) {
|
|
|
3332
3316
|
logger.newLine();
|
|
3333
3317
|
logger.info(`Package: ${packageName}.zip`);
|
|
3334
3318
|
logger.log(`Size: ${sizeMB} MB`);
|
|
3335
|
-
logger.log(`Location: ${
|
|
3319
|
+
logger.log(`Location: ${path9__default.default.relative(process.cwd(), outputPath)}`);
|
|
3336
3320
|
logger.newLine();
|
|
3337
3321
|
logger.section("Next steps:");
|
|
3338
3322
|
logger.log(
|
|
3339
|
-
` onexthm deploy --package ${
|
|
3323
|
+
` onexthm deploy --package ${path9__default.default.relative(process.cwd(), outputPath)}`
|
|
3340
3324
|
);
|
|
3341
3325
|
} catch (error) {
|
|
3342
3326
|
logger.stopSpinner(false, "Failed to create package");
|
|
@@ -3348,13 +3332,13 @@ async function packageCommand(options) {
|
|
|
3348
3332
|
}
|
|
3349
3333
|
function runCommand2(command, args) {
|
|
3350
3334
|
return new Promise((resolve) => {
|
|
3351
|
-
const proc =
|
|
3335
|
+
const proc = child_process.spawn(command, args, {
|
|
3352
3336
|
cwd: process.cwd(),
|
|
3353
3337
|
stdio: "pipe",
|
|
3354
3338
|
shell: true
|
|
3355
3339
|
});
|
|
3356
3340
|
let hasError = false;
|
|
3357
|
-
proc.stderr
|
|
3341
|
+
proc.stderr.on("data", (data) => {
|
|
3358
3342
|
const message = data.toString();
|
|
3359
3343
|
if (message.includes("error") || message.includes("Error") || message.includes("ERROR")) {
|
|
3360
3344
|
hasError = true;
|
|
@@ -3394,9 +3378,9 @@ async function deployCommand(options) {
|
|
|
3394
3378
|
ensureOneXProject();
|
|
3395
3379
|
let packagePath;
|
|
3396
3380
|
if (options.package) {
|
|
3397
|
-
packagePath =
|
|
3381
|
+
packagePath = path9__default.default.resolve(options.package);
|
|
3398
3382
|
} else if (options.theme) {
|
|
3399
|
-
const distDir =
|
|
3383
|
+
const distDir = path9__default.default.join(process.cwd(), "dist");
|
|
3400
3384
|
if (!fs__default.default.existsSync(distDir)) {
|
|
3401
3385
|
logger.error("No dist/ directory found. Run 'onexthm package' first.");
|
|
3402
3386
|
process.exit(1);
|
|
@@ -3411,7 +3395,7 @@ async function deployCommand(options) {
|
|
|
3411
3395
|
process.exit(1);
|
|
3412
3396
|
}
|
|
3413
3397
|
packageFiles.sort().reverse();
|
|
3414
|
-
packagePath =
|
|
3398
|
+
packagePath = path9__default.default.join(distDir, packageFiles[0]);
|
|
3415
3399
|
} else {
|
|
3416
3400
|
logger.error("Either --package or --theme must be specified.");
|
|
3417
3401
|
logger.info("Examples:");
|
|
@@ -3425,11 +3409,11 @@ async function deployCommand(options) {
|
|
|
3425
3409
|
}
|
|
3426
3410
|
const stats = await fs__default.default.stat(packagePath);
|
|
3427
3411
|
const sizeMB = (stats.size / 1024 / 1024).toFixed(2);
|
|
3428
|
-
const fileName =
|
|
3412
|
+
const fileName = path9__default.default.basename(packagePath);
|
|
3429
3413
|
logger.newLine();
|
|
3430
3414
|
logger.info(`Package: ${fileName}`);
|
|
3431
3415
|
logger.log(`Size: ${sizeMB} MB`);
|
|
3432
|
-
logger.log(`Path: ${
|
|
3416
|
+
logger.log(`Path: ${path9__default.default.relative(process.cwd(), packagePath)}`);
|
|
3433
3417
|
logger.newLine();
|
|
3434
3418
|
const apiUrl = options.apiUrl || process.env.ONEX_API_URL || "http://localhost:3001";
|
|
3435
3419
|
const uploadEndpoint = `${apiUrl}/website-api/themes/upload`;
|
|
@@ -3533,11 +3517,11 @@ function getBucketName(env) {
|
|
|
3533
3517
|
return environment === "production" ? "theme-s3-bucket" : "theme-s3-bucket";
|
|
3534
3518
|
}
|
|
3535
3519
|
async function findCompiledThemeDir(themeId, version2) {
|
|
3536
|
-
const searchPaths = [
|
|
3520
|
+
const searchPaths = [path9__default.default.resolve(process.cwd(), "dist")];
|
|
3537
3521
|
for (const dir of searchPaths) {
|
|
3538
3522
|
if (await fs__default.default.pathExists(dir)) {
|
|
3539
|
-
const hasManifest = await fs__default.default.pathExists(
|
|
3540
|
-
const hasThemeEntry = await fs__default.default.pathExists(
|
|
3523
|
+
const hasManifest = await fs__default.default.pathExists(path9__default.default.join(dir, "manifest.json"));
|
|
3524
|
+
const hasThemeEntry = await fs__default.default.pathExists(path9__default.default.join(dir, "bundle-entry.js")) || await fs__default.default.pathExists(path9__default.default.join(dir, "theme.config.js")) || await fs__default.default.pathExists(path9__default.default.join(dir, "index.js"));
|
|
3541
3525
|
if (hasManifest || hasThemeEntry) {
|
|
3542
3526
|
return dir;
|
|
3543
3527
|
}
|
|
@@ -3546,7 +3530,7 @@ async function findCompiledThemeDir(themeId, version2) {
|
|
|
3546
3530
|
return null;
|
|
3547
3531
|
}
|
|
3548
3532
|
async function readManifest() {
|
|
3549
|
-
const manifestTsPath =
|
|
3533
|
+
const manifestTsPath = path9__default.default.resolve(process.cwd(), "manifest.ts");
|
|
3550
3534
|
if (await fs__default.default.pathExists(manifestTsPath)) {
|
|
3551
3535
|
try {
|
|
3552
3536
|
const module = await import(manifestTsPath);
|
|
@@ -3555,7 +3539,7 @@ async function readManifest() {
|
|
|
3555
3539
|
logger.warning("Failed to import manifest.ts, trying package.json");
|
|
3556
3540
|
}
|
|
3557
3541
|
}
|
|
3558
|
-
const packageJsonPath =
|
|
3542
|
+
const packageJsonPath = path9__default.default.resolve(process.cwd(), "package.json");
|
|
3559
3543
|
if (await fs__default.default.pathExists(packageJsonPath)) {
|
|
3560
3544
|
const pkg = await fs__default.default.readJson(packageJsonPath);
|
|
3561
3545
|
return {
|
|
@@ -3589,13 +3573,13 @@ async function findSourceDir(themeId, explicitDir) {
|
|
|
3589
3573
|
}
|
|
3590
3574
|
const searchPaths = [
|
|
3591
3575
|
process.cwd(),
|
|
3592
|
-
|
|
3593
|
-
|
|
3576
|
+
path9__default.default.resolve(process.cwd(), `../../themes/${themeId}`),
|
|
3577
|
+
path9__default.default.resolve(process.cwd(), `../themes/${themeId}`)
|
|
3594
3578
|
];
|
|
3595
3579
|
const markers = ["theme.config.ts", "bundle-entry.ts"];
|
|
3596
3580
|
for (const dir of searchPaths) {
|
|
3597
3581
|
for (const marker of markers) {
|
|
3598
|
-
if (await fs__default.default.pathExists(
|
|
3582
|
+
if (await fs__default.default.pathExists(path9__default.default.join(dir, marker))) {
|
|
3599
3583
|
return dir;
|
|
3600
3584
|
}
|
|
3601
3585
|
}
|
|
@@ -3647,7 +3631,7 @@ async function uploadCommand(options) {
|
|
|
3647
3631
|
spinner.succeed(`Found compiled theme at: ${compiledDir}`);
|
|
3648
3632
|
spinner.start("Creating bundle.zip...");
|
|
3649
3633
|
const tmpDir = os__default.default.tmpdir();
|
|
3650
|
-
const bundleZipPath =
|
|
3634
|
+
const bundleZipPath = path9__default.default.join(tmpDir, `${themeId}-${version2}-bundle.zip`);
|
|
3651
3635
|
await createZipFromDir(compiledDir, bundleZipPath);
|
|
3652
3636
|
const bundleZipBuffer = await fs__default.default.readFile(bundleZipPath);
|
|
3653
3637
|
const bundleSizeMB = (bundleZipBuffer.length / 1024 / 1024).toFixed(2);
|
|
@@ -3701,7 +3685,7 @@ async function uploadCommand(options) {
|
|
|
3701
3685
|
if (sourceDir) {
|
|
3702
3686
|
spinner.succeed(`Found source at: ${sourceDir}`);
|
|
3703
3687
|
spinner.start("Creating source.zip...");
|
|
3704
|
-
const sourceZipPath =
|
|
3688
|
+
const sourceZipPath = path9__default.default.join(
|
|
3705
3689
|
tmpDir,
|
|
3706
3690
|
`${themeId}-${version2}-source.zip`
|
|
3707
3691
|
);
|
|
@@ -3835,8 +3819,8 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
|
|
|
3835
3819
|
async function createCompatibilityFiles(outputDir, manifest) {
|
|
3836
3820
|
const entryFile = manifest.output?.entry || "bundle-entry.js";
|
|
3837
3821
|
if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
|
|
3838
|
-
const hashedPath =
|
|
3839
|
-
const stablePath =
|
|
3822
|
+
const hashedPath = path9__default.default.join(outputDir, entryFile);
|
|
3823
|
+
const stablePath = path9__default.default.join(outputDir, "bundle-entry.js");
|
|
3840
3824
|
if (await fs__default.default.pathExists(hashedPath)) {
|
|
3841
3825
|
await fs__default.default.copy(hashedPath, stablePath);
|
|
3842
3826
|
const mapPath = hashedPath + ".map";
|
|
@@ -3845,13 +3829,13 @@ async function createCompatibilityFiles(outputDir, manifest) {
|
|
|
3845
3829
|
}
|
|
3846
3830
|
}
|
|
3847
3831
|
}
|
|
3848
|
-
const sectionsRegistryPath =
|
|
3832
|
+
const sectionsRegistryPath = path9__default.default.join(outputDir, "sections-registry.js");
|
|
3849
3833
|
const content = `// Re-export all sections from bundle-entry
|
|
3850
3834
|
// This file exists to maintain compatibility with the import path
|
|
3851
3835
|
export * from './bundle-entry.js';
|
|
3852
3836
|
`;
|
|
3853
3837
|
await fs__default.default.writeFile(sectionsRegistryPath, content, "utf-8");
|
|
3854
|
-
const pkgJsonPath =
|
|
3838
|
+
const pkgJsonPath = path9__default.default.join(outputDir, "package.json");
|
|
3855
3839
|
await fs__default.default.writeFile(pkgJsonPath, '{\n "type": "module"\n}\n', "utf-8");
|
|
3856
3840
|
}
|
|
3857
3841
|
function showDownloadFailureHelp(themeId, bucket) {
|
|
@@ -3946,7 +3930,7 @@ async function downloadCommand(options) {
|
|
|
3946
3930
|
zip.extractAllTo(outputDir, true);
|
|
3947
3931
|
const entries = zip.getEntries().filter((e) => !e.isDirectory);
|
|
3948
3932
|
spinner.succeed(`Extracted ${entries.length} files to ${outputDir}`);
|
|
3949
|
-
const manifestPath =
|
|
3933
|
+
const manifestPath = path9__default.default.join(outputDir, "manifest.json");
|
|
3950
3934
|
const manifest = await fs__default.default.readJson(manifestPath);
|
|
3951
3935
|
await createCompatibilityFiles(outputDir, manifest);
|
|
3952
3936
|
console.log();
|
|
@@ -4046,9 +4030,10 @@ async function resolveLatestVersion2(s3Client, bucket, themeId) {
|
|
|
4046
4030
|
}
|
|
4047
4031
|
function runInstall(cwd) {
|
|
4048
4032
|
return new Promise((resolve) => {
|
|
4049
|
-
const proc =
|
|
4033
|
+
const proc = child_process.spawn("pnpm", ["install"], {
|
|
4050
4034
|
cwd,
|
|
4051
|
-
stdio: "inherit"
|
|
4035
|
+
stdio: "inherit",
|
|
4036
|
+
shell: true
|
|
4052
4037
|
});
|
|
4053
4038
|
proc.on("close", (code) => resolve(code === 0));
|
|
4054
4039
|
proc.on("error", () => resolve(false));
|
|
@@ -4079,7 +4064,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
4079
4064
|
const oldPrefix = `${oldName}-`;
|
|
4080
4065
|
const newPrefix = `${newName}-`;
|
|
4081
4066
|
const newDisplayName = newName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
4082
|
-
const pkgPath =
|
|
4067
|
+
const pkgPath = path9__default.default.join(themeDir, "package.json");
|
|
4083
4068
|
if (await fs__default.default.pathExists(pkgPath)) {
|
|
4084
4069
|
const pkg = await fs__default.default.readJson(pkgPath);
|
|
4085
4070
|
pkg.name = `@onex-themes/${newName}`;
|
|
@@ -4095,7 +4080,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
4095
4080
|
}
|
|
4096
4081
|
await fs__default.default.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
4097
4082
|
}
|
|
4098
|
-
const configPath =
|
|
4083
|
+
const configPath = path9__default.default.join(themeDir, "theme.config.ts");
|
|
4099
4084
|
if (await fs__default.default.pathExists(configPath)) {
|
|
4100
4085
|
let content = await fs__default.default.readFile(configPath, "utf-8");
|
|
4101
4086
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -4105,7 +4090,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
4105
4090
|
);
|
|
4106
4091
|
await fs__default.default.writeFile(configPath, content);
|
|
4107
4092
|
}
|
|
4108
|
-
const layoutPath =
|
|
4093
|
+
const layoutPath = path9__default.default.join(themeDir, "theme.layout.ts");
|
|
4109
4094
|
if (await fs__default.default.pathExists(layoutPath)) {
|
|
4110
4095
|
let content = await fs__default.default.readFile(layoutPath, "utf-8");
|
|
4111
4096
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -4118,7 +4103,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
4118
4103
|
const oldDisplayName = oldName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
4119
4104
|
const tsFiles = await glob.glob("**/*.ts", { cwd: themeDir, nodir: true });
|
|
4120
4105
|
for (const file of tsFiles) {
|
|
4121
|
-
const filePath =
|
|
4106
|
+
const filePath = path9__default.default.join(themeDir, file);
|
|
4122
4107
|
let content = await fs__default.default.readFile(filePath, "utf-8");
|
|
4123
4108
|
const original = content;
|
|
4124
4109
|
content = content.replace(
|
|
@@ -4147,7 +4132,7 @@ async function cloneCommand(themeName, options) {
|
|
|
4147
4132
|
const spinner = ora__default.default("Initializing clone...").start();
|
|
4148
4133
|
try {
|
|
4149
4134
|
const bucket = options.bucket || getBucketName3(options.environment);
|
|
4150
|
-
const outputDir = options.output ||
|
|
4135
|
+
const outputDir = options.output || path9__default.default.resolve(process.cwd(), newName);
|
|
4151
4136
|
const s3Client = getS3Client3();
|
|
4152
4137
|
if (await fs__default.default.pathExists(outputDir)) {
|
|
4153
4138
|
spinner.fail(chalk4__default.default.red(`Directory already exists: ${outputDir}`));
|
|
@@ -4202,7 +4187,7 @@ async function cloneCommand(themeName, options) {
|
|
|
4202
4187
|
spinner.succeed(
|
|
4203
4188
|
`Renamed theme: ${chalk4__default.default.gray(themeName)} \u2192 ${chalk4__default.default.cyan(newName)}`
|
|
4204
4189
|
);
|
|
4205
|
-
const envExamplePath =
|
|
4190
|
+
const envExamplePath = path9__default.default.join(outputDir, ".env.example");
|
|
4206
4191
|
if (!await fs__default.default.pathExists(envExamplePath)) {
|
|
4207
4192
|
await fs__default.default.writeFile(
|
|
4208
4193
|
envExamplePath,
|
|
@@ -4215,18 +4200,32 @@ async function cloneCommand(themeName, options) {
|
|
|
4215
4200
|
].join("\n")
|
|
4216
4201
|
);
|
|
4217
4202
|
}
|
|
4218
|
-
const
|
|
4219
|
-
|
|
4220
|
-
{
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4203
|
+
const mcpJsonPath = path9__default.default.join(outputDir, ".mcp.json");
|
|
4204
|
+
if (await fs__default.default.pathExists(mcpJsonPath)) {
|
|
4205
|
+
const { default: inquirerMod } = await import('inquirer');
|
|
4206
|
+
const { figmaApiKey } = await inquirerMod.prompt([
|
|
4207
|
+
{
|
|
4208
|
+
type: "password",
|
|
4209
|
+
name: "figmaApiKey",
|
|
4210
|
+
message: "Figma API Key (optional, for Figma-to-code MCP \u2014 press Enter to skip):"
|
|
4211
|
+
}
|
|
4212
|
+
]);
|
|
4213
|
+
let mcpContent = await fs__default.default.readFile(mcpJsonPath, "utf-8");
|
|
4214
|
+
if (figmaApiKey) {
|
|
4215
|
+
mcpContent = mcpContent.replace("__FIGMA_API_KEY__", figmaApiKey);
|
|
4216
|
+
} else {
|
|
4217
|
+
try {
|
|
4218
|
+
const mcpJson = JSON.parse(mcpContent);
|
|
4219
|
+
delete mcpJson.mcpServers?.figma;
|
|
4220
|
+
mcpContent = JSON.stringify(mcpJson, null, 2) + "\n";
|
|
4221
|
+
} catch {
|
|
4222
|
+
}
|
|
4224
4223
|
}
|
|
4225
|
-
|
|
4226
|
-
|
|
4224
|
+
await fs__default.default.writeFile(mcpJsonPath, mcpContent, "utf-8");
|
|
4225
|
+
}
|
|
4227
4226
|
if (options.install !== false) {
|
|
4228
4227
|
const hasPkgJson = await fs__default.default.pathExists(
|
|
4229
|
-
|
|
4228
|
+
path9__default.default.join(outputDir, "package.json")
|
|
4230
4229
|
);
|
|
4231
4230
|
if (hasPkgJson) {
|
|
4232
4231
|
spinner.start("Installing dependencies...");
|
|
@@ -4253,10 +4252,9 @@ async function cloneCommand(themeName, options) {
|
|
|
4253
4252
|
console.log(chalk4__default.default.cyan(" Files: ") + chalk4__default.default.white(entries.length));
|
|
4254
4253
|
console.log();
|
|
4255
4254
|
console.log(chalk4__default.default.cyan("Next steps:"));
|
|
4256
|
-
console.log(chalk4__default.default.gray(` cd ${
|
|
4257
|
-
const copyCmd = process.platform === "win32" ? "copy .env.example .env" : "cp .env.example .env";
|
|
4255
|
+
console.log(chalk4__default.default.gray(` cd ${path9__default.default.relative(process.cwd(), outputDir)}`));
|
|
4258
4256
|
console.log(
|
|
4259
|
-
chalk4__default.default.gray(
|
|
4257
|
+
chalk4__default.default.gray(" cp .env.example .env # then add your Company ID")
|
|
4260
4258
|
);
|
|
4261
4259
|
if (options.install === false) {
|
|
4262
4260
|
console.log(chalk4__default.default.gray(" pnpm install"));
|
|
@@ -4289,7 +4287,7 @@ var MIME_TYPES = {
|
|
|
4289
4287
|
};
|
|
4290
4288
|
function createDevServer(options) {
|
|
4291
4289
|
const clients = /* @__PURE__ */ new Set();
|
|
4292
|
-
const themeDataPath =
|
|
4290
|
+
const themeDataPath = path9__default.default.join(options.distDir, "theme-data.json");
|
|
4293
4291
|
const server = http__default.default.createServer((req, res) => {
|
|
4294
4292
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
4295
4293
|
res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
|
|
@@ -4315,8 +4313,8 @@ function createDevServer(options) {
|
|
|
4315
4313
|
if (pathname.startsWith("/_assets/")) {
|
|
4316
4314
|
const parts = pathname.replace(/^\/_assets\//, "").split("/");
|
|
4317
4315
|
const assetSubpath = parts.slice(1).join("/");
|
|
4318
|
-
const assetPath =
|
|
4319
|
-
if (!assetPath.startsWith(
|
|
4316
|
+
const assetPath = path9__default.default.join(options.themePath, "assets", assetSubpath);
|
|
4317
|
+
if (!assetPath.startsWith(path9__default.default.join(options.themePath, "assets"))) {
|
|
4320
4318
|
res.writeHead(403);
|
|
4321
4319
|
res.end("Forbidden");
|
|
4322
4320
|
return;
|
|
@@ -4327,8 +4325,8 @@ function createDevServer(options) {
|
|
|
4327
4325
|
if (pathname.startsWith("/themes/")) {
|
|
4328
4326
|
const match = pathname.match(/^\/themes\/[^/]+\/assets\/(.+)/);
|
|
4329
4327
|
if (match) {
|
|
4330
|
-
const assetPath =
|
|
4331
|
-
if (!assetPath.startsWith(
|
|
4328
|
+
const assetPath = path9__default.default.join(options.themePath, "assets", match[1]);
|
|
4329
|
+
if (!assetPath.startsWith(path9__default.default.join(options.themePath, "assets"))) {
|
|
4332
4330
|
res.writeHead(403);
|
|
4333
4331
|
res.end("Forbidden");
|
|
4334
4332
|
return;
|
|
@@ -4342,26 +4340,26 @@ function createDevServer(options) {
|
|
|
4342
4340
|
const segments = subpath.split("/");
|
|
4343
4341
|
let assetPath;
|
|
4344
4342
|
if (segments[0] === options.themeName || segments[0] === options.themeName.replace(/^my-/, "")) {
|
|
4345
|
-
assetPath =
|
|
4343
|
+
assetPath = path9__default.default.join(
|
|
4346
4344
|
options.themePath,
|
|
4347
4345
|
"assets",
|
|
4348
4346
|
segments.slice(1).join("/")
|
|
4349
4347
|
);
|
|
4350
4348
|
} else {
|
|
4351
|
-
assetPath =
|
|
4349
|
+
assetPath = path9__default.default.join(options.themePath, "assets", subpath);
|
|
4352
4350
|
}
|
|
4353
|
-
if (assetPath.startsWith(
|
|
4351
|
+
if (assetPath.startsWith(path9__default.default.join(options.themePath, "assets")) && fs3__default.default.existsSync(assetPath)) {
|
|
4354
4352
|
serveFile(res, assetPath);
|
|
4355
4353
|
return;
|
|
4356
4354
|
}
|
|
4357
4355
|
}
|
|
4358
|
-
const filePath =
|
|
4356
|
+
const filePath = path9__default.default.join(options.distDir, pathname);
|
|
4359
4357
|
if (!filePath.startsWith(options.distDir)) {
|
|
4360
4358
|
res.writeHead(403);
|
|
4361
4359
|
res.end("Forbidden");
|
|
4362
4360
|
return;
|
|
4363
4361
|
}
|
|
4364
|
-
if (
|
|
4362
|
+
if (fs3__default.default.existsSync(filePath) && fs3__default.default.statSync(filePath).isFile()) {
|
|
4365
4363
|
serveFile(res, filePath);
|
|
4366
4364
|
} else {
|
|
4367
4365
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
@@ -4393,14 +4391,14 @@ function createDevServer(options) {
|
|
|
4393
4391
|
}
|
|
4394
4392
|
function serveFile(res, filePath) {
|
|
4395
4393
|
try {
|
|
4396
|
-
if (!
|
|
4394
|
+
if (!fs3__default.default.existsSync(filePath)) {
|
|
4397
4395
|
res.writeHead(404);
|
|
4398
4396
|
res.end("Not Found");
|
|
4399
4397
|
return;
|
|
4400
4398
|
}
|
|
4401
|
-
const ext =
|
|
4399
|
+
const ext = path9__default.default.extname(filePath);
|
|
4402
4400
|
const contentType = MIME_TYPES[ext] || "application/octet-stream";
|
|
4403
|
-
const content =
|
|
4401
|
+
const content = fs3__default.default.readFileSync(filePath);
|
|
4404
4402
|
res.writeHead(200, { "Content-Type": contentType });
|
|
4405
4403
|
res.end(content);
|
|
4406
4404
|
} catch {
|
|
@@ -4413,7 +4411,7 @@ function generatePreviewHTML(themeName, port, themeDataPath) {
|
|
|
4413
4411
|
let fontVarsCSS = "";
|
|
4414
4412
|
if (themeDataPath) {
|
|
4415
4413
|
try {
|
|
4416
|
-
const themeData = JSON.parse(
|
|
4414
|
+
const themeData = JSON.parse(fs3__default.default.readFileSync(themeDataPath, "utf-8"));
|
|
4417
4415
|
const typography = (themeData?.themeConfig || themeData?.theme?.config)?.typography?.fontFamily;
|
|
4418
4416
|
if (typography) {
|
|
4419
4417
|
const fontFamilies = /* @__PURE__ */ new Set();
|
|
@@ -4501,14 +4499,14 @@ async function devCommand(options) {
|
|
|
4501
4499
|
if (options.theme) {
|
|
4502
4500
|
themeName = options.theme;
|
|
4503
4501
|
try {
|
|
4504
|
-
const workspaceThemePath =
|
|
4502
|
+
const workspaceThemePath = path9__default.default.join(getThemesDir(), themeName);
|
|
4505
4503
|
if (fs__default.default.existsSync(workspaceThemePath)) {
|
|
4506
4504
|
themePath = workspaceThemePath;
|
|
4507
4505
|
} else {
|
|
4508
|
-
themePath =
|
|
4506
|
+
themePath = path9__default.default.join(process.cwd(), themeName);
|
|
4509
4507
|
}
|
|
4510
4508
|
} catch {
|
|
4511
|
-
themePath =
|
|
4509
|
+
themePath = path9__default.default.join(process.cwd(), themeName);
|
|
4512
4510
|
}
|
|
4513
4511
|
if (!fs__default.default.existsSync(themePath)) {
|
|
4514
4512
|
logger.error(`Theme "${themeName}" not found.`);
|
|
@@ -4519,10 +4517,10 @@ async function devCommand(options) {
|
|
|
4519
4517
|
"theme.config.ts",
|
|
4520
4518
|
"bundle-entry.ts",
|
|
4521
4519
|
"manifest.ts"
|
|
4522
|
-
].some((f) => fs__default.default.existsSync(
|
|
4520
|
+
].some((f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f)));
|
|
4523
4521
|
if (isThemeDir) {
|
|
4524
4522
|
themePath = process.cwd();
|
|
4525
|
-
themeName =
|
|
4523
|
+
themeName = path9__default.default.basename(themePath);
|
|
4526
4524
|
} else {
|
|
4527
4525
|
logger.error(
|
|
4528
4526
|
"Not in a theme directory and no --theme specified. Run from theme root or use --theme flag."
|
|
@@ -4591,9 +4589,9 @@ async function devCommand(options) {
|
|
|
4591
4589
|
watcher.close();
|
|
4592
4590
|
await context2.dispose();
|
|
4593
4591
|
server.close();
|
|
4594
|
-
const shimPath =
|
|
4592
|
+
const shimPath = path9__default.default.join(outputDir, ".process-shim.js");
|
|
4595
4593
|
try {
|
|
4596
|
-
await
|
|
4594
|
+
await fs8__default.default.unlink(shimPath);
|
|
4597
4595
|
} catch {
|
|
4598
4596
|
}
|
|
4599
4597
|
process.exit(0);
|
|
@@ -4602,8 +4600,8 @@ async function devCommand(options) {
|
|
|
4602
4600
|
|
|
4603
4601
|
// src/commands/config.ts
|
|
4604
4602
|
init_logger();
|
|
4605
|
-
var CONFIG_DIR =
|
|
4606
|
-
var CONFIG_FILE =
|
|
4603
|
+
var CONFIG_DIR = path9__default.default.join(os__default.default.homedir(), ".onexthm");
|
|
4604
|
+
var CONFIG_FILE = path9__default.default.join(CONFIG_DIR, ".env");
|
|
4607
4605
|
var CONFIG_ENTRIES = [
|
|
4608
4606
|
{
|
|
4609
4607
|
key: "AWS_ACCESS_KEY_ID",
|
|
@@ -4870,13 +4868,13 @@ async function publishCommand(options) {
|
|
|
4870
4868
|
logger.info(`Logged in as: ${tokens.user.email}`);
|
|
4871
4869
|
let themePath;
|
|
4872
4870
|
if (options.theme) {
|
|
4873
|
-
themePath =
|
|
4871
|
+
themePath = path9__default.default.resolve(options.theme);
|
|
4874
4872
|
} else {
|
|
4875
4873
|
const isThemeDir = [
|
|
4876
4874
|
"theme.config.ts",
|
|
4877
4875
|
"bundle-entry.ts",
|
|
4878
4876
|
"manifest.ts"
|
|
4879
|
-
].some((f) => fs__default.default.existsSync(
|
|
4877
|
+
].some((f) => fs__default.default.existsSync(path9__default.default.join(process.cwd(), f)));
|
|
4880
4878
|
if (isThemeDir) {
|
|
4881
4879
|
themePath = process.cwd();
|
|
4882
4880
|
} else {
|
|
@@ -4886,13 +4884,13 @@ async function publishCommand(options) {
|
|
|
4886
4884
|
process.exit(1);
|
|
4887
4885
|
}
|
|
4888
4886
|
}
|
|
4889
|
-
const pkgPath =
|
|
4887
|
+
const pkgPath = path9__default.default.join(themePath, "package.json");
|
|
4890
4888
|
if (!fs__default.default.existsSync(pkgPath)) {
|
|
4891
4889
|
logger.error("No package.json found in theme directory");
|
|
4892
4890
|
process.exit(1);
|
|
4893
4891
|
}
|
|
4894
4892
|
const pkg = fs__default.default.readJsonSync(pkgPath);
|
|
4895
|
-
const themeId = pkg.name?.replace("@onex-themes/", "") ||
|
|
4893
|
+
const themeId = pkg.name?.replace("@onex-themes/", "") || path9__default.default.basename(themePath);
|
|
4896
4894
|
if (options.bump) {
|
|
4897
4895
|
const currentVersion = pkg.version || "1.0.0";
|
|
4898
4896
|
const newVersion = semver__default.default.inc(currentVersion, options.bump);
|
|
@@ -5024,13 +5022,13 @@ Or use the --bump flag:
|
|
|
5024
5022
|
try {
|
|
5025
5023
|
const archiver3 = await import('archiver');
|
|
5026
5024
|
const { createWriteStream } = await import('fs');
|
|
5027
|
-
const distDir =
|
|
5025
|
+
const distDir = path9__default.default.join(themePath, "dist");
|
|
5028
5026
|
if (!fs__default.default.existsSync(distDir)) {
|
|
5029
5027
|
logger.stopSpinner(false, "No dist/ directory");
|
|
5030
5028
|
logger.error("Build the theme first: onexthm build");
|
|
5031
5029
|
process.exit(1);
|
|
5032
5030
|
}
|
|
5033
|
-
const bundleZipPath =
|
|
5031
|
+
const bundleZipPath = path9__default.default.join(themePath, "dist", "bundle.zip");
|
|
5034
5032
|
await createZip(distDir, bundleZipPath, [
|
|
5035
5033
|
"bundle.zip",
|
|
5036
5034
|
"source.zip",
|
|
@@ -5055,7 +5053,7 @@ Or use the --bump flag:
|
|
|
5055
5053
|
}
|
|
5056
5054
|
logger.startSpinner("Uploading source...");
|
|
5057
5055
|
try {
|
|
5058
|
-
const sourceZipPath =
|
|
5056
|
+
const sourceZipPath = path9__default.default.join(themePath, "dist", "source.zip");
|
|
5059
5057
|
await createZip(themePath, sourceZipPath, [
|
|
5060
5058
|
"node_modules",
|
|
5061
5059
|
"dist",
|
|
@@ -5140,17 +5138,23 @@ async function createZip(sourceDir, outputPath, exclude) {
|
|
|
5140
5138
|
}
|
|
5141
5139
|
|
|
5142
5140
|
// src/cli.ts
|
|
5141
|
+
dotenv__default.default.config({
|
|
5142
|
+
path: path9__default.default.join(process.cwd(), ".env.local"),
|
|
5143
|
+
override: true
|
|
5144
|
+
});
|
|
5145
|
+
dotenv__default.default.config({ path: path9__default.default.join(process.cwd(), ".env") });
|
|
5143
5146
|
try {
|
|
5144
5147
|
const projectRoot = getProjectRoot();
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5148
|
+
if (path9__default.default.resolve(projectRoot) !== path9__default.default.resolve(process.cwd())) {
|
|
5149
|
+
dotenv__default.default.config({
|
|
5150
|
+
path: path9__default.default.join(projectRoot, ".env.local")
|
|
5151
|
+
});
|
|
5152
|
+
dotenv__default.default.config({ path: path9__default.default.join(projectRoot, ".env") });
|
|
5153
|
+
}
|
|
5150
5154
|
} catch {
|
|
5151
5155
|
}
|
|
5152
5156
|
dotenv__default.default.config({
|
|
5153
|
-
path:
|
|
5157
|
+
path: path9__default.default.join(os__default.default.homedir(), ".onexthm", ".env"),
|
|
5154
5158
|
quiet: true
|
|
5155
5159
|
});
|
|
5156
5160
|
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|