@onexapis/cli 1.1.5 → 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.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",
@@ -1291,7 +1292,7 @@ Add your theme-specific blocks here.
1291
1292
  }
1292
1293
  }
1293
1294
  function generateManifest(data) {
1294
- return `import type { ThemeExport } from "@duongthiu/onex-core";
1295
+ return `import type { ThemeExport } from "@onexapis/core";
1295
1296
 
1296
1297
  /**
1297
1298
  * ${data.displayName} Theme Manifest
@@ -1305,10 +1306,10 @@ export const manifest: ThemeExport = {
1305
1306
  author: "${data.author}",
1306
1307
 
1307
1308
  // Theme configuration
1308
- config: () => import("./theme.config").then((m) => m.themeConfig),
1309
+ config: () => import("./config").then((m) => m.themeConfig),
1309
1310
 
1310
1311
  // Theme layout (header/footer sections)
1311
- layout: () => import("./theme.layout").then((m) => m.themeLayout),
1312
+ layout: () => import("./layout").then((m) => m.themeLayout),
1312
1313
 
1313
1314
  // Available sections in this theme
1314
1315
  sections: {
@@ -1339,7 +1340,7 @@ export default manifest;
1339
1340
  `;
1340
1341
  }
1341
1342
  function generateThemeConfig(data) {
1342
- return `import type { ThemeConfig } from "@duongthiu/onex-core";
1343
+ return `import type { ThemeConfig } from "@onexapis/core";
1343
1344
 
1344
1345
  /**
1345
1346
  * ${data.displayName} Theme Configuration
@@ -1440,7 +1441,7 @@ export const themeConfig: ThemeConfig = {
1440
1441
  `;
1441
1442
  }
1442
1443
  function generateThemeLayout(data) {
1443
- return `import type { ThemeLayoutConfig } from "@duongthiu/onex-core";
1444
+ return `import type { ThemeLayoutConfig } from "@onexapis/core";
1444
1445
 
1445
1446
  /**
1446
1447
  * ${data.themeName} Theme Layout
@@ -1474,13 +1475,13 @@ function generateThemeIndex(data) {
1474
1475
  * ${data.themeNamePascal} Theme
1475
1476
  */
1476
1477
 
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";
1478
+ export { manifest as ${data.themeNamePascal}Manifest } from "./manifest";
1479
+ export { themeConfig as ${data.themeNamePascal}Config } from "./config";
1480
+ export { themeLayout as ${data.themeNamePascal}Layout } from "./layout";
1480
1481
  `;
1481
1482
  }
1482
1483
  function generateHomePage(data) {
1483
- return `import type { PageConfig } from "@duongthiu/onex-core";
1484
+ return `import type { PageConfig } from "@onexapis/core";
1484
1485
 
1485
1486
  /**
1486
1487
  * Home Page Configuration
@@ -1631,7 +1632,7 @@ async function createSectionCommand(name, options) {
1631
1632
  }
1632
1633
  }
1633
1634
  function generateSectionSchema(data) {
1634
- return `import type { SectionSchema } from "@duongthiu/onex-core";
1635
+ return `import type { SectionSchema } from "@onexapis/core";
1635
1636
 
1636
1637
  /**
1637
1638
  * ${data.displayName} Section Schema
@@ -1693,7 +1694,7 @@ export const ${data.sectionName}Schema: SectionSchema = {
1693
1694
  }
1694
1695
  function generateSectionTemplate(data) {
1695
1696
  return `import React from "react";
1696
- import type { SectionComponentProps } from "@duongthiu/onex-core";
1697
+ import type { SectionComponentProps } from "@onexapis/core";
1697
1698
 
1698
1699
  /**
1699
1700
  * ${data.displayName} - Default Template
@@ -1877,7 +1878,7 @@ async function createBlockCommand(name, options) {
1877
1878
  }
1878
1879
  }
1879
1880
  function generateBlockSchema(data) {
1880
- return `import type { BlockDefinition } from "@duongthiu/onex-core";
1881
+ return `import type { BlockDefinition } from "@onexapis/core";
1881
1882
 
1882
1883
  /**
1883
1884
  * ${data.displayName} Block Schema
@@ -1926,7 +1927,7 @@ export const ${data.blockName}Definition: BlockDefinition = {
1926
1927
  }
1927
1928
  function generateBlockComponent(data) {
1928
1929
  return `import React from "react";
1929
- import type { BlockComponentProps } from "@duongthiu/onex-core";
1930
+ import type { BlockComponentProps } from "@onexapis/core";
1930
1931
 
1931
1932
  /**
1932
1933
  * ${data.displayName} Block Component
@@ -2079,7 +2080,7 @@ async function createComponentCommand(name, options) {
2079
2080
  }
2080
2081
  }
2081
2082
  function generateComponentSchema(data) {
2082
- return `import type { ComponentDefinition } from "@duongthiu/onex-core";
2083
+ return `import type { ComponentDefinition } from "@onexapis/core";
2083
2084
 
2084
2085
  /**
2085
2086
  * ${data.displayName} Component Schema
@@ -2143,7 +2144,7 @@ export const ${data.componentName}Definition: ComponentDefinition = {
2143
2144
  }
2144
2145
  function generateComponent(data) {
2145
2146
  return `import React from "react";
2146
- import type { ComponentProps } from "@duongthiu/onex-core";
2147
+ import type { ComponentProps } from "@onexapis/core";
2147
2148
 
2148
2149
  /**
2149
2150
  * ${data.displayName} Component
@@ -2317,9 +2318,9 @@ async function listThemesInfo() {
2317
2318
  const versionMatch = manifestContent.match(/version:\s*["'](.+)["']/);
2318
2319
  const descMatch = manifestContent.match(/description:\s*["'](.+)["']/);
2319
2320
  const displayName = nameMatch ? nameMatch[1] : theme;
2320
- const version = versionMatch ? versionMatch[1] : "unknown";
2321
+ const version2 = versionMatch ? versionMatch[1] : "unknown";
2321
2322
  const description = descMatch ? descMatch[1] : "";
2322
- logger.log(chalk4__default.default.cyan(` ${displayName}`) + chalk4__default.default.gray(` (v${version})`));
2323
+ logger.log(chalk4__default.default.cyan(` ${displayName}`) + chalk4__default.default.gray(` (v${version2})`));
2323
2324
  if (description) {
2324
2325
  logger.log(chalk4__default.default.gray(` ${description}`));
2325
2326
  }
@@ -2667,14 +2668,14 @@ async function packageCommand(options) {
2667
2668
  }
2668
2669
  }
2669
2670
  const packageJsonPath = path8__default.default.join(themePath, "package.json");
2670
- let version = "1.0.0";
2671
+ let version2 = "1.0.0";
2671
2672
  if (fs__default.default.existsSync(packageJsonPath)) {
2672
2673
  const packageJson = await fs__default.default.readJson(packageJsonPath);
2673
- version = packageJson.version || "1.0.0";
2674
+ version2 = packageJson.version || "1.0.0";
2674
2675
  }
2675
2676
  logger.newLine();
2676
2677
  logger.info(`Theme: ${themeName}`);
2677
- logger.info(`Version: ${version}`);
2678
+ logger.info(`Version: ${version2}`);
2678
2679
  logger.newLine();
2679
2680
  const compiledThemePath = path8__default.default.join(
2680
2681
  process.cwd(),
@@ -2709,7 +2710,7 @@ async function packageCommand(options) {
2709
2710
  }
2710
2711
  logger.newLine();
2711
2712
  logger.section("Step 2: Create Package");
2712
- const packageName = options.name || `${themeName}-${version}`;
2713
+ const packageName = options.name || `${themeName}-${version2}`;
2713
2714
  const outputDir = options.output || path8__default.default.join(process.cwd(), "dist");
2714
2715
  const outputPath = path8__default.default.join(outputDir, `${packageName}.zip`);
2715
2716
  await fs__default.default.ensureDir(outputDir);
@@ -2924,7 +2925,7 @@ function getBucketName(env) {
2924
2925
  const environment = env || process.env.ENVIRONMENT || "staging";
2925
2926
  return environment === "production" ? "onex-themes-prod" : "onex-themes-staging";
2926
2927
  }
2927
- async function findCompiledThemeDir(themeId, version) {
2928
+ async function findCompiledThemeDir(themeId, version2) {
2928
2929
  const searchPaths = [path8__default.default.resolve(process.cwd(), "dist")];
2929
2930
  for (const dir of searchPaths) {
2930
2931
  if (await fs__default.default.pathExists(dir)) {
@@ -2994,9 +2995,9 @@ async function findSourceDir(themeId, explicitDir) {
2994
2995
  }
2995
2996
  return null;
2996
2997
  }
2997
- async function updateLatestPointer(s3Client, bucket, themeId, version) {
2998
+ async function updateLatestPointer(s3Client, bucket, themeId, version2) {
2998
2999
  const latestData = {
2999
- version,
3000
+ version: version2,
3000
3001
  uploadedAt: (/* @__PURE__ */ new Date()).toISOString()
