e2sm 0.2.1 → 0.3.0
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/index.mjs +79 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3013,7 +3013,7 @@ BUILT_IN_PREFIX.codePointAt(0);
|
|
|
3013
3013
|
|
|
3014
3014
|
//#endregion
|
|
3015
3015
|
//#region package.json
|
|
3016
|
-
var version = "0.
|
|
3016
|
+
var version = "0.3.0";
|
|
3017
3017
|
|
|
3018
3018
|
//#endregion
|
|
3019
3019
|
//#region src/lib.ts
|
|
@@ -3041,6 +3041,25 @@ function validateUnknownFlags(tokens, args) {
|
|
|
3041
3041
|
}
|
|
3042
3042
|
return null;
|
|
3043
3043
|
}
|
|
3044
|
+
/**
|
|
3045
|
+
* Determines if template mode is active.
|
|
3046
|
+
*/
|
|
3047
|
+
function isTemplateMode(flags) {
|
|
3048
|
+
return Boolean(flags.template || flags.application || flags.stage);
|
|
3049
|
+
}
|
|
3050
|
+
/**
|
|
3051
|
+
* Validates that --name flag is not used with template mode flags.
|
|
3052
|
+
*/
|
|
3053
|
+
function validateNameTemplateConflict(flags) {
|
|
3054
|
+
if (flags.name && isTemplateMode(flags)) {
|
|
3055
|
+
const conflicting = [];
|
|
3056
|
+
if (flags.template) conflicting.push("--template");
|
|
3057
|
+
if (flags.application) conflicting.push("--application");
|
|
3058
|
+
if (flags.stage) conflicting.push("--stage");
|
|
3059
|
+
return `Cannot use --name with ${conflicting.join(", ")}`;
|
|
3060
|
+
}
|
|
3061
|
+
return null;
|
|
3062
|
+
}
|
|
3044
3063
|
function parseEnvContent(content) {
|
|
3045
3064
|
const result = {};
|
|
3046
3065
|
for (const line of content.split("\n")) {
|
|
@@ -3121,6 +3140,21 @@ const command = define({
|
|
|
3121
3140
|
type: "string",
|
|
3122
3141
|
short: "r",
|
|
3123
3142
|
description: "AWS region to use (e.g., ap-northeast-1)"
|
|
3143
|
+
},
|
|
3144
|
+
template: {
|
|
3145
|
+
type: "boolean",
|
|
3146
|
+
short: "t",
|
|
3147
|
+
description: "Use template mode: generate secret name as $application/$stage"
|
|
3148
|
+
},
|
|
3149
|
+
application: {
|
|
3150
|
+
type: "string",
|
|
3151
|
+
short: "a",
|
|
3152
|
+
description: "Application name for template mode (implies --template)"
|
|
3153
|
+
},
|
|
3154
|
+
stage: {
|
|
3155
|
+
type: "string",
|
|
3156
|
+
short: "s",
|
|
3157
|
+
description: "Stage name for template mode (implies --template)"
|
|
3124
3158
|
}
|
|
3125
3159
|
},
|
|
3126
3160
|
run: async (ctx) => {
|
|
@@ -3129,6 +3163,11 @@ const command = define({
|
|
|
3129
3163
|
console.error(unknownFlagError);
|
|
3130
3164
|
process.exit(1);
|
|
3131
3165
|
}
|
|
3166
|
+
const conflictError = validateNameTemplateConflict(ctx.values);
|
|
3167
|
+
if (conflictError) {
|
|
3168
|
+
console.error(conflictError);
|
|
3169
|
+
process.exit(1);
|
|
3170
|
+
}
|
|
3132
3171
|
const isDryRun = ctx.values.dryRun;
|
|
3133
3172
|
const profile = ctx.values.profile;
|
|
3134
3173
|
const inputFlag = ctx.values.input;
|
|
@@ -3169,8 +3208,46 @@ const command = define({
|
|
|
3169
3208
|
return;
|
|
3170
3209
|
}
|
|
3171
3210
|
let secretName;
|
|
3211
|
+
const templateFlag = ctx.values.template;
|
|
3212
|
+
const applicationFlag = ctx.values.application;
|
|
3213
|
+
const stageFlag = ctx.values.stage;
|
|
3214
|
+
const useTemplateMode = isTemplateMode({
|
|
3215
|
+
template: templateFlag,
|
|
3216
|
+
application: applicationFlag,
|
|
3217
|
+
stage: stageFlag
|
|
3218
|
+
});
|
|
3172
3219
|
if (nameFlag) secretName = nameFlag;
|
|
3173
|
-
else {
|
|
3220
|
+
else if (useTemplateMode) {
|
|
3221
|
+
let application;
|
|
3222
|
+
let stage;
|
|
3223
|
+
if (applicationFlag) application = applicationFlag;
|
|
3224
|
+
else {
|
|
3225
|
+
const result = await he({
|
|
3226
|
+
message: "Enter the application name:",
|
|
3227
|
+
placeholder: "my-app",
|
|
3228
|
+
defaultValue: "my-app"
|
|
3229
|
+
});
|
|
3230
|
+
if (isCancel(result)) {
|
|
3231
|
+
xe("Operation cancelled");
|
|
3232
|
+
process.exit(0);
|
|
3233
|
+
}
|
|
3234
|
+
application = result;
|
|
3235
|
+
}
|
|
3236
|
+
if (stageFlag) stage = stageFlag;
|
|
3237
|
+
else {
|
|
3238
|
+
const result = await he({
|
|
3239
|
+
message: "Enter the stage name:",
|
|
3240
|
+
placeholder: "dev",
|
|
3241
|
+
defaultValue: "dev"
|
|
3242
|
+
});
|
|
3243
|
+
if (isCancel(result)) {
|
|
3244
|
+
xe("Operation cancelled");
|
|
3245
|
+
process.exit(0);
|
|
3246
|
+
}
|
|
3247
|
+
stage = result;
|
|
3248
|
+
}
|
|
3249
|
+
secretName = `${application}/${stage}`;
|
|
3250
|
+
} else {
|
|
3174
3251
|
const result = await he({
|
|
3175
3252
|
message: "Enter the secret name for AWS Secrets Manager:",
|
|
3176
3253
|
placeholder: "my-app/default",
|