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