@vamship/build-utils 1.5.3 → 2.0.0-1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. package/package.json +40 -51
  2. package/src/directory.js +36 -24
  3. package/src/index.js +5 -17
  4. package/src/project.js +160 -433
  5. package/src/schema/project-definition.js +137 -0
  6. package/src/task-builder.js +100 -0
  7. package/src/task-builders/build-js-task-builder.js +57 -0
  8. package/src/task-builders/build-task-builder.js +78 -0
  9. package/src/task-builders/build-ts-task-builder.js +63 -0
  10. package/src/task-builders/build-ui-task-builder.js +45 -0
  11. package/src/task-builders/clean-task-builder.js +39 -0
  12. package/src/task-builders/copy-files-task-builder.js +78 -0
  13. package/src/task-builders/docs-js-task-builder.js +74 -0
  14. package/src/task-builders/docs-task-builder.js +74 -0
  15. package/src/task-builders/docs-ts-task-builder.js +52 -0
  16. package/src/task-builders/format-task-builder.js +61 -0
  17. package/src/task-builders/index.js +21 -17
  18. package/src/task-builders/lint-fix-task-builder.js +61 -0
  19. package/src/task-builders/lint-task-builder.js +56 -0
  20. package/src/task-builders/not-supported-task-builder.js +48 -0
  21. package/src/task-builders/package-aws-task-builder.js +105 -0
  22. package/src/task-builders/package-container-task-builder.js +132 -0
  23. package/src/task-builders/package-npm-task-builder.js +83 -0
  24. package/src/task-builders/package-task-builder.js +101 -0
  25. package/src/task-builders/publish-aws-task-builder.js +111 -0
  26. package/src/task-builders/publish-container-task-builder.js +103 -0
  27. package/src/task-builders/publish-npm-task-builder.js +60 -0
  28. package/src/task-builders/publish-task-builder.js +98 -0
  29. package/src/task-builders/test-task-builder.js +85 -0
  30. package/src/task-builders/test-ui-task-builder.js +65 -0
  31. package/src/task-builders/watch-task-builder.js +109 -0
  32. package/src/task-factories/api-task-factory.js +67 -0
  33. package/src/task-factories/aws-microservice-task-factory.js +53 -0
  34. package/src/task-factories/cli-task-factory.js +68 -0
  35. package/src/task-factories/container-task-factory.js +64 -0
  36. package/src/task-factories/index.js +8 -0
  37. package/src/task-factories/lib-task-factory.js +52 -0
  38. package/src/task-factories/ui-task-factory.js +48 -0
  39. package/src/task-factory.js +52 -0
  40. package/src/utils/semver-utils.js +29 -0
  41. package/src/utils/task-factory-utils.js +70 -0
  42. package/src/task-builders/build/build-js.js +0 -66
  43. package/src/task-builders/build/build-ts.js +0 -70
  44. package/src/task-builders/build/build-types.js +0 -47
  45. package/src/task-builders/build/build-ui.js +0 -67
  46. package/src/task-builders/build/index.js +0 -60
  47. package/src/task-builders/clean.js +0 -57
  48. package/src/task-builders/docs/docs-js.js +0 -41
  49. package/src/task-builders/docs/docs-ts.js +0 -40
  50. package/src/task-builders/docs/index.js +0 -32
  51. package/src/task-builders/format.js +0 -58
  52. package/src/task-builders/lint.js +0 -56
  53. package/src/task-builders/package/index.js +0 -50
  54. package/src/task-builders/package/package-aws.js +0 -58
  55. package/src/task-builders/package/package-docker.js +0 -128
  56. package/src/task-builders/package/package-npm.js +0 -25
  57. package/src/task-builders/package/package-types.js +0 -54
  58. package/src/task-builders/package/utils.js +0 -50
  59. package/src/task-builders/publish/index.js +0 -50
  60. package/src/task-builders/publish/publish-aws.js +0 -62
  61. package/src/task-builders/publish/publish-docker.js +0 -79
  62. package/src/task-builders/publish/publish-npm.js +0 -36
  63. package/src/task-builders/publish/publish-types.js +0 -36
  64. package/src/task-builders/test/index.js +0 -39
  65. package/src/task-builders/test/test-ui.js +0 -39
  66. package/src/task-builders/test/test.js +0 -67
