@onexapis/cli 1.1.37 → 1.1.39
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 +639 -401
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +633 -396
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +255 -203
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +252 -200
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -4
- package/templates/default/CLAUDE.md +334 -1
- package/templates/default/esbuild.config.js +20 -0
- package/templates/default/pages/about.ts +2 -2
- package/templates/default/pages/forgot-password.ts +1 -3
- package/templates/default/pages/home.ts +4 -4
- package/templates/default/pages/login.ts +1 -3
- package/templates/default/pages/profile.ts +2 -2
- package/templates/default/pages/register.ts +1 -3
- package/templates/default/pages/showcase.ts +7 -7
- package/templates/default/pages/verify-code.ts +1 -3
- package/templates/default/sections/about/about.schema.ts +1 -1
- package/templates/default/sections/auth-forgot-password/auth-forgot-password.schema.ts +1 -1
- package/templates/default/sections/auth-login/auth-login.schema.ts +1 -1
- package/templates/default/sections/auth-register/auth-register.schema.ts +1 -1
- package/templates/default/sections/auth-verify-code/auth-verify-code.schema.ts +1 -1
- 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.schema.ts +1 -1
- package/templates/default/sections/gallery/gallery.schema.ts +1 -1
- package/templates/default/sections/header/header.schema.ts +1 -1
- package/templates/default/sections/hero/hero.schema.ts +1 -1
- package/templates/default/sections/profile/profile.schema.ts +1 -1
- package/templates/default/sections/stats/stats.schema.ts +1 -1
- package/templates/default/sections/testimonials/testimonials.schema.ts +1 -1
- package/templates/default/theme.layout.ts +18 -0
package/dist/index.js
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
var chalk4 = require('chalk');
|
|
4
4
|
var ora = require('ora');
|
|
5
5
|
var esbuild = require('esbuild');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var path8 = require('path');
|
|
7
|
+
var fs7 = require('fs/promises');
|
|
8
8
|
var crypto = require('crypto');
|
|
9
9
|
var glob = require('glob');
|
|
10
10
|
var module$1 = require('module');
|
|
11
|
-
var
|
|
11
|
+
var fs3 = require('fs');
|
|
12
12
|
var child_process = require('child_process');
|
|
13
13
|
var inquirer = require('inquirer');
|
|
14
14
|
var fs = require('fs-extra');
|
|
15
15
|
var ejs = require('ejs');
|
|
16
|
-
var clientS3 = require('@aws-sdk/client-s3');
|
|
17
16
|
var os = require('os');
|
|
17
|
+
var clientS3 = require('@aws-sdk/client-s3');
|
|
18
18
|
var archiver = require('archiver');
|
|
19
19
|
var AdmZip = require('adm-zip');
|
|
20
20
|
|
|
@@ -42,10 +42,10 @@ function _interopNamespace(e) {
|
|
|
42
42
|
var chalk4__default = /*#__PURE__*/_interopDefault(chalk4);
|
|
43
43
|
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
44
44
|
var esbuild__namespace = /*#__PURE__*/_interopNamespace(esbuild);
|
|
45
|
-
var
|
|
46
|
-
var
|
|
45
|
+
var path8__default = /*#__PURE__*/_interopDefault(path8);
|
|
46
|
+
var fs7__default = /*#__PURE__*/_interopDefault(fs7);
|
|
47
47
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
48
|
-
var
|
|
48
|
+
var fs3__default = /*#__PURE__*/_interopDefault(fs3);
|
|
49
49
|
var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
|
|
50
50
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
51
51
|
var ejs__default = /*#__PURE__*/_interopDefault(ejs);
|
|
@@ -139,8 +139,8 @@ async function generateThemeCSS(themePath, outDir) {
|
|
|
139
139
|
const tailwindcss = (await import('tailwindcss')).default;
|
|
140
140
|
const tailwindConfig = {
|
|
141
141
|
content: [
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
path8__default.default.join(themePath, "sections/**/*.{ts,tsx}"),
|
|
143
|
+
path8__default.default.join(themePath, "components/**/*.{ts,tsx}")
|
|
144
144
|
],
|
|
145
145
|
theme: { extend: {} },
|
|
146
146
|
plugins: []
|
|
@@ -150,7 +150,7 @@ async function generateThemeCSS(themePath, outDir) {
|
|
|
150
150
|
inputCSS,
|
|
151
151
|
{ from: void 0 }
|
|
152
152
|
);
|
|
153
|
-
await
|
|
153
|
+
await fs7__default.default.writeFile(path8__default.default.join(outDir, "bundle.css"), result.css);
|
|
154
154
|
exports.logger.info("Generated bundle.css");
|
|
155
155
|
} catch (err) {
|
|
156
156
|
exports.logger.warning(
|
|
@@ -161,12 +161,12 @@ async function generateThemeCSS(themePath, outDir) {
|
|
|
161
161
|
async function resolveNodeModulesFile(startDir, relativePath) {
|
|
162
162
|
let dir = startDir;
|
|
163
163
|
while (true) {
|
|
164
|
-
const candidate =
|
|
164
|
+
const candidate = path8__default.default.join(dir, "node_modules", relativePath);
|
|
165
165
|
try {
|
|
166
|
-
await
|
|
166
|
+
await fs7__default.default.access(candidate);
|
|
167
167
|
return candidate;
|
|
168
168
|
} catch {
|
|
169
|
-
const parent =
|
|
169
|
+
const parent = path8__default.default.dirname(dir);
|
|
170
170
|
if (parent === dir) break;
|
|
171
171
|
dir = parent;
|
|
172
172
|
}
|
|
@@ -190,7 +190,7 @@ async function scanImportsFromPackage(sourceDir, packageName) {
|
|
|
190
190
|
});
|
|
191
191
|
for (const file of sourceFiles) {
|
|
192
192
|
try {
|
|
193
|
-
const content = await
|
|
193
|
+
const content = await fs7__default.default.readFile(path8__default.default.join(sourceDir, file), "utf-8");
|
|
194
194
|
for (const match of content.matchAll(namespaceImportRegex)) {
|
|
195
195
|
const subpath = match[1] ? match[1].slice(1) : "";
|
|
196
196
|
if (!result[subpath]) result[subpath] = /* @__PURE__ */ new Set();
|
|
@@ -244,17 +244,17 @@ function createCoreGlobalPlugin(themePath) {
|
|
|
244
244
|
const distFileName = subpath ? `${subpath}.mjs` : "index.mjs";
|
|
245
245
|
let distPath = await resolveNodeModulesFile(
|
|
246
246
|
themePath,
|
|
247
|
-
|
|
247
|
+
path8__default.default.join("@onexapis", "core", "dist", distFileName)
|
|
248
248
|
);
|
|
249
249
|
if (!distPath) {
|
|
250
250
|
distPath = await resolveNodeModulesFile(
|
|
251
251
|
__dirname,
|
|
252
|
-
|
|
252
|
+
path8__default.default.join("@onexapis", "core", "dist", distFileName)
|
|
253
253
|
);
|
|
254
254
|
}
|
|
255
255
|
try {
|
|
256
256
|
if (!distPath) throw new Error("not found");
|
|
257
|
-
const distContent = await
|
|
257
|
+
const distContent = await fs7__default.default.readFile(distPath, "utf-8");
|
|
258
258
|
const exportMatches = distContent.matchAll(/export\s*\{([^}]+)\}/g);
|
|
259
259
|
for (const m of exportMatches) {
|
|
260
260
|
const names = m[1].split(",").map((n) => {
|
|
@@ -483,7 +483,7 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
483
483
|
const pages = {};
|
|
484
484
|
for (const ext of [".ts", ".js"]) {
|
|
485
485
|
try {
|
|
486
|
-
const mod = await jiti.import(
|
|
486
|
+
const mod = await jiti.import(path8__default.default.join(themePath, `theme.config${ext}`));
|
|
487
487
|
themeConfig = mod.default || mod;
|
|
488
488
|
break;
|
|
489
489
|
} catch {
|
|
@@ -491,20 +491,20 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
491
491
|
}
|
|
492
492
|
for (const ext of [".ts", ".js"]) {
|
|
493
493
|
try {
|
|
494
|
-
const mod = await jiti.import(
|
|
494
|
+
const mod = await jiti.import(path8__default.default.join(themePath, `theme.layout${ext}`));
|
|
495
495
|
layoutConfig = mod.default || mod;
|
|
496
496
|
break;
|
|
497
497
|
} catch {
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
const schemas = {};
|
|
501
|
-
const sectionsDir =
|
|
501
|
+
const sectionsDir = path8__default.default.join(themePath, "sections");
|
|
502
502
|
try {
|
|
503
|
-
const sectionDirs = await
|
|
503
|
+
const sectionDirs = await fs7__default.default.readdir(sectionsDir);
|
|
504
504
|
for (const dir of sectionDirs) {
|
|
505
|
-
const schemaFile =
|
|
505
|
+
const schemaFile = path8__default.default.join(sectionsDir, dir, `${dir}.schema.ts`);
|
|
506
506
|
try {
|
|
507
|
-
await
|
|
507
|
+
await fs7__default.default.access(schemaFile);
|
|
508
508
|
const mod = await jiti.import(schemaFile);
|
|
509
509
|
for (const [key, value] of Object.entries(mod)) {
|
|
510
510
|
if (key.endsWith("Schema") && value && typeof value === "object" && value.type) {
|
|
@@ -516,14 +516,14 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
516
516
|
}
|
|
517
517
|
} catch {
|
|
518
518
|
}
|
|
519
|
-
const pagesDir =
|
|
519
|
+
const pagesDir = path8__default.default.join(themePath, "pages");
|
|
520
520
|
try {
|
|
521
|
-
const files = await
|
|
521
|
+
const files = await fs7__default.default.readdir(pagesDir);
|
|
522
522
|
for (const file of files) {
|
|
523
523
|
if (!file.match(/\.(ts|js)$/)) continue;
|
|
524
524
|
const name = file.replace(/\.(ts|js)$/, "");
|
|
525
525
|
try {
|
|
526
|
-
const mod = await jiti.import(
|
|
526
|
+
const mod = await jiti.import(path8__default.default.join(pagesDir, file));
|
|
527
527
|
const config = mod.default || mod;
|
|
528
528
|
const sections = (config.sections || []).map((section) => {
|
|
529
529
|
const schema = schemas[section.type];
|
|
@@ -551,8 +551,8 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
551
551
|
}
|
|
552
552
|
} catch {
|
|
553
553
|
}
|
|
554
|
-
await
|
|
555
|
-
|
|
554
|
+
await fs7__default.default.writeFile(
|
|
555
|
+
path8__default.default.join(outputDir, "theme-data.json"),
|
|
556
556
|
JSON.stringify(
|
|
557
557
|
{
|
|
558
558
|
themeId,
|
|
@@ -575,36 +575,36 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
575
575
|
exports.logger.info(`Generated theme-data.json (${Object.keys(pages).length} pages)`);
|
|
576
576
|
}
|
|
577
577
|
async function contentHashEntry(outputDir) {
|
|
578
|
-
const entryPath =
|
|
579
|
-
const mapPath =
|
|
578
|
+
const entryPath = path8__default.default.join(outputDir, "bundle-entry.js");
|
|
579
|
+
const mapPath = path8__default.default.join(outputDir, "bundle-entry.js.map");
|
|
580
580
|
const oldFiles = await glob.glob("bundle-entry-*.js*", { cwd: outputDir });
|
|
581
581
|
for (const f of oldFiles) {
|
|
582
|
-
await
|
|
582
|
+
await fs7__default.default.unlink(path8__default.default.join(outputDir, f));
|
|
583
583
|
}
|
|
584
584
|
let entryContent;
|
|
585
585
|
try {
|
|
586
|
-
entryContent = await
|
|
586
|
+
entryContent = await fs7__default.default.readFile(entryPath, "utf-8");
|
|
587
587
|
} catch {
|
|
588
|
-
const indexPath =
|
|
588
|
+
const indexPath = path8__default.default.join(outputDir, "index.js");
|
|
589
589
|
try {
|
|
590
|
-
entryContent = await
|
|
590
|
+
entryContent = await fs7__default.default.readFile(indexPath, "utf-8");
|
|
591
591
|
} catch {
|
|
592
592
|
exports.logger.warning("No entry file found in output, skipping content hash");
|
|
593
593
|
return;
|
|
594
594
|
}
|
|
595
595
|
const hash2 = crypto__default.default.createHash("sha256").update(entryContent).digest("hex").slice(0, 8);
|
|
596
596
|
const hashedName2 = `bundle-entry-${hash2}.js`;
|
|
597
|
-
const indexMapPath =
|
|
597
|
+
const indexMapPath = path8__default.default.join(outputDir, "index.js.map");
|
|
598
598
|
const hashedMapName2 = `bundle-entry-${hash2}.js.map`;
|
|
599
599
|
entryContent = entryContent.replace(
|
|
600
600
|
/\/\/# sourceMappingURL=index\.js\.map/,
|
|
601
601
|
`//# sourceMappingURL=${hashedMapName2}`
|
|
602
602
|
);
|
|
603
|
-
await
|
|
604
|
-
await
|
|
603
|
+
await fs7__default.default.writeFile(path8__default.default.join(outputDir, hashedName2), entryContent);
|
|
604
|
+
await fs7__default.default.unlink(indexPath);
|
|
605
605
|
try {
|
|
606
|
-
await
|
|
607
|
-
await
|
|
606
|
+
await fs7__default.default.access(indexMapPath);
|
|
607
|
+
await fs7__default.default.rename(indexMapPath, path8__default.default.join(outputDir, hashedMapName2));
|
|
608
608
|
} catch {
|
|
609
609
|
}
|
|
610
610
|
exports.logger.info(`Entry hashed: ${hashedName2}`);
|
|
@@ -617,11 +617,11 @@ async function contentHashEntry(outputDir) {
|
|
|
617
617
|
/\/\/# sourceMappingURL=bundle-entry\.js\.map/,
|
|
618
618
|
`//# sourceMappingURL=${hashedMapName}`
|
|
619
619
|
);
|
|
620
|
-
await
|
|
621
|
-
await
|
|
620
|
+
await fs7__default.default.writeFile(path8__default.default.join(outputDir, hashedName), entryContent);
|
|
621
|
+
await fs7__default.default.unlink(entryPath);
|
|
622
622
|
try {
|
|
623
|
-
await
|
|
624
|
-
await
|
|
623
|
+
await fs7__default.default.access(mapPath);
|
|
624
|
+
await fs7__default.default.rename(mapPath, path8__default.default.join(outputDir, hashedMapName));
|
|
625
625
|
} catch {
|
|
626
626
|
}
|
|
627
627
|
exports.logger.info(`Entry hashed: ${hashedName}`);
|
|
@@ -633,7 +633,7 @@ async function extractDataRequirements(themePath) {
|
|
|
633
633
|
const requirements = {};
|
|
634
634
|
for (const file of schemaFiles) {
|
|
635
635
|
try {
|
|
636
|
-
const mod = await jiti.import(
|
|
636
|
+
const mod = await jiti.import(path8__default.default.join(themePath, file));
|
|
637
637
|
const exports$1 = mod;
|
|
638
638
|
for (const value of Object.values(exports$1)) {
|
|
639
639
|
if (value && typeof value === "object" && typeof value.type === "string" && value.dataRequirements && typeof value.dataRequirements === "object") {
|
|
@@ -652,8 +652,8 @@ async function generateManifest(themeName, themePath, outputDir) {
|
|
|
652
652
|
let version = "1.0.0";
|
|
653
653
|
let themeId = themeName;
|
|
654
654
|
try {
|
|
655
|
-
const pkgContent = await
|
|
656
|
-
|
|
655
|
+
const pkgContent = await fs7__default.default.readFile(
|
|
656
|
+
path8__default.default.join(themePath, "package.json"),
|
|
657
657
|
"utf-8"
|
|
658
658
|
);
|
|
659
659
|
const pkg = JSON.parse(pkgContent);
|
|
@@ -671,7 +671,7 @@ async function generateManifest(themeName, themePath, outputDir) {
|
|
|
671
671
|
const dataRequirements = await extractDataRequirements(themePath);
|
|
672
672
|
let hasThemeConfig = false;
|
|
673
673
|
try {
|
|
674
|
-
await
|
|
674
|
+
await fs7__default.default.access(path8__default.default.join(themePath, "theme.config.ts"));
|
|
675
675
|
hasThemeConfig = true;
|
|
676
676
|
} catch {
|
|
677
677
|
}
|
|
@@ -712,24 +712,24 @@ async function generateManifest(themeName, themePath, outputDir) {
|
|
|
712
712
|
// Section data requirements for server-side prefetching (keyed by section type)
|
|
713
713
|
dataRequirements
|
|
714
714
|
};
|
|
715
|
-
await
|
|
716
|
-
|
|
715
|
+
await fs7__default.default.writeFile(
|
|
716
|
+
path8__default.default.join(outputDir, "manifest.json"),
|
|
717
717
|
JSON.stringify(manifest, null, 2)
|
|
718
718
|
);
|
|
719
719
|
}
|
|
720
720
|
async function compileStandaloneTheme(themePath, themeName) {
|
|
721
|
-
const outputDir =
|
|
722
|
-
const bundleEntry =
|
|
723
|
-
const indexEntry =
|
|
721
|
+
const outputDir = path8__default.default.join(themePath, "dist");
|
|
722
|
+
const bundleEntry = path8__default.default.join(themePath, "bundle-entry.ts");
|
|
723
|
+
const indexEntry = path8__default.default.join(themePath, "index.ts");
|
|
724
724
|
let entryPoint = indexEntry;
|
|
725
725
|
try {
|
|
726
|
-
await
|
|
726
|
+
await fs7__default.default.access(bundleEntry);
|
|
727
727
|
entryPoint = bundleEntry;
|
|
728
728
|
} catch {
|
|
729
729
|
}
|
|
730
|
-
const shimPath =
|
|
731
|
-
await
|
|
732
|
-
await
|
|
730
|
+
const shimPath = path8__default.default.join(outputDir, ".process-shim.js");
|
|
731
|
+
await fs7__default.default.mkdir(outputDir, { recursive: true });
|
|
732
|
+
await fs7__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
733
733
|
const buildOptions = {
|
|
734
734
|
entryPoints: [entryPoint],
|
|
735
735
|
bundle: true,
|
|
@@ -779,7 +779,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
779
779
|
try {
|
|
780
780
|
const result = await esbuild__namespace.build(buildOptions);
|
|
781
781
|
try {
|
|
782
|
-
await
|
|
782
|
+
await fs7__default.default.unlink(shimPath);
|
|
783
783
|
} catch {
|
|
784
784
|
}
|
|
785
785
|
await contentHashEntry(outputDir);
|
|
@@ -798,7 +798,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
798
798
|
return true;
|
|
799
799
|
} catch (error) {
|
|
800
800
|
try {
|
|
801
|
-
await
|
|
801
|
+
await fs7__default.default.unlink(shimPath);
|
|
802
802
|
} catch {
|
|
803
803
|
}
|
|
804
804
|
exports.logger.error(`esbuild compilation failed: ${error}`);
|
|
@@ -806,18 +806,18 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
808
|
async function compileStandaloneThemeDev(themePath, themeName) {
|
|
809
|
-
const outputDir =
|
|
810
|
-
const bundleEntry =
|
|
811
|
-
const indexEntry =
|
|
809
|
+
const outputDir = path8__default.default.join(themePath, "dist");
|
|
810
|
+
const bundleEntry = path8__default.default.join(themePath, "bundle-entry.ts");
|
|
811
|
+
const indexEntry = path8__default.default.join(themePath, "index.ts");
|
|
812
812
|
let entryPoint = indexEntry;
|
|
813
813
|
try {
|
|
814
|
-
await
|
|
814
|
+
await fs7__default.default.access(bundleEntry);
|
|
815
815
|
entryPoint = bundleEntry;
|
|
816
816
|
} catch {
|
|
817
817
|
}
|
|
818
|
-
const shimPath =
|
|
819
|
-
await
|
|
820
|
-
await
|
|
818
|
+
const shimPath = path8__default.default.join(outputDir, ".process-shim.js");
|
|
819
|
+
await fs7__default.default.mkdir(outputDir, { recursive: true });
|
|
820
|
+
await fs7__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
821
821
|
const buildOptions = {
|
|
822
822
|
entryPoints: [entryPoint],
|
|
823
823
|
bundle: true,
|
|
@@ -870,18 +870,18 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
870
870
|
return { context: context2, outputDir };
|
|
871
871
|
}
|
|
872
872
|
async function compilePreviewRuntime(themePath) {
|
|
873
|
-
const outputDir =
|
|
874
|
-
await
|
|
875
|
-
const outputPath =
|
|
873
|
+
const outputDir = path8__default.default.join(themePath, "dist");
|
|
874
|
+
await fs7__default.default.mkdir(outputDir, { recursive: true });
|
|
875
|
+
const outputPath = path8__default.default.join(outputDir, "preview-runtime.js");
|
|
876
876
|
const locations = [
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
877
|
+
path8__default.default.join(__dirname, "..", "preview", "preview-app.tsx"),
|
|
878
|
+
path8__default.default.join(__dirname, "preview", "preview-app.tsx"),
|
|
879
|
+
path8__default.default.join(__dirname, "..", "..", "src", "preview", "preview-app.tsx")
|
|
880
880
|
];
|
|
881
881
|
let previewEntryPath = null;
|
|
882
882
|
for (const loc of locations) {
|
|
883
883
|
try {
|
|
884
|
-
await
|
|
884
|
+
await fs7__default.default.access(loc);
|
|
885
885
|
previewEntryPath = loc;
|
|
886
886
|
break;
|
|
887
887
|
} catch {
|
|
@@ -964,10 +964,10 @@ ${locations.join("\n")}`
|
|
|
964
964
|
if (!lucideScanned) {
|
|
965
965
|
lucideScanned = true;
|
|
966
966
|
const coreSrcCandidates = [
|
|
967
|
-
|
|
968
|
-
|
|
967
|
+
path8__default.default.join(themePath, "node_modules", "@onexapis", "core", "src"),
|
|
968
|
+
path8__default.default.join(themePath, "..", "..", "packages", "core", "src"),
|
|
969
969
|
// monorepo sibling
|
|
970
|
-
|
|
970
|
+
path8__default.default.join(
|
|
971
971
|
__dirname,
|
|
972
972
|
"..",
|
|
973
973
|
"..",
|
|
@@ -982,7 +982,7 @@ ${locations.join("\n")}`
|
|
|
982
982
|
let coreSourceDir = null;
|
|
983
983
|
for (const candidate of coreSrcCandidates) {
|
|
984
984
|
try {
|
|
985
|
-
await
|
|
985
|
+
await fs7__default.default.access(candidate);
|
|
986
986
|
coreSourceDir = candidate;
|
|
987
987
|
break;
|
|
988
988
|
} catch {
|
|
@@ -1001,21 +1001,21 @@ ${locations.join("\n")}`
|
|
|
1001
1001
|
}
|
|
1002
1002
|
} else {
|
|
1003
1003
|
const coreDistCandidates = [
|
|
1004
|
-
|
|
1004
|
+
path8__default.default.join(themePath, "node_modules", "@onexapis", "core", "dist")
|
|
1005
1005
|
];
|
|
1006
1006
|
const resolvedDist = await resolveNodeModulesFile(
|
|
1007
1007
|
__dirname,
|
|
1008
|
-
|
|
1008
|
+
path8__default.default.join("@onexapis", "core", "dist")
|
|
1009
1009
|
);
|
|
1010
1010
|
if (resolvedDist) coreDistCandidates.push(resolvedDist);
|
|
1011
1011
|
for (const candidate of coreDistCandidates) {
|
|
1012
1012
|
try {
|
|
1013
|
-
await
|
|
1013
|
+
await fs7__default.default.access(candidate);
|
|
1014
1014
|
const mjsFiles = await glob.glob("*.mjs", { cwd: candidate });
|
|
1015
1015
|
const importRegex = /import\s*\{([^}]+)\}\s*from\s*["']lucide-react["']/g;
|
|
1016
1016
|
for (const file of mjsFiles) {
|
|
1017
|
-
const content = await
|
|
1018
|
-
|
|
1017
|
+
const content = await fs7__default.default.readFile(
|
|
1018
|
+
path8__default.default.join(candidate, file),
|
|
1019
1019
|
"utf-8"
|
|
1020
1020
|
);
|
|
1021
1021
|
for (const match of content.matchAll(importRegex)) {
|
|
@@ -1070,7 +1070,7 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
1070
1070
|
const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) || __filename);
|
|
1071
1071
|
const cjsPath = req.resolve("framer-motion");
|
|
1072
1072
|
const pkgDir = cjsPath.replace(/[/\\]dist[/\\].*$/, "");
|
|
1073
|
-
const esmEntry =
|
|
1073
|
+
const esmEntry = path8__default.default.join(pkgDir, "dist", "es", "index.mjs");
|
|
1074
1074
|
const { existsSync } = await import('fs');
|
|
1075
1075
|
if (existsSync(esmEntry)) {
|
|
1076
1076
|
return { path: esmEntry, namespace: "file" };
|
|
@@ -1169,8 +1169,8 @@ export function headers() { return new Headers(); }
|
|
|
1169
1169
|
});
|
|
1170
1170
|
}
|
|
1171
1171
|
};
|
|
1172
|
-
const shimPath =
|
|
1173
|
-
await
|
|
1172
|
+
const shimPath = path8__default.default.join(outputDir, ".process-shim-preview.js");
|
|
1173
|
+
await fs7__default.default.writeFile(shimPath, PROCESS_SHIM);
|
|
1174
1174
|
await esbuild__namespace.build({
|
|
1175
1175
|
entryPoints: [previewEntryPath],
|
|
1176
1176
|
bundle: true,
|
|
@@ -1205,7 +1205,7 @@ export function headers() { return new Headers(); }
|
|
|
1205
1205
|
}
|
|
1206
1206
|
});
|
|
1207
1207
|
try {
|
|
1208
|
-
await
|
|
1208
|
+
await fs7__default.default.unlink(shimPath);
|
|
1209
1209
|
} catch {
|
|
1210
1210
|
}
|
|
1211
1211
|
return outputPath;
|
|
@@ -1352,8 +1352,8 @@ function validateThemeName(name) {
|
|
|
1352
1352
|
return /^[a-z][a-z0-9-]*$/.test(name);
|
|
1353
1353
|
}
|
|
1354
1354
|
function pathExists(filePath) {
|
|
1355
|
-
const
|
|
1356
|
-
return
|
|
1355
|
+
const fs12 = __require("fs-extra");
|
|
1356
|
+
return fs12.existsSync(filePath);
|
|
1357
1357
|
}
|
|
1358
1358
|
function validateCategory(category) {
|
|
1359
1359
|
const validCategories = [
|
|
@@ -1394,18 +1394,18 @@ async function renderTemplate(templatePath, data) {
|
|
|
1394
1394
|
return ejs__default.default.render(template, data);
|
|
1395
1395
|
}
|
|
1396
1396
|
async function writeFile(filePath, content) {
|
|
1397
|
-
await fs__default.default.ensureDir(
|
|
1397
|
+
await fs__default.default.ensureDir(path8__default.default.dirname(filePath));
|
|
1398
1398
|
await fs__default.default.writeFile(filePath, content, "utf-8");
|
|
1399
1399
|
}
|
|
1400
1400
|
function getTemplatesDir() {
|
|
1401
1401
|
const locations = [
|
|
1402
|
-
|
|
1402
|
+
path8__default.default.join(__dirname, "../../templates"),
|
|
1403
1403
|
// Development
|
|
1404
|
-
|
|
1404
|
+
path8__default.default.join(__dirname, "../templates"),
|
|
1405
1405
|
// Production (dist/)
|
|
1406
|
-
|
|
1406
|
+
path8__default.default.join(process.cwd(), "templates"),
|
|
1407
1407
|
// Fallback
|
|
1408
|
-
|
|
1408
|
+
path8__default.default.join(process.cwd(), "packages/cli/templates")
|
|
1409
1409
|
// Monorepo
|
|
1410
1410
|
];
|
|
1411
1411
|
for (const location of locations) {
|
|
@@ -1417,7 +1417,7 @@ function getTemplatesDir() {
|
|
|
1417
1417
|
}
|
|
1418
1418
|
async function copyTemplate(templateName, targetDir, data) {
|
|
1419
1419
|
const templatesDir = getTemplatesDir();
|
|
1420
|
-
const templateDir =
|
|
1420
|
+
const templateDir = path8__default.default.join(templatesDir, templateName);
|
|
1421
1421
|
if (!fs__default.default.existsSync(templateDir)) {
|
|
1422
1422
|
throw new Error(
|
|
1423
1423
|
`Template "${templateName}" not found at ${templateDir}. Available templates: ${fs__default.default.readdirSync(templatesDir).join(", ")}`
|
|
@@ -1426,8 +1426,8 @@ async function copyTemplate(templateName, targetDir, data) {
|
|
|
1426
1426
|
await fs__default.default.ensureDir(targetDir);
|
|
1427
1427
|
const files = await fs__default.default.readdir(templateDir);
|
|
1428
1428
|
for (const file of files) {
|
|
1429
|
-
const templatePath =
|
|
1430
|
-
const targetPath =
|
|
1429
|
+
const templatePath = path8__default.default.join(templateDir, file);
|
|
1430
|
+
const targetPath = path8__default.default.join(targetDir, file);
|
|
1431
1431
|
const stat = await fs__default.default.stat(templatePath);
|
|
1432
1432
|
if (stat.isDirectory()) {
|
|
1433
1433
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -1444,8 +1444,8 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
1444
1444
|
await fs__default.default.ensureDir(targetDir);
|
|
1445
1445
|
const files = await fs__default.default.readdir(templateDir);
|
|
1446
1446
|
for (const file of files) {
|
|
1447
|
-
const templatePath =
|
|
1448
|
-
const targetPath =
|
|
1447
|
+
const templatePath = path8__default.default.join(templateDir, file);
|
|
1448
|
+
const targetPath = path8__default.default.join(targetDir, file);
|
|
1449
1449
|
const stat = await fs__default.default.stat(templatePath);
|
|
1450
1450
|
if (stat.isDirectory()) {
|
|
1451
1451
|
await copyTemplateDir(templatePath, targetPath, data);
|
|
@@ -1460,32 +1460,32 @@ async function copyTemplateDir(templateDir, targetDir, data) {
|
|
|
1460
1460
|
}
|
|
1461
1461
|
function getProjectRoot() {
|
|
1462
1462
|
let currentDir = process.cwd();
|
|
1463
|
-
while (currentDir !==
|
|
1464
|
-
const packageJsonPath =
|
|
1463
|
+
while (currentDir !== path8__default.default.parse(currentDir).root) {
|
|
1464
|
+
const packageJsonPath = path8__default.default.join(currentDir, "package.json");
|
|
1465
1465
|
if (fs__default.default.existsSync(packageJsonPath)) {
|
|
1466
1466
|
const packageJson = fs__default.default.readJsonSync(packageJsonPath);
|
|
1467
|
-
if (packageJson.workspaces || fs__default.default.existsSync(
|
|
1467
|
+
if (packageJson.workspaces || fs__default.default.existsSync(path8__default.default.join(currentDir, "src/themes")) || fs__default.default.existsSync(path8__default.default.join(currentDir, "themes"))) {
|
|
1468
1468
|
return currentDir;
|
|
1469
1469
|
}
|
|
1470
1470
|
}
|
|
1471
|
-
currentDir =
|
|
1471
|
+
currentDir = path8__default.default.dirname(currentDir);
|
|
1472
1472
|
}
|
|
1473
1473
|
return process.cwd();
|
|
1474
1474
|
}
|
|
1475
1475
|
function getThemesDir() {
|
|
1476
1476
|
const root = getProjectRoot();
|
|
1477
|
-
if (fs__default.default.existsSync(
|
|
1478
|
-
return
|
|
1479
|
-
if (fs__default.default.existsSync(
|
|
1480
|
-
return
|
|
1481
|
-
return
|
|
1477
|
+
if (fs__default.default.existsSync(path8__default.default.join(root, "themes")))
|
|
1478
|
+
return path8__default.default.join(root, "themes");
|
|
1479
|
+
if (fs__default.default.existsSync(path8__default.default.join(root, "src/themes")))
|
|
1480
|
+
return path8__default.default.join(root, "src/themes");
|
|
1481
|
+
return path8__default.default.dirname(root);
|
|
1482
1482
|
}
|
|
1483
1483
|
function getFeaturesDir() {
|
|
1484
|
-
return
|
|
1484
|
+
return path8__default.default.join(getProjectRoot(), "src/features");
|
|
1485
1485
|
}
|
|
1486
1486
|
function isOneXProject() {
|
|
1487
1487
|
const root = getProjectRoot();
|
|
1488
|
-
return fs__default.default.existsSync(
|
|
1488
|
+
return fs__default.default.existsSync(path8__default.default.join(root, "themes")) || fs__default.default.existsSync(path8__default.default.join(root, "src/themes")) || fs__default.default.existsSync(path8__default.default.join(root, "theme.config.ts")) || fs__default.default.existsSync(path8__default.default.join(root, "bundle-entry.ts"));
|
|
1489
1489
|
}
|
|
1490
1490
|
function ensureOneXProject() {
|
|
1491
1491
|
if (!isOneXProject()) {
|
|
@@ -1501,13 +1501,13 @@ function listThemes() {
|
|
|
1501
1501
|
return [];
|
|
1502
1502
|
}
|
|
1503
1503
|
return fs__default.default.readdirSync(themesDir).filter((name) => {
|
|
1504
|
-
const themePath =
|
|
1505
|
-
return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(
|
|
1504
|
+
const themePath = path8__default.default.join(themesDir, name);
|
|
1505
|
+
return fs__default.default.statSync(themePath).isDirectory() && (fs__default.default.existsSync(path8__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path8__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path8__default.default.join(themePath, "manifest.ts")));
|
|
1506
1506
|
});
|
|
1507
1507
|
}
|
|
1508
1508
|
function themeExists(themeName) {
|
|
1509
|
-
const themePath =
|
|
1510
|
-
return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(
|
|
1509
|
+
const themePath = path8__default.default.join(getThemesDir(), themeName);
|
|
1510
|
+
return fs__default.default.existsSync(themePath) && (fs__default.default.existsSync(path8__default.default.join(themePath, "theme.config.ts")) || fs__default.default.existsSync(path8__default.default.join(themePath, "bundle-entry.ts")) || fs__default.default.existsSync(path8__default.default.join(themePath, "manifest.ts")));
|
|
1511
1511
|
}
|
|
1512
1512
|
function detectPackageManager() {
|
|
1513
1513
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
@@ -1515,9 +1515,9 @@ function detectPackageManager() {
|
|
|
1515
1515
|
if (userAgent.includes("yarn")) return "yarn";
|
|
1516
1516
|
if (userAgent.includes("bun")) return "bun";
|
|
1517
1517
|
const cwd = process.cwd();
|
|
1518
|
-
if (fs__default.default.existsSync(
|
|
1519
|
-
if (fs__default.default.existsSync(
|
|
1520
|
-
if (fs__default.default.existsSync(
|
|
1518
|
+
if (fs__default.default.existsSync(path8__default.default.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
1519
|
+
if (fs__default.default.existsSync(path8__default.default.join(cwd, "yarn.lock"))) return "yarn";
|
|
1520
|
+
if (fs__default.default.existsSync(path8__default.default.join(cwd, "bun.lockb"))) return "bun";
|
|
1521
1521
|
return "npm";
|
|
1522
1522
|
}
|
|
1523
1523
|
async function installDependencies(projectPath, packageManager = "npm") {
|
|
@@ -1534,6 +1534,11 @@ async function installDependencies(projectPath, packageManager = "npm") {
|
|
|
1534
1534
|
}
|
|
1535
1535
|
});
|
|
1536
1536
|
}
|
|
1537
|
+
var AUTH_DIR = path8__default.default.join(os__default.default.homedir(), ".onexthm");
|
|
1538
|
+
path8__default.default.join(AUTH_DIR, "auth.json");
|
|
1539
|
+
function getApiUrl() {
|
|
1540
|
+
return process.env.ONEXTHM_API_URL || process.env.NEXT_PUBLIC_API_URL || "https://platform-dev.onexeos.com";
|
|
1541
|
+
}
|
|
1537
1542
|
|
|
1538
1543
|
// src/commands/init.ts
|
|
1539
1544
|
async function initCommand(projectName, options = {}) {
|
|
@@ -1551,7 +1556,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1551
1556
|
if (!validateThemeName(kebabName)) {
|
|
1552
1557
|
return "Invalid project name. Use lowercase letters, numbers, and hyphens only.";
|
|
1553
1558
|
}
|
|
1554
|
-
if (
|
|
1559
|
+
if (fs3__default.default.existsSync(path8__default.default.join(process.cwd(), kebabName))) {
|
|
1555
1560
|
return `Directory "${kebabName}" already exists`;
|
|
1556
1561
|
}
|
|
1557
1562
|
return true;
|
|
@@ -1562,11 +1567,46 @@ async function initCommand(projectName, options = {}) {
|
|
|
1562
1567
|
} else {
|
|
1563
1568
|
name = toKebabCase(projectName);
|
|
1564
1569
|
}
|
|
1565
|
-
const projectPath =
|
|
1566
|
-
if (
|
|
1570
|
+
const projectPath = path8__default.default.join(process.cwd(), name);
|
|
1571
|
+
if (fs3__default.default.existsSync(projectPath)) {
|
|
1567
1572
|
exports.logger.error(`Directory "${name}" already exists.`);
|
|
1568
1573
|
process.exit(1);
|
|
1569
1574
|
}
|
|
1575
|
+
if (!options.yes) {
|
|
1576
|
+
try {
|
|
1577
|
+
const apiUrl = getApiUrl();
|
|
1578
|
+
const controller = new AbortController();
|
|
1579
|
+
const timeout = setTimeout(() => controller.abort(), 3e3);
|
|
1580
|
+
const response = await fetch(
|
|
1581
|
+
`${apiUrl}/website-api/themes/${encodeURIComponent(name)}/exists`,
|
|
1582
|
+
{ signal: controller.signal }
|
|
1583
|
+
);
|
|
1584
|
+
clearTimeout(timeout);
|
|
1585
|
+
if (response.ok) {
|
|
1586
|
+
const data2 = await response.json();
|
|
1587
|
+
const body = data2.statusCode ? data2.body : data2;
|
|
1588
|
+
if (body.exists && body.owner === "other") {
|
|
1589
|
+
exports.logger.warning(
|
|
1590
|
+
`Theme ID "${name}" is already registered by another developer.
|
|
1591
|
+
You can still create this locally, but publishing will fail.
|
|
1592
|
+
Consider using a different name.`
|
|
1593
|
+
);
|
|
1594
|
+
const { proceed } = await inquirer__default.default.prompt([
|
|
1595
|
+
{
|
|
1596
|
+
type: "confirm",
|
|
1597
|
+
name: "proceed",
|
|
1598
|
+
message: "Continue anyway?",
|
|
1599
|
+
default: false
|
|
1600
|
+
}
|
|
1601
|
+
]);
|
|
1602
|
+
if (!proceed) {
|
|
1603
|
+
process.exit(0);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
} catch {
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1570
1610
|
let displayName;
|
|
1571
1611
|
let description;
|
|
1572
1612
|
let author;
|
|
@@ -1634,7 +1674,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1634
1674
|
}
|
|
1635
1675
|
exports.logger.startSpinner("Creating project structure...");
|
|
1636
1676
|
try {
|
|
1637
|
-
|
|
1677
|
+
fs3__default.default.mkdirSync(projectPath, { recursive: true });
|
|
1638
1678
|
await copyTemplate(template, projectPath, data);
|
|
1639
1679
|
await renameThemeInFiles(
|
|
1640
1680
|
projectPath,
|
|
@@ -1643,9 +1683,9 @@ async function initCommand(projectName, options = {}) {
|
|
|
1643
1683
|
description,
|
|
1644
1684
|
author
|
|
1645
1685
|
);
|
|
1646
|
-
const mcpJsonPath =
|
|
1647
|
-
if (
|
|
1648
|
-
let mcpContent =
|
|
1686
|
+
const mcpJsonPath = path8__default.default.join(projectPath, ".mcp.json");
|
|
1687
|
+
if (fs3__default.default.existsSync(mcpJsonPath)) {
|
|
1688
|
+
let mcpContent = fs3__default.default.readFileSync(mcpJsonPath, "utf-8");
|
|
1649
1689
|
if (figmaApiKey) {
|
|
1650
1690
|
mcpContent = mcpContent.replace("__FIGMA_API_KEY__", figmaApiKey);
|
|
1651
1691
|
} else {
|
|
@@ -1656,7 +1696,7 @@ async function initCommand(projectName, options = {}) {
|
|
|
1656
1696
|
} catch {
|
|
1657
1697
|
}
|
|
1658
1698
|
}
|
|
1659
|
-
|
|
1699
|
+
fs3__default.default.writeFileSync(mcpJsonPath, mcpContent, "utf-8");
|
|
1660
1700
|
}
|
|
1661
1701
|
exports.logger.stopSpinner(true, "Project structure created!");
|
|
1662
1702
|
if (options.git) {
|
|
@@ -1716,16 +1756,16 @@ async function initCommand(projectName, options = {}) {
|
|
|
1716
1756
|
exports.logger.error(
|
|
1717
1757
|
error instanceof Error ? error.message : "Unknown error occurred"
|
|
1718
1758
|
);
|
|
1719
|
-
if (
|
|
1720
|
-
|
|
1759
|
+
if (fs3__default.default.existsSync(projectPath)) {
|
|
1760
|
+
fs3__default.default.rmSync(projectPath, { recursive: true, force: true });
|
|
1721
1761
|
}
|
|
1722
1762
|
process.exit(1);
|
|
1723
1763
|
}
|
|
1724
1764
|
}
|
|
1725
1765
|
async function renameThemeInFiles(projectPath, themeName, displayName, description, author) {
|
|
1726
|
-
const configPath =
|
|
1727
|
-
if (
|
|
1728
|
-
let content =
|
|
1766
|
+
const configPath = path8__default.default.join(projectPath, "theme.config.ts");
|
|
1767
|
+
if (fs3__default.default.existsSync(configPath)) {
|
|
1768
|
+
let content = fs3__default.default.readFileSync(configPath, "utf-8");
|
|
1729
1769
|
content = content.replace(
|
|
1730
1770
|
/name: "My Simple Theme"/,
|
|
1731
1771
|
`name: "${displayName}"`
|
|
@@ -1734,11 +1774,11 @@ async function renameThemeInFiles(projectPath, themeName, displayName, descripti
|
|
|
1734
1774
|
/description: ".*?"/,
|
|
1735
1775
|
`description: "${description}"`
|
|
1736
1776
|
);
|
|
1737
|
-
|
|
1777
|
+
fs3__default.default.writeFileSync(configPath, content, "utf-8");
|
|
1738
1778
|
}
|
|
1739
|
-
const pkgPath =
|
|
1740
|
-
if (
|
|
1741
|
-
let content =
|
|
1779
|
+
const pkgPath = path8__default.default.join(projectPath, "package.json");
|
|
1780
|
+
if (fs3__default.default.existsSync(pkgPath)) {
|
|
1781
|
+
let content = fs3__default.default.readFileSync(pkgPath, "utf-8");
|
|
1742
1782
|
content = content.replace(
|
|
1743
1783
|
/@onex-themes\/my-simple/g,
|
|
1744
1784
|
`@onex-themes/${themeName}`
|
|
@@ -1747,7 +1787,7 @@ async function renameThemeInFiles(projectPath, themeName, displayName, descripti
|
|
|
1747
1787
|
/"description": ".*?"/,
|
|
1748
1788
|
`"description": "${description}"`
|
|
1749
1789
|
);
|
|
1750
|
-
|
|
1790
|
+
fs3__default.default.writeFileSync(pkgPath, content, "utf-8");
|
|
1751
1791
|
}
|
|
1752
1792
|
}
|
|
1753
1793
|
|
|
@@ -1758,10 +1798,10 @@ async function createSectionCommand(name, options) {
|
|
|
1758
1798
|
ensureOneXProject();
|
|
1759
1799
|
if (!options.theme) {
|
|
1760
1800
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
1761
|
-
(f) => fs__default.default.existsSync(
|
|
1801
|
+
(f) => fs__default.default.existsSync(path8__default.default.join(process.cwd(), f))
|
|
1762
1802
|
);
|
|
1763
1803
|
if (isStandaloneTheme) {
|
|
1764
|
-
options.theme =
|
|
1804
|
+
options.theme = path8__default.default.basename(process.cwd());
|
|
1765
1805
|
}
|
|
1766
1806
|
}
|
|
1767
1807
|
const sectionName = toKebabCase(name);
|
|
@@ -1824,35 +1864,35 @@ async function createSectionCommand(name, options) {
|
|
|
1824
1864
|
};
|
|
1825
1865
|
exports.logger.startSpinner("Creating section files...");
|
|
1826
1866
|
try {
|
|
1827
|
-
const themePath =
|
|
1828
|
-
const sectionPath =
|
|
1867
|
+
const themePath = path8__default.default.join(getThemesDir(), themeName);
|
|
1868
|
+
const sectionPath = path8__default.default.join(themePath, "sections", sectionName);
|
|
1829
1869
|
const schemaContent = generateSectionSchema(data);
|
|
1830
1870
|
await writeFile(
|
|
1831
|
-
|
|
1871
|
+
path8__default.default.join(sectionPath, `${sectionName}.schema.ts`),
|
|
1832
1872
|
schemaContent
|
|
1833
1873
|
);
|
|
1834
1874
|
if (createTemplate) {
|
|
1835
1875
|
const templateContent = generateSectionTemplate(data);
|
|
1836
1876
|
await writeFile(
|
|
1837
|
-
|
|
1877
|
+
path8__default.default.join(sectionPath, `${sectionName}-default.tsx`),
|
|
1838
1878
|
templateContent
|
|
1839
1879
|
);
|
|
1840
1880
|
}
|
|
1841
1881
|
const indexContent = generateSectionIndex(data, createTemplate);
|
|
1842
|
-
await writeFile(
|
|
1882
|
+
await writeFile(path8__default.default.join(sectionPath, "index.ts"), indexContent);
|
|
1843
1883
|
exports.logger.stopSpinner(true, "Section files created successfully!");
|
|
1844
1884
|
exports.logger.newLine();
|
|
1845
1885
|
exports.logger.section("Next steps:");
|
|
1846
1886
|
exports.logger.log(
|
|
1847
|
-
` 1. Edit schema: ${
|
|
1887
|
+
` 1. Edit schema: ${path8__default.default.relative(process.cwd(), path8__default.default.join(sectionPath, `${sectionName}.schema.ts`))}`
|
|
1848
1888
|
);
|
|
1849
1889
|
if (createTemplate) {
|
|
1850
1890
|
exports.logger.log(
|
|
1851
|
-
` 2. Edit template: ${
|
|
1891
|
+
` 2. Edit template: ${path8__default.default.relative(process.cwd(), path8__default.default.join(sectionPath, `${sectionName}-default.tsx`))}`
|
|
1852
1892
|
);
|
|
1853
1893
|
}
|
|
1854
1894
|
exports.logger.log(
|
|
1855
|
-
` 3. Add to theme manifest: ${
|
|
1895
|
+
` 3. Add to theme manifest: ${path8__default.default.relative(process.cwd(), path8__default.default.join(themePath, "manifest.ts"))}`
|
|
1856
1896
|
);
|
|
1857
1897
|
exports.logger.newLine();
|
|
1858
1898
|
exports.logger.success("Section created successfully!");
|
|
@@ -2000,10 +2040,10 @@ async function createBlockCommand(name, options) {
|
|
|
2000
2040
|
ensureOneXProject();
|
|
2001
2041
|
if (!options.theme) {
|
|
2002
2042
|
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
2003
|
-
(f) => fs__default.default.existsSync(
|
|
2043
|
+
(f) => fs__default.default.existsSync(path8__default.default.join(process.cwd(), f))
|
|
2004
2044
|
);
|
|
2005
2045
|
if (isStandaloneTheme) {
|
|
2006
|
-
options.theme =
|
|
2046
|
+
options.theme = path8__default.default.basename(process.cwd());
|
|
2007
2047
|
}
|
|
2008
2048
|
}
|
|
2009
2049
|
const blockName = toKebabCase(name);
|
|
@@ -2078,24 +2118,24 @@ async function createBlockCommand(name, options) {
|
|
|
2078
2118
|
};
|
|
2079
2119
|
exports.logger.startSpinner("Creating block files...");
|
|
2080
2120
|
try {
|
|
2081
|
-
const blockPath = scope === "shared" ?
|
|
2121
|
+
const blockPath = scope === "shared" ? path8__default.default.join(getFeaturesDir(), "blocks", blockName) : path8__default.default.join(getThemesDir(), themeName, "blocks", blockName);
|
|
2082
2122
|
const schemaContent = generateBlockSchema(data);
|
|
2083
2123
|
await writeFile(
|
|
2084
|
-
|
|
2124
|
+
path8__default.default.join(blockPath, `${blockName}.schema.ts`),
|
|
2085
2125
|
schemaContent
|
|
2086
2126
|
);
|
|
2087
2127
|
const componentContent = generateBlockComponent(data);
|
|
2088
|
-
await writeFile(
|
|
2128
|
+
await writeFile(path8__default.default.join(blockPath, `${blockName}.tsx`), componentContent);
|
|
2089
2129
|
const indexContent = generateBlockIndex(data);
|
|
2090
|
-
await writeFile(
|
|
2130
|
+
await writeFile(path8__default.default.join(blockPath, "index.ts"), indexContent);
|
|
2091
2131
|
exports.logger.stopSpinner(true, "Block files created successfully!");
|
|
2092
2132
|
exports.logger.newLine();
|
|
2093
2133
|
exports.logger.section("Next steps:");
|
|
2094
2134
|
exports.logger.log(
|
|
2095
|
-
` 1. Edit schema: ${
|
|
2135
|
+
` 1. Edit schema: ${path8__default.default.relative(process.cwd(), path8__default.default.join(blockPath, `${blockName}.schema.ts`))}`
|
|
2096
2136
|
);
|
|
2097
2137
|
exports.logger.log(
|
|
2098
|
-
` 2. Edit component: ${
|
|
2138
|
+
` 2. Edit component: ${path8__default.default.relative(process.cwd(), path8__default.default.join(blockPath, `${blockName}.tsx`))}`
|
|
2099
2139
|
);
|
|
2100
2140
|
exports.logger.log(
|
|
2101
2141
|
` 3. Register in block registry: src/lib/registry/block-registry.ts`
|
|
@@ -2273,31 +2313,31 @@ async function createComponentCommand(name, options) {
|
|
|
2273
2313
|
};
|
|
2274
2314
|
exports.logger.startSpinner("Creating component files...");
|
|
2275
2315
|
try {
|
|
2276
|
-
const componentPath =
|
|
2316
|
+
const componentPath = path8__default.default.join(
|
|
2277
2317
|
getFeaturesDir(),
|
|
2278
2318
|
"components",
|
|
2279
2319
|
componentName
|
|
2280
2320
|
);
|
|
2281
2321
|
const schemaContent = generateComponentSchema(data);
|
|
2282
2322
|
await writeFile(
|
|
2283
|
-
|
|
2323
|
+
path8__default.default.join(componentPath, `${componentName}.schema.ts`),
|
|
2284
2324
|
schemaContent
|
|
2285
2325
|
);
|
|
2286
2326
|
const componentContent = generateComponent(data);
|
|
2287
2327
|
await writeFile(
|
|
2288
|
-
|
|
2328
|
+
path8__default.default.join(componentPath, `${componentName}.tsx`),
|
|
2289
2329
|
componentContent
|
|
2290
2330
|
);
|
|
2291
2331
|
const indexContent = generateComponentIndex(data);
|
|
2292
|
-
await writeFile(
|
|
2332
|
+
await writeFile(path8__default.default.join(componentPath, "index.ts"), indexContent);
|
|
2293
2333
|
exports.logger.stopSpinner(true, "Component files created successfully!");
|
|
2294
2334
|
exports.logger.newLine();
|
|
2295
2335
|
exports.logger.section("Next steps:");
|
|
2296
2336
|
exports.logger.log(
|
|
2297
|
-
` 1. Edit schema: ${
|
|
2337
|
+
` 1. Edit schema: ${path8__default.default.relative(process.cwd(), path8__default.default.join(componentPath, `${componentName}.schema.ts`))}`
|
|
2298
2338
|
);
|
|
2299
2339
|
exports.logger.log(
|
|
2300
|
-
` 2. Edit component: ${
|
|
2340
|
+
` 2. Edit component: ${path8__default.default.relative(process.cwd(), path8__default.default.join(componentPath, `${componentName}.tsx`))}`
|
|
2301
2341
|
);
|
|
2302
2342
|
exports.logger.log(
|
|
2303
2343
|
` 3. Register in component registry: src/lib/registry/component-registry.ts`
|
|
@@ -2454,13 +2494,13 @@ async function listSections(themeFilter) {
|
|
|
2454
2494
|
return;
|
|
2455
2495
|
}
|
|
2456
2496
|
for (const theme of themes) {
|
|
2457
|
-
const sectionsDir =
|
|
2497
|
+
const sectionsDir = path8__default.default.join(getThemesDir(), theme, "sections");
|
|
2458
2498
|
if (!fs__default.default.existsSync(sectionsDir)) {
|
|
2459
2499
|
continue;
|
|
2460
2500
|
}
|
|
2461
2501
|
const sections = fs__default.default.readdirSync(sectionsDir).filter((name) => {
|
|
2462
|
-
const sectionPath =
|
|
2463
|
-
return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(
|
|
2502
|
+
const sectionPath = path8__default.default.join(sectionsDir, name);
|
|
2503
|
+
return fs__default.default.statSync(sectionPath).isDirectory() && fs__default.default.existsSync(path8__default.default.join(sectionPath, "index.ts"));
|
|
2464
2504
|
});
|
|
2465
2505
|
if (sections.length > 0) {
|
|
2466
2506
|
exports.logger.log(chalk4__default.default.cyan(`
|
|
@@ -2474,11 +2514,11 @@ async function listSections(themeFilter) {
|
|
|
2474
2514
|
}
|
|
2475
2515
|
async function listBlocks(themeFilter) {
|
|
2476
2516
|
exports.logger.section("\u{1F9F1} Blocks");
|
|
2477
|
-
const sharedBlocksDir =
|
|
2517
|
+
const sharedBlocksDir = path8__default.default.join(getFeaturesDir(), "blocks");
|
|
2478
2518
|
if (fs__default.default.existsSync(sharedBlocksDir)) {
|
|
2479
2519
|
const sharedBlocks = fs__default.default.readdirSync(sharedBlocksDir).filter((name) => {
|
|
2480
|
-
const blockPath =
|
|
2481
|
-
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(
|
|
2520
|
+
const blockPath = path8__default.default.join(sharedBlocksDir, name);
|
|
2521
|
+
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path8__default.default.join(blockPath, "index.ts"));
|
|
2482
2522
|
});
|
|
2483
2523
|
if (sharedBlocks.length > 0) {
|
|
2484
2524
|
exports.logger.log(chalk4__default.default.cyan("\n Shared:"));
|
|
@@ -2489,13 +2529,13 @@ async function listBlocks(themeFilter) {
|
|
|
2489
2529
|
}
|
|
2490
2530
|
const themes = themeFilter ? [themeFilter] : listThemes();
|
|
2491
2531
|
for (const theme of themes) {
|
|
2492
|
-
const blocksDir =
|
|
2532
|
+
const blocksDir = path8__default.default.join(getThemesDir(), theme, "blocks");
|
|
2493
2533
|
if (!fs__default.default.existsSync(blocksDir)) {
|
|
2494
2534
|
continue;
|
|
2495
2535
|
}
|
|
2496
2536
|
const blocks = fs__default.default.readdirSync(blocksDir).filter((name) => {
|
|
2497
|
-
const blockPath =
|
|
2498
|
-
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(
|
|
2537
|
+
const blockPath = path8__default.default.join(blocksDir, name);
|
|
2538
|
+
return fs__default.default.statSync(blockPath).isDirectory() && fs__default.default.existsSync(path8__default.default.join(blockPath, "index.ts"));
|
|
2499
2539
|
});
|
|
2500
2540
|
if (blocks.length > 0) {
|
|
2501
2541
|
exports.logger.log(chalk4__default.default.cyan(`
|
|
@@ -2509,14 +2549,14 @@ async function listBlocks(themeFilter) {
|
|
|
2509
2549
|
}
|
|
2510
2550
|
async function listComponents() {
|
|
2511
2551
|
exports.logger.section("\u2699\uFE0F Components");
|
|
2512
|
-
const componentsDir =
|
|
2552
|
+
const componentsDir = path8__default.default.join(getFeaturesDir(), "components");
|
|
2513
2553
|
if (!fs__default.default.existsSync(componentsDir)) {
|
|
2514
2554
|
exports.logger.warning("No components directory found");
|
|
2515
2555
|
return;
|
|
2516
2556
|
}
|
|
2517
2557
|
const components = fs__default.default.readdirSync(componentsDir).filter((name) => {
|
|
2518
|
-
const componentPath =
|
|
2519
|
-
return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(
|
|
2558
|
+
const componentPath = path8__default.default.join(componentsDir, name);
|
|
2559
|
+
return fs__default.default.statSync(componentPath).isDirectory() && fs__default.default.existsSync(path8__default.default.join(componentPath, "index.ts"));
|
|
2520
2560
|
});
|
|
2521
2561
|
if (components.length === 0) {
|
|
2522
2562
|
exports.logger.warning("No components found");
|
|
@@ -2537,11 +2577,11 @@ async function listThemesInfo() {
|
|
|
2537
2577
|
}
|
|
2538
2578
|
exports.logger.log("");
|
|
2539
2579
|
for (const theme of themes) {
|
|
2540
|
-
const themeDir =
|
|
2580
|
+
const themeDir = path8__default.default.join(getThemesDir(), theme);
|
|
2541
2581
|
const candidates = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"];
|
|
2542
2582
|
let manifestContent = "";
|
|
2543
2583
|
for (const candidate of candidates) {
|
|
2544
|
-
const candidatePath =
|
|
2584
|
+
const candidatePath = path8__default.default.join(themeDir, candidate);
|
|
2545
2585
|
if (fs__default.default.existsSync(candidatePath)) {
|
|
2546
2586
|
manifestContent = fs__default.default.readFileSync(candidatePath, "utf-8");
|
|
2547
2587
|
break;
|
|
@@ -2570,14 +2610,14 @@ async function buildCommand(options) {
|
|
|
2570
2610
|
if (options.theme) {
|
|
2571
2611
|
themeName = options.theme;
|
|
2572
2612
|
try {
|
|
2573
|
-
const workspaceThemePath =
|
|
2613
|
+
const workspaceThemePath = path8__default.default.join(getThemesDir(), themeName);
|
|
2574
2614
|
if (fs__default.default.existsSync(workspaceThemePath)) {
|
|
2575
2615
|
themePath = workspaceThemePath;
|
|
2576
2616
|
} else {
|
|
2577
|
-
themePath =
|
|
2617
|
+
themePath = path8__default.default.join(process.cwd(), themeName);
|
|
2578
2618
|
}
|
|
2579
2619
|
} catch {
|
|
2580
|
-
themePath =
|
|
2620
|
+
themePath = path8__default.default.join(process.cwd(), themeName);
|
|
2581
2621
|
}
|
|
2582
2622
|
if (!fs__default.default.existsSync(themePath)) {
|
|
2583
2623
|
exports.logger.error(`Theme "${themeName}" not found.`);
|
|
@@ -2588,10 +2628,10 @@ async function buildCommand(options) {
|
|
|
2588
2628
|
"theme.config.ts",
|
|
2589
2629
|
"bundle-entry.ts",
|
|
2590
2630
|
"manifest.ts"
|
|
2591
|
-
].some((f) => fs__default.default.existsSync(
|
|
2631
|
+
].some((f) => fs__default.default.existsSync(path8__default.default.join(process.cwd(), f)));
|
|
2592
2632
|
if (isThemeDir) {
|
|
2593
2633
|
themePath = process.cwd();
|
|
2594
|
-
themeName =
|
|
2634
|
+
themeName = path8__default.default.basename(themePath);
|
|
2595
2635
|
exports.logger.info(`Building current theme: ${themeName}`);
|
|
2596
2636
|
} else {
|
|
2597
2637
|
exports.logger.error(
|
|
@@ -2600,7 +2640,7 @@ async function buildCommand(options) {
|
|
|
2600
2640
|
process.exit(1);
|
|
2601
2641
|
}
|
|
2602
2642
|
}
|
|
2603
|
-
const packageJsonPath =
|
|
2643
|
+
const packageJsonPath = path8__default.default.join(themePath, "package.json");
|
|
2604
2644
|
const hasPkgJson = fs__default.default.existsSync(packageJsonPath);
|
|
2605
2645
|
if (!hasPkgJson) {
|
|
2606
2646
|
exports.logger.warning(
|
|
@@ -2656,9 +2696,9 @@ async function buildCommand(options) {
|
|
|
2656
2696
|
exports.logger.success("\u2713 Theme built successfully!");
|
|
2657
2697
|
exports.logger.newLine();
|
|
2658
2698
|
exports.logger.info(`Theme: ${themeName}`);
|
|
2659
|
-
const distPath =
|
|
2699
|
+
const distPath = path8__default.default.join(themePath, "dist");
|
|
2660
2700
|
if (fs__default.default.existsSync(distPath)) {
|
|
2661
|
-
exports.logger.log(`Output: ${
|
|
2701
|
+
exports.logger.log(`Output: ${path8__default.default.relative(process.cwd(), distPath)}`);
|
|
2662
2702
|
const files = fs__default.default.readdirSync(distPath);
|
|
2663
2703
|
exports.logger.log(`Files: ${files.length}`);
|
|
2664
2704
|
}
|
|
@@ -2746,11 +2786,11 @@ function getBucketName(env) {
|
|
|
2746
2786
|
return environment === "production" ? "theme-s3-bucket" : "theme-s3-bucket";
|
|
2747
2787
|
}
|
|
2748
2788
|
async function findCompiledThemeDir(themeId, version) {
|
|
2749
|
-
const searchPaths = [
|
|
2789
|
+
const searchPaths = [path8__default.default.resolve(process.cwd(), "dist")];
|
|
2750
2790
|
for (const dir of searchPaths) {
|
|
2751
2791
|
if (await fs__default.default.pathExists(dir)) {
|
|
2752
|
-
const hasManifest = await fs__default.default.pathExists(
|
|
2753
|
-
const hasThemeEntry = await fs__default.default.pathExists(
|
|
2792
|
+
const hasManifest = await fs__default.default.pathExists(path8__default.default.join(dir, "manifest.json"));
|
|
2793
|
+
const hasThemeEntry = await fs__default.default.pathExists(path8__default.default.join(dir, "bundle-entry.js")) || await fs__default.default.pathExists(path8__default.default.join(dir, "theme.config.js")) || await fs__default.default.pathExists(path8__default.default.join(dir, "index.js"));
|
|
2754
2794
|
if (hasManifest || hasThemeEntry) {
|
|
2755
2795
|
return dir;
|
|
2756
2796
|
}
|
|
@@ -2759,7 +2799,7 @@ async function findCompiledThemeDir(themeId, version) {
|
|
|
2759
2799
|
return null;
|
|
2760
2800
|
}
|
|
2761
2801
|
async function readManifest() {
|
|
2762
|
-
const manifestTsPath =
|
|
2802
|
+
const manifestTsPath = path8__default.default.resolve(process.cwd(), "manifest.ts");
|
|
2763
2803
|
if (await fs__default.default.pathExists(manifestTsPath)) {
|
|
2764
2804
|
try {
|
|
2765
2805
|
const module = await import(manifestTsPath);
|
|
@@ -2768,7 +2808,7 @@ async function readManifest() {
|
|
|
2768
2808
|
exports.logger.warning("Failed to import manifest.ts, trying package.json");
|
|
2769
2809
|
}
|
|
2770
2810
|
}
|
|
2771
|
-
const packageJsonPath =
|
|
2811
|
+
const packageJsonPath = path8__default.default.resolve(process.cwd(), "package.json");
|
|
2772
2812
|
if (await fs__default.default.pathExists(packageJsonPath)) {
|
|
2773
2813
|
const pkg = await fs__default.default.readJson(packageJsonPath);
|
|
2774
2814
|
return {
|
|
@@ -2802,13 +2842,13 @@ async function findSourceDir(themeId, explicitDir) {
|
|
|
2802
2842
|
}
|
|
2803
2843
|
const searchPaths = [
|
|
2804
2844
|
process.cwd(),
|
|
2805
|
-
|
|
2806
|
-
|
|
2845
|
+
path8__default.default.resolve(process.cwd(), `../../themes/${themeId}`),
|
|
2846
|
+
path8__default.default.resolve(process.cwd(), `../themes/${themeId}`)
|
|
2807
2847
|
];
|
|
2808
2848
|
const markers = ["theme.config.ts", "bundle-entry.ts"];
|
|
2809
2849
|
for (const dir of searchPaths) {
|
|
2810
2850
|
for (const marker of markers) {
|
|
2811
|
-
if (await fs__default.default.pathExists(
|
|
2851
|
+
if (await fs__default.default.pathExists(path8__default.default.join(dir, marker))) {
|
|
2812
2852
|
return dir;
|
|
2813
2853
|
}
|
|
2814
2854
|
}
|
|
@@ -2860,7 +2900,7 @@ async function uploadCommand(options) {
|
|
|
2860
2900
|
spinner.succeed(`Found compiled theme at: ${compiledDir}`);
|
|
2861
2901
|
spinner.start("Creating bundle.zip...");
|
|
2862
2902
|
const tmpDir = os__default.default.tmpdir();
|
|
2863
|
-
const bundleZipPath =
|
|
2903
|
+
const bundleZipPath = path8__default.default.join(tmpDir, `${themeId}-${version}-bundle.zip`);
|
|
2864
2904
|
await createZipFromDir(compiledDir, bundleZipPath);
|
|
2865
2905
|
const bundleZipBuffer = await fs__default.default.readFile(bundleZipPath);
|
|
2866
2906
|
const bundleSizeMB = (bundleZipBuffer.length / 1024 / 1024).toFixed(2);
|
|
@@ -2914,7 +2954,7 @@ async function uploadCommand(options) {
|
|
|
2914
2954
|
if (sourceDir) {
|
|
2915
2955
|
spinner.succeed(`Found source at: ${sourceDir}`);
|
|
2916
2956
|
spinner.start("Creating source.zip...");
|
|
2917
|
-
const sourceZipPath =
|
|
2957
|
+
const sourceZipPath = path8__default.default.join(
|
|
2918
2958
|
tmpDir,
|
|
2919
2959
|
`${themeId}-${version}-source.zip`
|
|
2920
2960
|
);
|
|
@@ -3048,8 +3088,8 @@ async function resolveLatestVersion(s3Client, bucket, themeId) {
|
|
|
3048
3088
|
async function createCompatibilityFiles(outputDir, manifest) {
|
|
3049
3089
|
const entryFile = manifest.output?.entry || "bundle-entry.js";
|
|
3050
3090
|
if (entryFile !== "bundle-entry.js" && entryFile.startsWith("bundle-entry-")) {
|
|
3051
|
-
const hashedPath =
|
|
3052
|
-
const stablePath =
|
|
3091
|
+
const hashedPath = path8__default.default.join(outputDir, entryFile);
|
|
3092
|
+
const stablePath = path8__default.default.join(outputDir, "bundle-entry.js");
|
|
3053
3093
|
if (await fs__default.default.pathExists(hashedPath)) {
|
|
3054
3094
|
await fs__default.default.copy(hashedPath, stablePath);
|
|
3055
3095
|
const mapPath = hashedPath + ".map";
|
|
@@ -3058,13 +3098,13 @@ async function createCompatibilityFiles(outputDir, manifest) {
|
|
|
3058
3098
|
}
|
|
3059
3099
|
}
|
|
3060
3100
|
}
|
|
3061
|
-
const sectionsRegistryPath =
|
|
3101
|
+
const sectionsRegistryPath = path8__default.default.join(outputDir, "sections-registry.js");
|
|
3062
3102
|
const content = `// Re-export all sections from bundle-entry
|
|
3063
3103
|
// This file exists to maintain compatibility with the import path
|
|
3064
3104
|
export * from './bundle-entry.js';
|
|
3065
3105
|
`;
|
|
3066
3106
|
await fs__default.default.writeFile(sectionsRegistryPath, content, "utf-8");
|
|
3067
|
-
const pkgJsonPath =
|
|
3107
|
+
const pkgJsonPath = path8__default.default.join(outputDir, "package.json");
|
|
3068
3108
|
await fs__default.default.writeFile(pkgJsonPath, '{\n "type": "module"\n}\n', "utf-8");
|
|
3069
3109
|
}
|
|
3070
3110
|
function showDownloadFailureHelp(themeId, bucket) {
|
|
@@ -3126,6 +3166,18 @@ async function downloadCommand(options) {
|
|
|
3126
3166
|
spinner.succeed(
|
|
3127
3167
|
`Resolved latest version: ${chalk4__default.default.cyan(resolvedVersion)}`
|
|
3128
3168
|
);
|
|
3169
|
+
const isCI = !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.VERCEL);
|
|
3170
|
+
if (isCI) {
|
|
3171
|
+
console.log(
|
|
3172
|
+
chalk4__default.default.yellow(
|
|
3173
|
+
`
|
|
3174
|
+
Warning: Resolved "latest" to ${resolvedVersion} in CI environment.
|
|
3175
|
+
For production builds, pin to a specific version:
|
|
3176
|
+
THEME_VERSION=${resolvedVersion}
|
|
3177
|
+
`
|
|
3178
|
+
)
|
|
3179
|
+
);
|
|
3180
|
+
}
|
|
3129
3181
|
}
|
|
3130
3182
|
spinner.start(
|
|
3131
3183
|
`Downloading bundle.zip for ${themeId}@${resolvedVersion}...`
|
|
@@ -3147,7 +3199,7 @@ async function downloadCommand(options) {
|
|
|
3147
3199
|
zip.extractAllTo(outputDir, true);
|
|
3148
3200
|
const entries = zip.getEntries().filter((e) => !e.isDirectory);
|
|
3149
3201
|
spinner.succeed(`Extracted ${entries.length} files to ${outputDir}`);
|
|
3150
|
-
const manifestPath =
|
|
3202
|
+
const manifestPath = path8__default.default.join(outputDir, "manifest.json");
|
|
3151
3203
|
const manifest = await fs__default.default.readJson(manifestPath);
|
|
3152
3204
|
await createCompatibilityFiles(outputDir, manifest);
|
|
3153
3205
|
console.log();
|
|
@@ -3281,7 +3333,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3281
3333
|
const oldPrefix = `${oldName}-`;
|
|
3282
3334
|
const newPrefix = `${newName}-`;
|
|
3283
3335
|
const newDisplayName = newName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3284
|
-
const pkgPath =
|
|
3336
|
+
const pkgPath = path8__default.default.join(themeDir, "package.json");
|
|
3285
3337
|
if (await fs__default.default.pathExists(pkgPath)) {
|
|
3286
3338
|
const pkg = await fs__default.default.readJson(pkgPath);
|
|
3287
3339
|
pkg.name = `@onex-themes/${newName}`;
|
|
@@ -3297,7 +3349,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3297
3349
|
}
|
|
3298
3350
|
await fs__default.default.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
3299
3351
|
}
|
|
3300
|
-
const configPath =
|
|
3352
|
+
const configPath = path8__default.default.join(themeDir, "theme.config.ts");
|
|
3301
3353
|
if (await fs__default.default.pathExists(configPath)) {
|
|
3302
3354
|
let content = await fs__default.default.readFile(configPath, "utf-8");
|
|
3303
3355
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -3307,7 +3359,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3307
3359
|
);
|
|
3308
3360
|
await fs__default.default.writeFile(configPath, content);
|
|
3309
3361
|
}
|
|
3310
|
-
const layoutPath =
|
|
3362
|
+
const layoutPath = path8__default.default.join(themeDir, "theme.layout.ts");
|
|
3311
3363
|
if (await fs__default.default.pathExists(layoutPath)) {
|
|
3312
3364
|
let content = await fs__default.default.readFile(layoutPath, "utf-8");
|
|
3313
3365
|
content = content.replace(/id:\s*"[^"]*"/, `id: "${newName}"`);
|
|
@@ -3320,7 +3372,7 @@ async function renameTheme(themeDir, oldName, newName) {
|
|
|
3320
3372
|
const oldDisplayName = oldName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3321
3373
|
const tsFiles = await glob.glob("**/*.ts", { cwd: themeDir, nodir: true });
|
|
3322
3374
|
for (const file of tsFiles) {
|
|
3323
|
-
const filePath =
|
|
3375
|
+
const filePath = path8__default.default.join(themeDir, file);
|
|
3324
3376
|
let content = await fs__default.default.readFile(filePath, "utf-8");
|
|
3325
3377
|
const original = content;
|
|
3326
3378
|
content = content.replace(
|
|
@@ -3349,7 +3401,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3349
3401
|
const spinner = ora__default.default("Initializing clone...").start();
|
|
3350
3402
|
try {
|
|
3351
3403
|
const bucket = options.bucket || getBucketName3(options.environment);
|
|
3352
|
-
const outputDir = options.output ||
|
|
3404
|
+
const outputDir = options.output || path8__default.default.resolve(process.cwd(), newName);
|
|
3353
3405
|
const s3Client = getS3Client3();
|
|
3354
3406
|
if (await fs__default.default.pathExists(outputDir)) {
|
|
3355
3407
|
spinner.fail(chalk4__default.default.red(`Directory already exists: ${outputDir}`));
|
|
@@ -3404,7 +3456,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3404
3456
|
spinner.succeed(
|
|
3405
3457
|
`Renamed theme: ${chalk4__default.default.gray(themeName)} \u2192 ${chalk4__default.default.cyan(newName)}`
|
|
3406
3458
|
);
|
|
3407
|
-
const envExamplePath =
|
|
3459
|
+
const envExamplePath = path8__default.default.join(outputDir, ".env.example");
|
|
3408
3460
|
if (!await fs__default.default.pathExists(envExamplePath)) {
|
|
3409
3461
|
await fs__default.default.writeFile(
|
|
3410
3462
|
envExamplePath,
|
|
@@ -3417,7 +3469,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3417
3469
|
].join("\n")
|
|
3418
3470
|
);
|
|
3419
3471
|
}
|
|
3420
|
-
const mcpJsonPath =
|
|
3472
|
+
const mcpJsonPath = path8__default.default.join(outputDir, ".mcp.json");
|
|
3421
3473
|
if (await fs__default.default.pathExists(mcpJsonPath)) {
|
|
3422
3474
|
const { default: inquirerMod } = await import('inquirer');
|
|
3423
3475
|
const { figmaApiKey } = await inquirerMod.prompt([
|
|
@@ -3442,7 +3494,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3442
3494
|
}
|
|
3443
3495
|
if (options.install !== false) {
|
|
3444
3496
|
const hasPkgJson = await fs__default.default.pathExists(
|
|
3445
|
-
|
|
3497
|
+
path8__default.default.join(outputDir, "package.json")
|
|
3446
3498
|
);
|
|
3447
3499
|
if (hasPkgJson) {
|
|
3448
3500
|
spinner.start("Installing dependencies...");
|
|
@@ -3469,7 +3521,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3469
3521
|
console.log(chalk4__default.default.cyan(" Files: ") + chalk4__default.default.white(entries.length));
|
|
3470
3522
|
console.log();
|
|
3471
3523
|
console.log(chalk4__default.default.cyan("Next steps:"));
|
|
3472
|
-
console.log(chalk4__default.default.gray(` cd ${
|
|
3524
|
+
console.log(chalk4__default.default.gray(` cd ${path8__default.default.relative(process.cwd(), outputDir)}`));
|
|
3473
3525
|
console.log(
|
|
3474
3526
|
chalk4__default.default.gray(" cp .env.example .env # then add your Company ID")
|
|
3475
3527
|
);
|