@mimik/local 4.4.5 → 5.0.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/.eslintrc CHANGED
@@ -11,8 +11,9 @@
11
11
  },
12
12
  "extends": "airbnb",
13
13
  "rules": {
14
- "import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
15
- "brace-style": [1, "stroustrup", {"allowSingleLine": true}],
14
+ "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
15
+ "import/no-unresolved": ["error", { "amd": true, "commonjs": true, "caseSensitiveStrict": true }],
16
+ "brace-style": [1, "stroustrup", { "allowSingleLine": true }],
16
17
  "no-confusing-arrow": [0], // arrow isnt confusing
17
18
  "max-len": [1, 180, { "ignoreComments": true }],
18
19
  "linebreak-style": 0,
@@ -22,12 +23,11 @@
22
23
  "@mimik/document-env/validate-document-env": 2,
23
24
  "@mimik/dependencies/case-sensitive": 2,
24
25
  "@mimik/dependencies/no-cycles": 2,
25
- "@mimik/dependencies/no-unresolved": 2,
26
26
  "@mimik/dependencies/require-json-ext": 2
27
27
  },
28
28
  "settings":{
29
29
  "react": {
30
- "version": "latest"
30
+ "version": "detect"
31
31
  }
32
32
  },
33
33
  "globals": {
package/README.md CHANGED
@@ -144,39 +144,13 @@ const local = require('@mimik/local');
144
144
  ```
145
145
 
146
146
  * [local](#module_local)
147
- * _Gulp_
148
- * [~test()](#module_local..test)
149
- * [~lint()](#module_local..lint)
150
- * [~docs()](#module_local..docs)
151
- * _sync_
152
- * [~mSTTestSetup()](#module_local..mSTTestSetup) ⇒
153
- * [~mSTSetup()](#module_local..mSTSetup) ⇒
154
- * [~testSetup()](#module_local..testSetup) ⇒
155
- * [~setup()](#module_local..setup) ⇒
156
- * [~testSetup()](#module_local..testSetup) ⇒
157
- * [~setup()](#module_local..setup) ⇒
158
-
159
- <a name="module_local..test"></a>
160
-
161
- ### local~test()
162
- Execute the test associated with that project. The test is under test/http-test.js.
147
+ * [~mSTTestSetup()](#module_local..mSTTestSetup) ⇒
148
+ * [~mSTSetup()](#module_local..mSTSetup)
149
+ * [~testSetup()](#module_local..testSetup)
150
+ * [~setup()](#module_local..setup)
151
+ * [~testSetup()](#module_local..testSetup) ⇒
152
+ * [~setup()](#module_local..setup) ⇒
163
153
 
164
- **Kind**: inner method of [<code>local</code>](#module_local)
165
- **Category**: Gulp
166
- <a name="module_local..lint"></a>
167
-
168
- ### local~lint()
169
- Lint the files of the project.
170
-
171
- **Kind**: inner method of [<code>local</code>](#module_local)
172
- **Category**: Gulp
173
- <a name="module_local..docs"></a>
174
-
175
- ### local~docs()
176
- Generate the README.md file for that project and add it to the git commit. The source to the file is in `./configuration/config.js`.
177
-
178
- **Kind**: inner method of [<code>local</code>](#module_local)
179
- **Category**: Gulp
180
154
  <a name="module_local..mSTTestSetup"></a>
181
155
 
182
156
  ### local~mSTTestSetup() ⇒
@@ -0,0 +1,64 @@
1
+ {
2
+ "env": {
3
+ "node": true
4
+ },
5
+ "plugins": [
6
+ "@mimik/document-env",
7
+ "@mimik/dependencies"
8
+ ],
9
+ "extends": "airbnb",
10
+ "parserOptions": {
11
+ "ecmaVersion": 2020
12
+ },
13
+ "rules": {
14
+ "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
15
+ "import/no-unresolved": ["error", { "amd": true, "commonjs": true, "caseSensitiveStrict": true }],
16
+ "brace-style": [1, "stroustrup", { "allowSingleLine": true }],
17
+ "no-confusing-arrow": [0],
18
+ "max-len": [1, 180, { "ignoreComments": true }],
19
+ "linebreak-style": 0,
20
+ "quotes": [1, "single"],
21
+ "semi": [1, "always"],
22
+ "no-process-env": ["error"],
23
+ "@mimik/document-env/validate-document-env": 2,
24
+ "@mimik/dependencies/case-sensitive": 2,
25
+ "@mimik/dependencies/no-cycles": 2,
26
+ "@mimik/dependencies/require-json-ext": 2
27
+ },
28
+ "overrides": [
29
+ {
30
+ "files": [
31
+ "src/configuration/config.js",
32
+ "test/**/*.js",
33
+ "tools/**/*.js"
34
+ ],
35
+ "rules": {
36
+ "no-process-env": "off"
37
+ }
38
+ },
39
+ {
40
+ "files": [
41
+ "test/**/*.js",
42
+ "tools/**/*.js"
43
+ ],
44
+ "rules": {
45
+ "@mimik/document-env/validate-document-env": "off"
46
+ }
47
+ }
48
+ ],
49
+ "settings": {
50
+ "react": {
51
+ "version": "detect"
52
+ },
53
+ },
54
+ "globals": {
55
+ "module": true,
56
+ "require": true,
57
+ "const": false,
58
+ "it": false,
59
+ "describe": false,
60
+ "before": true,
61
+ "after": true,
62
+ "JSON": true
63
+ }
64
+ }
@@ -0,0 +1,63 @@
1
+ # local
2
+ *.sh
3
+ local/start.json
4
+ local/testStart.json
5
+ package-lock.json
6
+ test/.testConfig.json
7
+
8
+ # Logs
9
+ logs
10
+ *.log
11
+ npm-debug.log*
12
+
13
+ # sublime project
14
+ *sublime*
15
+
16
+ # Runtime data
17
+ pids
18
+ *.pid
19
+ *.seed
20
+
21
+ # Directory for instrumented libs generated by jscoverage/JSCover
22
+ lib-cov
23
+
24
+ # nyc test coverage
25
+ .nyc_output
26
+
27
+ # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
28
+ .grunt
29
+
30
+ # node-waf configuration
31
+ .lock-wscript
32
+
33
+ # Compiled binary addons (http://nodejs.org/api/addons.html)
34
+ build/Release
35
+ coverage
36
+ mochawesome-reports
37
+ mochawesome-report
38
+
39
+ # Dependency directories
40
+ node_modules
41
+ jspm_packages
42
+ api
43
+
44
+ # Optional npm cache directory
45
+ .npm
46
+
47
+ # Optional REPL history
48
+ .node_repl_history
49
+
50
+ #Webstorm configuration
51
+ .idea
52
+
53
+ #OAuth key, etc.
54
+ .env
55
+
56
+ #OSX
57
+ .DS_Store
58
+
59
+ #Windows
60
+ start.*.bat
61
+
62
+ # temp files
63
+ *~
@@ -0,0 +1,4 @@
1
+ {
2
+ "exclude": ["gulpfile.js"],
3
+ "reporter": ["lcov", "text"]
4
+ }
package/index.js CHANGED
@@ -1,13 +1,6 @@
1
1
  /* eslint-disable prefer-template, no-console */
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
- const log = require('fancy-log');
5
- const gulp = require('gulp');
6
- const env = require('gulp-env');
7
- const eslint = require('gulp-eslint');
8
- const git = require('gulp-git');
9
- const jsdoc2md = require('jsdoc-to-markdown');
10
- const mocha = require('gulp-spawn-mocha');
11
4
  const _ = require('lodash');
12
5
 
13
6
  const { commitCheckMsg } = require('@mimik/git-hooks');
@@ -18,6 +11,9 @@ const {
18
11
  start2env,
19
12
  start2shell,
20
13
  baseUrl,
14
+ read,
15
+ write,
16
+ parse,
21
17
  } = require('./lib/helpers');
22
18
  const {
23
19
  defaultDirectory,
@@ -49,6 +45,8 @@ colors.setTheme({
49
45
  info: ['grey', 'bold'],
50
46
  });
51
47
 
48
+ const INSTALL = 'install';
49
+
52
50
  /**
53
51
  * @module local
54
52
  * @example
@@ -620,142 +618,23 @@ const rootPath = (pathName, ignore) => {
620
618
  if (ignore) return `${IGNORE}${rootDir}`;
621
619
  return rootDir;
622
620
  };
623
- const files = [
624
- rootPath('src/**/*.js'),
625
- rootPath('Gulpfile.js'),
626
- rootPath('local/**.js'),
627
- rootPath('test/**/*.js'),
628
- rootPath('tools/**/*.js'),
629
- rootPath('tools/**/{node_modules,node_modules/**}', true),
630
- ];
631
-
632
- /**
633
- *
634
- * Gulp function for local project: test.
635
- *
636
- * @function test
637
- * @category Gulp
638
- *
639
- * @description Execute the test associated with that project. The test is under test/http-test.js.
640
- */
641
- const test = () => {
642
- const envs = env({ file: rootPath('server-test.json') });
643
-
644
- return gulp.src([rootPath('test/http-test.js')], { allowEmpty: true })
645
- .pipe(envs)
646
- .pipe(mocha({
647
- reporter: 'mochawesome',
648
- exit: true,
649
- }))
650
- .pipe(envs.reset);
651
- };
652
-
653
- /**
654
- *
655
- * Gulp function for local project: lint.
656
- *
657
- * @function lint
658
- * @category Gulp
659
- *
660
- * @description Lint the files of the project.
661
- */
662
- const lint = () => gulp.src(files, { allowEmpty: true })
663
- .pipe(eslint({}))
664
- .pipe(eslint.format());
665
621
 
666
- const createDocs = (done) => {
667
- jsdoc2md.render({ files: rootPath('src/configuration/config.js') })
668
- .then((output) => fs.writeFileSync(rootPath('README.md'), output))
669
- .catch((err) => log.error('docs creation failed:', err.message))
670
- .finally(() => done());
622
+ const dotFiles = () => {
623
+ write(rootPath('.eslintrc'), parse(read(path.join(__dirname, 'dotFiles', 'eslintrc.json'), INSTALL)), 'eslintrc.json', INSTALL, true);
624
+ write(rootPath('.nycrc'), parse(read(path.join(__dirname, 'dotFiles', 'nycrc.json'), 'nycrc.json', INSTALL)), INSTALL, true);
625
+ write(rootPath('.gitignore'), read(path.join(__dirname, 'dotFiles', 'gitIgnore.txt'), INSTALL), INSTALL);
671
626
  };
672
627
 
673
- const add = () => gulp.src(rootPath('README.md'))
674
- .pipe(git.add({ quiet: true }));
675
-
676
- /**
677
- *
678
- * Gulp function for local project: docs.
679
- *
680
- * @function docs
681
- * @category Gulp
682
- *
683
- * @description Generate the README.md file for that project and add it to the git commit. The source to the file is in `./configuration/config.js`.
684
- */
685
- const docs = gulp.series(createDocs, add);
686
-
687
- const dotFiles = () => {
688
- const eslintrc = {
689
- env: {
690
- node: true,
691
- },
692
- plugins: [
693
- '@mimik/document-env',
694
- '@mimik/dependencies',
695
- ],
696
- extends: 'airbnb',
697
- parserOptions: {
698
- ecmaVersion: 2020,
699
- },
700
- rules: {
701
- 'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
702
- 'brace-style': [1, 'stroustrup', { allowSingleLine: true }],
703
- 'no-confusing-arrow': [0], // arrow isnt confusing
704
- 'max-len': [1, 180, { ignoreComments: true }],
705
- 'linebreak-style': 0,
706
- quotes: [1, 'single'],
707
- semi: [1, 'always'],
708
- 'no-process-env': ['error'],
709
- '@mimik/document-env/validate-document-env': 2,
710
- '@mimik/dependencies/case-sensitive': 2,
711
- '@mimik/dependencies/no-cycles': 2,
712
- '@mimik/dependencies/no-unresolved': 2,
713
- '@mimik/dependencies/require-json-ext': 2,
714
- },
715
- overrides: [
716
- {
717
- files: [
718
- 'src/configuration/config.js',
719
- 'test/**/*.js',
720
- 'tools/**/*.js',
721
- ],
722
- rules: {
723
- 'no-process-env': 'off',
724
- },
725
- },
726
- {
727
- files: [
728
- 'test/**/*.js',
729
- 'tools/**/*.js',
730
- ],
731
- rules: {
732
- '@mimik/document-env/validate-document-env': 'off',
733
- },
734
- },
735
- ],
736
- settings: {
737
- react: {
738
- version: 'latest',
739
- },
740
- },
741
- globals: {
742
- module: true,
743
- require: true,
744
- const: false,
745
- it: false,
746
- describe: false,
747
- before: true,
748
- after: true,
749
- JSON: true,
750
- },
751
- };
752
- const nycrc = {
753
- exclude: ['gulpfile.js'],
754
- reporter: ['lcov', 'text'],
755
- };
628
+ const scripts = () => {
629
+ const packageFilename = rootPath('package.json');
630
+ const scriptsFile = parse(read(path.join(__dirname, 'scripts.json'), INSTALL), 'scripts.json', INSTALL);
631
+ const packageFile = parse(read(packageFilename, INSTALL), 'package.json', INSTALL);
756
632
 
757
- fs.writeFileSync(rootPath('.eslintrc'), JSON.stringify(eslintrc, null, 2));
758
- fs.writeFileSync(rootPath('.nycrc'), JSON.stringify(nycrc, null, 2));
633
+ Object.keys(scriptsFile.scripts).forEach((script) => {
634
+ packageFile.scripts[script] = scriptsFile.scripts[script];
635
+ });
636
+ packageFile.husky = scriptsFile.husky;
637
+ write(packageFilename, packageFile, 'package.json', INSTALL, true);
759
638
  };
760
639
 
761
640
  module.exports = {
@@ -765,10 +644,7 @@ module.exports = {
765
644
  mITSetup,
766
645
  testSetup,
767
646
  setup,
768
- test,
769
- lint,
770
- docs,
771
- add,
772
647
  dotFiles,
648
+ scripts,
773
649
  commitCheckMsg,
774
650
  };
package/lib/helpers.js CHANGED
@@ -22,6 +22,31 @@ const exitError = (regType, error, filename) => {
22
22
  process.exit(1);
23
23
  };
24
24
 
25
+ const read = (filename, regType) => {
26
+ let readFile;
27
+
28
+ try { readFile = fs.readFileSync(filename).toString(); }
29
+ catch (err) {
30
+ if (err.code !== 'ENOENT') return exitError(regType, err, filename);
31
+ throw err;
32
+ }
33
+ return readFile;
34
+ };
35
+
36
+ const write = (fname, origContent, regType, withJSON) => {
37
+ let content = origContent;
38
+
39
+ if (withJSON) content = json.stringify(content, null, 2);
40
+ try { fs.writeFileSync(fname, content); }
41
+ catch (err) { exitError(regType, err, fname); }
42
+ return content;
43
+ };
44
+
45
+ const parse = (rawFile, rawFilename, regType) => {
46
+ try { return json.parse(rawFile); }
47
+ catch (errParse) { return exitError(regType, errParse, rawFilename); }
48
+ };
49
+
25
50
  const start2shell = (start) => {
26
51
  let result = '#!/bin/sh\n';
27
52
 
@@ -103,23 +128,7 @@ const baseUrl = (serverType, regType, config, literal) => {
103
128
  const retrieve = (regType, filename, options) => {
104
129
  let result;
105
130
 
106
- const read = (fname) => {
107
- let readFile;
108
-
109
- try { readFile = json.parse(fs.readFileSync(fname).toString()); }
110
- catch (err) {
111
- if (err.code !== 'ENOENT') exitError(regType, err, fname);
112
- throw err;
113
- }
114
- return readFile;
115
- };
116
-
117
131
  const readMerge = (fname, fnameSupp) => {
118
- const parse = (rawFile, rawFilename) => {
119
- try { return json.parse(rawFile); }
120
- catch (errParse) { return exitError(regType, errParse, rawFilename); }
121
- };
122
-
123
132
  const merge = (origRawFile, parsedFile, origRawFileSupp, parsedFileSupp) => {
124
133
  const keysParsedFile = Object.keys(parsedFile);
125
134
  let rawFile = origRawFile;
@@ -137,30 +146,17 @@ const retrieve = (regType, filename, options) => {
137
146
  return `${rawFile},\n//-- test\n${rawFileSupp}`;
138
147
  };
