@dsmrt/axiom-cli 0.3.0 → 1.0.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,26 @@
1
1
  # @dsmrt/axiom-cli
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - d767a0e: Making loadConfig return a promise; adding typescript config support and better esm/mjs/mts support; better docs
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [d767a0e]
12
+ - @dsmrt/axiom-aws-sdk@1.0.0
13
+ - @dsmrt/axiom-config@1.0.0
14
+
15
+ ## 0.3.1
16
+
17
+ ### Patch Changes
18
+
19
+ - f4c9e19: fix: remove debug and fix testing
20
+ - Updated dependencies [f4c9e19]
21
+ - @dsmrt/axiom-aws-sdk@0.2.2
22
+ - @dsmrt/axiom-config@0.2.3
23
+
3
24
  ## 0.3.0
4
25
 
5
26
  ### Minor Changes
package/README.md CHANGED
@@ -26,12 +26,12 @@ npm install @dsmrt/axiom-cli
26
26
  - View rendered configs
27
27
  - Manage SSM Parameters
28
28
 
29
- ```
29
+ ```bash
30
30
  axiom --help
31
31
  ```
32
32
 
33
33
  ## Acknowledgements
34
34
 
35
35
  - [Nate Iler](https://github.com/nateiler)
36
+ - [Go Mondo](https://www.go-mondo.com)
36
37
  - [Flipbox Digital](https://www.flipboxdigital.com)
37
- - [Go Mondo](https://www.flipboxdigital.com)
package/dist/bin/axiom.js CHANGED
@@ -59,9 +59,10 @@ var ParamsCommand = class {
59
59
  };
60
60
 
61
61
  // src/commands/params/get.ts
62
- var import_axiom_config2 = require("@dsmrt/axiom-config");
63
- var import_axiom_aws_sdk = require("@dsmrt/axiom-aws-sdk");
64
62
  var import_client_ssm = require("@aws-sdk/client-ssm");
63
+ var import_axiom_aws_sdk = require("@dsmrt/axiom-aws-sdk");
64
+ var import_axiom_config2 = require("@dsmrt/axiom-config");
65
+ var import_chalk = __toESM(require("chalk"));
65
66
 
66
67
  // src/aws/credentials-provider.ts
67
68
  var import_credential_providers = require("@aws-sdk/credential-providers");
@@ -69,19 +70,19 @@ var import_client_sts = require("@aws-sdk/client-sts");
69
70
  var import_inquirer = __toESM(require("inquirer"));
70
71
 
71
72
  // src/cache.ts
72
- var import_os = __toESM(require("os"));
73
- var import_fs = __toESM(require("fs"));
74
- var DEFAULT_DIRECTORY = `${import_os.default.homedir()}/.axiom/cache`;
73
+ var import_node_fs = __toESM(require("fs"));
74
+ var import_node_os = __toESM(require("os"));
75
+ var DEFAULT_DIRECTORY = `${import_node_os.default.homedir()}/.axiom/cache`;
75
76
  var cache_default = class {
76
77
  constructor(cacheDir = DEFAULT_DIRECTORY) {
77
78
  this.cacheDir = cacheDir;
78
79
  }
79
80
  get(name) {
80
81
  const file = `${this.cacheDir}/${name}`;
81
- if (!import_fs.default.existsSync(file)) {
82
+ if (!import_node_fs.default.existsSync(file)) {
82
83
  return;
83
84
  }
84
- const buffer = import_fs.default.readFileSync(file);
85
+ const buffer = import_node_fs.default.readFileSync(file);
85
86
  const item = JSON.parse(buffer.toString());
86
87
  if (item.expires === void 0) {
87
88
  return item.data;
@@ -94,16 +95,16 @@ var cache_default = class {
94
95
  return item.data;
95
96
  }
96
97
  delete(name) {
97
- import_fs.default.unlinkSync(`${this.cacheDir}/${name}`);
98
+ import_node_fs.default.unlinkSync(`${this.cacheDir}/${name}`);
98
99
  }
99
100
  set(name, value, expires) {
100
- if (!import_fs.default.existsSync(this.cacheDir)) {
101
- import_fs.default.mkdirSync(this.cacheDir, {
101
+ if (!import_node_fs.default.existsSync(this.cacheDir)) {
102
+ import_node_fs.default.mkdirSync(this.cacheDir, {
102
103
  recursive: true,
103
104
  mode: 448
104
105
  });
105
106
  }
106
- import_fs.default.writeFileSync(
107
+ import_node_fs.default.writeFileSync(
107
108
  `${this.cacheDir}/${name}`,
108
109
  JSON.stringify({
109
110
  expires,
@@ -199,38 +200,22 @@ var awsOptions = () => {
199
200
  };
200
201
  };
201
202
 
202
- // src/commands/params/utils.ts
203
- var buildPath = (config, path) => {
204
- if (path === void 0) {
205
- return config.aws?.baseParameterPath;
206
- }
207
- if (/^\//.test(path)) {
208
- return path;
209
- }
210
- return `${config.aws?.baseParameterPath.replace(/\/$/, "")}/${path}`;
211
- };
212
-
213
203
  // src/commands/params/get.ts
214
- var import_chalk = __toESM(require("chalk"));
215
204
  var GetCommand = class {
216
205
  command = "get [path]";
217
206
  describe = "Get all parameters under the base path";
218
207
  builder = (args) => {
219
- const config = (0, import_axiom_config2.loadConfig)();
220
208
  args.options({ ...commonOptions(), ...awsOptions() });
221
209
  args.positional("path", {
222
210
  type: "string",
223
211
  describe: `OPTIONAL path to parameter. Supports absolute and relative paths.
