@onexapis/cli 1.1.6 → 1.1.8

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 CHANGED
@@ -14,6 +14,7 @@ var fs = require('fs-extra');
14
14
  var ejs = require('ejs');
15
15
  var child_process = require('child_process');
16
16
  var commander = require('commander');
17
+ var module$1 = require('module');
17
18
  var fs2 = require('fs');
18
19
  var inquirer = require('inquirer');
19
20
  var archiver = require('archiver');
@@ -369,7 +370,7 @@ async function extractDataRequirements(themePath) {
369
370
  return requirements;
370
371
  }
371
372
  async function generateManifest2(themeName, themePath, outputDir) {
372
- let version = "1.0.0";
373
+ let version2 = "1.0.0";
373
374
  let themeId = themeName;
374
375
  try {
375
376
  const pkgContent = await fs7__default.default.readFile(
@@ -377,7 +378,7 @@ async function generateManifest2(themeName, themePath, outputDir) {
377
378
  "utf-8"
378
379
  );
379
380
  const pkg = JSON.parse(pkgContent);
380
- version = pkg.version || version;
381
+ version2 = pkg.version || version2;
381
382
  if (pkg.name) {
382
383
  themeId = pkg.name.replace(/^@onex-themes\//, "");
383
384
  }
@@ -401,7 +402,7 @@ async function generateManifest2(themeName, themePath, outputDir) {
401
402
  const entryFile = jsFiles.find((f) => f.includes("bundle-entry")) || "bundle-entry.js";
402
403
  const manifest = {
403
404
  themeId,
404
- version,
405
+ version: version2,
405
406
  name: themeId.charAt(0).toUpperCase() + themeId.slice(1),
406
407
  compiledAt: (/* @__PURE__ */ new Date()).toISOString(),
407
408
  format: "esm",
@@ -757,7 +758,8 @@ export function headers() { return new Headers(); }
757
758
  };
758
759
  return {
759
760
  contents: stubs[args.path] || "export default {};",
760
- loader: "jsx"
761
+ loader: "jsx",
762
+ resolveDir: themePath
761
763
  };
762
764
  });
763
765
  }
@@ -1305,10 +1307,10 @@ export const manifest: ThemeExport = {
1305
1307
  author: "${data.author}",
1306
1308
 
1307
1309
  // Theme configuration
1308
- config: () => import("./theme.config").then((m) => m.themeConfig),
1310
+ config: () => import("./config").then((m) => m.themeConfig),
1309
1311
 
1310
1312
  // Theme layout (header/footer sections)
1311
- layout: () => import("./theme.layout").then((m) => m.themeLayout),
1313
+ layout: () => import("./layout").then((m) => m.themeLayout),
1312
1314
 
1313
1315
  // Available sections in this theme
1314
1316
  sections: {
@@ -1474,9 +1476,9 @@ function generateThemeIndex(data) {
1474
1476
  * ${data.themeNamePascal} Theme
1475
1477
  */
1476
1478
 
1477
- export { manifest as ${data.themeName}Manifest } from "./manifest";
1478
- export { themeConfig as ${data.themeName}Config } from "./theme.config";
1479
- export { themeLayout as ${data.themeName}Layout } from "./theme.layout";
1479
+ export { manifest as ${data.themeNamePascal}Manifest } from "./manifest";
1480
+ export { themeConfig as ${data.themeNamePascal}Config } from "./config";
1481
+ export { themeLayout as ${data.themeNamePascal}Layout } from "./layout";
1480
1482
  `;
1481
1483
  }
1482
1484
  function generateHomePage(data) {
@@ -2317,9 +2319,9 @@ async function listThemesInfo() {
2317
2319
  const versionMatch = manifestContent.match(/version:\s*["'](.+)["']/);
2318
2320
  const descMatch = manifestContent.match(/description:\s*["'](.+)["']/);
2319
2321
  const displayName = nameMatch ? nameMatch[1] : theme;
2320
- const version = versionMatch ? versionMatch[1] : "unknown";
2322
+ const version2 = versionMatch ? versionMatch[1] : "unknown";
2321
2323
  const description = descMatch ? descMatch[1] : "";
2322
- logger.log(chalk4__default.default.cyan(` ${displayName}`) + chalk4__default.default.gray(` (v${version})`));
2324
+ logger.log(chalk4__default.default.cyan(` ${displayName}`) + chalk4__default.default.gray(` (v${version2})`));
2323
2325
  if (description) {
2324
2326
  logger.log(chalk4__default.default.gray(` ${description}`));
2325
2327
  }
@@ -2667,14 +2669,14 @@ async function packageCommand(options) {
2667
2669
  }
2668
2670
  }
2669
2671
  const packageJsonPath = path8__default.default.join(themePath, "package.json");
2670
- let version = "1.0.0";
2672
+ let version2 = "1.0.0";
2671
2673
  if (fs__default.default.existsSync(packageJsonPath)) {
2672
2674
  const packageJson = await fs__default.default.readJson(packageJsonPath);
2673
- version = packageJson.version || "1.0.0";
2675
+ version2 = packageJson.version || "1.0.0";
2674
2676
  }
2675
2677
  logger.newLine();
2676
2678
  logger.info(`Theme: ${themeName}`);
2677
- logger.info(`Version: ${version}`);
2679
+ logger.info(`Version: ${version2}`);
2678
2680
  logger.newLine();
2679
2681
  const compiledThemePath = path8__default.default.join(
2680
2682
  process.cwd(),
@@ -2709,7 +2711,7 @@ async function packageCommand(options) {
2709
2711
  }
2710
2712
  logger.newLine();
2711
2713
  logger.section("Step 2: Create Package");
2712
- const packageName = options.name || `${themeName}-${version}`;
2714
+ const packageName = options.name || `${themeName}-${version2}`;
2713
2715
  const outputDir = options.output || path8__default.default.join(process.cwd(), "dist");
2714
2716
  const outputPath = path8__default.default.join(outputDir, `${packageName}.zip`);
2715
2717
  await fs__default.default.ensureDir(outputDir);
@@ -2924,7 +2926,7 @@ function getBucketName(env) {
2924
2926
  const environment = env || process.env.ENVIRONMENT || "staging";
2925
2927
  return environment === "production" ? "onex-themes-prod" : "onex-themes-staging";
2926
2928
  }
2927
- async function findCompiledThemeDir(themeId, version) {
2929
+ async function findCompiledThemeDir(themeId, version2) {
2928
2930
  const searchPaths = [path8__default.default.resolve(process.cwd(), "dist")];
2929
2931
  for (const dir of searchPaths) {
2930
2932
  if (await fs__default.default.pathExists(dir)) {
@@ -2994,9 +2996,9 @@ async function findSourceDir(themeId, explicitDir) {
2994
2996
  }
2995
2997
  return null;
2996
2998
  }
2997
- async function updateLatestPointer(s3Client, bucket, themeId, version) {
2999
+ async function updateLatestPointer(s3Client, bucket, themeId, version2) {
2998
3000
  const latestData = {
2999
- version,
3001
+ version: version2,
3000
3002
  uploadedAt: (/* @__PURE__ */ new Date()).toISOString()
3001
3003
  };
3002
3004
  await s3Client.send(
@@ -3013,23 +3015,23 @@ async function uploadCommand(options) {
3013
3015
  const spinner = ora__default.default("Preparing theme upload...").start();
3014
3016
  try {
3015
3017
  let themeId;
3016
- let version;
3018
+ let version2;
3017
3019
  if (options.theme) {
3018
3020
  themeId = options.theme;
3019
- version = options.version || "1.0.0";
3021
+ version2 = options.version || "1.0.0";
3020
3022
  } else {
3021
3023
  const manifest = await readManifest();
3022
3024
  themeId = manifest.themeId;
3023
- version = options.version || manifest.version || "1.0.0";
3025
+ version2 = options.version || manifest.version || "1.0.0";
3024
3026
  }
3025
- spinner.text = `Found theme: ${themeId}@${version}`;
3027
+ spinner.text = `Found theme: ${themeId}@${version2}`;
3026
3028
  const bucket = options.bucket || getBucketName(options.environment);
3027
3029
  const s3Client = getS3Client();
3028
- const compiledDir = await findCompiledThemeDir(themeId, version);
3030
+ const compiledDir = await findCompiledThemeDir(themeId, version2);
3029
3031
  if (!compiledDir) {
3030
3032
  spinner.fail(
3031
3033
  chalk4__default.default.red(
3032
- `Compiled theme not found for ${themeId}@${version}. Run 'onex build' first.`
3034
+ `Compiled theme not found for ${themeId}@${version2}. Run 'onex build' first.`
3033
3035
  )
3034
3036
  );
3035
3037
  logger.info(chalk4__default.default.gray(`Expected location:
@@ -3039,7 +3041,7 @@ async function uploadCommand(options) {
3039
3041
  spinner.succeed(`Found compiled theme at: ${compiledDir}`);
3040
3042
  spinner.start("Creating bundle.zip...");
3041
3043
  const tmpDir = os__default.default.tmpdir();
3042
- const bundleZipPath = path8__default.default.join(tmpDir, `${themeId}-${version}-bundle.zip`);
3044
+ const bundleZipPath = path8__default.default.join(tmpDir, `${themeId}-${version2}-bundle.zip`);
3043
3045
  await createZipFromDir(compiledDir, bundleZipPath);
3044
3046
  const bundleZipBuffer = await fs__default.default.readFile(bundleZipPath);
3045
3047
  const bundleSizeMB = (bundleZipBuffer.length / 1024 / 1024).toFixed(2);
@@ -3050,7 +3052,7 @@ async function uploadCommand(options) {
3050
3052
  console.log(chalk4__default.default.gray(` bundle.zip: ${bundleSizeMB} MB`));
3051
3053
  console.log(
3052
3054
  chalk4__default.default.cyan(
3053
- ` S3 path: s3://${bucket}/themes/${themeId}/${version}/bundle.zip`
3055
+ ` S3 path: s3://${bucket}/themes/${themeId}/${version2}/bundle.zip`
3054
3056
  )
3055
3057
  );
3056
3058
  if (!options.skipSource) {
@@ -3059,7 +3061,7 @@ async function uploadCommand(options) {
3059
3061
  console.log(chalk4__default.default.gray(` source dir: ${sourceDir}`));
3060
3062
  console.log(
3061
3063
  chalk4__default.default.cyan(
3062
- ` S3 path: s3://${bucket}/themes/${themeId}/${version}/source.zip`
3064
+ ` S3 path: s3://${bucket}/themes/${themeId}/${version2}/source.zip`
3063
3065
  )
3064
3066
  );
3065
3067
  } else {
@@ -3073,7 +3075,7 @@ async function uploadCommand(options) {
3073
3075
  return;
3074
3076
  }
3075
3077
  spinner.start("Uploading bundle.zip to S3...");
3076
- const bundleS3Key = `themes/${themeId}/${version}/bundle.zip`;
3078
+ const bundleS3Key = `themes/${themeId}/${version2}/bundle.zip`;
3077
3079
  await s3Client.send(
3078
3080
  new clientS3.PutObjectCommand({
3079
3081
  Bucket: bucket,
@@ -3095,7 +3097,7 @@ async function uploadCommand(options) {
3095
3097
  spinner.start("Creating source.zip...");
3096
3098
  const sourceZipPath = path8__default.default.join(
3097
3099
  tmpDir,
3098
- `${themeId}-${version}-source.zip`
3100
+ `${themeId}-${version2}-source.zip`
3099
3101
  );
3100
3102
  await createZipFromDir(sourceDir, sourceZipPath, [
3101
3103
  "node_modules/**",
@@ -3109,7 +3111,7 @@ async function uploadCommand(options) {
3109
3111
  const sourceSizeMB = (sourceZipBuffer.length / 1024 / 1024).toFixed(2);
3110
3112
  spinner.succeed(`Created source.zip (${sourceSizeMB} MB)`);
3111
3113
  spinner.start("Uploading source.zip to S3...");
3112
- const sourceS3Key = `themes/${themeId}/${version}/source.zip`;
3114
+ const sourceS3Key = `themes/${themeId}/${version2}/source.zip`;
3113
3115
  await s3Client.send(
3114
3116
  new clientS3.PutObjectCommand({
3115
3117
  Bucket: bucket,
@@ -3130,20 +3132,20 @@ async function uploadCommand(options) {
3130
3132
  }
3131
3133
  }
3132
3134
  spinner.start("Updating latest.json pointer...");
3133
- await updateLatestPointer(s3Client, bucket, themeId, version);
3135
+ await updateLatestPointer(s3Client, bucket, themeId, version2);
3134
3136
  spinner.succeed("Updated latest.json pointer");
3135
3137
  console.log();
3136
3138
  logger.success(chalk4__default.default.green.bold("Theme uploaded successfully!"));
3137
3139
  console.log();
3138
3140
  console.log(
3139
- chalk4__default.default.cyan(" Theme: ") + chalk4__default.default.white(`${themeId}@${version}`)
3141
+ chalk4__default.default.cyan(" Theme: ") + chalk4__default.default.white(`${themeId}@${version2}`)
3140
3142
  );
3141
3143
  console.log(chalk4__default.default.cyan(" Bucket: ") + chalk4__default.default.white(bucket));
3142
3144
  console.log(
3143
3145
  chalk4__default.default.cyan(" Files: ") + chalk4__default.default.white(`bundle.zip${sourceUploaded ? " + source.zip" : ""}`)
3144
3146
  );
3145
3147
  console.log(
3146
- chalk4__default.default.cyan(" Path: ") + chalk4__default.default.gray(`s3://${bucket}/themes/${themeId}/${version}/`)
3148
+ chalk4__default.default.cyan(" Path: ") + chalk4__default.default.gray(`s3://${bucket}/themes/${themeId}/${version2}/`)
3147
3149
  );
3148
3150
  console.log();
3149
3151
  } catch (error) {
@@ -3285,7 +3287,7 @@ async function downloadCommand(options) {
3285
3287
  const spinner = ora__default.default("Initializing download...").start();
3286
3288
  try {
3287
3289
  const themeId = options.themeId || process.env.NEXT_PUBLIC_THEME_ID || process.env.THEME_ID;
3288
- const version = options.version || process.env.THEME_VERSION || "latest";
3290
+ const version2 = options.version || process.env.THEME_VERSION || "latest";
3289
3291
  const bucket = options.bucket || getBucketName2(options.environment);
3290
3292
  const outputDir = options.output || "./active-theme";
3291
3293
  if (!themeId) {
@@ -3296,10 +3298,10 @@ async function downloadCommand(options) {
3296
3298
  );
3297
3299
  process.exit(1);
3298
3300
  }
3299
- spinner.text = `Downloading ${themeId}@${version} from ${bucket}...`;
3301
+ spinner.text = `Downloading ${themeId}@${version2} from ${bucket}...`;
3300
3302
  const s3Client = getS3Client2();
3301
- let resolvedVersion = version;
3302
- if (version === "latest") {
3303
+ let resolvedVersion = version2;
3304
+ if (version2 === "latest") {
3303
3305
  spinner.text = "Resolving latest version...";
3304
3306
  resolvedVersion = await resolveLatestVersion(s3Client, bucket, themeId);
3305
3307
  spinner.succeed(
@@ -3539,14 +3541,14 @@ async function cloneCommand(themeName, options) {
3539
3541
  );
3540
3542
  process.exit(1);
3541
3543
  }
3542
- let version = options.version || "latest";
3543
- if (version === "latest") {
3544
+ let version2 = options.version || "latest";
3545
+ if (version2 === "latest") {
3544
3546
  spinner.text = "Resolving latest version...";
3545
- version = await resolveLatestVersion2(s3Client, bucket, themeName);
3546
- spinner.succeed(`Resolved latest version: ${chalk4__default.default.cyan(version)}`);
3547
+ version2 = await resolveLatestVersion2(s3Client, bucket, themeName);
3548
+ spinner.succeed(`Resolved latest version: ${chalk4__default.default.cyan(version2)}`);
3547
3549
  }
3548
- spinner.start(`Downloading source.zip for ${themeName}@${version}...`);
3549
- const s3Key = `themes/${themeName}/${version}/source.zip`;
3550
+ spinner.start(`Downloading source.zip for ${themeName}@${version2}...`);
3551
+ const s3Key = `themes/${themeName}/${version2}/source.zip`;
3550
3552
  let zipBuffer;
3551
3553
  try {
3552
3554
  const response = await s3Client.send(
@@ -3618,7 +3620,7 @@ async function cloneCommand(themeName, options) {
3618
3620
  logger.success(chalk4__default.default.green.bold("Theme cloned successfully!"));
3619
3621
  console.log();
3620
3622
  console.log(
3621
- chalk4__default.default.cyan(" Source: ") + chalk4__default.default.gray(`${themeName}@${version}`)
3623
+ chalk4__default.default.cyan(" Source: ") + chalk4__default.default.gray(`${themeName}@${version2}`)
3622
3624
  );
3623
3625
  console.log(chalk4__default.default.cyan(" Theme: ") + chalk4__default.default.white(newName));
3624
3626
  console.log(chalk4__default.default.cyan(" Location: ") + chalk4__default.default.white(outputDir));
@@ -3893,8 +3895,10 @@ dotenv__default.default.config({
3893
3895
  path: path8__default.default.join(os__default.default.homedir(), ".onex", ".env"),
3894
3896
  quiet: true
3895
3897
  });
3898
+ var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
3899
+ var { version } = require2("../package.json");
3896
3900
  var program = new commander.Command();
3897
- program.name("onex").description("CLI tool for OneX theme development").version("0.1.0");
3901
+ program.name("onex").description("CLI tool for OneX theme development").version(version);
3898
3902
  program.command("init").description("Create a new OneX theme project").argument("[project-name]", "Name of the project").option(
3899
3903
  "-t, --template <template>",
3900
3904
  "Template to use (default, minimal)",