3001
3002
  };
3002
3003
  await s3Client.send(
@@ -3013,23 +3014,23 @@ async function uploadCommand(options) {
3013
3014
  const spinner = ora__default.default("Preparing theme upload...").start();
3014
3015
  try {
3015
3016
  let themeId;
3016
- let version;
3017
+ let version2;
3017
3018
  if (options.theme) {
3018
3019
  themeId = options.theme;
3019
- version = options.version || "1.0.0";
3020
+ version2 = options.version || "1.0.0";
3020
3021
  } else {
3021
3022
  const manifest = await readManifest();
3022
3023
  themeId = manifest.themeId;
3023
- version = options.version || manifest.version || "1.0.0";
3024
+ version2 = options.version || manifest.version || "1.0.0";
3024
3025
  }
3025
- spinner.text = `Found theme: ${themeId}@${version}`;
3026
+ spinner.text = `Found theme: ${themeId}@${version2}`;
3026
3027
  const bucket = options.bucket || getBucketName(options.environment);
3027
3028
  const s3Client = getS3Client();
3028
- const compiledDir = await findCompiledThemeDir(themeId, version);
3029
+ const compiledDir = await findCompiledThemeDir(themeId, version2);
3029
3030
  if (!compiledDir) {
3030
3031
  spinner.fail(
3031
3032
  chalk4__default.default.red(
3032
- `Compiled theme not found for ${themeId}@${version}. Run 'onex build' first.`
3033
+ `Compiled theme not found for ${themeId}@${version2}. Run 'onex build' first.`
3033
3034
  )
3034
3035
  );
3035
3036
  logger.info(chalk4__default.default.gray(`Expected location:
@@ -3039,7 +3040,7 @@ async function uploadCommand(options) {
3039
3040
  spinner.succeed(`Found compiled theme at: ${compiledDir}`);
3040
3041
  spinner.start("Creating bundle.zip...");
3041
3042
  const tmpDir = os__default.default.tmpdir();
3042
- const bundleZipPath = path8__default.default.join(tmpDir, `${themeId}-${version}-bundle.zip`);
3043
+ const bundleZipPath = path8__default.default.join(tmpDir, `${themeId}-${version2}-bundle.zip`);
3043
3044
  await createZipFromDir(compiledDir, bundleZipPath);
3044
3045
  const bundleZipBuffer = await fs__default.default.readFile(bundleZipPath);
3045
3046
  const bundleSizeMB = (bundleZipBuffer.length / 1024 / 1024).toFixed(2);
@@ -3050,7 +3051,7 @@ async function uploadCommand(options) {
3050
3051
  console.log(chalk4__default.default.gray(` bundle.zip: ${bundleSizeMB} MB`));
3051
3052
  console.log(
3052
3053
  chalk4__default.default.cyan(
3053
- ` S3 path: s3://${bucket}/themes/${themeId}/${version}/bundle.zip`
3054
+ ` S3 path: s3://${bucket}/themes/${themeId}/${version2}/bundle.zip`
3054
3055
  )
3055
3056
  );
3056
3057
  if (!options.skipSource) {
@@ -3059,7 +3060,7 @@ async function uploadCommand(options) {
3059
3060
  console.log(chalk4__default.default.gray(` source dir: ${sourceDir}`));
3060
3061
  console.log(
3061
3062
  chalk4__default.default.cyan(
3062
- ` S3 path: s3://${bucket}/themes/${themeId}/${version}/source.zip`
3063
+ ` S3 path: s3://${bucket}/themes/${themeId}/${version2}/source.zip`
3063
3064
  )
3064
3065
  );
3065
3066
  } else {
@@ -3073,7 +3074,7 @@ async function uploadCommand(options) {
3073
3074
  return;
3074
3075
  }
3075
3076
  spinner.start("Uploading bundle.zip to S3...");
3076
- const bundleS3Key = `themes/${themeId}/${version}/bundle.zip`;
3077
+ const bundleS3Key = `themes/${themeId}/${version2}/bundle.zip`;
3077
3078
  await s3Client.send(
3078
3079
  new clientS3.PutObjectCommand({
3079
3080
  Bucket: bucket,
@@ -3095,7 +3096,7 @@ async function uploadCommand(options) {
3095
3096
  spinner.start("Creating source.zip...");
3096
3097
  const sourceZipPath = path8__default.default.join(
3097
3098
  tmpDir,
3098
- `${themeId}-${version}-source.zip`
3099
+ `${themeId}-${version2}-source.zip`
3099
3100
  );
3100
3101
  await createZipFromDir(sourceDir, sourceZipPath, [
3101
3102
  "node_modules/**",
@@ -3109,7 +3110,7 @@ async function uploadCommand(options) {
3109
3110
  const sourceSizeMB = (sourceZipBuffer.length / 1024 / 1024).toFixed(2);
3110
3111
  spinner.succeed(`Created source.zip (${sourceSizeMB} MB)`);
3111
3112
  spinner.start("Uploading source.zip to S3...");
3112
- const sourceS3Key = `themes/${themeId}/${version}/source.zip`;
3113
+ const sourceS3Key = `themes/${themeId}/${version2}/source.zip`;
3113
3114
  await s3Client.send(
3114
3115
  new clientS3.PutObjectCommand({
3115
3116
  Bucket: bucket,
@@ -3130,20 +3131,20 @@ async function uploadCommand(options) {
3130
3131
  }
3131
3132
  }
3132
3133
  spinner.start("Updating latest.json pointer...");
3133
- await updateLatestPointer(s3Client, bucket, themeId, version);
3134
+ await updateLatestPointer(s3Client, bucket, themeId, version2);
3134
3135
  spinner.succeed("Updated latest.json pointer");
3135
3136
  console.log();
3136
3137
  logger.success(chalk4__default.default.green.bold("Theme uploaded successfully!"));
3137
3138
  console.log();
3138
3139
  console.log(
3139
- chalk4__default.default.cyan(" Theme: ") + chalk4__default.default.white(`${themeId}@${version}`)
3140
+ chalk4__default.default.cyan(" Theme: ") + chalk4__default.default.white(`${themeId}@${version2}`)
3140
3141
  );
3141
3142
  console.log(chalk4__default.default.cyan(" Bucket: ") + chalk4__default.default.white(bucket));
3142
3143
  console.log(
3143
3144
  chalk4__default.default.cyan(" Files: ") + chalk4__default.default.white(`bundle.zip${sourceUploaded ? " + source.zip" : ""}`)
3144
3145
  );
3145
3146
  console.log(
3146
- chalk4__default.default.cyan(" Path: ") + chalk4__default.default.gray(`s3://${bucket}/themes/${themeId}/${version}/`)
3147
+ chalk4__default.default.cyan(" Path: ") + chalk4__default.default.gray(`s3://${bucket}/themes/${themeId}/${version2}/`)
3147
3148
  );
3148
3149
  console.log();
3149
3150
  } catch (error) {
@@ -3285,7 +3286,7 @@ async function downloadCommand(options) {
3285
3286
  const spinner = ora__default.default("Initializing download...").start();
3286
3287
  try {
3287
3288
  const themeId = options.themeId || process.env.NEXT_PUBLIC_THEME_ID || process.env.THEME_ID;
3288
- const version = options.version || process.env.THEME_VERSION || "latest";
3289
+ const version2 = options.version || process.env.THEME_VERSION || "latest";
3289
3290
  const bucket = options.bucket || getBucketName2(options.environment);
3290
3291
  const outputDir = options.output || "./active-theme";
3291
3292
  if (!themeId) {
@@ -3296,10 +3297,10 @@ async function downloadCommand(options) {
3296
3297
  );
3297
3298
  process.exit(1);
3298
3299
  }
3299
- spinner.text = `Downloading ${themeId}@${version} from ${bucket}...`;
3300
+ spinner.text = `Downloading ${themeId}@${version2} from ${bucket}...`;
3300
3301
  const s3Client = getS3Client2();
3301
- let resolvedVersion = version;
3302
- if (version === "latest") {
3302
+ let resolvedVersion = version2;
3303
+ if (version2 === "latest") {
3303
3304
  spinner.text = "Resolving latest version...";
3304
3305
  resolvedVersion = await resolveLatestVersion(s3Client, bucket, themeId);
3305
3306
  spinner.succeed(
@@ -3539,14 +3540,14 @@ async function cloneCommand(themeName, options) {
3539
3540
  );
3540
3541
  process.exit(1);
3541
3542
  }
3542
- let version = options.version || "latest";
3543
- if (version === "latest") {
3543
+ let version2 = options.version || "latest";
3544
+ if (version2 === "latest") {
3544
3545
  spinner.text = "Resolving latest version...";
3545
- version = await resolveLatestVersion2(s3Client, bucket, themeName);
3546
- spinner.succeed(`Resolved latest version: ${chalk4__default.default.cyan(version)}`);
3546
+ version2 = await resolveLatestVersion2(s3Client, bucket, themeName);
3547
+ spinner.succeed(`Resolved latest version: ${chalk4__default.default.cyan(version2)}`);
3547
3548
  }
3548
- spinner.start(`Downloading source.zip for ${themeName}@${version}...`);
3549
- const s3Key = `themes/${themeName}/${version}/source.zip`;
3549
+ spinner.start(`Downloading source.zip for ${themeName}@${version2}...`);
3550
+ const s3Key = `themes/${themeName}/${version2}/source.zip`;
3550
3551
  let zipBuffer;
3551
3552
  try {
3552
3553
  const response = await s3Client.send(
@@ -3618,7 +3619,7 @@ async function cloneCommand(themeName, options) {
3618
3619
  logger.success(chalk4__default.default.green.bold("Theme cloned successfully!"));
3619
3620
  console.log();
3620
3621
  console.log(
3621
- chalk4__default.default.cyan(" Source: ") + chalk4__default.default.gray(`${themeName}@${version}`)
3622
+ chalk4__default.default.cyan(" Source: ") + chalk4__default.default.gray(`${themeName}@${version2}`)
3622
3623
  );
3623
3624
  console.log(chalk4__default.default.cyan(" Theme: ") + chalk4__default.default.white(newName));
3624
3625
  console.log(chalk4__default.default.cyan(" Location: ") + chalk4__default.default.white(outputDir));
@@ -3626,7 +3627,9 @@ async function cloneCommand(themeName, options) {
3626
3627
  console.log();
3627
3628
  console.log(chalk4__default.default.cyan("Next steps:"));
3628
3629
  console.log(chalk4__default.default.gray(` cd ${path8__default.default.relative(process.cwd(), outputDir)}`));
3629
- console.log(chalk4__default.default.gray(" cp .env.example .env # then add your Company ID"));
3630
+ console.log(
3631
+ chalk4__default.default.gray(" cp .env.example .env # then add your Company ID")
3632
+ );
3630
3633
  if (options.install === false) {
3631
3634
  console.log(chalk4__default.default.gray(" pnpm install"));
3632
3635
  }
@@ -3891,8 +3894,10 @@ dotenv__default.default.config({
3891
3894
  path: path8__default.default.join(os__default.default.homedir(), ".onex", ".env"),
3892
3895
  quiet: true
3893
3896
  });
3897
+ 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)));
3898
+ var { version } = require2("../package.json");
3894
3899
  var program = new commander.Command();
3895
- program.name("onex").description("CLI tool for OneX theme development").version("0.1.0");
3900
+ program.name("onex").description("CLI tool for OneX theme development").version(version);
3896
3901
  program.command("init").description("Create a new OneX theme project").argument("[project-name]", "Name of the project").option(
3897
3902
  "-t, --template <template>",
3898
3903
  "Template to use (default, minimal)",