139
148
 
140
- let readFileRaw;
141
149
  let readFileSuppRaw;
142
-
143
- try { readFileRaw = fs.readFileSync(fname).toString(); }
144
- catch (errFname) {
145
- if (errFname.code !== 'ENOENT') exitError(regType, errFname, fname);
146
- throw errFname;
147
- }
148
- const readFile = parse(readFileRaw, fname);
150
+ const readFileRaw = read(fname, regType);
151
+ const readFile = parse(readFileRaw, fname, regType);
149
152
 
150
153
  if (!fnameSupp) return readFile;
151
- try { readFileSuppRaw = fs.readFileSync(fnameSupp).toString(); }
154
+ try { readFileSuppRaw = read(fnameSupp, regType); }
152
155
  catch (errFnameSupp) {
153
- if (errFnameSupp.code !== 'ENOENT') exitError(regType, errFnameSupp, fnameSupp);
154
156
  return readFile;
155
157
  }
156
158
 
157
- return parse(merge(readFileRaw, readFile, readFileSuppRaw, parse(readFileSuppRaw, fnameSupp)), `${fname} + ${fnameSupp}`);
158
- };
159
-
160
- const write = (fname, content) => {
161
- try { fs.writeFileSync(fname, json.stringify(content, null, 2)); }
162
- catch (err) { exitError(regType, err, fname); }
163
- return content;
159
+ return parse(merge(readFileRaw, readFile, readFileSuppRaw, parse(readFileSuppRaw, fnameSupp, regType)), `${fname} + ${fnameSupp}`, regType);
164
160
  };
