@mimik/local 7.1.0 → 7.1.2

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/lib/common.js CHANGED
@@ -1,15 +1,148 @@
1
- import process from 'process';
2
-
3
- const packageFile = './package.json';
4
- const mSTConfigFile = '../mSTConfig.json';
5
- const mITConfigFile = '../mITConfig.json';
6
- const mIDConfigFile = '../mIDConfig.json';
7
- const sumoLogFile = '../sumoLog.json';
8
- const s3LogFile = '../s3Log.json';
9
- const kinesisLogFile = '../kinesisLog.json';
10
- const locationFile = '../locationConfig.json';
11
- const keyFile = '../key.json';
12
- const customerConfigFile = '../customerConfig.json';
1
+ /* eslint-disable no-magic-numbers */
2
+ import { getCorrelationId } from '@mimik/request-helper';
3
+ import process from 'node:process';
4
+
5
+ const S3_MAX_EVENTS = 10;
6
+ const S3_TIMEOUT = 1;
7
+ const S3_MAX_SIZE = 5;
8
+
9
+ const DEFAULT_MST_PORT = 8025;
10
+ const DEFAULT_MIT_PORT = 8050;
11
+ const DEFAULT_MID_PORT = 8015;
12
+
13
+ const ERROR_CODE = {
14
+ NOT_FOUND: 404,
15
+ SYSTEM: 500,
16
+ };
17
+
18
+ const DEFAULT_ADMIN_EXTERNAL_ID_BASE = 'admin_default_local';
19
+
20
+ const DEFAULT = {
21
+ MID_PORT: DEFAULT_MID_PORT,
22
+ MIT_PORT: DEFAULT_MIT_PORT,
23
+ MST_PORT: DEFAULT_MST_PORT,
24
+
25
+ API_DIRECTORY: './api',
26
+
27
+ MID: {
28
+ basePath: '/mID/v1',
29
+ protocol: 'http:',
30
+ domainName: 'localhost',
31
+ port: DEFAULT_MID_PORT,
32
+ implicit: {
33
+ key: 'a-secret-key-for-implicit',
34
+ audience: 'https://mimik',
35
+ },
36
+ admin: {
37
+ externalId: `${DEFAULT_ADMIN_EXTERNAL_ID_BASE}_mID`,
38
+ },
39
+ },
40
+ MIT: {
41
+ basePath: '/mIT/v1',
42
+ protocol: 'http:',
43
+ domainName: 'localhost',
44
+ port: DEFAULT_MIT_PORT,
45
+ },
46
+ MST: {
47
+ basePath: '/mST/v1',
48
+ protocol: 'http:',
49
+ domainName: 'localhost',
50
+ port: DEFAULT_MST_PORT,
51
+ admin: {
52
+ clientId: '12345',
53
+ clientSecret: 'timeForSecret',
54
+ },
55
+ },
56
+
57
+ KINESISLOG: {
58
+ region: '--- default region ---',
59
+ accessKeyId: '--- default accessKey Id',
60
+ secretAccessKey: '--- default secret accessKey ---',
61
+ streamNameInfo: '--- default streamName Info ---',
62
+ streamNameError: '--- default streamName Error ---',
63
+ streamNameOther: '--- default streamName Other ---',
64
+ },
65
+ S3LOG: {
66
+ region: '--- default region ---',
67
+ accessKeyId: '--- default accessKey Id',
68
+ secretAccessKey: '--- default secret accessKey ---',
69
+ bucketname: '--- default bucketname ---',
70
+ maxEvents: S3_MAX_EVENTS,
71
+ timeout: S3_TIMEOUT,
72
+ maxSize: S3_MAX_SIZE,
73
+ },
74
+ SUMOLOG: {
75
+ default: {
76
+ url: 'https://default-sumo-endPoint',
77
+ code: '--- default code ---',
78
+ },
79
+ },
80
+
81
+ KEY: {
82
+ username: ' ',
83
+ password: ' ',
84
+ },
85
+ LOCATION: {
86
+ url: null,
87
+ key: null,
88
+ },
89
+
90
+ FILE: {
91
+ packageFile: './package.json',
92
+
93
+ mIDConfigFile: '../mIDConfig.json',
94
+ mITConfigFile: '../mITConfig.json',
95
+ mSTConfigFile: '../mSTConfig.json',
96
+
97
+ kinesisLogFile: '../kinesisLog.json',
98
+ s3LogFile: '../s3Log.json',
99
+ sumoLogFile: '../sumoLog.json',
100
+
101
+ customerConfigFile: '../customerConfig.json',
102
+ keyFile: '../key.json',
103
+ locationFile: '../locationConfig.json',
104
+
105
+ exampleStartFile: './local/start-example.json',
106
+ exampleTestStartFile: './local/testStart-example.json',
107
+ shellFile: './server-start.sh',
108
+ startFile: './local/start.json',
109
+ testJsonFile: './server-test.json',
110
+ testStartFile: './local/testStart.json',
111
+ },
112
+ };
113
+ const DUMMY = {
114
+ CUSTOMER_CODE: 'dummy-code',
115
+
116
+ MID: {
117
+ basePath: '/mID/v1',
118
+ protocol: 'http:',
119
+ domainName: 'dummy-mID',
120
+ port: DEFAULT_MID_PORT,
121
+ implicit: {
122
+ key: 'a-secret-key-for-implicit',
123
+ audience: 'https://dummy-mID-audience',
124
+ },
125
+ admin: {
126
+ externalId: `${DEFAULT_ADMIN_EXTERNAL_ID_BASE}_mID`,
127
+ },
128
+ },
129
+ MIT: {
130
+ basePath: '/mIT/v1',
131
+ protocol: 'http:',
132
+ domainName: 'dummy-mIT',
133
+ port: DEFAULT_MIT_PORT,
134
+ },
135
+ MST: {
136
+ basePath: '/mST/v1',
137
+ protocol: 'http',
138
+ domainName: 'dummy-mST',
139
+ port: DEFAULT_MST_PORT,
140
+ admin: {
141
+ clientId: '12345',
142
+ clientSecret: 'timeForSecret',
143
+ },
144
+ },
145
+ };
13
146
 