package/package.json CHANGED
@@ -1,17 +1,22 @@
1
1
  {
2
2
  "name": "@vamship/build-utils",
3
- "version": "1.5.3",
3
+ "version": "2.0.0-1",
4
4
  "description": "Utility library for build tooling",
5
+ "type": "module",
5
6
  "main": "src/index.js",
6
7
  "scripts": {
7
- "clean": "rm -rf .nyc_output coverage",
8
- "monitor": "nodemon --exec npm run test",
9
- "test": "nyc mocha -R spec --recursive test/unit/ && nyc report --reporter=html",
8
+ "clean": "rm -rf .nyc_output .coverage",
9
+ "watch:test": "NODE_OPTIONS=\"--experimental-vm-modules\" c8 mocha --watch",
10
+ "test": "NODE_OPTIONS=\"--experimental-vm-modules\" c8 mocha",
10
11
  "lint": "eslint src/**/*.js test/**/*.js",
11
12
  "format": "prettier --write \"{{src,test}/**/*.js,README.md}\"",
12
13
  "docs": "jsdoc --readme README.md --package package.json --template node_modules/docdash --destination docs --recurse src",
13
14
  "all": "npm run format && npm run lint && npm run test && npm run clean"
14
15
  },
16
+ "engines": {
17
+ "node": ">= 20.11.0",
18
+ "npm": ">= 10.2.4"
19
+ },
15
20
  "files": [
16
21
  "package.json",
17
22
  "LICENSE",
@@ -41,67 +46,51 @@
41
46
  },
42
47
  "homepage": "https://github.com/vamship/build-utils#readme",
43
48
  "devDependencies": {
44
- "chai": "^4.3.7",
45
- "chai-as-promised": "^7.1.1",
46
- "eslint": "^8.40.0",
47
- "jsdoc": "^4.0.2",
48
- "mocha": "^10.2.0",
49
- "nodemon": "^2.0.22",
50
- "nyc": "^15.1.0",
51
- "prettier": "^2.8.8",
52
- "rewire": "^6.0.0",
53
- "sinon": "^15.0.4",
49
+ "c8": "^9.1.0",
50
+ "chai": "^4.4.1",
51
+ "dot-prop": "^8.0.2",
52
+ "eslint": "^8.56.0",
53
+ "esmock": "^2.6.5",
54
+ "gulp-eslint-new": "^2.0.0",
55
+ "jsdoc": "^4.0.3",
56
+ "mocha": "^10.4.0",
57
+ "nodemon": "^3.1.0",
58
+ "prettier": "^3.2.5",
59
+ "rewire": "^7.0.0",
60
+ "sinon": "^17.0.2",
54
61
  "sinon-chai": "^3.7.0"
55
62
  },
56
63
  "dependencies": {
57
- "camelcase": "^6.3.0",
64
+ "ajv": "^8.13.0",
65
+ "ansi-colors": "^4.1.3",
66
+ "change-case": "^5.4.4",
58
67
  "delete": "^1.1.0",
59
- "docdash": "^2.0.1",
60
- "dotenv": "^16.0.3",
61
- "dotenv-expand": "^10.0.0",
62
- "execa": "^5.1.1",
63
- "fancy-log": "^2.0.0",
68
+ "docdash": "^2.0.2",
69
+ "dotenv": "^16.4.5",
70
+ "dotenv-expand": "^11.0.6",
71
+ "execa": "^9.0.1",
72
+ "fancy-log": ">=2.0.0",
64
73
  "mkdirp": "^3.0.1",
65
- "semver": "^7.5.0"
74
+ "semver": "^7.6.2"
66
75
  },
67
76
  "peerDependencies": {
68
77
  "@typescript-eslint/eslint-plugin": ">= 5.1.0",
69
78
  "@typescript-eslint/parser": ">= 5.1.0",
70
- "eslint": ">= 7.32.0",
71
- "fancy-log": ">= 1.3.3",
79
+ "c8": ">= 7.12.0",
80
+ "eslint": ">= 8.56.0",
81
+ "fancy-log": ">=2.0.0",
72
82
  "gulp": ">= 4.0.2",
73
- "gulp-eslint": ">= 6.0.0",
74
83
  "gulp-prettier": ">= 4.0.0",
75
- "gulp-typedoc": ">= 3.0.1",
76
84
  "gulp-typescript": ">= 5.0.1",
77
85
  "gulp-zip": ">= 5.1.0",
78
- "jsdoc": ">= 4.0.2",
79
- "mocha": ">= 10.2.0",
80
- "nyc": ">= 15.1.0",
81
- "prettier": ">= 2.8.8"
82
- },
83
- "peerDependenciesMeta": {
84
- "gulp-eslint": {
85
- "optional": true
86
- },
87
- "gulp-typedoc": {
88
- "optional": true
89
- },
90
- "gulp-typescript": {
91
- "optional": true
92
- }
86
+ "jsdoc": ">= 3.6.7",
87
+ "mocha": ">= 9.1.2",
88
+ "prettier": ">= 2.4.1",
89
+ "typedoc": ">= 0.24.8"
93
90
  },
94
91
  "optionalDependencies": {
95
- "typedoc": ">=0.24.7",
96
- "typescript": ">=5.0.4"
97
- },
98
- "overrides": {
99
- "glob-parent": "^6.0.2",
100
- "jsdoc": "^4.0.2",
101
- "sanitize-html": "^2.10.0"
102
- },
103
- "engines": {
104
- "node": ">= 14.18.1",
105
- "npm": ">= 8.1.0"
92
+ "gulp-jsdoc3": "= 3.0.0",
93
+ "typedoc": ">=0.25.13",
94
+ "typescript": ">=5.4.5"
106
95
  }
107
96
  }
