@onexapis/cli 1.1.8 → 1.1.10
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/README.md +58 -45
- package/dist/cli.js +146 -2
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +146 -2
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -3396,8 +3396,8 @@ function runInstall(cwd) {
|
|
|
3396
3396
|
});
|
|
3397
3397
|
}
|
|
3398
3398
|
async function promptThemeName(originalName) {
|
|
3399
|
-
const { default:
|
|
3400
|
-
const { themeName } = await
|
|
3399
|
+
const { default: inquirer6 } = await import('inquirer');
|
|
3400
|
+
const { themeName } = await inquirer6.prompt([
|
|
3401
3401
|
{
|
|
3402
3402
|
type: "input",
|
|
3403
3403
|
name: "themeName",
|
|
@@ -3839,6 +3839,149 @@ async function devCommand(options) {
|
|
|
3839
3839
|
});
|
|
3840
3840
|
}
|
|
3841
3841
|
|
|
3842
|
+
// src/commands/config.ts
|
|
3843
|
+
init_logger();
|
|
3844
|
+
var CONFIG_DIR = path8.join(os.homedir(), ".onex");
|
|
3845
|
+
var CONFIG_FILE = path8.join(CONFIG_DIR, ".env");
|
|
3846
|
+
var CONFIG_ENTRIES = [
|
|
3847
|
+
{
|
|
3848
|
+
key: "AWS_ACCESS_KEY_ID",
|
|
3849
|
+
label: "AWS Access Key ID",
|
|
3850
|
+
required: true
|
|
3851
|
+
},
|
|
3852
|
+
{
|
|
3853
|
+
key: "AWS_SECRET_ACCESS_KEY",
|
|
3854
|
+
label: "AWS Secret Access Key",
|
|
3855
|
+
required: true,
|
|
3856
|
+
secret: true
|
|
3857
|
+
},
|
|
3858
|
+
{
|
|
3859
|
+
key: "AWS_REGION",
|
|
3860
|
+
label: "AWS Region",
|
|
3861
|
+
required: false,
|
|
3862
|
+
defaultValue: "ap-southeast-1"
|
|
3863
|
+
},
|
|
3864
|
+
{
|
|
3865
|
+
key: "BUCKET_NAME",
|
|
3866
|
+
label: "S3 Bucket Name",
|
|
3867
|
+
required: false,
|
|
3868
|
+
defaultValue: "theme-s3-bucket"
|
|
3869
|
+
},
|
|
3870
|
+
{
|
|
3871
|
+
key: "NEXT_PUBLIC_API_URL",
|
|
3872
|
+
label: "API URL",
|
|
3873
|
+
required: false,
|
|
3874
|
+
defaultValue: "https://api-dev.onexeos.com"
|
|
3875
|
+
},
|
|
3876
|
+
{
|
|
3877
|
+
key: "NEXT_PUBLIC_COMPANY_ID",
|
|
3878
|
+
label: "Company ID",
|
|
3879
|
+
required: false
|
|
3880
|
+
}
|
|
3881
|
+
];
|
|
3882
|
+
function parseEnvFile(content) {
|
|
3883
|
+
const result = {};
|
|
3884
|
+
for (const line of content.split("\n")) {
|
|
3885
|
+
const trimmed = line.trim();
|
|
3886
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
3887
|
+
const eqIndex = trimmed.indexOf("=");
|
|
3888
|
+
if (eqIndex === -1) continue;
|
|
3889
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
3890
|
+
const value = trimmed.slice(eqIndex + 1).trim();
|
|
3891
|
+
result[key] = value;
|
|
3892
|
+
}
|
|
3893
|
+
return result;
|
|
3894
|
+
}
|
|
3895
|
+
function serializeEnv(values) {
|
|
3896
|
+
const lines = [
|
|
3897
|
+
"# OneX CLI Configuration",
|
|
3898
|
+
"# Generated by: onex config",
|
|
3899
|
+
""
|
|
3900
|
+
];
|
|
3901
|
+
lines.push("# AWS / S3 Configuration");
|
|
3902
|
+
for (const key of [
|
|
3903
|
+
"AWS_ACCESS_KEY_ID",
|
|
3904
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
3905
|
+
"AWS_REGION",
|
|
3906
|
+
"BUCKET_NAME"
|
|
3907
|
+
]) {
|
|
3908
|
+
if (values[key]) lines.push(`${key}=${values[key]}`);
|
|
3909
|
+
}
|
|
3910
|
+
lines.push("");
|
|
3911
|
+
lines.push("# API Configuration");
|
|
3912
|
+
for (const key of ["NEXT_PUBLIC_API_URL", "NEXT_PUBLIC_COMPANY_ID"]) {
|
|
3913
|
+
if (values[key]) lines.push(`${key}=${values[key]}`);
|
|
3914
|
+
}
|
|
3915
|
+
const knownKeys = new Set(CONFIG_ENTRIES.map((e) => e.key));
|
|
3916
|
+
const extraKeys = Object.keys(values).filter((k) => !knownKeys.has(k));
|
|
3917
|
+
if (extraKeys.length > 0) {
|
|
3918
|
+
lines.push("");
|
|
3919
|
+
lines.push("# Other");
|
|
3920
|
+
for (const key of extraKeys) {
|
|
3921
|
+
lines.push(`${key}=${values[key]}`);
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
lines.push("");
|
|
3925
|
+
return lines.join("\n");
|
|
3926
|
+
}
|
|
3927
|
+
async function configCommand() {
|
|
3928
|
+
logger.header("OneX CLI Configuration");
|
|
3929
|
+
let existing = {};
|
|
3930
|
+
try {
|
|
3931
|
+
const content = await fs.readFile(CONFIG_FILE, "utf-8");
|
|
3932
|
+
existing = parseEnvFile(content);
|
|
3933
|
+
logger.info(`Existing config found at: ${CONFIG_FILE}`);
|
|
3934
|
+
logger.newLine();
|
|
3935
|
+
} catch {
|
|
3936
|
+
logger.info("No existing config found. Let's set one up.");
|
|
3937
|
+
logger.newLine();
|
|
3938
|
+
}
|
|
3939
|
+
const answers = {};
|
|
3940
|
+
for (const entry of CONFIG_ENTRIES) {
|
|
3941
|
+
const currentValue = existing[entry.key] || "";
|
|
3942
|
+
const defaultVal = currentValue || entry.defaultValue || "";
|
|
3943
|
+
const displayDefault = entry.secret && currentValue ? currentValue.slice(0, 4) + "****" + currentValue.slice(-4) : defaultVal;
|
|
3944
|
+
const { value } = await inquirer.prompt([
|
|
3945
|
+
{
|
|
3946
|
+
type: entry.secret ? "password" : "input",
|
|
3947
|
+
name: "value",
|
|
3948
|
+
message: `${entry.label}${entry.required ? " (required)" : ""}:`,
|
|
3949
|
+
default: entry.secret ? void 0 : defaultVal,
|
|
3950
|
+
...entry.secret && currentValue ? {
|
|
3951
|
+
suffix: ` (current: ${displayDefault}, press Enter to keep)`
|
|
3952
|
+
} : {},
|
|
3953
|
+
validate: (input) => {
|
|
3954
|
+
if (entry.required && !input && !currentValue) {
|
|
3955
|
+
return `${entry.label} is required`;
|
|
3956
|
+
}
|
|
3957
|
+
return true;
|
|
3958
|
+
}
|
|
3959
|
+
}
|
|
3960
|
+
]);
|
|
3961
|
+
answers[entry.key] = value || currentValue;
|
|
3962
|
+
}
|
|
3963
|
+
const merged = { ...existing, ...answers };
|
|
3964
|
+
for (const key of Object.keys(merged)) {
|
|
3965
|
+
if (!merged[key]) delete merged[key];
|
|
3966
|
+
}
|
|
3967
|
+
await fs.ensureDir(CONFIG_DIR);
|
|
3968
|
+
await fs.writeFile(CONFIG_FILE, serializeEnv(merged));
|
|
3969
|
+
logger.newLine();
|
|
3970
|
+
logger.success(`Config saved to: ${CONFIG_FILE}`);
|
|
3971
|
+
logger.newLine();
|
|
3972
|
+
logger.section("Configured values:");
|
|
3973
|
+
for (const entry of CONFIG_ENTRIES) {
|
|
3974
|
+
const val = merged[entry.key];
|
|
3975
|
+
if (!val) continue;
|
|
3976
|
+
const display = entry.secret ? val.slice(0, 4) + "****" + val.slice(-4) : val;
|
|
3977
|
+
logger.log(` ${entry.label}: ${display}`);
|
|
3978
|
+
}
|
|
3979
|
+
logger.newLine();
|
|
3980
|
+
logger.info(
|
|
3981
|
+
"These credentials are stored globally and used by clone, upload, and download commands."
|
|
3982
|
+
);
|
|
3983
|
+
}
|
|
3984
|
+
|
|
3842
3985
|
// src/cli.ts
|
|
3843
3986
|
try {
|
|
3844
3987
|
const projectRoot = getProjectRoot();
|
|
@@ -3906,6 +4049,7 @@ program.command("clone").description("Clone theme source code from S3").argument
|
|
|
3906
4049
|
"Environment (staging|production)",
|
|
3907
4050
|
"staging"
|
|
3908
4051
|
).option("--no-install", "Skip running pnpm install after clone").action(cloneCommand);
|
|
4052
|
+
program.command("config").description("Configure OneX CLI credentials (AWS, API keys)").action(configCommand);
|
|
3909
4053
|
program.configureOutput({
|
|
3910
4054
|
writeErr: (str) => process.stderr.write(chalk4.red(str))
|
|
3911
4055
|
});
|