@driveflux/fab 4.0.2 → 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/dist/clean.js CHANGED
@@ -1,26 +1,194 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
8
+ }
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
10
+ try {
11
+ var info = gen[key](arg);
12
+ var value = info.value;
13
+ } catch (error) {
14
+ reject(error);
15
+ return;
16
+ }
17
+ if (info.done) {
18
+ resolve(value);
19
+ } else {
20
+ Promise.resolve(value).then(_next, _throw);
21
+ }
22
+ }
23
+ function _async_to_generator(fn) {
24
+ return function() {
25
+ var self = this, args = arguments;
26
+ return new Promise(function(resolve, reject) {
27
+ var gen = fn.apply(self, args);
28
+ function _next(value) {
29
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
30
+ }
31
+ function _throw(err) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
33
+ }
34
+ _next(undefined);
35
+ });
36
+ };
37
+ }
38
+ function _iterable_to_array(iter) {
39
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
40
+ }
41
+ function _non_iterable_spread() {
42
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
43
+ }
44
+ function _to_consumable_array(arr) {
45
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
46
+ }
47
+ function _unsupported_iterable_to_array(o, minLen) {
48
+ if (!o) return;
49
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
50
+ var n = Object.prototype.toString.call(o).slice(8, -1);
51
+ if (n === "Object" && o.constructor) n = o.constructor.name;
52
+ if (n === "Map" || n === "Set") return Array.from(n);
53
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
54
+ }
55
+ function _ts_generator(thisArg, body) {
56
+ var f, y, t, _ = {
57
+ label: 0,
58
+ sent: function() {
59
+ if (t[0] & 1) throw t[1];
60
+ return t[1];
61
+ },
62
+ trys: [],
63
+ ops: []
64
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
65
+ return d(g, "next", {
66
+ value: verb(0)
67
+ }), d(g, "throw", {
68
+ value: verb(1)
69
+ }), d(g, "return", {
70
+ value: verb(2)
71
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
72
+ value: function() {
73
+ return this;
74
+ }
75
+ }), g;
76
+ function verb(n) {
77
+ return function(v) {
78
+ return step([
79
+ n,
80
+ v
81
+ ]);
82
+ };
83
+ }
84
+ function step(op) {
85
+ if (f) throw new TypeError("Generator is already executing.");
86
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
87
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
88
+ if (y = 0, t) op = [
89
+ op[0] & 2,
90
+ t.value
91
+ ];
92
+ switch(op[0]){
93
+ case 0:
94
+ case 1:
95
+ t = op;
96
+ break;
97
+ case 4:
98
+ _.label++;
99
+ return {
100
+ value: op[1],
101
+ done: false
102
+ };
103
+ case 5:
104
+ _.label++;
105
+ y = op[1];
106
+ op = [
107
+ 0
108
+ ];
109
+ continue;
110
+ case 7:
111
+ op = _.ops.pop();
112
+ _.trys.pop();
113
+ continue;
114
+ default:
115
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
116
+ _ = 0;
117
+ continue;
118
+ }
119
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
120
+ _.label = op[1];
121
+ break;
122
+ }
123
+ if (op[0] === 6 && _.label < t[1]) {
124
+ _.label = t[1];
125
+ t = op;
126
+ break;
127
+ }
128
+ if (t && _.label < t[2]) {
129
+ _.label = t[2];
130
+ _.ops.push(op);
131
+ break;
132
+ }
133
+ if (t[2]) _.ops.pop();
134
+ _.trys.pop();
135
+ continue;
136
+ }
137
+ op = body.call(thisArg, _);
138
+ } catch (e) {
139
+ op = [
140
+ 6,
141
+ e
142
+ ];
143
+ y = 0;
144
+ } finally{
145
+ f = t = 0;
146
+ }
147
+ if (op[0] & 5) throw op[1];
148
+ return {
149
+ value: op[0] ? op[1] : void 0,
150
+ done: true
151
+ };
152
+ }
153
+ }
1
154
  import path from 'node:path';
2
155
  import { deleteAsync } from 'del';
3
156
  import merge from 'lodash.merge';
4
157
  import { getDefaultOptions } from './utils.js';
