@1medium/cli 1.9.1 → 1.10.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/package.json +1 -1
- package/src/api.js +28 -0
- package/src/index.js +117 -1
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -293,6 +293,31 @@ async function resumeScriptEvent(id) {
|
|
|
293
293
|
return request("POST", `/script-events/${id}/resume`);
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
// ============================================================================
|
|
297
|
+
// Script Secret API
|
|
298
|
+
// ============================================================================
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* List script secrets (keys only, no values)
|
|
302
|
+
*/
|
|
303
|
+
async function listSecrets() {
|
|
304
|
+
return request("GET", "/script-secrets");
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Create or upsert a script secret
|
|
309
|
+
*/
|
|
310
|
+
async function createSecret(key, value) {
|
|
311
|
+
return request("POST", "/script-secrets", { key, value });
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Delete a script secret by ID
|
|
316
|
+
*/
|
|
317
|
+
async function deleteSecret(id) {
|
|
318
|
+
return request("DELETE", `/script-secrets/${id}`);
|
|
319
|
+
}
|
|
320
|
+
|
|
296
321
|
module.exports = {
|
|
297
322
|
whoami,
|
|
298
323
|
createTask,
|
|
@@ -322,4 +347,7 @@ module.exports = {
|
|
|
322
347
|
deleteScriptEvent,
|
|
323
348
|
pauseScriptEvent,
|
|
324
349
|
resumeScriptEvent,
|
|
350
|
+
listSecrets,
|
|
351
|
+
createSecret,
|
|
352
|
+
deleteSecret,
|
|
325
353
|
};
|
package/src/index.js
CHANGED
|
@@ -724,7 +724,7 @@ scriptCmd
|
|
|
724
724
|
.command("push <file>")
|
|
725
725
|
.description("Push a script from a local file")
|
|
726
726
|
.option("-n, --name <name>", "Script name (defaults to filename)")
|
|
727
|
-
.option("--trigger <trigger>", "Trigger type: onCreate, onUpdate, onTag, schedule", "
|
|
727
|
+
.option("--trigger <trigger>", "Trigger type: onCreate, onUpdate, onTag, schedule", "onCreate")
|
|
728
728
|
.option("-j, --json", "Output as JSON")
|
|
729
729
|
.action(async (file, options) => {
|
|
730
730
|
try {
|
|
@@ -975,6 +975,122 @@ scriptCmd
|
|
|
975
975
|
}
|
|
976
976
|
});
|
|
977
977
|
|
|
978
|
+
// ============================================================================
|
|
979
|
+
// Secret Commands
|
|
980
|
+
// ============================================================================
|
|
981
|
+
|
|
982
|
+
const secretCmd = program.command("secret").description("Manage script secrets");
|
|
983
|
+
|
|
984
|
+
secretCmd
|
|
985
|
+
.command("set <key> <value>")
|
|
986
|
+
.description("Create or update a script secret")
|
|
987
|
+
.option("-j, --json", "Output as JSON")
|
|
988
|
+
.action(async (key, value, options) => {
|
|
989
|
+
try {
|
|
990
|
+
const data = await api.createSecret(key.toUpperCase(), value);
|
|
991
|
+
const secret = data.secret || data;
|
|
992
|
+
|
|
993
|
+
if (options.json) {
|
|
994
|
+
console.log(JSON.stringify(data, null, 2));
|
|
995
|
+
} else {
|
|
996
|
+
console.log(chalk.green("Secret saved:"));
|
|
997
|
+
console.log(` Key: ${secret.key}`);
|
|
998
|
+
console.log(` ID: ${secret.id}`);
|
|
999
|
+
}
|
|
1000
|
+
} catch (error) {
|
|
1001
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
1002
|
+
process.exit(1);
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
|
|
1006
|
+
secretCmd
|
|
1007
|
+
.command("list")
|
|
1008
|
+
.description("List script secret keys (values are never shown)")
|
|
1009
|
+
.option("-j, --json", "Output as JSON")
|
|
1010
|
+
.action(async (options) => {
|
|
1011
|
+
try {
|
|
1012
|
+
const data = await api.listSecrets();
|
|
1013
|
+
const secrets = data.secrets || data;
|
|
1014
|
+
|
|
1015
|
+
if (options.json) {
|
|
1016
|
+
console.log(JSON.stringify(data, null, 2));
|
|
1017
|
+
} else {
|
|
1018
|
+
console.log(chalk.bold("\nScript Secrets:\n"));
|
|
1019
|
+
if (!secrets.length) {
|
|
1020
|
+
console.log(" No secrets stored.");
|
|
1021
|
+
} else {
|
|
1022
|
+
for (const secret of secrets) {
|
|
1023
|
+
console.log(` ${chalk.cyan(secret.key)}`);
|
|
1024
|
+
console.log(chalk.gray(` ID: ${secret.id} Added: ${new Date(secret.createdAt).toLocaleDateString()}`));
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
console.log("");
|
|
1028
|
+
}
|
|
1029
|
+
} catch (error) {
|
|
1030
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
1031
|
+
process.exit(1);
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
secretCmd
|
|
1036
|
+
.command("delete <key>")
|
|
1037
|
+
.description("Delete a script secret by key name")
|
|
1038
|
+
.option("-j, --json", "Output as JSON")
|
|
1039
|
+
.action(async (key, options) => {
|
|
1040
|
+
try {
|
|
1041
|
+
// Look up secret by key name to get its ID
|
|
1042
|
+
const data = await api.listSecrets();
|
|
1043
|
+
const secrets = data.secrets || data;
|
|
1044
|
+
const match = secrets.find((s) => s.key === key.toUpperCase());
|
|
1045
|
+
|
|
1046
|
+
if (!match) {
|
|
1047
|
+
console.error(chalk.red(`Error: Secret "${key.toUpperCase()}" not found`));
|
|
1048
|
+
process.exit(1);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
const deleteData = await api.deleteSecret(match.id);
|
|
1052
|
+
|
|
1053
|
+
if (options.json) {
|
|
1054
|
+
console.log(JSON.stringify(deleteData, null, 2));
|
|
1055
|
+
} else {
|
|
1056
|
+
console.log(chalk.green(`Secret deleted: ${key.toUpperCase()}`));
|
|
1057
|
+
}
|
|
1058
|
+
} catch (error) {
|
|
1059
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
1060
|
+
process.exit(1);
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
// Alias: `1m secrets` -> `1m secret list`
|
|
1065
|
+
program
|
|
1066
|
+
.command("secrets")
|
|
1067
|
+
.description("List script secrets (alias for 'secret list')")
|
|
1068
|
+
.option("-j, --json", "Output as JSON")
|
|
1069
|
+
.action(async (options) => {
|
|
1070
|
+
try {
|
|
1071
|
+
const data = await api.listSecrets();
|
|
1072
|
+
const secrets = data.secrets || data;
|
|
1073
|
+
|
|
1074
|
+
if (options.json) {
|
|
1075
|
+
console.log(JSON.stringify(data, null, 2));
|
|
1076
|
+
} else {
|
|
1077
|
+
console.log(chalk.bold("\nScript Secrets:\n"));
|
|
1078
|
+
if (!secrets.length) {
|
|
1079
|
+
console.log(" No secrets stored.");
|
|
1080
|
+
} else {
|
|
1081
|
+
for (const secret of secrets) {
|
|
1082
|
+
console.log(` ${chalk.cyan(secret.key)}`);
|
|
1083
|
+
console.log(chalk.gray(` ID: ${secret.id} Added: ${new Date(secret.createdAt).toLocaleDateString()}`));
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
console.log("");
|
|
1087
|
+
}
|
|
1088
|
+
} catch (error) {
|
|
1089
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
1090
|
+
process.exit(1);
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
|
|
978
1094
|
// ============================================================================
|
|
979
1095
|
// Config Commands
|
|
980
1096
|
// ============================================================================
|