jiek 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as childProcess from 'node:child_process';
2
2
  import fs from 'node:fs';
3
- import path, { isAbsolute, relative, resolve as resolve$1 } from 'node:path';
4
- import { bump, TAGS } from '@jiek/utils/bumper';
3
+ import path, { isAbsolute, relative, resolve } from 'node:path';
4
+ import { TAGS, bump } from '@jiek/utils/bumper';
5
5
  import { program } from 'commander';
6
6
  import detectIndent from 'detect-indent';
7
7
  import { applyEdits, modify } from 'jsonc-parser';
@@ -14,14 +14,6 @@ import require$$0 from 'util';
14
14
  import require$$0$1 from 'path';
15
15
  import 'jiek/cli-only-build';
16
16
 
17
- let resolve;
18
- function actionDone() {
19
- resolve();
20
- }
21
- function actionRestore() {
22
- new Promise((r) => resolve = r);
23
- }
24
-
25
17
  let root;
26
18
  function getRoot() {
27
19
  if (root)
@@ -4240,7 +4232,7 @@ function getOutDirs({
4240
4232
  js: "dts",
4241
4233
  dts: "js"
4242
4234
  }[type]] : outdir) ?? defaultOutdir;
4243
- return (isAbsolute(dir) ? dir : `./${relative(cwd, resolve$1(cwd, dir))}`).replace("{{PKG_NAME}}", pkgName);
4235
+ return (isAbsolute(dir) ? dir : `./${relative(cwd, resolve(cwd, dir))}`).replace("{{PKG_NAME}}", pkgName);
4244
4236
  }
