jiek 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/bin/jiek-dev.js +4 -0
  2. package/bin/jiek.js +2 -0
  3. package/dist/commands/build.esm.js +68 -0
  4. package/dist/commands/build.esm.js.map +1 -0
  5. package/dist/commands/build.esm.min.js +2 -0
  6. package/dist/commands/build.esm.min.js.map +1 -0
  7. package/dist/commands/publish.esm.js +60 -0
  8. package/dist/commands/publish.esm.js.map +1 -0
  9. package/dist/commands/publish.esm.min.js +2 -0
  10. package/dist/commands/publish.esm.min.js.map +1 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.esm.d.ts +2 -0
  13. package/dist/index.esm.js +6 -0
  14. package/dist/index.esm.js.map +1 -0
  15. package/dist/index.esm.min.js +2 -0
  16. package/dist/index.esm.min.js.map +1 -0
  17. package/dist/index.iife.js +155 -0
  18. package/dist/index.iife.js.map +1 -0
  19. package/dist/index.iife.min.js +2 -0
  20. package/dist/index.iife.min.js.map +1 -0
  21. package/dist/index.umd.js +158 -0
  22. package/dist/index.umd.js.map +1 -0
  23. package/dist/index.umd.min.js +2 -0
  24. package/dist/index.umd.min.js.map +1 -0
  25. package/dist/inner.esm.js +10 -0
  26. package/dist/inner.esm.js.map +1 -0
  27. package/dist/inner.esm.min.js +2 -0
  28. package/dist/inner.esm.min.js.map +1 -0
  29. package/dist/merge-package-json.esm.js +16 -0
  30. package/dist/merge-package-json.esm.js.map +1 -0
  31. package/dist/merge-package-json.esm.min.js +2 -0
  32. package/dist/merge-package-json.esm.min.js.map +1 -0
  33. package/package.json +56 -0
  34. package/src/commands/build.ts +91 -0
  35. package/src/commands/publish.ts +79 -0
  36. package/src/index.ts +6 -0
  37. package/src/inner.ts +11 -0
  38. package/src/merge-package-json.ts +19 -0
  39. package/src/rollup/index.ts +162 -0
  40. package/src/rollup/plugins/globals.ts +34 -0
  41. package/src/rollup/plugins/skip.ts +23 -0
  42. package/src/rollup/utils/commonOptions.ts +9 -0
  43. package/src/rollup/utils/externalResolver.ts +11 -0
  44. package/src/rollup/utils/globalResolver.ts +24 -0
  45. package/src/rollup/utils/withMinify.ts +16 -0
  46. package/tests/build.spec.ts +28 -0
  47. package/tests/fixtures/node_modules/.bin/jiek +17 -0
  48. package/tests/fixtures/node_modules/.jiek/jiek+test-foo.rollup.config.js +31 -0
  49. package/tests/fixtures/node_modules/.modules.yaml +95 -0
  50. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/README.md +3 -0
  51. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
  52. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/package.json +20 -0
  53. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/LICENSE +21 -0
  54. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/loader.js +3 -0
  55. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/package.json +8 -0
  56. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/LICENSE +20 -0
  57. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/README.md +481 -0
  58. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/package.json +59 -0
  59. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/browser.js +269 -0
  60. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/common.js +274 -0
  61. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/index.js +10 -0
  62. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/node.js +263 -0
  63. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/LICENSE +21 -0
  64. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/README.md +50 -0
  65. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/loader.d.ts +3 -0
  66. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/loader.js +15 -0
  67. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.d.ts +23 -0
  68. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.js +4926 -0
  69. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/loader.js +1 -0
  70. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/node_modules/.bin/esbuild +14 -0
  71. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/package.json +46 -0
  72. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/register.js +3 -0
  73. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/LICENSE.md +21 -0
  74. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/README.md +3 -0
  75. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/bin/esbuild +0 -0
  76. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/install.js +288 -0
  77. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.d.ts +703 -0
  78. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.js +2436 -0
  79. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/node_modules/.bin/esbuild +14 -0
  80. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/package.json +46 -0
  81. package/tests/fixtures/node_modules/.pnpm/lock.yaml +291 -0
  82. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js +162 -0
  83. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/license.md +21 -0
  84. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/package.json +37 -0
  85. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/readme.md +60 -0
  86. package/tests/fixtures/node_modules/.pnpm/node_modules/.bin/esbuild +14 -0
  87. package/tests/fixtures/package.json +8 -0
  88. package/tests/fixtures/packages/bar/package.json +4 -0
  89. package/tests/fixtures/packages/foo/dist/index.d.ts +3 -0
  90. package/tests/fixtures/packages/foo/dist/index.esm.d.ts +3 -0
  91. package/tests/fixtures/packages/foo/dist/index.esm.js +6 -0
  92. package/tests/fixtures/packages/foo/dist/index.esm.js.map +1 -0
  93. package/tests/fixtures/packages/foo/dist/index.esm.min.js +2 -0
  94. package/tests/fixtures/packages/foo/dist/index.esm.min.js.map +1 -0
  95. package/tests/fixtures/packages/foo/dist/index.iife.js +15 -0
  96. package/tests/fixtures/packages/foo/dist/index.iife.js.map +1 -0
  97. package/tests/fixtures/packages/foo/dist/index.iife.min.js +2 -0
  98. package/tests/fixtures/packages/foo/dist/index.iife.min.js.map +1 -0
  99. package/tests/fixtures/packages/foo/dist/index.umd.js +16 -0
  100. package/tests/fixtures/packages/foo/dist/index.umd.js.map +1 -0
  101. package/tests/fixtures/packages/foo/dist/index.umd.min.js +2 -0
  102. package/tests/fixtures/packages/foo/dist/index.umd.min.js.map +1 -0
  103. package/tests/fixtures/packages/foo/package.json +7 -0
  104. package/tests/fixtures/packages/foo/src/index.ts +3 -0
  105. package/tests/fixtures/pnpm-workspace.yaml +2 -0
  106. package/tests/publish.spec.ts +31 -0
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ process.env.NODE_ENV = 'test'
3
+ require('esbuild-register')
4
+ require('../src/index.ts')
package/bin/jiek.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../dist/index.umd.js')
@@ -0,0 +1,68 @@
1
+ import * as childProcess from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
5
+ import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages';
6
+ import { program } from 'commander';
7
+ import { load } from 'js-yaml';
8
+ import { actionRestore, actionDone } from '../inner.esm.js';
9
+ import { mergePackageJson } from '../merge-package-json.esm.js';
10
+
11
+ const FILE_TEMPLATE = (manifest) => `
12
+ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/index.ts" : "jiek/rollup"}').template({ }, ${JSON.stringify(manifest, null, 2)})
13
+ `.trimStart();
14
+ program.command("build").option("--filter <filter>", "filter packages").option("--root <root>", "root path").action(async ({ root: rootOption, filter, ...options }) => {
15
+ actionRestore();
16
+ const root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : process.cwd();
17
+ const wd = getWorkspaceDir(root);
18
+ const pnpmWorkspaceFilePath = path.resolve(wd, "pnpm-workspace.yaml");
19
+ const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, "utf-8");
20
+ const pnpmWorkspace = load(pnpmWorkspaceFileContent);
21
+ if (root === wd && !filter) {
22
+ throw new Error("root path is workspace root, please provide a filter");
23
+ }
24
+ if (root !== wd && !filter) {
25
+ const packageJSONIsExist = fs.existsSync(path.resolve(root, "package.json"));
26
+ if (!packageJSONIsExist) {
27
+ throw new Error("root path is not workspace root, please provide a filter");
28
+ }
29
+ const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, "package.json"), "utf-8"));
30
+ if (!packageJSON.name) {
31
+ throw new Error("root path is not workspace root, please provide a filter");
32
+ }
33
+ filter = packageJSON.name;
34
+ }
35
+ const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
36
+ filter: filter ?? "",
37
+ followProdDepsOnly: true
38
+ }], {
39
+ prefix: root,
40
+ workspaceDir: wd,
41
+ patterns: pnpmWorkspace.packages
42
+ });
43
+ const jiekTempDir = (...paths) => path.resolve(wd, "node_modules/.jiek", ...paths);
44
+ if (!fs.existsSync(jiekTempDir()))
45
+ fs.mkdirSync(jiekTempDir());
46
+ const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
47
+ let i = 0;
48
+ for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {
49
+ const newManifest = mergePackageJson(manifest, dir);
50
+ const escapeManifestName = manifest.name?.replace(/^@/g, "").replace(/\//g, "+");
51
+ const configFile = jiekTempDir(
52
+ `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
53
+ );
54
+ fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest));
55
+ let prefix = "";
56
+ if (process.env.NODE_ENV === "test") {
57
+ const registerPath = require.resolve("esbuild-register");
58
+ const loaderPath = require.resolve("esbuild-register/loader");
59
+ prefix = `node --import ${registerPath} -r ${loaderPath} `;
60
+ }
61
+ childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {
62
+ cwd: dir,
63
+ stdio: "inherit"
64
+ });
65
+ }
66
+ actionDone();
67
+ });
68
+ //# sourceMappingURL=build.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.esm.js","sources":["../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template({ }, ${JSON.stringify(manifest, null, 2)})\n`.trimStart()\n\nprogram\n .command('build')\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n"],"names":[],"mappings":";;;;;;;;;;AAYA,MAAM,aAAA,GAAgB,CAAC,QAAsB,KAAA,CAAA;AAAA,0BAAA,EAE3C,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,MAAA,GACrB,0BACA,GAAA,aACN,CAAoB,iBAAA,EAAA,IAAA,CAAK,SAAU,CAAA,QAAA,EAAU,IAAM,EAAA,CAAC,CAAC,CAAA;AAAA,CAAA,CACnD,SAAU,EAAA,CAAA;AAEZ,OAAA,CACG,QAAQ,OAAO,CAAA,CACf,OAAO,mBAAqB,EAAA,iBAAiB,EAC7C,MAAO,CAAA,eAAA,EAAiB,WAAW,CACnC,CAAA,MAAA,CAAO,OAAO,EAAE,IAAA,EAAM,YAAY,MAAQ,EAAA,GAAG,SAGxC,KAAA;AACJ,EAAc,aAAA,EAAA,CAAA;AACd,EAAA,MAAM,IAAO,GAAA,UAAA,GACT,IAAK,CAAA,UAAA,CAAW,UAAU,CACxB,GAAA,UAAA,GACA,IAAK,CAAA,OAAA,CAAQ,QAAQ,GAAI,EAAA,EAAG,UAAU,CAAA,GACxC,QAAQ,GAAI,EAAA,CAAA;AAChB,EAAM,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vD,MAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,OAAA,CAAQ,yBAAyB,CAAA,CAAA;AAC5D,MAAS,MAAA,GAAA,CAAA,cAAA,EAAiB,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA,CAAA,CAAA,CAAA;AAAA,KACzD;AAEA,IAAA,YAAA,CAAa,SAAS,CAAG,EAAA,MAAM,GAAG,gBAAgB,CAAA,IAAA,EAAO,UAAU,CAAI,CAAA,EAAA;AAAA,MACrE,GAAK,EAAA,GAAA;AAAA,MAAK,KAAO,EAAA,SAAA;AAAA,KAClB,CAAA,CAAA;AAAA,GACH;AAEA,EAAW,UAAA,EAAA,CAAA;AACb,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import*as e from"node:child_process";import r from"node:fs";import o from"node:path";import{getWorkspaceDir as t}from"@jiek/utils/getWorkspaceDir";import{filterPackagesFromDir as s}from"@pnpm/filter-workspace-packages";import{program as i}from"commander";import{load as p}from"js-yaml";import{actionRestore as l,actionDone as n}from"../inner.esm.min.js";import{mergePackageJson as a}from"../merge-package-json.esm.min.js";const c=e=>`\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template({ }, ${JSON.stringify(e,null,2)})\n`.trimStart();i.command("build").option("--filter <filter>","filter packages").option("--root <root>","root path").action((async({root:i,filter:m,...f})=>{l();const d=i?o.isAbsolute(i)?i:o.resolve(process.cwd(),i):process.cwd(),u=t(d),k=o.resolve(u,"pnpm-workspace.yaml"),w=r.readFileSync(k,"utf-8"),g=p(w);if(d===u&&!m)throw new Error("root path is workspace root, please provide a filter");if(d!==u&&!m){if(!r.existsSync(o.resolve(d,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const e=JSON.parse(r.readFileSync(o.resolve(d,"package.json"),"utf-8"));if(!e.name)throw new Error("root path is not workspace root, please provide a filter");m=e.name}const{selectedProjectsGraph:j}=await s(u,[{filter:m??"",followProdDepsOnly:!0}],{prefix:d,workspaceDir:u,patterns:g.packages}),v=(...e)=>o.resolve(u,"node_modules/.jiek",...e);r.existsSync(v())||r.mkdirSync(v());const y=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let h=0;for(const[o,{package:{manifest:t}}]of Object.entries(j)){const s=a(t,o),i=t.name?.replace(/^@/g,"").replace(/\//g,"+"),p=v(`${i??"anonymous-"+h++}.rollup.config.js`);r.writeFileSync(p,c(s));let l="";if("test"===process.env.NODE_ENV){l=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}e.execSync(`${l}${y} -c ${p}`,{cwd:o,stdio:"inherit"})}n()}));
2
+ //# sourceMappingURL=build.esm.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.esm.min.js","sources":["../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template({ }, ${JSON.stringify(manifest, null, 2)})\n`.trimStart()\n\nprogram\n .command('build')\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n"],"names":["FILE_TEMPLATE","manifest","process","env","NODE_ENV","JSON","stringify","trimStart","program","command","option","action","async","root","rootOption","filter","options","actionRestore","path","isAbsolute","resolve","cwd","wd","getWorkspaceDir","pnpmWorkspaceFilePath","pnpmWorkspaceFileContent","fs","readFileSync","pnpmWorkspace","load","Error","existsSync","packageJSON","parse","name","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","packages","jiekTempDir","paths","mkdirSync","rollupBinaryPath","require","replace","i","dir","package","Object","entries","newManifest","mergePackageJson","escapeManifestName","configFile","writeFileSync","childProcess","execSync","stdio","actionDone"],"mappings":"saAYA,MAAMA,EAAiBC,GAAsB,+BAElB,SAAzBC,QAAQC,IAAIC,SACR,2BACA,iCACcC,KAAKC,UAAUL,EAAU,KAAM,QACjDM,YAEFC,EACGC,QAAQ,SACRC,OAAO,oBAAqB,mBAC5BA,OAAO,gBAAiB,aACxBC,QAAOC,OAASC,KAAMC,EAAYC,YAAWC,MAI9BC,IACd,MAAMJ,EAAOC,EACTI,EAAKC,WAAWL,GACdA,EACAI,EAAKE,QAAQlB,QAAQmB,MAAOP,GAC9BZ,QAAQmB,MACNC,EAAKC,EAAgBV,GACrBW,EAAwBN,EAAKE,QAAQE,EAAI,uBACzCG,EAA2BC,EAAGC,aAAaH,EAAuB,SAClEI,EAAgBC,EAAKJ,GAGvB,GAAAZ,IAASS,IAAOP,EACZ,MAAA,IAAIe,MAAM,wDAGd,GAAAjB,IAASS,IAAOP,EAAQ,CAE1B,IAD2BW,EAAGK,WAAWb,EAAKE,QAAQP,EAAM,iBAEpD,MAAA,IAAIiB,MAAM,4DAEZ,MAAAE,EAAc3B,KAAK4B,MAAMP,EAAGC,aAAaT,EAAKE,QAAQP,EAAM,gBAAiB,UAC/E,IAACmB,EAAYE,KACT,MAAA,IAAIJ,MAAM,4DAElBf,EAASiB,EAAYE,IACvB,CACA,MAAMC,sBAAEA,SAAgCC,EAAsBd,EAAI,CAAC,CACjEP,OAAQA,GAAU,GAClBsB,oBAAoB,IAClB,CACFC,OAAQzB,EACR0B,aAAcjB,EACdkB,SAAUZ,EAAca,WAEpBC,EAAc,IAAIC,IAAoBzB,EAAKE,QAAQE,EAAI,wBAAyBqB,GACjFjB,EAAGK,WAAWW,MAAmBhB,EAAAkB,UAAUF,KAEhD,MAAMG,EAAmBC,QAAQ1B,QAAQ,UACtC2B,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAYC,GAAOC,SAASjD,SAAEA,OAAiBkD,OAAOC,QAAQjB,GAAwB,CAC9E,MAAAkB,EAAcC,EAAiBrD,EAAUgD,GAEzCM,EAAqBtD,EAASiC,MAAMa,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtES,EAAad,EACjB,GAAGa,GAAsB,aAAaP,wBAExCtB,EAAG+B,cAAcD,EAAYxD,EAAcqD,IAC3C,IAAIf,EAAS,GACT,GAAyB,SAAzBpC,QAAQC,IAAIC,SAAqB,CAG1BkC,EAAA,iBAFYQ,QAAQ1B,QAAQ,0BAClB0B,QAAQ1B,QAAQ,6BAErC,CAEAsC,EAAaC,SAAS,GAAGrB,IAASO,QAAuBW,IAAc,CACrEnC,IAAK4B,EAAKW,MAAO,WAErB,CAEWC,GAAA"}
@@ -0,0 +1,60 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { bump } from '@jiek/utils/bumper';
4
+ import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
5
+ import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages';
6
+ import * as childProcess from 'child_process';
7
+ import { program } from 'commander';
8
+ import { actionRestore, actionDone } from '../inner.esm.js';
9
+ import { mergePackageJson } from '../merge-package-json.esm.js';
10
+
11
+ program.command("publish").aliases(["pub", "p"]).option("--filter <filter>", "filter packages").option("--root <root>", "root path").option("--bumper <bumper>", "bump version", "patch").action(async ({ root: rootOption, filter, bumper, ...options }) => {
12
+ actionRestore();
13
+ const root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : process.cwd();
14
+ const wd = getWorkspaceDir(root);
15
+ const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
16
+ filter: filter ?? "",
17
+ followProdDepsOnly: true
18
+ }], {
19
+ prefix: root,
20
+ workspaceDir: wd,
21
+ patterns: ["packages/*"]
22
+ });
23
+ const mainfests = [];
24
+ Object.entries(selectedProjectsGraph).forEach(([, { package: { dir, manifest } }]) => {
25
+ mainfests.push([
26
+ dir,
27
+ mergePackageJson(manifest, dir)
28
+ ]);
29
+ });
30
+ const passArgs = Object.entries(options).reduce((acc, [key, value]) => {
31
+ if (value) {
32
+ acc.push(`--${key}`, value);
33
+ }
34
+ return acc;
35
+ }, []);
36
+ for (const [dir, m] of mainfests) {
37
+ const newVersion = bump(m.version, bumper);
38
+ const newManifest = {
39
+ ...m,
40
+ version: newVersion
41
+ };
42
+ fs.renameSync(path.join(dir, "package.json"), path.join(dir, "package.json.bak"));
43
+ fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify(newManifest, null, 2));
44
+ console.log(newManifest);
45
+ try {
46
+ childProcess.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
47
+ cwd: dir,
48
+ stdio: "inherit"
49
+ });
50
+ const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, "package.json.bak"), "utf-8"));
51
+ oldPackageJson.version = newVersion;
52
+ fs.writeFileSync(path.join(dir, "package.json.bak"), JSON.stringify(oldPackageJson, null, 2));
53
+ } finally {
54
+ fs.unlinkSync(path.join(dir, "package.json"));
55
+ fs.renameSync(path.join(dir, "package.json.bak"), path.join(dir, "package.json"));
56
+ }
57
+ }
58
+ actionDone();
59
+ });
60
+ //# sourceMappingURL=publish.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.esm.js","sources":["../../src/commands/publish.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.ren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G,GAAK,EAAA,GAAA;AAAA,QACL,KAAO,EAAA,SAAA;AAAA,OACR,CAAA,CAAA;AACD,MAAM,MAAA,cAAA,GAAiB,IAAK,CAAA,KAAA,CAAM,EAAG,CAAA,YAAA,CAAa,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,kBAAkB,CAAG,EAAA,OAAO,CAAC,CAAA,CAAA;AAC9F,MAAA,cAAA,CAAe,OAAU,GAAA,UAAA,CAAA;AACzB,MAAG,EAAA,CAAA,aAAA,CAAc,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,kBAAkB,CAAG,EAAA,IAAA,CAAK,SAAU,CAAA,cAAA,EAAgB,IAAM,EAAA,CAAC,CAAC,CAAA,CAAA;AAAA,KAC5F,SAAA;AACA,MAAA,EAAA,CAAG,UAAW,CAAA,IAAA,CAAK,IAAK,CAAA,GAAA,EAAK,cAAc,CAAC,CAAA,CAAA;AAC5C,MAAG,EAAA,CAAA,UAAA,CAAW,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,kBAAkB,GAAG,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,cAAc,CAAC,CAAA,CAAA;AAAA,KAClF;AAAA,GACF;AACA,EAAW,UAAA,EAAA,CAAA;AACb,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import o from"node:fs";import e from"node:path";import{bump as r}from"@jiek/utils/bumper";import{getWorkspaceDir as i}from"@jiek/utils/getWorkspaceDir";import{filterPackagesFromDir as n}from"@pnpm/filter-workspace-packages";import*as s from"child_process";import{program as a}from"commander";import{actionRestore as p,actionDone as t}from"../inner.esm.min.js";import{mergePackageJson as c}from"../merge-package-json.esm.min.js";a.command("publish").aliases(["pub","p"]).option("--filter <filter>","filter packages").option("--root <root>","root path").option("--bumper <bumper>","bump version","patch").action((async({root:a,filter:m,bumper:l,...f})=>{p();const j=a?e.isAbsolute(a)?a:e.resolve(process.cwd(),a):process.cwd(),k=i(j),{selectedProjectsGraph:g}=await n(k,[{filter:m??"",followProdDepsOnly:!0}],{prefix:j,workspaceDir:k,patterns:["packages/*"]}),u=[];Object.entries(g).forEach((([,{package:{dir:o,manifest:e}}])=>{u.push([o,c(e,o)])}));const b=Object.entries(f).reduce(((o,[e,r])=>(r&&o.push(`--${e}`,r),o)),[]);for(const[i,n]of u){const a=r(n.version,l),p={...n,version:a};o.renameSync(e.join(i,"package.json"),e.join(i,"package.json.bak")),o.writeFileSync(e.join(i,"package.json"),JSON.stringify(p,null,2)),console.log(p);try{s.execSync(["pnpm","publish","--access","public","--no-git-checks",...b].join(" "),{cwd:i,stdio:"inherit"});const r=JSON.parse(o.readFileSync(e.join(i,"package.json.bak"),"utf-8"));r.version=a,o.writeFileSync(e.join(i,"package.json.bak"),JSON.stringify(r,null,2))}finally{o.unlinkSync(e.join(i,"package.json")),o.renameSync(e.join(i,"package.json.bak"),e.join(i,"package.json"))}}t()}));
2
+ //# sourceMappingURL=publish.esm.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.esm.min.js","sources":["../../src/commands/publish.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n"],"names":["program","command","aliases","option","action","async","root","rootOption","filter","bumper","options","actionRestore","path","isAbsolute","resolve","process","cwd","wd","getWorkspaceDir","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","mainfests","Object","entries","forEach","package","dir","manifest","push","mergePackageJson","passArgs","reduce","acc","key","value","m","newVersion","bump","version","newManifest","fs","renameSync","join","writeFileSync","JSON","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","parse","readFileSync","unlinkSync","actionDone"],"mappings":"4aAaAA,EACGC,QAAQ,WACRC,QAAQ,CAAC,MAAO,MAChBC,O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AAM,GAAE,CAC5F,QACAX,EAAGc,WAAW9C,EAAKkC,KAAKhB,EAAK,iBAC1Bc,EAAAC,WAAWjC,EAAKkC,KAAKhB,EAAK,oBAAqBlB,EAAKkC,KAAKhB,EAAK,gBACnE,CACF,CACW6B,GAAA"}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,6 @@
1
+ import './commands/publish.esm.js';
2
+ import './commands/build.esm.js';
3
+ import { program } from 'commander';
4
+
5
+ program.parse(process.argv);
6
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":[],"mappings":";;;;AAKA,OAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA"}
@@ -0,0 +1,2 @@
1
+ import"./commands/publish.esm.min.js";import"./commands/build.esm.min.js";import{program as m}from"commander";m.parse(process.argv);
2
+ //# sourceMappingURL=index.esm.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.min.js","sources":["../src/index.ts"],"sourcesContent":["import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["program","parse","process","argv"],"mappings":"8GAKAA,EAAQC,MAAMC,QAAQC"}
@@ -0,0 +1,155 @@
1
+ (function (fs, path, bumper, getWorkspaceDir, filterWorkspacePackages, childProcess, commander, pkger, childProcess$1, jsYaml) {
2
+ 'use strict';
3
+
4
+ function _interopNamespaceDefault(e) {
5
+ var n = Object.create(null);
6
+ if (e) {
7
+ Object.keys(e).forEach(function (k) {
8
+ if (k !== 'default') {
9
+ var d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: function () { return e[k]; }
13
+ });
14
+ }
15
+ });
16
+ }
17
+ n.default = e;
18
+ return Object.freeze(n);
19
+ }
20
+
21
+ var childProcess__namespace = /*#__PURE__*/_interopNamespaceDefault(childProcess);
22
+ var childProcess__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(childProcess$1);
23
+
24
+ let resolve;
25
+ function actionDone() {
26
+ resolve();
27
+ }
28
+ function actionRestore() {
29
+ new Promise((r) => resolve = r);
30
+ }
31
+
32
+ function mergePackageJson(manifest, cwd) {
33
+ const {
34
+ jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {},
35
+ exports
36
+ } = manifest;
37
+ const inputs = jiekInputs ?? (Array.isArray(exports) ? exports : void 0);
38
+ return {
39
+ ...manifest,
40
+ ...pkger.pkger({ inputs, cwd, ...jiek })
41
+ };
42
+ }
43
+
44
+ commander.program.command("publish").aliases(["pub", "p"]).option("--filter <filter>", "filter packages").option("--root <root>", "root path").option("--bumper <bumper>", "bump version", "patch").action(async ({ root: rootOption, filter, bumper: bumper$1, ...options }) => {
45
+ actionRestore();
46
+ const root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : process.cwd();
47
+ const wd = getWorkspaceDir.getWorkspaceDir(root);
48
+ const { selectedProjectsGraph } = await filterWorkspacePackages.filterPackagesFromDir(wd, [{
49
+ filter: filter ?? "",
50
+ followProdDepsOnly: true
51
+ }], {
52
+ prefix: root,
53
+ workspaceDir: wd,
54
+ patterns: ["packages/*"]
55
+ });
56
+ const mainfests = [];
57
+ Object.entries(selectedProjectsGraph).forEach(([, { package: { dir, manifest } }]) => {
58
+ mainfests.push([
59
+ dir,
60
+ mergePackageJson(manifest, dir)
61
+ ]);
62
+ });
63
+ const passArgs = Object.entries(options).reduce((acc, [key, value]) => {
64
+ if (value) {
65
+ acc.push(`--${key}`, value);
66
+ }
67
+ return acc;
68
+ }, []);
69
+ for (const [dir, m] of mainfests) {
70
+ const newVersion = bumper.bump(m.version, bumper$1);
71
+ const newManifest = {
72
+ ...m,
73
+ version: newVersion
74
+ };
75
+ fs.renameSync(path.join(dir, "package.json"), path.join(dir, "package.json.bak"));
76
+ fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify(newManifest, null, 2));
77
+ console.log(newManifest);
78
+ try {
79
+ childProcess__namespace.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
80
+ cwd: dir,
81
+ stdio: "inherit"
82
+ });
83
+ const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, "package.json.bak"), "utf-8"));
84
+ oldPackageJson.version = newVersion;
85
+ fs.writeFileSync(path.join(dir, "package.json.bak"), JSON.stringify(oldPackageJson, null, 2));
86
+ } finally {
87
+ fs.unlinkSync(path.join(dir, "package.json"));
88
+ fs.renameSync(path.join(dir, "package.json.bak"), path.join(dir, "package.json"));
89
+ }
90
+ }
91
+ actionDone();
92
+ });
93
+
94
+ const FILE_TEMPLATE = (manifest) => `
95
+ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/index.ts" : "jiek/rollup"}').template({ }, ${JSON.stringify(manifest, null, 2)})
96
+ `.trimStart();
97
+ commander.program.command("build").option("--filter <filter>", "filter packages").option("--root <root>", "root path").action(async ({ root: rootOption, filter, ...options }) => {
98
+ actionRestore();
99
+ const root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : process.cwd();
100
+ const wd = getWorkspaceDir.getWorkspaceDir(root);
101
+ const pnpmWorkspaceFilePath = path.resolve(wd, "pnpm-workspace.yaml");
102
+ const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, "utf-8");
103
+ const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
104
+ if (root === wd && !filter) {
105
+ throw new Error("root path is workspace root, please provide a filter");
106
+ }
107
+ if (root !== wd && !filter) {
108
+ const packageJSONIsExist = fs.existsSync(path.resolve(root, "package.json"));
109
+ if (!packageJSONIsExist) {
110
+ throw new Error("root path is not workspace root, please provide a filter");
111
+ }
112
+ const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, "package.json"), "utf-8"));
113
+ if (!packageJSON.name) {
114
+ throw new Error("root path is not workspace root, please provide a filter");
115
+ }
116
+ filter = packageJSON.name;
117
+ }
118
+ const { selectedProjectsGraph } = await filterWorkspacePackages.filterPackagesFromDir(wd, [{
119
+ filter: filter ?? "",
120
+ followProdDepsOnly: true
121
+ }], {
122
+ prefix: root,
123
+ workspaceDir: wd,
124
+ patterns: pnpmWorkspace.packages
125
+ });
126
+ const jiekTempDir = (...paths) => path.resolve(wd, "node_modules/.jiek", ...paths);
127
+ if (!fs.existsSync(jiekTempDir()))
128
+ fs.mkdirSync(jiekTempDir());
129
+ const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
130
+ let i = 0;
131
+ for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {
132
+ const newManifest = mergePackageJson(manifest, dir);
133
+ const escapeManifestName = manifest.name?.replace(/^@/g, "").replace(/\//g, "+");
134
+ const configFile = jiekTempDir(
135
+ `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
136
+ );
137
+ fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest));
138
+ let prefix = "";
139
+ if (process.env.NODE_ENV === "test") {
140
+ const registerPath = require.resolve("esbuild-register");
141
+ const loaderPath = require.resolve("esbuild-register/loader");
142
+ prefix = `node --import ${registerPath} -r ${loaderPath} `;
143
+ }
144
+ childProcess__namespace$1.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {
145
+ cwd: dir,
146
+ stdio: "inherit"
147
+ });
148
+ }
149
+ actionDone();
150
+ });
151
+
152
+ commander.program.parse(process.argv);
153
+
154
+ })(fs, path, bumper, getWorkspaceDir, filterWorkspacePackages, childProcess, commander, pkger, childProcess$1, jsYaml);
155
+ //# sourceMappingURL=index.iife.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.iife.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template({ }, ${JSON.stringify(manifest, null, 2)})\n`.trimStart()\n\nprogram\n .command('build')\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["pkger","program","bumper","getWorkspaceDir","filterPackagesFromDir","bump","childProcess","load"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAAA,IAAI,OAAA,CAAA;EAIG,SAAS,UAAa,GAAA;EAC3B,EAAQ,OAAA,EAAA,CAAA;EACV,CAAA;EAEO,SAAS,aAAgB,GAAA;EAC9B,EAAe,IAAI,OAAA,CAAc,CAAK,CAAA,KAAA,OAAA,GAAU,CAAC,CAAA,CAAA;EACnD;;ECNgB,SAAA,gBAAA,CAAiB,UAG9B,GAAa,EAAA;EACd,EAAM,MAAA;EAAA,IACJ,IAAA,EAAM,EAAE,MAAQ,EAAA,UAAA,EAAY,KAAK,CAAG,EAAA,GAAG,IAAK,EAAA,GAAI,EAAC;EAAA,IAAG,OAAA;EAAA,GAClD,GAAA,QAAA,CAAA;EACJ,EAAA,MAAM,SAAS,UACb,KAAA,KAAA,CAAM,OAAQ,CAAA,OAAO,IAAI,OAAU,GAAA,KAAA,CAAA,CAAA,CAAA;EAErC,EAAO,OAAA;EAAA,IACL,GAAG,QAAA;EAAA,IACH,GAAGA,WAAM,CAAA,EAAE,QAAQ,GAAK,EAAA,GAAG,MAAM,CAAA;EAAA,GACnC,CAAA;EACF;;ACLAC,mBAAA,CACG,OAAQ,CAAA,SAAS,CACjB,CAAA,OAAA,CAAQ,CAAC,KAAA,EAAO,GAAG,CAAC,CACpB,CAAA,MAAA,CAAO,mBAAqB,EAAA,iBAAiB,EAC7C,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CACnC,MAAO,CAAA,mBAAA,EAAqB,cAAgB,EAAA,OAAO,EACnD,MAAO,CAAA,OAAO,EAAE,IAAA,EAAM,UAAY,EAAA,MAAA,UAAQC,QAAQ,EAAA,GA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,CAAA;EAAA,KACzD;EAEA,IAAAE,yBAAA,CAAa,SAAS,CAAG,EAAA,MAAM,GAAG,gBAAgB,CAAA,IAAA,EAAO,UAAU,CAAI,CAAA,EAAA;EAAA,MACrE,GAAK,EAAA,GAAA;EAAA,MAAK,KAAO,EAAA,SAAA;EAAA,KAClB,CAAA,CAAA;EAAA,GACH;EAEA,EAAW,UAAA,EAAA,CAAA;EACb,CAAC,CAAA;;ACrFHL,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
@@ -0,0 +1,2 @@
1
+ !function(e,r,o,t,s,i,n,a,c,p){"use strict";function l(e){var r=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var t=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,t.get?t:{enumerable:!0,get:function(){return e[o]}})}})),r.default=e,Object.freeze(r)}var u=l(i),f=l(c);let d;function k(){d()}function g(){new Promise((e=>d=e))}function m(e,r){const{jiek:{inputs:o,cwd:t,...s}={},exports:i}=e,n=o??(Array.isArray(i)?i:void 0);return{...e,...a.pkger({inputs:n,cwd:r,...s})}}n.program.command("publish").aliases(["pub","p"]).option("--filter <filter>","filter packages").option("--root <root>","root path").option("--bumper <bumper>","bump version","patch").action((async({root:i,filter:n,bumper:a,...c})=>{g();const p=i?r.isAbsolute(i)?i:r.resolve(process.cwd(),i):process.cwd(),l=t.getWorkspaceDir(p),{selectedProjectsGraph:f}=await s.filterPackagesFromDir(l,[{filter:n??"",followProdDepsOnly:!0}],{prefix:p,workspaceDir:l,patterns:["packages/*"]}),d=[];Object.entries(f).forEach((([,{package:{dir:e,manifest:r}}])=>{d.push([e,m(r,e)])}));const j=Object.entries(c).reduce(((e,[r,o])=>(o&&e.push(`--${r}`,o),e)),[]);for(const[t,s]of d){const i=o.bump(s.version,a),n={...s,version:i};e.renameSync(r.join(t,"package.json"),r.join(t,"package.json.bak")),e.writeFileSync(r.join(t,"package.json"),JSON.stringify(n,null,2)),console.log(n);try{u.execSync(["pnpm","publish","--access","public","--no-git-checks",...j].join(" "),{cwd:t,stdio:"inherit"});const o=JSON.parse(e.readFileSync(r.join(t,"package.json.bak"),"utf-8"));o.version=i,e.writeFileSync(r.join(t,"package.json.bak"),JSON.stringify(o,null,2))}finally{e.unlinkSync(r.join(t,"package.json")),e.renameSync(r.join(t,"package.json.bak"),r.join(t,"package.json"))}}k()}));const j=e=>`\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template({ }, ${JSON.stringify(e,null,2)})\n`.trimStart();n.program.command("build").option("--filter <filter>","filter packages").option("--root <root>","root path").action((async({root:o,filter:i,...n})=>{g();const a=o?r.isAbsolute(o)?o:r.resolve(process.cwd(),o):process.cwd(),c=t.getWorkspaceDir(a),l=r.resolve(c,"pnpm-workspace.yaml"),u=e.readFileSync(l,"utf-8"),d=p.load(u);if(a===c&&!i)throw new Error("root path is workspace root, please provide a filter");if(a!==c&&!i){if(!e.existsSync(r.resolve(a,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const o=JSON.parse(e.readFileSync(r.resolve(a,"package.json"),"utf-8"));if(!o.name)throw new Error("root path is not workspace root, please provide a filter");i=o.name}const{selectedProjectsGraph:y}=await s.filterPackagesFromDir(c,[{filter:i??"",followProdDepsOnly:!0}],{prefix:a,workspaceDir:c,patterns:d.packages}),b=(...e)=>r.resolve(c,"node_modules/.jiek",...e);e.existsSync(b())||e.mkdirSync(b());const w=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let h=0;for(const[r,{package:{manifest:o}}]of Object.entries(y)){const t=m(o,r),s=o.name?.replace(/^@/g,"").replace(/\//g,"+"),i=b(`${s??"anonymous-"+h++}.rollup.config.js`);e.writeFileSync(i,j(t));let n="";if("test"===process.env.NODE_ENV){n=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}f.execSync(`${n}${w} -c ${i}`,{cwd:r,stdio:"inherit"})}k()})),n.program.parse(process.argv)}(fs,path,bumper,getWorkspaceDir,filterWorkspacePackages,childProcess,commander,pkger,childProcess$1,jsYaml);
2
+ //# sourceMappingURL=index.iife.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.iife.min.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template({ }, ${JSON.stringify(manifest, null, 2)})\n`.trimStart()\n\nprogram\n .command('build')\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["resolve","actionDone","actionRestore","Promise","r","mergePackageJson","manifest","cwd","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","commander","program","command","aliases","option","action","async","root","rootOption","filter","bumper","options","path","isAbsolute","process","wd","getWorkspaceDir","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","mainfests","Object","entries","forEach","package","dir","push","passArgs","reduce","acc","key","value","m","newVersion","bump","version","newManifest","fs","renameSync","join","writeFileSync","JSON","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","parse","readFileSync","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","pnpmWorkspaceFilePath","pnpmWorkspaceFileContent","pnpmWorkspace","load","Error","existsSync","packageJSON","name","packages","jiekTempDir","paths","mkdirSync","rollupBinaryPath","require","replace","i","escapeManifestName","configFile","argv"],"mappings":"iUAAA,IAAIA,EAIG,SAASC,IACND,GACV,CAEO,SAASE,IACC,IAAIC,SAAmBC,GAAAJ,EAAUI,GAClD,CCNgB,SAAAC,EAAiBC,EAG9BC,GACK,MACJC,MAAQC,OAAQC,EAAYH,IAAKI,KAAMH,GAAS,CAAC,EAAAI,QAAGA,GAClDN,EACEG,EAASC,IACbG,MAAMC,QAAQF,GAAWA,OAAU,GAE9B,MAAA,IACFN,KACAS,EAAMA,MAAA,CAAEN,SAAQF,SAAQC,IAE/B,CCLAQ,EAAAC,QACGC,QAAQ,W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