@onexapis/cli 1.1.16 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -46
- package/bin/onexthm.js +4 -0
- package/dist/cli.js +230 -44
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +230 -44
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +115 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +115 -29
- package/dist/index.mjs.map +1 -1
- package/dist/preview/preview-app.tsx +175 -53
- package/package.json +14 -12
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import path7 from 'path';
|
|
|
5
5
|
import fs6 from 'fs/promises';
|
|
6
6
|
import crypto from 'crypto';
|
|
7
7
|
import { glob } from 'glob';
|
|
8
|
+
import { createRequire } from 'module';
|
|
8
9
|
import fs2 from 'fs';
|
|
9
10
|
import { execSync, spawn } from 'child_process';
|
|
10
11
|
import inquirer from 'inquirer';
|
|
@@ -240,6 +241,12 @@ function createThemeDepsStubPlugin(themePath) {
|
|
|
240
241
|
if (!result.errors.length) return result;
|
|
241
242
|
} catch {
|
|
242
243
|
}
|
|
244
|
+
try {
|
|
245
|
+
const req = createRequire(import.meta.url || __filename);
|
|
246
|
+
const resolved = req.resolve(args.path);
|
|
247
|
+
if (resolved) return { path: resolved, namespace: "file" };
|
|
248
|
+
} catch {
|
|
249
|
+
}
|
|
243
250
|
return { path: args.path, namespace };
|
|
244
251
|
});
|
|
245
252
|
};
|
|
@@ -248,11 +255,19 @@ function createThemeDepsStubPlugin(themePath) {
|
|
|
248
255
|
const stubs = {
|
|
249
256
|
"next/image": `
|
|
250
257
|
import React from 'react';
|
|
251
|
-
const Image = (props) => {
|
|
252
|
-
const { src, alt, width, height, fill, priority, ...rest } = props;
|
|
258
|
+
const Image = React.forwardRef((props, ref) => {
|
|
259
|
+
const { src, alt, width, height, fill, priority, sizes, quality, placeholder, blurDataURL, onLoad, onError, style, className, ...rest } = props;
|
|
253
260
|
const imgSrc = typeof src === 'object' ? src.src : src;
|
|
254
|
-
|
|
255
|
-
};
|
|
261
|
+
const fillStyle = fill ? { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: style?.objectFit || 'cover', display: 'block' } : {};
|
|
262
|
+
const mergedStyle = { ...fillStyle, ...style };
|
|
263
|
+
return React.createElement('img', {
|
|
264
|
+
ref, src: imgSrc, alt,
|
|
265
|
+
width: fill ? undefined : width, height: fill ? undefined : height,
|
|
266
|
+
loading: priority ? 'eager' : 'lazy',
|
|
267
|
+
style: Object.keys(mergedStyle).length > 0 ? mergedStyle : undefined,
|
|
268
|
+
className, onLoad, onError, ...rest,
|
|
269
|
+
});
|
|
270
|
+
});
|
|
256
271
|
export default Image;
|
|
257
272
|
`,
|
|
258
273
|
"next/link": `
|
|
@@ -286,7 +301,10 @@ export function headers() { return new Headers(); }
|
|
|
286
301
|
if (!lucideThemeScanned) {
|
|
287
302
|
lucideThemeScanned = true;
|
|
288
303
|
try {
|
|
289
|
-
const scanned = await scanImportsFromPackage(
|
|
304
|
+
const scanned = await scanImportsFromPackage(
|
|
305
|
+
themePath,
|
|
306
|
+
"lucide-react"
|
|
307
|
+
);
|
|
290
308
|
for (const names of Object.values(scanned)) {
|
|
291
309
|
for (const name of names) lucideImports.add(name);
|
|
292
310
|
}
|
|
@@ -349,10 +367,13 @@ export function useFormContext() { return useForm(); }
|
|
|
349
367
|
loader: "js"
|
|
350
368
|
}));
|
|
351
369
|
tryResolveOrStub(/^@hookform\/resolvers/, "hookform-resolvers-stub");
|
|
352
|
-
build2.onLoad(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
370
|
+
build2.onLoad(
|
|
371
|
+
{ filter: /.*/, namespace: "hookform-resolvers-stub" },
|
|
372
|
+
() => ({
|
|
373
|
+
contents: `export function zodResolver() { return () => ({ values: {}, errors: {} }); }`,
|
|
374
|
+
loader: "js"
|
|
375
|
+
})
|
|
376
|
+
);
|
|
356
377
|
tryResolveOrStub(/^next-intl$/, "next-intl-stub");
|
|
357
378
|
build2.onLoad({ filter: /.*/, namespace: "next-intl-stub" }, () => ({
|
|
358
379
|
contents: `
|
|
@@ -610,7 +631,11 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
610
631
|
banner: {
|
|
611
632
|
js: '"use client";'
|
|
612
633
|
},
|
|
613
|
-
plugins: [
|
|
634
|
+
plugins: [
|
|
635
|
+
reactGlobalPlugin,
|
|
636
|
+
createCoreGlobalPlugin(themePath),
|
|
637
|
+
createThemeDepsStubPlugin(themePath)
|
|
638
|
+
],
|
|
614
639
|
external: [],
|
|
615
640
|
alias: {
|
|
616
641
|
events: "events/",
|
|
@@ -692,7 +717,11 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
692
717
|
banner: {
|
|
693
718
|
js: '"use client";'
|
|
694
719
|
},
|
|
695
|
-
plugins: [
|
|
720
|
+
plugins: [
|
|
721
|
+
reactGlobalPlugin,
|
|
722
|
+
createCoreGlobalPlugin(themePath),
|
|
723
|
+
createThemeDepsStubPlugin(themePath)
|
|
724
|
+
],
|
|
696
725
|
external: [],
|
|
697
726
|
alias: {
|
|
698
727
|
events: "events/",
|
|
@@ -827,7 +856,16 @@ ${locations.join("\n")}`
|
|
|
827
856
|
path7.join(themePath, "node_modules", "@onexapis", "core", "src"),
|
|
828
857
|
path7.join(themePath, "..", "..", "packages", "core", "src"),
|
|
829
858
|
// monorepo sibling
|
|
830
|
-
path7.join(
|
|
859
|
+
path7.join(
|
|
860
|
+
__dirname,
|
|
861
|
+
"..",
|
|
862
|
+
"..",
|
|
863
|
+
"..",
|
|
864
|
+
"..",
|
|
865
|
+
"packages",
|
|
866
|
+
"core",
|
|
867
|
+
"src"
|
|
868
|
+
)
|
|
831
869
|
// from CLI src
|
|
832
870
|
];
|
|
833
871
|
let coreSourceDir = null;
|
|
@@ -841,7 +879,10 @@ ${locations.join("\n")}`
|
|
|
841
879
|
}
|
|
842
880
|
if (coreSourceDir) {
|
|
843
881
|
try {
|
|
844
|
-
const scanned = await scanImportsFromPackage(
|
|
882
|
+
const scanned = await scanImportsFromPackage(
|
|
883
|
+
coreSourceDir,
|
|
884
|
+
"lucide-react"
|
|
885
|
+
);
|
|
845
886
|
for (const names of Object.values(scanned)) {
|
|
846
887
|
for (const name of names) lucideIconNames.add(name);
|
|
847
888
|
}
|
|
@@ -862,7 +903,10 @@ ${locations.join("\n")}`
|
|
|
862
903
|
const mjsFiles = await glob("*.mjs", { cwd: candidate });
|
|
863
904
|
const importRegex = /import\s*\{([^}]+)\}\s*from\s*["']lucide-react["']/g;
|
|
864
905
|
for (const file of mjsFiles) {
|
|
865
|
-
const content = await fs6.readFile(
|
|
906
|
+
const content = await fs6.readFile(
|
|
907
|
+
path7.join(candidate, file),
|
|
908
|
+
"utf-8"
|
|
909
|
+
);
|
|
866
910
|
for (const match of content.matchAll(importRegex)) {
|
|
867
911
|
for (const name of match[1].split(",")) {
|
|
868
912
|
const original = name.trim().split(/\s+as\s+/)[0].trim();
|
|
@@ -878,7 +922,10 @@ ${locations.join("\n")}`
|
|
|
878
922
|
}
|
|
879
923
|
}
|
|
880
924
|
try {
|
|
881
|
-
const scanned = await scanImportsFromPackage(
|
|
925
|
+
const scanned = await scanImportsFromPackage(
|
|
926
|
+
themePath,
|
|
927
|
+
"lucide-react"
|
|
928
|
+
);
|
|
882
929
|
for (const names of Object.values(scanned)) {
|
|
883
930
|
for (const name of names) lucideIconNames.add(name);
|
|
884
931
|
}
|
|
@@ -908,14 +955,39 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
|
|
|
908
955
|
if (!result.errors.length) return result;
|
|
909
956
|
} catch {
|
|
910
957
|
}
|
|
958
|
+
try {
|
|
959
|
+
const req = createRequire(import.meta.url || __filename);
|
|
960
|
+
const cjsPath = req.resolve("framer-motion");
|
|
961
|
+
const pkgDir = cjsPath.replace(/[/\\]dist[/\\].*$/, "");
|
|
962
|
+
const esmEntry = path7.join(pkgDir, "dist", "es", "index.mjs");
|
|
963
|
+
const { existsSync } = await import('fs');
|
|
964
|
+
if (existsSync(esmEntry)) {
|
|
965
|
+
return { path: esmEntry, namespace: "file" };
|
|
966
|
+
}
|
|
967
|
+
return { path: cjsPath, namespace: "file" };
|
|
968
|
+
} catch {
|
|
969
|
+
}
|
|
911
970
|
return { path: args.path, namespace: "motion-stub" };
|
|
912
971
|
});
|
|
913
972
|
build2.onLoad({ filter: /.*/, namespace: "motion-stub" }, () => ({
|
|
914
973
|
contents: `
|
|
915
|
-
|
|
916
|
-
const
|
|
974
|
+
import React from 'react';
|
|
975
|
+
const MotionComponent = React.forwardRef((props, ref) => {
|
|
976
|
+
const { initial, animate, exit, variants, transition, whileInView, whileHover, whileTap, viewport, onAnimationComplete, layout, layoutId, style, className, ...rest } = props;
|
|
977
|
+
return React.createElement(rest.as || 'div', { ref, style, className, ...rest }, rest.children);
|
|
978
|
+
});
|
|
979
|
+
const handler = { get: (_, name) => {
|
|
980
|
+
if (name === '__esModule') return true;
|
|
981
|
+
if (name === 'create') return () => new Proxy({}, handler);
|
|
982
|
+
return MotionComponent;
|
|
983
|
+
}};
|
|
917
984
|
export const motion = new Proxy({}, handler);
|
|
918
|
-
export const AnimatePresence =
|
|
985
|
+
export const AnimatePresence = (props) => props.children || null;
|
|
986
|
+
export const useInView = () => true;
|
|
987
|
+
export const useAnimation = () => ({ start: () => {}, stop: () => {}, set: () => {} });
|
|
988
|
+
export const useMotionValue = (v) => ({ get: () => v, set: () => {}, onChange: () => () => {} });
|
|
989
|
+
export const useTransform = (v) => v;
|
|
990
|
+
export const useScroll = () => ({ scrollY: { get: () => 0, onChange: () => () => {} }, scrollYProgress: { get: () => 0, onChange: () => () => {} } });
|
|
919
991
|
export default { motion, AnimatePresence };
|
|
920
992
|
`.trim(),
|
|
921
993
|
loader: "jsx"
|
|
@@ -938,12 +1010,26 @@ export default { motion, AnimatePresence };
|
|
|
938
1010
|
build2.onLoad({ filter: /.*/, namespace: "next-stub" }, (args) => {
|
|
939
1011
|
const stubs = {
|
|
940
1012
|
"next/image": `
|
|
941
|
-
const Image = (props) => {
|
|
942
|
-
const { src, alt, width, height, fill, priority, ...rest } = props;
|
|
943
|
-
const imgSrc = typeof src === 'object' ? src.src : src;
|
|
944
|
-
return React.createElement('img', { src: imgSrc, alt, width: fill ? undefined : width, height: fill ? undefined : height, loading: priority ? 'eager' : 'lazy', ...rest });
|
|
945
|
-
};
|
|
946
1013
|
import React from 'react';
|
|
1014
|
+
const Image = React.forwardRef((props, ref) => {
|
|
1015
|
+
const { src, alt, width, height, fill, priority, sizes, quality, placeholder, blurDataURL, onLoad, onError, style, className, ...rest } = props;
|
|
1016
|
+
const imgSrc = typeof src === 'object' ? src.src : src;
|
|
1017
|
+
const fillStyle = fill ? { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: style?.objectFit || 'cover', display: 'block' } : {};
|
|
1018
|
+
const mergedStyle = { ...fillStyle, ...style };
|
|
1019
|
+
return React.createElement('img', {
|
|
1020
|
+
ref,
|
|
1021
|
+
src: imgSrc,
|
|
1022
|
+
alt,
|
|
1023
|
+
width: fill ? undefined : width,
|
|
1024
|
+
height: fill ? undefined : height,
|
|
1025
|
+
loading: priority ? 'eager' : 'lazy',
|
|
1026
|
+
style: Object.keys(mergedStyle).length > 0 ? mergedStyle : undefined,
|
|
1027
|
+
className,
|
|
1028
|
+
onLoad,
|
|
1029
|
+
onError,
|
|
1030
|
+
...rest,
|
|
1031
|
+
});
|
|
1032
|
+
});
|
|
947
1033
|
export default Image;
|
|
948
1034
|
`,
|
|
949
1035
|
"next/link": `
|
|
@@ -1466,7 +1552,7 @@ Add your theme-specific blocks here.
|
|
|
1466
1552
|
try {
|
|
1467
1553
|
execSync("git init", { cwd: projectPath, stdio: "ignore" });
|
|
1468
1554
|
execSync("git add .", { cwd: projectPath, stdio: "ignore" });
|
|
1469
|
-
execSync('git commit -m "Initial commit from
|
|
1555
|
+
execSync('git commit -m "Initial commit from onexthm init"', {
|
|
1470
1556
|
cwd: projectPath,
|
|
1471
1557
|
stdio: "ignore"
|
|
1472
1558
|
});
|
|
@@ -2634,7 +2720,7 @@ async function buildCommand(options) {
|
|
|
2634
2720
|
logger.stopSpinner(true, "Lint passed");
|
|
2635
2721
|
const pkgJson = fs.readJsonSync(packageJsonPath);
|
|
2636
2722
|
const buildScript = pkgJson.scripts?.build || "";
|
|
2637
|
-
const isRecursive = buildScript.includes("
|
|
2723
|
+
const isRecursive = buildScript.includes("onexthm build") || buildScript.includes("onex-cli build");
|
|
2638
2724
|
logger.startSpinner(
|
|
2639
2725
|
options.watch ? "Building (watch mode)..." : "Building..."
|
|
2640
2726
|
);
|
|
@@ -2832,7 +2918,7 @@ async function uploadCommand(options) {
|
|
|
2832
2918
|
if (!compiledDir) {
|
|
2833
2919
|
spinner.fail(
|
|
2834
2920
|
chalk4.red(
|
|
2835
|
-
`Compiled theme not found for ${themeId}@${version}. Run '
|
|
2921
|
+
`Compiled theme not found for ${themeId}@${version}. Run 'onexthm build' first.`
|
|
2836
2922
|
)
|
|
2837
2923
|
);
|
|
2838
2924
|
logger.info(chalk4.gray(`Expected location:
|
|
@@ -3064,7 +3150,7 @@ function showDownloadFailureHelp(themeId, bucket) {
|
|
|
3064
3150
|
console.log(chalk4.white("1. Compile and upload the theme:"));
|
|
3065
3151
|
console.log(chalk4.gray(` cd themes/${themeId}`));
|
|
3066
3152
|
console.log(chalk4.gray(" pnpm build"));
|
|
3067
|
-
console.log(chalk4.gray("
|
|
3153
|
+
console.log(chalk4.gray(" onexthm upload"));
|
|
3068
3154
|
console.log();
|
|
3069
3155
|
console.log(chalk4.white("2. Verify AWS credentials are set:"));
|
|
3070
3156
|
console.log(
|
|
@@ -3366,7 +3452,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3366
3452
|
chalk4.yellow("The theme source may not have been uploaded yet.")
|
|
3367
3453
|
);
|
|
3368
3454
|
console.log(
|
|
3369
|
-
chalk4.gray(`Upload source with:
|
|
3455
|
+
chalk4.gray(`Upload source with: onexthm upload --theme ${themeName}`)
|
|
3370
3456
|
);
|
|
3371
3457
|
console.log();
|
|
3372
3458
|
process.exit(1);
|
|
@@ -3435,7 +3521,7 @@ async function cloneCommand(themeName, options) {
|
|
|
3435
3521
|
if (options.install === false) {
|
|
3436
3522
|
console.log(chalk4.gray(" pnpm install"));
|
|
3437
3523
|
}
|
|
3438
|
-
console.log(chalk4.gray("
|
|
3524
|
+
console.log(chalk4.gray(" onexthm build"));
|
|
3439
3525
|
console.log();
|
|
3440
3526
|
} catch (error) {
|
|
3441
3527
|
spinner.fail(chalk4.red(`Clone failed: ${error.message}`));
|