@mimik/local 7.1.0 → 7.1.1
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 +332 -223
- package/dotFiles/eslint.config.js +10 -12
- package/eslint.config.js +10 -6
- package/index.js +358 -273
- package/lib/common.js +149 -142
- package/lib/helpers.js +12 -11
- package/lib/rp-axios-wrapper.js +4 -4
- package/lib/tasks.js +35 -55
- package/manual-test/getAPI.js +2 -2
- package/manual-test/testMerge.js +3 -3
- package/package.json +6 -5
- package/configuration/config.js +0 -57
package/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/* eslint-disable prefer-template, no-console */
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
IGNORE,
|
|
3
|
+
DEFAULT,
|
|
4
|
+
DUMMY,
|
|
6
5
|
LITERAL,
|
|
7
6
|
SYSTEM_NAME,
|
|
8
7
|
TEST,
|
|
9
|
-
shellFile,
|
|
10
|
-
testJsonFile,
|
|
11
8
|
} from './lib/common.js';
|
|
12
9
|
import {
|
|
13
10
|
baseUrl,
|
|
@@ -20,7 +17,7 @@ import {
|
|
|
20
17
|
start2shell,
|
|
21
18
|
write,
|
|
22
19
|
} from './lib/helpers.js';
|
|
23
|
-
import { dirname, join } from 'path';
|
|
20
|
+
import { dirname, join } from 'node:path';
|
|
24
21
|
import {
|
|
25
22
|
getAPI,
|
|
26
23
|
getAdminToken,
|
|
@@ -34,9 +31,9 @@ import {
|
|
|
34
31
|
startSetup,
|
|
35
32
|
} from './lib/tasks.js';
|
|
36
33
|
import { commitCheckMsg } from '@mimik/git-hooks';
|
|
37
|
-
import { fileURLToPath } from 'url';
|
|
34
|
+
import { fileURLToPath } from 'node:url';
|
|
38
35
|
import find from 'lodash.find';
|
|
39
|
-
import
|
|
36
|
+
import { writeFileSync } from 'node:fs';
|
|
40
37
|
|
|
41
38
|
colors.setTheme({
|
|
42
39
|
success: 'green',
|
|
@@ -59,111 +56,122 @@ const getBasePath = apiDef => apiDef.basePath || apiDef.servers[FIRST].url;
|
|
|
59
56
|
* or
|
|
60
57
|
* import { mSTTestSetup, mSTSetup, mITTestSetup, mITSetup, testSetup, setup, dotFiles, scripts, unScripts, commitCheckMsg, start2process, testJsonFile} from '@mimik/local';
|
|
61
58
|
*
|
|
62
|
-
* @description
|
|
59
|
+
* @description Utilities for local deployment.
|
|
63
60
|
*
|
|
64
61
|
* The following files are expected to exist:
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
62
|
+
*
|
|
63
|
+
* In the directory **above** the server’s root directory: `mSTConfig.json`, `mIDConfig.json`, `mITConfig.json`, `sumoLog.json`, `kinesisLog.json`, `s3Log.json`, `customerConfig.json`, `key.json`, and `locationConfig.json`. If they don’t exist when the script launches, defaults will be set up.
|
|
64
|
+
*
|
|
65
|
+
* - For `mSTConfig.json`:
|
|
66
|
+
* ```javascript
|
|
68
67
|
* {
|
|
69
|
-
* "basePath": "
|
|
70
|
-
* "protocol": "
|
|
71
|
-
* "domainName": "
|
|
72
|
-
* "port": "
|
|
73
|
-
* "passphrase": "
|
|
74
|
-
* "update": "
|
|
68
|
+
* "basePath": "Base path of the mST server, e.g., `/mST/v1`",
|
|
69
|
+
* "protocol": "Protocol for the mST server, e.g., `http:` (default: `http:`)",
|
|
70
|
+
* "domainName": "Domain name of the mST server",
|
|
71
|
+
* "port": "Port for the mST server, e.g., `8025`",
|
|
72
|
+
* "passphrase": "Passphrase used to generate the public/private key pair; if not present, mST will use a regular key",
|
|
73
|
+
* "update": "Whether mST should be updated (default: `false`). If the address is localhost, mST will be updated.",
|
|
75
74
|
* "admin": {
|
|
76
|
-
* "clientId": "
|
|
77
|
-
* "clientSecret": "secret
|
|
75
|
+
* "clientId": "Client ID used to obtain an mST admin token, e.g., `12345`",
|
|
76
|
+
* "clientSecret": "Client secret used to obtain an mST admin token, e.g., `timeForSecret`"
|
|
78
77
|
* }
|
|
79
78
|
* }
|
|
80
79
|
* ```
|
|
81
|
-
* `domainName` must
|
|
82
|
-
*
|
|
83
|
-
*
|
|
80
|
+
* `domainName` must exist. When `domainName` is `localhost`, `port` must also exist. When `domainName` is `localhost`, the local IP will replace `localhost`. When `domainName` is different from `localhost`, `port` is ignored.
|
|
81
|
+
*
|
|
82
|
+
* - For `mIDConfig.json`:
|
|
83
|
+
* ```javascript
|
|
84
84
|
* {
|
|
85
|
-
* "basePath": "
|
|
86
|
-
* "protocol": "
|
|
87
|
-
* "domainName": "
|
|
88
|
-
* "port": "
|
|
85
|
+
* "basePath": "Base path of the mID server, e.g., `/mID/v1`",
|
|
86
|
+
* "protocol": "Protocol for the mID server, e.g., `http:` (default: `http:`)",
|
|
87
|
+
* "domainName": "Domain name of the mID server",
|
|
88
|
+
* "port": "Port for the mID server, e.g., `8015`",
|
|
89
89
|
* "implicit": {
|
|
90
|
-
* "key": "
|
|
91
|
-
* "audience": "
|
|
90
|
+
* "key": "Key to sign and verify the signature of a user token, e.g., `timeForSecret`",
|
|
91
|
+
* "audience": "URL defining the audience used in the user token, e.g., `https://mimik`"
|
|
92
92
|
* }
|
|
93
93
|
* }
|
|
94
94
|
* ```
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
95
|
+
* The same `domainName`/`port` rules as in `mSTConfig.json` apply.
|
|
96
|
+
*
|
|
97
|
+
* - For `mITConfig.json`:
|
|
98
|
+
* ```javascript
|
|
98
99
|
* {
|
|
99
|
-
* "basePath": "
|
|
100
|
-
* "protocol": "
|
|
101
|
-
* "domainName": "
|
|
102
|
-
* "port": "
|
|
100
|
+
* "basePath": "Base path of the mIT server, e.g., `/mIT/v1`",
|
|
101
|
+
* "protocol": "Protocol for the mIT server, e.g., `http:` (default: `http:`)",
|
|
102
|
+
* "domainName": "Domain name of the mIT server",
|
|
103
|
+
* "port": "Port for the mIT server, e.g., `8050`"
|
|
103
104
|
* }
|
|
104
105
|
* ```
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
106
|
+
* The same `domainName`/`port` rules as in `mSTConfig.json` apply.
|
|
107
|
+
*
|
|
108
|
+
* - For `sumoLog.json`:
|
|
109
|
+
* ```javascript
|
|
108
110
|
* {
|
|
109
111
|
* "<serverType>": {
|
|
110
|
-
* "url": "
|
|
111
|
-
* "code": "code for
|
|
112
|
+
* "url": "Base URL for Sumo Logic, e.g., `https://endpoint2.collection.us2.sumologic.com/receiver/v1/http/`",
|
|
113
|
+
* "code": "The code for Sumo Logic (the part after the last `/` in the URL)"
|
|
112
114
|
* },
|
|
113
115
|
* "default": {
|
|
114
|
-
* "url": "
|
|
115
|
-
* "code": "code for
|
|
116
|
+
* "url": "Base URL for Sumo Logic, e.g., `https://endpoint2.collection.us2.sumologic.com/receiver/v1/http/`",
|
|
117
|
+
* "code": "The code for Sumo Logic (the part after the last `/` in the URL)"
|
|
118
|
+
* }
|
|
116
119
|
* }
|
|
117
120
|
* ```
|
|
118
|
-
*
|
|
119
|
-
*
|
|
121
|
+
*
|
|
122
|
+
* - For `kinesisLog.json`:
|
|
123
|
+
* ```javascript
|
|
120
124
|
* {
|
|
121
|
-
* "region": "
|
|
122
|
-
* "accessKeyId": "
|
|
123
|
-
* "secretAccessKey": "
|
|
124
|
-
* "streamNameInfo": "
|
|
125
|
-
* "streamNameError": "
|
|
126
|
-
* "streamNameOther": "
|
|
125
|
+
* "region": "Region of the Kinesis implementation",
|
|
126
|
+
* "accessKeyId": "Access key ID for Kinesis",
|
|
127
|
+
* "secretAccessKey": "Secret access key for Kinesis",
|
|
128
|
+
* "streamNameInfo": "Name of the Kinesis stream for info",
|
|
129
|
+
* "streamNameError": "Name of the Kinesis stream for errors",
|
|
130
|
+
* "streamNameOther": "Name of the Kinesis stream for all other levels"
|
|
127
131
|
* }
|
|
128
132
|
* ```
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* "
|
|
134
|
-
* "
|
|
135
|
-
* "
|
|
136
|
-
* "
|
|
137
|
-
* "
|
|
138
|
-
* "
|
|
139
|
-
*
|
|
133
|
+
*
|
|
134
|
+
* - For `s3Log.json`:
|
|
135
|
+
* ```javascript
|
|
136
|
+
* {
|
|
137
|
+
* "region": "Region of the S3 implementation",
|
|
138
|
+
* "accessKeyId": "Access key ID for S3",
|
|
139
|
+
* "secretAccessKey": "Secret access key for S3",
|
|
140
|
+
* "bucketname": "Name of the S3 bucket used to store information",
|
|
141
|
+
* "maxEvents": "Number of events buffered before sending to S3 (integer)",
|
|
142
|
+
* "timeout": "Number of seconds before a timeout triggers sending to S3 (integer)",
|
|
143
|
+
* "maxSize": "Maximum size in bytes before sending to S3 (integer)"
|
|
144
|
+
* }
|
|
140
145
|
* ```
|
|
146
|
+
*
|
|
141
147
|
* - for `key.json`:
|
|
142
|
-
* ```
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* "username": "
|
|
146
|
-
* "password": "
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
148
|
+
* ```javascript
|
|
149
|
+
* {
|
|
150
|
+
* "bitbucket": {
|
|
151
|
+
* "username": "Username to access the Bitbucket account",
|
|
152
|
+
* "password": "Password to access the Bitbucket account"
|
|
153
|
+
* },
|
|
154
|
+
* "swaggerhub": "Key to access private APIs on SwaggerHub"
|
|
155
|
+
* }
|
|
150
156
|
* ```
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
+
*
|
|
158
|
+
* - For `locationConfig.json`:
|
|
159
|
+
* ```javascript
|
|
160
|
+
* {
|
|
161
|
+
* "url": "URL of the location provider",
|
|
162
|
+
* "key": "API key used to make requests to the location provider"
|
|
163
|
+
* }
|
|
157
164
|
* ```
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* -
|
|
162
|
-
*
|
|
163
|
-
* Additionally `example-testStart.json` is used
|
|
164
|
-
* The configuration of these files depends on the configuration parameters
|
|
165
|
-
*
|
|
166
|
-
*
|
|
165
|
+
*
|
|
166
|
+
* A property may be defined for each `serverType` involved. If the `serverType` does not exist, the `default` entry is used.
|
|
167
|
+
*
|
|
168
|
+
* - for `customerConfig.json`: see `mST` `README.md` file for an example of a customer configuration. This may have to be updated to reflect the new server.
|
|
169
|
+
* - In the `local` directory under the server’s root directory: two files, `start.json` and `testStart.json`, may exist. `start.json` is used when `npm start` is executed; `testStart.json` is used when `npm test` is executed.
|
|
170
|
+
* If these files don’t exist, `example-start.json` is used to create `start.json` and `testStart.json`. Additionally, `example-testStart.json` is used to create `testStart.json`; values in `example-testStart.json` take precedence over values in `example-start.json`.
|
|
171
|
+
* The configuration of these files depends on the server’s configuration parameters.
|
|
172
|
+
*
|
|
173
|
+
* Example `start.json` for `mIT`:
|
|
174
|
+
* ```javascript
|
|
167
175
|
* {
|
|
168
176
|
* "NODE_ENV": "local",
|
|
169
177
|
* "LOG_LEVEL": "debug",
|
|
@@ -176,29 +184,32 @@ const getBasePath = apiDef => apiDef.basePath || apiDef.servers[FIRST].url;
|
|
|
176
184
|
* "SERVER_SECURITY_SET": "off"
|
|
177
185
|
* }
|
|
178
186
|
* ```
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
187
|
+
*
|
|
188
|
+
* Although all files use the `.json` extension, you may still add `//` comments to make them more explicit or to remove parameters.
|
|
189
|
+
*
|
|
190
|
+
* Reserved environment variables used by the library for configuration:
|
|
191
|
+
* - `oauthImplicitNeeded`: if the service handles user tokens, the implicit configuration is required
|
|
192
|
+
* - `mIDNeeded`: if the service targets mID
|
|
183
193
|
* - `locationNeeded`: if location translation is needed
|
|
184
|
-
* - `standAlone`: if the service
|
|
194
|
+
* - `standAlone`: if the service must operate without other services (if the service has targets, 500 errors are likely)
|
|
185
195
|
*
|
|
186
|
-
* If SERVER_ID is not set in
|
|
196
|
+
* If `SERVER_ID` is not set in `start.json` or `testStart.json`, it will be assigned using `uuidv4`.
|
|
187
197
|
*
|
|
188
|
-
* For
|
|
189
|
-
* This file contains
|
|
190
|
-
* ```
|
|
198
|
+
* For tests, a JSON file (`server-test.json`) is created in the project root (`.`).
|
|
199
|
+
* This file contains information needed to start the tests:
|
|
200
|
+
* ```javascript
|
|
191
201
|
* {
|
|
192
|
-
* "start": "
|
|
193
|
-
* "CUSTOMER_NAME": "name
|
|
194
|
-
* "CUSTOMER_CODE": "code
|
|
195
|
-
* "BASE_PATH": "
|
|
196
|
-
* "MST_TOKEN": "mST admin token for creating clients
|
|
197
|
-
* "ADMIN_TOKEN": "
|
|
198
|
-
* "MID_TOKEN": "mID admin token for creating users when `authImplicitNeeded is set
|
|
202
|
+
* "start": "Information needed to set environment variables for the test",
|
|
203
|
+
* "CUSTOMER_NAME": "Customer name used to set up customer config",
|
|
204
|
+
* "CUSTOMER_CODE": "Customer code used to set up customer config (`not available for mST`)",
|
|
205
|
+
* "BASE_PATH": "Base path of the API",
|
|
206
|
+
* "MST_TOKEN": "mST admin token for creating clients (`not available in standAlone`)",
|
|
207
|
+
* "ADMIN_TOKEN": "Admin token of the service (`not available in standAlone`)",
|
|
208
|
+
* "MID_TOKEN": "mID admin token for creating users when `authImplicitNeeded` is set (`not available in standAlone`)"
|
|
199
209
|
* }
|
|
200
|
-
|
|
201
|
-
*
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* In `standAlone` mode, the test can obtain tokens using `oauth-helper-temp`.
|
|
202
213
|
*
|
|
203
214
|
*/
|
|
204
215
|
|
|
@@ -207,7 +218,7 @@ const mSTInit = (confType) => {
|
|
|
207
218
|
const config = init(regType, false, true);
|
|
208
219
|
const start = startSetup(config, startConfig);
|
|
209
220
|
|
|
210
|
-
getAPI(start.SWAGGER_FILE_DIRECTORY ||
|
|
221
|
+
getAPI(start.SWAGGER_FILE_DIRECTORY || DEFAULT.API_DIRECTORY, config.pack.swaggerFile, config.key)
|
|
211
222
|
.then((apiDefinition) => {
|
|
212
223
|
console.log('- mST base url: ' + config.mSTBaseUrl.info);
|
|
213
224
|
console.log('- mIT base url: ' + config.MITBaseUrl.info);
|
|
@@ -215,12 +226,12 @@ const mSTInit = (confType) => {
|
|
|
215
226
|
if (confType === TEST) {
|
|
216
227
|
start.CUSTOMER_NAME = SYSTEM_NAME;
|
|
217
228
|
start.BASE_PATH = getBasePath(apiDefinition);
|
|
218
|
-
return { file: testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
229
|
+
return { file: DEFAULT.FILE.testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
219
230
|
}
|
|
220
|
-
return { file: shellFile, content: start2shell(start), type: 'shell script' };
|
|
231
|
+
return { file: DEFAULT.FILE.shellFile, content: start2shell(start), type: 'shell script' };
|
|
221
232
|
})
|
|
222
233
|
.then((response) => {
|
|
223
|
-
|
|
234
|
+
writeFileSync(response.file, response.content);
|
|
224
235
|
console.log(`${regType}status: ` + 'completed'.success + ', ' + response.type.info + ' created at (' + response.file.info + ')');
|
|
225
236
|
})
|
|
226
237
|
.catch(err => exitError(regType, err));
|
|
@@ -234,7 +245,7 @@ const mITInit = (confType) => {
|
|
|
234
245
|
let start = startSetup(config, startConfig);
|
|
235
246
|
let authorization;
|
|
236
247
|
|
|
237
|
-
getAPI(start.SWAGGER_FILE_DIRECTORY ||
|
|
248
|
+
getAPI(start.SWAGGER_FILE_DIRECTORY || DEFAULT.API_DIRECTORY, config.pack.swaggerFile, config.key)
|
|
238
249
|
.then((apiDefinition) => {
|
|
239
250
|
console.log('- mST base url: ' + `${mSTBaseUrl}`.info);
|
|
240
251
|
console.log('- mIT base url: ' + config.MITBaseUrl.info);
|
|
@@ -243,11 +254,11 @@ const mITInit = (confType) => {
|
|
|
243
254
|
start = settingUpDummyServer(type, start.SERVER_ID, null, start);
|
|
244
255
|
if (confType === TEST) {
|
|
245
256
|
start.CUSTOMER_NAME = SYSTEM_NAME;
|
|
246
|
-
start.CUSTOMER_CODE =
|
|
257
|
+
start.CUSTOMER_CODE = DUMMY.CUSTOMER_CODE;
|
|
247
258
|
start.BASE_PATH = getBasePath(apiDefinition);
|
|
248
|
-
return { file: testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
259
|
+
return { file: DEFAULT.FILE.testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
249
260
|
}
|
|
250
|
-
return { file: shellFile, content: start2shell(start), type: 'shell script' };
|
|
261
|
+
return { file: DEFAULT.FILE.shellFile, content: start2shell(start), type: 'shell script' };
|
|
251
262
|
}
|
|
252
263
|
return getAdminToken(
|
|
253
264
|
{ type: 'mST', audience: `${baseUrl('mST', regType, config.mST, LITERAL)}/clients/Generic-mST` },
|
|
@@ -274,16 +285,16 @@ const mITInit = (confType) => {
|
|
|
274
285
|
start.BASE_PATH = getBasePath(apiDefinition);
|
|
275
286
|
start.MST_TOKEN = authorization;
|
|
276
287
|
start.ADMIN_TOKEN = adminToken;
|
|
277
|
-
return { file: testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
288
|
+
return { file: DEFAULT.FILE.testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
278
289
|
}
|
|
279
290
|
if (adminToken) console.log('- admin token for the service: ' + adminToken.info);
|
|
280
291
|
console.log('- mST token: ' + authorization.info);
|
|
281
|
-
return { file: shellFile, content: start2shell(start), type: 'shell script' };
|
|
292
|
+
return { file: DEFAULT.FILE.shellFile, content: start2shell(start), type: 'shell script' };
|
|
282
293
|
});
|
|
283
294
|
}));
|
|
284
295
|
})
|
|
285
296
|
.then((response) => {
|
|
286
|
-
|
|
297
|
+
writeFileSync(response.file, response.content);
|
|
287
298
|
console.log(`${regType}status: ` + 'completed'.success + ', ' + response.type.info + ' created at (' + response.file.info + ')');
|
|
288
299
|
})
|
|
289
300
|
.catch(err => exitError(regType, err));
|
|
@@ -301,7 +312,7 @@ const serverInit = (confType) => {
|
|
|
301
312
|
let start = startSetup(config, startConfig);
|
|
302
313
|
let authorization;
|
|
303
314
|
|
|
304
|
-
getAPI(start.SWAGGER_FILE_DIRECTORY ||
|
|
315
|
+
getAPI(start.SWAGGER_FILE_DIRECTORY || DEFAULT.API_DIRECTORY, config.pack.swaggerFile, config.key)
|
|
305
316
|
.then((apiDefinition) => {
|
|
306
317
|
console.log('- mST base url: ' + `${mSTBaseUrl}`.info);
|
|
307
318
|
console.log('- mIT base url: ' + config.MITBaseUrl.info);
|
|
@@ -310,11 +321,11 @@ const serverInit = (confType) => {
|
|
|
310
321
|
start = settingUpDummyServer(type, start.SERVER_ID, customer, start);
|
|
311
322
|
if (confType === TEST) {
|
|
312
323
|
start.CUSTOMER_NAME = customer.name;
|
|
313
|
-
start.CUSTOMER_CODE =
|
|
324
|
+
start.CUSTOMER_CODE = DUMMY.CUSTOMER_CODE;
|
|
314
325
|
start.BASE_PATH = getBasePath(apiDefinition);
|
|
315
|
-
return { file: testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
326
|
+
return { file: DEFAULT.FILE.testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
316
327
|
}
|
|
317
|
-
return { file: shellFile, content: start2shell(start), type: 'shell script' };
|
|
328
|
+
return { file: DEFAULT.FILE.shellFile, content: start2shell(start), type: 'shell script' };
|
|
318
329
|
}
|
|
319
330
|
return getAdminToken(
|
|
320
331
|
{ type: 'mST', audience: `${baseUrl('mST', regType, config.mST, LITERAL)}/clients/Generic-mST` },
|
|
@@ -345,7 +356,7 @@ const serverInit = (confType) => {
|
|
|
345
356
|
start.BASE_PATH = getBasePath(apiDefinition);
|
|
346
357
|
start.MST_TOKEN = authorization;
|
|
347
358
|
start.ADMIN_TOKEN = adminToken;
|
|
348
|
-
const testResponse = { file: testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
359
|
+
const testResponse = { file: DEFAULT.FILE.testJsonFile, content: JSON.stringify(start2env(start), null, TAB), type: 'JSON file' };
|
|
349
360
|
|
|
350
361
|
if (startConfig.oauthImplicitNeeded === 'yes') {
|
|
351
362
|
return settingUpAdminClient('mID', `admin_${customer.name}_${start.NODE_ENV}_mID`, customer, start.MST_TOKEN, mSTBaseUrl)
|
|
@@ -360,12 +371,12 @@ const serverInit = (confType) => {
|
|
|
360
371
|
}
|
|
361
372
|
if (adminToken) console.log('- admin token for the service: ' + adminToken.info);
|
|
362
373
|
console.log('- mST token: ' + authorization.info);
|
|
363
|
-
return { file: shellFile, content: start2shell(start), type: 'shell script' };
|
|
374
|
+
return { file: DEFAULT.FILE.shellFile, content: start2shell(start), type: 'shell script' };
|
|
364
375
|
});
|
|
365
376
|
});
|
|
366
377
|
})
|
|
367
378
|
.then((response) => {
|
|
368
|
-
|
|
379
|
+
writeFileSync(response.file, response.content);
|
|
369
380
|
console.log(`${regType}status: ` + 'completed'.success + ', ' + response.type.info + ' created at (' + response.file.info + ')');
|
|
370
381
|
})
|
|
371
382
|
.catch(err => exitError(regType, err));
|
|
@@ -373,292 +384,366 @@ const serverInit = (confType) => {
|
|
|
373
384
|
|
|
374
385
|
/**
|
|
375
386
|
*
|
|
376
|
-
*
|
|
387
|
+
* Set up `mST` for tests.
|
|
377
388
|
*
|
|
378
389
|
* @function mSTTestSetup
|
|
379
390
|
* @category sync
|
|
380
391
|
*
|
|
381
392
|
* @return `null`.
|
|
382
393
|
*
|
|
383
|
-
*
|
|
394
|
+
* Exits with code `1` on error.
|
|
384
395
|
*
|
|
385
|
-
*
|
|
396
|
+
* Actions performed:
|
|
386
397
|
*
|
|
387
|
-
* 1.
|
|
388
|
-
* 2.
|
|
398
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
399
|
+
* 2. Generate a JSON object and store it in a file in the project root (`.`) to enable tests.
|
|
389
400
|
*
|
|
390
|
-
*
|
|
401
|
+
* Files required:
|
|
391
402
|
*
|
|
392
403
|
* | Filename | Description |
|
|
393
404
|
* | -------- | ----------- |
|
|
394
|
-
* | `../sumoLog.json` |
|
|
395
|
-
* | `../kinesisLog.json` |
|
|
396
|
-
* | `../s3Log.json` |
|
|
397
|
-
* | `../mSTConfig.json` |
|
|
398
|
-
* | `../mITConfig.json` |
|
|
399
|
-
* |
|
|
405
|
+
* | `../sumoLog.json` | Sumologic endpoints and code
|
|
406
|
+
* | `../kinesisLog.json` | AWS Kinesis configuration
|
|
407
|
+
* | `../s3Log.json` | AWS S3 configuration
|
|
408
|
+
* | `../mSTConfig.json` | mST configuration
|
|
409
|
+
* | `../mITConfig.json` | mIT configuration
|
|
410
|
+
* | `../locationConfig.json` | Location provider URL and key (when needed)
|
|
411
|
+
* | `../key.json` | Github username and password or Swaggerhub key
|
|
412
|
+
* | `./local/testStart.json` | Local configuration (if it does not exist, `example-start.json` will be used to create `testStart.json`)
|
|
400
413
|
*/
|
|
401
414
|
export const mSTTestSetup = () => mSTInit(TEST);
|
|
402
415
|
|
|
403
416
|
/**
|
|
404
417
|
*
|
|
405
|
-
*
|
|
418
|
+
* Set up `mST`.
|
|
406
419
|
*
|
|
407
420
|
* @function mSTSetup
|
|
408
421
|
* @category sync
|
|
409
422
|
*
|
|
410
423
|
* @return `null`.
|
|
411
424
|
*
|
|
412
|
-
*
|
|
425
|
+
* Exits with code `1` on error.
|
|
413
426
|
*
|
|
414
|
-
*
|
|
427
|
+
* Actions performed:
|
|
415
428
|
*
|
|
416
|
-
* 1.
|
|
417
|
-
* 2.
|
|
429
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
430
|
+
* 2. Generate a shell script in the project root (`.`) to start the server.
|
|
418
431
|
*
|
|
419
|
-
*
|
|
432
|
+
* Files required:
|
|
420
433
|
*
|
|
421
434
|
* | Filename | Description |
|
|
422
435
|
* | -------- | ----------- |
|
|
423
|
-
* | `../sumoLog.json` |
|
|
424
|
-
* | `../kinesisLog.json` |
|
|
425
|
-
* | `../s3Log.json` |
|
|
426
|
-
* | `../mSTConfig.json` |
|
|
427
|
-
* | `../mITConfig.json` |
|
|
428
|
-
* |
|
|
436
|
+
* | `../sumoLog.json` | Sumologic endpoints and code
|
|
437
|
+
* | `../kinesisLog.json` | AWS Kinesis configuration
|
|
438
|
+
* | `../s3Log.json` | AWS S3 configuration
|
|
439
|
+
* | `../mSTConfig.json` | mST configuration
|
|
440
|
+
* | `../mITConfig.json` | mIT configuration
|
|
441
|
+
* | `../locationConfig.json` | Location provider URL and key (when needed)
|
|
442
|
+
* | `../key.json` | Github username and password or Swaggerhub key
|
|
443
|
+
* | `./local/start.json` | Local configuration (if it does not exist, `example-start.json` will be used to create `start.json`)
|
|
429
444
|
*/
|
|
430
445
|
export const mSTSetup = () => mSTInit();
|
|
431
446
|
|
|
432
447
|
/**
|
|
433
448
|
*
|
|
434
|
-
*
|
|
449
|
+
* Set up `mIT` for tests.
|
|
435
450
|
*
|
|
436
451
|
* @function mITTestSetup
|
|
437
452
|
* @category sync
|
|
438
453
|
*
|
|
439
454
|
* @return `null`.
|
|
440
455
|
*
|
|
441
|
-
*
|
|
456
|
+
* Exits with code `1` on error.
|
|
442
457
|
*
|
|
443
458
|
* Two modes are available:
|
|
444
|
-
* 1. stand alone
|
|
445
|
-
* 2. with mST
|
|
446
459
|
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
460
|
+
* 1. Standalone
|
|
461
|
+
* 2. With mST
|
|
449
462
|
*
|
|
450
|
-
*
|
|
451
|
-
* 2. get an admin token for that service
|
|
452
|
-
* 3. generate a JSON object store in a file under .
|
|
463
|
+
* The environment variable `STAND_ALONE` selects the mode.
|
|
453
464
|
*
|
|
454
|
-
*
|
|
465
|
+
* When **standalone**, the following actions are performed:
|
|
455
466
|
*
|
|
456
|
-
*
|
|
467
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
468
|
+
* 2. Obtain an admin token for the service.
|
|
469
|
+
* 3. Generate a JSON object and store it in a file under the project root (`.`).
|
|
457
470
|
*
|
|
458
|
-
*
|
|
459
|
-
* 2. get an admin token for mST
|
|
460
|
-
* 3. register the service in mST
|
|
461
|
-
* 4. register an admin client for that service in mST
|
|
462
|
-
* 5. get an admin token for that service
|
|
463
|
-
* 6. get an admin token for mID if needed
|
|
464
|
-
* 7. generate a JSON object store in a file under .
|
|
471
|
+
* In `standAlone` mode, dependencies are not reachable and operations that contact dependencies will most likely return a 500 error.
|
|
465
472
|
*
|
|
466
|
-
*
|
|
473
|
+
* When **mST and other servers are present**, the following actions are performed:
|
|
474
|
+
*
|
|
475
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
476
|
+
* 2. Obtain an admin token for mST.
|
|
477
|
+
* 3. Register the service in mST.
|
|
478
|
+
* 4. Register an admin client for the service in mST.
|
|
479
|
+
* 5. Obtain an admin token for the service.
|
|
480
|
+
* 6. Obtain an admin token for mID if needed.
|
|
481
|
+
* 7. Generate a JSON object and store it in a file under the project root (`.`).
|
|
482
|
+
*
|
|
483
|
+
* Files required:
|
|
467
484
|
*
|
|
468
485
|
* | Filename | Description |
|
|
469
486
|
* | -------- | ----------- |
|
|
470
|
-
* | `../sumoLog.json` |
|
|
471
|
-
* | `../kinesisLog.json` |
|
|
472
|
-
* | `../s3Log.json` |
|
|
473
|
-
* | `../mSTConfig.json` |
|
|
474
|
-
* | `../mITConfig.json` |
|
|
475
|
-
* |
|
|
487
|
+
* | `../sumoLog.json` | Sumologic endpoints and code
|
|
488
|
+
* | `../kinesisLog.json` | AWS Kinesis configuration
|
|
489
|
+
* | `../s3Log.json` | AWS S3 configuration
|
|
490
|
+
* | `../mSTConfig.json` | mST configuration
|
|
491
|
+
* | `../mITConfig.json` | mIT configuration
|
|
492
|
+
* | `../locationConfig.json` | Location provider URL and key (when needed)
|
|
493
|
+
* | `../key.json` | Github username and password or Swaggerhub key
|
|
494
|
+
* | `./local/testStart.json` | Local configuration (if it does not exist, `example-start.json` will be used to create `testStart.json`)
|
|
476
495
|
*/
|
|
477
496
|
export const mITTestSetup = () => mITInit(TEST);
|
|
478
497
|
|
|
479
498
|
/**
|
|
480
499
|
*
|
|
481
|
-
*
|
|
500
|
+
* Set up `mIT`.
|
|
482
501
|
*
|
|
483
502
|
* @function mITSetup
|
|
484
503
|
* @category sync
|
|
485
504
|
*
|
|
486
505
|
* @return `null`.
|
|
487
506
|
*
|
|
488
|
-
*
|
|
507
|
+
* Exits with code `1` on error.
|
|
489
508
|
*
|
|
490
509
|
* Two modes are available:
|
|
491
|
-
* 1. stand alone
|
|
492
|
-
* 2. with mST
|
|
493
510
|
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
511
|
+
* 1. Standalone
|
|
512
|
+
* 2. With mST
|
|
496
513
|
*
|
|
497
|
-
*
|
|
498
|
-
* 2. get an admin token for that service
|
|
499
|
-
* 3. generate a shell script to start the server
|
|
514
|
+
* The environment variable `STAND_ALONE` selects the mode.
|
|
500
515
|
*
|
|
501
|
-
*
|
|
516
|
+
* When **standalone**, the following actions are performed:
|
|
502
517
|
*
|
|
503
|
-
*
|
|
518
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
519
|
+
* 2. Obtain an admin token for the service.
|
|
520
|
+
* 3. Generate a shell script in the project root (`.`) to start the server.
|
|
504
521
|
*
|
|
505
|
-
*
|
|
506
|
-
* 2. get an admin token for mST
|
|
507
|
-
* 3. register the service in mST
|
|
508
|
-
* 4. generate a shell script to start the server
|
|
522
|
+
* In `standAlone` mode, dependencies are not reachable and operations that contact dependencies will most likely return a 500 error.
|
|
509
523
|
*
|
|
510
|
-
*
|
|
524
|
+
* When **mST is present**, the following actions are performed:
|
|
525
|
+
*
|
|
526
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
527
|
+
* 2. Obtain an admin token for mST.
|
|
528
|
+
* 3. Register the service in mST.
|
|
529
|
+
* 4. Generate a shell script in the project root (`.`) to start the server.
|
|
530
|
+
*
|
|
531
|
+
* Files required:
|
|
511
532
|
*
|
|
512
533
|
* | Filename | Description |
|
|
513
534
|
* | -------- | ----------- |
|
|
514
|
-
* | `../sumoLog.json` |
|
|
515
|
-
* | `../kinesisLog.json` |
|
|
516
|
-
* | `../s3Log.json` |
|
|
517
|
-
* | `../mSTConfig.json` |
|
|
518
|
-
* | `../mITConfig.json` |
|
|
519
|
-
* |
|
|
535
|
+
* | `../sumoLog.json` | Sumologic endpoints and code
|
|
536
|
+
* | `../kinesisLog.json` | AWS Kinesis configuration
|
|
537
|
+
* | `../s3Log.json` | AWS S3 configuration
|
|
538
|
+
* | `../mSTConfig.json` | mST configuration
|
|
539
|
+
* | `../mITConfig.json` | mIT configuration
|
|
540
|
+
* | `../locationConfig.json` | Location provider URL and key (when needed)
|
|
541
|
+
* | `../key.json` | Github username and password or Swaggerhub key
|
|
542
|
+
* | `./local/start.json` | Local configuration (if it does not exist, `example-start.json` will be used to create `start.json`)
|
|
520
543
|
*/
|
|
521
544
|
export const mITSetup = () => mITInit();
|
|
522
545
|
|
|
523
546
|
/**
|
|
524
547
|
*
|
|
525
|
-
*
|
|
548
|
+
* Set up a service (not mST or mIT) for tests.
|
|
526
549
|
*
|
|
527
550
|
* @function testSetup
|
|
528
551
|
* @category sync
|
|
529
552
|
*
|
|
530
553
|
* @return `null`.
|
|
531
554
|
*
|
|
532
|
-
*
|
|
555
|
+
* Exits with code `1` on error.
|
|
533
556
|
*
|
|
534
557
|
* Two modes are available:
|
|
535
|
-
* 1. stand alone
|
|
536
|
-
* 2. with mST, mID are other dependent servers
|
|
537
558
|
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
559
|
+
* 1. Standalone
|
|
560
|
+
* 2. With mST/mID and other dependent servers
|
|
540
561
|
*
|
|
541
|
-
*
|
|
542
|
-
* 2. get an admin token for that service
|
|
543
|
-
* 3. generate a JSON object store in a file under .
|
|
562
|
+
* The environment variable `STAND_ALONE` selects the mode.
|
|
544
563
|
*
|
|
545
|
-
*
|
|
564
|
+
* When **standalone**, the following actions are performed:
|
|
546
565
|
*
|
|
547
|
-
*
|
|
566
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
567
|
+
* 2. Obtain an admin token for the service.
|
|
568
|
+
* 3. Generate a JSON object and store it in a file under the project root (`.`).
|
|
548
569
|
*
|
|
549
|
-
*
|
|
550
|
-
* 2. get an admin token for mST
|
|
551
|
-
* 3. setup the customer in mST
|
|
552
|
-
* 4. register the service in mST
|
|
553
|
-
* 5. register an admin client for that service in mST
|
|
554
|
-
* 6. get an admin token for that service
|
|
555
|
-
* 7. get an admin token for mID if needed
|
|
556
|
-
* 8. generate a json object store in a file under .
|
|
570
|
+
* In `standAlone` mode, dependencies are not reachable and operations that contact dependencies will most likely return a 500 error.
|
|
557
571
|
*
|
|
558
|
-
*
|
|
572
|
+
* When **mST and other servers are present**, the following actions are performed:
|
|
573
|
+
*
|
|
574
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
575
|
+
* 2. Obtain an admin token for mST.
|
|
576
|
+
* 3. Set up the customer in mST.
|
|
577
|
+
* 4. Register the service in mST.
|
|
578
|
+
* 5. Register an admin client for the service in mST.
|
|
579
|
+
* 6. Obtain an admin token for the service.
|
|
580
|
+
* 7. Obtain an admin token for mID if needed.
|
|
581
|
+
* 8. Generate a JSON object and store it in a file under the project root (`.`).
|
|
582
|
+
*
|
|
583
|
+
* Files required:
|
|
559
584
|
*
|
|
560
585
|
* | Filename | Description |
|
|
561
586
|
* | -------- | ----------- |
|
|
562
|
-
* | `../sumoLog.json` |
|
|
563
|
-
* | `../kinesisLog.json` |
|
|
564
|
-
* | `../s3Log.json` |
|
|
565
|
-
* | `../mSTConfig.json` |
|
|
566
|
-
* | `../mITConfig.json` |
|
|
567
|
-
* | `../mIDConfig.json` |
|
|
568
|
-
* | `../customerConfig.json` |
|
|
569
|
-
* |
|
|
587
|
+
* | `../sumoLog.json` | Sumologic endpoints and code
|
|
588
|
+
* | `../kinesisLog.json` | AWS Kinesis configuration
|
|
589
|
+
* | `../s3Log.json` | AWS S3 configuration
|
|
590
|
+
* | `../mSTConfig.json` | mST configuration
|
|
591
|
+
* | `../mITConfig.json` | mIT configuration
|
|
592
|
+
* | `../mIDConfig.json` | mID configuration (when needed)
|
|
593
|
+
* | `../customerConfig.json` | mST customer configuration
|
|
594
|
+
* | `../locationConfig.json` | Location provider URL and key (when needed)
|
|
595
|
+
* | `../key.json` | Github username and password or Swaggerhub key
|
|
596
|
+
* | `./local/testStart.json` | Local configuration (if it does not exist, `example-start.json` will be used to create `testStart.json`)
|
|
570
597
|
*/
|
|
571
598
|
export const testSetup = () => serverInit(TEST);
|
|
572
599
|
|
|
573
600
|
/**
|
|
574
601
|
*
|
|
575
|
-
*
|
|
602
|
+
* Set up a service (not mST or mIT).
|
|
576
603
|
*
|
|
577
604
|
* @function setup
|
|
578
605
|
* @category sync
|
|
579
606
|
*
|
|
580
607
|
* @return `null`.
|
|
581
608
|
*
|
|
582
|
-
*
|
|
609
|
+
* Exits with code `1` on error.
|
|
583
610
|
*
|
|
584
611
|
* Two modes are available:
|
|
585
|
-
* 1.
|
|
586
|
-
* 2.
|
|
612
|
+
* 1. Standalone
|
|
613
|
+
* 2. With mST/mID and other dependent servers
|
|
587
614
|
*
|
|
588
|
-
* The environment variable STAND_ALONE
|
|
589
|
-
* When in stand alone, the following actions are being performed:
|
|
615
|
+
* The environment variable `STAND_ALONE` selects the mode.
|
|
590
616
|
*
|
|
591
|
-
*
|
|
592
|
-
* 2. get an admin token for that service
|
|
593
|
-
* 3. generate a shell script to start the server
|
|
617
|
+
* When **standalone**, the following actions are performed:
|
|
594
618
|
*
|
|
595
|
-
*
|
|
619
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
620
|
+
* 2. Obtain an admin token for the service.
|
|
621
|
+
* 3. Generate a shell script to start the server.
|
|
596
622
|
*
|
|
597
|
-
*
|
|
623
|
+
* In `standAlone` mode, dependencies are not reachable and operations that contact dependencies will most likely return a 500 error.
|
|
598
624
|
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
625
|
+
* When **mST and other servers are present**, the following actions are performed:
|
|
626
|
+
*
|
|
627
|
+
* 1. Retrieve the API definition from [SwaggerHub](https://app.swaggerhub.com/search?type=API&owner=mimik).
|
|
628
|
+
* 2. Obtain an admin token for mST.
|
|
629
|
+
* 3. Set up the customer in mST.
|
|
630
|
+
* 4. Register the service in mST.
|
|
631
|
+
* 5. Generate a shell script in the project root (`.`) to start the server.
|
|
604
632
|
*
|
|
605
633
|
* The following files are needed to perform these actions:
|
|
606
634
|
*
|
|
607
635
|
* | Filename | Description |
|
|
608
636
|
* | -------- | ----------- |
|
|
609
|
-
* | `../sumo.json` |
|
|
610
|
-
* | `../kinesisLog.json` |
|
|
611
|
-
* | `../s3Log.json` |
|
|
612
|
-
* | `../mSTConfig.json` |
|
|
613
|
-
* | `../mITConfig.json` |
|
|
614
|
-
* | `../mIDConfig.json` |
|
|
615
|
-
* | `../customerConfig.json` |
|
|
616
|
-
* |
|
|
637
|
+
* | `../sumo.json` | Sumo Logic endpoints and code
|
|
638
|
+
* | `../kinesisLog.json` | Kinesis configuration
|
|
639
|
+
* | `../s3Log.json` | S3 configuration
|
|
640
|
+
* | `../mSTConfig.json` | mST configuration
|
|
641
|
+
* | `../mITConfig.json` | mIT configuration
|
|
642
|
+
* | `../mIDConfig.json` | mID configuration (when needed)
|
|
643
|
+
* | `../customerConfig.json` | mST customer configuration
|
|
644
|
+
* | `../locationConfig.json` | Location provider URL and key (when needed)
|
|
645
|
+
* | `../key.json` | Github username and password or Swaggerhub key
|
|
646
|
+
* | `./local/start.json` | Local configuration (if it does not exist, `example-start.json` will be used to create `start.json`)
|
|
617
647
|
*/
|
|
618
648
|
export const setup = () => serverInit();
|
|
619
649
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
650
|
+
/**
|
|
651
|
+
*
|
|
652
|
+
* Utility to create `rule files`.
|
|
653
|
+
*
|
|
654
|
+
* @function dotFiles
|
|
655
|
+
* @category sync
|
|
656
|
+
*
|
|
657
|
+
* @return `null`.
|
|
658
|
+
*
|
|
659
|
+
* Creates the `rule files` for:
|
|
660
|
+
*
|
|
661
|
+
* - `eslint` -> `eslint.config.js`.
|
|
662
|
+
* - `c8` -> `.nycrc`
|
|
663
|
+
* - `github` -> `.gitignore`
|
|
664
|
+
*
|
|
665
|
+
* If a file already exists, it will be overwritten.
|
|
666
|
+
*/
|
|
631
667
|
export const dotFiles = () => {
|
|
632
|
-
write(
|
|
633
|
-
write(
|
|
634
|
-
write(
|
|
668
|
+
write('./eslint.config.js', read(join(localDirname, 'dotFiles', 'eslint.config.js'), INSTALL), INSTALL);
|
|
669
|
+
write('./.nycrc', parse(read(join(localDirname, 'dotFiles', 'nycrc.json'), 'nycrc.json', INSTALL)), INSTALL, true);
|
|
670
|
+
write('./.gitignore', read(join(localDirname, 'dotFiles', 'gitIgnore.txt'), INSTALL), INSTALL);
|
|
635
671
|
};
|
|
636
672
|
|
|
673
|
+
/**
|
|
674
|
+
*
|
|
675
|
+
* Utility to add `scripts` and `husky`.
|
|
676
|
+
*
|
|
677
|
+
* @function scripts
|
|
678
|
+
* @category sync
|
|
679
|
+
*
|
|
680
|
+
* @return `null`.
|
|
681
|
+
*
|
|
682
|
+
* Adds `scripts` and `husky` to `package.json`. If a script already exists, it will be overwritten.
|
|
683
|
+
*/
|
|
637
684
|
export const scripts = () => {
|
|
638
|
-
const
|
|
639
|
-
const
|
|
640
|
-
const packageFile = parse(read(packageFilename, INSTALL), 'package.json', INSTALL);
|
|
685
|
+
const scriptsContent = parse(read(join(localDirname, 'scripts.json'), INSTALL), 'scripts.json', INSTALL);
|
|
686
|
+
const packageContent = parse(read(DEFAULT.FILE.packageFile, INSTALL), DEFAULT.FILE.packageFile, INSTALL);
|
|
641
687
|
|
|
642
|
-
Object.keys(
|
|
643
|
-
|
|
688
|
+
Object.keys(scriptsContent.scripts).forEach((script) => {
|
|
689
|
+
packageContent.scripts[script] = scriptsContent.scripts[script];
|
|
644
690
|
});
|
|
645
|
-
|
|
646
|
-
write(
|
|
691
|
+
packageContent.husky = scriptsContent.husky;
|
|
692
|
+
write(DEFAULT.FILE.packageFile, packageContent, DEFAULT.FILE.packageFile, INSTALL, true);
|
|
647
693
|
};
|
|
648
694
|
|
|
695
|
+
/**
|
|
696
|
+
*
|
|
697
|
+
* Utility to remove `scripts` and `husky`.
|
|
698
|
+
*
|
|
699
|
+
* @function unscripts
|
|
700
|
+
* @category sync
|
|
701
|
+
*
|
|
702
|
+
* @return `null`.
|
|
703
|
+
*
|
|
704
|
+
* Removes `scripts` and `husky` from `package.json`. Only removes the scripts that are in the script file.
|
|
705
|
+
*/
|
|
649
706
|
export const unScripts = () => {
|
|
650
|
-
const
|
|
651
|
-
const
|
|
652
|
-
const packageFile = parse(read(packageFilename, INSTALL), 'package.json', INSTALL);
|
|
707
|
+
const scriptsContent = parse(read(join(localDirname, 'scripts.json'), INSTALL), 'scripts.json', INSTALL);
|
|
708
|
+
const packageContent = parse(read(DEFAULT.FILE.packageFile, INSTALL), DEFAULT.FILE.packageFile, INSTALL);
|
|
653
709
|
|
|
654
|
-
Object.keys(
|
|
655
|
-
delete
|
|
710
|
+
Object.keys(scriptsContent.scripts).forEach((script) => {
|
|
711
|
+
delete packageContent.scripts[script];
|
|
656
712
|
});
|
|
657
|
-
delete
|
|
658
|
-
write(
|
|
713
|
+
delete packageContent.husky;
|
|
714
|
+
write(DEFAULT.FILE.packageFile, packageContent, DEFAULT.FILE.packageFile, INSTALL, true);
|
|
659
715
|
};
|
|
660
716
|
|
|
661
|
-
|
|
717
|
+
/**
|
|
718
|
+
* Path to the JSON test file.
|
|
719
|
+
*
|
|
720
|
+
* @type {string}
|
|
721
|
+
*/
|
|
722
|
+
export const testJsonFile = DEFAULT.FILE.testJsonFile; // eslint-disable-line prefer-destructuring
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
*
|
|
726
|
+
* Check the validity of the commit message.
|
|
727
|
+
*
|
|
728
|
+
* @function commitCheckMsg
|
|
729
|
+
* @category async
|
|
730
|
+
* @return {Promise}.
|
|
731
|
+
* @fulfil `null`.
|
|
732
|
+
*
|
|
733
|
+
* Exits with code `1` if the commit message is not correct or if the branch is not a Jira generated branch.
|
|
734
|
+
*/
|
|
735
|
+
export { commitCheckMsg };
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
*
|
|
739
|
+
* Set up the environment variables based on given JSON object.
|
|
740
|
+
*
|
|
741
|
+
* @function start2process
|
|
742
|
+
* @category sync
|
|
743
|
+
* @param {object} start - JSON object that is used to configure the environment variables. The comments (starting by //) are ignored.
|
|
744
|
+
* @return `null`.
|
|
745
|
+
*/
|
|
746
|
+
export { start2process };
|
|
662
747
|
|
|
663
748
|
export default {
|
|
664
749
|
commitCheckMsg,
|