165
161
 
166
162
  const readSourceDefault = (fSource, fSourceSupp, content, fname) => {
@@ -179,7 +175,7 @@ const retrieve = (regType, filename, options) => {
179
175
  };
180
176
 
181
177
  try {
182
- result = read(filename);
178
+ result = parse(read(filename, regType), filename, regType);
183
179
  console.log('- using ' + filename.info);
184
180
  return result;
185
181
  }
@@ -187,7 +183,7 @@ const retrieve = (regType, filename, options) => {
187
183
  if (!options) exitError(regType, { statusCode: 404, message: `no options (${errFilename})` }, filename);
188
184
  if (options.altFilename) {
189
185
  try {
190
- result = read(options.altFilename);
186
+ result = parse(read(options.altFilename, regType), options.altFilename, regType);
191
187
  console.log('- using ' + options.altFilename.info);
192
188
  return result;
193
189
  }
@@ -195,17 +191,17 @@ const retrieve = (regType, filename, options) => {
195
191
  if (!options.sourceFileName) {
196
192
  if (!options.default) exitError(regType, { statusCode: 404, message: `no files or default (${errAltFilename})` }, filename);
197
193
  console.log('- using ' + 'default'.warn + ' for ' + filename.info);
198
- return write(filename, options.default);
194
+ return write(filename, options.default, regType);
199
195
  }
200
- return write(filename, readSourceDefault(options.sourceFilename, options.sourceFilenameSupp, options.default, filename));
196
+ return write(filename, readSourceDefault(options.sourceFilename, options.sourceFilenameSupp, options.default, filename), regType);
201
197
  }
202
198
  }
203
199
  if (!options.sourceFilename) {
204
200
  if (!options.default) exitError(regType, { statusCode: 404, message: `no files or default (${errFilename.message})` }, filename);
205
201
  console.log('- using ' + 'default'.warn + ' for ' + filename.info);
206
- return write(filename, options.default);
202
+ return write(filename, options.default, regType);
207
203
  }
208
- return write(filename, readSourceDefault(options.sourceFilename, options.sourceFilenameSupp, options.default, filename));
204
+ return write(filename, readSourceDefault(options.sourceFilename, options.sourceFilenameSupp, options.default, filename), regType);
209
205
  }
210
206
  };
