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