jiek 2.1.10 → 2.1.12

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,10 +1,10 @@
1
- import fs from 'node:fs';
1
+ import fs, { existsSync, statSync } from 'node:fs';
2
2
  import { createRequire } from 'node:module';
3
3
  import path from 'node:path';
4
- import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages';
5
4
  import { program } from 'commander';
6
5
  import { load } from 'js-yaml';
7
6
  import { isWorkspaceDir, getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
7
+ import process$1 from 'node:process';
8
8
  import { confirm } from '@inquirer/prompts';
9
9
  import { MultiBar, Presets } from 'cli-progress';
10
10
  import { execaCommand } from 'execa';
@@ -86,6 +86,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
86
86
  }
87
87
  filter = packageJSON.name;
88
88
  }
89
+ const { filterPackagesFromDir } = await import('@pnpm/filter-workspace-packages');
89
90
  const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
90
91
  filter: filter ?? "",
91
92
  followProdDepsOnly: true
@@ -108,15 +109,29 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
108
109
 
109
110
  var name = "jiek";
110
111
  var type = "module";
111
- var version = "2.1.9";
112
+ var version = "2.1.11";
112
113
  var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
113
114
  var author = "YiJie <yijie4188@gmail.com>";
115
+ var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
114
116
  var repository = {
115
117
  url: "nwylzw/jiek",
116
118
  directory: "packages/jiek"
117
119
  };
118
- var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
119
120
  var bugs = "https://github.com/NWYLZW/jiek/issues?q=is%3Aissue+is%3Aopen+jiek";