211
207
 
@@ -218,4 +214,7 @@ module.exports = {
218
214
  setDomainName,
219
215
  baseUrl,
220
216
  retrieve,
217
+ read,
218
+ write,
219
+ parse,
221
220
  };
@@ -1,3 +1,3 @@
1
1
  const start = require('../index');
2
2
 
3
- return start.getAPI('./testing', 'mimik', 'mDS', '1.1.1')
3
+ start.getAPI('./testing', 'mimik', 'mDS', '1.1.1');
@@ -1,7 +1,8 @@
1
- const { retrieve }= require('../lib/helpers');
1
+ /* eslint-disable no-console */
2
+ const { retrieve } = require('../lib/helpers');
2
3
 
3
4
  // console.log(retrieve('test', 'test.json', { sourceFilename: './start-example.json', sourceFilenameSupp: 'startTest-example.json' } ));
4
5
 
5
6
  // console.log(retrieve('test', 'test.json'));
6
7
  // console.log(retrieve('test', 'test.json', { sourceFilename: './nonexistent.json', sourceFilenameSupp: 'startTest-example.json' }));
7
- console.log(retrieve('test', 'test.json', { sourceFilename: './start-example.json' } ));
8
+ console.log(retrieve('test', 'test.json', { sourceFilename: './start-example.json' }));
@@ -1,3 +1,4 @@
1
+ /* eslint-disable prefer-template, no-console, no-process-env */
1
2
  const colors = require('colors');
