@onexapis/cli 1.1.15 → 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/dist/index.js CHANGED
@@ -7,6 +7,7 @@ var path7 = require('path');
7
7
  var fs6 = require('fs/promises');
8
8
  var crypto = require('crypto');
9
9
  var glob = require('glob');
10
+ var module$1 = require('module');
10
11
  var fs2 = require('fs');
11
12
  var child_process = require('child_process');
12
13
  var inquirer = require('inquirer');
@@ -277,6 +278,12 @@ function createThemeDepsStubPlugin(themePath) {
277
278
  if (!result.errors.length) return result;
278
279
  } catch {
279
280
  }
281
+ try {
282
+ 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);
283
+ const resolved = req.resolve(args.path);
284
+ if (resolved) return { path: resolved, namespace: "file" };
285
+ } catch {
286
+ }
280
287
  return { path: args.path, namespace };
281
288
  });
282
289
  };
@@ -285,11 +292,19 @@ function createThemeDepsStubPlugin(themePath) {
285
292
  const stubs = {
286
293
  "next/image": `
287
294
  import React from 'react';
288
- const Image = (props) => {
289
- const { src, alt, width, height, fill, priority, ...rest } = props;
295
+ const Image = React.forwardRef((props, ref) => {
296
+ const { src, alt, width, height, fill, priority, sizes, quality, placeholder, blurDataURL, onLoad, onError, style, className, ...rest } = props;
290
297
  const imgSrc = typeof src === 'object' ? src.src : src;
291
- return React.createElement('img', { src: imgSrc, alt, width: fill ? undefined : width, height: fill ? undefined : height, loading: priority ? 'eager' : 'lazy', ...rest });
292
- };
298
+ const fillStyle = fill ? { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: style?.objectFit || 'cover', display: 'block' } : {};
299
+ const mergedStyle = { ...fillStyle, ...style };
300
+ return React.createElement('img', {
301
+ ref, src: imgSrc, alt,
302
+ width: fill ? undefined : width, height: fill ? undefined : height,
303
+ loading: priority ? 'eager' : 'lazy',
304
+ style: Object.keys(mergedStyle).length > 0 ? mergedStyle : undefined,
305
+ className, onLoad, onError, ...rest,
306
+ });
307
+ });
293
308
  export default Image;
294
309
  `,
295
310
  "next/link": `
@@ -323,7 +338,10 @@ export function headers() { return new Headers(); }
323
338
  if (!lucideThemeScanned) {
324
339
  lucideThemeScanned = true;
325
340
  try {
326
- const scanned = await scanImportsFromPackage(themePath, "lucide-react");
341
+ const scanned = await scanImportsFromPackage(
342
+ themePath,
343
+ "lucide-react"
344
+ );
327
345
  for (const names of Object.values(scanned)) {
328
346
  for (const name of names) lucideImports.add(name);
329
347
  }
@@ -386,10 +404,13 @@ export function useFormContext() { return useForm(); }
386
404
  loader: "js"
387
405
  }));
388
406
  tryResolveOrStub(/^@hookform\/resolvers/, "hookform-resolvers-stub");
389
- build2.onLoad({ filter: /.*/, namespace: "hookform-resolvers-stub" }, () => ({
390
- contents: `export function zodResolver() { return () => ({ values: {}, errors: {} }); }`,
391
- loader: "js"
392
- }));
407
+ build2.onLoad(
408
+ { filter: /.*/, namespace: "hookform-resolvers-stub" },
409
+ () => ({
410
+ contents: `export function zodResolver() { return () => ({ values: {}, errors: {} }); }`,
411
+ loader: "js"
412
+ })
413
+ );
393
414
  tryResolveOrStub(/^next-intl$/, "next-intl-stub");
394
415
  build2.onLoad({ filter: /.*/, namespace: "next-intl-stub" }, () => ({
395
416
  contents: `
@@ -647,7 +668,11 @@ async function compileStandaloneTheme(themePath, themeName) {
647
668
  banner: {
648
669
  js: '"use client";'
649
670
  },
650
- plugins: [reactGlobalPlugin, createCoreGlobalPlugin(themePath), createThemeDepsStubPlugin(themePath)],
671
+ plugins: [
672
+ reactGlobalPlugin,
673
+ createCoreGlobalPlugin(themePath),
674
+ createThemeDepsStubPlugin(themePath)
675
+ ],
651
676
  external: [],
652
677
  alias: {
653
678
  events: "events/",
@@ -729,7 +754,11 @@ async function compileStandaloneThemeDev(themePath, themeName) {
729
754
  banner: {
730
755
  js: '"use client";'
731
756
  },
732
- plugins: [reactGlobalPlugin, createCoreGlobalPlugin(themePath), createThemeDepsStubPlugin(themePath)],
757
+ plugins: [
758
+ reactGlobalPlugin,
759
+ createCoreGlobalPlugin(themePath),
760
+ createThemeDepsStubPlugin(themePath)
761
+ ],
733
762
  external: [],
734
763
  alias: {
735
764
  events: "events/",
@@ -864,7 +893,16 @@ ${locations.join("\n")}`
864
893
  path7__default.default.join(themePath, "node_modules", "@onexapis", "core", "src"),
865
894
  path7__default.default.join(themePath, "..", "..", "packages", "core", "src"),
866
895
  // monorepo sibling
867
- path7__default.default.join(__dirname, "..", "..", "..", "..", "packages", "core", "src")
896
+ path7__default.default.join(
897
+ __dirname,
898
+ "..",
899
+ "..",
900
+ "..",
901
+ "..",
902
+ "packages",
903
+ "core",
904
+ "src"
905
+ )
868
906
  // from CLI src
869
907
  ];
870
908
  let coreSourceDir = null;
@@ -878,7 +916,10 @@ ${locations.join("\n")}`
878
916
  }
879
917
  if (coreSourceDir) {
880
918
  try {
881
- const scanned = await scanImportsFromPackage(coreSourceDir, "lucide-react");
919
+ const scanned = await scanImportsFromPackage(
920
+ coreSourceDir,
921
+ "lucide-react"
922
+ );
882
923
  for (const names of Object.values(scanned)) {
883
924
  for (const name of names) lucideIconNames.add(name);
884
925
  }
@@ -899,7 +940,10 @@ ${locations.join("\n")}`
899
940
  const mjsFiles = await glob.glob("*.mjs", { cwd: candidate });
900
941
  const importRegex = /import\s*\{([^}]+)\}\s*from\s*["']lucide-react["']/g;
901
942
  for (const file of mjsFiles) {
902
- const content = await fs6__default.default.readFile(path7__default.default.join(candidate, file), "utf-8");
943
+ const content = await fs6__default.default.readFile(
944
+ path7__default.default.join(candidate, file),
945
+ "utf-8"
946
+ );
903
947
  for (const match of content.matchAll(importRegex)) {
904
948
  for (const name of match[1].split(",")) {
905
949
  const original = name.trim().split(/\s+as\s+/)[0].trim();
@@ -915,7 +959,10 @@ ${locations.join("\n")}`
915
959
  }
916
960
  }
917
961
  try {
918
- const scanned = await scanImportsFromPackage(themePath, "lucide-react");
962
+ const scanned = await scanImportsFromPackage(
963
+ themePath,
964
+ "lucide-react"
965
+ );
919
966
  for (const names of Object.values(scanned)) {
920
967
  for (const name of names) lucideIconNames.add(name);
921
968
  }
@@ -945,14 +992,39 @@ export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true :
945
992
  if (!result.errors.length) return result;
946
993
  } catch {
947
994
  }
995
+ try {
996
+ 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);
997
+ const cjsPath = req.resolve("framer-motion");
998
+ const pkgDir = cjsPath.replace(/[/\\]dist[/\\].*$/, "");
999
+ const esmEntry = path7__default.default.join(pkgDir, "dist", "es", "index.mjs");
1000
+ const { existsSync } = await import('fs');
1001
+ if (existsSync(esmEntry)) {
1002
+ return { path: esmEntry, namespace: "file" };
1003
+ }
1004
+ return { path: cjsPath, namespace: "file" };
1005
+ } catch {
1006
+ }
948
1007
  return { path: args.path, namespace: "motion-stub" };
949
1008
  });
950
1009
  build2.onLoad({ filter: /.*/, namespace: "motion-stub" }, () => ({
951
1010
  contents: `
952
- const stub = (props) => props.children || null;
953
- const handler = { get: (_, name) => name === '__esModule' ? true : stub };
1011
+ import React from 'react';
1012
+ const MotionComponent = React.forwardRef((props, ref) => {
1013
+ const { initial, animate, exit, variants, transition, whileInView, whileHover, whileTap, viewport, onAnimationComplete, layout, layoutId, style, className, ...rest } = props;
1014
+ return React.createElement(rest.as || 'div', { ref, style, className, ...rest }, rest.children);
1015
+ });
1016
+ const handler = { get: (_, name) => {
1017
+ if (name === '__esModule') return true;
1018
+ if (name === 'create') return () => new Proxy({}, handler);
1019
+ return MotionComponent;
1020
+ }};
954
1021
  export const motion = new Proxy({}, handler);
955
- export const AnimatePresence = stub;
1022
+ export const AnimatePresence = (props) => props.children || null;
1023
+ export const useInView = () => true;
1024
+ export const useAnimation = () => ({ start: () => {}, stop: () => {}, set: () => {} });
1025
+ export const useMotionValue = (v) => ({ get: () => v, set: () => {}, onChange: () => () => {} });
1026
+ export const useTransform = (v) => v;
1027
+ export const useScroll = () => ({ scrollY: { get: () => 0, onChange: () => () => {} }, scrollYProgress: { get: () => 0, onChange: () => () => {} } });
956
1028
  export default { motion, AnimatePresence };
957
1029
  `.trim(),
958
1030
  loader: "jsx"
@@ -975,12 +1047,26 @@ export default { motion, AnimatePresence };
975
1047
  build2.onLoad({ filter: /.*/, namespace: "next-stub" }, (args) => {
976
1048
  const stubs = {
977
1049
  "next/image": `
978
- const Image = (props) => {
979
- const { src, alt, width, height, fill, priority, ...rest } = props;
980
- const imgSrc = typeof src === 'object' ? src.src : src;
981
- return React.createElement('img', { src: imgSrc, alt, width: fill ? undefined : width, height: fill ? undefined : height, loading: priority ? 'eager' : 'lazy', ...rest });
982
- };
983
1050
  import React from 'react';
1051
+ const Image = React.forwardRef((props, ref) => {
1052
+ const { src, alt, width, height, fill, priority, sizes, quality, placeholder, blurDataURL, onLoad, onError, style, className, ...rest } = props;
1053
+ const imgSrc = typeof src === 'object' ? src.src : src;
1054
+ const fillStyle = fill ? { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: style?.objectFit || 'cover', display: 'block' } : {};
1055
+ const mergedStyle = { ...fillStyle, ...style };
1056
+ return React.createElement('img', {
1057
+ ref,
1058
+ src: imgSrc,
1059
+ alt,
1060
+ width: fill ? undefined : width,
1061
+ height: fill ? undefined : height,
1062
+ loading: priority ? 'eager' : 'lazy',
1063
+ style: Object.keys(mergedStyle).length > 0 ? mergedStyle : undefined,
1064
+ className,
1065
+ onLoad,
1066
+ onError,
1067
+ ...rest,
1068
+ });
1069
+ });
984
1070
  export default Image;
985
1071
  `,
986
1072
  "next/link": `
@@ -1503,7 +1589,7 @@ Add your theme-specific blocks here.
1503
1589
  try {
1504
1590
  child_process.execSync("git init", { cwd: projectPath, stdio: "ignore" });
1505
1591
  child_process.execSync("git add .", { cwd: projectPath, stdio: "ignore" });
1506
- child_process.execSync('git commit -m "Initial commit from onex init"', {
1592
+ child_process.execSync('git commit -m "Initial commit from onexthm init"', {
1507
1593
  cwd: projectPath,
1508
1594
  stdio: "ignore"
1509
1595
  });
@@ -2671,7 +2757,7 @@ async function buildCommand(options) {
2671
2757
  exports.logger.stopSpinner(true, "Lint passed");
2672
2758
  const pkgJson = fs__default.default.readJsonSync(packageJsonPath);
2673
2759
  const buildScript = pkgJson.scripts?.build || "";
2674
- const isRecursive = buildScript.includes("onex build") || buildScript.includes("onex-cli build");
2760
+ const isRecursive = buildScript.includes("onexthm build") || buildScript.includes("onex-cli build");
2675
2761
  exports.logger.startSpinner(
2676
2762
  options.watch ? "Building (watch mode)..." : "Building..."
2677
2763
  );
@@ -2869,7 +2955,7 @@ async function uploadCommand(options) {
2869
2955
  if (!compiledDir) {
2870
2956
  spinner.fail(
2871
2957
  chalk4__default.default.red(
2872
- `Compiled theme not found for ${themeId}@${version}. Run 'onex build' first.`
2958
+ `Compiled theme not found for ${themeId}@${version}. Run 'onexthm build' first.`
2873
2959
  )
2874
2960
  );
2875
2961
  exports.logger.info(chalk4__default.default.gray(`Expected location:
@@ -3101,7 +3187,7 @@ function showDownloadFailureHelp(themeId, bucket) {
3101
3187
  console.log(chalk4__default.default.white("1. Compile and upload the theme:"));
3102
3188
  console.log(chalk4__default.default.gray(` cd themes/${themeId}`));
3103
3189
  console.log(chalk4__default.default.gray(" pnpm build"));
3104
- console.log(chalk4__default.default.gray(" onex upload"));
3190
+ console.log(chalk4__default.default.gray(" onexthm upload"));
3105
3191
  console.log();
3106
3192
  console.log(chalk4__default.default.white("2. Verify AWS credentials are set:"));
3107
3193
  console.log(
@@ -3403,7 +3489,7 @@ async function cloneCommand(themeName, options) {
3403
3489
  chalk4__default.default.yellow("The theme source may not have been uploaded yet.")
3404
3490
  );
3405
3491
  console.log(
3406
- chalk4__default.default.gray(`Upload source with: onex upload --theme ${themeName}`)
3492
+ chalk4__default.default.gray(`Upload source with: onexthm upload --theme ${themeName}`)
3407
3493
  );
3408
3494
  console.log();
3409
3495
  process.exit(1);
@@ -3472,7 +3558,7 @@ async function cloneCommand(themeName, options) {
3472
3558
  if (options.install === false) {
3473
3559
  console.log(chalk4__default.default.gray(" pnpm install"));
3474
3560
  }
3475
- console.log(chalk4__default.default.gray(" onex build"));
3561
+ console.log(chalk4__default.default.gray(" onexthm build"));
3476
3562
  console.log();
3477
3563
  } catch (error) {
3478
3564
  spinner.fail(chalk4__default.default.red(`Clone failed: ${error.message}`));