4245
4237
  return {
4246
4238
  js: resolveOutdir("js"),
@@ -4424,14 +4416,59 @@ Support with variables: 'PKG_NAME',
4424
4416
  .e.g. 'dist/{{PKG_NAME}}'.
4425
4417
  `.trim();
4426
4418
 
4427
- program.command("publish").aliases(["pub", "p"]).option("-b, --bumper <bumper>", "bump version", "patch").option("-no-b, --no-bumper", "no bump version").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-s, --silent", "no output").option("-p, --preview", "preview publish").action(async ({ outdir, preview, silent, bumper, ...options }) => {
4428
- actionRestore();
4419
+ const description = `
4420
+ Publish package to npm registry, and auto generate exports field and other fields in published package.json.
4421
+ If you want to through the options to the \`pnpm publish\` command, you can pass the options after '--'.
4422
+ `.trim();
4423
+ async function forEachSelectedProjectsGraphEntries(callback) {
4429
4424
  const { value = {} } = await getSelectedProjectsGraph() ?? {};
4430
4425
  const selectedProjectsGraphEntries = Object.entries(value);
4431
4426
  if (selectedProjectsGraphEntries.length === 0) {
4432
4427
  throw new Error("no packages selected");
4433
4428
  }
4434
- const manifests = selectedProjectsGraphEntries.map(([dir, manifest]) => {
4429
+ for (const [dir, manifest] of selectedProjectsGraphEntries) {
4430
+ callback(dir, manifest);
4431
+ }
4432
+ }
4433
+ program.command("publish").description(description).aliases(["pub", "p"]).option("-b, --bumper <bumper>", "bump version", "patch").option("-no-b, --no-bumper", "no bump version").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").action(async ({ outdir, bumper }) => {
4434
+ let shouldPassThrough = false;
4435
+ const passThroughOptions = process.argv.reduce(
4436
+ (acc, value) => {
4437
+ if (shouldPassThrough) {
4438
+ acc.push(value);
4439
+ }
4440
+ if (value === "--") {
4441
+ shouldPassThrough = true;
4442
+ }
4443
+ return acc;
4444
+ },
4445
+ []
4446
+ );
4447
+ await forEachSelectedProjectsGraphEntries((dir) => {
4448
+ const args = ["pnpm", "publish", "--access", "public", "--no-git-checks"];
4449
+ if (bumper && TAGS.includes(bumper)) {
4450
+ args.push("--tag", bumper);
4451
+ }
4452
+ args.push(...passThroughOptions);
4453
+ childProcess.execSync(args.join(" "), {
4454
+ cwd: dir,
4455
+ stdio: "inherit",
4456
+ env: {
4457
+ ...process.env,
4458
+ JIEK_PUBLISH_OUTDIR: JSON.stringify(outdir),
4459
+ JIEK_PUBLISH_BUMPER: JSON.stringify(bumper)
4460
+ }
4461
+ });
4462
+ });
4463
+ });
4464
+ async function prepublish() {
4465
+ const {
4466
+ JIEK_PUBLISH_OUTDIR: outdirEnv,
4467
+ JIEK_PUBLISH_BUMPER: bumperEnv
4468
+ } = process.env;
4469
+ const outdir = outdirEnv ? JSON.parse(outdirEnv) : "dist";
4470
+ const bumper = bumperEnv ? JSON.parse(bumperEnv) : false;
4471
+ const generateNewManifest = (dir, manifest) => {
4435
4472
  const { name, type, exports: entrypoints = {} } = manifest;
4436
4473
  if (!name) {
4437
4474
  throw new Error(`package.json in ${dir} must have a name field`);
@@ -4452,35 +4489,38 @@ program.command("publish").aliases(["pub", "p"]).option("-b, --bumper <bumper>",
4452
4489
  ...resolvedEntrypoints,
4453
4490
  ...exports
4454
4491
  };
4455
- return [dir, newManifest, resolvedOutdir];
4456
- });
4457
- const passArgs = Object.entries(options).reduce((acc, [key, value2]) => {
4458
- if (value2) {
4459
- acc.push(`--${key}`, value2);
4460
- }
4461
- return acc;
4462
- }, []);
4463
- for (const [dir, manifest, resolvedOutdir] of manifests) {
4464
- const oldJSONString = fs.readFileSync(path.join(dir, "package.json"), "utf-8");
4465
- const oldJSON = JSON.parse(oldJSONString) ?? "0.0.0";
4466
- const newVersion = bumper ? bump(oldJSON.version, bumper) : oldJSON.version;
4467
- const { indent = " " } = detectIndent(oldJSONString);
4468
- const formattingOptions = {
4469
- tabSize: indent.length,
4470
- insertSpaces: true
4471
- };
4492
+ return [newManifest, resolvedOutdir];
4493
+ };
4494
+ const generateNewPackageJSONString = ({
4495
+ oldJSONString,
4496
+ oldJSON,
4497
+ manifest,
4498
+ formattingOptions
4499
+ }) => {
4472
4500
  let newJSONString = oldJSONString;
4473
4501
  newJSONString = applyEdits(
4474
4502
  newJSONString,
4475
4503
  modify(
4476
4504
  newJSONString,
4477
- ["version"],
4478
- newVersion,
4505
+ ["publishConfig", "typesVersions"],
4506
+ {
4507
+ "<5.0": {
4508
+ "*": [
4509
+ "*",
4510
+ `./*`,
4511
+ `./*/index.d.ts`,
4512
+ `./*/index.d.mts`,
4513
+ `./*/index.d.cts`
4514
+ ]
4515
+ }
4516
+ },
4479
4517
  { formattingOptions }
4480
4518
  )
4481
4519
  );
4482
- for (const [key, value2] of Object.entries(manifest)) {
4483
- if (JSON.stringify(value2) === JSON.stringify(oldJSON[key]))
4520
+ for (const [key, value] of Object.entries(manifest)) {
4521
+ if (key === "version")
4522
+ continue;
4523
+ if (JSON.stringify(value) === JSON.stringify(oldJSON[key]))
4484
4524
  continue;
4485
4525
  if (key !== "exports") {
4486
4526
  newJSONString = applyEdits(
@@ -4488,12 +4528,12 @@ program.command("publish").aliases(["pub", "p"]).option("-b, --bumper <bumper>",
4488
4528
  modify(
4489
4529
  newJSONString,
4490
4530
  ["publishConfig", key],
4491
- value2,
4531
+ value,
4492
4532
  { formattingOptions }
4493
4533
  )
4494
4534
  );
4495
4535
  } else {
4496
- const exports = value2;
4536
+ const exports = value;
4497
4537
  for (const [k, v] of Object.entries(exports)) {
4498
4538
  newJSONString = applyEdits(
4499
4539
  newJSONString,
@@ -4535,46 +4575,180 @@ program.command("publish").aliases(["pub", "p"]).option("-b, --bumper <bumper>",
4535
4575
  }
4536
4576
  }
4537
4577
  }
4538
- newJSONString = applyEdits(
4539
- newJSONString,
4540
- modify(
4541
- newJSONString,
4542
- ["publishConfig", "typesVersions"],
4543
- {
4544
- "<5.0": {
4545
- "*": [
4546
- "*",
4547
- `${resolvedOutdir}/*`,
4548
- `${resolvedOutdir}/*/index.d.ts`,
4549
- `${resolvedOutdir}/*/index.d.mts`,
4550
- `${resolvedOutdir}/*/index.d.cts`
4551
- ]
4552
- }
4578
+ if (oldJSON["peerDependencies"]) {
4579
+ const peerDependenciesMeta = Object.keys(oldJSON["peerDependencies"]).reduce(
4580
+ (acc, key) => {
4581
+ acc[key] = { optional: true };
4582
+ return acc;
4553
4583
  },
4554
- { formattingOptions }
4555
- )
4584
+ {}
4585
+ );
4586
+ newJSONString = applyEdits(
4587
+ newJSONString,
4588
+ modify(
4589
+ newJSONString,
4590
+ ["peerDependenciesMeta"],
4591
+ peerDependenciesMeta,
4592
+ { formattingOptions }
4593
+ )
4594
+ );
4595
+ }
4596
+ if (oldJSON["files"]) {
4597
+ newJSONString = applyEdits(
4598
+ newJSONString,
4599
+ modify(
4600
+ newJSONString,
4601
+ ["files"],
4602
+ void 0,
4603
+ { formattingOptions }
4604
+ )
4605
+ );
4606
+ }
4607
+ return newJSONString;
4608
+ };
4609
+ await forEachSelectedProjectsGraphEntries((dir, originalManifest) => {
4610
+ const [manifest, resolvedOutdir] = generateNewManifest(dir, originalManifest);
4611
+ const resolveByDir = (...paths) => path.resolve(dir, ...paths);
4612
+ const oldJSONString = fs.readFileSync(resolveByDir("package.json"), "utf-8");
4613
+ const oldJSON = JSON.parse(oldJSONString) ?? "0.0.0";
4614
+ if (typeof oldJSON.version !== "string") {
4615
+ throw new Error(`${dir}/package.json must have a version field with a string value`);
4616
+ }
4617
+ const { indent = " " } = detectIndent(oldJSONString);
4618
+ const formattingOptions = {
4619
+ tabSize: indent.length,
4620
+ insertSpaces: true
4621
+ };
4622
+ const newVersion = bumper ? bump(oldJSON.version, bumper) : oldJSON.version;
4623
+ const modifyVersionPackageJSON = applyEdits(
4624
+ oldJSONString,
4625
+ modify(oldJSONString, ["version"], newVersion, { formattingOptions })
4556
4626
  );
4557
- try {
4558
- fs.renameSync(path.join(dir, "package.json"), path.join(dir, "package.json.bak"));
4559
- fs.writeFileSync(path.join(dir, "package.json"), newJSONString);
4560
- !silent && console.log(newJSONString);
4561
- if (preview) {
4627
+ const newJSONString = generateNewPackageJSONString({
4628
+ oldJSONString: modifyVersionPackageJSON,
4629
+ oldJSON: {
4630
+ ...oldJSON,
4631
+ version: newVersion
4632
+ },
4633
+ manifest,
4634
+ formattingOptions
4635
+ });
4636
+ const withPublishConfigDirectoryOldJSONString = applyEdits(
4637
+ modifyVersionPackageJSON,
4638
+ modify(modifyVersionPackageJSON, ["publishConfig", "directory"], resolvedOutdir, { formattingOptions })
4639
+ );
4640
+ if (!fs.existsSync(resolveByDir(resolvedOutdir))) {
4641
+ fs.mkdirSync(resolveByDir(resolvedOutdir));
4642
+ }
4643
+ const jiekTempDir = resolveByDir("node_modules/.jiek/.tmp");
4644
+ if (!fs.existsSync(resolveByDir(jiekTempDir))) {
4645
+ fs.mkdirSync(resolveByDir(jiekTempDir), { recursive: true });
4646
+ }
4647
+ fs.writeFileSync(resolveByDir(resolvedOutdir, "package.json"), newJSONString);
4648
+ fs.writeFileSync(resolveByDir(jiekTempDir, "package.json"), modifyVersionPackageJSON);
4649
+ fs.writeFileSync(resolveByDir("package.json"), withPublishConfigDirectoryOldJSONString);
4650
+ const allBuildFiles = fs.readdirSync(resolveByDir(resolvedOutdir), { recursive: true }).filter((file) => typeof file === "string").filter((file) => file !== "package.json");
4651
+ for (const file of allBuildFiles) {
4652
+ const filepath = resolveByDir(resolvedOutdir, file);
4653
+ const stat = fs.statSync(filepath);
4654
+ if (stat.isDirectory()) {
4655
+ const existsIndexFile = allBuildFiles.some(
4656
+ (f) => [
4657
+ path.join(file, "index.js"),
4658
+ path.join(file, "index.mjs"),
4659
+ path.join(file, "index.cjs")
4660
+ ].includes(f)
4661
+ );
4662
+ if (existsIndexFile) {
4663
+ const cpDistPath = resolveByDir(resolvedOutdir, resolvedOutdir, file);
4664
+ const pkgJSONPath = resolveByDir(resolvedOutdir, file, "package.json");
4665
+ const relativePath = path.relative(filepath, cpDistPath);
4666
+ const { type } = manifest;
4667
+ fs.writeFileSync(
4668
+ pkgJSONPath,
4669
+ JSON.stringify({
4670
+ type,
4671
+ main: [relativePath, `index.${type === "module" ? "c" : ""}js`].join("/"),
4672
+ module: [relativePath, `index.${type === "module" ? "" : "m"}js`].join("/")
4673
+ })
4674
+ );
4675
+ }
4676
+ }
4677
+ }
4678
+ fs.mkdirSync(resolveByDir(resolvedOutdir, resolvedOutdir));
4679
+ for (const file of allBuildFiles) {
4680
+ const filepath = resolveByDir(resolvedOutdir, file);
4681
+ const newFilepath = resolveByDir(resolvedOutdir, resolvedOutdir, file);
4682
+ const stat = fs.statSync(filepath);
4683
+ if (stat.isDirectory()) {
4684
+ fs.mkdirSync(newFilepath, { recursive: true });
4562
4685
  continue;
4563
4686
  }
4564
- const args = ["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs];
4565
- if (bumper && TAGS.includes(bumper)) {
4566
- args.push("--tag", bumper);
4687
+ if (stat.isFile()) {
4688
+ fs.cpSync(filepath, newFilepath);
4689
+ fs.rmSync(filepath);
4690
+ }
4691
+ }
4692
+ if (oldJSON.files) {
4693
+ if (!Array.isArray(oldJSON.files)) {
4694
+ throw new Error(`${dir}/package.json files field must be an array`);
4695
+ }
4696
+ if (Array.isArray(oldJSON.files) && oldJSON.files.every((file) => typeof file !== "string")) {
4697
+ throw new Error(`${dir}/package.json files field must be an array of string`);
4567
4698
  }
4568
- childProcess.execSync(args.join(" "), {
4569
- cwd: dir,
4570
- stdio: "inherit"
4571
- });
4572
- const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ["version"], newVersion, {}));
4573
- fs.writeFileSync(path.join(dir, "package.json.bak"), modifyVersionPackageJSON);
4574
- } finally {
4575
- fs.unlinkSync(path.join(dir, "package.json"));
4576
- fs.renameSync(path.join(dir, "package.json.bak"), path.join(dir, "package.json"));
4577
4699
  }
4700
+ const resolvedOutdirAbs = resolveByDir(resolvedOutdir);
4701
+ const files = (oldJSON.files ?? fs.readdirSync(resolveByDir("."))).filter((file) => file === "node_modules" || resolveByDir(file) !== resolvedOutdirAbs);
4702
+ for (const file of files) {
4703
+ const path2 = resolveByDir(file);
4704
+ try {
4705
+ const stat = fs.statSync(path2);
4706
+ if (stat.isDirectory()) {
4707
+ fs.cpSync(path2, resolveByDir(resolvedOutdir, file), { recursive: true });
4708
+ continue;
4709
+ }
4710
+ if (stat.isFile()) {
4711
+ fs.cpSync(path2, resolveByDir(resolvedOutdir, file));
4712
+ continue;
4713
+ }
4714
+ } catch (e) {
4715
+ console.warn(String(e));
4716
+ continue;
4717
+ }
4718
+ throw new Error(`file type of ${path2} is not supported`);
4719
+ }
4720
+ });
4721
+ }
4722
+ async function postpublish() {
4723
+ await forEachSelectedProjectsGraphEntries((dir) => {
4724
+ const jiekTempDir = path.resolve(dir, "node_modules/.jiek/.tmp");
4725
+ const packageJSON = path.resolve(dir, "package.json");
4726
+ const jiekTempPackageJSON = path.resolve(jiekTempDir, "package.json");
4727
+ if (fs.existsSync(jiekTempPackageJSON)) {
4728
+ fs.copyFileSync(jiekTempPackageJSON, packageJSON);
4729
+ fs.rmSync(jiekTempPackageJSON);
4730
+ console.log(`${dir}/package.json has been restored`);
4731
+ } else {
4732
+ throw new Error(
4733
+ `jiek temp \`${dir}/package.json\` not found, please confirm the jiek pre-publish command has been executed`
4734
+ );
4735
+ }
4736
+ });
4737
+ }
4738
+ program.action(async () => {
4739
+ const {
4740
+ npm_lifecycle_event: NPM_LIFECYCLE_EVENT
4741
+ } = process.env;
4742
+ switch (NPM_LIFECYCLE_EVENT) {
4743
+ case "prepublish":
4744
+ await prepublish();
4745
+ break;
4746
+ case "postpublish":
4747
+ await postpublish();
4748
+ break;
4749
+ default:
4750
+ program.help();
4578
4751
  }
4579
- actionDone();
4580
4752
  });
4753
+ program.command("prepublish").action(prepublish);
4754
+ program.command("postpublish").action(postpublish);
@@ -4503,7 +4503,7 @@ const {
4503
4503
  JIEK_WITHOUT_DTS,
4504
4504
  JIEK_WITHOUT_MINIFY,
4505
4505
  JIEK_MINIFY_TYPE,
4506
- JIEK_NO_CLEAN,
4506
+ JIEK_CLEAN,
4507
4507
  JIEK_ONLY_MINIFY,
4508
4508
  JIEK_TSCONFIG,
4509
4509
  JIEK_DTSCONFIG
@@ -4527,7 +4527,7 @@ const WITHOUT_JS = JIEK_WITHOUT_JS === "true";
4527
4527
  const WITHOUT_DTS = JIEK_WITHOUT_DTS === "true";
4528
4528
  const WITHOUT_MINIFY = JIEK_WITHOUT_MINIFY === "true";
4529
4529
  const ONLY_MINIFY = JIEK_ONLY_MINIFY === "true";
4530
- const CLEAN = JIEK_NO_CLEAN !== "true";
4530
+ const CLEAN = JIEK_CLEAN === "true";
4531
4531
  const MINIFY_DEFAULT_VALUE = WITHOUT_MINIFY ? false : ONLY_MINIFY ? "only-minify" : true;
4532
4532
  const BUILDER_OPTIONS = {
4533
4533
  type: JIEK_BUILDER ?? "esbuild"
@@ -4490,7 +4490,7 @@ const {
4490
4490
  JIEK_WITHOUT_DTS,
4491
4491
  JIEK_WITHOUT_MINIFY,
4492
4492
  JIEK_MINIFY_TYPE,
4493
- JIEK_NO_CLEAN,
4493
+ JIEK_CLEAN,
4494
4494
  JIEK_ONLY_MINIFY,
4495
4495
  JIEK_TSCONFIG,
4496
4496
  JIEK_DTSCONFIG
@@ -4514,7 +4514,7 @@ const WITHOUT_JS = JIEK_WITHOUT_JS === "true";
4514
4514
  const WITHOUT_DTS = JIEK_WITHOUT_DTS === "true";
4515
4515
  const WITHOUT_MINIFY = JIEK_WITHOUT_MINIFY === "true";
4516
4516
  const ONLY_MINIFY = JIEK_ONLY_MINIFY === "true";
4517
- const CLEAN = JIEK_NO_CLEAN !== "true";
4517
+ const CLEAN = JIEK_CLEAN === "true";
4518
4518
  const MINIFY_DEFAULT_VALUE = WITHOUT_MINIFY ? false : ONLY_MINIFY ? "only-minify" : true;
4519
4519
  const BUILDER_OPTIONS = {
4520
4520
  type: JIEK_BUILDER ?? "esbuild"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "2.0.2",
4
+ "version": "2.1.0",
5
5
  "description": "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.",
6
6
  "author": "YiJie <yijie4188@gmail.com>",
7
7
  "repository": {
@@ -16,13 +16,6 @@
16
16
  "jiek-build": "bin/jiek-build.js",
17
17
  "jb": "bin/jiek-build.js"
18
18
  },
19
- "files": [
20
- "dist",
21
- "src",
22
- "bin",
23
- "LICENSE",
24
- "README.md"
25
- ],
26
19
  "exports": {
27
20
  "./package.json": "./package.json",
28
21
  ".": {
@@ -75,6 +68,23 @@
75
68
  "rollup-plugin-swc3": "^0.12.1",
76
69
  "typescript": "^4.0.0||^5.0.0"
77
70
  },
71
+ "devDependencies": {
72
+ "@npm/types": "^1.0.2",
73
+ "@pnpm/filter-workspace-packages": "^7.2.13",
74
+ "@pnpm/workspace.pkgs-graph": "^2.0.15",
75
+ "@rollup/plugin-terser": "^0.4.4",
76
+ "@types/cli-progress": "^3.11.5",
77
+ "@types/inquirer": "^9.0.7",
78
+ "@types/js-yaml": "^4.0.9",
79
+ "@types/micromatch": "^4.0.6",
80
+ "esbuild-register": "^3.5.0",
81
+ "micromatch": "^4.0.5",
82
+ "node-sass": "^9.0.0",
83
+ "postcss": "^8.4.47",
84
+ "rollup-plugin-postcss": "^4.0.2",
85
+ "rollup-plugin-esbuild": "^6.1.0",
86
+ "rollup-plugin-swc3": "^0.12.1"
87
+ },
78
88
  "peerDependenciesMeta": {
79
89
  "@rollup/plugin-terser": {
80
90
  "optional": true
@@ -101,37 +111,20 @@
101
111
  "optional": true
102
112
  }
103
113
  },
104
- "devDependencies": {
105
- "@npm/types": "^1.0.2",
106
- "@pnpm/filter-workspace-packages": "^7.2.13",
107
- "@pnpm/workspace.pkgs-graph": "^2.0.15",
108
- "@rollup/plugin-terser": "^0.4.4",
109
- "@types/cli-progress": "^3.11.5",
110
- "@types/inquirer": "^9.0.7",
111
- "@types/js-yaml": "^4.0.9",
112
- "@types/micromatch": "^4.0.6",
113
- "esbuild-register": "^3.5.0",
114
- "micromatch": "^4.0.5",
115
- "node-sass": "^9.0.0",
116
- "postcss": "^8.4.47",
117
- "rollup-plugin-postcss": "^4.0.2",
118
- "rollup-plugin-esbuild": "^6.1.0",
119
- "rollup-plugin-swc3": "^0.12.1"
120
- },
121
114
  "scripts": {
122
- "prepublish": "jb --noMin"
115
+ "prepublish": "jb -nm && jk"
123
116
  },
124
- "main": "./dist/index.cjs",
125
- "module": "./dist/index.js",
126
117
  "typesVersions": {
127
118
  "<5.0": {
128
119
  "*": [
129
120
  "*",
130
- "./dist/*",
131
- "./dist/*/index.d.ts",
132
- "./dist/*/index.d.mts",
133
- "./dist/*/index.d.cts"
121
+ "./*",
122
+ "./*/index.d.ts",
123
+ "./*/index.d.mts",
124
+ "./*/index.d.cts"
134
125
  ]
135
126
  }
136
- }
127
+ },
128
+ "main": "./dist/index.cjs",
129
+ "module": "./dist/index.js"
137
130
  }
@@ -0,0 +1 @@
1
+ {"type":"module","main":"../dist/rollup/index.cjs","module":"../dist/rollup/index.js"}
@@ -41,7 +41,7 @@ const isDefault = process.env.JIEK_IS_ONLY_BUILD === 'true'
41
41
 
42
42
  const description = `
43
43
  Build the package according to the 'exports' field from the package.json.
44
- If you want to rewrite the \`rollup\` command options, you can pass the options after '--'.
44
+ If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
45
45
  ${isDefault ? 'This command is the default command.' : ''}
46
46
  `.trim()
47
47
 
@@ -139,24 +139,19 @@ If you pass the --entries option, it will merge into the entries of the command.
139
139
  `.trim()
140
140
 
141
141
  const command = isDefault
142
- ? program
143
- .name('jb/jiek-build')
144
- .helpCommand(false)
142
+ ? (() => {
143
+ const c = program
144
+ .name('jb/jiek-build')
145
+ .helpCommand(false)
146
+ if (IS_WORKSPACE) {
147
+ c.argument('[filters]', buildFilterDescription)
148
+ } else {
149
+ c.argument('[entries]', buildEntriesDescription)
150
+ }
151
+ return c
152
+ })()
145
153
  : program
146
-
147
- if (IS_WORKSPACE) {
148
- if (isDefault) {
149
- command.argument('[filters]', buildFilterDescription)
150
- } else {
151
- command.command('build [filters]')
152
- }
153
- } else {
154
- if (isDefault) {
155
- command.argument('[entries]', buildEntriesDescription)
156
- } else {
157
- command.command('build [entries]')
158
- }
159
- }
154
+ .command(`build [${IS_WORKSPACE ? 'filters' : 'entries'}]`)
160
155
 
161
156
  command
162
157
  .description(description)