jiek 2.3.3 → 2.3.4

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.
Files changed (77) hide show
  1. package/dist/.internal/.chunks/{filterSupport.4rM7f6jB.cjs → getWD.Bdo2NGCR.cjs} +30 -30
  2. package/dist/.internal/.chunks/{filterSupport.BXWpLBpT.js → getWD.DGvwAHMY.js} +29 -29
  3. package/dist/.internal/.chunks/{loadConfig.OOKddvHF.cjs → loadConfig.8xhNFEJe.cjs} +30 -12
  4. package/dist/.internal/.chunks/{loadConfig.CFfzkm_p.js → loadConfig.BjzxLOdC.js} +26 -9
  5. package/dist/.internal/bin/common.cjs +90 -97
  6. package/dist/.internal/bin/common.js +91 -98
  7. package/dist/.internal/bin/parseArgv.cjs +2 -2
  8. package/dist/.internal/bin/parseArgv.js +2 -2
  9. package/dist/.internal/commands/utils/createAreaManagement.cjs +108 -0
  10. package/dist/.internal/commands/utils/createAreaManagement.d.cts +18 -0
  11. package/dist/.internal/commands/utils/createAreaManagement.d.ts +18 -0
  12. package/dist/.internal/commands/utils/createAreaManagement.js +106 -0
  13. package/dist/.internal/polyfill.cjs +13 -0
  14. package/dist/.internal/polyfill.d.cts +1 -0
  15. package/dist/.internal/polyfill.d.ts +1 -0
  16. package/dist/.internal/polyfill.js +11 -0
  17. package/dist/.internal/utils/filterSupport.cjs +1 -1
  18. package/dist/.internal/utils/filterSupport.js +2 -2
  19. package/dist/.internal/utils/loadConfig.cjs +3 -3
  20. package/dist/.internal/utils/loadConfig.d.cts +1 -0
  21. package/dist/.internal/utils/loadConfig.d.ts +1 -0
  22. package/dist/.internal/utils/loadConfig.js +4 -4
  23. package/dist/.internal/utils/pascalCase.cjs +5 -0
  24. package/dist/.internal/utils/pascalCase.d.cts +3 -0
  25. package/dist/.internal/utils/pascalCase.d.ts +3 -0
  26. package/dist/.internal/utils/pascalCase.js +3 -0
  27. package/dist/.internal/utils/reveal.cjs +9 -0
  28. package/dist/.internal/utils/reveal.d.cts +3 -0
  29. package/dist/.internal/utils/reveal.d.ts +3 -0
  30. package/dist/.internal/utils/reveal.js +7 -0
  31. package/dist/bin/index.cjs +101 -43
  32. package/dist/index.d.cts +7 -0
  33. package/dist/index.d.ts +7 -0
  34. package/dist/rollup/index.cjs +16 -18
  35. package/dist/rollup/index.js +13 -15
  36. package/package.json +2 -2
  37. package/src/bin/build.cts +0 -5
  38. package/src/bin/common.ts +0 -3
  39. package/src/bin/index.cts +0 -7
  40. package/src/bin/parseArgv.ts +0 -26
  41. package/src/bridge.ts +0 -46
  42. package/src/commands/base.ts +0 -18
  43. package/src/commands/build/analyzer.ts +0 -122
  44. package/src/commands/build/client/analyzer.tsx +0 -121
  45. package/src/commands/build/client/index.ts +0 -26
  46. package/src/commands/build.ts +0 -544
  47. package/src/commands/descriptions.ts +0 -17
  48. package/src/commands/meta.ts +0 -5
  49. package/src/commands/publish.ts +0 -628
  50. package/src/commands/utils/optionParser.ts +0 -4
  51. package/src/index.ts +0 -12
  52. package/src/inner.ts +0 -11
  53. package/src/rollup/base.ts +0 -152
  54. package/src/rollup/bundle-analyzer.ts +0 -62
  55. package/src/rollup/index.ts +0 -893
  56. package/src/rollup/plugins/create-require.ts +0 -23
  57. package/src/rollup/plugins/progress.ts +0 -26
  58. package/src/rollup/plugins/replace.ts +0 -185
  59. package/src/rollup/plugins/skip.ts +0 -21
  60. package/src/rollup/plugins/with-external.ts +0 -23
  61. package/src/rollup/utils/commonOptions.ts +0 -9
  62. package/src/rollup/utils/externalResolver.ts +0 -47
  63. package/src/rollup/utils/globalResolver.ts +0 -13
  64. package/src/rollup/utils/withMinify.ts +0 -18
  65. package/src/rollup-plugin-utils.ts +0 -32
  66. package/src/server.ts +0 -30
  67. package/src/utils/checkDependency.ts +0 -26
  68. package/src/utils/filterSupport.ts +0 -90
  69. package/src/utils/getInternalModuleName.ts +0 -5
  70. package/src/utils/getRoot.ts +0 -14
  71. package/src/utils/getWD.ts +0 -31
  72. package/src/utils/intersection.ts +0 -1
  73. package/src/utils/loadConfig.ts +0 -108
  74. package/src/utils/recursiveListFiles.ts +0 -13
  75. package/src/utils/resolveExports.ts +0 -165
  76. package/src/utils/ts.ts +0 -94
  77. package/src/utils/tsRegister.ts +0 -22
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var filterSupport = require('../.chunks/filterSupport.4rM7f6jB.cjs');
4
3
  var commander = require('commander');