2
3
  const fs = require('fs');
3
4
  const json = require('comment-json');
@@ -21,46 +22,47 @@ const exitError = (regType, error, filename) => {
21
22
  const regType = 'test';
22
23
 
23
24
  const readMerge = (fname, fnameSupp) => {
24
- const parse = (rawFile, rawFilename) => {
25
- try { return json.parse(rawFile); }
26
- catch (errParse) { exitError(regType, errParse, rawFilename); }
27
- };
25
+ const parse = (rawFile, rawFilename) => {
26
+ try { return json.parse(rawFile); }
27
+ catch (errParse) {
28
+ return exitError(regType, errParse, rawFilename);
29
+ }
30
+ };
28
31
 
29
- const merge = (origRawFile, parsedFile, origRawFileSupp, parsedFileSupp) => {
30
- const keysParsedFile = Object.keys(parsedFile);
31
- let rawFile = origRawFile;
32
- let rawFileSupp = origRawFileSupp;
32
+ const merge = (origRawFile, parsedFile, origRawFileSupp, parsedFileSupp) => {
33
+ const keysParsedFile = Object.keys(parsedFile);
34
+ let rawFile = origRawFile;
35
+ let rawFileSupp = origRawFileSupp;
33
36
 
34
- Object.keys(parsedFileSupp).forEach((key) => {
35
- if (keysParsedFile.includes(key)) {
36
- const regex = new RegExp(`\n[ \t]+"${key}"`);
37
+ Object.keys(parsedFileSupp).forEach((key) => {
38
+ if (keysParsedFile.includes(key)) {
39
+ const regex = new RegExp(`\n[ \t]+"${key}"`);
37
40
 
38
- rawFile = rawFile.replace(regex, `\n// "${key}"`)
39
- }
40
- });
41
- rawFile = rawFile.substring(0, rawFile.length - 2);
42
- rawFileSupp = rawFileSupp.substring(1);
43
- return `${rawFile},\n//-- test\n${rawFileSupp}`;
44
- };
41
+ rawFile = rawFile.replace(regex, `\n// "${key}"`);
42
+ }
43
+ });
44
+ rawFile = rawFile.substring(0, rawFile.length - 2);
45
+ rawFileSupp = rawFileSupp.substring(1);
46
+ return `${rawFile},\n//-- test\n${rawFileSupp}`;
47
+ };
45
48
 
46
- let readFileRaw;
47
- let readFileSuppRaw;
49
+ let readFileRaw;
50
+ let readFileSuppRaw;
48
51
 
49
- try { readFileRaw = fs.readFileSync(fname).toString(); }
50
- catch (errFname) {
51
- if (errFname.code !== 'ENOENT') exitError(regType, errFname, fname);
52
- throw errFname;
53
- }
54
- const readFile = parse(readFileRaw, fname);
55
-
56
- try { readFileSuppRaw = fs.readFileSync(fnameSupp).toString(); }
57
- catch (errFnameSupp) {
58
- if (errFnameSupp.code !== 'ENOENT') exitError(regType, errFnameSupp, fnameSupp);
59
- return readFile;
60
- }
61
-
62
- return parse(merge(readFileRaw, readFile, readFileSuppRaw, parse(readFileSuppRaw, fnameSupp)), `${fname} + ${fnameSupp}`);
63
- };
52
+ try { readFileRaw = fs.readFileSync(fname).toString(); }
53
+ catch (errFname) {
54
+ if (errFname.code !== 'ENOENT') exitError(regType, errFname, fname);
55
+ throw errFname;
56
+ }
57
+ const readFile = parse(readFileRaw, fname);
64
58
 
59
+ try { readFileSuppRaw = fs.readFileSync(fnameSupp).toString(); }
60
+ catch (errFnameSupp) {
61
+ if (errFnameSupp.code !== 'ENOENT') exitError(regType, errFnameSupp, fnameSupp);
62
+ return readFile;
63
+ }
64
+
65
+ return parse(merge(readFileRaw, readFile, readFileSuppRaw, parse(readFileSuppRaw, fnameSupp)), `${fname} + ${fnameSupp}`);
66
+ };
65
67
 