14
147
  const API_PROVIDER_BITBUCKET = 'https://api.bitbucket.org/2.0/repositories';
15
148
  const API_PROVIDER_SWAGGERHUB = 'https://api.swaggerhub.com/apis';
@@ -18,7 +151,6 @@ const SWAGGER = 'swagger';
18
151
  const EXTENSION_YML = '.yml';
19
152
  const EXTENSION_JSON = '.json';
20
153
  const POSTFIX = `${SWAGGER}${EXTENSION_JSON}`;
21
- const DEFAULT_DIRECTORY = './api';
22
154
  const SWAGGERHUB = 'swaggerhub';
23
155
  const BITBUCKET = 'bitbucket';
24
156
  const RESOLVED = 'resolved=true';
@@ -33,129 +165,26 @@ const ALL_MODES = [AWS_S3, AWS_KINESIS, SUMOLOGIC, ALL, NONE];
33
165
  const SWAGGER_SEP = '_';
34
166
  const TEST = 'test';
35
167
 
36
- const DEFAULT_BITBUCKET_USERNAME = ' ';
37
- const DEFAULT_BITBUCKET_PASSWORD = ' ';
38
-
39
168
  const SYSTEM_NAME = 'System';
40
169
  const TOKEN_SERVICE = 'mST';
41
170
  const IT_REGISTRY = 'mIT';
42
171
  const IDENTITY_SERVICE = 'mID';
43
172
 
44
- const testJsonFile = './server-test.json';
45
- const shellFile = './server-start.sh';
46
- const startFile = './local/start.json';
47
- const testStartFile = './local/testStart.json';
48
- const exampleStartFile = './local/start-example.json';
49
- const exampleTestStartFile = './local/testStart-example.json';
50
-
51
173
  const LITERAL = true;
