declapract-typescript-ehmpathy 0.23.7 → 0.24.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.
@@ -26,20 +26,29 @@ jobs:
26
26
  - name: checkout
27
27
  uses: actions/checkout@v3
28
28
 
29
- - name: set node version
29
+ - name: set node-version
30
30
  uses: actions/setup-node@v3
31
31
  with:
32
32
  node-version-file: '.nvmrc'
33
33
  cache: 'npm'
34
34
 
35
- - name: install
36
- run: npm ci --ignore-scripts
35
+ - name: node-modules cache get
36
+ uses: actions/cache/restore@v3
37
+ id: cache
38
+ with:
39
+ path: ./node_modules
40
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
41
+
42
+ - name: node-modules cache miss install
43
+ if: steps.cache.outputs.cache-hit != 'true'
44
+ run: npm ci --ignore-scripts --prefer-offline --no-audit
37
45
 
38
- - name: cache node modules
39
- uses: actions/cache@v2
46
+ - name: node-modules cache set
47
+ if: steps.cache.outputs.cache-hit != 'true'
48
+ uses: actions/cache/save@v3
40
49
  with:
41
- path: node_modules
42
- key: ${{ runner.os }}-node-${{ github.sha }}
50
+ path: ./node_modules
51
+ key: ${{ steps.cache.outputs.cache-primary-key }}
43
52
 
44
53
  # run tests in parallel
45
54
  test-commits:
@@ -51,17 +60,17 @@ jobs:
51
60
  with:
52
61
  fetch-depth: 0 # we need all commits to test:commits
53
62
 
54
- - name: set node version
63
+ - name: set node-version
55
64
  uses: actions/setup-node@v3
56
65
  with:
57
66
  node-version-file: '.nvmrc'
58
67
  cache: 'npm'
59
68
 
60
- - name: grab node_modules from cache
61
- uses: actions/cache@v2
69
+ - name: get node-modules from cache
70
+ uses: actions/cache/restore@v3
62
71
  with:
63
- path: node_modules
64
- key: ${{ runner.os }}-node-${{ github.sha }}
72
+ path: ./node_modules
73
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
65
74
 
66
75
  - name: test:commits
67
76
  run: npm run test:commits
@@ -73,17 +82,17 @@ jobs:
73
82
  - name: checkout
74
83
  uses: actions/checkout@v3
75
84
 
76
- - name: set node version
85
+ - name: set node-version
77
86
  uses: actions/setup-node@v3
78
87
  with:
79
88
  node-version-file: '.nvmrc'
80
89
  cache: 'npm'
81
90
 
82
- - name: grab node_modules from cache
83
- uses: actions/cache@v2
91
+ - name: get node-modules from cache
92
+ uses: actions/cache/restore@v3
84
93
  with:
85
- path: node_modules
86
- key: ${{ runner.os }}-node-${{ github.sha }}
94
+ path: ./node_modules
95
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
87
96
 
88
97
  - name: test:types
89
98
  run: npm run test:types
@@ -95,17 +104,17 @@ jobs:
95
104
  - name: checkout
96
105
  uses: actions/checkout@v3
97
106
 
98
- - name: set node version
107
+ - name: set node-version
99
108
  uses: actions/setup-node@v3
100
109
  with:
101
110
  node-version-file: '.nvmrc'
102
111
  cache: 'npm'
103
112
 
104
- - name: grab node_modules from cache
105
- uses: actions/cache@v2
113
+ - name: get node-modules from cache
114
+ uses: actions/cache/restore@v3
106
115
  with:
107
- path: node_modules
108
- key: ${{ runner.os }}-node-${{ github.sha }}
116
+ path: ./node_modules
117
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
109
118
 
110
119
  - name: test:format
111
120
  run: npm run test:format
@@ -117,17 +126,17 @@ jobs:
117
126
  - name: checkout
118
127
  uses: actions/checkout@v3
119
128
 
120
- - name: set node version
129
+ - name: set node-version
121
130
  uses: actions/setup-node@v3
122
131
  with:
123
132
  node-version-file: '.nvmrc'
124
133
  cache: 'npm'
125
134
 
126
- - name: grab node_modules from cache
127
- uses: actions/cache@v2
135
+ - name: get node-modules from cache
136
+ uses: actions/cache/restore@v3
128
137
  with:
129
- path: node_modules
130
- key: ${{ runner.os }}-node-${{ github.sha }}
138
+ path: ./node_modules
139
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
131
140
 
132
141
  - name: test:lint
133
142
  run: npm run test:lint
@@ -139,17 +148,17 @@ jobs:
139
148
  - name: checkout
140
149
  uses: actions/checkout@v3
141
150
 
142
- - name: set node version
151
+ - name: set node-version
143
152
  uses: actions/setup-node@v3
144
153
  with:
145
154
  node-version-file: '.nvmrc'
146
155
  cache: 'npm'
147
156
 
