@roots/bud-build 5.0.0 → 5.1.0

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.
Files changed (64) hide show
  1. package/lib/cjs/Build/config.js +247 -252
  2. package/lib/cjs/Build/index.js +120 -77
  3. package/lib/cjs/Build/items.js +14 -18
  4. package/lib/cjs/Build/loaders.js +4 -3
  5. package/lib/cjs/Build/rules.js +129 -94
  6. package/lib/cjs/Item/index.js +16 -9
  7. package/lib/cjs/Item/item.dependencies.js +0 -1
  8. package/lib/cjs/Item/item.interface.js +0 -1
  9. package/lib/cjs/Loader/index.js +27 -4
  10. package/lib/cjs/Rule/index.js +178 -81
  11. package/lib/cjs/index.js +22 -5
  12. package/lib/cjs/shared/Base.js +0 -1
  13. package/lib/tsconfig.tsbuildinfo +1 -1
  14. package/package.json +9 -26
  15. package/types/Build/config.d.ts.map +1 -1
  16. package/types/Build/index.d.ts +19 -4
  17. package/types/Build/index.d.ts.map +1 -1
  18. package/types/Build/items.d.ts +3 -3
  19. package/types/Build/items.d.ts.map +1 -1
  20. package/types/Build/loaders.d.ts.map +1 -1
  21. package/types/Build/rules.d.ts +38 -21
  22. package/types/Build/rules.d.ts.map +1 -1
  23. package/types/Item/index.d.ts +1 -1
  24. package/types/Item/index.d.ts.map +1 -1
  25. package/types/Rule/index.d.ts +122 -24
  26. package/types/Rule/index.d.ts.map +1 -1
  27. package/types/shared/Base.d.ts.map +1 -1
  28. package/lib/cjs/Build/config.js.map +0 -1
  29. package/lib/cjs/Build/index.js.map +0 -1
  30. package/lib/cjs/Build/items.js.map +0 -1
  31. package/lib/cjs/Build/loaders.js.map +0 -1
  32. package/lib/cjs/Build/rules.js.map +0 -1
  33. package/lib/cjs/Item/index.js.map +0 -1
  34. package/lib/cjs/Item/item.dependencies.js.map +0 -1
  35. package/lib/cjs/Item/item.interface.js.map +0 -1
  36. package/lib/cjs/Loader/index.js.map +0 -1
  37. package/lib/cjs/Rule/index.js.map +0 -1
  38. package/lib/cjs/index.js.map +0 -1
  39. package/lib/cjs/shared/Base.js.map +0 -1
  40. package/lib/esm/Build/config.js +0 -263
  41. package/lib/esm/Build/config.js.map +0 -1
  42. package/lib/esm/Build/index.js +0 -133
  43. package/lib/esm/Build/index.js.map +0 -1
  44. package/lib/esm/Build/items.js +0 -119
  45. package/lib/esm/Build/items.js.map +0 -1
  46. package/lib/esm/Build/loaders.js +0 -55
  47. package/lib/esm/Build/loaders.js.map +0 -1
  48. package/lib/esm/Build/rules.js +0 -129
  49. package/lib/esm/Build/rules.js.map +0 -1
  50. package/lib/esm/Item/index.js +0 -80
  51. package/lib/esm/Item/index.js.map +0 -1
  52. package/lib/esm/Item/item.dependencies.js +0 -4
  53. package/lib/esm/Item/item.dependencies.js.map +0 -1
  54. package/lib/esm/Item/item.interface.js +0 -2
  55. package/lib/esm/Item/item.interface.js.map +0 -1
  56. package/lib/esm/Loader/index.js +0 -49
  57. package/lib/esm/Loader/index.js.map +0 -1
  58. package/lib/esm/Rule/index.js +0 -155
  59. package/lib/esm/Rule/index.js.map +0 -1
  60. package/lib/esm/index.js +0 -26
  61. package/lib/esm/index.js.map +0 -1
  62. package/lib/esm/shared/Base.js +0 -8
  63. package/lib/esm/shared/Base.js.map +0 -1
  64. package/lib/tsconfig-esm.tsbuildinfo +0 -1
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.Item = void 0;
4
- const tslib_1 = require("tslib");
5
10
  const item_dependencies_1 = require("./item.dependencies");