52
- const IGNORE = '!';
53
174
 
54
- const correlationId = `test-local@0/${new Date().toISOString()}`;
175
+ const correlationId = getCorrelationId('test-local');
55
176
  const languageDescription = `${process.release.name} ${process.version}`;
56
177
  const platformDescription = `${process.platform}; ${process.arch}`;
57
178
  const inBracket = `(${platformDescription}; ${languageDescription})`;
58
179
  const userAgent = `test-local ${inBracket}`;
59
180
 
60
- const DEFAULT_MST = {
61
- basePath: '/mST/v1',
62
- protocol: 'http:',
63
- domainName: 'localhost',
64
- port: 8025,
65
- admin: {
66
- clientId: '12345',
67
- clientSecret: 'timeForSecret',
68
- },
69
- };
70
- const DUMMY_MST = {
71
- basePath: '/mST/v1',
72
- protocol: 'http',
73
- domainName: 'dummy-mST',
74
- port: 8025,
75
- admin: {
76
- clientId: '12345',
77
- clientSecret: 'timeForSecret',
78
- },
79
- };
80
- const DUMMY_CUSTOMER_CODE = 'dummy-code';
81
- const DEFAULT_MIT = {
82
- basePath: '/mIT/v1',
83
- protocol: 'http:',
84
- domainName: 'localhost',
85
- port: 8050,
86
- };
87
- const DUMMY_MIT = {
88
- basePath: '/mIT/v1',
89
- protocol: 'http:',
90
- domainName: 'dummy-mIT',
91
- port: 8050,
92
- };
93
- const DEFAULT_MID = {
94
- basePath: '/mID/v1',
95
- protocol: 'http:',
96
- domainName: 'localhost',
97
- port: 8015,
98
- implicit: {
99
- key: 'a-secret-key-for-implicit',
100
- audience: 'https://mimik',
101
- },
102
- };
103
- const DUMMY_MID = {
104
- basePath: '/mID/v1',
105
- protocol: 'http:',
106
- domainName: 'dummy-mID',
107
- port: 8015,
108
- implicit: {
109
- key: 'a-secret-key-for-implicit',
110
- audience: 'https://dummy-mID-audience',
111
- },
112
- };
113
- const DEFAULT_SUMOLOG = {
114
- default: {
115
- url: 'https://default-sumo-endPoint',
116
- code: '--- default code ---',
117
- },
118
- };
119
- const DEFAULT_S3LOG = {
120
- region: '--- default region ---',
121
- accessKeyId: '--- default accessKey Id',
122
- secretAccessKey: '--- default secret accessKey ---',
123
- bucketname: '--- default bucketname ---',
124
- maxEvents: 10,
125
- timeout: 1,
126
- maxSize: 5,
127
- };
128
- const DEFAULT_KINESISLOG = {
129
- region: '--- default region ---',
130
- accessKeyId: '--- default accessKey Id',
131
- secretAccessKey: '--- default secret accessKey ---',
132
- streamNameInfo: '--- default streamName Info ---',
133
- streamNameError: '--- default streamName Error ---',
134
- streamNameOther: '--- default streamName Other ---',
135
- };
136
- const DEFAULT_KEY = {
137
- username: DEFAULT_BITBUCKET_USERNAME,
138
- password: DEFAULT_BITBUCKET_PASSWORD,
139
- };
140
- const DEFAULT_LOCATION = {
141
- url: null,
142
- key: null,
143
- };
144
-
145
181
  const ERR_CHECK = '✘';
146
182
  const SUCCESS_CHECK = '✔︎';
147
183
 
