@dsmrt/axiom-cli 1.0.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @dsmrt/axiom-cli
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b1a56bc: adding debug logging to the cli and config packages
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [b1a56bc]
12
+ - @dsmrt/axiom-config@1.1.0
13
+
3
14
  ## 1.0.0
4
15
 
5
16
  ### Major Changes
package/dist/bin/axiom.js CHANGED
@@ -28,6 +28,16 @@ var import_yargs = __toESM(require("yargs"));
28
28
 
29
29
  // src/commands/config.ts
30
30
  var import_axiom_config = require("@dsmrt/axiom-config");
31
+
32
+ // src/debug.ts
33
+ var isDebugEnabled = () => process.env.AXIOM_DEBUG === "true" || process.env.AXIOM_DEBUG === "1";
34
+ var debug = (message, ...args) => {
35
+ if (isDebugEnabled()) {
36
+ console.error(`[axiom:cli] ${message}`, ...args);
37
+ }
38
+ };
39
+
40
+ // src/commands/config.ts
31
41
  var Config = class {
32
42
  command = "config";
33
43
  describe = "print the config";
@@ -38,9 +48,13 @@ var Config = class {
38
48
  return args;
39
49
  };
40
50
  handler = async (args) => {
41
- console.log(JSON.stringify(await this.loadConfig(args)));
51
+ debug(`Config command handler called with env: ${args.env}`);
52
+ const config = await this.loadConfig(args);
53
+ debug(`Config loaded successfully, outputting as JSON`);
54
+ console.log(JSON.stringify(config));
42
55
  };
43
56
  loadConfig = async (args) => {
57
+ debug(`Loading config with env: ${args.env}`);
44
58
  return (0, import_axiom_config.loadConfig)(args);
45
59
  };
46
60
  };
@@ -215,7 +229,16 @@ Example:
215
229
  return args;
216
230
  };
217
231
  handler = async (args) => {
232
+ debug(
233
+ `Get command handler called with env: ${args.env}, path: ${args.path}`
234
+ );
218
235
  const config = await (0, import_axiom_config2.loadConfig)({ env: args.env });
236
+ debug(
237
+ `Config loaded successfully, base parameter path: ${config.aws?.baseParameterPath}`
238
+ );
239
+ debug(
240
+ `Creating SSM client with region: ${config.aws.region}, profile: ${config.aws.profile}`
241
+ );
219
242
  const collection = new import_axiom_aws_sdk.ParameterCollection(
220
243
  config.aws?.baseParameterPath,
221
244
  new import_client_ssm.SSMClient({
@@ -228,7 +251,9 @@ Example:
228
251
  })
229
252
  })
230
253
  );
254
+ debug(`Fetching parameters from SSM...`);
231
255
  const params = await collection.get();