4
+ var filterSupport = require('../.chunks/getWD.Bdo2NGCR.cjs');
5
5
  var fs = require('node:fs');
6
6
  var path = require('node:path');
7
7
  var process = require('node:process');
@@ -11,9 +11,9 @@ var node_child_process = require('node:child_process');
11
11
  var prompts = require('@inquirer/prompts');
12
12
  var base = require('../rollup/base.cjs');
13
13
  var Koa = require('koa');
14
- var loadConfig = require('../.chunks/loadConfig.OOKddvHF.cjs');
15
- require('js-yaml');
14
+ var loadConfig = require('../.chunks/loadConfig.8xhNFEJe.cjs');
16
15
  require('@jiek/utils/getWorkspaceDir');
16
+ require('js-yaml');
17
17
  require('node:url');
18
18
  require('node:string_decoder');
19
19
  require('node:util');
@@ -37,8 +37,8 @@ var Koa__default = /*#__PURE__*/_interopDefault(Koa);
37
37
 
38
38
  var name = "jiek";
39
39
  var type = "module";
40
- var version = "2.3.2";
41
- var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
40
+ var version = "2.3.3";
41
+ var description = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
42
42
  var author = "YiJie <yijie4188@gmail.com>";
43
43
  var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
44
44
  var repository = {
@@ -80,8 +80,7 @@ var files = [
80
80
  "README.md",
81
81
  "bin",
82
82
  "bin-helper",
83
- "dist",
84
- "src"
83
+ "dist"
85
84
  ];
86
85
  var scripts = {
87
86
  prepublish: "pnpm test && jb -nm && jk",
@@ -138,13 +137,13 @@ var devDependencies = {
138
137
  "rollup-plugin-esbuild": "^6.1.0",
139
138
  "rollup-plugin-postcss": "^4.0.2",
140
139
  "rollup-plugin-swc3": "^0.12.1",
141
- "vite-bundle-analyzer": "0.16.0-beta.3"
140
+ "vite-bundle-analyzer": "^0.16.0-beta.4"
142
141
  };
143
142
  var pkg = {
144
143
  name: name,
145
144
  type: type,
146
145
  version: version,
147
- description: description$1,
146
+ description: description,
148
147
  author: author,
149
148
  homepage: homepage,
150
149
  repository: repository,
@@ -165,7 +164,7 @@ Specify the build entry-points of the package.json's 'exports' field.
165
164
  Support glob pattern and array.
166
165
  .e.g. '.', './*', './sub/*', './a,./b'.
167
166
  `.trim();
168
- const filterDescription = `
167
+ const filtersDescription = `
169
168
  Filter the packages from the workspace.
170
169
  Support fuzzy match and array.
171
170
  .e.g. 'core,utils'.
@@ -181,7 +180,7 @@ const IS_WORKSPACE = !notWorkspace;
181
180
 
182
181
  commander.program.name("jk/jiek").version(pkg.version).description(`${pkg.description} - Version ${pkg.version}`).option("-c, --config-path <configPath>", "Custom jiek config path").option("--env.<name>=<value>", "Set the environment variable.");
183
182
  if (filterSupport.type !== "" && IS_WORKSPACE) {
184
- commander.program.option("-f, --filter <filter>", filterDescription);
183
+ commander.program.option("-f, --filter <filter>", filtersDescription);
185
184
  }
186
185
 
187
186
  function Main() {
@@ -412,70 +411,20 @@ const createServer = (port, host) => {
412
411
  };
413
412
  };
414
413
 
415
- const FILE_TEMPLATE = (manifest) => `
416
- module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
417
- `.trimStart();
418
- const ROLLUP_BIN = filterSupport.require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
419
- const isDefault = process__default.default.env.JIEK_BIN__FILENAME === "build.cjs";
420
- const description = `
421
- Build the package according to the 'exports' field from the package.json.
422
- If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
423
- ${isDefault ? "This command is the default command." : ""}
424
- `.trim();
425
- let DEFAULT_BUILDER_TYPE;
426
- Object.entries(base.BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
427
- try {
428
- filterSupport.require.resolve(packageName);
429
- DEFAULT_BUILDER_TYPE = type;
430
- } catch {
431
- }
432
- });
433
- if (!DEFAULT_BUILDER_TYPE) {
434
- DEFAULT_BUILDER_TYPE = "esbuild";
435
- }
436
- const buildFilterDescription = `
437
- ${filterDescription}
438
- If you pass the --filter option, it will merge into the filters of the command.
439
- `.trim();
440
- const buildEntriesDescription = `
441
- ${entriesDescription}
442
- If you pass the --entries option, it will merge into the entries of the command.
443
- `.trim();
444
- let command = isDefault ? (() => {
445
- const c = commander.program.name("jb/jiek-build").helpCommand(false);
446
- if (IS_WORKSPACE) {
447
- c.argument("[filters]", buildFilterDescription);
448
- } else {
449
- c.argument("[entries]", buildEntriesDescription);
450
- }
451
- return c;
452
- })() : commander.program.command(`build [${IS_WORKSPACE ? "filters" : "entries"}]`);
453
- command = command.description(description).option("-t, --type <TYPE>", `The type of build, support ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
454
- if (!base.BUILDER_TYPES.includes(v)) {
455
- throw new Error(`The value of 'type' must be ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
456
- }
457
- return String(v);
458
- }, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", parseBoolean).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
459
- "--minType <MINTYPE>",
460
- 'The type of minify, support "builder" and "terser".',
461
- (v) => {
462
- if (!["builder", "terser"].includes(v)) {
463
- throw new Error('The value of `minType` must be "builder" or "terser"');
414
+ async function action(filtersOrEntries, options) {
415
+ const FILE_TEMPLATE = (manifest) => `module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})`;
416
+ const ROLLUP_BIN = filterSupport.require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
417
+ let DEFAULT_BUILDER_TYPE;
418
+ Object.entries(base.BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type2, packageName]) => {
419
+ try {
420
+ filterSupport.require.resolve(packageName);
421
+ DEFAULT_BUILDER_TYPE = type2;
422
+ } catch {
464
423
  }
465
- return String(v);
424
+ });
425
+ if (!DEFAULT_BUILDER_TYPE) {
426
+ DEFAULT_BUILDER_TYPE = "esbuild";
466
427
  }
467
- ).option("-nc, --noClean", "Do not clean the output directory before building.", parseBoolean).option(
468
- "-om, --onlyMin",
469
- "Only output minify files, but dts files will still be output, it only replaces the js files.",
470
- parseBoolean
471
- );
472
- command = command.option("--skipJS", 'Skip entries which end with ".js".', parseBoolean);
473
- command = command.option("--features.keepImportAttributes", "Keep the import attributes in the output.");
474
- command = command.option("--tsconfig <TSCONFIG>", "The path of the tsconfig file which is used to generate js and dts files.", String).option("--dtsconfig <DTSCONFIG>", "The path of the tsconfig file which is used to generate dts files.", String);
475
- command = command.option("-w, --watch", "Watch the file changes.", parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
476
- command = registerAnalyzerCommandOptions(command);
477
- command = command.option("-s, --silent", "Don't display logs.", parseBoolean).option("-v, --verbose", "Display debug logs.", parseBoolean);
478
- command.action(async (commandFiltersOrEntries, options) => {
479
428
  let {
480
429
  type,
481
430
  outdir,
@@ -536,7 +485,7 @@ command.action(async (commandFiltersOrEntries, options) => {
536
485
  }
537
486
  let entries = [
538
487
  optionEntries,
539
- IS_WORKSPACE ? void 0 : commandFiltersOrEntries
488
+ IS_WORKSPACE ? void 0 : filtersOrEntries
540
489
  ].filter(Boolean).join(",");
541
490
  if (entries.length === 0) {
542
491
  entries = void 0;
@@ -563,9 +512,8 @@ command.action(async (commandFiltersOrEntries, options) => {
563
512
  ...process__default.default.env
564
513
  };
565
514
  const multiBars = new cliProgress.MultiBar({
566
- clearOnComplete: false,
567
515
  hideCursor: true,
568
- format: "- {bar} | {status} | {pkgName} | {input} | {message}"
516
+ format: "- {pkgName} | {status} | {input} | {message}"
569
517
  }, cliProgress.Presets.shades_classic);
570
518
  const { wd } = filterSupport.getWD();
571
519
  const wdNodeModules = path__default.default.resolve(wd, "node_modules");
@@ -595,15 +543,15 @@ command.action(async (commandFiltersOrEntries, options) => {
595
543
  `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
596
544
  );
597
545
  fs.writeFileSync(configFile, FILE_TEMPLATE(manifest));
598
- const command2 = [ROLLUP_BIN, "--silent", "-c", configFile];
546
+ const command = [ROLLUP_BIN, "--silent", "-c", configFile];
599
547
  if (loadConfig.tsRegisterName != null) {
600
- command2.unshift(`node -r ${loadConfig.tsRegisterName}`);
548
+ command.unshift(`node -r ${loadConfig.tsRegisterName}`);
601
549
  }
602
550
  if (watch) {
603
- command2.push("--watch");
551
+ command.push("--watch");
604
552
  }
605
- command2.push(...passThroughOptions);
606
- const child = index.execaCommand(command2.join(" "), {
553
+ command.push(...passThroughOptions);
554
+ const child = index.execaCommand(command.join(" "), {
607
555
  ipc: true,
608
556
  cwd: pkgCWD,
609
557
  windowsHide: true,
@@ -644,12 +592,11 @@ command.action(async (commandFiltersOrEntries, options) => {
644
592
  leafs.forEach(({ input, path: path2 }) => {
645
593
  const key = `${input}:${path2}`;
646
594
  if (bars[key]) return;
647
- bars[key] = multiBars.create(50, 0, {
595
+ bars[key] = multiBars.create(0, 0, {
648
596
  pkgName: manifest.name,
649
597
  input: input.padEnd(inputMaxLen + 5),
650
598
  status: "waiting".padEnd(10)
651
599
  }, {
652
- barsize: 20,
653
600
  linewrap: true
654
601
  });
655
602
  });
@@ -666,18 +613,11 @@ command.action(async (commandFiltersOrEntries, options) => {
666
613
  const bar = bars[`${input}:${path2}`];
667
614
  if (!bar) return;
668
615
  const time = times[`${input}:${path2}`];
669
- bar.update(
670
- {
671
- start: 0,
672
- resolve: 20,
673
- end: 50
674
- }[event ?? "start"] ?? 0,
675
- {
676
- input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
677
- status: event?.padEnd(10),
678
- message: `${tags?.join(", ")}: ${message}`
679
- }
680
- );
616
+ bar.update(0, {
617
+ input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
618
+ status: event?.padEnd(10),
619
+ message: `${tags?.join(", ")}: ${message}`
620
+ });
681
621
  break;
682
622
  }
683
623
  case "watchChange": {
@@ -741,7 +681,7 @@ cwd: ${pkgCWD}
741
681
  verbose && child.stdout?.pipe(process__default.default.stdout);
742
682
  });
743
683
  };
744
- const commandFilters = IS_WORKSPACE ? commandFiltersOrEntries : void 0;
684
+ const commandFilters = IS_WORKSPACE ? filtersOrEntries : void 0;
745
685
  const filters = [
746
686
  .../* @__PURE__ */ new Set([
747
687
  ...commander.program.getOptionValue("filter")?.split(",").map((s) => s.trim()).filter((s) => s.length > 0) ?? [],
@@ -757,4 +697,57 @@ cwd: ${pkgCWD}
757
697
  multiBars.stop();
758
698
  !silent && console.log("Build complete");
759
699
  }
760
- });
700
+ }
701
+ function registerCommand() {
702
+ let command = process__default.default.env.JIEK_BIN__FILENAME === "build.cjs" ? (() => {
703
+ const c = commander.program.name("jb/jiek-build").helpCommand(false);
704
+ if (IS_WORKSPACE) {
705
+ c.argument(
706
+ "[filters]",
707
+ `${filtersDescription}
708
+ If you pass the --filter option, it will merge into the filters of the command.`
709
+ );
710
+ } else {
711
+ c.argument(
712
+ "[entries]",
713
+ `${entriesDescription}
714
+ If you pass the --entries option, it will merge into the entries of the command.`
715
+ );
716
+ }
717
+ return c;
718
+ })() : commander.program.command(`build [${IS_WORKSPACE ? "filters" : "entries"}]`);
719
+ command = command.description(`
720
+ Build the package according to the 'exports' field from the package.json.
721
+ If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
722
+ `.trim()).option("-t, --type <TYPE>", `The type of build, support ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
723
+ if (!base.BUILDER_TYPES.includes(v)) {
724
+ throw new Error(`The value of 'type' must be ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
725
+ }
726
+ return String(v);
727
+ }, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", parseBoolean).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
728
+ "--minType <MINTYPE>",
729
+ 'The type of minify, support "builder" and "terser".',
730
+ (v) => {
731
+ if (!["builder", "terser"].includes(v)) {
732
+ throw new Error('The value of `minType` must be "builder" or "terser"');
733
+ }
734
+ return String(v);
735
+ }
736
+ ).option("-nc, --noClean", "Do not clean the output directory before building.", parseBoolean).option(
737
+ "-om, --onlyMin",
738
+ "Only output minify files, but dts files will still be output, it only replaces the js files.",
739
+ parseBoolean
740
+ );
741
+ command = command.option("--skipJS", 'Skip entries which end with ".js".', parseBoolean);
742
+ command = command.option("--features.keepImportAttributes", "Keep the import attributes in the output.");
743
+ command = command.option(
744
+ "--tsconfig <TSCONFIG>",
745
+ "The path of the tsconfig file which is used to generate js and dts files.",
746
+ String
747
+ ).option("--dtsconfig <DTSCONFIG>", "The path of the tsconfig file which is used to generate dts files.", String);
748
+ command = command.option("-w, --watch", "Watch the file changes.", parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
749
+ command = registerAnalyzerCommandOptions(command);
750
+ command = command.option("-s, --silent", "Don't display logs.", parseBoolean).option("-v, --verbose", "Display debug logs.", parseBoolean);
751
+ command.action(action);
752
+ }
753
+ registerCommand();
@@ -1,5 +1,5 @@
1
- import { g as getWD, t as type$1, r as require, f as filterPackagesGraph, a as getSelectedProjectsGraph } from '../.chunks/filterSupport.BXWpLBpT.js';
2
1
  import { program } from 'commander';
2
+ import { g as getWD, t as type$1, r as require, f as filterPackagesGraph, a as getSelectedProjectsGraph } from '../.chunks/getWD.DGvwAHMY.js';
3
3
  import { existsSync, mkdirSync, writeFileSync, statSync } from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import process from 'node:process';
@@ -7,12 +7,12 @@ import { MultiBar, Presets } from 'cli-progress';
7
7
  import { e as execaCommand } from '../.chunks/index.BHuJRlvZ.js';
8
8
  import { execSync } from 'node:child_process';
9
9
  import { confirm } from '@inquirer/prompts';
10
- import { BUILDER_TYPE_PACKAGE_NAME_MAP, BUILDER_TYPES } from '../rollup/base.js';
10
+ import { BUILDER_TYPES, BUILDER_TYPE_PACKAGE_NAME_MAP } from '../rollup/base.js';
11
11
  import Koa from 'koa';
12
- import { l as loadConfig, t as tsRegisterName } from '../.chunks/loadConfig.CFfzkm_p.js';
12
+ import { l as loadConfig, t as tsRegisterName } from '../.chunks/loadConfig.BjzxLOdC.js';
13
+ import '@jiek/utils/getWorkspaceDir';
13
14
  import 'node:module';
14
15
  import 'js-yaml';
15
- import '@jiek/utils/getWorkspaceDir';
16
16
  import 'node:url';
17
17
  import 'node:string_decoder';
18
18
  import 'node:util';
@@ -30,8 +30,8 @@ import 'node:stream/promises';
30
30
 
31
31
  var name = "jiek";
32
32
  var type = "module";
33
- var version = "2.3.2";
34
- var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
33
+ var version = "2.3.3";
34
+ var description = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
35
35
  var author = "YiJie <yijie4188@gmail.com>";
36
36
  var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
37
37
  var repository = {
@@ -73,8 +73,7 @@ var files = [
73
73
  "README.md",
74
74
  "bin",
75
75
  "bin-helper",
76
- "dist",
77
- "src"
76
+ "dist"
78
77
  ];
79
78
  var scripts = {
80
79
  prepublish: "pnpm test && jb -nm && jk",
@@ -131,13 +130,13 @@ var devDependencies = {
131
130
  "rollup-plugin-esbuild": "^6.1.0",
132
131
  "rollup-plugin-postcss": "^4.0.2",
133
132
  "rollup-plugin-swc3": "^0.12.1",
134
- "vite-bundle-analyzer": "0.16.0-beta.3"
133
+ "vite-bundle-analyzer": "^0.16.0-beta.4"
135
134
  };
136
135
  var pkg = {
137
136
  name: name,
138
137
  type: type,
139
138
  version: version,
140
- description: description$1,
139
+ description: description,
141
140
  author: author,
142
141
  homepage: homepage,
143
142
  repository: repository,
@@ -158,7 +157,7 @@ Specify the build entry-points of the package.json's 'exports' field.
158
157
  Support glob pattern and array.
159
158
  .e.g. '.', './*', './sub/*', './a,./b'.
160
159
  `.trim();
161
- const filterDescription = `
160
+ const filtersDescription = `
162
161
  Filter the packages from the workspace.
163
162
  Support fuzzy match and array.
164
163
  .e.g. 'core,utils'.
@@ -174,7 +173,7 @@ const IS_WORKSPACE = !notWorkspace;
174
173
 
175
174
  program.name("jk/jiek").version(pkg.version).description(`${pkg.description} - Version ${pkg.version}`).option("-c, --config-path <configPath>", "Custom jiek config path").option("--env.<name>=<value>", "Set the environment variable.");
176
175
  if (type$1 !== "" && IS_WORKSPACE) {
177
- program.option("-f, --filter <filter>", filterDescription);
176
+ program.option("-f, --filter <filter>", filtersDescription);
178
177
  }
179
178
 
180
179
  function Main() {
@@ -405,70 +404,20 @@ const createServer = (port, host) => {
405
404
  };
406
405
  };
407
406
 
408
- const FILE_TEMPLATE = (manifest) => `
409
- module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
410
- `.trimStart();
411
- const ROLLUP_BIN = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
412
- const isDefault = process.env.JIEK_BIN__FILENAME === "build.cjs";
413
- const description = `
414
- Build the package according to the 'exports' field from the package.json.
415
- If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
416
- ${isDefault ? "This command is the default command." : ""}
417
- `.trim();
418
- let DEFAULT_BUILDER_TYPE;
419
- Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
420
- try {
421
- require.resolve(packageName);
422
- DEFAULT_BUILDER_TYPE = type;
423
- } catch {
424
- }
425
- });
426
- if (!DEFAULT_BUILDER_TYPE) {
427
- DEFAULT_BUILDER_TYPE = "esbuild";
428
- }
429
- const buildFilterDescription = `
430
- ${filterDescription}
431
- If you pass the --filter option, it will merge into the filters of the command.
432
- `.trim();
433
- const buildEntriesDescription = `
434
- ${entriesDescription}
435
- If you pass the --entries option, it will merge into the entries of the command.
436
- `.trim();
437
- let command = isDefault ? (() => {
438
- const c = program.name("jb/jiek-build").helpCommand(false);
439
- if (IS_WORKSPACE) {
440
- c.argument("[filters]", buildFilterDescription);
441
- } else {
442
- c.argument("[entries]", buildEntriesDescription);
443
- }
444
- return c;
445
- })() : program.command(`build [${IS_WORKSPACE ? "filters" : "entries"}]`);
446
- command = command.description(description).option("-t, --type <TYPE>", `The type of build, support ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
447
- if (!BUILDER_TYPES.includes(v)) {
448
- throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
449
- }
450
- return String(v);
451
- }, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", parseBoolean).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
452
- "--minType <MINTYPE>",
453
- 'The type of minify, support "builder" and "terser".',
454
- (v) => {
455
- if (!["builder", "terser"].includes(v)) {
456
- throw new Error('The value of `minType` must be "builder" or "terser"');
407
+ async function action(filtersOrEntries, options) {
408
+ const FILE_TEMPLATE = (manifest) => `module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})`;
409
+ const ROLLUP_BIN = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
410
+ let DEFAULT_BUILDER_TYPE;
411
+ Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type2, packageName]) => {
412
+ try {
413
+ require.resolve(packageName);
414
+ DEFAULT_BUILDER_TYPE = type2;
415
+ } catch {
457
416
  }
458
- return String(v);
417
+ });
418
+ if (!DEFAULT_BUILDER_TYPE) {
419
+ DEFAULT_BUILDER_TYPE = "esbuild";
459
420
  }
460
- ).option("-nc, --noClean", "Do not clean the output directory before building.", parseBoolean).option(
461
- "-om, --onlyMin",
462
- "Only output minify files, but dts files will still be output, it only replaces the js files.",
463
- parseBoolean
464
- );
465
- command = command.option("--skipJS", 'Skip entries which end with ".js".', parseBoolean);
466
- command = command.option("--features.keepImportAttributes", "Keep the import attributes in the output.");
467
- command = command.option("--tsconfig <TSCONFIG>", "The path of the tsconfig file which is used to generate js and dts files.", String).option("--dtsconfig <DTSCONFIG>", "The path of the tsconfig file which is used to generate dts files.", String);
468
- command = command.option("-w, --watch", "Watch the file changes.", parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
469
- command = registerAnalyzerCommandOptions(command);
470
- command = command.option("-s, --silent", "Don't display logs.", parseBoolean).option("-v, --verbose", "Display debug logs.", parseBoolean);
471
- command.action(async (commandFiltersOrEntries, options) => {
472
421
  let {
473
422
  type,
474
423
  outdir,
@@ -529,7 +478,7 @@ command.action(async (commandFiltersOrEntries, options) => {
529
478
  }
530
479
  let entries = [
531
480
  optionEntries,
532
- IS_WORKSPACE ? void 0 : commandFiltersOrEntries
481
+ IS_WORKSPACE ? void 0 : filtersOrEntries
533
482
  ].filter(Boolean).join(",");
534
483
  if (entries.length === 0) {
535
484
  entries = void 0;
@@ -556,9 +505,8 @@ command.action(async (commandFiltersOrEntries, options) => {
556
505
  ...process.env
557
506
  };
558
507
  const multiBars = new MultiBar({
559
- clearOnComplete: false,
560
508
  hideCursor: true,
561
- format: "- {bar} | {status} | {pkgName} | {input} | {message}"
509
+ format: "- {pkgName} | {status} | {input} | {message}"
562
510
  }, Presets.shades_classic);
563
511
  const { wd } = getWD();
564
512
  const wdNodeModules = path.resolve(wd, "node_modules");
@@ -588,15 +536,15 @@ command.action(async (commandFiltersOrEntries, options) => {
588
536
  `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
589
537
  );
590
538
  writeFileSync(configFile, FILE_TEMPLATE(manifest));
591
- const command2 = [ROLLUP_BIN, "--silent", "-c", configFile];
539
+ const command = [ROLLUP_BIN, "--silent", "-c", configFile];
592
540
  if (tsRegisterName != null) {
593
- command2.unshift(`node -r ${tsRegisterName}`);
541
+ command.unshift(`node -r ${tsRegisterName}`);
594
542
  }
595
543
  if (watch) {
596
- command2.push("--watch");
544
+ command.push("--watch");
597
545
  }
598
- command2.push(...passThroughOptions);
599
- const child = execaCommand(command2.join(" "), {
546
+ command.push(...passThroughOptions);
547
+ const child = execaCommand(command.join(" "), {
600
548
  ipc: true,
601
549
  cwd: pkgCWD,
602
550
  windowsHide: true,
@@ -637,12 +585,11 @@ command.action(async (commandFiltersOrEntries, options) => {
637
585
  leafs.forEach(({ input, path: path2 }) => {
638
586
  const key = `${input}:${path2}`;
639
587
  if (bars[key]) return;
640
- bars[key] = multiBars.create(50, 0, {
588
+ bars[key] = multiBars.create(0, 0, {
641
589
  pkgName: manifest.name,
642
590
  input: input.padEnd(inputMaxLen + 5),
643
591
  status: "waiting".padEnd(10)
644
592
  }, {
645
- barsize: 20,
646
593
  linewrap: true
647
594
  });
648
595
  });
@@ -659,18 +606,11 @@ command.action(async (commandFiltersOrEntries, options) => {
659
606
  const bar = bars[`${input}:${path2}`];
660
607
  if (!bar) return;
661
608
  const time = times[`${input}:${path2}`];
662
- bar.update(
663
- {
664
- start: 0,
665
- resolve: 20,
666
- end: 50
667
- }[event ?? "start"] ?? 0,
668
- {
669
- input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
670
- status: event?.padEnd(10),
671
- message: `${tags?.join(", ")}: ${message}`
672
- }
673
- );
609
+ bar.update(0, {
610
+ input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
611
+ status: event?.padEnd(10),
612
+ message: `${tags?.join(", ")}: ${message}`
613
+ });
674
614
  break;
675
615
  }
676
616
  case "watchChange": {
@@ -734,7 +674,7 @@ cwd: ${pkgCWD}
734
674
  verbose && child.stdout?.pipe(process.stdout);
735
675
  });
736
676
  };
737
- const commandFilters = IS_WORKSPACE ? commandFiltersOrEntries : void 0;
677
+ const commandFilters = IS_WORKSPACE ? filtersOrEntries : void 0;
738
678
  const filters = [
739
679
  .../* @__PURE__ */ new Set([
740
680
  ...program.getOptionValue("filter")?.split(",").map((s) => s.trim()).filter((s) => s.length > 0) ?? [],
@@ -750,4 +690,57 @@ cwd: ${pkgCWD}
750
690
  multiBars.stop();
751
691
  !silent && console.log("Build complete");
752
692
  }
753
- });
693
+ }
694
+ function registerCommand() {
695
+ let command = process.env.JIEK_BIN__FILENAME === "build.cjs" ? (() => {
696
+ const c = program.name("jb/jiek-build").helpCommand(false);
697
+ if (IS_WORKSPACE) {
698
+ c.argument(
699
+ "[filters]",
700
+ `${filtersDescription}
701
+ If you pass the --filter option, it will merge into the filters of the command.`
702
+ );
703
+ } else {
704
+ c.argument(
705
+ "[entries]",
706
+ `${entriesDescription}
707
+ If you pass the --entries option, it will merge into the entries of the command.`
708
+ );
709
+ }
710
+ return c;
711
+ })() : program.command(`build [${IS_WORKSPACE ? "filters" : "entries"}]`);
712
+ command = command.description(`
713
+ Build the package according to the 'exports' field from the package.json.
714
+ If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
715
+ `.trim()).option("-t, --type <TYPE>", `The type of build, support ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
716
+ if (!BUILDER_TYPES.includes(v)) {
717
+ throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
718
+ }
719
+ return String(v);
720
+ }, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", parseBoolean).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
721
+ "--minType <MINTYPE>",
722
+ 'The type of minify, support "builder" and "terser".',
723
+ (v) => {
724
+ if (!["builder", "terser"].includes(v)) {
725
+ throw new Error('The value of `minType` must be "builder" or "terser"');
726
+ }
727
+ return String(v);
728
+ }
729
+ ).option("-nc, --noClean", "Do not clean the output directory before building.", parseBoolean).option(
730
+ "-om, --onlyMin",
731
+ "Only output minify files, but dts files will still be output, it only replaces the js files.",
732
+ parseBoolean
733
+ );
734
+ command = command.option("--skipJS", 'Skip entries which end with ".js".', parseBoolean);
735
+ command = command.option("--features.keepImportAttributes", "Keep the import attributes in the output.");
736
+ command = command.option(
737
+ "--tsconfig <TSCONFIG>",
738
+ "The path of the tsconfig file which is used to generate js and dts files.",
739
+ String
740
+ ).option("--dtsconfig <DTSCONFIG>", "The path of the tsconfig file which is used to generate dts files.", String);
741
+ command = command.option("-w, --watch", "Watch the file changes.", parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
742
+ command = registerAnalyzerCommandOptions(command);
743
+ command = command.option("-s, --silent", "Don't display logs.", parseBoolean).option("-v, --verbose", "Display debug logs.", parseBoolean);
744
+ command.action(action);
745
+ }
746
+ registerCommand();
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var commander = require('commander');
4
3
  var process = require('node:process');
4
+ var commander = require('commander');
5
5
 
6
6
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
7
 
@@ -12,7 +12,7 @@ const env = {};
12
12
  let isPassThrough = false;
13
13
  const newArgv = argv.filter((arg) => {
14
14
  if (isPassThrough) {
15
- return true;
15
+ return false;
16
16
  }
17
17
  if (arg === "--") {
18
18
  isPassThrough = true;
@@ -1,12 +1,12 @@
1
- import { program } from 'commander';
2
1
  import process from 'node:process';
2
+ import { program } from 'commander';
3
3
 
4
4
  const { argv } = process;
5
5
  const env = {};
6
6
  let isPassThrough = false;
7
7
  const newArgv = argv.filter((arg) => {
8
8
  if (isPassThrough) {
9
- return true;
9
+ return false;
10
10
  }
11
11
  if (arg === "--") {
12
12
  isPassThrough = true;