66
- console.log(json.stringify(readMerge('../../../mst-2297/local/start-example.json', '../../../mst-2297/local/startTest-example.json'), null, 2))
68
+ console.log(json.stringify(readMerge('../../../mst-2297/local/start-example.json', '../../../mst-2297/local/startTest-example.json'), null, 2));
@@ -1,7 +1,8 @@
1
+ /* eslint-disable no-console */
1
2
  const _ = require('lodash');
2
3
 
3
4
  const test = ' a, b ,c,d ';
4
- const allTest = 'all '
5
+ const allTest = 'all ';
5
6
 
6
7
  console.log(_.split(_.trim(test), /\s*,\s*/));
7
- console.log(_.split(_.trim(allTest), /\s*,\s*/));
8
+ console.log(_.split(_.trim(allTest), /\s*,\s*/));
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@mimik/local",
3
- "version": "4.4.5",
3
+ "version": "5.0.2",
4
4
  "description": "Local setup configuration for normal and test opreration",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "lint": "gulp lint",
8
- "docs": "gulp docs",
9
- "test": "exit 0",
10
- "prepublishOnly": "gulp docs; gulp lint; npm run test",
11
- "commit-ready": "gulp docs; gulp lint; npm run test",
7
+ "lint": "eslint --ignore-path .gitignore .",
8
+ "docs": "jsdoc2md index.js > README.md",
9
+ "test": "echo \"Error: no test specified\" && exit 0",
10
+ "test-ci": "echo \"Error: no test specified\" && exit 0",
11
+ "prepublishOnly": "npm run docs && npm run lint && npm run test-ci",
12
+ "commit-ready": "npm run docs && npm run lint && npm run test-ci",
12
13
  "prepare": "husky install"