148
184
  export {
149
- packageFile,
150
- mSTConfigFile,
151
- mITConfigFile,
152
- mIDConfigFile,
153
- sumoLogFile,
154
- s3LogFile,
155
- kinesisLogFile,
156
- locationFile,
157
- keyFile,
158
- customerConfigFile,
185
+ DEFAULT,
186
+ DUMMY,
187
+ ERROR_CODE,
159
188
  API_PROVIDER_BITBUCKET,
160
189
  API_PROVIDER_SWAGGERHUB,
161
190
  BITBUCKET,
@@ -165,30 +194,10 @@ export {
165
194
  EXTENSION_YML,
166
195
  POSTFIX,
167
196
  RESOLVED,
168
- DEFAULT_DIRECTORY,
169
- testJsonFile,
170
- shellFile,
171
- startFile,
172
- testStartFile,
173
- exampleStartFile,
174
- exampleTestStartFile,
175
197
  correlationId,
176
198
  userAgent,
177
199
  LITERAL,
178
- IGNORE,
179
200
  TEST,
180
- DEFAULT_MST,
181
- DEFAULT_MIT,
182
- DEFAULT_MID,
183
- DEFAULT_SUMOLOG,
184
- DEFAULT_S3LOG,
185
- DEFAULT_KINESISLOG,
186
- DEFAULT_KEY,
187
- DEFAULT_LOCATION,
188
- DUMMY_MST,
189
- DUMMY_CUSTOMER_CODE,
190
- DUMMY_MIT,
191
- DUMMY_MID,
192
201
  ERR_CHECK,
193
202
  SUCCESS_CHECK,
194
203
  AWS_S3,
@@ -202,6 +211,4 @@ export {
202
211
  TOKEN_SERVICE,
203
212
  IT_REGISTRY,
204
213
  IDENTITY_SERVICE,
205
- DEFAULT_BITBUCKET_USERNAME,
206
- DEFAULT_BITBUCKET_PASSWORD,
207
214
  };
package/lib/helpers.js CHANGED
@@ -1,12 +1,13 @@
1
1
  /* eslint-disable prefer-template, no-console, no-process-env, processDoc/validate-document-env */
2
+ import { readFileSync, writeFileSync } from 'node:fs';
3
+ import { ERROR_CODE } from './common.js';
2
4
  import colors from 'colors';
3
- import fs from 'fs';
4
5
  import ip from 'ip';
6
+ import { isIP } from 'node:net';
5
7
  import isNumber from 'lodash.isnumber';
6
8
  import isObject from 'lodash.isobject';
7
9
  import json from 'comment-json';
8
- import net from 'net';
9
- import process from 'process';
10
+ import process from 'node:process';
10
11
 
11
12
  colors.setTheme({
12
13
  success: 'green',
@@ -37,7 +38,7 @@ const read = (filename, regType) => {
37
38
  let readFile;
38
39
 
39
40
  try {
40
- readFile = fs.readFileSync(filename).toString();
41
+ readFile = readFileSync(filename).toString();
41
42
  }
42
43
  catch (err) {
43
44
  if (err.code !== 'ENOENT') return exitError(regType, err, filename);
@@ -48,8 +49,8 @@ const read = (filename, regType) => {
48
49
 
49
50
  const write = (fname, content, regType, withJSON) => {
50
51
  try {
51
- if (withJSON) fs.writeFileSync(fname, json.stringify(content, null, TAB));
52
- else fs.writeFileSync(fname, content, null, TAB);
52
+ if (withJSON) writeFileSync(fname, json.stringify(content, null, TAB));
53
+ else writeFileSync(fname, content, null, TAB);
53
54
  }
54
55
  catch (err) { exitError(regType, err, fname); }
55
56
  return content;
@@ -105,7 +106,7 @@ const start2process = (start) => {
105
106
  };
106
107
  const setDomainName = (serverType, regType, domainName, port, literal) => {
107
108
  if (!domainName) exitError(regType, `domainName must exist in ${serverType}Config.json`);
108
- const needPort = domainName === 'localhost' || net.isIP(domainName);
109
+ const needPort = domainName === 'localhost' || isIP(domainName);
109
110
 
110
111
  if (needPort && !port) exitError(regType, `port missing in ${serverType}Config.json`);
111
112
  if (domainName === 'localhost' && !literal) return `${ip.address()}:${port}`;
@@ -187,7 +188,7 @@ const retrieve = (regType, filename, options) => {
187
188
  return readFile;
188
189
  }
189
190
  catch (err) {
190
- if (!content) exitError(regType, { statusCode: 404, message: `no files or default (${err.message})` }, fname);
191
+ if (!content) exitError(regType, { statusCode: ERROR_CODE.NOT_FOUND, message: `no files or default (${err.message})` }, fname);
191
192
  console.log('- using ' + 'default'.warn + ' for ' + fname.info);
192
193
  return content;
193
194
  }
@@ -199,7 +200,7 @@ const retrieve = (regType, filename, options) => {
199
200
  return result;
200
201
  }
201
202
  catch (errFilename) {
202
- if (!options) exitError(regType, { statusCode: 404, message: `no options (${errFilename})` }, filename);
203
+ if (!options) exitError(regType, { statusCode: ERROR_CODE.NOT_FOUND, message: `no options (${errFilename})` }, filename);
203
204
  if (options.altFilename) {
204
205
  try {
205
206
  result = parse(read(options.altFilename, regType), options.altFilename, regType);
@@ -208,7 +209,7 @@ const retrieve = (regType, filename, options) => {
208
209
  }
209
210
  catch (errAltFilename) {
210
211
  if (!options.sourceFileName) {
211
- if (!options.default) exitError(regType, { statusCode: 404, message: `no files or default (${errAltFilename})` }, filename);
212
+ if (!options.default) exitError(regType, { statusCode: ERROR_CODE.NOT_FOUND, message: `no files or default (${errAltFilename})` }, filename);
212
213
  console.log('- using ' + 'default'.warn + ' for ' + filename.info);
213
214
  return write(filename, options.default, regType, true);
214
215
  }
@@ -216,7 +217,7 @@ const retrieve = (regType, filename, options) => {
216
217
  }
217
218
  }
218
219
  if (!options.sourceFilename) {
219
- if (!options.default) exitError(regType, { statusCode: 404, message: `no files or default (${errFilename.message})` }, filename);
220
+ if (!options.default) exitError(regType, { statusCode: ERROR_CODE.NOT_FOUND, message: `no files or default (${errFilename.message})` }, filename);
220
221
  console.log('- using ' + 'default'.warn + ' for ' + filename.info);
221
222
  return write(filename, options.default, regType, true);
222
223
  }
@@ -1,6 +1,6 @@
1
- import { correlationId, userAgent } from './common.js';
1
+ import { ERROR_CODE, correlationId, userAgent } from './common.js';
2
+ import { STATUS_CODES } from 'node:http';
2
3
  import axios from 'axios';
3
- import http from 'http';
4
4
 
5
5
  const rp = (origOptions) => {
6
6
  const options = origOptions;
@@ -26,8 +26,8 @@ const rp = (origOptions) => {
26
26
  if (!response) {
27
27
  const error = new Error('system Error');
28
28
 
29
- error.statusCode = 500;
30
- error.title = http.STATUS_CODES[error.statusCode];
29
+ error.statusCode = ERROR_CODE.SYSTEM;
30
+ error.title = STATUS_CODES[error.statusCode];
31
31
  error.info = {
32
32
  code: err.code,
33
33
  address: err.address,
package/lib/tasks.js CHANGED
@@ -8,19 +8,8 @@ import {
8
8
  AWS_KINESIS,
9
9
  AWS_S3,
10
10
  BITBUCKET,
11
- DEFAULT_BITBUCKET_PASSWORD,
12
- DEFAULT_BITBUCKET_USERNAME,
13
- DEFAULT_KEY,
14
- DEFAULT_KINESISLOG,
15
- DEFAULT_LOCATION,
16
- DEFAULT_MID,
17
- DEFAULT_MIT,
18
- DEFAULT_MST,
19
- DEFAULT_S3LOG,
20
- DEFAULT_SUMOLOG,
21
- DUMMY_MID,
22
- DUMMY_MIT,
23
- DUMMY_MST,
11
+ DEFAULT,
12
+ DUMMY,
24
13
  ERR_CHECK,
25
14
  EXTENSION_YML,
26
15
  IDENTITY_SERVICE,
@@ -37,20 +26,6 @@ import {
37
26
  SYSTEM_NAME,
38
27
  TEST,
39
28
  TOKEN_SERVICE,
40
- customerConfigFile,
41
- exampleStartFile,
42
- exampleTestStartFile,
43
- keyFile,
44
- kinesisLogFile,
45
- locationFile,
46
- mIDConfigFile,
47
- mITConfigFile,
48
- mSTConfigFile,
49
- packageFile,
50
- s3LogFile,
51
- startFile,
52
- sumoLogFile,
53
- testStartFile,
54
29
  } from './common.js';
55
30
  import {
56
31
  baseUrl,
@@ -58,18 +33,18 @@ import {
58
33
  retrieve,
59
34
  setDomainName,
60
35
  } from './helpers.js';
36
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
61
37
  import { Base64 } from 'js-base64';
62
38
  import Promise from 'bluebird';
63
39
  import SwaggerClient from 'swagger-client';
64
40
  import clone from 'lodash.clone';
65
41
  import difference from 'lodash.difference';
66
- import fs from 'fs';
67
42
  import { getAllTargets } from './commonExt.js';
68
43
  import isEmpty from 'lodash.isempty';
69
- import { join } from 'path';
44
+ import { join } from 'node:path';
70
45
  import json from 'comment-json';
71
46
  import { load } from 'js-yaml';
72
- import process from 'process';
47
+ import process from 'node:process';
73
48
  import { rp } from './rp-axios-wrapper.js';
74
49
  import split from 'lodash.split';
75
50
  import { v4 as uuidv4 } from 'uuid';
@@ -91,10 +66,13 @@ const getStartParams = (confType) => {
91
66
 
92
67
  process.stdout.write(test);
93
68
  regType += test;
94
- startConfig = retrieve(regType, testStartFile, { sourceFilename: exampleStartFile, sourceFilenameSupp: exampleTestStartFile });
69
+ startConfig = retrieve(regType, DEFAULT.FILE.testStartFile, {
70
+ sourceFilename: DEFAULT.FILE.exampleStartFile,
71
+ sourceFilenameSupp: DEFAULT.FILE.exampleTestStartFile,
72
+ });
95
73
  }
96
74
  else {
97
- startConfig = retrieve(regType, startFile, { sourceFilename: exampleStartFile });
75
+ startConfig = retrieve(regType, DEFAULT.FILE.startFile, { sourceFilename: DEFAULT.FILE.exampleStartFile });
98
76
  }
99
77
  return {
100
78
  regType,
@@ -103,14 +81,14 @@ const getStartParams = (confType) => {
103
81
  };
104
82
 
105
83
  const init = (regType, standAlone, isMSTSet) => {
106
- const pack = retrieve(regType, packageFile);
107
- const sumoLog = retrieve(regType, sumoLogFile, { default: DEFAULT_SUMOLOG });
108
- const s3Log = retrieve(regType, s3LogFile, { default: DEFAULT_S3LOG });
109
- const kinesisLog = retrieve(regType, kinesisLogFile, { default: DEFAULT_KINESISLOG });
110
- const locationProvider = retrieve(regType, locationFile, { default: DEFAULT_LOCATION });
111
- const key = retrieve(regType, keyFile, { default: DEFAULT_KEY });
112
-
113
- console.log('- server type is ' + pack.mimik.type.info);
84
+ const pack = retrieve(regType, DEFAULT.FILE.packageFile);
85
+ const sumoLog = retrieve(regType, DEFAULT.FILE.sumoLogFile, { default: DEFAULT.SUMOLOG });
86
+ const s3Log = retrieve(regType, DEFAULT.FILE.s3LogFile, { default: DEFAULT.S3LOG });
87
+ const kinesisLog = retrieve(regType, DEFAULT.FILE.kinesisLogFile, { default: DEFAULT.KINESISLOG });
88
+ const locationProvider = retrieve(regType, DEFAULT.FILE.locationFile, { default: DEFAULT.LOCATION });
89
+ const key = retrieve(regType, DEFAULT.FILE.keyFile, { default: DEFAULT.KEY });
90
+
91
+ console.log('- server type: ' + pack.mimik.type.info + ', version: ' + pack.version.info);
114
92
  const config = {
115
93
  regType,
116
94
  pack,
@@ -121,19 +99,21 @@ const init = (regType, standAlone, isMSTSet) => {
121
99
  key,
122
100
  };
123
101
 
124
- if (isMSTSet && pack.mimik.type !== TOKEN_SERVICE && pack.mimik.type !== IT_REGISTRY) config.customer = retrieve(regType, customerConfigFile); // we don't need customer for mST or mIT
102
+ if (isMSTSet && pack.mimik.type !== TOKEN_SERVICE && pack.mimik.type !== IT_REGISTRY) {
103
+ config.customer = retrieve(regType, DEFAULT.FILE.customerConfigFile); // we don't need customer for mST or mIT
104
+ };
125
105
  if (standAlone || !isMSTSet) {
126
- config.mST = DUMMY_MST;
106
+ config.mST = DUMMY.MST;
127
107
  console.log('- using ' + 'dummy mSTConfig'.warn);
128
- config.mIT = DUMMY_MIT;
108
+ config.mIT = DUMMY.MIT;
129
109
  console.log('- using ' + 'dummy mITConfig'.warn);
130
- config.mID = DUMMY_MID;
110
+ config.mID = DUMMY.MID;
131
111
  console.log('- using ' + 'dummy mIDConfig'.warn);
132
112
  }
133
113
  else {
134
- config.mST = retrieve(regType, mSTConfigFile, { default: DEFAULT_MST });
135
- config.mIT = retrieve(regType, mITConfigFile, { default: DEFAULT_MIT });
136
- config.mID = retrieve(regType, mIDConfigFile, { default: DEFAULT_MID });
114
+ config.mST = retrieve(regType, DEFAULT.FILE.mSTConfigFile, { default: DEFAULT.MST });
115
+ config.mIT = retrieve(regType, DEFAULT.FILE.mITConfigFile, { default: DEFAULT.MIT });
116
+ config.mID = retrieve(regType, DEFAULT.FILE.mIDConfigFile, { default: DEFAULT.MID });
137
117
  }
138
118
  config.mSTBaseUrl = baseUrl(TOKEN_SERVICE, regType, config.mST);
139
119
  config.MITBaseUrl = baseUrl(IT_REGISTRY, regType, config.mIT);
@@ -170,7 +150,7 @@ const startSetup = (config, origStart) => {
170
150
  let sumoLog = config.sumoLog[type];
171
151
 
172
152
  if (!sumoLog) {
173
- if (!config.sumoLog.default) exitError(regType, Error(`missing sumologic default config in ${sumoLogFile}`));
153
+ if (!config.sumoLog.default) exitError(regType, Error(`missing sumologic default config in ${DEFAULT.FILE.sumoLogFile}`));
174
154
  console.log('- using ' + 'default value'.warn + ' for sumologic');
175
155
  sumoLog = config.sumoLog.default;
176
156
  }
@@ -294,9 +274,9 @@ const getAPI = (directory, swaggerFile, key) => {
294
274
  let apiDefinition;
295
275
 
296
276
  try {
297
- if (fs.existsSync(apiFilename)) {
277
+ if (existsSync(apiFilename)) {
298
278
  process.stdout.write(': ' + apiFilename.info + ' ' + 'already setup'.warn);
299
- apiDefinition = fs.readFileSync(apiFilename, 'utf8');
279
+ apiDefinition = readFileSync(apiFilename, 'utf8');
300
280
  }
301
281
  }
302
282
  catch (err) {
@@ -320,7 +300,7 @@ const getAPI = (directory, swaggerFile, key) => {
320
300
  if (apiDefinitionResult.errors.length !== EMPTY) {
321
301
  throw new Error('Errors while resolving definition');
322
302
  }
323
- fs.writeFileSync(apiFilename, JSON.stringify(apiDefinitionResult.spec, null, TAB));
303
+ writeFileSync(apiFilename, JSON.stringify(apiDefinitionResult.spec, null, TAB));
324
304
  console.log(' ' + SUCCESS_CHECK.success);
325
305
  return apiDefinitionResult.spec;
326
306
  })
@@ -333,8 +313,8 @@ const getAPI = (directory, swaggerFile, key) => {
333
313
  });
334
314
  }
335
315
  try {
336
- if (!fs.existsSync(directory)) {
337
- fs.mkdirSync(directory);
316
+ if (!existsSync(directory)) {
317
+ mkdirSync(directory);
338
318
  }
339
319
  }
340
320
  catch (err) {
@@ -358,7 +338,7 @@ const getAPI = (directory, swaggerFile, key) => {
358
338
  if (!key[BITBUCKET] || !key[BITBUCKET].username || !key[BITBUCKET].password) {
359
339
  throw new Error('missing username/password for accessing Bitbucket');
360
340
  }
361
- if (key[BITBUCKET].username === DEFAULT_BITBUCKET_USERNAME || key[BITBUCKET].password === DEFAULT_BITBUCKET_PASSWORD) {
341
+ if (key[BITBUCKET].username === DEFAULT.KEY.username || key[BITBUCKET].password === DEFAULT.KEY.password) {
362
342
  throw new Error('missing username/password for accessing Bitbucket');
363
343
  }
364
344
  opts.headers.Authorization = `Basic ${Base64.encode(`${key[BITBUCKET].username}:${key[BITBUCKET].password}`)}`;
@@ -386,7 +366,7 @@ const getAPI = (directory, swaggerFile, key) => {
386
366
  if (apiDefinitionResult.errors.length !== EMPTY) {
387
367
  throw new Error('errors while resolving definition');
388
368
  }
389
- fs.writeFileSync(apiFilename, JSON.stringify(apiDefinitionResult.spec, null, TAB));
369
+ writeFileSync(apiFilename, JSON.stringify(apiDefinitionResult.spec, null, TAB));
390
370
  console.log(SUCCESS_CHECK.success);
391
371
  return apiDefinitionResult.spec;
392
372
  })
@@ -1,3 +1,3 @@
1
- import start from '../index.js';
1
+ import { getAPI } from '../lib/tasks.js';
2
2
 
3
- start.getAPI('./testing', 'mimik', 'mDS', '1.1.1');
3
+ getAPI('./testing', 'mimik', 'mDS', '1.1.1');
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable prefer-template, no-console */
2
2
  import colors from 'colors';
3
- import fs from 'fs';
4
3
  import json from 'comment-json';
5
4
  import process from 'process';
5
+ import { readFileSync } from 'node:fs';
6
6
 
7
7
  colors.setTheme({
8
8
  success: 'green',
@@ -60,7 +60,7 @@ const readMerge = (fname, fnameSupp) => {
60
60
  let readFileSuppRaw;
61
61
 
62
62
  try {
63
- readFileRaw = fs.readFileSync(fname).toString();
63
+ readFileRaw = readFileSync(fname).toString();
64
64
  }
65
65
  catch (errFname) {
66
66
  if (errFname.code !== 'ENOENT') exitError(regType, errFname, fname);
@@ -69,7 +69,7 @@ const readMerge = (fname, fnameSupp) => {
69
69
  const readFile = parse(readFileRaw, fname);
70
70
 
71
71
  try {
72
- readFileSuppRaw = fs.readFileSync(fnameSupp).toString();
72
+ readFileSuppRaw = readFileSync(fnameSupp).toString();
73
73
  }
74
74
  catch (errFnameSupp) {
75
75
  if (errFnameSupp.code !== 'ENOENT') exitError(regType, errFnameSupp, fnameSupp);