@bifravst/http-api-mock 3.0.9 → 3.0.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 CHANGED
@@ -29,13 +29,13 @@ node node_modules/@bifravst/http-api-mock/dist/cdk/http-api-mock.js
29
29
  ## Describe a mock HTTP API
30
30
 
31
31
  ```bash
32
- node node_modules/@bifravst/http-api-mock/dist/cdk/http-api-mock.js describe <stackName>
32
+ node node_modules/@bifravst/http-api-mock/dist/cdk/http-api-mock.js --describe --stack-name <stackName>
33
33
  ```
34
34
 
35
35
  ## Delete a mock HTTP API
36
36
 
37
37
  ```bash
38
- node node_modules/@bifravst/http-api-mock/dist/cdk/http-api-mock.js destroy <stackName>
38
+ node node_modules/@bifravst/http-api-mock/dist/cdk/http-api-mock.js --destroy --stack-name <stackName>
39
39
  ```
40
40
 
41
41
  ## Node & NPM
@@ -12,6 +12,15 @@ import { fileURLToPath } from 'node:url';
12
12
  import pJSON from '../package.json' with { type: 'json' };
13
13
  import { randomString } from '../src/randomString.js';
14
14
  import { HTTPAPIMockApp } from './App.js';
15
+ const loadConfig = async () => {
16
+ try {
17
+ const config = JSON.parse(await fs.readFile(path.join(process.cwd(), 'http-api-mock.json'), 'utf-8'));
18
+ return config;
19
+ }
20
+ catch {
21
+ return {};
22
+ }
23
+ };
15
24
  const options = commandLineArgs([
16
25
  {
17
26
  name: 'config',
@@ -23,23 +32,18 @@ const options = commandLineArgs([
23
32
  type: Boolean,
24
33
  defaultValue: false,
25
34
  },
35
+ {
36
+ name: 'stack-name',
37
+ type: String,
38
+ defaultValue: process.env.HTTP_API_MOCK_STACK_NAME ??
39
+ (await loadConfig())?.stackName ??
40
+ `http-api-mock-${randomString()}`,
41
+ },
26
42
  ]);
27
- const loadConfig = async () => {
28
- try {
29
- const config = JSON.parse(await fs.readFile(path.join(process.cwd(), 'http-api-mock.json'), 'utf-8'));
30
- return config;
31
- }
32
- catch {
33
- return {};
34
- }
35
- };
36
- const stackName = process.env.HTTP_API_MOCK_STACK_NAME ??
37
- (await loadConfig())?.stackName ??
38
- `http-api-mock-${randomString()}`;
39
43
  const saveConfig = async () => {
40
44
  writeFileSync(path.join(process.cwd(), 'http-api-mock.json'), JSON.stringify({
41
- stackName,
42
- ...(await stackOutput(new CloudFormationClient({}))(stackName)),
45
+ stackName: options['stack-name'],
46
+ ...(await stackOutput(new CloudFormationClient({}))(options['stack-name'])),
43
47
  }, null, 2));
44
48
  };
45
49
  if (options.config === true) {
@@ -55,7 +59,7 @@ await fs.mkdir(layersDir);
55
59
  const dependencies = [
56
60
  '@bifravst/from-env',
57
61
  ];
58
- const app = new HTTPAPIMockApp(stackName, {
62
+ const app = new HTTPAPIMockApp(options['stack-name'], {
59
63
  lambdaSources: {
60
64
  httpApiMock: await packLambdaFromPath({
61
65
  id: 'httpApiMock',
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifravst/http-api-mock",
3
- "version": "3.0.9",
3
+ "version": "3.0.10",
4
4
  "description": "Helper functions for AWS lambdas written in TypeScript.",
5
5
  "exports": {
6
6
  "./*": {
@@ -72,10 +72,10 @@
72
72
  ],
73
73
  "prettier": "@bifravst/prettier-config",
74
74
  "dependencies": {
75
+ "@aws-cdk/toolkit-lib": "1.38.2",
75
76
  "@aws-sdk/client-cloudformation": "3.1111.0",
76
77
  "@aws-sdk/client-dynamodb": "3.1111.0",
77
78
  "@aws-sdk/client-sts": "3.1111.0",
78
- "@aws-cdk/toolkit-lib": "1.38.2",
79
79
  "@aws-sdk/util-dynamodb": "3.996.9",
80
80
  "@bifravst/aws-cdk-lambda-helpers": "5.0.4",
81
81
  "@bifravst/cloudformation-helpers": "10.0.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifravst/http-api-mock",
3
- "version": "3.0.9",
3
+ "version": "3.0.10",
4
4
  "description": "Helper functions for AWS lambdas written in TypeScript.",
5
5
  "exports": {
6
6
  "./*": {
@@ -72,10 +72,10 @@
72
72
  ],
73
73
  "prettier": "@bifravst/prettier-config",
74
74
  "dependencies": {
75
+ "@aws-cdk/toolkit-lib": "1.38.2",
75
76
  "@aws-sdk/client-cloudformation": "3.1111.0",
76
77
  "@aws-sdk/client-dynamodb": "3.1111.0",
77
78
  "@aws-sdk/client-sts": "3.1111.0",
78
- "@aws-cdk/toolkit-lib": "1.38.2",
79
79
  "@aws-sdk/util-dynamodb": "3.996.9",
80
80
  "@bifravst/aws-cdk-lambda-helpers": "5.0.4",
81
81
  "@bifravst/cloudformation-helpers": "10.0.1",