jiek 0.1.12-alpha.3 → 0.1.12-alpha.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,47 +3,69 @@ import path from 'node:path';
3
3
  import { bump } from '@jiek/utils/bumper';
4
4
  import * as childProcess from 'child_process';
5
5
  import { program } from 'commander';
6
+ import detectIndent from 'detect-indent';
7
+ import { applyEdits, modify } from 'jsonc-parser';
6
8
  import { actionRestore, actionDone } from '../inner.esm.js';
7
9
  import { mergePackageJson } from '../merge-package-json.esm.js';
8
10
  import { getSelectedProjectsGraph } from '../utils/filterSupport.esm.js';
9
11
 
10
- program.command("publish").aliases(["pub", "p"]).option("--bumper <bumper>", "bump version", "patch").action(async ({ bumper, ...options }) => {
12
+ program.command("publish").aliases(["pub", "p"]).option("-b, --bumper <bumper>", "bump version", "patch").option("-p, --preview", "preview publish").action(async ({ preview, bumper, ...options }) => {
11
13
  actionRestore();
12
14
  const { value = {} } = await getSelectedProjectsGraph() ?? {};
13
15
  const selectedProjectsGraphEntries = Object.entries(value);
14
16
  if (selectedProjectsGraphEntries.length === 0) {
15
17
  throw new Error("no packages selected");
16
18
  }
17
- const mainfests = [];
18
- selectedProjectsGraphEntries.forEach(([dir, manifest]) => {
19
- mainfests.push([
20
- dir,
21
- mergePackageJson(manifest, dir)
22
- ]);
23
- });
19
+ const mainfests = selectedProjectsGraphEntries.map(([dir, manifest]) => [
20
+ dir,
21
+ mergePackageJson(manifest, dir)
22
+ ]);
24
23
  const passArgs = Object.entries(options).reduce((acc, [key, value2]) => {
25
24
  if (value2) {
26
25
  acc.push(`--${key}`, value2);
27
26
  }
28
27
  return acc;
29
28
  }, []);
30
- for (const [dir, m] of mainfests) {
31
- const newVersion = bump(m.version, bumper);
32
- const newManifest = {
33
- ...m,
34
- version: newVersion
29
+ for (const [dir, manifest] of mainfests) {
30
+ const oldJSONString = fs.readFileSync(path.join(dir, "package.json"), "utf-8");
31
+ const oldJSON = JSON.parse(oldJSONString) ?? "0.0.0";
32
+ const newVersion = bump(oldJSON.version, bumper);
33
+ const { indent = " " } = detectIndent(oldJSONString);
34
+ const formattingOptions = {
35
+ tabSize: indent.length,
36
+ insertSpaces: true
35
37
  };
36
- fs.renameSync(path.join(dir, "package.json"), path.join(dir, "package.json.bak"));
37
- fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify(newManifest, null, 2));
38
- console.log(newManifest);
38
+ let newJSONString = oldJSONString;
39
+ newJSONString = applyEdits(newJSONString, modify(
40
+ newJSONString,
41
+ ["version"],
42
+ newVersion,
43
+ { formattingOptions }
44
+ ));
45
+ for (const [key, value2] of Object.entries(manifest)) {
46
+ if (JSON.stringify(value2) === JSON.stringify(oldJSON[key]))
47
+ continue;
48
+ newJSONString = applyEdits(newJSONString, modify(
49
+ newJSONString,
50
+ ["publishConfig", key],
51
+ value2,
52
+ { formattingOptions }
53
+ ));
54
+ }
39
55
  try {
56
+ fs.renameSync(path.join(dir, "package.json"), path.join(dir, "package.json.bak"));
57
+ fs.writeFileSync(path.join(dir, "package.json"), newJSONString);
58
+ console.log(newJSONString);
59
+ if (preview) {
60
+ console.warn("preview mode");
61
+ continue;
62
+ }
40
63
  childProcess.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
41
64
  cwd: dir,
42
65
  stdio: "inherit"
43
66
  });
44
- const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, "package.json.bak"), "utf-8"));
45
- oldPackageJson.version = newVersion;
46
- fs.writeFileSync(path.join(dir, "package.json.bak"), JSON.stringify(oldPackageJson, null, 2));
67
+ const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ["version"], newVersion, {}));
68
+ fs.writeFileSync(path.join(dir, "package.json.bak"), modifyVersionPackageJSON);
47
69
  } finally {
48
70
  fs.unlinkSync(path.join(dir, "package.json"));
49
71
  fs.renameSync(path.join(dir, "package.json.bak"), path.join(dir, "package.json"));
@@ -1 +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 type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([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":["value"],"mappings":";;;;;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AA,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"}
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 * as childProcess from 'child_process'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\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, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\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":["value"],"mappings":";;;;;;;;;;;AAaA,OACG,CAAA,OAAA,CAAQ,SAAS,CAAA,CACjB,OAAQ,CAAA,CAAC,OAAO,GAAG,CAAC,CACpB,CAAA,MAAA,CAAO,uBAAyB,EAAA,cAAA,EAAgB,OAAO,CACvD,CAAA,MAAA,CAAO,eAAiB,EAAA,iBAAiB,CACzC,CAAA,MAAA,CAAO,OAAO,EAAE,OAAS,EAAA,MAAA,EAAQ,GAAG,OAAA,EAG/B,KAAA;AACJ,EAAc,aAAA,EAAA,CAAA;AAEd,EAAM,MAAA,EAAE,QAAQ,EAAC,KAAM,MAAM,wBAAA,MAA8B,EAAC,CAAA;AAC5D,EAAM,MAAA,4BAAA,GAA+B,MAAO,CAAA,OAAA,CAAQ,KAAK,CAAA,CAAA;AACzD,EAAI,IAAA,4BAAA,CAA6B,WAAW,CAAG,EAAA;AAC7C,IAAM,MAAA,IAAI,MAAM,s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aAAA,EAAe,CAAC,SAAS,CAAG,EAAA,UAAA,EAAY,EAAE,CAAC,CAAA,CAAA;AAC7G,MAAA,EAAA,CAAG,cAAc,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,kBAAkB,GAAG,wBAAwB,CAAA,CAAA;AAAA,KAC7E,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"}
@@ -1,2 +1,2 @@
1
- import n from"node:fs";import o from"node:path";import{bump as e}from"@jiek/utils/bumper";import*as i from"child_process";import{program as s}from"commander";import{actionRestore as r,actionDone as a}from"../inner.esm.min.js";import{mergePackageJson as c}from"../merge-package-json.esm.min.js";import{getSelectedProjectsGraph as p}from"../utils/filterSupport.esm.min.js";s.command("publish").aliases(["pub","p"]).option("--bumper <bumper>","bump version","patch").action((async({bumper:s,...t})=>{r();const{value:m={}}=await p()??{},j=Object.entries(m);if(0===j.length)throw new Error("no packages selected");const l=[];j.forEach((([n,o])=>{l.push([n,c(o,n)])}));const u=Object.entries(t).reduce(((n,[o,e])=>(e&&n.push(`--${o}`,e),n)),[]);for(const[r,a]of l){const c=e(a.version,s),p={...a,version:c};n.renameSync(o.join(r,"package.json"),o.join(r,"package.json.bak")),n.writeFileSync(o.join(r,"package.json"),JSON.stringify(p,null,2)),console.log(p);try{i.execSync(["pnpm","publish","--access","public","--no-git-checks",...u].join(" "),{cwd:r,stdio:"inherit"});const e=JSON.parse(n.readFileSync(o.join(r,"package.json.bak"),"utf-8"));e.version=c,n.writeFileSync(o.join(r,"package.json.bak"),JSON.stringify(e,null,2))}finally{n.unlinkSync(o.join(r,"package.json")),n.renameSync(o.join(r,"package.json.bak"),o.join(r,"package.json"))}}a()}));
1
+ import e from"node:fs";import n from"node:path";import{bump as o}from"@jiek/utils/bumper";import*as i from"child_process";import{program as r}from"commander";import s from"detect-indent";import{applyEdits as t,modify as p}from"jsonc-parser";import{actionRestore as a,actionDone as c}from"../inner.esm.min.js";import{mergePackageJson as m}from"../merge-package-json.esm.min.js";import{getSelectedProjectsGraph as j}from"../utils/filterSupport.esm.min.js";r.command("publish").aliases(["pub","p"]).option("-b, --bumper <bumper>","bump version","patch").option("-p, --preview","preview publish").action((async({preview:r,bumper:f,...l})=>{a();const{value:g={}}=await j()??{},u=Object.entries(g);if(0===u.length)throw new Error("no packages selected");const b=u.map((([e,n])=>[e,m(n,e)])),k=Object.entries(l).reduce(((e,[n,o])=>(o&&e.push(`--${n}`,o),e)),[]);for(const[a,c]of b){const m=e.readFileSync(n.join(a,"package.json"),"utf-8"),j=JSON.parse(m)??"0.0.0",l=o(j.version,f),{indent:g=" "}=s(m),u={tabSize:g.length,insertSpaces:!0};let b=m;b=t(b,p(b,["version"],l,{formattingOptions:u}));for(const[e,n]of Object.entries(c))JSON.stringify(n)!==JSON.stringify(j[e])&&(b=t(b,p(b,["publishConfig",e],n,{formattingOptions:u})));try{if(e.renameSync(n.join(a,"package.json"),n.join(a,"package.json.bak")),e.writeFileSync(n.join(a,"package.json"),b),console.log(b),r){console.warn("preview mode");continue}i.execSync(["pnpm","publish","--access","public","--no-git-checks",...k].join(" "),{cwd:a,stdio:"inherit"});const o=t(m,p(m,["version"],l,{}));e.writeFileSync(n.join(a,"package.json.bak"),o)}finally{e.unlinkSync(n.join(a,"package.json")),e.renameSync(n.join(a,"package.json.bak"),n.join(a,"package.json"))}}c()}));
2
2
  //# sourceMappingURL=publish.esm.min.js.map
@@ -1 +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 type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([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","bumper","options","actionRestore","value","getSelectedProjectsGraph","selectedProjectsGraphEntries","Object","entries","length","Error","mainfests","forEach","dir","manifest","push","mergePackageJson","passArgs","reduce","acc","key","m","newVersion","bump","version","newManifest","fs","renameSync","path","join","writeFileSync","JSON","stringify","console","log","childProcess","execSync","cwd","stdio","oldPackageJson","parse","readFileSync","unlinkSync","actionDone"],"mappings":"mXAYAA,EACGC,QAAQ,WACRC,QAAQ,CAAC,MAAO,MAChBC,OAAO,oBAAqB,eAAgB,SAC5CC,QAAOC,OAASC,YAAWC,MAKZC,IAER,MAAAC,MAAEA,EAAQ,CAAC,SAAYC,KAA8B,CAAA,EACrDC,EAA+BC,OAAOC,QAAQJ,GAChD,GAAwC,IAAxCE,EAA6BG,OACzB,MAAA,IAAIC,MAAM,wBAElB,MAAMC,EAA0C,GAChDL,EACGM,SAAQ,EAAEC,EAAKC,MACdH,EAAUI,KAAK,CACbF,EAAKG,EAAiBF,EAAUD,IACjC,IAEC,MAAAI,EAAWV,OACdC,QAAQN,GACRgB,QAAO,CAACC,GAAMC,EAAKhB,MACdA,GACFe,EAAIJ,KAAK,KAAKK,IAAOhB,GAEhBe,IACN,IACL,IAAA,MAAYN,EAAKQ,KAAMV,EAAW,CAChC,MAAMW,EAAaC,EAAKF,EAAEG,QAASvB,GAC7BwB,EAAc,IACfJ,EACHG,QAASF,GAERI,EAAAC,WAAWC,EAAKC,KAAKhB,EAAK,gBAAiBe,EAAKC,KAAKhB,EAAK,qBAC1Da,EAAAI,cAAcF,EAAKC,KAAKhB,EAAK,gBAAiBkB,KAAKC,UAAUP,EAAa,KAAM,IACnFQ,QAAQC,IAAIT,GACR,IACFU,EAAaC,SAAS,CAAC,OAAQ,UAAW,WAAY,SAAU,qBAAsBnB,GAAUY,KAAK,KAAM,CACzGQ,IAAKxB,EACLyB,MAAO,YAEH,MAAAC,EAAiBR,KAAKS,MAAMd,EAAGe,aAAab,EAAKC,KAAKhB,EAAK,oBAAqB,UACtF0B,EAAef,QAAUF,EACtBI,EAAAI,cAAcF,EAAKC,KAAKhB,EAAK,oBAAqBkB,KAAKC,UAAUO,EAAgB,KAAM,GAAE,CAC5F,QACAb,EAAGgB,WAAWd,EAAKC,KAAKhB,EAAK,iBAC1Ba,EAAAC,WAAWC,EAAKC,KAAKhB,EAAK,oBAAqBe,EAAKC,KAAKhB,EAAK,gBACnE,CACF,CACW8B,GAAA"}
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 * as childProcess from 'child_process'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\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, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\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","preview","bumper","options","actionRestore","value","getSelectedProjectsGraph","selectedProjectsGraphEntries","Object","entries","length","Error","mainfests","map","dir","manifest","mergePackageJson","passArgs","reduce","acc","key","push","oldJSONString","fs","readFileSync","path","join","oldJSON","JSON","parse","newVersion","bump","version","indent","detectIndent","formattingOptions","tabSize","insertSpaces","newJSONString","applyEdits","modify","stringify","renameSync","writeFileSync","console","log","warn","childProcess","execSync","cwd","stdio","modifyVersionPackageJSON","unlinkSync","actionDone"],"mappings":"scAaAA,EACGC,QAAQ,WACRC,QAAQ,CAAC,MAAO,MAChBC,OAAO,wBAAyB,eAAgB,SAChDA,OAAO,gBAAiB,mBACxBC,QAAOC,OAASC,UAASC,YAAWC,MAIrBC,IAER,MAAAC,MAAEA,EAAQ,CAAC,SAAYC,KAA8B,CAAA,EACrDC,EAA+BC,OAAOC,QAAQJ,GAChD,GAAwC,IAAxCE,E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K,oBAAqBqC,EAAwB,CAC7E,QACA5B,EAAG6B,WAAW3B,EAAKC,KAAKZ,EAAK,iBAC1BS,EAAAmB,WAAWjB,EAAKC,KAAKZ,EAAK,oBAAqBW,EAAKC,KAAKZ,EAAK,gBACnE,CACF,CACWuC,GAAA"}
@@ -1,4 +1,4 @@
1
- (function (fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, pkger, childProcess$1) {
1
+ (function (fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, detectIndent, jsoncParser, pkger, childProcess$1) {
2
2
  'use strict';
3
3
 
4
4
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -24,6 +24,7 @@
24
24
  var fs__default = /*#__PURE__*/_interopDefault(fs);
25
25
  var path__default = /*#__PURE__*/_interopDefault(path);
26
26
  var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
27
+ var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
27
28
  var childProcess__namespace$1 = /*#__PURE__*/_interopNamespace(childProcess$1);
28
29
 
29
30
  let type = "";
@@ -115,43 +116,63 @@
115
116
  };
116
117
  }
117
118
 
118
- commander.program.command("publish").aliases(["pub", "p"]).option("--bumper <bumper>", "bump version", "patch").action(async ({ bumper: bumper$1, ...options }) => {
119
+ commander.program.command("publish").aliases(["pub", "p"]).option("-b, --bumper <bumper>", "bump version", "patch").option("-p, --preview", "preview publish").action(async ({ preview, bumper: bumper$1, ...options }) => {
119
120
  actionRestore();
120
121
  const { value = {} } = await getSelectedProjectsGraph() ?? {};
121
122
  const selectedProjectsGraphEntries = Object.entries(value);
122
123
  if (selectedProjectsGraphEntries.length === 0) {
123
124
  throw new Error("no packages selected");
124
125
  }
125
- const mainfests = [];
126
- selectedProjectsGraphEntries.forEach(([dir, manifest]) => {
127
- mainfests.push([
128
- dir,
129
- mergePackageJson(manifest, dir)
130
- ]);
131
- });
126
+ const mainfests = selectedProjectsGraphEntries.map(([dir, manifest]) => [
127
+ dir,
128
+ mergePackageJson(manifest, dir)
129
+ ]);
132
130
  const passArgs = Object.entries(options).reduce((acc, [key, value2]) => {
133
131
  if (value2) {
134
132
  acc.push(`--${key}`, value2);
135
133
  }
136
134
  return acc;
137
135
  }, []);
138
- for (const [dir, m] of mainfests) {
139
- const newVersion = bumper.bump(m.version, bumper$1);
140
- const newManifest = {
141
- ...m,
142
- version: newVersion
136
+ for (const [dir, manifest] of mainfests) {
137
+ const oldJSONString = fs__default.default.readFileSync(path__default.default.join(dir, "package.json"), "utf-8");
138
+ const oldJSON = JSON.parse(oldJSONString) ?? "0.0.0";
139
+ const newVersion = bumper.bump(oldJSON.version, bumper$1);
140
+ const { indent = " " } = detectIndent__default.default(oldJSONString);
141
+ const formattingOptions = {
142
+ tabSize: indent.length,
143
+ insertSpaces: true
143
144
  };
144
- fs__default.default.renameSync(path__default.default.join(dir, "package.json"), path__default.default.join(dir, "package.json.bak"));
145
- fs__default.default.writeFileSync(path__default.default.join(dir, "package.json"), JSON.stringify(newManifest, null, 2));
146
- console.log(newManifest);
145
+ let newJSONString = oldJSONString;
146
+ newJSONString = jsoncParser.applyEdits(newJSONString, jsoncParser.modify(
147
+ newJSONString,
148
+ ["version"],
149
+ newVersion,
150
+ { formattingOptions }
151
+ ));
152
+ for (const [key, value2] of Object.entries(manifest)) {
153
+ if (JSON.stringify(value2) === JSON.stringify(oldJSON[key]))
154
+ continue;
155
+ newJSONString = jsoncParser.applyEdits(newJSONString, jsoncParser.modify(
156
+ newJSONString,
157
+ ["publishConfig", key],
158
+ value2,
159
+ { formattingOptions }
160
+ ));
161
+ }
147
162
  try {
163
+ fs__default.default.renameSync(path__default.default.join(dir, "package.json"), path__default.default.join(dir, "package.json.bak"));
164
+ fs__default.default.writeFileSync(path__default.default.join(dir, "package.json"), newJSONString);
165
+ console.log(newJSONString);
166
+ if (preview) {
167
+ console.warn("preview mode");
168
+ continue;
169
+ }
148
170
  childProcess__namespace.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
149
171
  cwd: dir,
150
172
  stdio: "inherit"
151
173
  });
152
- const oldPackageJson = JSON.parse(fs__default.default.readFileSync(path__default.default.join(dir, "package.json.bak"), "utf-8"));
153
- oldPackageJson.version = newVersion;
154
- fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), JSON.stringify(oldPackageJson, null, 2));
174
+ const modifyVersionPackageJSON = jsoncParser.applyEdits(oldJSONString, jsoncParser.modify(oldJSONString, ["version"], newVersion, {}));
175
+ fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), modifyVersionPackageJSON);
155
176
  } finally {
156
177
  fs__default.default.unlinkSync(path__default.default.join(dir, "package.json"));
157
178
  fs__default.default.renameSync(path__default.default.join(dir, "package.json.bak"), path__default.default.join(dir, "package.json"));
@@ -209,5 +230,5 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
209
230
  commander.program.version(pkg.version).description(pkg.description).option("--root <root>", "root path");
210
231
  commander.program.parse(process.argv);
211
232
 
212
- })(fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, pkger, childProcess$1);
233
+ })(fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, detectIndent, jsoncParser, pkger, childProcess$1);
213
234
  //# sourceMappingURL=index.iife.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.iife.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import 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\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\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 return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","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 type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([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 { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\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, manifest] of Object.entries(value)) {\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 './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["program","path","getWorkspaceDir","fs","load","filterPackagesFromDir","pkger","bumper","value","bump","childProcess"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQO,IAAI,IAAO,GAAA,EAAA,CAAA;EAElB,IAAI;EACF,EAAA,OAAA,CAAQ,QAAQ,iCAAiC,CAAA,CAAA;EACjD,EAAO,IAAA,GAAA,MAAA,CAAA;EACT,CAAQ,CAAA,MAAA;EAAc,CAAA;EACtB,IAAI,SAAS,EAAI,EAAA;EACf,EACGA,iBAAA,CAAA,MAAA,CAAO,yBAAyB,iBAAiB,CAAA,CAAA;EACtD,CAAA;EAUA,eAAsB,wBAAmD,GAAA;EACvE,EAAI,IAAA,MAAA,GAASA,iBAAQ,CAAA,cAAA,CAAe,QAAQ,CAAA,CAAA;EAC5C,EAAM,MAAA,UAAA,GAAaA,iBAAQ,CAAA,cAAA,CAAe,MAAM,CAAA,CAAA;EAChD,EAAA,MAAM,IAAO,GAAA,UAAA,GACTC,qBAAK,CAAA,UAAA,CAAW,UAAU,CACxB,GAA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c,CAAA,UAAA,EAAY,aAAc,CAAA,WAAW,CAAC,CAAA,CAAA;EACvD,IAAA,IAAI,MAAS,GAAA,EAAA,CAAA;EACb,IAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,MAAQ,EAAA;EACnC,MAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,kBAAkB,CAAA,CAAA;EACvD,MAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,OAAA,CAAQ,yBAAyB,CAAA,CAAA;EAC5D,MAAS,MAAA,GAAA,CAAA,cAAA,EAAiB,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA,CAAA,CAAA,CAAA;EAAA,KACzD;EAEA,IAAAO,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;;ECxDH,MAAM,GAAA,GAAM,QAAQ,iBAAiB,CAAA,CAAA;AAErCV,mBACG,CAAA,OAAA,CAAQ,GAAI,CAAA,OAAO,CACnB,CAAA,WAAA,CAAY,IAAI,WAAW,CAAA,CAC3B,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AAEtCA,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
1
+ {"version":3,"file":"index.iife.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import 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\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\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 return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","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 { 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 }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\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, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\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 { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\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, manifest] of Object.entries(value)) {\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 './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["program","path","getWorkspaceDir","fs","load","filterPackagesFromDir","pkger","bumper","value","bump","detectIndent","applyEdits","modify","childProcess"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQO,IAAI,IAAO,GAAA,EAAA,CAAA;EAElB,IAAI;EACF,EAAA,OAAA,CAAQ,QAAQ,iCAAi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A,CAAA,iBAAA,CAAA;EAAA,KAC7C,CAAA;EACA,IAAAA,mBAAA,CAAG,aAAc,CAAA,UAAA,EAAY,aAAc,CAAA,WAAW,CAAC,CAAA,CAAA;EACvD,IAAA,IAAI,MAAS,GAAA,EAAA,CAAA;EACb,IAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,MAAQ,EAAA;EACnC,MAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,kBAAkB,CAAA,CAAA;EACvD,MAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,OAAA,CAAQ,yBAAyB,CAAA,CAAA;EAC5D,MAAS,MAAA,GAAA,CAAA,cAAA,EAAiB,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA,CAAA,CAAA,CAAA;EAAA,KACzD;EAEA,IAAAU,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;;ECxDH,MAAM,GAAA,GAAM,QAAQ,iBAAiB,CAAA,CAAA;AAErCb,mBACG,CAAA,OAAA,CAAQ,GAAI,CAAA,OAAO,CACnB,CAAA,WAAA,CAAY,IAAI,WAAW,CAAA,CAC3B,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AAEtCA,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
@@ -1,2 +1,2 @@
1
- !function(e,r,t,o,a,n,s,i,c,l){"use strict";function p(e){return e&&e.__esModule?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var f=p(e),d=p(r),g=u(i),k=u(l);let m,j="";try{require.resolve("@pnpm/filter-workspace-packages"),j="pnpm"}catch{}async function w(){let e=a.program.getOptionValue("filter");const r=a.program.getOptionValue("root"),s=r?d.default.isAbsolute(r)?r:d.default.resolve(process.cwd(),r):process.cwd();let i,c=!1;try{i=t.getWorkspaceDir(s,j)}catch(e){if(!("message"in e)||"workspace root not found"!==e.message)throw e;i=s,c=!0}if(!c&&"pnpm"===j){const r=d.default.resolve(i,"pnpm-workspace.yaml"),t=f.default.readFileSync(r,"utf-8"),a=n.load(t);if(s===i&&!e)throw new Error("root path is workspace root, please provide a filter");if(s!==i&&!e){if(!f.default.existsSync(d.default.resolve(s,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const r=JSON.parse(f.default.readFileSync(d.default.resolve(s,"package.json"),"utf-8"));if(!r.name)throw new Error("root path is not workspace root, please provide a filter");e=r.name}const{selectedProjectsGraph:c}=await o.filterPackagesFromDir(i,[{filter:e??"",followProdDepsOnly:!0}],{prefix:s,workspaceDir:i,patterns:a.packages});return{wd:i,root:s,value:Object.entries(c).reduce(((e,[r,t])=>(e[r]=t.package.manifest,e)),{})}}return{wd:i,root:s,value:{[i]:JSON.parse(f.default.readFileSync(d.default.resolve(i,"package.json"),"utf-8"))}}}function y(){m()}function v(){new Promise((e=>m=e))}function b(e,r){const{jiek:{inputs:t,cwd:o,...a}={},exports:n}=e,s=t??(Array.isArray(n)?n:void 0);return{...e,...c.pkger({inputs:s,cwd:r,...a})}}""!==j&&a.program.option("-f, --filter <filter>","filter packages"),a.program.command("publish").aliases(["pub","p"]).option("--bumper <bumper>","bump version","patch").action((async({bumper:e,...r})=>{v();const{value:t={}}=await w()??{},o=Object.entries(t);if(0===o.length)throw new Error("no packages selected");const a=[];o.forEach((([e,r])=>{a.push([e,b(r,e)])}));const n=Object.entries(r).reduce(((e,[r,t])=>(t&&e.push(`--${r}`,t),e)),[]);for(const[r,t]of a){const o=s.bump(t.version,e),a={...t,version:o};f.default.renameSync(d.default.join(r,"package.json"),d.default.join(r,"package.json.bak")),f.default.writeFileSync(d.default.join(r,"package.json"),JSON.stringify(a,null,2)),console.log(a);try{g.execSync(["pnpm","publish","--access","public","--no-git-checks",...n].join(" "),{cwd:r,stdio:"inherit"});const e=JSON.parse(f.default.readFileSync(d.default.join(r,"package.json.bak"),"utf-8"));e.version=o,f.default.writeFileSync(d.default.join(r,"package.json.bak"),JSON.stringify(e,null,2))}finally{f.default.unlinkSync(d.default.join(r,"package.json")),f.default.renameSync(d.default.join(r,"package.json.bak"),d.default.join(r,"package.json"))}}y()}));const h=e=>`\nconst pkg = ${JSON.stringify(e,null,2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template(templateArg, pkg)\n`.trimStart();a.program.command("build").action((async()=>{v();const{wd:e,value:r={}}=await w()??{};if(0===Object.keys(r).length)throw new Error("no package found");const t=(...r)=>d.default.resolve(e,"node_modules/.jiek",...r);f.default.existsSync(t())||f.default.mkdirSync(t());const o=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let a=0;for(const[e,n]of Object.entries(r)){const r=b(n,e),s=n.name?.replace(/^@/g,"").replace(/\//g,"+"),i=t(`${s??"anonymous-"+a++}.rollup.config.js`);f.default.writeFileSync(i,h(r));let c="";if("test"===process.env.NODE_ENV){c=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}k.execSync(`${c}${o} -c ${i}`,{cwd:e,stdio:"inherit"})}y()}));const O=require("../package.json");a.program.version(O.version).description(O.description).option("--root <root>","root path"),a.program.parse(process.argv)}(fs,path,getWorkspaceDir,filterWorkspacePackages,commander,jsYaml,bumper,childProcess,pkger,childProcess$1);
1
+ !function(e,t,r,o,n,a,i,s,c,l,p,u){"use strict";function f(e){return e&&e.__esModule?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var g=f(e),m=f(t),k=d(s),j=f(c),y=d(u);let w,v="";try{require.resolve("@pnpm/filter-workspace-packages"),v="pnpm"}catch{}async function b(){let e=n.program.getOptionValue("filter");const t=n.program.getOptionValue("root"),i=t?m.default.isAbsolute(t)?t:m.default.resolve(process.cwd(),t):process.cwd();let s,c=!1;try{s=r.getWorkspaceDir(i,v)}catch(e){if(!("message"in e)||"workspace root not found"!==e.message)throw e;s=i,c=!0}if(!c&&"pnpm"===v){const t=m.default.resolve(s,"pnpm-workspace.yaml"),r=g.default.readFileSync(t,"utf-8"),n=a.load(r);if(i===s&&!e)throw new Error("root path is workspace root, please provide a filter");if(i!==s&&!e){if(!g.default.existsSync(m.default.resolve(i,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const t=JSON.parse(g.default.readFileSync(m.default.resolve(i,"package.json"),"utf-8"));if(!t.name)throw new Error("root path is not workspace root, please provide a filter");e=t.name}const{selectedProjectsGraph:c}=await o.filterPackagesFromDir(s,[{filter:e??"",followProdDepsOnly:!0}],{prefix:i,workspaceDir:s,patterns:n.packages});return{wd:s,root:i,value:Object.entries(c).reduce(((e,[t,r])=>(e[t]=r.package.manifest,e)),{})}}return{wd:s,root:i,value:{[s]:JSON.parse(g.default.readFileSync(m.default.resolve(s,"package.json"),"utf-8"))}}}function h(){w()}function O(){new Promise((e=>w=e))}function S(e,t){const{jiek:{inputs:r,cwd:o,...n}={},exports:a}=e,i=r??(Array.isArray(a)?a:void 0);return{...e,...p.pkger({inputs:i,cwd:t,...n})}}""!==v&&n.program.option("-f, --filter <filter>","filter packages"),n.program.command("publish").aliases(["pub","p"]).option("-b, --bumper <bumper>","bump version","patch").option("-p, --preview","preview publish").action((async({preview:e,bumper:t,...r})=>{O();const{value:o={}}=await b()??{},n=Object.entries(o);if(0===n.length)throw new Error("no packages selected");const a=n.map((([e,t])=>[e,S(t,e)])),s=Object.entries(r).reduce(((e,[t,r])=>(r&&e.push(`--${t}`,r),e)),[]);for(const[r,o]of a){const n=g.default.readFileSync(m.default.join(r,"package.json"),"utf-8"),a=JSON.parse(n)??"0.0.0",c=i.bump(a.version,t),{indent:p=" "}=j.default(n),u={tabSize:p.length,insertSpaces:!0};let f=n;f=l.applyEdits(f,l.modify(f,["version"],c,{formattingOptions:u}));for(const[e,t]of Object.entries(o))JSON.stringify(t)!==JSON.stringify(a[e])&&(f=l.applyEdits(f,l.modify(f,["publishConfig",e],t,{formattingOptions:u})));try{if(g.default.renameSync(m.default.join(r,"package.json"),m.default.join(r,"package.json.bak")),g.default.writeFileSync(m.default.join(r,"package.json"),f),console.log(f),e){console.warn("preview mode");continue}k.execSync(["pnpm","publish","--access","public","--no-git-checks",...s].join(" "),{cwd:r,stdio:"inherit"});const t=l.applyEdits(n,l.modify(n,["version"],c,{}));g.default.writeFileSync(m.default.join(r,"package.json.bak"),t)}finally{g.default.unlinkSync(m.default.join(r,"package.json")),g.default.renameSync(m.default.join(r,"package.json.bak"),m.default.join(r,"package.json"))}}h()}));const E=e=>`\nconst pkg = ${JSON.stringify(e,null,2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template(templateArg, pkg)\n`.trimStart();n.program.command("build").action((async()=>{O();const{wd:e,value:t={}}=await b()??{};if(0===Object.keys(t).length)throw new Error("no package found");const r=(...t)=>m.default.resolve(e,"node_modules/.jiek",...t);g.default.existsSync(r())||g.default.mkdirSync(r());const o=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let n=0;for(const[e,a]of Object.entries(t)){const t=S(a,e),i=a.name?.replace(/^@/g,"").replace(/\//g,"+"),s=r(`${i??"anonymous-"+n++}.rollup.config.js`);g.default.writeFileSync(s,E(t));let c="";if("test"===process.env.NODE_ENV){c=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}y.execSync(`${c}${o} -c ${s}`,{cwd:e,stdio:"inherit"})}h()}));const P=require("../package.json");n.program.version(P.version).description(P.description).option("--root <root>","root path"),n.program.parse(process.argv)}(fs,path,getWorkspaceDir,filterWorkspacePackages,commander,jsYaml,bumper,childProcess,detectIndent,jsoncParser,pkger,childProcess$1);
2
2
  //# sourceMappingURL=index.iife.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.iife.min.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import 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\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\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 return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","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 type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([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 { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\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, manifest] of Object.entries(value)) {\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 './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["resolve","type","require","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","default","pnpmWorkspaceFileContent","fs","readFileSync","pnpmWorkspace","load","Error","existsSync","packageJSON","JSON","parse","name","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","packages","value","Object","entries","reduce","acc","key","package","manifest","actionDone","actionRestore","Promise","r","mergePackageJson","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","option","command","aliases","action","bumper","options","selectedProjectsGraphEntries","length","mainfests","forEach","dir","push","passArgs","m","newVersion","bump","version","newManifest","renameSync","join","writeFileSync","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","commander","keys","jiekTempDir","paths","mkdirSync","rollupBinaryPath","replace","i","escapeManifestName","configFile","pkg","description","argv"],"mappings":"8ZAQO,ICRHA,EDQOC,EAAO,GAElB,IACEC,QAAQF,QAAQ,mCACTC,EAAA,MACT,CAAQ,MAAc,CActBE,eAAsBC,IAChB,IAAAC,EAASC,EAAAA,QAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAAA,QAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAAA,QAAKC,WAAWH,GACdA,EACAE,EAAAA,QAAKV,QAAQY,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,IACIC,EADAC,GAAe,EAEf,IACGD,EAAAE,EAAAA,gBAAgBP,EAAMR,SACpBgB,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDH,EAAAL,EACUM,GAAA,CAIn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AA,ICvDf,MAAMwD,EAAMrG,QAAQ,mBAGjB2F,EAAAvF,QAAAsE,QAAQ2B,EAAI3B,SACZ4B,YAAYD,EAAIC,aAChB5C,OAAO,gBAAiB,aAE3BtD,EAAAA,QAAQwB,MAAMlB,QAAQ6F"}
1
+ {"version":3,"file":"index.iife.min.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import 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\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\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 return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","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 { 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 }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\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, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\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 { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\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, manifest] of Object.entries(value)) {\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 './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["resolve","type","require","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","default","pnpmWorkspaceFileContent","fs","readFileSync","pnpmWorkspace","load","Error","existsSync","packageJSON","JSON","parse","name","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","packages","value","Object","entries","reduce","acc","key","package","manifest","actionDone","actionRestore","Promise","r","mergePackageJson","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","option","command","aliases","action","preview","bumper","options","selectedProjectsGraphEntries","length","mainfests","map","dir","passArgs","push","oldJSONString","join","oldJSON","newVersion","bump","version","indent","detectIndent","formattingOptions","tabSize","insertSpaces","newJSONString","applyEdits","modify","stringify","renameSync","writeFileSync","console","log","warn","childProcess","execSync","stdio","modifyVersionPackageJSON","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","commander","keys","jiekTempDir","paths","mkdirSync","rollupBinaryPath","replace","i","newManifest","escapeManifestName","configFile","pkg","description","argv"],"mappings":"yaAQO,ICRHA,EDQOC,EAAO,GAElB,IACEC,QAAQF,QAAQ,mCACTC,EAAA,MACT,CAAQ,MAAc,CActBE,eAAsBC,IAChB,IAAAC,EAASC,EAAAA,QAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAAA,QAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAAA,QAAKC,WAAWH,GACdA,EACAE,EAAAA,QAAKV,QAAQY,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,I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BnF,UAAAqF,UAAUF,KAEhD,MAAMG,EAAmB1G,QAAQF,QAAQ,UACtC6G,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAYvC,EAAKzB,KAAaN,OAAOC,QAAQF,GAAQ,CAC7C,MAAAwE,EAAc5D,EAAiBL,EAAUyB,GAEzCyC,EAAqBlE,EAASf,MAAM8E,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtEI,EAAaR,EACjB,GAAGO,GAAsB,aAAaF,wBAExCxF,EAAAA,QAAGoE,cAAcuB,EAAYd,EAAcY,IAC3C,IAAI5E,EAAS,GACT,GAAyB,SAAzBvB,QAAQwF,IAAIC,SAAqB,CAG1BlE,EAAA,iBAFYjC,QAAQF,QAAQ,0BAClBE,QAAQF,QAAQ,6BAErC,CAEA8F,EAAaC,SAAS,GAAG5D,IAASyE,QAAuBK,IAAc,CACrEpG,IAAK0D,EAAKyB,MAAO,WAErB,CAEWjD,GAAA,ICvDf,MAAMmE,EAAMhH,QAAQ,mBAGjBqG,EAAAjG,QAAAyE,QAAQmC,EAAInC,SACZoC,YAAYD,EAAIC,aAChBvD,OAAO,gBAAiB,aAE3BtD,EAAAA,QAAQwB,MAAMlB,QAAQwG"}
package/dist/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('node:fs'), require('node:path'), require('@jiek/utils/getWorkspaceDir'), require('@pnpm/filter-workspace-packages'), require('commander'), require('js-yaml'), require('@jiek/utils/bumper'), require('child_process'), require('@jiek/pkger'), require('node:child_process')) :
3
- typeof define === 'function' && define.amd ? define(['node:fs', 'node:path', '@jiek/utils/getWorkspaceDir', '@pnpm/filter-workspace-packages', 'commander', 'js-yaml', '@jiek/utils/bumper', 'child_process', '@jiek/pkger', 'node:child_process'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.fs, global.path, global.getWorkspaceDir, global.filterWorkspacePackages, global.commander, global.jsYaml, global.bumper, global.childProcess, global.pkger, global.childProcess$1));
5
- })(this, (function (fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, pkger, childProcess$1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('node:fs'), require('node:path'), require('@jiek/utils/getWorkspaceDir'), require('@pnpm/filter-workspace-packages'), require('commander'), require('js-yaml'), require('@jiek/utils/bumper'), require('child_process'), require('detect-indent'), require('jsonc-parser'), require('@jiek/pkger'), require('node:child_process')) :
3
+ typeof define === 'function' && define.amd ? define(['node:fs', 'node:path', '@jiek/utils/getWorkspaceDir', '@pnpm/filter-workspace-packages', 'commander', 'js-yaml', '@jiek/utils/bumper', 'child_process', 'detect-indent', 'jsonc-parser', '@jiek/pkger', 'node:child_process'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.fs, global.path, global.getWorkspaceDir, global.filterWorkspacePackages, global.commander, global.jsYaml, global.bumper, global.childProcess, global.detectIndent, global.jsoncParser, global.pkger, global.childProcess$1));
5
+ })(this, (function (fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, detectIndent, jsoncParser, pkger, childProcess$1) { 'use strict';
6
6
 
7
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
@@ -27,6 +27,7 @@
27
27
  var fs__default = /*#__PURE__*/_interopDefault(fs);
28
28
  var path__default = /*#__PURE__*/_interopDefault(path);
29
29
  var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
30
+ var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
30
31
  var childProcess__namespace$1 = /*#__PURE__*/_interopNamespace(childProcess$1);
31
32
 
32
33
  let type = "";
@@ -118,43 +119,63 @@
118
119
  };
119
120
  }
120
121
 
121
- commander.program.command("publish").aliases(["pub", "p"]).option("--bumper <bumper>", "bump version", "patch").action(async ({ bumper: bumper$1, ...options }) => {
122
+ commander.program.command("publish").aliases(["pub", "p"]).option("-b, --bumper <bumper>", "bump version", "patch").option("-p, --preview", "preview publish").action(async ({ preview, bumper: bumper$1, ...options }) => {
122
123
  actionRestore();
123
124
  const { value = {} } = await getSelectedProjectsGraph() ?? {};
124
125
  const selectedProjectsGraphEntries = Object.entries(value);
125
126
  if (selectedProjectsGraphEntries.length === 0) {
126
127
  throw new Error("no packages selected");
127
128
  }
128
- const mainfests = [];
129
- selectedProjectsGraphEntries.forEach(([dir, manifest]) => {
130
- mainfests.push([
131
- dir,
132
- mergePackageJson(manifest, dir)
133
- ]);
134
- });
129
+ const mainfests = selectedProjectsGraphEntries.map(([dir, manifest]) => [
130
+ dir,
131
+ mergePackageJson(manifest, dir)
132
+ ]);
135
133
  const passArgs = Object.entries(options).reduce((acc, [key, value2]) => {
136
134
  if (value2) {
137
135
  acc.push(`--${key}`, value2);
138
136
  }
139
137
  return acc;
140
138
  }, []);
141
- for (const [dir, m] of mainfests) {
142
- const newVersion = bumper.bump(m.version, bumper$1);
143
- const newManifest = {
144
- ...m,
145
- version: newVersion
139
+ for (const [dir, manifest] of mainfests) {
140
+ const oldJSONString = fs__default.default.readFileSync(path__default.default.join(dir, "package.json"), "utf-8");
141
+ const oldJSON = JSON.parse(oldJSONString) ?? "0.0.0";
142
+ const newVersion = bumper.bump(oldJSON.version, bumper$1);
143
+ const { indent = " " } = detectIndent__default.default(oldJSONString);
144
+ const formattingOptions = {
145
+ tabSize: indent.length,
146
+ insertSpaces: true
146
147
  };
147
- fs__default.default.renameSync(path__default.default.join(dir, "package.json"), path__default.default.join(dir, "package.json.bak"));
148
- fs__default.default.writeFileSync(path__default.default.join(dir, "package.json"), JSON.stringify(newManifest, null, 2));
149
- console.log(newManifest);
148
+ let newJSONString = oldJSONString;
149
+ newJSONString = jsoncParser.applyEdits(newJSONString, jsoncParser.modify(
150
+ newJSONString,
151
+ ["version"],
152
+ newVersion,
153
+ { formattingOptions }
154
+ ));
155
+ for (const [key, value2] of Object.entries(manifest)) {
156
+ if (JSON.stringify(value2) === JSON.stringify(oldJSON[key]))
157
+ continue;
158
+ newJSONString = jsoncParser.applyEdits(newJSONString, jsoncParser.modify(
159
+ newJSONString,
160
+ ["publishConfig", key],
161
+ value2,
162
+ { formattingOptions }
163
+ ));
164
+ }
150
165
  try {
166
+ fs__default.default.renameSync(path__default.default.join(dir, "package.json"), path__default.default.join(dir, "package.json.bak"));
167
+ fs__default.default.writeFileSync(path__default.default.join(dir, "package.json"), newJSONString);
168
+ console.log(newJSONString);
169
+ if (preview) {
170
+ console.warn("preview mode");
171
+ continue;
172
+ }
151
173
  childProcess__namespace.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
152
174
  cwd: dir,
153
175
  stdio: "inherit"
154
176
  });
155
- const oldPackageJson = JSON.parse(fs__default.default.readFileSync(path__default.default.join(dir, "package.json.bak"), "utf-8"));
156
- oldPackageJson.version = newVersion;
157
- fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), JSON.stringify(oldPackageJson, null, 2));
177
+ const modifyVersionPackageJSON = jsoncParser.applyEdits(oldJSONString, jsoncParser.modify(oldJSONString, ["version"], newVersion, {}));
178
+ fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), modifyVersionPackageJSON);
158
179
  } finally {
159
180
  fs__default.default.unlinkSync(path__default.default.join(dir, "package.json"));
160
181
  fs__default.default.renameSync(path__default.default.join(dir, "package.json.bak"), path__default.default.join(dir, "package.json"));
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import 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\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\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 return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","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 type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([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 { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\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, manifest] of Object.entries(value)) {\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 './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["program","path","getWorkspaceDir","fs","load","filterPackagesFromDir","pkger","bumper","value","bump","childProcess"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQO,IAAI,IAAO,GAAA,EAAA,CAAA;EAElB,IAAI;EACF,EAAA,OAAA,CAAQ,QAAQ,iCAAiC,CAAA,CAAA;EACjD,EAAO,IAAA,GAAA,MAAA,CAAA;EACT,CAAQ,CAAA,MAAA;EAAc,CAAA;EACtB,IAAI,SAAS,EAAI,EAAA;EACf,EACGA,iBAAA,CAAA,MAAA,CAAO,yBAAyB,iBAAiB,CAAA,CAAA;EACtD,CAAA;EAUA,eAAsB,wBAAmD,GAAA;EACvE,EAAI,IAAA,MAAA,GAASA,iBAAQ,CAAA,cAAA,CAAe,QAAQ,CAAA,CAAA;EAC5C,EAAM,MAAA,UAAA,GAAaA,iBAAQ,CAAA,cAAA,CAAe,MAAM,CAAA,CAAA;EAChD,EAAA,MAAM,I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A,iBAAA,CAAA;EAAA,KAC7C,CAAA;EACA,IAAAA,mBAAA,CAAG,aAAc,CAAA,UAAA,EAAY,aAAc,CAAA,WAAW,CAAC,CAAA,CAAA;EACvD,IAAA,IAAI,MAAS,GAAA,EAAA,CAAA;EACb,IAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,MAAQ,EAAA;EACnC,MAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,kBAAkB,CAAA,CAAA;EACvD,MAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,OAAA,CAAQ,yBAAyB,CAAA,CAAA;EAC5D,MAAS,MAAA,GAAA,CAAA,cAAA,EAAiB,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA,CAAA,CAAA,CAAA;EAAA,KACzD;EAEA,IAAAO,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;;ECxDH,MAAM,GAAA,GAAM,QAAQ,iBAAiB,CAAA,CAAA;AAErCV,mBACG,CAAA,OAAA,CAAQ,GAAI,CAAA,OAAO,CACnB,CAAA,WAAA,CAAY,IAAI,WAAW,CAAA,CAC3B,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AAEtCA,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import 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\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\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 return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","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 { 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 }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\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, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\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 { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\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, manifest] of Object.entries(value)) {\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 './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["program","path","getWorkspaceDir","fs","load","filterPackagesFromDir","pkger","bumper","value","bump","detectIndent","applyEdits","modify","childProcess"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQO,IAAI,IAAO,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,CAAG,EAAA,kBAAA,IAAsB,CAAa,UAAA,EAAA,CAAA,EAAG,CAAE,CAAA,CAAA,iBAAA,CAAA;EAAA,KAC7C,CAAA;EACA,IAAAA,mBAAA,CAAG,aAAc,CAAA,UAAA,EAAY,aAAc,CAAA,WAAW,CAAC,CAAA,CAAA;EACvD,IAAA,IAAI,MAAS,GAAA,EAAA,CAAA;EACb,IAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,MAAQ,EAAA;EACnC,MAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,kBAAkB,CAAA,CAAA;EACvD,MAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,OAAA,CAAQ,yBAAyB,CAAA,CAAA;EAC5D,MAAS,MAAA,GAAA,CAAA,cAAA,EAAiB,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA,CAAA,CAAA,CAAA;EAAA,KACzD;EAEA,IAAAU,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;;ECxDH,MAAM,GAAA,GAAM,QAAQ,iBAAiB,CAAA,CAAA;AAErCb,mBACG,CAAA,OAAA,CAAQ,GAAI,CAAA,OAAO,CACnB,CAAA,WAAA,CAAY,IAAI,WAAW,CAAA,CAC3B,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AAEtCA,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("node:fs"),require("node:path"),require("@jiek/utils/getWorkspaceDir"),require("@pnpm/filter-workspace-packages"),require("commander"),require("js-yaml"),require("@jiek/utils/bumper"),require("child_process"),require("@jiek/pkger"),require("node:child_process")):"function"==typeof define&&define.amd?define(["node:fs","node:path","@jiek/utils/getWorkspaceDir","@pnpm/filter-workspace-packages","commander","js-yaml","@jiek/utils/bumper","child_process","@jiek/pkger","node:child_process"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).fs,e.path,e.getWorkspaceDir,e.filterWorkspacePackages,e.commander,e.jsYaml,e.bumper,e.childProcess,e.pkger,e.childProcess$1)}(this,(function(e,r,t,o,n,a,s,i,c,l){"use strict";function p(e){return e&&e.__esModule?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var d=p(e),f=p(r),g=u(i),k=u(l);let m,j="";try{require.resolve("@pnpm/filter-workspace-packages"),j="pnpm"}catch{}async function y(){let e=n.program.getOptionValue("filter");const r=n.program.getOptionValue("root"),s=r?f.default.isAbsolute(r)?r:f.default.resolve(process.cwd(),r):process.cwd();let i,c=!1;try{i=t.getWorkspaceDir(s,j)}catch(e){if(!("message"in e)||"workspace root not found"!==e.message)throw e;i=s,c=!0}if(!c&&"pnpm"===j){const r=f.default.resolve(i,"pnpm-workspace.yaml"),t=d.default.readFileSync(r,"utf-8"),n=a.load(t);if(s===i&&!e)throw new Error("root path is workspace root, please provide a filter");if(s!==i&&!e){if(!d.default.existsSync(f.default.resolve(s,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const r=JSON.parse(d.default.readFileSync(f.default.resolve(s,"package.json"),"utf-8"));if(!r.name)throw new Error("root path is not workspace root, please provide a filter");e=r.name}const{selectedProjectsGraph:c}=await o.filterPackagesFromDir(i,[{filter:e??"",followProdDepsOnly:!0}],{prefix:s,workspaceDir:i,patterns:n.packages});return{wd:i,root:s,value:Object.entries(c).reduce(((e,[r,t])=>(e[r]=t.package.manifest,e)),{})}}return{wd:i,root:s,value:{[i]:JSON.parse(d.default.readFileSync(f.default.resolve(i,"package.json"),"utf-8"))}}}function h(){m()}function w(){new Promise((e=>m=e))}function b(e,r){const{jiek:{inputs:t,cwd:o,...n}={},exports:a}=e,s=t??(Array.isArray(a)?a:void 0);return{...e,...c.pkger({inputs:s,cwd:r,...n})}}""!==j&&n.program.option("-f, --filter <filter>","filter packages"),n.program.command("publish").aliases(["pub","p"]).option("--bumper <bumper>","bump version","patch").action((async({bumper:e,...r})=>{w();const{value:t={}}=await y()??{},o=Object.entries(t);if(0===o.length)throw new Error("no packages selected");const n=[];o.forEach((([e,r])=>{n.push([e,b(r,e)])}));const a=Object.entries(r).reduce(((e,[r,t])=>(t&&e.push(`--${r}`,t),e)),[]);for(const[r,t]of n){const o=s.bump(t.version,e),n={...t,version:o};d.default.renameSync(f.default.join(r,"package.json"),f.default.join(r,"package.json.bak")),d.default.writeFileSync(f.default.join(r,"package.json"),JSON.stringify(n,null,2)),console.log(n);try{g.execSync(["pnpm","publish","--access","public","--no-git-checks",...a].join(" "),{cwd:r,stdio:"inherit"});const e=JSON.parse(d.default.readFileSync(f.default.join(r,"package.json.bak"),"utf-8"));e.version=o,d.default.writeFileSync(f.default.join(r,"package.json.bak"),JSON.stringify(e,null,2))}finally{d.default.unlinkSync(f.default.join(r,"package.json")),d.default.renameSync(f.default.join(r,"package.json.bak"),f.default.join(r,"package.json"))}}h()}));const v=e=>`\nconst pkg = ${JSON.stringify(e,null,2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template(templateArg, pkg)\n`.trimStart();n.program.command("build").action((async()=>{w();const{wd:e,value:r={}}=await y()??{};if(0===Object.keys(r).length)throw new Error("no package found");const t=(...r)=>f.default.resolve(e,"node_modules/.jiek",...r);d.default.existsSync(t())||d.default.mkdirSync(t());const o=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let n=0;for(const[e,a]of Object.entries(r)){const r=b(a,e),s=a.name?.replace(/^@/g,"").replace(/\//g,"+"),i=t(`${s??"anonymous-"+n++}.rollup.config.js`);d.default.writeFileSync(i,v(r));let c="";if("test"===process.env.NODE_ENV){c=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}k.execSync(`${c}${o} -c ${i}`,{cwd:e,stdio:"inherit"})}h()}));const O=require("../package.json");n.program.version(O.version).description(O.description).option("--root <root>","root path"),n.program.parse(process.argv)}));
1
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("node:fs"),require("node:path"),require("@jiek/utils/getWorkspaceDir"),require("@pnpm/filter-workspace-packages"),require("commander"),require("js-yaml"),require("@jiek/utils/bumper"),require("child_process"),require("detect-indent"),require("jsonc-parser"),require("@jiek/pkger"),require("node:child_process")):"function"==typeof define&&define.amd?define(["node:fs","node:path","@jiek/utils/getWorkspaceDir","@pnpm/filter-workspace-packages","commander","js-yaml","@jiek/utils/bumper","child_process","detect-indent","jsonc-parser","@jiek/pkger","node:child_process"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).fs,e.path,e.getWorkspaceDir,e.filterWorkspacePackages,e.commander,e.jsYaml,e.bumper,e.childProcess,e.detectIndent,e.jsoncParser,e.pkger,e.childProcess$1)}(this,(function(e,r,t,o,n,i,s,a,c,p,l,u){"use strict";function d(e){return e&&e.__esModule?e:{default:e}}function f(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var g=d(e),m=d(r),k=f(a),j=d(c),y=f(u);let w,h="";try{require.resolve("@pnpm/filter-workspace-packages"),h="pnpm"}catch{}async function b(){let e=n.program.getOptionValue("filter");const r=n.program.getOptionValue("root"),s=r?m.default.isAbsolute(r)?r:m.default.resolve(process.cwd(),r):process.cwd();let a,c=!1;try{a=t.getWorkspaceDir(s,h)}catch(e){if(!("message"in e)||"workspace root not found"!==e.message)throw e;a=s,c=!0}if(!c&&"pnpm"===h){const r=m.default.resolve(a,"pnpm-workspace.yaml"),t=g.default.readFileSync(r,"utf-8"),n=i.load(t);if(s===a&&!e)throw new Error("root path is workspace root, please provide a filter");if(s!==a&&!e){if(!g.default.existsSync(m.default.resolve(s,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const r=JSON.parse(g.default.readFileSync(m.default.resolve(s,"package.json"),"utf-8"));if(!r.name)throw new Error("root path is not workspace root, please provide a filter");e=r.name}const{selectedProjectsGraph:c}=await o.filterPackagesFromDir(a,[{filter:e??"",followProdDepsOnly:!0}],{prefix:s,workspaceDir:a,patterns:n.packages});return{wd:a,root:s,value:Object.entries(c).reduce(((e,[r,t])=>(e[r]=t.package.manifest,e)),{})}}return{wd:a,root:s,value:{[a]:JSON.parse(g.default.readFileSync(m.default.resolve(a,"package.json"),"utf-8"))}}}function v(){w()}function O(){new Promise((e=>w=e))}function S(e,r){const{jiek:{inputs:t,cwd:o,...n}={},exports:i}=e,s=t??(Array.isArray(i)?i:void 0);return{...e,...l.pkger({inputs:s,cwd:r,...n})}}""!==h&&n.program.option("-f, --filter <filter>","filter packages"),n.program.command("publish").aliases(["pub","p"]).option("-b, --bumper <bumper>","bump version","patch").option("-p, --preview","preview publish").action((async({preview:e,bumper:r,...t})=>{O();const{value:o={}}=await b()??{},n=Object.entries(o);if(0===n.length)throw new Error("no packages selected");const i=n.map((([e,r])=>[e,S(r,e)])),a=Object.entries(t).reduce(((e,[r,t])=>(t&&e.push(`--${r}`,t),e)),[]);for(const[t,o]of i){const n=g.default.readFileSync(m.default.join(t,"package.json"),"utf-8"),i=JSON.parse(n)??"0.0.0",c=s.bump(i.version,r),{indent:l=" "}=j.default(n),u={tabSize:l.length,insertSpaces:!0};let d=n;d=p.applyEdits(d,p.modify(d,["version"],c,{formattingOptions:u}));for(const[e,r]of Object.entries(o))JSON.stringify(r)!==JSON.stringify(i[e])&&(d=p.applyEdits(d,p.modify(d,["publishConfig",e],r,{formattingOptions:u})));try{if(g.default.renameSync(m.default.join(t,"package.json"),m.default.join(t,"package.json.bak")),g.default.writeFileSync(m.default.join(t,"package.json"),d),console.log(d),e){console.warn("preview mode");continue}k.execSync(["pnpm","publish","--access","public","--no-git-checks",...a].join(" "),{cwd:t,stdio:"inherit"});const r=p.applyEdits(n,p.modify(n,["version"],c,{}));g.default.writeFileSync(m.default.join(t,"package.json.bak"),r)}finally{g.default.unlinkSync(m.default.join(t,"package.json")),g.default.renameSync(m.default.join(t,"package.json.bak"),m.default.join(t,"package.json"))}}v()}));const q=e=>`\nconst pkg = ${JSON.stringify(e,null,2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template(templateArg, pkg)\n`.trimStart();n.program.command("build").action((async()=>{O();const{wd:e,value:r={}}=await b()??{};if(0===Object.keys(r).length)throw new Error("no package found");const t=(...r)=>m.default.resolve(e,"node_modules/.jiek",...r);g.default.existsSync(t())||g.default.mkdirSync(t());const o=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let n=0;for(const[e,i]of Object.entries(r)){const r=S(i,e),s=i.name?.replace(/^@/g,"").replace(/\//g,"+"),a=t(`${s??"anonymous-"+n++}.rollup.config.js`);g.default.writeFileSync(a,q(r));let c="";if("test"===process.env.NODE_ENV){c=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}y.execSync(`${c}${o} -c ${a}`,{cwd:e,stdio:"inherit"})}v()}));const E=require("../package.json");n.program.version(E.version).description(E.description).option("--root <root>","root path"),n.program.parse(process.argv)}));
2
2
  //# sourceMappingURL=index.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.min.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import 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\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\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 return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","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 type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([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 { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\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, manifest] of Object.entries(value)) {\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 './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["resolve","type","require","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","default","pnpmWorkspaceFileContent","fs","readFileSync","pnpmWorkspace","load","Error","existsSync","packageJSON","JSON","parse","name","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","packages","value","Object","entries","reduce","acc","key","package","manifest","actionDone","actionRestore","Promise","r","mergePackageJson","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","option","command","aliases","action","bumper","options","selectedProjectsGraphEntries","length","mainfests","forEach","dir","push","passArgs","m","newVersion","bump","version","newManifest","renameSync","join","writeFileSync","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","commander","keys","jiekTempDir","paths","mkdirSync","rollupBinaryPath","replace","i","escapeManifestName","configFile","pkg","description","argv"],"mappings":"opCAQO,ICRHA,EDQOC,EAAO,GAElB,IACEC,QAAQF,QAAQ,mCACTC,EAAA,MACT,CAAQ,MAAc,CActBE,eAAsBC,IAChB,IAAAC,EAASC,EAAAA,QAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAAA,QAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAAA,QAAKC,WAAWH,GACdA,EACAE,EAAAA,QAAKV,QAAQY,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,IACIC,EADAC,GAAe,EAEf,IACGD,EAAAE,EAAAA,gBAAgBP,EAAMR,SACpBgB,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDH,EAAAL,EACUM,GAAA,CAInB,CACI,IAACA,GAAyB,SAATd,EAAiB,CACpC,MAAMkB,EAAwBT,EAAAU,QAAKpB,QAAQc,EAAI,uBACzCO,EAA2BC,EAAAF,QAAGG,aAAaJ,EAAuB,SAClEK,EAAgBC,OAAKJ,GAGvB,GAAAZ,IAASK,IAAOT,EACZ,MAAA,IAAIqB,MAAM,wDAGd,GAAAjB,IAASK,IAAOT,EAAQ,CAE1B,IAD2BiB,EAAGF,QAAAO,WAAWjB,EAAAA,QAAKV,QAAQS,EAAM,iBAEpD,MAAA,IAAIiB,MAAM,4DAEZ,MAAAE,EAAcC,KAAKC,MAAMR,EAAGF,QAAAG,aAAab,U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AAyB,MAAIA,EAAQ,CAAC,SACLnC,KAA8B,GAExC,GAAkC,IAA9BoC,OAAOsD,KAAKvD,GAAO4B,OACf,MAAA,IAAIzC,MAAM,oBAEZ,MAAAqE,EAAc,IAAIC,IAAoBtF,EAAAU,QAAKpB,QAAQc,EAAI,wBAAyBkF,GACjF1E,EAAAF,QAAGO,WAAWoE,MAAmBzE,UAAA2E,UAAUF,KAEhD,MAAMG,EAAmBhG,QAAQF,QAAQ,UACtCmG,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAY9B,EAAKxB,KAAaN,OAAOC,QAAQF,GAAQ,CAC7C,MAAAsC,EAAc1B,EAAiBL,EAAUwB,GAEzC+B,EAAqBvD,EAASf,MAAMoE,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtEG,EAAaP,EACjB,GAAGM,GAAsB,aAAaD,wBAExC9E,EAAAA,QAAG0D,cAAcsB,EAAYb,EAAcZ,IAC3C,IAAI1C,EAAS,GACT,GAAyB,SAAzBvB,QAAQ8E,IAAIC,SAAqB,CAG1BxD,EAAA,iBAFYjC,QAAQF,QAAQ,0BAClBE,QAAQF,QAAQ,6BAErC,CAEAoF,EAAaC,SAAS,GAAGlD,IAAS+D,QAAuBI,IAAc,CACrEzF,IAAKyD,EAAKgB,MAAO,WAErB,CAEWvC,GAAA,ICvDf,MAAMwD,EAAMrG,QAAQ,mBAGjB2F,EAAAvF,QAAAsE,QAAQ2B,EAAI3B,SACZ4B,YAAYD,EAAIC,aAChB5C,OAAO,gBAAiB,aAE3BtD,EAAAA,QAAQwB,MAAMlB,QAAQ6F"}
1
+ {"version":3,"file":"index.umd.min.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import 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\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\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 return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","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 { 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 }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\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, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\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 { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\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, manifest] of Object.entries(value)) {\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 './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["resolve","type","require","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","default","pnpmWorkspaceFileContent","fs","readFileSync","pnpmWorkspace","load","Error","existsSync","packageJSON","JSON","parse","name","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","packages","value","Object","entries","reduce","acc","key","package","manifest","actionDone","actionRestore","Promise","r","mergePackageJson","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","option","command","aliases","action","preview","bumper","options","selectedProjectsGraphEntries","length","mainfests","map","dir","passArgs","push","oldJSONString","join","oldJSON","newVersion","bump","version","indent","detectIndent","formattingOptions","tabSize","insertSpaces","newJSONString","applyEdits","modify","stringify","renameSync","writeFileSync","console","log","warn","childProcess","execSync","stdio","modifyVersionPackageJSON","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","commander","keys","jiekTempDir","paths","mkdirSync","rollupBinaryPath","replace","i","newManifest","escapeManifestName","configFile","pkg","description","argv"],"mappings":"4wCAQO,ICRHA,EDQOC,EAAO,GAElB,IACEC,QAAQF,QAAQ,mCACTC,EAAA,MACT,CAAQ,MAAc,CActBE,eAAsBC,IAChB,IAAAC,EAASC,EAAAA,QAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAAA,QAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAAA,QAAKC,WAAWH,GACdA,EACAE,EAAAA,QAAKV,QAAQY,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,IACIC,EADAC,GAAe,EAEf,IACGD,EAAAE,EAAAA,gBAAgBP,EAAMR,SACpBgB,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDH,EAAAL,EACUM,GAAA,CAInB,CACI,IAACA,GAAyB,SAATd,EAAiB,CACpC,MAAMkB,EAAwBT,EAAAU,QAAKpB,QAAQc,EAAI,uBACzCO,EAA2BC,EAAAF,QAAGG,aAAaJ,EAAuB,SAClEK,EAAgBC,OAAKJ,GAGvB,GAAAZ,IAASK,IAAOT,EACZ,MAAA,IAAIqB,MAAM,wDAGd,GAAAjB,IAASK,IAAOT,EAAQ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,QAAQwF,IAAIC,SAAqB,CAG1BlE,EAAA,iBAFYjC,QAAQF,QAAQ,0BAClBE,QAAQF,QAAQ,6BAErC,CAEA8F,EAAaC,SAAS,GAAG5D,IAASyE,QAAuBK,IAAc,CACrEpG,IAAK0D,EAAKyB,MAAO,WAErB,CAEWjD,GAAA,ICvDf,MAAMmE,EAAMhH,QAAQ,mBAGjBqG,EAAAjG,QAAAyE,QAAQmC,EAAInC,SACZoC,YAAYD,EAAIC,aAChBvD,OAAO,gBAAiB,aAE3BtD,EAAAA,QAAQwB,MAAMlB,QAAQwG"}
@@ -1 +1 @@
1
- {"version":3,"file":"merge-package-json.esm.js","sources":["../src/merge-package-json.ts"],"sourcesContent":["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"],"names":[],"mappings":";;AAIgB,SAAA,gBAAA,CAAiB,UAG9B,GAAa,EAAA;AACd,EAAM,MAAA;AAAA,IACJ,IAAA,EAAM,EAAE,MAAQ,EAAA,UAAA,EAAY,KAAK,CAAG,EAAA,GAAG,IAAK,EAAA,GAAI,EAAC;AAAA,IAAG,OAAA;AAAA,GAClD,GAAA,QAAA,CAAA;AACJ,EAAA,MAAM,SAAS,UACb,KAAA,KAAA,CAAM,OAAQ,CAAA,OAAO,IAAI,OAAU,GAAA,KAAA,CAAA,CAAA,CAAA;AAErC,EAAO,OAAA;AAAA,IACL,GAAG,QAAA;AAAA,IACH,GAAG,KAAM,CAAA,EAAE,QAAQ,GAAK,EAAA,GAAG,MAAM,CAAA;AAAA,GACnC,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"merge-package-json.esm.js","sources":["../src/merge-package-json.ts"],"sourcesContent":["import { type Options, pkger } from '@jiek/pkger'\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 }\n}\n"],"names":[],"mappings":";;AAGgB,SAAA,gBAAA,CAAiB,UAG9B,GAAa,EAAA;AACd,EAAM,MAAA;AAAA,IACJ,IAAA,EAAM,EAAE,MAAQ,EAAA,UAAA,EAAY,KAAK,CAAG,EAAA,GAAG,IAAK,EAAA,GAAI,EAAC;AAAA,IAAG,OAAA;AAAA,GAClD,GAAA,QAAA,CAAA;AACJ,EAAA,MAAM,SAAS,UACb,KAAA,KAAA,CAAM,OAAQ,CAAA,OAAO,IAAI,OAAU,GAAA,KAAA,CAAA,CAAA,CAAA;AAErC,EAAO,OAAA;AAAA,IACL,GAAG,QAAA;AAAA,IACH,GAAG,KAAM,CAAA,EAAE,QAAQ,GAAK,EAAA,GAAG,MAAM,CAAA;AAAA,GACnC,CAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"merge-package-json.esm.min.js","sources":["../src/merge-package-json.ts"],"sourcesContent":["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"],"names":["mergePackageJson","manifest","cwd","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger"],"mappings":"oCAIgB,SAAAA,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,EAAM,CAAEN,SAAQF,SAAQC,IAE/B"}
1
+ {"version":3,"file":"merge-package-json.esm.min.js","sources":["../src/merge-package-json.ts"],"sourcesContent":["import { type Options, pkger } from '@jiek/pkger'\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 }\n}\n"],"names":["mergePackageJson","manifest","cwd","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger"],"mappings":"oCAGgB,SAAAA,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,EAAM,CAAEN,SAAQF,SAAQC,IAE/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jiek",
3
- "version": "0.1.12-alpha.3",
3
+ "version": "0.1.12-alpha.5",
4
4
  "description": "YiJie's personal kits.",
5
5
  "bin": {
6
6
  "jiek": "bin/jiek.js",