148
- - name: grab node_modules from cache
149
- uses: actions/cache@v2
157
+ - name: get node-modules from cache
158
+ uses: actions/cache/restore@v3
150
159
  with:
151
- path: node_modules
152
- key: ${{ runner.os }}-node-${{ github.sha }}
160
+ path: ./node_modules
161
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
153
162
 
154
163
  - name: test:unit
155
164
  run: npm run test:unit
@@ -161,17 +170,17 @@ jobs:
161
170
  - name: checkout
162
171
  uses: actions/checkout@v3
163
172
 
164
- - name: set node version
173
+ - name: set node-version
165
174
  uses: actions/setup-node@v3
166
175
  with:
167
176
  node-version-file: '.nvmrc'
168
177
  cache: 'npm'
169
178
 
170
- - name: grab node_modules from cache
171
- uses: actions/cache@v2
179
+ - name: get node-modules from cache
180
+ uses: actions/cache/restore@v3
172
181
  with:
173
- path: node_modules
174
- key: ${{ runner.os }}-node-${{ github.sha }}
182
+ path: ./node_modules
183
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
175
184
 
176
185
  - name: configure aws credentials
177
186
  if: "${{ inputs.aws-account-id != '' }}"
@@ -202,17 +211,17 @@ jobs:
202
211
  - name: checkout
203
212
  uses: actions/checkout@v3
204
213
 
205
- - name: set node version
214
+ - name: set node-version
206
215
  uses: actions/setup-node@v3
207
216
  with:
208
217
  node-version-file: '.nvmrc'
209
218
  cache: 'npm'
210
219
 
211
- - name: grab node_modules from cache
212
- uses: actions/cache@v2
220
+ - name: get node-modules from cache
221
+ uses: actions/cache/restore@v3
213
222
  with:
214
- path: node_modules
215
- key: ${{ runner.os }}-node-${{ github.sha }}
223
+ path: ./node_modules
224
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
216
225
 
217
226
  - name: configure aws credentials
218
227
  if: "${{ inputs.aws-account-id != '' }}"
@@ -0,0 +1,3 @@
1
+ import { FileCheckType } from 'declapract';
2
+
3
+ export const check = FileCheckType.EXISTS;
@@ -54,8 +54,16 @@ jobs:
54
54
  && echo 'wrong aws account' && exit 1 \
55
55
  || echo 'correct aws account';
56
56
 
57
- - name: install
58
- run: npm ci --ignore-scripts
57
+ - name: node-modules cache get
58
+ uses: actions/cache/restore@v3
59
+ id: cache
60
+ with:
61
+ path: ./node_modules
62
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
63
+
64
+ - name: node-modules cache miss install
65
+ if: steps.cache.outputs.cache-hit != 'true'
66
+ run: npm ci --ignore-scripts --prefer-offline --no-audit
59
67
 
60
68
  - name: deploy
61
69
  run: STAGE=${{ inputs.stage }} DEPLOYER_NAME=$GITHUB_ACTOR npm run deploy
@@ -1,8 +1,11 @@
1
+ import { createIsOfEnum } from 'type-fns';
2
+
1
3
  export enum Stage {
2
4
  PRODUCTION = 'prod',
3
5
  DEVELOPMENT = 'dev',
4
6
  TEST = 'test',
5
7
  }
8
+ export const isOfStage = createIsOfEnum(Stage);
6
9
 
7
10
  /**
8
11
  * this allows us to infer what the stage should be in environments that do not have STAGE specified
@@ -24,6 +27,7 @@ const inferStageFromNodeEnv = () => {
24
27
  const getEnvironment = () => {
25
28
  const stage = process.env.STAGE ?? inferStageFromNodeEnv(); // figure it out from NODE_ENV if not explicitly defined
26
29
  if (!stage) throw new Error('process.env.STAGE must be defined');
30
+ if (!isOfStage(stage)) throw new Error(`invalid stage defined '${stage}'`);
27
31
  return { stage };
28
32
  };
29
33
 
@@ -4,6 +4,7 @@ import uniq from 'lodash.uniq';
4
4
 
5
5
  const expectedIgnores = [
6
6
  '*.log',
7
+ '*.tsbuildinfo',
7
8
  '.artifact', // deployment artifacts from `simple-artifact-builder` are produced here
8
9
  '.env',
9
10
  '.serverless',
@@ -18,6 +18,7 @@ export const contents: FileContentsFunction = async (context) => {
18
18
  `jest.mock('./src/utils/config/getConfig', () => ({
19
19
  getConfig: jest.fn().mockImplementation(() => require('./config/test.json')), // mock that getConfig just returns plaintext test env config in unit tests
20
20
  }));
21
+
21
22
  `,
22
23
  '',
23
24
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "declapract-typescript-ehmpathy",
3
- "version": "0.23.7",
3
+ "version": "0.24.0",
4
4
  "description": "declapract best practices declarations for typescript",
5
5
  "main": "src/index.js",
6
6
  "repository": "ehmpathy/declapract-typescript-ehmpathy",