@onexapis/cli 1.1.6 → 1.1.7

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.mjs CHANGED
@@ -12,6 +12,7 @@ import fs from 'fs-extra';
12
12
  import ejs from 'ejs';
13
13
  import { execSync, spawn } from 'child_process';
14
14
  import { Command } from 'commander';
15
+ import { createRequire } from 'module';
15
16
  import fs2 from 'fs';
16
17
  import inquirer from 'inquirer';
17
18
  import archiver from 'archiver';
@@ -327,7 +328,7 @@ async function extractDataRequirements(themePath) {
327
328
  return requirements;
328
329
  }
329
330
  async function generateManifest2(themeName, themePath, outputDir) {
330
- let version = "1.0.0";
331
+ let version2 = "1.0.0";
331
332
  let themeId = themeName;
332
333
  try {
333
334
  const pkgContent = await fs7.readFile(
@@ -335,7 +336,7 @@ async function generateManifest2(themeName, themePath, outputDir) {
335
336
  "utf-8"
336
337
  );
337
338
  const pkg = JSON.parse(pkgContent);
338
- version = pkg.version || version;
339
+ version2 = pkg.version || version2;
339
340
  if (pkg.name) {
340
341
  themeId = pkg.name.replace(/^@onex-themes\//, "");
341
342
  }
@@ -359,7 +360,7 @@ async function generateManifest2(themeName, themePath, outputDir) {
359
360
  const entryFile = jsFiles.find((f) => f.includes("bundle-entry")) || "bundle-entry.js";
360
361
  const manifest = {
361
362
  themeId,
362
- version,
363
+ version: version2,
363
364
  name: themeId.charAt(0).toUpperCase() + themeId.slice(1),
364
365
  compiledAt: (/* @__PURE__ */ new Date()).toISOString(),
365
366
  format: "esm",
@@ -1263,10 +1264,10 @@ export const manifest: ThemeExport = {
1263
1264
  author: "${data.author}",
1264
1265
 
1265
1266
  // Theme configuration
1266
- config: () => import("./theme.config").then((m) => m.themeConfig),
1267
+ config: () => import("./config").then((m) => m.themeConfig),
1267
1268
 
1268
1269
  // Theme layout (header/footer sections)
1269
- layout: () => import("./theme.layout").then((m) => m.themeLayout),
1270
+ layout: () => import("./layout").then((m) => m.themeLayout),
1270
1271
 
1271
1272
  // Available sections in this theme
1272
1273
  sections: {
@@ -1432,9 +1433,9 @@ function generateThemeIndex(data) {
1432
1433
  * ${data.themeNamePascal} Theme
1433
1434
  */
1434
1435
 
1435
- export { manifest as ${data.themeName}Manifest } from "./manifest";
1436
- export { themeConfig as ${data.themeName}Config } from "./theme.config";
1437
- export { themeLayout as ${data.themeName}Layout } from "./theme.layout";
1436
+ export { manifest as ${data.themeNamePascal}Manifest } from "./manifest";
1437
+ export { themeConfig as ${data.themeNamePascal}Config } from "./config";
1438
+ export { themeLayout as ${data.themeNamePascal}Layout } from "./layout";
1438
1439
  `;
1439
1440
  }
1440
1441
  function generateHomePage(data) {
@@ -2275,9 +2276,9 @@ async function listThemesInfo() {
2275
2276
  const versionMatch = manifestContent.match(/version:\s*["'](.+)["']/);
2276
2277
  const descMatch = manifestContent.match(/description:\s*["'](.+)["']/);
2277
2278
  const displayName = nameMatch ? nameMatch[1] : theme;
2278
- const version = versionMatch ? versionMatch[1] : "unknown";
2279
+ const version2 = versionMatch ? versionMatch[1] : "unknown";
2279
2280
  const description = descMatch ? descMatch[1] : "";
2280
- logger.log(chalk4.cyan(` ${displayName}`) + chalk4.gray(` (v${version})`));
2281
+ logger.log(chalk4.cyan(` ${displayName}`) + chalk4.gray(` (v${version2})`));
2281
2282
  if (description) {
2282
2283
  logger.log(chalk4.gray(` ${description}`));
2283
2284
  }
@@ -2625,14 +2626,14 @@ async function packageCommand(options) {
2625
2626
  }
2626
2627
  }
2627
2628
  const packageJsonPath = path8.join(themePath, "package.json");
2628
- let version = "1.0.0";
2629
+ let version2 = "1.0.0";
2629
2630
  if (fs.existsSync(packageJsonPath)) {
2630
2631
  const packageJson = await fs.readJson(packageJsonPath);
2631
- version = packageJson.version || "1.0.0";
2632
+ version2 = packageJson.version || "1.0.0";
2632
2633
  }
2633
2634
  logger.newLine();
2634
2635
  logger.info(`Theme: ${themeName}`);
2635
- logger.info(`Version: ${version}`);
2636
+ logger.info(`Version: ${version2}`);
2636
2637
  logger.newLine();
2637
2638
  const compiledThemePath = path8.join(
2638
2639
  process.cwd(),
@@ -2667,7 +2668,7 @@ async function packageCommand(options) {
2667
2668
  }
2668
2669
  logger.newLine();
2669
2670
  logger.section("Step 2: Create Package");
2670
- const packageName = options.name || `${themeName}-${version}`;
2671
+ const packageName = options.name || `${themeName}-${version2}`;
2671
2672
  const outputDir = options.output || path8.join(process.cwd(), "dist");
2672
2673
  const outputPath = path8.join(outputDir, `${packageName}.zip`);
2673
2674
  await fs.ensureDir(outputDir);
@@ -2882,7 +2883,7 @@ function getBucketName(env) {
2882
2883
  const environment = env || process.env.ENVIRONMENT || "staging";
2883
2884
  return environment === "production" ? "onex-themes-prod" : "onex-themes-staging";
2884
2885
  }
2885
- async function findCompiledThemeDir(themeId, version) {
2886
+ async function findCompiledThemeDir(themeId, version2) {
2886
2887
  const searchPaths = [path8.resolve(process.cwd(), "dist")];
2887
2888
  for (const dir of searchPaths) {
2888
2889
  if (await fs.pathExists(dir)) {
@@ -2952,9 +2953,9 @@ async function findSourceDir(themeId, explicitDir) {
2952
2953
  }
2953
2954
  return null;
2954
2955
  }
2955
- async function updateLatestPointer(s3Client, bucket, themeId, version) {
2956
+ async function updateLatestPointer(s3Client, bucket, themeId, version2) {
2956
2957
  const latestData = {
2957
- version,
2958
+ version: version2,
2958
2959
  uploadedAt: (/* @__PURE__ */ new Date()).toISOString()
2959
2960
  };
2960
2961
  await s3Client.send(
@@ -2971,23 +2972,23 @@ async function uploadCommand(options) {
2971
2972
  const spinner = ora("Preparing theme upload...").start();
2972
2973
  try {
2973
2974
  let themeId;
2974
- let version;
2975
+ let version2;
2975
2976
  if (options.theme) {
2976
2977
  themeId = options.theme;
2977
- version = options.version || "1.0.0";
2978
+ version2 = options.version || "1.0.0";
2978
2979
  } else {
2979
2980
  const manifest = await readManifest();
2980
2981
  themeId = manifest.themeId;
2981
- version = options.version || manifest.version || "1.0.0";
2982
+ version2 = options.version || manifest.version || "1.0.0";
2982
2983
  }
2983
- spinner.text = `Found theme: ${themeId}@${version}`;
2984
+ spinner.text = `Found theme: ${themeId}@${version2}`;
2984
2985
  const bucket = options.bucket || getBucketName(options.environment);
2985
2986
  const s3Client = getS3Client();
2986
- const compiledDir = await findCompiledThemeDir(themeId, version);
2987
+ const compiledDir = await findCompiledThemeDir(themeId, version2);
2987
2988
  if (!compiledDir) {
2988
2989
  spinner.fail(
2989
2990
  chalk4.red(
2990
- `Compiled theme not found for ${themeId}@${version}. Run 'onex build' first.`
2991
+ `Compiled theme not found for ${themeId}@${version2}. Run 'onex build' first.`
2991
2992
  )
2992
2993
  );
2993
2994
  logger.info(chalk4.gray(`Expected location:
@@ -2997,7 +2998,7 @@ async function uploadCommand(options) {
2997
2998
  spinner.succeed(`Found compiled theme at: ${compiledDir}`);
2998
2999
  spinner.start("Creating bundle.zip...");
2999
3000
  const tmpDir = os.tmpdir();
3000
- const bundleZipPath = path8.join(tmpDir, `${themeId}-${version}-bundle.zip`);
3001
+ const bundleZipPath = path8.join(tmpDir, `${themeId}-${version2}-bundle.zip`);
3001
3002
  await createZipFromDir(compiledDir, bundleZipPath);
3002
3003
  const bundleZipBuffer = await fs.readFile(bundleZipPath);
3003
3004
  const bundleSizeMB = (bundleZipBuffer.length / 1024 / 1024).toFixed(2);
@@ -3008,7 +3009,7 @@ async function uploadCommand(options) {
3008
3009
  console.log(chalk4.gray(` bundle.zip: ${bundleSizeMB} MB`));
3009
3010
  console.log(
3010
3011
  chalk4.cyan(
3011
- ` S3 path: s3://${bucket}/themes/${themeId}/${version}/bundle.zip`
3012
+ ` S3 path: s3://${bucket}/themes/${themeId}/${version2}/bundle.zip`
3012
3013
  )
3013
3014
  );
3014
3015
  if (!options.skipSource) {
@@ -3017,7 +3018,7 @@ async function uploadCommand(options) {
3017
3018
  console.log(chalk4.gray(` source dir: ${sourceDir}`));
3018
3019
  console.log(
3019
3020
  chalk4.cyan(
3020
- ` S3 path: s3://${bucket}/themes/${themeId}/${version}/source.zip`
3021
+ ` S3 path: s3://${bucket}/themes/${themeId}/${version2}/source.zip`
3021
3022
  )
3022
3023
  );
3023
3024
  } else {
@@ -3031,7 +3032,7 @@ async function uploadCommand(options) {
3031
3032
  return;
3032
3033
  }
3033
3034
  spinner.start("Uploading bundle.zip to S3...");
3034
- const bundleS3Key = `themes/${themeId}/${version}/bundle.zip`;
3035
+ const bundleS3Key = `themes/${themeId}/${version2}/bundle.zip`;
3035
3036
  await s3Client.send(
3036
3037
  new PutObjectCommand({
3037
3038
  Bucket: bucket,
@@ -3053,7 +3054,7 @@ async function uploadCommand(options) {
3053
3054
  spinner.start("Creating source.zip...");
3054
3055
  const sourceZipPath = path8.join(
3055
3056
  tmpDir,
3056
- `${themeId}-${version}-source.zip`
3057
+ `${themeId}-${version2}-source.zip`
3057
3058
  );
3058
3059
  await createZipFromDir(sourceDir, sourceZipPath, [
3059
3060
  "node_modules/**",
@@ -3067,7 +3068,7 @@ async function uploadCommand(options) {
3067
3068
  const sourceSizeMB = (sourceZipBuffer.length / 1024 / 1024).toFixed(2);
3068
3069
  spinner.succeed(`Created source.zip (${sourceSizeMB} MB)`);
3069
3070
  spinner.start("Uploading source.zip to S3...");
3070
- const sourceS3Key = `themes/${themeId}/${version}/source.zip`;
3071
+ const sourceS3Key = `themes/${themeId}/${version2}/source.zip`;
3071
3072
  await s3Client.send(
3072
3073
  new PutObjectCommand({
3073
3074
  Bucket: bucket,
@@ -3088,20 +3089,20 @@ async function uploadCommand(options) {
3088
3089
  }
3089
3090
  }
3090
3091
  spinner.start("Updating latest.json pointer...");
3091
- await updateLatestPointer(s3Client, bucket, themeId, version);
3092
+ await updateLatestPointer(s3Client, bucket, themeId, version2);
3092
3093
  spinner.succeed("Updated latest.json pointer");
3093
3094
  console.log();
3094
3095
  logger.success(chalk4.green.bold("Theme uploaded successfully!"));
3095
3096
  console.log();
3096
3097
  console.log(
3097
- chalk4.cyan(" Theme: ") + chalk4.white(`${themeId}@${version}`)
3098
+ chalk4.cyan(" Theme: ") + chalk4.white(`${themeId}@${version2}`)
3098
3099
  );
3099
3100
  console.log(chalk4.cyan(" Bucket: ") + chalk4.white(bucket));
3100
3101
  console.log(
3101
3102
  chalk4.cyan(" Files: ") + chalk4.white(`bundle.zip${sourceUploaded ? " + source.zip" : ""}`)
3102
3103
  );
3103
3104
  console.log(
3104
- chalk4.cyan(" Path: ") + chalk4.gray(`s3://${bucket}/themes/${themeId}/${version}/`)
3105
+ chalk4.cyan(" Path: ") + chalk4.gray(`s3://${bucket}/themes/${themeId}/${version2}/`)
3105
3106
  );
3106
3107
  console.log();
3107
3108
  } catch (error) {
@@ -3243,7 +3244,7 @@ async function downloadCommand(options) {
3243
3244
  const spinner = ora("Initializing download...").start();
3244
3245
  try {
3245
3246
  const themeId = options.themeId || process.env.NEXT_PUBLIC_THEME_ID || process.env.THEME_ID;
3246
- const version = options.version || process.env.THEME_VERSION || "latest";
3247
+ const version2 = options.version || process.env.THEME_VERSION || "latest";
3247
3248
  const bucket = options.bucket || getBucketName2(options.environment);
3248
3249
  const outputDir = options.output || "./active-theme";
3249
3250
  if (!themeId) {
@@ -3254,10 +3255,10 @@ async function downloadCommand(options) {
3254
3255
  );
3255
3256
  process.exit(1);
3256
3257
  }
3257
- spinner.text = `Downloading ${themeId}@${version} from ${bucket}...`;
3258
+ spinner.text = `Downloading ${themeId}@${version2} from ${bucket}...`;
3258
3259
  const s3Client = getS3Client2();
3259
- let resolvedVersion = version;
3260
- if (version === "latest") {
3260
+ let resolvedVersion = version2;
3261
+ if (version2 === "latest") {
3261
3262
  spinner.text = "Resolving latest version...";
3262
3263
  resolvedVersion = await resolveLatestVersion(s3Client, bucket, themeId);
3263
3264
  spinner.succeed(
@@ -3497,14 +3498,14 @@ async function cloneCommand(themeName, options) {
3497
3498
  );
3498
3499
  process.exit(1);
3499
3500
  }
3500
- let version = options.version || "latest";
3501
- if (version === "latest") {
3501
+ let version2 = options.version || "latest";
3502
+ if (version2 === "latest") {
3502
3503
  spinner.text = "Resolving latest version...";
3503
- version = await resolveLatestVersion2(s3Client, bucket, themeName);
3504
- spinner.succeed(`Resolved latest version: ${chalk4.cyan(version)}`);
3504
+ version2 = await resolveLatestVersion2(s3Client, bucket, themeName);
3505
+ spinner.succeed(`Resolved latest version: ${chalk4.cyan(version2)}`);
3505
3506
  }
3506
- spinner.start(`Downloading source.zip for ${themeName}@${version}...`);
3507
- const s3Key = `themes/${themeName}/${version}/source.zip`;
3507
+ spinner.start(`Downloading source.zip for ${themeName}@${version2}...`);
3508
+ const s3Key = `themes/${themeName}/${version2}/source.zip`;
3508
3509
  let zipBuffer;
3509
3510
  try {
3510
3511
  const response = await s3Client.send(
@@ -3576,7 +3577,7 @@ async function cloneCommand(themeName, options) {
3576
3577
  logger.success(chalk4.green.bold("Theme cloned successfully!"));
3577
3578
  console.log();
3578
3579
  console.log(
3579
- chalk4.cyan(" Source: ") + chalk4.gray(`${themeName}@${version}`)
3580
+ chalk4.cyan(" Source: ") + chalk4.gray(`${themeName}@${version2}`)
3580
3581
  );
3581
3582
  console.log(chalk4.cyan(" Theme: ") + chalk4.white(newName));
3582
3583
  console.log(chalk4.cyan(" Location: ") + chalk4.white(outputDir));
@@ -3851,8 +3852,10 @@ dotenv.config({
3851
3852
  path: path8.join(os.homedir(), ".onex", ".env"),
3852
3853
  quiet: true
3853
3854
  });
3855
+ var require2 = createRequire(import.meta.url);
3856
+ var { version } = require2("../package.json");
3854
3857
  var program = new Command();
3855
- program.name("onex").description("CLI tool for OneX theme development").version("0.1.0");
3858
+ program.name("onex").description("CLI tool for OneX theme development").version(version);
3856
3859
  program.command("init").description("Create a new OneX theme project").argument("[project-name]", "Name of the project").option(
3857
3860
  "-t, --template <template>",
3858
3861
  "Template to use (default, minimal)",