package/src/directory.js CHANGED
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- const _path = require('path');
1
+ import _path from 'path';
4
2
 
5
3
  const _sepRegexp = new RegExp(_path.sep.replace(/\\/g, '\\\\'), 'g');
6
4
 
@@ -8,13 +6,13 @@ const _sepRegexp = new RegExp(_path.sep.replace(/\\/g, '\\\\'), 'g');
8
6
  * Abstract representation of a directory, with methods for traversal and
9
7
  * glob pattern generation.
10
8
  */
11
- class Directory {
9
+ export class Directory {
12
10
  /**
13
11
  * @param {String} path The path represented by this directory.
14
12
  */
15
13
  constructor(path) {
16
14
  if (typeof path !== 'string') {
17
- throw new Error('Invalid path specified (arg #1)');
15
+ throw new Error('Invalid path (arg #1)');
18
16
  }
19
17
 
20
18
  let relativePath = path.replace(process.cwd(), '');
@@ -39,10 +37,10 @@ class Directory {
39
37
  */
40
38
  static createTree(rootPath, tree) {
41
39
  if (typeof rootPath !== 'string') {
42
- throw new Error('Invalid rootPath specified (arg #1)');
40
+ throw new Error('Invalid rootPath (arg #1)');
43
41
  }
44
42
  if (!tree || tree instanceof Array || typeof tree !== 'object') {
45
- throw new Error('Invalid tree specified (arg #2)');
43
+ throw new Error('Invalid tree (arg #2)');
46
44
  }
47
45
 
48
46
  function createRecursive(parent, tree) {
@@ -72,10 +70,10 @@ class Directory {
72
70
  */
73
71
  static traverseTree(root, callback) {
74
72
  if (!(root instanceof Directory)) {
75
- throw new Error('Invalid root directory specified (arg #1)');
73
+ throw new Error('Invalid root directory (arg #1)');
76
74
  }
77
75
  if (typeof callback !== 'function') {
78
- throw new Error('Invalid callback function specified (arg #1)');
76
+ throw new Error('Invalid callback function (arg #2)');
79
77
  }
80
78
  function traverseRecursive(parent, level) {
81
79
  callback(parent, level);
@@ -129,11 +127,11 @@ class Directory {
129
127
  */
130
128
  addChild(name) {
131
129
  if (typeof name !== 'string' || name.length <= 0) {
132
- throw new Error('Invalid directory name specified (arg #1)');
130
+ throw new Error('Invalid directory name (arg #1)');
133
131
  }
134
132
  if (name.match(/[\\/:]/)) {
135
133
  throw new Error(
136
- 'Directory name cannot include path separators (:, \\ or /)'
134
+ 'Directory name cannot include path separators (:, \\ or /)',
137
135
  );
138
136
  }
139
137
  const child = new Directory(_path.join(this.path, name));
@@ -142,6 +140,16 @@ class Directory {
142
140
  return child;
143
141
  }
144
142
 
143
+ /**
144
+ * Returns an array containing all first level children of the current
145
+ * directory.
146
+ *
147
+ * @return {Directory[]} An array of first level children for the directory.
148
+ */
149
+ getChildren() {
150
+ return this._children.slice();
151
+ }
152
+
145
153
  /**
146
154
  * Retrieves a child directory object by recursively searching through the
147
155
  * current directory's child tree.
@@ -154,7 +162,7 @@ class Directory {
154
162
  */
155
163
  getChild(path) {
156
164
  if (typeof path !== 'string' || path.length <= 0) {
157
- throw new Error('Invalid child path specified (arg #1)');
165
+ throw new Error('Invalid childPath (arg #1)');
158
166
  }
159
167
  const tokens = path.split('/');
160
168
  const child = tokens.reduce((result, name) => {
@@ -171,16 +179,6 @@ class Directory {
171
179
  return child;
172
180
  }
173
181
 
174
- /**
175
- * Returns an array containing all first level children of the current
176
- * directory.
177
- *
178
- * @return {Directory[]} An array of first level children for the directory.
179
- */
180
- getChildren() {
181
- return this._children.slice();
182
- }
183
-
184
182
  /**
185
183
  * Returns the path to a file within the current directory. This file
186
184
  * does not have to actually exist on the file system, and can also be the
@@ -229,6 +227,20 @@ class Directory {
229
227
  }
230
228
  return `${this.globPath}**/${extension}`;
231
229
  }
230
+ /**
231
+ * Gets a string glob that can be used to match all folders/files
232
+ * starting with .(dot) in the current folder and all sub folders,
233
+ * optionally filtered by file extension.
234
+ *
235
+ * @param {String} [extension] An optional extension to use when generating
236
+ * a globbing pattern.
237
+ */
238
+ getAllHiddenFilesGlob(extension) {
239
+ if (typeof extension !== 'string') {
240
+ extension = '.*';
241
+ } else {
242
+ extension = `.*.${extension}`;
243
+ }
244
+ return `${this.globPath}**/${extension}`;
245
+ }
232
246
  }
233
-
234
- module.exports = Directory;
package/src/index.js CHANGED
@@ -3,20 +3,8 @@
3
3
  /**
4
4
  * Utility library that can be used to create development tooling.
5
5
  */
6
- module.exports = {
7
- /**
8
- * A class that represents a directory on the file system.
9
- */
10
- Directory: require('./directory'),
11
-
12
- /**
13
- * Represents a specific project configuration.
14
- */
15
- Project: require('./project'),
16
-
17
- /**
18
- * A collection of task builder functions that can be used to generate
19
- * commonly used gulp files for projects.
20
- */
21
- taskBuilders: require('./task-builders'),
22
- };
6
+ export * from './directory.js';
7
+ export * from './project.js';
8
+ export * from './task-builders/index.js';
9
+ export * from './task-factories/index.js';
10
+ export { getTaskFactory } from './utils/task-factory-utils.js';