121
+ var exports = {
122
+ "./package.json": "./package.json",
123
+ ".": "./src/index.ts",
124
+ "./bin-helper": {
125
+ require: "./bin-helper.cjs",
126
+ "default": "./bin-helper.js"
127
+ },
128
+ "./cli": "./src/cli.ts",
129
+ "./cli-only-build": "./src/cli-only-build.ts",
130
+ "./rollup": "./src/rollup/index.ts"
131
+ };
132
+ var imports = {
133
+ "#~/*": "./src/*"
134
+ };
120
135
  var bin = {
121
136
  jiek: "bin/jiek.js",
122
137
  jk: "bin/jiek.js",
@@ -124,52 +139,47 @@ var bin = {
124
139
  jb: "bin/jiek-build.js"
125
140
  };
126
141
  var files = [
127
- "dist",
128
- "src",
129
- "bin",
130
142
  "LICENSE",
131
- "README.md"
143
+ "README.md",
144
+ "bin",
145
+ "bin-helper.cjs",
146
+ "bin-helper.js",
147
+ "dist",
148
+ "src"
132
149
  ];
133
150
  var scripts = {
134
151
  prepublish: "jb -nm && jk",
135
152
  postpublish: "jk",
136
153
  test: "vitest run"
137
154
  };
138
- var exports = {
139
- "./package.json": "./package.json",
140
- ".": "./src/index.ts",
141
- "./cli": "./src/cli.ts",
142
- "./cli-only-build": "./src/cli-only-build.ts",
143
- "./rollup": "./src/rollup/index.ts"
144
- };
145
- var imports = {
146
- "#~/*": "./src/*"
155
+ var peerDependencies = {
156
+ "@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0",
157
+ "@rollup/plugin-terser": "^0.4.4",
158
+ "esbuild-register": "^3.5.0",
159
+ postcss: "^8.4.47",
160
+ "rollup-plugin-esbuild": "^6.1.0",
161
+ "rollup-plugin-postcss": "^4.0.2",
162
+ "rollup-plugin-swc3": "^0.12.1",
163
+ typescript: "^4.0.0||^5.0.0",
164
+ "vite-bundle-analyzer": "^0.15.1"
147
165
  };
148
166
  var dependencies = {
167
+ "@inquirer/prompts": "^7.1.0",
149
168
  "@jiek/pkger": "workspace:^",
150
169
  "@jiek/rollup-plugin-dts": "^6.2.1",
151
170
  "@jiek/utils": "workspace:^",
152
- "@inquirer/prompts": "^7.1.0",
153
171
  "@rollup/plugin-commonjs": "^28.0.0",
172
+ "@rollup/plugin-inject": "^5.0.5",
154
173
  "@rollup/plugin-json": "^6.0.1",
155
174
  "@rollup/plugin-node-resolve": "^15.3.0",
175
+ "@rollup/plugin-replace": "^6.0.1",
156
176
  "cli-progress": "^3.12.0",
157
177
  commander: "^12.0.0",
158
178
  "detect-indent": "^6.1.0",
159
- execa: "9.3.1",
179
+ execa: "~9.3.1",
160
180
  "js-yaml": "^4.1.0",
161
181
  "jsonc-parser": "^3.2.1",
162
- rollup: "4.13.2"
163
- };
164
- var peerDependencies = {
165
- "@rollup/plugin-terser": "^0.4.4",
166
- "@pnpm/filter-workspace-packages": "^7.2.13",
167
- "esbuild-register": "^3.5.0",
168
- postcss: "^8.4.47",
169
- "rollup-plugin-postcss": "^4.0.2",
170
- "rollup-plugin-esbuild": "^6.1.0",
171
- "rollup-plugin-swc3": "^0.12.1",
172
- typescript: "^4.0.0||^5.0.0"
182
+ rollup: "^4.0.0"
173
183
  };
174
184
  var devDependencies = {
175
185
  "@npm/types": "^1.0.2",
@@ -184,9 +194,10 @@ var devDependencies = {
184
194
  micromatch: "^4.0.5",
185
195
  "node-sass": "^9.0.0",
186
196
  postcss: "^8.4.47",
187
- "rollup-plugin-postcss": "^4.0.2",
188
197
  "rollup-plugin-esbuild": "^6.1.0",
189
- "rollup-plugin-swc3": "^0.12.1"
198
+ "rollup-plugin-postcss": "^4.0.2",
199
+ "rollup-plugin-swc3": "^0.12.1",
200
+ "vite-bundle-analyzer": "^0.15.1"
190
201
  };
191
202
  var pkg = {
192
203
  name: name,
@@ -194,16 +205,16 @@ var pkg = {
194
205
  version: version,
195
206
  description: description$1,
196
207
  author: author,
197
- repository: repository,
198
208
  homepage: homepage,
209
+ repository: repository,
199
210
  bugs: bugs,
211
+ exports: exports,
212
+ imports: imports,
200
213
  bin: bin,
201
214
  files: files,
202
215
  scripts: scripts,
203
- exports: exports,
204
- imports: imports,
205
- dependencies: dependencies,
206
216
  peerDependencies: peerDependencies,
217
+ dependencies: dependencies,
207
218
  devDependencies: devDependencies
208
219
  };
209
220
 
@@ -226,7 +237,7 @@ Support with variables: 'PKG_NAME',
226
237
  const { notWorkspace } = getWD();
227
238
  const IS_WORKSPACE = !notWorkspace;
228
239
 
229
- program.name("jk/jiek").version(pkg.version).description(`${pkg.description} - Version ${pkg.version}`).option("-c, --config-path <configPath>", "Custom jiek config path");
240
+ 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.");
230
241
  if (type$1 !== "" && IS_WORKSPACE) {
231
242
  program.option("-f, --filter <filter>", filterDescription);
232
243
  }
@@ -289,10 +300,7 @@ function getConfigPath(root, dir) {
289
300
  function loadConfig(dirOrOptions) {
290
301
  let dir;
291
302
  let root;
292
- if (typeof dirOrOptions === "object") {
293
- dir = dirOrOptions.dir;
294
- root = dirOrOptions.root ?? getWD().wd;
295
- } else {
303
+ {
296
304
  dir = dirOrOptions;
297
305
  root = getWD().wd;
298
306
  }
@@ -347,7 +355,7 @@ const FILE_TEMPLATE = (manifest) => `
347
355
  module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
348
356
  `.trimStart();
349
357
  const require = createRequire(import.meta.url);
350
- const isDefault = process.env.JIEK_IS_ONLY_BUILD === "true";
358
+ const isDefault = process$1.env.JIEK_IS_ONLY_BUILD === "true";
351
359
  const description = `
352
360
  Build the package according to the 'exports' field from the package.json.
353
361
  If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
@@ -356,7 +364,7 @@ ${isDefault ? "This command is the default command." : ""}
356
364
  async function checkDependency(dependency) {
357
365
  try {
358
366
  require.resolve(dependency);
359
- } catch (e) {
367
+ } catch {
360
368
  console.error(`The package '${dependency}' is not installed, please install it first.`);
361
369
  const { notWorkspace } = getWD();
362
370
  const command2 = `pnpm install -${notWorkspace ? "" : "w"}D ${dependency}`;
@@ -364,7 +372,7 @@ async function checkDependency(dependency) {
364
372
  await execaCommand(command2);
365
373
  } else {
366
374
  console.warn(`You can run the command '${command2}' to install it manually.`);
367
- process.exit(1);
375
+ process$1.exit(1);
368
376
  }
369
377
  }
370
378
  }
@@ -392,7 +400,7 @@ const buildEntriesDescription = `
392
400
  ${entriesDescription}
393
401
  If you pass the --entries option, it will merge into the entries of the command.
394
402
  `.trim();
395
- const command = isDefault ? (() => {
403
+ let command = isDefault ? (() => {
396
404
  const c = program.name("jb/jiek-build").helpCommand(false);
397
405
  if (IS_WORKSPACE) {
398
406
  c.argument("[filters]", buildFilterDescription);
@@ -401,7 +409,7 @@ const command = isDefault ? (() => {
401
409
  }
402
410
  return c;
403
411
  })() : program.command(`build [${IS_WORKSPACE ? "filters" : "entries"}]`);
404
- command.description(description).option("-t, --type <TYPE>", `The type of build, support ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
412
+ command = command.description(description).option("-t, --type <TYPE>", `The type of build, support ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
405
413
  if (!BUILDER_TYPES.includes(v)) {
406
414
  throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
407
415
  }
@@ -419,7 +427,16 @@ command.description(description).option("-t, --type <TYPE>", `The type of build,
419
427
  "-om, --onlyMin",
420
428
  "Only output minify files, but dts files will still be output, it only replaces the js files.",
421
429
  parseBoolean
422
- ).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).option("-w, --watch", "Watch the file changes.", parseBoolean).option("-s, --silent", "Don't display logs.", parseBoolean).option("-v, --verbose", "Display debug logs.", parseBoolean).action(async (commandFiltersOrEntries, options) => {
430
+ );
431
+ 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);
432
+ command = command.option("-w, --watch", "Watch the file changes.", parseBoolean);
433
+ command = command.option("--ana", "Enable the bundle analyzer.", parseBoolean).option("--ana.dir <DIR>", "The directory of the bundle analyzer.", ".jk-analyses").option("--ana.mode <MODE>", 'The mode of the bundle analyzer, support "static", "json" and "server".', "server").option("--ana.port <PORT>", "The port of the bundle analyzer.", Number.parseInt).option("--ana.open", "Open the bundle analyzer in the browser.", parseBoolean).option(
434
+ "--ana.size <SIZE>",
435
+ 'The default size of the bundle analyzer, support "stat", "parsed" and "gzip".',
436
+ "parsed"
437
+ );
438
+ command = command.option("-s, --silent", "Don't display logs.", parseBoolean).option("-v, --verbose", "Display debug logs.", parseBoolean);
439
+ command.action(async (commandFiltersOrEntries, options) => {
423
440
  let {
424
441
  type,
425
442
  outdir,
@@ -453,7 +470,7 @@ command.description(description).option("-t, --type <TYPE>", `The type of build,
453
470
  );
454
471
  }
455
472
  let shouldPassThrough = false;
456
- const passThroughOptions = process.argv.reduce(
473
+ const passThroughOptions = process$1.argv.reduce(
457
474
  (acc, value) => {
458
475
  if (shouldPassThrough) {
459
476
  acc.push(value);
@@ -465,6 +482,16 @@ command.description(description).option("-t, --type <TYPE>", `The type of build,
465
482
  },
466
483
  []
467
484
  );
485
+ const analyzer = options.ana ? {
486
+ dir: options["ana.dir"],
487
+ mode: options["ana.mode"],
488
+ port: options["ana.port"],
489
+ open: options["ana.open"],
490
+ size: options["ana.size"]
491
+ } : void 0;
492
+ if (analyzer) {
493
+ await checkDependency("vite-bundle-analyzer");
494
+ }
468
495
  const { build } = loadConfig();
469
496
  silent = silent ?? build?.silent ?? false;
470
497
  if (withoutMin && onlyMin) {
@@ -481,7 +508,7 @@ command.description(description).option("-t, --type <TYPE>", `The type of build,
481
508
  entries = void 0;
482
509
  }
483
510
  const env = {
484
- ...process.env,
511
+ JIEK_ANALYZER: analyzer && JSON.stringify(analyzer),
485
512
  JIEK_BUILDER: type,
486
513
  JIEK_OUT_DIR: outdir,
487
514
  JIEK_CLEAN: String(!noClean),
@@ -493,7 +520,8 @@ command.description(description).option("-t, --type <TYPE>", `The type of build,
493
520
  JIEK_ONLY_MINIFY: String(onlyMin),
494
521
  JIEK_MINIFY_TYPE: minifyType,
495
522
  JIEK_TSCONFIG: tsconfig,
496
- JIEK_DTSCONFIG: dtsconfig
523
+ JIEK_DTSCONFIG: dtsconfig,
524
+ ...process$1.env
497
525
  };
498
526
  const multiBars = new MultiBar({
499
527
  clearOnComplete: false,
@@ -519,16 +547,33 @@ command.description(description).option("-t, --type <TYPE>", `The type of build,
519
547
  let i = 0;
520
548
  await Promise.all(
521
549
  Object.entries(value).map(async ([dir, manifest]) => {
522
- if (!manifest.name) {
550
+ if (manifest.name == null) {
523
551
  throw new Error("package.json must have a name field");
524
552
  }
553
+ if (analyzer) {
554
+ const anaDir = path.resolve(dir, analyzer.dir);
555
+ if (!existsSync(anaDir)) {
556
+ fs.mkdirSync(anaDir, { recursive: true });
557
+ }
558
+ const gitIgnorePath = path.resolve(anaDir, ".gitignore");
559
+ if (!existsSync(gitIgnorePath)) {
560
+ fs.writeFileSync(gitIgnorePath, "*\n!.gitignore\n");
561
+ }
562
+ const npmIgnorePath = path.resolve(anaDir, ".npmignore");
563
+ if (!existsSync(npmIgnorePath)) {
564
+ fs.writeFileSync(npmIgnorePath, "*\n");
565
+ }
566
+ if (!statSync(anaDir).isDirectory()) {
567
+ throw new Error(`The directory '${anaDir}' is not a directory.`);
568
+ }
569
+ }
525
570
  const escapeManifestName = manifest.name.replace(/^@/g, "").replace(/\//g, "+");
526
571
  const configFile = jiekTempDir(
527
572
  `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
528
573
  );
529
574
  fs.writeFileSync(configFile, FILE_TEMPLATE(manifest));
530
575
  const command2 = [rollupBinaryPath, "--silent", "-c", configFile];
531
- if (tsRegisterName) {
576
+ if (tsRegisterName != null) {
532
577
  command2.unshift(`node -r ${tsRegisterName}`);
533
578
  }
534
579
  if (watch) {
@@ -641,7 +686,7 @@ command.description(description).option("-t, --type <TYPE>", `The type of build,
641
686
  });
642
687
  child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(`rollup build failed:
643
688
  ${errorStr}`)));
644
- verbose && child.stdout?.pipe(process.stdout);
689
+ verbose && child.stdout?.pipe(process$1.stdout);
645
690
  });
646
691
  })
647
692
  );
@@ -665,8 +710,29 @@ ${errorStr}`)));
665
710
  }
666
711
  });
667
712
 
668
- if (process.env.JIEK_IS_ONLY_BUILD === "true") {
669
- import('commander').then(({ program }) => {
670
- program.parse(process.argv);
671
- });
713
+ const { argv } = process$1;
714
+ const env = {};
715
+ let isPassThrough = false;
716
+ const newArgv = argv.filter((arg) => {
717
+ if (isPassThrough) {
718
+ return true;
719
+ }
720
+ if (arg === "--") {
721
+ isPassThrough = true;
722
+ return false;
723
+ }
724
+ const m = /^--env\.(\w+)=(.*)$/.exec(arg);
725
+ if (m) {
726
+ env[m[1]] = m[2];
727
+ return false;
728
+ }
729
+ return true;
730
+ });
731
+ for (const [key, value] of Object.entries(env)) {
732
+ process$1.env[key] = value;
733
+ }
734
+ var parseArgv = () => program.parse(newArgv);
735
+
736
+ if (process$1.env.JIEK_IS_ONLY_BUILD === "true") {
737
+ parseArgv();
672
738
  }
package/dist/cli.cjs CHANGED
@@ -8,13 +8,13 @@ var commander = require('commander');
8
8
  var detectIndent = require('detect-indent');
9
9
  var jsoncParser = require('jsonc-parser');
10
10
  var node_module = require('node:module');
11
- var filterWorkspacePackages = require('@pnpm/filter-workspace-packages');
12
11
  var jsYaml = require('js-yaml');
13
12
  var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
14
13
  var entrypoints = require('@jiek/pkger/entrypoints');
15
14
  var require$$0 = require('util');
16
15
  var require$$0$1 = require('path');
17
16
  require('jiek/cli-only-build');
17
+ var process$1 = require('node:process');
18
18
 
19
19
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
20
20
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -43,6 +43,7 @@ var path__default = /*#__PURE__*/_interopDefault(path);
43
43
  var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
44
44
  var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
45
45
  var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
46
+ var process__default = /*#__PURE__*/_interopDefault(process$1);
46
47
 
47
48
  let root;
48
49
  function getRoot() {
@@ -80,7 +81,7 @@ function getWD() {
80
81
 
81
82
  let type = "";
82
83
  try {
83
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
84
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
84
85
  require$1.resolve("@pnpm/filter-workspace-packages");
85
86
  type = "pnpm";
86
87
  } catch {
@@ -118,7 +119,8 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
118
119
  }
119
120
  filter = packageJSON.name;
120
121
  }
121
- const { selectedProjectsGraph } = await filterWorkspacePackages.filterPackagesFromDir(wd, [{
122
+ const { filterPackagesFromDir } = await import('@pnpm/filter-workspace-packages');
123
+ const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
122
124
  filter: filter ?? "",
123
125
  followProdDepsOnly: true
124
126
  }], {
@@ -4335,7 +4337,7 @@ function getExports({
4335
4337
  ];
4336
4338
  }
4337
4339
 
4338
- const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
4340
+ const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
4339
4341
  function packageIsExist(name) {
4340
4342
  try {
4341
4343
  require$2.resolve(name);
@@ -4358,7 +4360,7 @@ for (const register of registers) {
4358
4360
  }
4359
4361
  }
4360
4362
 
4361
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
4363
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
4362
4364
  let configName = "jiek.config";
4363
4365
  function getConfigPath(root, dir) {
4364
4366
  const isSupportTsLoader = !!tsRegisterName;
@@ -4606,6 +4608,17 @@ async function prepublish() {
4606
4608
  }
4607
4609
  }
4608
4610
  }
4611
+ if (oldJSON["devDependencies"]) {
4612
+ newJSONString = jsoncParser.applyEdits(
4613
+ newJSONString,
4614
+ jsoncParser.modify(
4615
+ newJSONString,
4616
+ ["devDependencies"],
4617
+ void 0,
4618
+ { formattingOptions }
4619
+ )
4620
+ );
4621
+ }
4609
4622
  if (oldJSON["peerDependencies"]) {
4610
4623
  const peerDependenciesMeta = Object.keys(oldJSON["peerDependencies"]).reduce(
4611
4624
  (acc, key) => {
@@ -4802,4 +4815,27 @@ Restore package.json after publish, you can add \`jk\` to the \`postpublish\` sc
4802
4815
  `.trim();
4803
4816
  commander.program.command("postpublish").description(postpublishDescription).action(postpublish);
4804
4817
 
4805
- commander.program.parse(process.argv);
4818
+ const { argv } = process__default.default;
4819
+ const env = {};
4820
+ let isPassThrough = false;
4821
+ const newArgv = argv.filter((arg) => {
4822
+ if (isPassThrough) {
4823
+ return true;
4824
+ }
4825
+ if (arg === "--") {
4826
+ isPassThrough = true;
4827
+ return false;
4828
+ }
4829
+ const m = /^--env\.(\w+)=(.*)$/.exec(arg);
4830
+ if (m) {
4831
+ env[m[1]] = m[2];
4832
+ return false;
4833
+ }
4834
+ return true;
4835
+ });
4836
+ for (const [key, value] of Object.entries(env)) {
4837
+ process__default.default.env[key] = value;
4838
+ }
4839
+ var parseArgv = () => commander.program.parse(newArgv);
4840
+
4841
+ parseArgv();
package/dist/cli.js CHANGED
@@ -6,13 +6,13 @@ import { program } from 'commander';
6
6
  import detectIndent from 'detect-indent';
7
7
  import { applyEdits, modify } from 'jsonc-parser';
8
8
  import { createRequire } from 'node:module';
9
- import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages';
10
9
  import { load } from 'js-yaml';
11
10
  import { isWorkspaceDir, getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
12
11
  import { resolveEntrypoints, filterLeafs, DEFAULT_SKIP_VALUES, entrypoints2Exports } from '@jiek/pkger/entrypoints';
13
12
  import require$$0 from 'util';
14
13
  import require$$0$1 from 'path';
15
14
  import 'jiek/cli-only-build';
15
+ import process$1 from 'node:process';
16
16
 
17
17
  let root;
18
18
  function getRoot() {
@@ -88,6 +88,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
88
88
  }
89
89
  filter = packageJSON.name;
90
90
  }
91
+ const { filterPackagesFromDir } = await import('@pnpm/filter-workspace-packages');
91
92
  const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
92
93
  filter: filter ?? "",
93
94
  followProdDepsOnly: true
@@ -4576,6 +4577,17 @@ async function prepublish() {
4576
4577
  }
4577
4578
  }
4578
4579
  }
4580
+ if (oldJSON["devDependencies"]) {
4581
+ newJSONString = applyEdits(
4582
+ newJSONString,
4583
+ modify(
4584
+ newJSONString,
4585
+ ["devDependencies"],
4586
+ void 0,
4587
+ { formattingOptions }
4588
+ )
4589
+ );
4590
+ }
4579
4591
  if (oldJSON["peerDependencies"]) {
4580
4592
  const peerDependenciesMeta = Object.keys(oldJSON["peerDependencies"]).reduce(
4581
4593
  (acc, key) => {
@@ -4772,4 +4784,27 @@ Restore package.json after publish, you can add \`jk\` to the \`postpublish\` sc
4772
4784
  `.trim();
4773
4785
  program.command("postpublish").description(postpublishDescription).action(postpublish);
4774
4786
 
4775
- program.parse(process.argv);
4787
+ const { argv } = process$1;
4788
+ const env = {};
4789
+ let isPassThrough = false;
4790
+ const newArgv = argv.filter((arg) => {
4791
+ if (isPassThrough) {
4792
+ return true;
4793
+ }
4794
+ if (arg === "--") {
4795
+ isPassThrough = true;
4796
+ return false;
4797
+ }
4798
+ const m = /^--env\.(\w+)=(.*)$/.exec(arg);
4799
+ if (m) {
4800
+ env[m[1]] = m[2];
4801
+ return false;
4802
+ }
4803
+ return true;
4804
+ });
4805
+ for (const [key, value] of Object.entries(env)) {
4806
+ process$1.env[key] = value;
4807
+ }
4808
+ var parseArgv = () => program.parse(newArgv);
4809
+
4810
+ parseArgv();