@driveflux/fab 1.0.0-next.0 → 1.0.0-next.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.
@@ -1,13 +1,14 @@
1
-
2
- > @driveflux/fab@1.0.0-next.0 build /Users/flux/Projects/flux/packages/fab
3
- > pnpm build:js && pnpm build:types
4
-
5
-
6
- > @driveflux/fab@1.0.0-next.0 build:js /Users/flux/Projects/flux/packages/fab
7
- > swc src -d dist
8
-
9
- Successfully compiled: 7 files with swc (69.51ms)
10
-
11
- > @driveflux/fab@1.0.0-next.0 build:types /Users/flux/Projects/flux/packages/fab
12
- > tsc --build --emitDeclarationOnly
13
-
1
+
2
+ 
3
+ > @driveflux/fab@1.0.0-next.2 build /Users/flux/Projects/flux/packages/fab
4
+ > pnpm build:js && pnpm build:types
5
+
6
+
7
+ > @driveflux/fab@1.0.0-next.2 build:js /Users/flux/Projects/flux/packages/fab
8
+ > swc src --strip-leading-paths -d dist
9
+
10
+ Successfully compiled: 7 files with swc (224.42ms)
11
+
12
+ > @driveflux/fab@1.0.0-next.2 build:types /Users/flux/Projects/flux/packages/fab
13
+ > tsc --build --emitDeclarationOnly
14
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @driveflux/fab
2
2
 
3
+ ## 1.0.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Version bump
8
+
9
+ ## 1.0.0-next.1
10
+
11
+ ### Patch Changes
12
+
13
+ - verion bump + minor improvements
14
+
3
15
  ## 1.0.0-next.0
4
16
 
5
17
  ### Major Changes
package/bin/fab.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // @ts-check
3
- import { Argument, Command, Option } from 'commander'
3
+ import { Command, Option } from 'commander'
4
4
  import path from 'node:path'
5
5
  import { build, buildCjs, buildEsm, buildTypes, clean, create, makeBaseExports, parseConfig } from '../index.js'
6
6
  const program = new Command()
@@ -37,12 +37,13 @@ function makeBuildCommand() {
37
37
  'The exports definition as an alternative to package.json. It must be the same structure as "exports"',
38
38
  parseExports
39
39
  )