13
14
  },
14
15
  "husky": {
@@ -22,43 +23,37 @@
22
23
  "microservice"
23
24
  ],
24
25
  "author": "mimik technology inc <support@mimik.com> (https://developer.mimik.com/)",
25
- "license": "Apache-2.0",
26
+ "license": "MIT",
26
27
  "repository": {
27
28
  "type": "git",
28
29
  "url": "https://bitbucket.org/mimiktech/local"
29
30
  },
30
31
  "dependencies": {
31
- "@mimik/eslint-plugin-dependencies": "2.4.1",
32
- "@mimik/eslint-plugin-document-env": "1.0.1",
33
- "@mimik/git-hooks": "1.5.3",
34
- "axios": "0.24.0",
32
+ "@mimik/git-hooks": "1.5.4",
33
+ "axios": "0.27.2",
35
34
  "bluebird": "3.7.2",
36
- "chai": "4.3.4",
37
35
  "colors": "1.4.0",
38
- "comment-json": "4.1.1",
39
- "debug": "4.3.3",
40
- "eslint": "8.7.0",
41
- "eslint-config-airbnb": "18.2.1",
42
- "eslint-plugin-import": "2.25.4",
43
- "eslint-plugin-jsx-a11y": "6.5.1",
44
- "eslint-plugin-react": "7.28.0",
45
- "eslint-plugin-react-hooks": "4.3.0",
46
- "fancy-log": "2.0.0",
47
- "gulp": "4.0.2",
48
- "gulp-env": "0.4.0",
49
- "gulp-eslint": "6.0.0",
50
- "gulp-git": "2.10.1",
51
- "gulp-spawn-mocha": "6.0.0",
52
- "ip": "1.1.5",
53
- "jsdoc-to-markdown": "7.1.0",
36
+ "comment-json": "4.2.2",
37
+ "debug": "4.3.4",
38
+ "ip": "1.1.8",
54
39
  "lodash": "4.17.21",
55
- "mocha": "9.1.4",
56
- "mochawesome": "7.0.1",
40
+ "uuid": "8.3.2",
41
+ "@mimik/eslint-plugin-dependencies": "^2.4.3",
42
+ "@mimik/eslint-plugin-document-env": "^1.0.3",
43
+ "chai": "4.3.6",
44
+ "eslint": "8.16.0",
45
+ "eslint-config-airbnb": "19.0.4",
46
+ "eslint-plugin-import": "2.26.0",
47
+ "eslint-plugin-jsx-a11y": "6.5.1",
48
+ "eslint-plugin-react": "7.30.0",
49
+ "eslint-plugin-react-hooks": "4.5.0",
50
+ "husky": "8.0.1",
51
+ "jsdoc-to-markdown": "7.1.1",
52
+ "mocha": "10.0.0",
53
+ "mochawesome": "7.1.3",
57
54
  "nyc": "15.1.0",
58
- "supertest": "6.2.1",
59
- "uuid": "8.3.2"
60
- },
61
- "devDependencies": {
62
- "husky": "7.0.4"
55
+ "rewire": "6.0.0",
56
+ "sinon": "14.0.0",
57
+ "supertest": "6.2.3"
63
58
  }
