js-build-tools 4.0.1 → 4.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/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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-build-tools",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
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",