5
- export const clean = async (rawOptions) => {
6
- const { destination, cleanTs, all, cleanJsGlobs, cleanTsGlobs, cwd, dry } = merge({}, getDefaultOptions(), rawOptions);
7
- const globs = cleanJsGlobs
8
- ? cleanJsGlobs
9
- : [path.resolve(destination, '**/*.js')];
10
- if (cleanTs || all) {
11
- globs.push(path.resolve(cwd || '.', 'tsconfig.tsbuildinfo'));
12
- if (cleanTsGlobs) {
13
- globs.push(...cleanTsGlobs);
14
- }
15
- else {
16
- globs.push(path.resolve(destination, '**/*.d.ts'));
17
- }
18
- }
19
- const result = await deleteAsync(globs, {
20
- dryRun: dry,
21
- });
22
- if (dry) {
23
- console.log('Files and directories that would be deleted:\n', result.join('\n'));
24
- }
158
+ export var clean = function clean(rawOptions) {
159
+ return _async_to_generator(function() {
160
+ var _merge, destination, cleanTs, all, cleanJsGlobs, cleanTsGlobs, cwd, dry, globs, _globs, result;
161
+ return _ts_generator(this, function(_state) {
162
+ switch(_state.label){
163
+ case 0:
164
+ _merge = merge({}, getDefaultOptions(), rawOptions), destination = _merge.destination, cleanTs = _merge.cleanTs, all = _merge.all, cleanJsGlobs = _merge.cleanJsGlobs, cleanTsGlobs = _merge.cleanTsGlobs, cwd = _merge.cwd, dry = _merge.dry;
165
+ globs = cleanJsGlobs ? cleanJsGlobs : [
166
+ path.resolve(destination, '**/*.js')
167
+ ];
168
+ if (cleanTs || all) {
169
+ globs.push(path.resolve(cwd || '.', 'tsconfig.tsbuildinfo'));
170
+ if (cleanTsGlobs) {
171
+ ;
172
+ (_globs = globs).push.apply(_globs, _to_consumable_array(cleanTsGlobs));
173
+ } else {
174
+ globs.push(path.resolve(destination, '**/*.d.ts'));
175
+ }
176
+ }
177
+ return [
178
+ 4,
179
+ deleteAsync(globs, {
180
+ dryRun: dry
181
+ })
182
+ ];
183
+ case 1:
184
+ result = _state.sent();
185
+ if (dry) {
186
+ console.log('Files and directories that would be deleted:\n', result.join('\n'));
187
+ }
188
+ return [
189
+ 2
190
+ ];
191
+ }
192
+ });
193
+ })();
25
194
  };
26
- //# sourceMappingURL=clean.js.map
package/dist/config.js CHANGED
@@ -1,56 +1,283 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _ts_generator(thisArg, body) {
31
+ var f, y, t, _ = {
32
+ label: 0,
33
+ sent: function() {
34
+ if (t[0] & 1) throw t[1];
35
+ return t[1];
36
+ },
37
+ trys: [],
38
+ ops: []
39
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
40
+ return d(g, "next", {
41
+ value: verb(0)
42
+ }), d(g, "throw", {
43
+ value: verb(1)
44
+ }), d(g, "return", {
45
+ value: verb(2)
46
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
47
+ value: function() {
48
+ return this;
49
+ }
50
+ }), g;
51
+ function verb(n) {
52
+ return function(v) {
53
+ return step([
54
+ n,
55
+ v
56
+ ]);
57
+ };
58
+ }
59
+ function step(op) {
60
+ if (f) throw new TypeError("Generator is already executing.");
61
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
62
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
63
+ if (y = 0, t) op = [
64
+ op[0] & 2,
65
+ t.value
66
+ ];
67
+ switch(op[0]){
68
+ case 0:
69
+ case 1:
70
+ t = op;
71
+ break;
72
+ case 4:
73
+ _.label++;
74
+ return {
75
+ value: op[1],
76
+ done: false
77
+ };
78
+ case 5:
79
+ _.label++;
80
+ y = op[1];
81
+ op = [
82
+ 0
83
+ ];
84
+ continue;
85
+ case 7:
86
+ op = _.ops.pop();
87
+ _.trys.pop();
88
+ continue;
89
+ default:
90
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
91
+ _ = 0;
92
+ continue;
93
+ }
94
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
95
+ _.label = op[1];
96
+ break;
97
+ }
98
+ if (op[0] === 6 && _.label < t[1]) {
99
+ _.label = t[1];
100
+ t = op;
101
+ break;
102
+ }
103
+ if (t && _.label < t[2]) {
104
+ _.label = t[2];
105
+ _.ops.push(op);
106
+ break;
107
+ }
108
+ if (t[2]) _.ops.pop();
109
+ _.trys.pop();
110
+ continue;
111
+ }
112
+ op = body.call(thisArg, _);
113
+ } catch (e) {
114
+ op = [
115
+ 6,
116
+ e
117
+ ];
118
+ y = 0;
119
+ } finally{
120
+ f = t = 0;
121
+ }
122
+ if (op[0] & 5) throw op[1];
123
+ return {
124
+ value: op[0] ? op[1] : void 0,
125
+ done: true
126
+ };
127
+ }
128
+ }
1
129
  import fs from 'node:fs/promises';