6
11
  const item_interface_1 = require("./item.interface");
7
12
  /**
@@ -15,7 +20,7 @@ class Item extends item_interface_1.Base.Abstract {
15
20
  *
16
21
  * @param options - {@link Base.Options}
17
22
  */
18
- constructor({ loader, options, }) {
23
+ constructor({ loader, options }) {
19
24
  super();
20
25
  this.setLoader(loader);
21
26
  options && this.setOptions(options);
@@ -48,7 +53,10 @@ class Item extends item_interface_1.Base.Abstract {
48
53
  * @decorator `@bind`
49
54
  */
50
55
  mergeOptions(options, app) {
51
- options = Object.assign(Object.assign({}, this.options(app)), options);
56
+ options = {
57
+ ...this.options(app),
58
+ ...options,
59
+ };
52
60
  this.setOptions((app) => options);
53
61
  }
54
62
  /**
@@ -65,20 +73,19 @@ class Item extends item_interface_1.Base.Abstract {
65
73
  return output;
66
74
  }
67
75
  }
68
- (0, tslib_1.__decorate)([
76
+ __decorate([
69
77
  item_dependencies_1.bind
70
78
  ], Item.prototype, "getLoader", null);
71
- (0, tslib_1.__decorate)([
79
+ __decorate([
72
80
  item_dependencies_1.bind
73
81
  ], Item.prototype, "setLoader", null);
74
- (0, tslib_1.__decorate)([
82
+ __decorate([
75
83
  item_dependencies_1.bind
76
84
  ], Item.prototype, "setOptions", null);
77
- (0, tslib_1.__decorate)([
85
+ __decorate([
78
86
  item_dependencies_1.bind
79
87
  ], Item.prototype, "mergeOptions", null);
80
- (0, tslib_1.__decorate)([
88
+ __decorate([
81
89
  item_dependencies_1.bind
82
90
  ], Item.prototype, "make", null);
83
91
  exports.Item = Item;
84
- //# sourceMappingURL=index.js.map
@@ -4,4 +4,3 @@ exports.bind = exports.isFunction = void 0;
4
4
  const bud_support_1 = require("@roots/bud-support");
5
5
  Object.defineProperty(exports, "bind", { enumerable: true, get: function () { return bud_support_1.bind; } });
6
6
  exports.isFunction = bud_support_1.lodash.isFunction;
7
- //# sourceMappingURL=item.dependencies.js.map
@@ -5,4 +5,3 @@ var bud_framework_1 = require("@roots/bud-framework");
5
5
  Object.defineProperty(exports, "Framework", { enumerable: true, get: function () { return bud_framework_1.Framework; } });
6
6
  Object.defineProperty(exports, "Base", { enumerable: true, get: function () { return bud_framework_1.Item; } });
7
7
  Object.defineProperty(exports, "Loader", { enumerable: true, get: function () { return bud_framework_1.Loader; } });
8
- //# sourceMappingURL=item.interface.js.map
@@ -1,8 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ };
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
2
27
  Object.defineProperty(exports, "__esModule", { value: true });
3
28
  exports.Loader = void 0;
4
- const tslib_1 = require("tslib");
5
- const Framework = (0, tslib_1.__importStar)(require("@roots/bud-framework"));
29
+ const Framework = __importStar(require("@roots/bud-framework"));
6
30
  const bud_support_1 = require("@roots/bud-support");
7
31
  const { isFunction } = bud_support_1.lodash;
8
32
  /**
@@ -46,8 +70,7 @@ class Loader extends Framework.Loader.Abstract {
46
70
  return isFunction(input) ? input : () => input;
47
71
  }
48
72
  }
49
- (0, tslib_1.__decorate)([
73
+ __decorate([
50
74
  bud_support_1.bind
51
75
  ], Loader.prototype, "make", null);
52
76
  exports.Loader = Loader;
53
- //# sourceMappingURL=index.js.map
@@ -1,89 +1,172 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.Rule = void 0;
4
- const tslib_1 = require("tslib");
5
- const bud_framework_1 = require("@roots/bud-framework");
6
10
  const bud_support_1 = require("@roots/bud-support");
7
- const { isFunction } = bud_support_1.lodash;
11
+ const Base_1 = require("../shared/Base");
8
12
  /**
9
13
  * Framework Rule
10
14
  *
11
15
  * @public
12
16
  */
13
- class Rule extends bud_framework_1.Rule.Abstract {
17
+ class Rule extends Base_1.Base {
14
18
  /**
15
19
  * Class constructor
16
20
  *
17
21
  * @public
18
22
  */
19
- constructor({ test, use = null, exclude = null, type = null, parser = null, generator = null, }) {
23
+ constructor(app, options) {
20
24
  super();
21
- this.test = isFunction(test) ? test : () => test;
22
- if (use) {
23
- this.use = isFunction(use) ? use : () => use;
24
- }
25
- if (exclude) {
26
- this.exclude = isFunction(exclude)
27
- ? exclude
28
- : () => exclude;
29
- }
30
- if (type) {
31
- this.type = isFunction(type) ? type : () => type;
32
- }
33
- if (parser) {
34
- this.parser = isFunction(parser) ? parser : () => parser;
35
- }
36
- if (generator) {
37
- this.generator = isFunction(generator)
38
- ? generator
39
- : () => generator;
40
- }
41
- }
42
- /**
43
- *
44
- * @param app - {@link @roots/bud-framework#Framework | Framework}
45
- * @returns
25
+ this.app = app;
26
+ if (!options)
27
+ return;
28
+ options.test && this.setTest(options.test);
29
+ options.use && this.setUse(options.use);
30
+ options.include && this.setInclude(options.include);
31
+ options.exclude && this.setExclude(options.exclude);
32
+ options.type && this.setType(options.type);
33
+ options.parser && this.setParser(options.parser);
34
+ options.generator && this.setGenerator(options.generator);
35
+ }
36
+ /**
37
+ * Test value
38
+ *
39
+ * @param app - Framework instance
46
40
  *
47
41
  * @public
48
42
  * @decorator `@bind`
49
43
  */
50
- getTest(app) {
51
- return this.test ? this.test(app) : null;
44
+ getTest() {
45
+ return this.test ? this.test(this.app) : null;
52
46
  }
47
+ /**
48
+ * Set test value
49
+ *
50
+ * @public
51
+ * @decorator `@bind`
52
+ */
53
53
  setTest(test) {
54
- this.test = isFunction(test) ? test : () => test;
54
+ this.test = this.normalizeInput(test);
55
+ return this;
55
56
  }
56
- getParser(app) {
57
- return this.parser ? this.parser(app) : null;
57
+ /**
58
+ * Get parser value
59
+ *
60
+ * @public
61
+ * @decorator `@bind`
62
+ */
63
+ getParser() {
64
+ return this.parser ? this.parser(this.app) : null;
58
65
  }
66
+ /**
67
+ * Set parser value
68
+ *
69
+ * @public
70
+ * @decorator `@bind`
71
+ */
59
72
  setParser(parser) {
60
- this.parser = isFunction(parser) ? parser : () => parser;
73
+ this.parser = this.normalizeInput(parser);
74
+ return this;
61
75
  }
62
- getUse(app) {
63
- return this.use ? this.use(app) : null;
76
+ /**
77
+ * Get use value
78
+ *
79
+ * @public
80
+ * @decorator `@bind`
81
+ */
82
+ getUse() {
83
+ return this.use ? this.use(this.app) : null;
64
84
  }
85
+ /**
86
+ * Set use value
87
+ *
88
+ * @public
89
+ * @decorator `@bind`
90
+ */
65
91
  setUse(use) {
66
- this.use = isFunction(use) ? use : () => use;
92
+ this.use = this.normalizeInput(use);
93
+ return this;
94
+ }
95
+ /**
96
+ * Get exclude value
97
+ *
98
+ * @public
99
+ * @decorator `@bind`
100
+ */
101
+ getInclude() {
102
+ return this.include ? this.include(this.app) : null;
103
+ }
104
+ /**
105
+ * Set exclude value
106
+ *
107
+ * @public
108
+ * @decorator `@bind`
109
+ */
110
+ setInclude(include) {
111
+ this.include = this.normalizeInput(include);
112
+ return this;
67
113
  }
68
- getExclude(app) {
69
- return this.exclude ? this.exclude(app) : null;
114
+ /**
115
+ * Get exclude value
116
+ *
117
+ * @public
118
+ * @decorator `@bind`
119
+ */
120
+ getExclude() {
121
+ return this.exclude ? this.exclude(this.app) : null;
70
122
  }
123
+ /**
124
+ * Set exclude value
125
+ *
126
+ * @public
127
+ * @decorator `@bind`
128
+ */
71
129
  setExclude(exclude) {
72
- this.exclude = isFunction(exclude) ? exclude : () => exclude;
130
+ this.exclude = this.normalizeInput(exclude);
131
+ return this;
73
132
  }
74
- getType(app) {
75
- return this.type ? this.type(app) : null;
133
+ /**
134
+ * Get type value
135
+ *
136
+ * @public
137
+ * @decorator `@bind`
138
+ */
139
+ getType() {
140
+ return this.type ? this.type(this.app) : null;
76
141
  }
142
+ /**
143
+ * Set type value
144
+ *
145
+ * @public
146
+ * @decorator `@bind`
147
+ */
77
148
  setType(type) {
78
- this.type = isFunction(type) ? type : () => type;
149
+ this.type = this.normalizeInput(type);
150
+ return this;
79
151
  }
80
- getGenerator(app) {
81
- return this.generator ? this.generator(app) : null;
152
+ /**
153
+ * Get generator value
154
+ *
155
+ * @public
156
+ * @decorator `@bind`
157
+ */
158
+ getGenerator() {
159
+ return this.generator ? this.generator(this.app) : null;
82
160
  }
161
+ /**
162
+ * Set generator value
163
+ *
164
+ * @public
165
+ * @decorator `@bind`
166
+ */
83
167
  setGenerator(generator) {
84
- this.generator = isFunction(generator)
85
- ? generator
86
- : () => generator;
168
+ this.generator = this.normalizeInput(generator);
169
+ return this;
87
170
  }
88
171
  /**
89
172
  * Produce final Base output
@@ -94,66 +177,80 @@ class Rule extends bud_framework_1.Rule.Abstract {
94
177
  * @public
95
178
  * @decorator `@bind`
96
179
  */
97
- make(app) {
180
+ make() {
98
181
  const output = {
99
- test: this.test(app),
182
+ test: this.test(this.app),
100
183
  };
101
- if (this.use) {
102
- output.use = this.use(app).map(item => item.make(app));
103
- }
104
- if (this.exclude) {
105
- output.exclude = this.exclude(app);
106
- }
107
- if (this.type) {
108
- output.type = this.type(app);
109
- }
110
- if (this.parser) {
111
- output.parser = this.parser(app);
112
- }
113
- if (this.generator) {
114
- output.generator = this.generator(app);
115
- }
184
+ this.use &&
185
+ Object.assign(output, {
186
+ use: this.use(this.app).map(item => item.make(this.app)),
187
+ });
188
+ this.include &&
189
+ Object.assign(output, {
190
+ include: this.include(this.app),
191
+ });
192
+ this.exclude &&
193
+ Object.assign(output, {
194
+ exclude: this.exclude(this.app),
195
+ });
196
+ this.type &&
197
+ Object.assign(output, {
198
+ type: this.type(this.app),
199
+ });
200
+ this.parser &&
201
+ Object.assign(output, {
202
+ parser: this.parser(this.app),
203
+ });
204
+ this.generator &&
205
+ Object.assign(output, {
206
+ generator: this.generator(this.app),
207
+ });
116
208
  return output;
117
209
  }
118
210
  }
119
- (0, tslib_1.__decorate)([
211
+ __decorate([
120
212
  bud_support_1.bind
121
213
  ], Rule.prototype, "getTest", null);
122
- (0, tslib_1.__decorate)([
214
+ __decorate([
123
215
  bud_support_1.bind
124
216
  ], Rule.prototype, "setTest", null);
125
- (0, tslib_1.__decorate)([
217
+ __decorate([
126
218
  bud_support_1.bind
127
219
  ], Rule.prototype, "getParser", null);
128
- (0, tslib_1.__decorate)([
220
+ __decorate([
129
221
  bud_support_1.bind
130
222
  ], Rule.prototype, "setParser", null);
131
- (0, tslib_1.__decorate)([
223
+ __decorate([
132
224
  bud_support_1.bind
133
225
  ], Rule.prototype, "getUse", null);
134
- (0, tslib_1.__decorate)([
226
+ __decorate([
135
227
  bud_support_1.bind
136
228
  ], Rule.prototype, "setUse", null);
137
- (0, tslib_1.__decorate)([
229
+ __decorate([
230
+ bud_support_1.bind
231
+ ], Rule.prototype, "getInclude", null);
232
+ __decorate([
233
+ bud_support_1.bind
234
+ ], Rule.prototype, "setInclude", null);
235
+ __decorate([
138
236
  bud_support_1.bind
139
237
  ], Rule.prototype, "getExclude", null);
140
- (0, tslib_1.__decorate)([
238
+ __decorate([
141
239
  bud_support_1.bind
142
240
  ], Rule.prototype, "setExclude", null);
143
- (0, tslib_1.__decorate)([
241
+ __decorate([
144
242
  bud_support_1.bind
145
243
  ], Rule.prototype, "getType", null);
146
- (0, tslib_1.__decorate)([
244
+ __decorate([
147
245
  bud_support_1.bind
148
246
  ], Rule.prototype, "setType", null);
149
- (0, tslib_1.__decorate)([
247
+ __decorate([
150
248
  bud_support_1.bind
151
249
  ], Rule.prototype, "getGenerator", null);
152
- (0, tslib_1.__decorate)([
250
+ __decorate([
153
251
  bud_support_1.bind
154
252
  ], Rule.prototype, "setGenerator", null);
155
- (0, tslib_1.__decorate)([
253
+ __decorate([
156
254
  bud_support_1.bind
157
255
  ], Rule.prototype, "make", null);
158
256
  exports.Rule = Rule;
159
- //# sourceMappingURL=index.js.map
package/lib/cjs/index.js CHANGED
@@ -1,9 +1,27 @@
1
1
  "use strict";
2
2
  // Copyright (c) Roots Foundation, LLC. All rights reserved.
3
3
  // Licensed under the MIT license.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
7
+ }) : (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ o[k2] = m[k];
10
+ }));
11
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
12
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
13
+ }) : function(o, v) {
14
+ o["default"] = v;
15
+ });
16
+ var __importStar = (this && this.__importStar) || function (mod) {
17
+ if (mod && mod.__esModule) return mod;
18
+ var result = {};
19
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
20
+ __setModuleDefault(result, mod);
21
+ return result;
22
+ };
4
23
  Object.defineProperty(exports, "__esModule", { value: true });
5
24
  exports.rules = exports.loaders = exports.items = exports.Rule = exports.Item = exports.Loader = exports.Build = void 0;
6
- const tslib_1 = require("tslib");
7
25
  /**
8
26
  * Compiler configuration builder
9
27
  *
@@ -27,10 +45,9 @@ var Item_1 = require("./Item");
27
45
  Object.defineProperty(exports, "Item", { enumerable: true, get: function () { return Item_1.Item; } });
28
46
  var Rule_1 = require("./Rule");
29
47
  Object.defineProperty(exports, "Rule", { enumerable: true, get: function () { return Rule_1.Rule; } });
30
- const items = (0, tslib_1.__importStar)(require("./Build/items"));
48
+ const items = __importStar(require("./Build/items"));
31
49
  exports.items = items;
32
- const loaders = (0, tslib_1.__importStar)(require("./Build/loaders"));
50
+ const loaders = __importStar(require("./Build/loaders"));
33
51
  exports.loaders = loaders;
34
- const rules = (0, tslib_1.__importStar)(require("./Build/rules"));
52
+ const rules = __importStar(require("./Build/rules"));
35
53
  exports.rules = rules;
36
- //# sourceMappingURL=index.js.map
@@ -9,4 +9,3 @@ class Base {
9
9
  }
10
10
  }
11
11
  exports.Base = Base;
12
- //# sourceMappingURL=Base.js.map