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