224
212
  Example:
225
- "/root/myParam" or "service/secret" (which translates to, "${buildPath(
226
- config,
227
- "service/secret"
228
- )})`
213
+ "/root/myParam" or "service/secret"`
229
214
  });
230
215
  return args;
231
216
  };
232
217
  handler = async (args) => {
233
- const config = (0, import_axiom_config2.loadConfig)({ env: args.env });
218
+ const config = await (0, import_axiom_config2.loadConfig)({ env: args.env });
234
219
  const collection = new import_axiom_aws_sdk.ParameterCollection(
235
220
  config.aws?.baseParameterPath,
236
221
  new import_client_ssm.SSMClient({
@@ -247,7 +232,7 @@ Example:
247
232
  params.forEach((parameter) => {
248
233
  console.log(
249
234
  import_chalk.default.gray(
250
- parameter.Name?.replace(/\/([^/]+)$/, "/" + import_chalk.default.bold.green("$1"))
235
+ parameter.Name?.replace(/\/([^/]+)$/, `/${import_chalk.default.bold.green("$1")}`)
251
236
  ),
252
237
  import_chalk.default.bold.white(parameter.Value)
253
238
  );
@@ -256,22 +241,31 @@ Example:
256
241
  };
257
242
 
258
243
  // src/commands/params/set.ts
259
- var import_axiom_config3 = require("@dsmrt/axiom-config");
260
- var import_inquirer2 = __toESM(require("inquirer"));
261
244
  var import_client_ssm2 = require("@aws-sdk/client-ssm");
245
+ var import_axiom_config3 = require("@dsmrt/axiom-config");
262
246
  var import_chalk2 = __toESM(require("chalk"));
247
+ var import_inquirer2 = __toESM(require("inquirer"));
248
+
249
+ // src/commands/params/utils.ts
250
+ var buildPath = (config, path) => {
251
+ if (path === void 0) {
252
+ return config.aws?.baseParameterPath;
253
+ }
254
+ if (/^\//.test(path)) {
255
+ return path;
256
+ }
257
+ return `${config.aws?.baseParameterPath.replace(/\/$/, "")}/${path}`;
258
+ };
259
+
260
+ // src/commands/params/set.ts
263
261
  var SetCommand = class {
264
262
  command = "set <path> <value>";
265
263
  describe = "Set all parameters under the base path";
266
264
  builder = (args) => {
267
- const config = (0, import_axiom_config3.loadConfig)();
268
265
  args.positional("path", {
269
266
  type: "string",
270
267
  describe: `Path to parameter. Supports absolute and relative paths.
271
- Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
272
- config,
273
- "service/secret"
274
- )})`
268
+ Example: "/root/myParam" or "service/secret"`
275
269
  });
276
270
  args.demandOption("path", "Path is required");
277
271
  args.positional("value", {
@@ -300,7 +294,7 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
300
294
  });
301
295
  };
302
296
  handler = async (args) => {
303
- const config = (0, import_axiom_config3.loadConfig)({ env: args.env });
297
+ const config = await (0, import_axiom_config3.loadConfig)({ env: args.env });
304
298
  if (args.force !== true) {
305
299
  const res = await import_inquirer2.default.prompt({
306
300
  type: "confirm",
@@ -329,24 +323,19 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
329
323
  };
330
324
 
331
325
  // src/commands/params/delete.ts
326
+ var import_client_ssm3 = require("@aws-sdk/client-ssm");
332
327
  var import_axiom_config4 = require("@dsmrt/axiom-config");
333
328
  var import_inquirer3 = __toESM(require("inquirer"));
334
- var import_client_ssm3 = require("@aws-sdk/client-ssm");
335
329
  var log = console.log;
336
330
  var DeleteCommand = class {
337
331
  command = "delete <path>";
338
332
  describe = "Delete SSM parameters";
339
333
  client;
340
334
  builder = (args) => {
341
- const config = (0, import_axiom_config4.loadConfig)();
342
335
  args.positional("path", {
343
336
  type: "string",
344
337
  describe: `Path to parameter. Supports absolute and relative paths.
345
- Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
346
- config,
347
- "service/secret"
348
- )})`,
349
- default: config.aws?.baseParameterPath,
338
+ Example: "/root/myParam" or "service/secret"`,
350
339
  demandOption: true
351
340
  }).demandOption("path", "Path is required");
352
341
  args.option("force", {
@@ -358,7 +347,7 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
358
347
  return args;
359
348
  };
360
349
  handler = async (args) => {
361
- const config = (0, import_axiom_config4.loadConfig)({ env: args.env });
350
+ const config = await (0, import_axiom_config4.loadConfig)({ env: args.env });
362
351
  const path = buildPath(args, args.path);
363
352
  const client = new import_client_ssm3.SSMClient({
364
353
  region: config.aws?.region,
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import "../chunk-XDVNYWAQ.mjs";
2
+ import "../chunk-72DOPOLO.mjs";
@@ -34,9 +34,10 @@ var ParamsCommand = class {
34
34
  };
35
35
 
36
36
  // src/commands/params/get.ts
37
- import { loadConfig as loadConfig2 } from "@dsmrt/axiom-config";
38
- import { ParameterCollection } from "@dsmrt/axiom-aws-sdk";
39
37
  import { SSMClient } from "@aws-sdk/client-ssm";
38
+ import { ParameterCollection } from "@dsmrt/axiom-aws-sdk";
39
+ import { loadConfig as loadConfig2 } from "@dsmrt/axiom-config";
40
+ import chalk from "chalk";
40
41
 
41
42
  // src/aws/credentials-provider.ts
42
43
  import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
@@ -47,8 +48,8 @@ import {
47
48
  import inquirer from "inquirer";
48
49
 
49
50
  // src/cache.ts
50
- import os from "os";
51
51
  import fs from "fs";
52
+ import os from "os";
52
53
  var DEFAULT_DIRECTORY = `${os.homedir()}/.axiom/cache`;
53
54
  var cache_default = class {
54
55
  constructor(cacheDir = DEFAULT_DIRECTORY) {
@@ -177,38 +178,22 @@ var awsOptions = () => {
177
178
  };
178
179
  };
179
180
 
180
- // src/commands/params/utils.ts
181
- var buildPath = (config, path) => {
182
- if (path === void 0) {
183
- return config.aws?.baseParameterPath;
184
- }
185
- if (/^\//.test(path)) {
186
- return path;
187
- }
188
- return `${config.aws?.baseParameterPath.replace(/\/$/, "")}/${path}`;
189
- };
190
-
191
181
  // src/commands/params/get.ts
192
- import chalk from "chalk";
193
182
  var GetCommand = class {
194
183
  command = "get [path]";
195
184
  describe = "Get all parameters under the base path";
196
185
  builder = (args) => {
197
- const config = loadConfig2();
198
186
  args.options({ ...commonOptions(), ...awsOptions() });
199
187
  args.positional("path", {
200
188
  type: "string",
201
189
  describe: `OPTIONAL path to parameter. Supports absolute and relative paths.
202
190
  Example:
203
- "/root/myParam" or "service/secret" (which translates to, "${buildPath(
204
- config,
205
- "service/secret"
206
- )})`
191
+ "/root/myParam" or "service/secret"`
207
192
  });
208
193
  return args;
209
194
  };
210
195
  handler = async (args) => {
211
- const config = loadConfig2({ env: args.env });
196
+ const config = await loadConfig2({ env: args.env });
212
197
  const collection = new ParameterCollection(
213
198
  config.aws?.baseParameterPath,
214
199
  new SSMClient({
@@ -225,7 +210,7 @@ Example:
225
210
  params.forEach((parameter) => {
226
211
  console.log(
227
212
  chalk.gray(
228
- parameter.Name?.replace(/\/([^/]+)$/, "/" + chalk.bold.green("$1"))
213
+ parameter.Name?.replace(/\/([^/]+)$/, `/${chalk.bold.green("$1")}`)
229
214
  ),
230
215
  chalk.bold.white(parameter.Value)
231
216
  );
@@ -234,26 +219,35 @@ Example:
234
219
  };
235
220
 
236
221
  // src/commands/params/set.ts
237
- import { loadConfig as loadConfig3 } from "@dsmrt/axiom-config";
238
- import inquirer2 from "inquirer";
239
222
  import {
240
- SSMClient as SSMClient2,
223
+ ParameterType,
241
224
  PutParameterCommand,
242
- ParameterType
225
+ SSMClient as SSMClient2
243
226
  } from "@aws-sdk/client-ssm";
227
+ import { loadConfig as loadConfig3 } from "@dsmrt/axiom-config";
244
228
  import chalk2 from "chalk";
229
+ import inquirer2 from "inquirer";
230
+
231
+ // src/commands/params/utils.ts
232
+ var buildPath = (config, path) => {
233
+ if (path === void 0) {
234
+ return config.aws?.baseParameterPath;
235
+ }
236
+ if (/^\//.test(path)) {
237
+ return path;
238
+ }
239
+ return `${config.aws?.baseParameterPath.replace(/\/$/, "")}/${path}`;
240
+ };
241
+
242
+ // src/commands/params/set.ts
245
243
  var SetCommand = class {
246
244
  command = "set <path> <value>";
247
245
  describe = "Set all parameters under the base path";
248
246
  builder = (args) => {
249
- const config = loadConfig3();
250
247
  args.positional("path", {
251
248
  type: "string",
252
249
  describe: `Path to parameter. Supports absolute and relative paths.
253
- Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
254
- config,
255
- "service/secret"
256
- )})`
250
+ Example: "/root/myParam" or "service/secret"`
257
251
  });
258
252
  args.demandOption("path", "Path is required");
259
253
  args.positional("value", {
@@ -282,7 +276,7 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
282
276
  });
283
277
  };
284
278
  handler = async (args) => {
285
- const config = loadConfig3({ env: args.env });
279
+ const config = await loadConfig3({ env: args.env });
286
280
  if (args.force !== true) {
287
281
  const res = await inquirer2.prompt({
288
282
  type: "confirm",
@@ -311,24 +305,19 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
311
305
  };
312
306
 
313
307
  // src/commands/params/delete.ts
308
+ import { DeleteParameterCommand, SSMClient as SSMClient3 } from "@aws-sdk/client-ssm";
314
309
  import { loadConfig as loadConfig4 } from "@dsmrt/axiom-config";
315
310
  import inquirer3 from "inquirer";
316
- import { SSMClient as SSMClient3, DeleteParameterCommand } from "@aws-sdk/client-ssm";
317
311
  var log = console.log;
318
312
  var DeleteCommand = class {
319
313
  command = "delete <path>";
320
314
  describe = "Delete SSM parameters";
321
315
  client;
322
316
  builder = (args) => {
323
- const config = loadConfig4();
324
317
  args.positional("path", {
325
318
  type: "string",
326
319
  describe: `Path to parameter. Supports absolute and relative paths.
327
- Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
328
- config,
329
- "service/secret"
330
- )})`,
331
- default: config.aws?.baseParameterPath,
320
+ Example: "/root/myParam" or "service/secret"`,
332
321
  demandOption: true
333
322
  }).demandOption("path", "Path is required");
334
323
  args.option("force", {
@@ -340,7 +329,7 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
340
329
  return args;
341
330
  };
342
331
  handler = async (args) => {
343
- const config = loadConfig4({ env: args.env });
332
+ const config = await loadConfig4({ env: args.env });
344
333
  const path = buildPath(args, args.path);
345
334
  const client = new SSMClient3({
346
335
  region: config.aws?.region,
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { Options as Options$1, CommandModule, CommandBuilder, ArgumentsCamelCase, Argv } from 'yargs';
2
1
  import * as _dsmrt_axiom_config from '@dsmrt/axiom-config';
3
2
  import { AwsConfigs, Config as Config$1 } from '@dsmrt/axiom-config';
3
+ import { CommandModule, CommandBuilder, ArgumentsCamelCase, Argv, Options as Options$1 } from 'yargs';
4
4
  import { SSMClient } from '@aws-sdk/client-ssm';
5
5
 
6
6
  interface Item {
@@ -8,13 +8,6 @@ interface Item {
8
8
  data: unknown;
9
9
  }
10
10
 
11
- declare const commonOptions: () => {
12
- [key: string]: Options$1;
13
- };
14
- declare const awsOptions: () => {
15
- [key: string]: Options$1;
16
- };
17
-
18
11
  interface ConfigOptions {
19
12
  env: string;
20
13
  }
@@ -26,8 +19,7 @@ declare class Config<U extends ConfigOptions> implements CommandModule<object, U
26
19
  loadConfig: (args: ConfigOptions) => Promise<_dsmrt_axiom_config.ConfigContainer & object>;
27
20
  }
28
21
 
29
- interface Options {
30
- }
22
+ type Options = object;
31
23
  declare class ParamsCommand<U extends Options> implements CommandModule<object, U> {
32
24
  command: string;
33
25
  describe: string;
@@ -75,4 +67,11 @@ declare class DeleteCommand<U extends config> implements CommandModule<object, U
75
67
  handler: (args: ArgumentsCamelCase<U>) => Promise<void>;
76
68
  }
77
69
 
70
+ declare const commonOptions: () => {
71
+ [key: string]: Options$1;
72
+ };
73
+ declare const awsOptions: () => {
74
+ [key: string]: Options$1;
75
+ };
76
+
78
77
  export { Config, DeleteCommand, type DeleteOptions, GetCommand, type GetOptions, type Item, ParamsCommand, SetCommand, type SetOptions, awsOptions, commonOptions };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Options as Options$1, CommandModule, CommandBuilder, ArgumentsCamelCase, Argv } from 'yargs';
2
1
  import * as _dsmrt_axiom_config from '@dsmrt/axiom-config';
3
2
  import { AwsConfigs, Config as Config$1 } from '@dsmrt/axiom-config';
3
+ import { CommandModule, CommandBuilder, ArgumentsCamelCase, Argv, Options as Options$1 } from 'yargs';
4
4
  import { SSMClient } from '@aws-sdk/client-ssm';
5
5
 
6
6
  interface Item {
@@ -8,13 +8,6 @@ interface Item {
8
8
  data: unknown;
9
9
  }
10
10
 
11
- declare const commonOptions: () => {
12
- [key: string]: Options$1;
13
- };
14
- declare const awsOptions: () => {
15
- [key: string]: Options$1;
16
- };
17
-
18
11
  interface ConfigOptions {
19
12
  env: string;
20
13
  }
@@ -26,8 +19,7 @@ declare class Config<U extends ConfigOptions> implements CommandModule<object, U
26
19
  loadConfig: (args: ConfigOptions) => Promise<_dsmrt_axiom_config.ConfigContainer & object>;
27
20
  }
28
21
 
29
- interface Options {
30
- }
22
+ type Options = object;
31
23
  declare class ParamsCommand<U extends Options> implements CommandModule<object, U> {
32
24
  command: string;
33
25
  describe: string;
@@ -75,4 +67,11 @@ declare class DeleteCommand<U extends config> implements CommandModule<object, U
75
67
  handler: (args: ArgumentsCamelCase<U>) => Promise<void>;
76
68
  }
77
69
 
70
+ declare const commonOptions: () => {
71
+ [key: string]: Options$1;
72
+ };
73
+ declare const awsOptions: () => {
74
+ [key: string]: Options$1;
75
+ };
76
+
78
77
  export { Config, DeleteCommand, type DeleteOptions, GetCommand, type GetOptions, type Item, ParamsCommand, SetCommand, type SetOptions, awsOptions, commonOptions };
package/dist/index.js CHANGED
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  Config: () => Config,
34
34
  DeleteCommand: () => DeleteCommand,
35
35
  GetCommand: () => GetCommand,
@@ -38,85 +38,10 @@ __export(src_exports, {
38
38
  awsOptions: () => awsOptions,
39
39
  commonOptions: () => commonOptions
40
40
  });
41
- module.exports = __toCommonJS(src_exports);
41
+ module.exports = __toCommonJS(index_exports);
42
42
 
43
- // src/cache.ts
44
- var import_os = __toESM(require("os"));
45
- var import_fs = __toESM(require("fs"));
46
- var DEFAULT_DIRECTORY = `${import_os.default.homedir()}/.axiom/cache`;
47
- var cache_default = class {
48
- constructor(cacheDir = DEFAULT_DIRECTORY) {
49
- this.cacheDir = cacheDir;
50
- }
51
- get(name) {
52
- const file = `${this.cacheDir}/${name}`;
53
- if (!import_fs.default.existsSync(file)) {
54
- return;
55
- }
56
- const buffer = import_fs.default.readFileSync(file);
57
- const item = JSON.parse(buffer.toString());
58
- if (item.expires === void 0) {
59
- return item.data;
60
- }
61
- item.expires = new Date(item.expires);
62
- if (item.expires < /* @__PURE__ */ new Date()) {
63
- this.delete(name);
64
- return;
65
- }
66
- return item.data;
67
- }
68
- delete(name) {
69
- import_fs.default.unlinkSync(`${this.cacheDir}/${name}`);
70
- }
71
- set(name, value, expires) {
72
- if (!import_fs.default.existsSync(this.cacheDir)) {
73
- import_fs.default.mkdirSync(this.cacheDir, {
74
- recursive: true,
75
- mode: 448
76
- });
77
- }
78
- import_fs.default.writeFileSync(
79
- `${this.cacheDir}/${name}`,
80
- JSON.stringify({
81
- expires,
82
- data: value
83
- }),
84
- {
85
- mode: 384
86
- }
87
- );
88
- }
89
- };
90
-
91
- // src/options.ts
92
- var commonOptions = () => {
93
- return {
94
- env: {
95
- string: true,
96
- desc: "Environment name like, prod, staging, dev, etc."
97
- }
98
- };
99
- };
100
- var awsOptions = () => {
101
- return {
102
- account: {
103
- string: true,
104
- desc: "AWS Account number like, 1243944546"
105
- },
106
- region: {
107
- string: true,
108
- desc: "AWS region like, us-east-1"
109
- },
110
- profile: {
111
- string: true,
112
- desc: "AWS configured profile"
113
- },
114
- baseParameterPath: {
115
- string: true,
116
- desc: "SSM parameter path base where configs like secrets and infrastucture managed items are set"
117
- }
118
- };
119
- };
43
+ // src/bin/axiom.ts
44
+ var import_yargs = __toESM(require("yargs"));
120
45
 
121
46
  // src/commands/config.ts
122
47
  var import_axiom_config = require("@dsmrt/axiom-config");
@@ -151,14 +76,65 @@ var ParamsCommand = class {
151
76
  };
152
77
 
153
78
  // src/commands/params/get.ts
154
- var import_axiom_config2 = require("@dsmrt/axiom-config");
155
- var import_axiom_aws_sdk = require("@dsmrt/axiom-aws-sdk");
156
79
  var import_client_ssm = require("@aws-sdk/client-ssm");
80
+ var import_axiom_aws_sdk = require("@dsmrt/axiom-aws-sdk");
81
+ var import_axiom_config2 = require("@dsmrt/axiom-config");
82
+ var import_chalk = __toESM(require("chalk"));
157
83
 
158
84
  // src/aws/credentials-provider.ts
159
85
  var import_credential_providers = require("@aws-sdk/credential-providers");
160
86
  var import_client_sts = require("@aws-sdk/client-sts");
161
87
  var import_inquirer = __toESM(require("inquirer"));
88
+
89
+ // src/cache.ts
90
+ var import_node_fs = __toESM(require("fs"));
91
+ var import_node_os = __toESM(require("os"));
92
+ var DEFAULT_DIRECTORY = `${import_node_os.default.homedir()}/.axiom/cache`;
93
+ var cache_default = class {
94
+ constructor(cacheDir = DEFAULT_DIRECTORY) {
95
+ this.cacheDir = cacheDir;
96
+ }
97
+ get(name) {
98
+ const file = `${this.cacheDir}/${name}`;
99
+ if (!import_node_fs.default.existsSync(file)) {
100
+ return;
101
+ }
102
+ const buffer = import_node_fs.default.readFileSync(file);
103
+ const item = JSON.parse(buffer.toString());
104
+ if (item.expires === void 0) {
105
+ return item.data;
106
+ }
107
+ item.expires = new Date(item.expires);
108
+ if (item.expires < /* @__PURE__ */ new Date()) {
109
+ this.delete(name);
110
+ return;
111
+ }
112
+ return item.data;
113
+ }
114
+ delete(name) {
115
+ import_node_fs.default.unlinkSync(`${this.cacheDir}/${name}`);
116
+ }
117
+ set(name, value, expires) {
118
+ if (!import_node_fs.default.existsSync(this.cacheDir)) {
119
+ import_node_fs.default.mkdirSync(this.cacheDir, {
120
+ recursive: true,
121
+ mode: 448
122
+ });
123
+ }
124
+ import_node_fs.default.writeFileSync(
125
+ `${this.cacheDir}/${name}`,
126
+ JSON.stringify({
127
+ expires,
128
+ data: value
129
+ }),
130
+ {
131
+ mode: 384
132
+ }
133
+ );
134
+ }
135
+ };
136
+
137
+ // src/aws/credentials-provider.ts
162
138
  var CACHE_KEY_PREFIX = "axiom#aws-credentials";
163
139
  var cache = new cache_default();
164
140
  var returnCredentialsFromAssumerole = (creds) => {
@@ -211,38 +187,52 @@ var CachedCredentialProvider = (config) => {
211
187
  return CachedCredentialViaProfileAndRegion(config.profile, config.region);
212
188
  };
213
189
 
214
- // src/commands/params/utils.ts
215
- var buildPath = (config, path) => {
216
- if (path === void 0) {
217
- return config.aws?.baseParameterPath;
218
- }
219
- if (/^\//.test(path)) {
220
- return path;
221
- }
222
- return `${config.aws?.baseParameterPath.replace(/\/$/, "")}/${path}`;
190
+ // src/options.ts
191
+ var commonOptions = () => {
192
+ return {
193
+ env: {
194
+ string: true,
195
+ desc: "Environment name like, prod, staging, dev, etc."
196
+ }
197
+ };
198
+ };
199
+ var awsOptions = () => {
200
+ return {
201
+ account: {
202
+ string: true,
203
+ desc: "AWS Account number like, 1243944546"
204
+ },
205
+ region: {
206
+ string: true,
207
+ desc: "AWS region like, us-east-1"
208
+ },
209
+ profile: {
210
+ string: true,
211
+ desc: "AWS configured profile"
212
+ },
213
+ baseParameterPath: {
214
+ string: true,
215
+ desc: "SSM parameter path base where configs like secrets and infrastucture managed items are set"
216
+ }
217
+ };
223
218
  };
224
219
 
225
220
  // src/commands/params/get.ts
226
- var import_chalk = __toESM(require("chalk"));
227
221
  var GetCommand = class {
228
222
  command = "get [path]";
229
223
  describe = "Get all parameters under the base path";
230
224
  builder = (args) => {
231
- const config = (0, import_axiom_config2.loadConfig)();
232
225
  args.options({ ...commonOptions(), ...awsOptions() });
233
226
  args.positional("path", {
234
227
  type: "string",
235
228
  describe: `OPTIONAL path to parameter. Supports absolute and relative paths.
236
229
  Example:
237
- "/root/myParam" or "service/secret" (which translates to, "${buildPath(
238
- config,
239
- "service/secret"
240
- )})`
230
+ "/root/myParam" or "service/secret"`
241
231
  });
242
232
  return args;
243
233
  };
244
234
  handler = async (args) => {
245
- const config = (0, import_axiom_config2.loadConfig)({ env: args.env });
235
+ const config = await (0, import_axiom_config2.loadConfig)({ env: args.env });
246
236
  const collection = new import_axiom_aws_sdk.ParameterCollection(
247
237
  config.aws?.baseParameterPath,
248
238
  new import_client_ssm.SSMClient({
@@ -259,7 +249,7 @@ Example:
259
249
  params.forEach((parameter) => {
260
250
  console.log(
261
251
  import_chalk.default.gray(
262
- parameter.Name?.replace(/\/([^/]+)$/, "/" + import_chalk.default.bold.green("$1"))
252
+ parameter.Name?.replace(/\/([^/]+)$/, `/${import_chalk.default.bold.green("$1")}`)
263
253
  ),
264
254
  import_chalk.default.bold.white(parameter.Value)
265
255
  );
@@ -268,22 +258,31 @@ Example:
268
258
  };
269
259
 
270
260
  // src/commands/params/set.ts
271
- var import_axiom_config3 = require("@dsmrt/axiom-config");
272
- var import_inquirer2 = __toESM(require("inquirer"));
273
261
  var import_client_ssm2 = require("@aws-sdk/client-ssm");
262
+ var import_axiom_config3 = require("@dsmrt/axiom-config");
274
263
  var import_chalk2 = __toESM(require("chalk"));
264
+ var import_inquirer2 = __toESM(require("inquirer"));
265
+
266
+ // src/commands/params/utils.ts
267
+ var buildPath = (config, path) => {
268
+ if (path === void 0) {
269
+ return config.aws?.baseParameterPath;
270
+ }
271
+ if (/^\//.test(path)) {
272
+ return path;
273
+ }
274
+ return `${config.aws?.baseParameterPath.replace(/\/$/, "")}/${path}`;
275
+ };
276
+
277
+ // src/commands/params/set.ts
275
278
  var SetCommand = class {
276
279
  command = "set <path> <value>";
277
280
  describe = "Set all parameters under the base path";
278
281
  builder = (args) => {
279
- const config = (0, import_axiom_config3.loadConfig)();
280
282
  args.positional("path", {
281
283
  type: "string",
282
284
  describe: `Path to parameter. Supports absolute and relative paths.
283
- Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
284
- config,
285
- "service/secret"
286
- )})`
285
+ Example: "/root/myParam" or "service/secret"`
287
286
  });
288
287
  args.demandOption("path", "Path is required");
289
288
  args.positional("value", {
@@ -312,7 +311,7 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
312
311
  });
313
312
  };
314
313
  handler = async (args) => {
315
- const config = (0, import_axiom_config3.loadConfig)({ env: args.env });
314
+ const config = await (0, import_axiom_config3.loadConfig)({ env: args.env });
316
315
  if (args.force !== true) {
317
316
  const res = await import_inquirer2.default.prompt({
318
317
  type: "confirm",
@@ -341,24 +340,19 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
341
340
  };
342
341
 
343
342
  // src/commands/params/delete.ts
343
+ var import_client_ssm3 = require("@aws-sdk/client-ssm");
344
344
  var import_axiom_config4 = require("@dsmrt/axiom-config");
345
345
  var import_inquirer3 = __toESM(require("inquirer"));
346
- var import_client_ssm3 = require("@aws-sdk/client-ssm");
347
346
  var log = console.log;
348
347
  var DeleteCommand = class {
349
348
  command = "delete <path>";
350
349
  describe = "Delete SSM parameters";
351
350
  client;
352
351
  builder = (args) => {
353
- const config = (0, import_axiom_config4.loadConfig)();
354
352
  args.positional("path", {
355
353
  type: "string",
356
354
  describe: `Path to parameter. Supports absolute and relative paths.
357
- Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
358
- config,
359
- "service/secret"
360
- )})`,
361
- default: config.aws?.baseParameterPath,
355
+ Example: "/root/myParam" or "service/secret"`,
362
356
  demandOption: true
363
357
  }).demandOption("path", "Path is required");
364
358
  args.option("force", {
@@ -370,7 +364,7 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
370
364
  return args;
371
365
  };
372
366
  handler = async (args) => {
373
- const config = (0, import_axiom_config4.loadConfig)({ env: args.env });
367
+ const config = await (0, import_axiom_config4.loadConfig)({ env: args.env });
374
368
  const path = buildPath(args, args.path);
375
369
  const client = new import_client_ssm3.SSMClient({
376
370
  region: config.aws?.region,
@@ -402,7 +396,6 @@ Example: "/root/myParam" or "service/secret" (which translates to, "${buildPath(
402
396
  };
403
397
 
404
398
  // src/bin/axiom.ts
405
- var import_yargs = __toESM(require("yargs"));
406
399
  (0, import_yargs.default)(process.argv.slice(2)).env("AXIOM").scriptName("axiom").option("config", {
407
400
  alias: "c",
408
401
  string: true
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  SetCommand,
7
7
  awsOptions,
8
8
  commonOptions
9
- } from "./chunk-XDVNYWAQ.mjs";
9
+ } from "./chunk-72DOPOLO.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": "0.3.0",
3
+ "version": "1.0.0",
4
4
  "description": "axiom cli for managing configs including secrets",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,35 +28,32 @@
28
28
  },
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@changesets/cli": "^2.27.1",
32
- "@types/inquirer": "^8.0.0",
33
- "@types/node": "^20.9.0",
34
- "@types/yargs": "^17.0.31",
35
- "@typescript-eslint/eslint-plugin": "^6.12.0",
36
- "@typescript-eslint/parser": "^6.12.0",
37
- "aws-sdk-client-mock": "^3.0.0",
38
- "eslint": "^8.54.0",
39
- "prettier": "^3.1.0",
40
- "ts-node": "^10.9.1",
41
- "tsup": "^8.0.1",
42
- "typescript": "^5.2.2",
43
- "@vitest/coverage-v8": "^1.2.1",
44
- "vitest": "^1.2.1"
31
+ "@biomejs/biome": "^2.3.8",
32
+ "@changesets/cli": "^2.27.11",
33
+ "@types/inquirer": "^8.2.10",
34
+ "@types/node": "^22.12.0",
35
+ "@types/yargs": "^17.0.33",
36
+ "@vitest/coverage-v8": "^4.0.0",
37
+ "aws-sdk-client-mock": "^3.1.0",
38
+ "ts-node": "^10.9.2",
39
+ "tsup": "^8.3.5",
40
+ "typescript": "^5.7.2",
41
+ "vitest": "^4.0.0"
45
42
  },
46
43
  "dependencies": {
47
- "@aws-sdk/client-ssm": "^3.451.0",
48
- "@aws-sdk/client-sts": "^3.454.0",
49
- "@aws-sdk/credential-providers": "^3.454.0",
50
- "@aws-sdk/types": "^3.451.0",
44
+ "@aws-sdk/client-ssm": "^3.716.0",
45
+ "@aws-sdk/client-sts": "^3.716.0",
46
+ "@aws-sdk/credential-providers": "^3.716.0",
47
+ "@aws-sdk/types": "^3.714.0",
51
48
  "chalk": "^4.1.2",
52
- "inquirer": "^8.0.0",
49
+ "inquirer": "^8.2.6",
53
50
  "yargs": "^17.7.2",
54
- "@dsmrt/axiom-aws-sdk": "^0.2.1",
55
- "@dsmrt/axiom-config": "^0.2.2"
51
+ "@dsmrt/axiom-aws-sdk": "^1.0.0",
52
+ "@dsmrt/axiom-config": "^1.0.0"
56
53
  },
57
54
  "scripts": {
58
- "lint": "eslint ./src/ ./src/aws ./src/bin --ext .ts",
59
- "lint:fix": "eslint ./src/ ./src/aws ./src/bin --ext .ts --fix",
55
+ "lint": "biome lint",
56
+ "lint:fix": "biome lint --fix",
60
57
  "test": "vitest run --coverage",
61
58
  "watch": "vitest watch --coverage",
62
59
  "build": "tsup --entry ./src/bin/axiom.ts --entry ./src/index.ts --format cjs,esm --dts --clean",
package/tsconfig.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "es2022",
4
- "module": "commonjs",
5
- "esModuleInterop": true,
6
- "forceConsistentCasingInFileNames": true,
7
- "strict": true,
8
- "skipLibCheck": true,
9
- "noEmit": true
10
- },
11
- "include": ["src/index.ts"]
2
+ "compilerOptions": {
3
+ "target": "es2022",
4
+ "module": "commonjs",
5
+ "esModuleInterop": true,
6
+ "forceConsistentCasingInFileNames": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "noEmit": true
10
+ },
11
+ "include": ["src/index.ts"]
12
12
  }
@@ -0,0 +1,14 @@
1
+ // vitest.config.ts
2
+ import { defineConfig } from "vitest/config";
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ include: ["src/**/*.test.ts"],
7
+ coverage: {
8
+ provider: "v8",
9
+ all: true,
10
+ exclude: ["lib/**/*", "src/__mocks__/**/*"],
11
+ reporter: ["text-summary", "json-summary"],
12
+ },
13
+ },
14
+ });