256
+ debug(`Retrieved ${params.size} parameters`);
232
257
  params.forEach((parameter) => {
233
258
  console.log(
234
259
  import_chalk.default.gray(
@@ -294,30 +319,50 @@ Example: "/root/myParam" or "service/secret"`
294
319
  });
295
320
  };
296
321
  handler = async (args) => {
322
+ debug(
323
+ `Set command handler called with path: ${args.path}, secure: ${args.secure}, overwrite: ${args.overwrite}, force: ${args.force}`
324
+ );
297
325
  const config = await (0, import_axiom_config3.loadConfig)({ env: args.env });
326
+ debug(
327
+ `Config loaded successfully, base parameter path: ${config.aws?.baseParameterPath}`
328
+ );
329
+ const fullPath = buildPath(config, args.path);
330
+ debug(`Full parameter path: ${fullPath}`);
298
331
  if (args.force !== true) {
332
+ debug(`Prompting user for confirmation...`);
299
333
  const res = await import_inquirer2.default.prompt({
300
334
  type: "confirm",
301
335
  name: "setParam",
302
336
  message: `Are you sure you want to set '${args.path}'?`
303
337
  });
304
338
  if (!res.setParam) {
339
+ debug(`User declined, aborting`);
305
340
  console.log("Doing nothing.");
306
341
  return;
307
342
  }
343
+ debug(`User confirmed`);
344
+ } else {
345
+ debug(`Force flag set, skipping confirmation`);
308
346
  }
347
+ debug(
348
+ `Creating SSM client with region: ${config.aws.region}, profile: ${config.aws.profile}`
349
+ );
309
350
  const client = new import_client_ssm2.SSMClient({
310
351
  region: config.aws.region,
311
352
  credentials: await CachedCredentialProvider(config.aws)
312
353
  });
354
+ debug(
355
+ `Sending parameter to SSM with type: ${args.secure ? "SecureString" : "String"}`
356
+ );
313
357
  const params = await client.send(
314
358
  new import_client_ssm2.PutParameterCommand({
315
- Name: buildPath(config, args.path),
359
+ Name: fullPath,
316
360
  Value: args.value,
317
361
  Type: args.secure ? import_client_ssm2.ParameterType.SECURE_STRING : import_client_ssm2.ParameterType.STRING,
318
362
  Overwrite: args.overwrite
319
363
  })
320
364
  );
365
+ debug(`Parameter set successfully, version: ${params.Version}`);
321
366
  console.log(import_chalk2.default.green("Version: "), import_chalk2.default.white.bold(params.Version));
322
367
  };
323
368
  };
@@ -347,33 +392,51 @@ Example: "/root/myParam" or "service/secret"`,
347
392
  return args;
348
393
  };
349
394
  handler = async (args) => {
395
+ debug(
396
+ `Delete command handler called with path: ${args.path}, force: ${args.force}`
397
+ );
350
398
  const config = await (0, import_axiom_config4.loadConfig)({ env: args.env });
399
+ debug(
400
+ `Config loaded successfully, base parameter path: ${config.aws?.baseParameterPath}`
401
+ );
351
402
  const path = buildPath(args, args.path);
403
+ debug(`Full parameter path: ${path}`);
404
+ debug(
405
+ `Creating SSM client with region: ${config.aws?.region}, profile: ${config.aws?.profile}`
406
+ );
352
407
  const client = new import_client_ssm3.SSMClient({
353
408
  region: config.aws?.region,
354
409
  credentials: await CachedCredentialProvider(config.aws)
355
410
  });
356
411
  if (path === args.aws.baseParameterPath) {
412
+ debug(`Delete blocked: path matches base parameter path`);
357
413
  throw new Error(
358
414
  `Deleting the path (path: ${path}) that matches the base path (awsSsmParameterPath: ${args.awsSsmParameterPath}) is prohibited.`
359
415
  );
360
416
  }
361
417
  if (args.force !== true) {
418
+ debug(`Prompting user for confirmation...`);
362
419
  const res = await import_inquirer3.default.prompt({
363
420
  type: "confirm",
364
421
  name: "delete",
365
422
  message: `Are you sure you want to delete '${path}'?`
366
423
  });
367
424
  if (!res.delete) {
425
+ debug(`User declined, aborting`);
368
426
  log("Doing nothing.");
369
427
  return;
370
428
  }
429
+ debug(`User confirmed`);
430
+ } else {
431
+ debug(`Force flag set, skipping confirmation`);
371
432
  }
433
+ debug(`Sending delete command to SSM for: ${path}`);
372
434
  await client.send(
373
435
  new import_client_ssm3.DeleteParameterCommand({
374
436
  Name: path
375
437
  })
376
438
  );
439
+ debug(`Parameter deleted successfully`);
377
440
  log("\u{1F44D}");
378
441
  };
379
442
  };
@@ -382,6 +445,16 @@ Example: "/root/myParam" or "service/secret"`,
382
445
  (0, import_yargs.default)(process.argv.slice(2)).env("AXIOM").scriptName("axiom").option("config", {
383
446
  alias: "c",
384
447
  string: true
448
+ }).option("debug", {
449
+ alias: "d",
450
+ type: "boolean",
451
+ description: "Enable debug output",
452
+ default: false,
453
+ global: true
454
+ }).middleware((argv) => {
455
+ if (argv.debug) {
456
+ process.env.AXIOM_DEBUG = "true";
457
+ }
385
458
  }).command(new Config()).command(new ParamsCommand()).strict().usage(
386
459
  `
387
460
  Axiom - an AWS focused config cli
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import "../chunk-72DOPOLO.mjs";
2
+ import "../chunk-CORLQJO7.mjs";
@@ -3,6 +3,16 @@ import yargs from "yargs";
3
3
 
4
4
  // src/commands/config.ts
5
5
  import { loadConfig } from "@dsmrt/axiom-config";
6
+
7
+ // src/debug.ts
8
+ var isDebugEnabled = () => process.env.AXIOM_DEBUG === "true" || process.env.AXIOM_DEBUG === "1";
9
+ var debug = (message, ...args) => {
10
+ if (isDebugEnabled()) {
11
+ console.error(`[axiom:cli] ${message}`, ...args);
12
+ }
13
+ };
14
+
15
+ // src/commands/config.ts
6
16
  var Config = class {
7
17
  command = "config";
8
18
  describe = "print the config";
@@ -13,9 +23,13 @@ var Config = class {
13
23
  return args;
14
24
  };
15
25
  handler = async (args) => {
16
- console.log(JSON.stringify(await this.loadConfig(args)));
26
+ debug(`Config command handler called with env: ${args.env}`);
27
+ const config = await this.loadConfig(args);
28
+ debug(`Config loaded successfully, outputting as JSON`);
29
+ console.log(JSON.stringify(config));
17
30
  };
18
31
  loadConfig = async (args) => {
32
+ debug(`Loading config with env: ${args.env}`);
19
33
  return loadConfig(args);
20
34
  };
21
35
  };
@@ -193,7 +207,16 @@ Example:
193
207
  return args;
194
208
  };
195
209
  handler = async (args) => {
210
+ debug(
211
+ `Get command handler called with env: ${args.env}, path: ${args.path}`
212
+ );
196
213
  const config = await loadConfig2({ env: args.env });
214
+ debug(
215
+ `Config loaded successfully, base parameter path: ${config.aws?.baseParameterPath}`
216
+ );
217
+ debug(
218
+ `Creating SSM client with region: ${config.aws.region}, profile: ${config.aws.profile}`
219
+ );
197
220
  const collection = new ParameterCollection(
198
221
  config.aws?.baseParameterPath,
199
222
  new SSMClient({
@@ -206,7 +229,9 @@ Example:
206
229
  })
207
230
  })
208
231
  );