64
59
  }
package/scripts.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "scripts": {
3
+ "lint": "eslint --ignore-path .gitignore .",
4
+ "docs": "jsdoc2md index.js > README.md",
5
+ "pretest": "node ./local/testSetup.js",
6
+ "test": "mocha --reporter mochawesome --bail --check-leaks test/",
7
+ "test-ci": "nyc --reporter=lcov --reporter=text npm test",
8
+ "prestart": "node ./local/setup.js",
9
+ "start": "sh server-start.sh",
10
+ "pre-push": "npm run docs && npm run lint && npm run test",
11
+ "pre-commit": "npm run docs && npm run lint",
12
+ "prepare": "husky install"
13
+ },
14
+ "husky": {
15
+ "hooks": {
16
+ "pre-commit": "npm run pre-commit",
17
+ "pre-push": "npm run pre-push",
18
+ "commit-msg": "node ./local/commitMsgCheck $1"
19
+ }
20
+ }
21
+ }
package/Gulpfile.js DELETED
@@ -1,34 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- const fs = require('fs');
3
- const log = require('fancy-log');
4
- const gulp = require('gulp');
5
- const eslint = require('gulp-eslint');
6
- const git = require('gulp-git');
7
- const jsdoc2md = require('jsdoc-to-markdown');
8
-
9
- const files = [
10
- 'index.js',
11
- 'Gulpfile.js',
12
- 'configuration/**/*.js',
13
- 'test/**/*.js',
14
- 'lib/**/*.js',
15
- ];
16
-
17
- const createDocs = (done) => {
18
- jsdoc2md.render({ files: 'index.js' })
19
- .then((output) => fs.writeFileSync('README.md', output))
20
- .catch((err) => log.error('docs creation failed:', err.message))
21
- .finally(() => done());
22
- };
23
-
24
- const lint = () => gulp.src(files)
25
- .pipe(eslint({}))
26
- .pipe(eslint.format());
27
-
28
- const add = () => gulp.src('README.md')
29
- .pipe(git.add({ quiet: true }));
30
-
31
- const docs = gulp.series(createDocs, add);
32
-
33
- gulp.task('docs', docs);
34
- gulp.task('lint', lint);