js-build-tools 4.0.1 → 4.0.3

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 CHANGED
@@ -138,7 +138,7 @@ const {
138
138
  typescript,
139
139
  watchFull,
140
140
  watchTest
141
- } = require('js-build-tools')
141
+ } = require('js-build-tools/gulpfile.base.js')
142
142
 
143
143
  // Everything you export will be created as a gulp task.
144
144
  // You can build your own tasks here as well by using some of the functions `js-build-tools/functions`.
@@ -169,7 +169,7 @@ export {
169
169
  typescript,
170
170
  watchFull,
171
171
  watchTest
172
- } from 'js-build-tools'
172
+ } from 'js-build-tools/gulpfile.base.mjs'
173
173
 
174
174
  // You can build your own tasks here as well by using some of the functions `js-build-tools/functions`.
175
175
  // You can list your available tasks by running `gulp --tasks`.
@@ -7,26 +7,50 @@ Object.defineProperty(exports, "__esModule", {
7
7
  Object.defineProperty(exports, "afterEach", {
8
8
  enumerable: true,
9
9
  get: function () {
10
- return setUp.afterEach;
10
+ return _testFilesystem.afterEach;
11
11
  }
12
12
  });
13
13
  Object.defineProperty(exports, "beforeEach", {
14
14
  enumerable: true,
15
15
  get: function () {
16
- return setUp.beforeEach;
16
+ return _testFilesystem.beforeEach;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "countMatches", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _testFilesystem.countMatches;
17
23
  }
18
24
  });
19
25
  Object.defineProperty(exports, "createTempDir", {
20
26
  enumerable: true,
21
27
  get: function () {
22
- return setUp.createTempDir;
28
+ return _testFilesystem.createTempDir;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "fileExists", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _testFilesystem.fileExists;
35
+ }
36
+ });
37
+ exports.gulpConfig = void 0;
38
+ Object.defineProperty(exports, "logObject", {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _testFilesystem.logObject;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "removeDirectory", {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _testFilesystem.removeDirectory;
23
48
  }
24
49
  });
25
- exports.setUp = exports.setDefaults = exports.gulpConfig = void 0;
50
+ exports.setDefaults = void 0;
26
51
  var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
27
52
  exports.gulpConfig = gulpConfig;
28
- var setUp = _interopRequireWildcard(require("test-filesystem"));
29
- exports.setUp = setUp;
53
+ var _testFilesystem = require("test-filesystem");
30
54
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
31
55
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
32
56
  // Import the configurations and override some of them to direct to the temp directory.
@@ -43,7 +67,7 @@ const setDefaults = function () {
43
67
  let testDir = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'test-temp';
44
68
  tempDir = `${testDir}/`;
45
69
  srcPath = `${tempDir}src`;
46
- setUp.setDefaults(tempDir);
70
+ _testFilesystem.setUp.setDefaults(tempDir);
47
71
  const distPath = `${tempDir}dist`;
48
72
  const browserPath = `${tempDir}browser`;
49
73
  const sassPath = `${tempDir}sass`;
@@ -10,13 +10,18 @@ var _strBefore = require("./strBefore.js");
10
10
  /**
11
11
  * Get a nested property value from an object.
12
12
  * Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotGet.ts Sí, funciona}
13
- * @param {Object} arrayObject - The array or object to get the property from
14
- * @param {string} dotNotation - The path to the property
13
+ * @param {Object} [arrayObject={}] - The array or object to get the property from
14
+ * @param {string} [dotNotation=''] - The path to the property
15
15
  * @param {string|null} [defaultValue=null] - The default value to return if the property is not found
16
16
  * @returns {*} The value of the property
17
17
  */
18
- const dotGet = function (arrayObject, dotNotation) {
18
+ const dotGet = function () {
19
+ let arrayObject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
20
+ let dotNotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
19
21
  let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
22
+ if (!dotNotation) {
23
+ return arrayObject;
24
+ }
20
25
  let key = (0, _strBefore.strBefore)(dotNotation, '.');
21
26
  const lastKey = !key;
22
27
  if (lastKey) {
@@ -1,6 +1,6 @@
1
1
  // Import the configurations and override some of them to direct to the temp directory.
2
2
  import * as gulpConfig from '../../gulp.config.mjs'
3
- import * as setUp from 'test-filesystem'
3
+ import { setUp } from 'test-filesystem'
4
4
 
5
5
  let tempDir = 'test-temp/'
6
6
  let srcPath = `${tempDir}src`
@@ -40,7 +40,7 @@ export const setDefaults = (testDir = 'test-temp') => {
40
40
  gulpConfig.set('test.watch', `${srcPath}/**/*.js`)
41
41
  }
42
42
 
43
- export { gulpConfig, setUp }
43
+ export { gulpConfig }
44
44
 
45
45
  export {
46
46
  /**
@@ -61,5 +61,29 @@ export {
61
61
  * @memberOf module:testHelpers
62
62
  * @returns {Promise<*>}
63
63
  */
64
- afterEach
64
+ afterEach,
65
+ /**
66
+ * Return number of occurrences of substring in another string.
67
+ * @memberOf module:testHelpers
68
+ * @returns {int}
69
+ */
70
+ countMatches,
71
+ /**
72
+ * Returns true if the given file or directory exists, otherwise false.
73
+ * @memberOf module:testHelpers
74
+ * @returns {boolean}
75
+ */
76
+ fileExists,
77
+ /**
78
+ * Console log objects in a readable format, returns the given object.
79
+ * @memberOf module:testHelpers
80
+ * @returns {*}
81
+ */
82
+ logObject,
83
+ /**
84
+ * Delete a directory and subcontents.
85
+ * @memberOf module:testHelpers
86
+ * @returns {Promise<*>}
87
+ */
88
+ removeDirectory,
65
89
  } from 'test-filesystem'
@@ -2,6 +2,6 @@ import { testHelpers } from './testHelpers.mjs'
2
2
 
3
3
  describe('testHelpers', () => {
4
4
  test('is object with all helper exports', () => {
5
- expect(Object.keys(testHelpers).length).toBe(6)
5
+ expect(Object.keys(testHelpers).length).toBe(9)
6
6
  })
7
7
  })
@@ -5,12 +5,15 @@ import { strBefore } from './strBefore.mjs'
5
5
  /**
6
6
  * Get a nested property value from an object.
7
7
  * Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotGet.ts Sí, funciona}
8
- * @param {Object} arrayObject - The array or object to get the property from
9
- * @param {string} dotNotation - The path to the property
8
+ * @param {Object} [arrayObject={}] - The array or object to get the property from
9
+ * @param {string} [dotNotation=''] - The path to the property
10
10
  * @param {string|null} [defaultValue=null] - The default value to return if the property is not found
11
11
  * @returns {*} The value of the property
12
12
  */
13
- export const dotGet = (arrayObject, dotNotation, defaultValue = null) => {
13
+ export const dotGet = (arrayObject = {}, dotNotation= '', defaultValue = null) => {
14
+ if (!dotNotation) {
15
+ return arrayObject
16
+ }
14
17
  let key = strBefore(dotNotation, '.')
15
18
  const lastKey = !key
16
19
  if (lastKey) {
package/gulp.config.js CHANGED
@@ -209,8 +209,8 @@ const setDefaults = {
209
209
  * @type {Configurations}
210
210
  */
211
211
  let gulpConfigurations = {}
212
- if (fileExists('../../build-tools.config.json')) {
213
- gulpConfigurations = JSON.parse(readFileSync('../../build-tools.config.json').toString())
212
+ if (fileExists(process.cwd() + '/build-tools.config.json')) {
213
+ gulpConfigurations = JSON.parse(readFileSync(process.cwd() + '/build-tools.config.json').toString())
214
214
  } else {
215
215
  if (fileExists('./build-tools.config.json')) {
216
216
  gulpConfigurations = JSON.parse(readFileSync('./build-tools.config.json').toString())
package/gulp.config.mjs CHANGED
@@ -12,22 +12,18 @@ import { fileExists } from 'test-filesystem'
12
12
  * A setting that may be an array of strings or a string only.
13
13
  * @typedef {Array<string>|string} module:gulpConfig~ArrayableSetting
14
14
  */
15
-
16
15
  /**
17
16
  * A setting that may be true or false.
18
17
  * @typedef {boolean} module:gulpConfig~BooleanSetting
19
18
  */
20
-
21
19
  /**
22
20
  * A setting that may be flag 'false' or provide a StringSetting
23
21
  * @typedef {false|StringSetting} module:gulpConfig~FlagStringSetting
24
22
  */
25
-
26
23
  /**
27
24
  * An object of boolean settings used as flags.
28
25
  * @typedef {Object<string, BooleanSetting>} module:gulpConfig~FlagsSetting
29
26
  */
30
-
31
27
  /**
32
28
  * Configure cli options for running Jest.
33
29
  * @typedef {FlagsSetting} module:gulpConfig~JestTestFlags
@@ -41,17 +37,14 @@ import { fileExists } from 'test-filesystem'
41
37
  * @property {BooleanSetting} watch
42
38
  * @property {BooleanSetting} watchAll
43
39
  */
44
-
45
40
  /**
46
41
  * A setting that may only be a string.
47
42
  * @typedef {string} module:gulpConfig~StringSetting
48
43
  */
49
-
50
44
  /**
51
45
  * Any single configuration option is a Setting.
52
46
  * @typedef {ArrayableSetting|BooleanSetting|FlagsSetting|StringSetting} Setting
53
47
  */
54
-
55
48
  /**
56
49
  * Configurations for building the browser files.
57
50
  * @typedef {Object<string, Setting>} module:gulpConfig~BrowserConfig
@@ -60,7 +53,6 @@ import { fileExists } from 'test-filesystem'
60
53
  * @property {StringSetting} name - The search pattern used for retrieving compiled distribution files.
61
54
  * @property {StringSetting} to - The output directory for browser-bundled files.
62
55
  */
63
-
64
56
  /**
65
57
  * Configurations for building the node distribution files.
66
58
  * @typedef {Object<string, Setting>} module:gulpConfig~DistConfig
@@ -68,7 +60,6 @@ import { fileExists } from 'test-filesystem'
68
60
  * @property {StringSetting} main - Name of the entry the distribution file.
69
61
  * @property {StringSetting} to - The output directory for the distribution files.
70
62
  */
71
-
72
63
  /**
73
64
  * Configurations for copying the font files.
74
65
  * @typedef {Object<string, Setting>} module:gulpConfig~FontConfig
@@ -76,7 +67,6 @@ import { fileExists } from 'test-filesystem'
76
67
  * @property {StringSetting} from - Path to search for fonts.
77
68
  * @property {StringSetting} to - Path to output fonts.
78
69
  */
79
-
80
70
  /**
81
71
  * Configurations to minify and copy the images.
82
72
  * @typedef {Object<string, Setting>} module:gulpConfig~ImageConfig
@@ -84,7 +74,6 @@ import { fileExists } from 'test-filesystem'
84
74
  * @property {StringSetting} from - Path to search for images.
85
75
  * @property {StringSetting} to - Path to output images.
86
76
  */
87
-
88
77
  /**
89
78
  * Configurations to compile and generate the Readme file.
90
79
  * @typedef {Object<string, Setting>} module:gulpConfig~ReadmeConfig
@@ -94,7 +83,6 @@ import { fileExists } from 'test-filesystem'
94
83
  * @property {StringSetting} template - The file which will be pre-fixed to your README.md output.
95
84
  * @property {StringSetting} to - The directory to output the readme file in.
96
85
  */
97
-
98
86
  /**
99
87
  * Configurations to compile and copy the sass files into css.
100
88
  * @typedef {Object<string, Setting>} module:gulpConfig~SassConfig
@@ -103,7 +91,6 @@ import { fileExists } from 'test-filesystem'
103
91
  * @property {StringSetting} path - The directory were sass files will be stored.
104
92
  * @property {StringSetting} to - The destination path for where generated CSS (from SASS files) should go.
105
93
  */
106
-
107
94
  /**
108
95
  * Configurations for running the test suite.
109
96
  * @typedef {Object<string, Setting>} module:gulpConfig~TestConfig
@@ -112,7 +99,6 @@ import { fileExists } from 'test-filesystem'
112
99
  * By default, stored as *.test.js adjacent to the files they are testing.
113
100
  * @property {ArrayableSetting} watch - The search pattern for watching files for changes.
114
101
  */
115
-
116
102
  /**
117
103
  * Configurations for compiling typescript into JS files.
118
104
  * @typedef {Object<string, Setting>} module:gulpConfig~TsConfig
@@ -121,7 +107,6 @@ import { fileExists } from 'test-filesystem'
121
107
  * @property {StringSetting} from - Pattern for finding the TypeScript files.
122
108
  * @property {StringSetting} to - Directory where parsed typescript files go.
123
109
  */
124
-
125
110
  /**
126
111
  * A set of Configurations options defined by Settings.
127
112
  * @typedef {Object<string, Setting>} module:gulpConfig~Configurations
@@ -137,7 +122,6 @@ import { fileExists } from 'test-filesystem'
137
122
  * @property {TestConfig} test - Run test suite configuration.
138
123
  * @property {TsConfig} typescript - Compile from typescript configuration.
139
124
  */
140
-
141
125
  import { dotGet } from './functions/utilities/dotGet.mjs'
142
126
  import { dotSet } from './functions/utilities/dotSet.mjs'
143
127
  import { dotNotate } from './functions/utilities/dotNotate.mjs'
@@ -210,9 +194,8 @@ const setDefaults = {
210
194
  * @type {Configurations}
211
195
  */
212
196
  let gulpConfigurations = null
213
-
214
- if (fileExists('../../build-tools.config.json')) {
215
- gulpConfigurations = JSON.parse(readFileSync('../../build-tools.config.json').toString())
197
+ if (fileExists(process.cwd() + '/build-tools.config.json')) {
198
+ gulpConfigurations = JSON.parse(readFileSync(process.cwd() + '/build-tools.config.json').toString())
216
199
  } else {
217
200
  if (fileExists('./build-tools.config.json')) {
218
201
  gulpConfigurations = JSON.parse(readFileSync('./build-tools.config.json').toString())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-build-tools",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Standardised build process with gulp.",
5
5
  "main": "gulpfile.base.js",
6
6
  "exports": {
@@ -13,7 +13,9 @@
13
13
  "./gulp.config.mjs": "./gulp.config.mjs",
14
14
  "./gulpfile.base": "./gulpfile.base.js",
15
15
  "./gulpfile.base.mjs": "./gulpfile.base.mjs",
16
- "./jsdoc.base": "./jsdoc.base.js"
16
+ "./jsdoc.base": "./jsdoc.base.js",
17
+ "./testHelpers": "./dist/testHelpers",
18
+ "./testHelpers.mjs": "./functions/testHelpers.mjs"
17
19
  },
18
20
  "scripts": {
19
21
  "build": "gulp build",
@@ -44,11 +46,11 @@
44
46
  ]
45
47
  },
46
48
  "dependencies": {
47
- "@babel/core": "^7.24.6",
48
- "@babel/plugin-transform-modules-commonjs": "^7.24.6",
49
- "@babel/preset-env": "^7.24.6",
50
- "@babel/preset-typescript": "^7.24.6",
51
- "@babel/runtime-corejs3": "^7.24.6",
49
+ "@babel/core": "^7.24.7",
50
+ "@babel/plugin-transform-modules-commonjs": "^7.24.7",
51
+ "@babel/preset-env": "^7.24.7",
52
+ "@babel/preset-typescript": "^7.24.7",
53
+ "@babel/runtime-corejs3": "^7.24.7",
52
54
  "babel-jest": "^29.7.0",
53
55
  "browserify": "^17.0.0",
54
56
  "core-js": "^3.37.1",