232
+ debug(`Fetching parameters from SSM...`);
209
233
  const params = await collection.get();
234
+ debug(`Retrieved ${params.size} parameters`);
210
235
  params.forEach((parameter) => {
211
236
  console.log(
212
237
  chalk.gray(
@@ -276,30 +301,50 @@ Example: "/root/myParam" or "service/secret"`
276
301
  });
277
302
  };
278
303
  handler = async (args) => {
304
+ debug(
305
+ `Set command handler called with path: ${args.path}, secure: ${args.secure}, overwrite: ${args.overwrite}, force: ${args.force}`
306
+ );
279
307
  const config = await loadConfig3({ env: args.env });
308
+ debug(
309
+ `Config loaded successfully, base parameter path: ${config.aws?.baseParameterPath}`
310
+ );
311
+ const fullPath = buildPath(config, args.path);
312
+ debug(`Full parameter path: ${fullPath}`);
280
313
  if (args.force !== true) {
314
+ debug(`Prompting user for confirmation...`);
281
315
  const res = await inquirer2.prompt({
282
316
  type: "confirm",
283
317
  name: "setParam",
284
318
  message: `Are you sure you want to set '${args.path}'?`
285
319
  });
286
320
  if (!res.setParam) {
321
+ debug(`User declined, aborting`);
287
322
  console.log("Doing nothing.");
288
323
  return;
289
324
  }
325
+ debug(`User confirmed`);
326
+ } else {
327
+ debug(`Force flag set, skipping confirmation`);
290
328
  }
329
+ debug(
330
+ `Creating SSM client with region: ${config.aws.region}, profile: ${config.aws.profile}`
331
+ );
291
332
  const client = new SSMClient2({
292
333
  region: config.aws.region,
293
334
  credentials: await CachedCredentialProvider(config.aws)
294
335
  });
336
+ debug(
337
+ `Sending parameter to SSM with type: ${args.secure ? "SecureString" : "String"}`
338
+ );
295
339
  const params = await client.send(
296
340
  new PutParameterCommand({
297
- Name: buildPath(config, args.path),
341
+ Name: fullPath,
298
342
  Value: args.value,
299
343
  Type: args.secure ? ParameterType.SECURE_STRING : ParameterType.STRING,
300
344
  Overwrite: args.overwrite
301
345
  })
302
346
  );
347
+ debug(`Parameter set successfully, version: ${params.Version}`);
303
348
  console.log(chalk2.green("Version: "), chalk2.white.bold(params.Version));
304
349
  };
305
350
  };
@@ -329,33 +374,51 @@ Example: "/root/myParam" or "service/secret"`,
329
374
  return args;
330
375
  };
331
376
  handler = async (args) => {
377
+ debug(
378
+ `Delete command handler called with path: ${args.path}, force: ${args.force}`
379
+ );
332
380
  const config = await loadConfig4({ env: args.env });
381
+ debug(
382
+ `Config loaded successfully, base parameter path: ${config.aws?.baseParameterPath}`
383
+ );
333
384
  const path = buildPath(args, args.path);
385
+ debug(`Full parameter path: ${path}`);
386
+ debug(
387
+ `Creating SSM client with region: ${config.aws?.region}, profile: ${config.aws?.profile}`
388
+ );
334
389
  const client = new SSMClient3({
335
390
  region: config.aws?.region,
336
391
  credentials: await CachedCredentialProvider(config.aws)
337
392
  });
338
393
  if (path === args.aws.baseParameterPath) {
394
+ debug(`Delete blocked: path matches base parameter path`);
339
395
  throw new Error(
340
396
  `Deleting the path (path: ${path}) that matches the base path (awsSsmParameterPath: ${args.awsSsmParameterPath}) is prohibited.`
341
397
  );
342
398
  }
343
399
  if (args.force !== true) {
400
+ debug(`Prompting user for confirmation...`);
344
401
  const res = await inquirer3.prompt({
345
402
  type: "confirm",
346
403
  name: "delete",
347
404
  message: `Are you sure you want to delete '${path}'?`
348
405
  });
349
406
  if (!res.delete) {
407
+ debug(`User declined, aborting`);
350
408
  log("Doing nothing.");
351
409
  return;
352
410
  }
411
+ debug(`User confirmed`);
412
+ } else {
413
+ debug(`Force flag set, skipping confirmation`);
353
414
  }
415
+ debug(`Sending delete command to SSM for: ${path}`);
354
416
  await client.send(
355
417
  new DeleteParameterCommand({
356
418
  Name: path
357
419
  })
358
420
  );
421
+ debug(`Parameter deleted successfully`);
359
422
  log("\u{1F44D}");
360
423
  };
361
424
  };
@@ -364,6 +427,16 @@ Example: "/root/myParam" or "service/secret"`,
364
427
  yargs(process.argv.slice(2)).env("AXIOM").scriptName("axiom").option("config", {
365
428
  alias: "c",
366
429
  string: true
430
+ }).option("debug", {
431
+ alias: "d",
432
+ type: "boolean",
433
+ description: "Enable debug output",
434
+ default: false,
435
+ global: true
436
+ }).middleware((argv) => {
437
+ if (argv.debug) {
438
+ process.env.AXIOM_DEBUG = "true";
439
+ }
367
440
  }).command(new Config()).command(new ParamsCommand()).strict().usage(
368
441
  `
369
442
  Axiom - an AWS focused config cli
package/dist/index.js CHANGED
@@ -45,6 +45,16 @@ var import_yargs = __toESM(require("yargs"));
45
45
 
46
46
  // src/commands/config.ts
47
47
  var import_axiom_config = require("@dsmrt/axiom-config");
48
+
49
+ // src/debug.ts
50
+ var isDebugEnabled = () => process.env.AXIOM_DEBUG === "true" || process.env.AXIOM_DEBUG === "1";
51
+ var debug = (message, ...args) => {
52
+ if (isDebugEnabled()) {
53
+ console.error(`[axiom:cli] ${message}`, ...args);
54
+ }
55
+ };
56
+
57
+ // src/commands/config.ts
48
58
  var Config = class {
49
59
  command = "config";
50
60
  describe = "print the config";
@@ -55,9 +65,13 @@ var Config = class {
55
65
  return args;
56
66
  };
57
67
  handler = async (args) => {
58
- console.log(JSON.stringify(await this.loadConfig(args)));
68
+ debug(`Config command handler called with env: ${args.env}`);
69
+ const config = await this.loadConfig(args);
70
+ debug(`Config loaded successfully, outputting as JSON`);
71
+ console.log(JSON.stringify(config));
59
72
  };
60
73
  loadConfig = async (args) => {
74
+ debug(`Loading config with env: ${args.env}`);
61
75
  return (0, import_axiom_config.loadConfig)(args);
62
76
  };
63
77
  };
@@ -232,7 +246,16 @@ Example:
232
246
  return args;
233
247
  };
234
248
  handler = async (args) => {
249
+ debug(
250
+ `Get command handler called with env: ${args.env}, path: ${args.path}`
251
+ );
235
252
  const config = await (0, import_axiom_config2.loadConfig)({ env: args.env });
253
+ debug(
254
+ `Config loaded successfully, base parameter path: ${config.aws?.baseParameterPath}`
255
+ );
256
+ debug(
257
+ `Creating SSM client with region: ${config.aws.region}, profile: ${config.aws.profile}`
258
+ );
236
259
  const collection = new import_axiom_aws_sdk.ParameterCollection(
237
260
  config.aws?.baseParameterPath,
238
261
  new import_client_ssm.SSMClient({
@@ -245,7 +268,9 @@ Example:
245
268
  })
246
269
  })
247
270
  );
