@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.js +47 -44
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +47 -44
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/default/esbuild.config.js +3 -3
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
|
|
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
|
-
|
|
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",
|
|
@@ -1305,10 +1306,10 @@ export const manifest: ThemeExport = {
|
|
|
1305
1306
|
author: "${data.author}",
|
|
1306
1307
|
|
|
1307
1308
|
// Theme configuration
|
|
1308
|
-
config: () => import("./
|
|
1309
|
+
config: () => import("./config").then((m) => m.themeConfig),
|
|
1309
1310
|
|
|
1310
1311
|
// Theme layout (header/footer sections)
|
|
1311
|
-
layout: () => import("./
|
|
1312
|
+
layout: () => import("./layout").then((m) => m.themeLayout),
|
|
1312
1313
|
|
|
1313
1314
|
// Available sections in this theme
|
|
1314
1315
|
sections: {
|
|
@@ -1474,9 +1475,9 @@ function generateThemeIndex(data) {
|
|
|
1474
1475
|
* ${data.themeNamePascal} Theme
|
|
1475
1476
|
*/
|
|
1476
1477
|
|
|
1477
|
-
export { manifest as ${data.
|
|
1478
|
-
export { themeConfig as ${data.
|
|
1479
|
-
export { themeLayout as ${data.
|
|
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) {
|
|
@@ -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
|
|
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${
|
|
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
|
|
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
|
-
|
|
2674
|
+
version2 = packageJson.version || "1.0.0";
|
|
2674
2675
|
}
|
|
2675
2676
|
logger.newLine();
|
|
2676
2677
|
logger.info(`Theme: ${themeName}`);
|
|
2677
|
-
logger.info(`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}-${
|
|
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,
|
|
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,
|
|
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
|
|
3017
|
+
let version2;
|
|
3017
3018
|
if (options.theme) {
|
|
3018
3019
|
themeId = options.theme;
|
|
3019
|
-
|
|
3020
|
+
version2 = options.version || "1.0.0";
|
|
3020
3021
|
} else {
|
|
3021
3022
|
const manifest = await readManifest();
|
|
3022
3023
|
themeId = manifest.themeId;
|
|
3023
|
-
|
|
3024
|
+
version2 = options.version || manifest.version || "1.0.0";
|
|
3024
3025
|
}
|
|
3025
|
-
spinner.text = `Found theme: ${themeId}@${
|
|
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,
|
|
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}@${
|
|
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}-${
|
|
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}/${
|
|
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}/${
|
|
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}/${
|
|
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}-${
|
|
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}/${
|
|
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,
|
|
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}@${
|
|
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}/${
|
|
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
|
|
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}@${
|
|
3300
|
+
spinner.text = `Downloading ${themeId}@${version2} from ${bucket}...`;
|
|
3300
3301
|
const s3Client = getS3Client2();
|
|
3301
|
-
let resolvedVersion =
|
|
3302
|
-
if (
|
|
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
|
|
3543
|
-
if (
|
|
3543
|
+
let version2 = options.version || "latest";
|
|
3544
|
+
if (version2 === "latest") {
|
|
3544
3545
|
spinner.text = "Resolving latest version...";
|
|
3545
|
-
|
|
3546
|
-
spinner.succeed(`Resolved latest version: ${chalk4__default.default.cyan(
|
|
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}@${
|
|
3549
|
-
const s3Key = `themes/${themeName}/${
|
|
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}@${
|
|
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));
|
|
@@ -3893,8 +3894,10 @@ dotenv__default.default.config({
|
|
|
3893
3894
|
path: path8__default.default.join(os__default.default.homedir(), ".onex", ".env"),
|
|
3894
3895
|
quiet: true
|
|
3895
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");
|
|
3896
3899
|
var program = new commander.Command();
|
|
3897
|
-
program.name("onex").description("CLI tool for OneX theme development").version(
|
|
3900
|
+
program.name("onex").description("CLI tool for OneX theme development").version(version);
|
|
3898
3901
|
program.command("init").description("Create a new OneX theme project").argument("[project-name]", "Name of the project").option(
|
|
3899
3902
|
"-t, --template <template>",
|
|
3900
3903
|
"Template to use (default, minimal)",
|