2
130
  import path from 'node:path';
3
131
  import merge from 'lodash.merge';
4
132
  import { z } from 'zod';
5
133
  import { getDefaultOptions } from './utils.js';
6
- const ConfigValidation = z.object({
134
+ var ConfigValidation = z.object({
7
135
  source: z.string(),
8
136
  destination: z.string(),
9
137
  /**
10
- * The files to copy verbatim. It can be a single source path, it is moved as it is to the destination folder
11
- * or an array of 2 paths [source, destination].
12
- */
13
- copyVerbatim: z.array(z.string().or(z.array(z.string()).length(2))),
138
+ * The files to copy verbatim. It can be a single source path, it is moved as it is to the destination folder
139
+ * or an array of 2 paths [source, destination].
140
+ */ copyVerbatim: z.array(z.string().or(z.array(z.string()).length(2))),
14
141
  cleanJsGlobs: z.array(z.string()).optional(),
15
- cleanTsGlobs: z.array(z.string()).optional(),
142
+ cleanTsGlobs: z.array(z.string()).optional()
16
143
  });
17
- export const parseConfig = async (options) => {
18
- const cwd = options?.cwd || process.cwd();
19
- let config;
20
- if (options?.config) {
21
- config = options.config;
22
- }
23
- else if (options?.configFile) {
24
- config = await readConfigFile(path.resolve(cwd, options.configFile));
25
- }
26
- else {
27
- config = await findConfigFile(cwd);
28
- }
29
- if (!config) {
30
- return getDefaultOptions();
31
- }
32
- const parsed = ConfigValidation.partial().parse(config);
33
- return merge({}, getDefaultOptions(), parsed);
144
+ export var parseConfig = function parseConfig(options) {
145
+ return _async_to_generator(function() {
146
+ var cwd, config, parsed;
147
+ return _ts_generator(this, function(_state) {
148
+ switch(_state.label){
149
+ case 0:
150
+ cwd = (options === null || options === void 0 ? void 0 : options.cwd) || process.cwd();
151
+ if (!(options === null || options === void 0 ? void 0 : options.config)) return [
152
+ 3,
153
+ 1
154
+ ];
155
+ config = options.config;
156
+ return [
157
+ 3,
158
+ 5
159
+ ];
160
+ case 1:
161
+ if (!(options === null || options === void 0 ? void 0 : options.configFile)) return [
162
+ 3,
163
+ 3
164
+ ];
165
+ return [
166
+ 4,
167
+ readConfigFile(path.resolve(cwd, options.configFile))
168
+ ];
169
+ case 2:
170
+ config = _state.sent();
171
+ return [
172
+ 3,
173
+ 5
174
+ ];
175
+ case 3:
176
+ return [
177
+ 4,
178
+ findConfigFile(cwd)
179
+ ];
180
+ case 4:
181
+ config = _state.sent();
182
+ _state.label = 5;
183
+ case 5:
184
+ if (!config) {
185
+ return [
186
+ 2,
187
+ getDefaultOptions()
188
+ ];
189
+ }
190
+ parsed = ConfigValidation.partial().parse(config);
191
+ return [
192
+ 2,
193
+ merge({}, getDefaultOptions(), parsed)
194
+ ];
195
+ }
196
+ });
197
+ })();
34
198
  };
35
- const findConfigFile = async (cwd = process.cwd()) => {
36
- const files = await fs.readdir(cwd);
37
- const configFile = files.find((f) => [
38
- 'fab.config.js',
39
- 'fab.config.cjs',
40
- 'fab.config.mjs',
41
- 'fabrc.json',
42
- '.fabrc',
43
- ].includes(f));
44
- return configFile && (await readConfigFile(path.resolve(cwd, configFile)));
199
+ var findConfigFile = function findConfigFile() {
200
+ var cwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd();
201
+ return _async_to_generator(function() {
202
+ var files, configFile, _tmp;
203
+ return _ts_generator(this, function(_state) {
204
+ switch(_state.label){
205
+ case 0:
206
+ return [
207
+ 4,
208
+ fs.readdir(cwd)
209
+ ];
210
+ case 1:
211
+ files = _state.sent();
212
+ configFile = files.find(function(f) {
213
+ return [
214
+ 'fab.config.js',
215
+ 'fab.config.cjs',
216
+ 'fab.config.mjs',
217
+ 'fabrc.json',
218
+ '.fabrc'
219
+ ].includes(f);
220
+ });
221
+ _tmp = configFile;
222
+ if (!_tmp) return [
223
+ 3,
224
+ 3
225
+ ];
226
+ return [
227
+ 4,
228
+ readConfigFile(path.resolve(cwd, configFile))
229
+ ];
230
+ case 2:
231
+ _tmp = _state.sent();
232
+ _state.label = 3;
233
+ case 3:
234
+ return [
235
+ 2,
236
+ _tmp
237
+ ];
238
+ }
239
+ });
240
+ })();
45
241
  };
46
- const readConfigFile = async (configPath) => {
47
- if (/.+\.(js|cjs|mjs)$/.test(configPath)) {
48
- return (await import(configPath)).default;
49
- }
50
- if (configPath.endsWith('.json') ||
51
- configPath.split('/').pop() === '.fabrc') {
52
- return JSON.parse(await fs.readFile(configPath, 'utf-8'));
53
- }
54
- throw new Error(`Unable to read the config file at ${configPath}`);
242
+ var readConfigFile = function readConfigFile(configPath) {
243
+ return _async_to_generator(function() {
244
+ var _;
245
+ return _ts_generator(this, function(_state) {
246
+ switch(_state.label){
247
+ case 0:
248
+ if (!/.+\.(js|cjs|mjs)$/.test(configPath)) return [
249
+ 3,
250
+ 2
251
+ ];
252
+ return [
253
+ 4,
254
+ import(configPath)
255
+ ];
256
+ case 1:
257
+ return [
258
+ 2,
259
+ _state.sent().default
260
+ ];
261
+ case 2:
262
+ if (!(configPath.endsWith('.json') || configPath.split('/').pop() === '.fabrc')) return [
263
+ 3,
264
+ 4
265
+ ];
266
+ _ = JSON.parse;
267
+ return [
268
+ 4,
269
+ fs.readFile(configPath, 'utf-8')
270
+ ];
271
+ case 3:
272
+ return [
273
+ 2,
274
+ _.apply(JSON, [
275
+ _state.sent()
276
+ ])
277
+ ];
278
+ case 4:
279
+ throw new Error("Unable to read the config file at ".concat(configPath));
280
+ }
281
+ });
282
+ })();
55
283
  };
56
- //# sourceMappingURL=config.js.map
@@ -1,16 +1,15 @@
1
- export const DEV_DEPS_TO_INSTALL = {
1
+ export var DEV_DEPS_TO_INSTALL = {
2
2
  backend: [
3
3
  '@driveflux/fab',
4
4
  '@driveflux/tsconfig',
5
5
  '@types/node',
6
- 'typescript',
6
+ 'typescript'
7
7
  ],
8
8
  frontend: [
9
9
  '@driveflux/fab',
10
10
  '@driveflux/tsconfig',
11
11
  '@types/node',
12
12
  '@types/react',
13
- 'typescript',
14
- ],
13
+ 'typescript'
14
+ ]
15
15
  };
16
- //# sourceMappingURL=create-package-config.js.map