271
+ debug(`Fetching parameters from SSM...`);
248
272
  const params = await collection.get();
273
+ debug(`Retrieved ${params.size} parameters`);
249
274
  params.forEach((parameter) => {
250
275
  console.log(
251
276
  import_chalk.default.gray(
@@ -311,30 +336,50 @@ Example: "/root/myParam" or "service/secret"`
311
336
  });
312
337
  };
313
338
  handler = async (args) => {
339
+ debug(
340
+ `Set command handler called with path: ${args.path}, secure: ${args.secure}, overwrite: ${args.overwrite}, force: ${args.force}`
341
+ );
314
342
  const config = await (0, import_axiom_config3.loadConfig)({ env: args.env });
343
+ debug(
344
+ `Config loaded successfully, base parameter path: ${config.aws?.baseParameterPath}`
345
+ );
346
+ const fullPath = buildPath(config, args.path);
347
+ debug(`Full parameter path: ${fullPath}`);
315
348
  if (args.force !== true) {
349
+ debug(`Prompting user for confirmation...`);
316
350
  const res = await import_inquirer2.default.prompt({
317
351
  type: "confirm",
318
352
  name: "setParam",
319
353
  message: `Are you sure you want to set '${args.path}'?`
320
354
  });
321
355
  if (!res.setParam) {
356
+ debug(`User declined, aborting`);
322
357
  console.log("Doing nothing.");
323
358
  return;
324
359
  }
360
+ debug(`User confirmed`);
361
+ } else {
362
+ debug(`Force flag set, skipping confirmation`);
325
363
  }
364
+ debug(
365
+ `Creating SSM client with region: ${config.aws.region}, profile: ${config.aws.profile}`
366
+ );
326
367
  const client = new import_client_ssm2.SSMClient({
327
368
  region: config.aws.region,
328
369
  credentials: await CachedCredentialProvider(config.aws)
329
370
  });
371
+ debug(
372
+ `Sending parameter to SSM with type: ${args.secure ? "SecureString" : "String"}`
373
+ );
330
374
  const params = await client.send(
331
375
  new import_client_ssm2.PutParameterCommand({
332
- Name: buildPath(config, args.path),
376
+ Name: fullPath,
333
377
  Value: args.value,
334
378
  Type: args.secure ? import_client_ssm2.ParameterType.SECURE_STRING : import_client_ssm2.ParameterType.STRING,
335
379
  Overwrite: args.overwrite
336
380
  })
337
381
  );
382
+ debug(`Parameter set successfully, version: ${params.Version}`);
338
383
  console.log(import_chalk2.default.green("Version: "), import_chalk2.default.white.bold(params.Version));
339
384
  };
340
385
  };
@@ -364,33 +409,51 @@ Example: "/root/myParam" or "service/secret"`,
364
409
  return args;
365
410
  };
366
411
  handler = async (args) => {
412
+ debug(
413
+ `Delete command handler called with path: ${args.path}, force: ${args.force}`
414
+ );
367
415
  const config = await (0, import_axiom_config4.loadConfig)({ env: args.env });
416
+ debug(
417
+ `Config loaded successfully, base parameter path: ${config.aws?.baseParameterPath}`
418
+ );
368
419
  const path = buildPath(args, args.path);
420
+ debug(`Full parameter path: ${path}`);
421
+ debug(
422
+ `Creating SSM client with region: ${config.aws?.region}, profile: ${config.aws?.profile}`
423
+ );
369
424
  const client = new import_client_ssm3.SSMClient({
370
425
  region: config.aws?.region,
371
426
  credentials: await CachedCredentialProvider(config.aws)
372
427
  });
373
428
  if (path === args.aws.baseParameterPath) {
429
+ debug(`Delete blocked: path matches base parameter path`);
374
430
  throw new Error(
375
431
  `Deleting the path (path: ${path}) that matches the base path (awsSsmParameterPath: ${args.awsSsmParameterPath}) is prohibited.`
376
432
  );
377
433
  }
378
434
  if (args.force !== true) {
435
+ debug(`Prompting user for confirmation...`);
379
436
  const res = await import_inquirer3.default.prompt({
380
437
  type: "confirm",
381
438
  name: "delete",
382
439
  message: `Are you sure you want to delete '${path}'?`
383
440
  });
384
441
  if (!res.delete) {
442
+ debug(`User declined, aborting`);
385
443
  log("Doing nothing.");
386
444
  return;
387
445
  }
446
+ debug(`User confirmed`);
447
+ } else {
448
+ debug(`Force flag set, skipping confirmation`);
388
449
  }
450
+ debug(`Sending delete command to SSM for: ${path}`);
389
451
  await client.send(
390
452
  new import_client_ssm3.DeleteParameterCommand({
391
453
  Name: path
392
454
  })
393
455
  );
456
+ debug(`Parameter deleted successfully`);
394
457
  log("\u{1F44D}");
395
458
  };
396
459
  };
@@ -399,6 +462,16 @@ Example: "/root/myParam" or "service/secret"`,
399
462
  (0, import_yargs.default)(process.argv.slice(2)).env("AXIOM").scriptName("axiom").option("config", {
400
463
  alias: "c",
401
464
  string: true
465
+ }).option("debug", {
466
+ alias: "d",
467
+ type: "boolean",
468
+ description: "Enable debug output",
469
+ default: false,
470
+ global: true
471
+ }).middleware((argv) => {
472
+ if (argv.debug) {
473
+ process.env.AXIOM_DEBUG = "true";
474
+ }
402
475
  }).command(new Config()).command(new ParamsCommand()).strict().usage(
403
476
  `
404
477
  Axiom - an AWS focused config cli
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  SetCommand,
7
7
  awsOptions,
8
8
  commonOptions
9
- } from "./chunk-72DOPOLO.mjs";
9
+ } from "./chunk-CORLQJO7.mjs";
10
10
  export {
11
11
  Config,
12
12
  DeleteCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsmrt/axiom-cli",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "axiom cli for managing configs including secrets",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -49,7 +49,7 @@
49
49
  "inquirer": "^8.2.6",
50
50
  "yargs": "^17.7.2",
51
51
  "@dsmrt/axiom-aws-sdk": "^1.0.0",
52
- "@dsmrt/axiom-config": "^1.0.0"
52
+ "@dsmrt/axiom-config": "^1.1.0"
53
53
  },
54
54
  "scripts": {
55
55
  "lint": "biome lint",