40
- .addArgument(
41
- new Argument('[command]', 'The command to run')
40
+ .addOption(
41
+ new Option('-t, --target [...target]', 'The target export to make')
42
42
  .choices(['all', 'esm', 'cjs', 'types', 'clean', 'cjs-exports'])
43
43
  .default('all')
44
44
  )
45
- .action(async (command, options) => {
45
+ .action(async (options) => {
46
+ const { target } = options
46
47
  const cwd = path.resolve(process.cwd(), options.cwd)
47
48
  const config = await parseConfig({ cwd })
48
49
 
@@ -56,7 +57,7 @@ function makeBuildCommand() {
56
57
  ...config,
57
58
  }
58
59
 
59
- switch (command) {
60
+ switch (target) {
60
61
  case 'all':
61
62
  await build(finalOptions)
62
63
  break
@@ -73,7 +74,7 @@ function makeBuildCommand() {
73
74
  await buildTypes(finalOptions)
74
75
  break
75
76
  default:
76
- throw new Error(`Unknown command ${command}`)
77
+ throw new Error(`Unknown target ${target}`)
77
78
  }
78
79
  })
79
80
  }
package/dist/build.d.ts CHANGED
@@ -5,15 +5,17 @@ interface BuildOptions extends BaseOptions, MakeBaseExportsOptions, CleanOptions
5
5
  noTypes?: boolean;
6
6
  noCJS?: boolean;
7
7
  noESM?: boolean;
8
+ copyVerbatim?: string[];
8
9
  }
9
10
  interface MakeBaseExportsOptions extends BaseOptions {
10
11
  noTypes?: boolean;
11
12
  exports?: PackageJson['exports'];
12
13
  }
13
- export declare const build: (options?: BuildOptions) => Promise<void>;
14
- export declare const buildTypes: (options?: BaseOptions) => Promise<void>;
15
- export declare const buildCjs: (options?: BaseOptions) => Promise<void>;
16
- export declare const makeBaseExports: (options?: MakeBaseExportsOptions) => Promise<string[]>;
17
- export declare const buildEsm: (options?: BaseOptions) => Promise<void>;
14
+ export declare const build: (rawOptions?: BuildOptions) => Promise<void>;
15
+ export declare const copyVerbatim: (rawOptions?: BuildOptions) => Promise<void>;
16
+ export declare const buildTypes: (rawOptions?: BaseOptions) => Promise<void>;
17
+ export declare const buildCjs: (rawOptions?: BaseOptions) => Promise<void>;
18
+ export declare const makeBaseExports: (rawOptions?: MakeBaseExportsOptions) => Promise<string[]>;
19
+ export declare const buildEsm: (rawOptions?: BaseOptions) => Promise<void>;
18
20
  export {};
19
21
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAS,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAK7C,UAAU,YAAa,SAAQ,WAAW,EAAE,sBAAsB,EAAE,YAAY;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,UAAU,sBAAuB,SAAQ,WAAW;IAClD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;CACjC;AAaD,eAAO,MAAM,KAAK,aAAmB,YAAY,kBAsBhD,CAAA;AAED,eAAO,MAAM,UAAU,aAAmB,WAAW,kBAGpD,CAAA;AAED,eAAO,MAAM,QAAQ,aAAmB,WAAW,kBAelD,CAAA;AAED,eAAO,MAAM,eAAe,aAAmB,sBAAsB,sBAmBpE,CAAA;AAwKD,eAAO,MAAM,QAAQ,aAAmB,WAAW,kBAIlD,CAAA"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAS,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAK7C,UAAU,YAAa,SAAQ,WAAW,EAAE,sBAAsB,EAAE,YAAY;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AAED,UAAU,sBAAuB,SAAQ,WAAW;IAClD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;CACjC;AAaD,eAAO,MAAM,KAAK,gBAAuB,YAAY,kBA2BpD,CAAA;AAED,eAAO,MAAM,YAAY,gBAAuB,YAAY,kBAc3D,CAAA;AAED,eAAO,MAAM,UAAU,gBAAuB,WAAW,kBAIxD,CAAA;AAED,eAAO,MAAM,QAAQ,gBAAuB,WAAW,kBAgBtD,CAAA;AAED,eAAO,MAAM,eAAe,gBAAuB,sBAAsB,sBAoBxE,CAAA;AAgLD,eAAO,MAAM,QAAQ,gBAAuB,WAAW,kBAKtD,CAAA"}
package/dist/build.js CHANGED
@@ -169,6 +169,7 @@ function _ts_generator(thisArg, body) {
169
169
  }
170
170
  }
171
171
  import fg from "fast-glob";
172
+ import merge from "lodash.merge";
172
173
  import assert from "node:assert";
173
174
  import fs from "node:fs/promises";
174
175
  import path from "node:path";
@@ -176,13 +177,12 @@ import { clean } from "./clean.js";
176
177
  import { ensureDir, getDefaultOptions, runCommand, validatePackageJson } from "./utils.js";
177
178
  var glob = fg.glob;
178
179
  export var build = function() {
179
- var _ref = _async_to_generator(function() {
180
+ var _ref = _async_to_generator(function(rawOptions) {
180
181
  var options, promises;
181
- var _arguments = arguments;
182
182
  return _ts_generator(this, function(_state) {
183
183
  switch(_state.label){
184
184
  case 0:
185
- options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : getDefaultOptions();
185
+ options = merge({}, getDefaultOptions(), rawOptions);
186
186
  // Cleanup first
187
187
  return [
188
188
  4,
@@ -200,6 +200,7 @@ export var build = function() {
200
200
  if (!options.noCJS) {
201
201
  promises.push(buildCjs(options));
202
202
  }
203
+ promises.push(copyVerbatim(options));
203
204
  // Build necessary files
204
205
  return [
205
206
  4,
@@ -207,31 +208,106 @@ export var build = function() {
207
208
  ];
208
209
  case 2:
209
210
  _state.sent();
210
- // Make exports for CJS
211
+ if (!!options.noCJS) return [
212
+ 3,
213
+ 4
214
+ ];
211
215
  return [
212
216
  4,
213
217
  makeBaseExports(options)
214
218
  ];
215
219
  case 3:
216
220
  _state.sent();
221
+ _state.label = 4;
222
+ case 4:
223
+ return [
224
+ 2
225
+ ];
226
+ }
227
+ });
228
+ });
229
+ return function build(rawOptions) {
230
+ return _ref.apply(this, arguments);
231
+ };
232
+ }();
233
+ export var copyVerbatim = function() {
234
+ var _ref = _async_to_generator(function(rawOptions) {
235
+ var _options_copyVerbatim, options, _options_cwd, cwd, _options_destination, destination;
236
+ return _ts_generator(this, function(_state) {
237
+ switch(_state.label){
238
+ case 0:
239
+ options = merge({}, getDefaultOptions(), rawOptions);
240
+ if (!((_options_copyVerbatim = options.copyVerbatim) === null || _options_copyVerbatim === void 0 ? void 0 : _options_copyVerbatim.length)) return [
241
+ 3,
242
+ 2
243
+ ];
244
+ cwd = (_options_cwd = options.cwd) !== null && _options_cwd !== void 0 ? _options_cwd : process.cwd();
245
+ destination = (_options_destination = options.destination) !== null && _options_destination !== void 0 ? _options_destination : getDefaultOptions().destination;
246
+ return [
247
+ 4,
248
+ Promise.all(options.copyVerbatim.map(function() {
249
+ var _ref = _async_to_generator(function(fileOrFolderRaw) {
250
+ var fileOrFolder, targetPath, targetPathCjs;
251
+ return _ts_generator(this, function(_state) {
252
+ switch(_state.label){
253
+ case 0:
254
+ fileOrFolder = "src/".concat(fileOrFolderRaw.replace(/^(\/)*src/, ""));
255
+ targetPath = path.resolve(destination, fileOrFolder).replace("/src", "");
256
+ targetPathCjs = path.resolve(destination, "cjs", fileOrFolder).replace("/src", "");
257
+ return [
258
+ 4,
259
+ ensureDir(path.dirname(targetPath))
260
+ ];
261
+ case 1:
262
+ _state.sent();
263
+ return [
264
+ 4,
265
+ fs.cp(path.resolve(cwd, fileOrFolder), targetPath, {
266
+ recursive: true
267
+ })
268
+ ];
269
+ case 2:
270
+ _state.sent();
271
+ return [
272
+ 4,
273
+ fs.cp(path.resolve(cwd, fileOrFolder), targetPathCjs, {
274
+ recursive: true
275
+ })
276
+ ];
277
+ case 3:
278
+ _state.sent();
279
+ return [
280
+ 2
281
+ ];
282
+ }
283
+ });
284
+ });
285
+ return function(fileOrFolderRaw) {
286
+ return _ref.apply(this, arguments);
287
+ };
288
+ }()))
289
+ ];
290
+ case 1:
291
+ _state.sent();
292
+ _state.label = 2;
293
+ case 2:
217
294
  return [
218
295
  2
219
296
  ];
220
297
  }
221
298
  });
222
299
  });
223
- return function build() {
300
+ return function copyVerbatim(rawOptions) {
224
301
  return _ref.apply(this, arguments);
225
302
  };
226
303
  }();
227
304
  export var buildTypes = function() {
228
- var _ref = _async_to_generator(function() {
305
+ var _ref = _async_to_generator(function(rawOptions) {
229
306
  var options;
230
- var _arguments = arguments;
231
307
  return _ts_generator(this, function(_state) {
232
308
  switch(_state.label){
233
309
  case 0:
234
- options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : getDefaultOptions();
310
+ options = merge({}, getDefaultOptions(), rawOptions);
235
311
  return [
236
312
  4,
237
313
  validatePackageJson({
@@ -259,18 +335,17 @@ export var buildTypes = function() {
259
335
  }
260
336
  });
261
337
  });
262
- return function buildTypes() {
338
+ return function buildTypes(rawOptions) {
263
339
  return _ref.apply(this, arguments);
264
340
  };
265
341
  }();
266
342
  export var buildCjs = function() {
267
- var _ref = _async_to_generator(function() {
343
+ var _ref = _async_to_generator(function(rawOptions) {
268
344
  var options, _options_cwd, cwd, _options_destination, destination, cjsPath, targetPath;
269
- var _arguments = arguments;
270
345
  return _ts_generator(this, function(_state) {
271
346
  switch(_state.label){
272
347
  case 0:
273
- options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : getDefaultOptions();
348
+ options = merge({}, getDefaultOptions(), rawOptions);
274
349
  cwd = (_options_cwd = options.cwd) !== null && _options_cwd !== void 0 ? _options_cwd : process.cwd();
275
350
  destination = (_options_destination = options.destination) !== null && _options_destination !== void 0 ? _options_destination : getDefaultOptions().destination;
276
351
  cjsPath = path.resolve(destination, "cjs");
@@ -291,6 +366,7 @@ export var buildCjs = function() {
291
366
  "src",
292
367
  "-C",
293
368
  "module.type=commonjs",
369
+ "--strip-leading-paths",
294
370
  "-d",
295
371
  cjsPath
296
372
  ], {
@@ -318,18 +394,17 @@ export var buildCjs = function() {
318
394
  }
319
395
  });
320
396
  });
321
- return function buildCjs() {
397
+ return function buildCjs(rawOptions) {
322
398
  return _ref.apply(this, arguments);
323
399
  };
324
400
  }();
325
401
  export var makeBaseExports = function() {
326
- var _ref = _async_to_generator(function() {
402
+ var _ref = _async_to_generator(function(rawOptions) {
327
403
  var options, _options_cwd, cwd, exp, _tmp, baseMap;
328
- var _arguments = arguments;
329
404
  return _ts_generator(this, function(_state) {
330
405
  switch(_state.label){
331
406
  case 0:
332
- options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : getDefaultOptions();
407
+ options = merge({}, getDefaultOptions(), rawOptions);
333
408
  cwd = (_options_cwd = options.cwd) !== null && _options_cwd !== void 0 ? _options_cwd : process.cwd();
334
409
  _tmp = options.exports;
335
410
  if (_tmp) return [
@@ -375,7 +450,7 @@ export var makeBaseExports = function() {
375
450
  }
376
451
  });
377
452
  });
378
- return function makeBaseExports() {
453
+ return function makeBaseExports(rawOptions) {
379
454
  return _ref.apply(this, arguments);
380
455
  };
381
456
  }();
@@ -605,11 +680,6 @@ var resolvePathWithExtension = function() {
605
680
  2,
606
681
  "".concat(targetFile, "/index.").concat(extension)
607
682
  ];
608
- } else {
609
- return [
610
- 2,
611
- "".concat(targetFile, ".").concat(extension)
612
- ];
613
683
  }
614
684
  return [
615
685
  3,
@@ -618,12 +688,25 @@ var resolvePathWithExtension = function() {
618
688
  case 2:
619
689
  e = _state.sent();
620
690
  return [
621
- 2,
622
- "".concat(targetFile, ".").concat(extension)
691
+ 3,
692
+ 3
623
693
  ];
624
694
  case 3:
695
+ if (targetFile.endsWith(extension)) {
696
+ return [
697
+ 2,
698
+ targetFile
699
+ ];
700
+ }
701
+ if (targetFile.endsWith(".js")) {
702
+ return [
703
+ 2,
704
+ targetFile.replace(/\.js$/, ".".concat(extension))
705
+ ];
706
+ }
625
707
  return [
626
- 2
708
+ 2,
709
+ "".concat(targetFile, ".").concat(extension)
627
710
  ];
628
711
  }
629
712
  });
@@ -676,18 +759,18 @@ var parseExportPath = function() {
676
759
  };
677
760
  }();
678
761
  export var buildEsm = function() {
679
- var _ref = _async_to_generator(function() {
762
+ var _ref = _async_to_generator(function(rawOptions) {
680
763
  var options, _options_destination;
681
- var _arguments = arguments;
682
764
  return _ts_generator(this, function(_state) {
683
765
  switch(_state.label){
684
766
  case 0:
685
- options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : getDefaultOptions();
767
+ options = merge({}, getDefaultOptions(), rawOptions);
686
768
  return [
687
769
  4,
688
770
  runCommand("pnpm", [
689
771
  "swc",
690
772
  "src",
773
+ "--strip-leading-paths",
691
774
  "-d",
692
775
  (_options_destination = options.destination) !== null && _options_destination !== void 0 ? _options_destination : getDefaultOptions().destination
693
776
  ], {
@@ -702,7 +785,7 @@ export var buildEsm = function() {
702
785
  }
703
786
  });
704
787
  });
705
- return function buildEsm() {
788
+ return function buildEsm(rawOptions) {
706
789
  return _ref.apply(this, arguments);
707
790
  };
708
791
  }();
package/dist/clean.js CHANGED
@@ -195,9 +195,9 @@ export var clean = function() {
195
195
  ];
196
196
  case 1:
197
197
  _state.sent();
198
- doNotCleanup = rawDoNotCleanup.map(function(f) {
198
+ doNotCleanup = (rawDoNotCleanup === null || rawDoNotCleanup === void 0 ? void 0 : rawDoNotCleanup.map(function(f) {
199
199
  return "!".concat(f);
200
- });
200
+ })) || [];
201
201
  if (!all) return [
202
202
  3,
203
203
  3
package/dist/config.d.ts CHANGED
@@ -7,13 +7,21 @@ interface ParseConfigOptions {
7
7
  }
8
8
  declare const ConfigValidation: z.ZodObject<{
9
9
  doNotCleanup: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
10
+ noCJS: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
11
+ copyVerbatim: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
10
12
  }, "strip", z.ZodTypeAny, {
11
13
  doNotCleanup?: string[] | undefined;
14
+ noCJS?: boolean | undefined;
15
+ copyVerbatim?: string[] | undefined;
12
16
  }, {
13
17
  doNotCleanup?: string[] | undefined;
18
+ noCJS?: boolean | undefined;
19
+ copyVerbatim?: string[] | undefined;
14
20
  }>;
15
21
  export declare const parseConfig: (options?: ParseConfigOptions) => Promise<{
16
22
  doNotCleanup?: string[] | undefined;
23
+ noCJS?: boolean | undefined;
24
+ copyVerbatim?: string[] | undefined;
17
25
  }>;
18
26
  export {};
19
27
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAErD,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,QAAA,MAAM,gBAAgB;;;;;;EAEV,CAAA;AAEZ,eAAO,MAAM,WAAW,aAAoB,kBAAkB;;EAiB7D,CAAA"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAErD,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,QAAA,MAAM,gBAAgB;;;;;;;;;;;;EAIV,CAAA;AAEZ,eAAO,MAAM,WAAW,aAAoB,kBAAkB;;;;EAiB7D,CAAA"}
package/dist/config.js CHANGED
@@ -126,7 +126,9 @@ import fs from "node:fs/promises";
126
126
  import path from "node:path";
127
127
  import { z } from "zod";
128
128
  var ConfigValidation = z.object({
129
- doNotCleanup: z.array(z.string())
129
+ doNotCleanup: z.array(z.string()),
130
+ noCJS: z.boolean().optional(),
131
+ copyVerbatim: z.array(z.string())
130
132
  }).partial();
131
133
  export var parseConfig = function() {
132
134
  var _ref = _async_to_generator(function(options) {