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.
- package/dist/practices/cicd-common/best-practice/.github/workflows/.test.yml +51 -42
- package/dist/practices/cicd-package/bad-practices/old-names/.github/workflows/publish-on-tag.yml.declapract +3 -0
- package/dist/practices/cicd-service/best-practice/.github/workflows/.deploy-sls.yml +10 -2
- package/dist/practices/environments/best-practice/src/utils/environment.ts +4 -0
- package/dist/practices/git/best-practice/.gitignore.declapract.ts +1 -0
- package/dist/practices/testing/best-practice/jest.unit.env.ts.declapract.ts +1 -0
- package/package.json +1 -1
|
@@ -26,20 +26,29 @@ jobs:
|
|
|
26
26
|
- name: checkout
|
|
27
27
|
uses: actions/checkout@v3
|
|
28
28
|
|
|
29
|
-
- name: set node
|
|
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:
|
|
36
|
-
|
|
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
|
|
39
|
-
|
|
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: ${{
|
|
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
|
|
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:
|
|
61
|
-
uses: actions/cache@
|
|
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-${{
|
|
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
|
|
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:
|
|
83
|
-
uses: actions/cache@
|
|
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-${{
|
|
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
|
|
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:
|
|
105
|
-
uses: actions/cache@
|
|
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-${{
|
|
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
|
|
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:
|
|
127
|
-
uses: actions/cache@
|
|
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-${{
|
|
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
|
|
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:
|
|
149
|
-
uses: actions/cache@
|
|
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-${{
|
|
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
|
|
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:
|
|
171
|
-
uses: actions/cache@
|
|
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-${{
|
|
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
|
|
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:
|
|
212
|
-
uses: actions/cache@
|
|
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-${{
|
|
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 != '' }}"
|
|
@@ -54,8 +54,16 @@ jobs:
|
|
|
54
54
|
&& echo 'wrong aws account' && exit 1 \
|
|
55
55
|
|| echo 'correct aws account';
|
|
56
56
|
|
|
57
|
-
- name:
|
|
58
|
-
|
|
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
|
|
|
@@ -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