@driveflux/fab 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/dist/build.js +78 -411
- package/dist/clean.js +21 -189
- package/dist/config.js +43 -270
- package/dist/create-package-config.js +5 -4
- package/dist/create.js +43 -287
- package/dist/index.js +1 -0
- package/dist/types.js +2 -1
- package/dist/utils.js +39 -246
- package/package.json +3 -3
package/dist/create.js
CHANGED
|
@@ -1,295 +1,51 @@
|
|
|
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
|
-
}
|
|
154
1
|
import fs from 'node:fs/promises';
|
|
155
2
|
import path from 'node:path';
|
|
156
3
|
import { deleteAsync } from 'del';
|
|
157
4
|
import { DEV_DEPS_TO_INSTALL } from './create-package-config.js';
|
|
158
5
|
import { ensureDir, getBaseDir, runCommand } from './utils.js';
|
|
159
|
-
export
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
_state.trys.push([
|
|
172
|
-
1,
|
|
173
|
-
6,
|
|
174
|
-
,
|
|
175
|
-
7
|
|
176
|
-
]);
|
|
177
|
-
return [
|
|
178
|
-
4,
|
|
179
|
-
fs.stat(finalDestination)
|
|
180
|
-
];
|
|
181
|
-
case 2:
|
|
182
|
-
if (!_state.sent()) return [
|
|
183
|
-
3,
|
|
184
|
-
5
|
|
185
|
-
];
|
|
186
|
-
if (!!dangerouslyRewrite) return [
|
|
187
|
-
3,
|
|
188
|
-
3
|
|
189
|
-
];
|
|
190
|
-
console.log("\uD83D\uDEA8 Cannot create the pacakge at ".concat(finalDestination, '. Please delete the previous file or directory or use "dangerouslyRewrite"'));
|
|
191
|
-
process.exit(1);
|
|
192
|
-
return [
|
|
193
|
-
3,
|
|
194
|
-
5
|
|
195
|
-
];
|
|
196
|
-
case 3:
|
|
197
|
-
return [
|
|
198
|
-
4,
|
|
199
|
-
deleteAsync(finalDestination)
|
|
200
|
-
];
|
|
201
|
-
case 4:
|
|
202
|
-
_state.sent();
|
|
203
|
-
_state.label = 5;
|
|
204
|
-
case 5:
|
|
205
|
-
return [
|
|
206
|
-
3,
|
|
207
|
-
7
|
|
208
|
-
];
|
|
209
|
-
case 6:
|
|
210
|
-
_e = _state.sent();
|
|
211
|
-
return [
|
|
212
|
-
3,
|
|
213
|
-
7
|
|
214
|
-
];
|
|
215
|
-
case 7:
|
|
216
|
-
// Make sure the folder exists
|
|
217
|
-
return [
|
|
218
|
-
4,
|
|
219
|
-
ensureDir(finalDestination)
|
|
220
|
-
];
|
|
221
|
-
case 8:
|
|
222
|
-
_state.sent();
|
|
223
|
-
templatePath = path.resolve(getBaseDir(), "templates/".concat(template));
|
|
224
|
-
return [
|
|
225
|
-
4,
|
|
226
|
-
fs.stat(templatePath)
|
|
227
|
-
];
|
|
228
|
-
case 9:
|
|
229
|
-
// Make sure the template exists
|
|
230
|
-
if (!_state.sent().isDirectory()) {
|
|
231
|
-
throw new Error("The template ".concat(template, " doesn't exist"));
|
|
232
|
-
}
|
|
233
|
-
// First, copy the template into the destintion
|
|
234
|
-
return [
|
|
235
|
-
4,
|
|
236
|
-
fs.cp(templatePath, finalDestination, {
|
|
237
|
-
recursive: true
|
|
238
|
-
})
|
|
239
|
-
];
|
|
240
|
-
case 10:
|
|
241
|
-
_state.sent();
|
|
242
|
-
// Now we insert the name into the package file
|
|
243
|
-
return [
|
|
244
|
-
4,
|
|
245
|
-
replaceInFile("".concat(finalDestination, "/package.json"), {
|
|
246
|
-
name: name
|
|
247
|
-
})
|
|
248
|
-
];
|
|
249
|
-
case 11:
|
|
250
|
-
_state.sent();
|
|
251
|
-
return [
|
|
252
|
-
4,
|
|
253
|
-
runCommand('pnpm', [
|
|
254
|
-
'add',
|
|
255
|
-
'-D'
|
|
256
|
-
].concat(_to_consumable_array(DEV_DEPS_TO_INSTALL[template])), {
|
|
257
|
-
cwd: cwd
|
|
258
|
-
})
|
|
259
|
-
];
|
|
260
|
-
case 12:
|
|
261
|
-
_state.sent();
|
|
262
|
-
return [
|
|
263
|
-
2
|
|
264
|
-
];
|
|
6
|
+
export const create = async ({ template, name, destination: providedDestination, cwd: providedCwd, dangerouslyRewrite, }) => {
|
|
7
|
+
const cwd = providedCwd ?? process.cwd();
|
|
8
|
+
const destination = providedDestination
|
|
9
|
+
? path.resolve(cwd, providedDestination)
|
|
10
|
+
: cwd;
|
|
11
|
+
const finalDestination = path.resolve(destination, name);
|
|
12
|
+
// Make sure we don't overwite stuff
|
|
13
|
+
try {
|
|
14
|
+
if (await fs.stat(finalDestination)) {
|
|
15
|
+
if (!dangerouslyRewrite) {
|
|
16
|
+
console.log(`🚨 Cannot create the pacakge at ${finalDestination}. Please delete the previous file or directory or use "dangerouslyRewrite"`);
|
|
17
|
+
process.exit(1);
|
|
265
18
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
};
|
|
269
|
-
var replaceInFile = function replaceInFile(filePath, replacements) {
|
|
270
|
-
return _async_to_generator(function() {
|
|
271
|
-
var content, newContent;
|
|
272
|
-
return _ts_generator(this, function(_state) {
|
|
273
|
-
switch(_state.label){
|
|
274
|
-
case 0:
|
|
275
|
-
return [
|
|
276
|
-
4,
|
|
277
|
-
fs.readFile(filePath, 'utf-8')
|
|
278
|
-
];
|
|
279
|
-
case 1:
|
|
280
|
-
content = _state.sent();
|
|
281
|
-
// No time to build the regex and replace logic, that's for later, we just replace the name now
|
|
282
|
-
newContent = content.replace('{{name}}', replacements.name);
|
|
283
|
-
return [
|
|
284
|
-
4,
|
|
285
|
-
fs.writeFile(filePath, newContent)
|
|
286
|
-
];
|
|
287
|
-
case 2:
|
|
288
|
-
_state.sent();
|
|
289
|
-
return [
|
|
290
|
-
2
|
|
291
|
-
];
|
|
19
|
+
else {
|
|
20
|
+
await deleteAsync(finalDestination);
|
|
292
21
|
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (_e) {
|
|
25
|
+
// Nothing to do
|
|
26
|
+
}
|
|
27
|
+
// Make sure the folder exists
|
|
28
|
+
await ensureDir(finalDestination);
|
|
29
|
+
const templatePath = path.resolve(getBaseDir(), `templates/${template}`);
|
|
30
|
+
// Make sure the template exists
|
|
31
|
+
if (!(await fs.stat(templatePath)).isDirectory()) {
|
|
32
|
+
throw new Error(`The template ${template} doesn't exist`);
|
|
33
|
+
}
|
|
34
|
+
// First, copy the template into the destintion
|
|
35
|
+
await fs.cp(templatePath, finalDestination, {
|
|
36
|
+
recursive: true,
|
|
37
|
+
});
|
|
38
|
+
// Now we insert the name into the package file
|
|
39
|
+
await replaceInFile(`${finalDestination}/package.json`, { name });
|
|
40
|
+
await runCommand('pnpm', ['add', '-D', ...DEV_DEPS_TO_INSTALL[template]], {
|
|
41
|
+
cwd,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const replaceInFile = async (filePath, replacements) => {
|
|
45
|
+
// Load the file
|
|
46
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
47
|
+
// No time to build the regex and replace logic, that's for later, we just replace the name now
|
|
48
|
+
const newContent = content.replace('{{name}}', replacements.name);
|
|
49
|
+
await fs.writeFile(filePath, newContent);
|
|
295
50
|
};
|
|
51
|
+
//# sourceMappingURL=create.js.map
|
package/dist/index.js
CHANGED
package/dist/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
package/dist/utils.js
CHANGED
|
@@ -1,256 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
export const ensureDir = async (dir) => {
|
|
2
5
|
try {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 _define_property(obj, key, value) {
|
|
31
|
-
if (key in obj) {
|
|
32
|
-
Object.defineProperty(obj, key, {
|
|
33
|
-
value: value,
|
|
34
|
-
enumerable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
writable: true
|
|
37
|
-
});
|
|
38
|
-
} else {
|
|
39
|
-
obj[key] = value;
|
|
40
|
-
}
|
|
41
|
-
return obj;
|
|
42
|
-
}
|
|
43
|
-
function _object_spread(target) {
|
|
44
|
-
for(var i = 1; i < arguments.length; i++){
|
|
45
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
-
var ownKeys = Object.keys(source);
|
|
47
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
-
}));
|
|
6
|
+
const stat = await fs.stat(dir);
|
|
7
|
+
if (!stat.isDirectory()) {
|
|
8
|
+
throw new Error(`${dir} is not a directory`);
|
|
51
9
|
}
|
|
52
|
-
ownKeys.forEach(function(key) {
|
|
53
|
-
_define_property(target, key, source[key]);
|
|
54
|
-
});
|
|
55
10
|
}
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
function _ts_generator(thisArg, body) {
|
|
59
|
-
var f, y, t, _ = {
|
|
60
|
-
label: 0,
|
|
61
|
-
sent: function() {
|
|
62
|
-
if (t[0] & 1) throw t[1];
|
|
63
|
-
return t[1];
|
|
64
|
-
},
|
|
65
|
-
trys: [],
|
|
66
|
-
ops: []
|
|
67
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
68
|
-
return d(g, "next", {
|
|
69
|
-
value: verb(0)
|
|
70
|
-
}), d(g, "throw", {
|
|
71
|
-
value: verb(1)
|
|
72
|
-
}), d(g, "return", {
|
|
73
|
-
value: verb(2)
|
|
74
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
75
|
-
value: function() {
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
}), g;
|
|
79
|
-
function verb(n) {
|
|
80
|
-
return function(v) {
|
|
81
|
-
return step([
|
|
82
|
-
n,
|
|
83
|
-
v
|
|
84
|
-
]);
|
|
85
|
-
};
|
|
11
|
+
catch (_e) {
|
|
12
|
+
await fs.mkdir(dir, { recursive: true });
|
|
86
13
|
}
|
|
87
|
-
function step(op) {
|
|
88
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
89
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
90
|
-
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;
|
|
91
|
-
if (y = 0, t) op = [
|
|
92
|
-
op[0] & 2,
|
|
93
|
-
t.value
|
|
94
|
-
];
|
|
95
|
-
switch(op[0]){
|
|
96
|
-
case 0:
|
|
97
|
-
case 1:
|
|
98
|
-
t = op;
|
|
99
|
-
break;
|
|
100
|
-
case 4:
|
|
101
|
-
_.label++;
|
|
102
|
-
return {
|
|
103
|
-
value: op[1],
|
|
104
|
-
done: false
|
|
105
|
-
};
|
|
106
|
-
case 5:
|
|
107
|
-
_.label++;
|
|
108
|
-
y = op[1];
|
|
109
|
-
op = [
|
|
110
|
-
0
|
|
111
|
-
];
|
|
112
|
-
continue;
|
|
113
|
-
case 7:
|
|
114
|
-
op = _.ops.pop();
|
|
115
|
-
_.trys.pop();
|
|
116
|
-
continue;
|
|
117
|
-
default:
|
|
118
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
119
|
-
_ = 0;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
123
|
-
_.label = op[1];
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
127
|
-
_.label = t[1];
|
|
128
|
-
t = op;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
if (t && _.label < t[2]) {
|
|
132
|
-
_.label = t[2];
|
|
133
|
-
_.ops.push(op);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
if (t[2]) _.ops.pop();
|
|
137
|
-
_.trys.pop();
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
op = body.call(thisArg, _);
|
|
141
|
-
} catch (e) {
|
|
142
|
-
op = [
|
|
143
|
-
6,
|
|
144
|
-
e
|
|
145
|
-
];
|
|
146
|
-
y = 0;
|
|
147
|
-
} finally{
|
|
148
|
-
f = t = 0;
|
|
149
|
-
}
|
|
150
|
-
if (op[0] & 5) throw op[1];
|
|
151
|
-
return {
|
|
152
|
-
value: op[0] ? op[1] : void 0,
|
|
153
|
-
done: true
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
import { spawn } from 'node:child_process';
|
|
158
|
-
import fs from 'node:fs/promises';
|
|
159
|
-
import path from 'node:path';
|
|
160
|
-
export var ensureDir = function ensureDir(dir) {
|
|
161
|
-
return _async_to_generator(function() {
|
|
162
|
-
var stat, _e;
|
|
163
|
-
return _ts_generator(this, function(_state) {
|
|
164
|
-
switch(_state.label){
|
|
165
|
-
case 0:
|
|
166
|
-
_state.trys.push([
|
|
167
|
-
0,
|
|
168
|
-
2,
|
|
169
|
-
,
|
|
170
|
-
4
|
|
171
|
-
]);
|
|
172
|
-
return [
|
|
173
|
-
4,
|
|
174
|
-
fs.stat(dir)
|
|
175
|
-
];
|
|
176
|
-
case 1:
|
|
177
|
-
stat = _state.sent();
|
|
178
|
-
if (!stat.isDirectory()) {
|
|
179
|
-
throw new Error("".concat(dir, " is not a directory"));
|
|
180
|
-
}
|
|
181
|
-
return [
|
|
182
|
-
3,
|
|
183
|
-
4
|
|
184
|
-
];
|
|
185
|
-
case 2:
|
|
186
|
-
_e = _state.sent();
|
|
187
|
-
return [
|
|
188
|
-
4,
|
|
189
|
-
fs.mkdir(dir, {
|
|
190
|
-
recursive: true
|
|
191
|
-
})
|
|
192
|
-
];
|
|
193
|
-
case 3:
|
|
194
|
-
_state.sent();
|
|
195
|
-
return [
|
|
196
|
-
3,
|
|
197
|
-
4
|
|
198
|
-
];
|
|
199
|
-
case 4:
|
|
200
|
-
return [
|
|
201
|
-
2
|
|
202
|
-
];
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
})();
|
|
206
14
|
};
|
|
207
|
-
export
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
basePath = getBaseDir();
|
|
212
|
-
binPath = path.resolve(basePath, 'node_modules/.bin', bin);
|
|
213
|
-
return [
|
|
214
|
-
2,
|
|
215
|
-
runCommand(binPath, args, options)
|
|
216
|
-
];
|
|
217
|
-
});
|
|
218
|
-
})();
|
|
15
|
+
export const runBin = async (bin, args, options) => {
|
|
16
|
+
const basePath = getBaseDir();
|
|
17
|
+
const binPath = path.resolve(basePath, 'node_modules/.bin', bin);
|
|
18
|
+
return runCommand(binPath, args, options);
|
|
219
19
|
};
|
|
220
|
-
export
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
} else {
|
|
239
|
-
resolve(true);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
})
|
|
243
|
-
];
|
|
20
|
+
export const runCommand = async (cmd, args, options) => {
|
|
21
|
+
const c = spawn(cmd, args, {
|
|
22
|
+
stdio: 'inherit',
|
|
23
|
+
shell: process.platform === 'win32',
|
|
24
|
+
...options,
|
|
25
|
+
});
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
c.on('error', (error) => {
|
|
28
|
+
console.error(error);
|
|
29
|
+
reject(error);
|
|
30
|
+
});
|
|
31
|
+
c.on('close', (code) => {
|
|
32
|
+
if (code !== 0) {
|
|
33
|
+
reject(new Error(`Command exited with code ${code}`));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
resolve(true);
|
|
37
|
+
}
|
|
244
38
|
});
|
|
245
|
-
})
|
|
39
|
+
});
|
|
246
40
|
};
|
|
247
|
-
export
|
|
41
|
+
export const getBaseDir = () => {
|
|
248
42
|
return path.resolve(path.dirname(decodeURIComponent(new URL(import.meta.url).pathname)), '..');
|
|
249
43
|
};
|
|
250
|
-
export
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
};
|
|
44
|
+
export const getDefaultOptions = () => ({
|
|
45
|
+
source: 'src',
|
|
46
|
+
destination: 'dist',
|
|
47
|
+
copyVerbatim: [],
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/fab",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"zod": "^4.4.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@driveflux/tsconfig": "3.0.
|
|
26
|
+
"@driveflux/tsconfig": "3.0.2",
|
|
27
27
|
"@types/lodash.merge": "^4.6.9",
|
|
28
|
-
"@types/node": "^25.
|
|
28
|
+
"@types/node": "^25.9.1",
|
|
29
29
|
"del-cli": "^7.0.0",
|
|
30
30
|
"type-fest": "^5.6.0",
|
|
31
31
|
"typescript": "^6.0.3"
|