jiek 0.1.12-alpha.1 → 0.1.12-alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/commands/build.esm.js +9 -31
- package/dist/commands/build.esm.js.map +1 -1
- package/dist/commands/build.esm.min.js +1 -1
- package/dist/commands/build.esm.min.js.map +1 -1
- package/dist/commands/publish.esm.js +11 -17
- package/dist/commands/publish.esm.js.map +1 -1
- package/dist/commands/publish.esm.min.js +1 -1
- package/dist/commands/publish.esm.min.js.map +1 -1
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +1 -56
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.umd.js +1 -56
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/rollup.esm.js +5 -5
- package/dist/rollup.esm.min.js +1 -1
- package/dist/rollup.esm.min.js.map +1 -1
- package/dist/utils/filterSupport.esm.js.map +1 -0
- package/dist/utils/filterSupport.esm.min.js.map +1 -0
- package/package.json +13 -9
- package/dist/package.json.esm.js +0 -58
- package/dist/package.json.esm.js.map +0 -1
- package/dist/package.json.esm.min.js +0 -2
- package/dist/package.json.esm.min.js.map +0 -1
- package/dist/src/commands/build.esm.js +0 -53
- package/dist/src/commands/build.esm.js.map +0 -1
- package/dist/src/commands/build.esm.min.js +0 -2
- package/dist/src/commands/build.esm.min.js.map +0 -1
- package/dist/src/commands/publish.esm.js +0 -54
- package/dist/src/commands/publish.esm.js.map +0 -1
- package/dist/src/commands/publish.esm.min.js +0 -2
- package/dist/src/commands/publish.esm.min.js.map +0 -1
- package/dist/src/inner.esm.js +0 -10
- package/dist/src/inner.esm.js.map +0 -1
- package/dist/src/inner.esm.min.js +0 -2
- package/dist/src/inner.esm.min.js.map +0 -1
- package/dist/src/merge-package-json.esm.js +0 -16
- package/dist/src/merge-package-json.esm.js.map +0 -1
- package/dist/src/merge-package-json.esm.min.js +0 -2
- package/dist/src/merge-package-json.esm.min.js.map +0 -1
- package/dist/src/rollup/plugins/globals.esm.js +0 -31
- package/dist/src/rollup/plugins/globals.esm.js.map +0 -1
- package/dist/src/rollup/plugins/globals.esm.min.js +0 -2
- package/dist/src/rollup/plugins/globals.esm.min.js.map +0 -1
- package/dist/src/rollup/plugins/skip.esm.js +0 -16
- package/dist/src/rollup/plugins/skip.esm.js.map +0 -1
- package/dist/src/rollup/plugins/skip.esm.min.js +0 -2
- package/dist/src/rollup/plugins/skip.esm.min.js.map +0 -1
- package/dist/src/rollup/utils/commonOptions.esm.js +0 -10
- package/dist/src/rollup/utils/commonOptions.esm.js.map +0 -1
- package/dist/src/rollup/utils/commonOptions.esm.min.js +0 -2
- package/dist/src/rollup/utils/commonOptions.esm.min.js.map +0 -1
- package/dist/src/rollup/utils/externalResolver.esm.js +0 -10
- package/dist/src/rollup/utils/externalResolver.esm.js.map +0 -1
- package/dist/src/rollup/utils/externalResolver.esm.min.js +0 -2
- package/dist/src/rollup/utils/externalResolver.esm.min.js.map +0 -1
- package/dist/src/rollup/utils/globalResolver.esm.js +0 -26
- package/dist/src/rollup/utils/globalResolver.esm.js.map +0 -1
- package/dist/src/rollup/utils/globalResolver.esm.min.js +0 -2
- package/dist/src/rollup/utils/globalResolver.esm.min.js.map +0 -1
- package/dist/src/rollup/utils/withMinify.esm.js +0 -15
- package/dist/src/rollup/utils/withMinify.esm.js.map +0 -1
- package/dist/src/rollup/utils/withMinify.esm.min.js +0 -2
- package/dist/src/rollup/utils/withMinify.esm.min.js.map +0 -1
- package/dist/src/utils/filterSupport.esm.js.map +0 -1
- package/dist/src/utils/filterSupport.esm.min.js.map +0 -1
- /package/dist/{src/utils → utils}/filterSupport.esm.js +0 -0
- /package/dist/{src/utils → utils}/filterSupport.esm.min.js +0 -0
@@ -1,12 +1,10 @@
|
|
1
1
|
import * as childProcess from 'node:child_process';
|
2
2
|
import fs from 'node:fs';
|
3
3
|
import path from 'node:path';
|
4
|
-
import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
|
5
|
-
import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages';
|
6
4
|
import { program } from 'commander';
|
7
|
-
import { load } from 'js-yaml';
|
8
5
|
import { actionRestore, actionDone } from '../inner.esm.js';
|
9
6
|
import { mergePackageJson } from '../merge-package-json.esm.js';
|
7
|
+
import { getSelectedProjectsGraph } from '../utils/filterSupport.esm.js';
|
10
8
|
|
11
9
|
const FILE_TEMPLATE = (manifest) => `
|
12
10
|
const pkg = ${JSON.stringify(manifest, null, 2)}
|
@@ -18,41 +16,21 @@ const templateArg = jiek.templateArgFilePath
|
|
18
16
|
}
|
19
17
|
module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/index.ts" : "jiek/rollup"}').template(templateArg, pkg)
|
20
18
|
`.trimStart();
|
21
|
-
program.command("build").
|
19
|
+
program.command("build").action(async () => {
|
22
20
|
actionRestore();
|
23
|
-
const
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
throw new Error("root path is workspace root, please provide a filter");
|
21
|
+
const {
|
22
|
+
wd,
|
23
|
+
value = {}
|
24
|
+
} = await getSelectedProjectsGraph() ?? {};
|
25
|
+
if (Object.keys(value).length === 0) {
|
26
|
+
throw new Error("no package found");
|
30
27
|
}
|
31
|
-
if (root !== wd && !filter) {
|
32
|
-
const packageJSONIsExist = fs.existsSync(path.resolve(root, "package.json"));
|
33
|
-
if (!packageJSONIsExist) {
|
34
|
-
throw new Error("root path is not workspace root, please provide a filter");
|
35
|
-
}
|
36
|
-
const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, "package.json"), "utf-8"));
|
37
|
-
if (!packageJSON.name) {
|
38
|
-
throw new Error("root path is not workspace root, please provide a filter");
|
39
|
-
}
|
40
|
-
filter = packageJSON.name;
|
41
|
-
}
|
42
|
-
const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
|
43
|
-
filter: filter ?? "",
|
44
|
-
followProdDepsOnly: true
|
45
|
-
}], {
|
46
|
-
prefix: root,
|
47
|
-
workspaceDir: wd,
|
48
|
-
patterns: pnpmWorkspace.packages
|
49
|
-
});
|
50
28
|
const jiekTempDir = (...paths) => path.resolve(wd, "node_modules/.jiek", ...paths);
|
51
29
|
if (!fs.existsSync(jiekTempDir()))
|
52
30
|
fs.mkdirSync(jiekTempDir());
|
53
31
|
const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
54
32
|
let i = 0;
|
55
|
-
for (const [dir,
|
33
|
+
for (const [dir, manifest] of Object.entries(value)) {
|
56
34
|
const newManifest = mergePackageJson(manifest, dir);
|
57
35
|
const escapeManifestName = manifest.name?.replace(/^@/g, "").replace(/\//g, "+");
|
58
36
|
const configFile = jiekTempDir(
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"build.esm.js","sources":["../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport {
|
1
|
+
{"version":3,"file":"build.esm.js","sources":["../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { 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"],"names":[],"mappings":";;;;;;;;AAUA,MAAM,aAAA,GAAgB,CAAC,QAAsB,KAAA,CAAA;AAAA,YAAA,EAC/B,IAAK,CAAA,SAAA,CAAU,QAAU,EAAA,IAAA,EAAM,CAAC,CAAC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAA,EAQ7C,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,MAAA,GACrB,6BACA,aACN,CAAA;AAAA,CAAA,CACE,SAAU,EAAA,CAAA;AAEZ,OAAA,CACG,OAAQ,CAAA,OAAO,CACf,CAAA,MAAA,CAAO,YAAY;AAClB,EAAc,aAAA,EAAA,CAAA;AACd,EAAM,MAAA;AAAA,IACJ,EAAA;AAAA,IAAI,QAAQ,EAAC;AAAA,GACX,GAAA,MA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C,MAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,kBAAkB,CAAA,CAAA;AACvD,MAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,OAAA,CAAQ,yBAAyB,CAAA,CAAA;AAC5D,MAAS,MAAA,GAAA,CAAA,cAAA,EAAiB,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA,CAAA,CAAA,CAAA;AAAA,KACzD;AAEA,IAAA,YAAA,CAAa,SAAS,CAAG,EAAA,MAAM,GAAG,gBAAgB,CAAA,IAAA,EAAO,UAAU,CAAI,CAAA,EAAA;AAAA,MACrE,GAAK,EAAA,GAAA;AAAA,MAAK,KAAO,EAAA,SAAA;AAAA,KAClB,CAAA,CAAA;AAAA,GACH;AAEA,EAAW,UAAA,EAAA,CAAA;AACb,CAAC,CAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import*as e from"node:child_process";import r from"node:fs";import o from"node:path";import{
|
1
|
+
import*as e from"node:child_process";import r from"node:fs";import o from"node:path";import{program as t}from"commander";import{actionRestore as i,actionDone as s}from"../inner.esm.min.js";import{mergePackageJson as n}from"../merge-package-json.esm.min.js";import{getSelectedProjectsGraph as l}from"../utils/filterSupport.esm.min.js";const m=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();t.command("build").action((async()=>{i();const{wd:t,value:p={}}=await l()??{};if(0===Object.keys(p).length)throw new Error("no package found");const c=(...e)=>o.resolve(t,"node_modules/.jiek",...e);r.existsSync(c())||r.mkdirSync(c());const a=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let d=0;for(const[o,t]of Object.entries(p)){const i=n(t,o),s=t.name?.replace(/^@/g,"").replace(/\//g,"+"),l=c(`${s??"anonymous-"+d++}.rollup.config.js`);r.writeFileSync(l,m(i));let p="";if("test"===process.env.NODE_ENV){p=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}e.execSync(`${p}${a} -c ${l}`,{cwd:o,stdio:"inherit"})}s()}));
|
2
2
|
//# sourceMappingURL=build.esm.min.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"build.esm.min.js","sources":["../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport {
|
1
|
+
{"version":3,"file":"build.esm.min.js","sources":["../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { 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"],"names":["FILE_TEMPLATE","manifest","JSON","stringify","process","env","NODE_ENV","trimStart","program","command","action","async","actionRestore","wd","value","getSelectedProjectsGraph","Object","keys","length","Error","jiekTempDir","paths","path","resolve","fs","existsSync","mkdirSync","rollupBinaryPath","require","replace","i","dir","entries","newManifest","mergePackageJson","escapeManifestName","name","configFile","writeFileSync","prefix","childProcess","execSync","cwd","stdio","actionDone"],"mappings":"8UAUA,MAAMA,EAAiBC,GAAsB,iBAC/BC,KAAKC,UAAUF,EAAU,KAAM,8LAQlB,SAAzBG,QAAQC,IAAIC,SACR,2BACA,+CAEJC,YAEFC,EACGC,QAAQ,SACRC,QAAOC,UACQC,IACR,MAAAC,GACJA,EAAAC,MAAIA,EAAQ,CAAC,SACLC,KAA8B,GAExC,GAAkC,IAA9BC,OAAOC,KAAKH,GAAOI,OACf,MAAA,IAAIC,MAAM,oBAEZ,MAAAC,EAAc,IAAIC,IAAoBC,EAAKC,QAAQV,EAAI,wBAAyBQ,GACjFG,EAAGC,WAAWL,MAAmBI,EAAAE,UAAUN,KAEhD,MAAMO,EAAmBC,QAAQL,QAAQ,UACtCM,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAYC,EAAK9B,KAAae,OAAOgB,QAAQlB,GAAQ,CAC7C,MAAAmB,EAAcC,EAAiBjC,EAAU8B,GAEzCI,EAAqBlC,EAASmC,MAAMP,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtEQ,EAAajB,EACjB,GAAGe,GAAsB,aAAaL,wBAExCN,EAAGc,cAAcD,EAAYrC,EAAciC,IAC3C,IAAIM,EAAS,GACT,GAAyB,SAAzBnC,QAAQC,IAAIC,SAAqB,CAG1BiC,EAAA,iBAFYX,QAAQL,QAAQ,0BAClBK,QAAQL,QAAQ,6BAErC,CAEAiB,EAAaC,SAAS,GAAGF,IAASZ,QAAuBU,IAAc,CACrEK,IAAKX,EAAKY,MAAO,WAErB,CAEWC,GAAA"}
|
@@ -1,35 +1,29 @@
|
|
1
1
|
import fs from 'node:fs';
|
2
2
|
import path from 'node:path';
|
3
3
|
import { bump } from '@jiek/utils/bumper';
|
4
|
-
import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
|
5
|
-
import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages';
|
6
4
|
import * as childProcess from 'child_process';
|
7
5
|
import { program } from 'commander';
|
8
6
|
import { actionRestore, actionDone } from '../inner.esm.js';
|
9
7
|
import { mergePackageJson } from '../merge-package-json.esm.js';
|
8
|
+
import { getSelectedProjectsGraph } from '../utils/filterSupport.esm.js';
|
10
9
|
|
11
|
-
program.command("publish").aliases(["pub", "p"]).option("--
|
10
|
+
program.command("publish").aliases(["pub", "p"]).option("--bumper <bumper>", "bump version", "patch").action(async ({ bumper, ...options }) => {
|
12
11
|
actionRestore();
|
13
|
-
const
|
14
|
-
const
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
}], {
|
19
|
-
prefix: root,
|
20
|
-
workspaceDir: wd,
|
21
|
-
patterns: ["packages/*"]
|
22
|
-
});
|
12
|
+
const { value = {} } = await getSelectedProjectsGraph() ?? {};
|
13
|
+
const selectedProjectsGraphEntries = Object.entries(value);
|
14
|
+
if (selectedProjectsGraphEntries.length === 0) {
|
15
|
+
throw new Error("no packages selected");
|
16
|
+
}
|
23
17
|
const mainfests = [];
|
24
|
-
|
18
|
+
selectedProjectsGraphEntries.forEach(([dir, manifest]) => {
|
25
19
|
mainfests.push([
|
26
20
|
dir,
|
27
21
|
mergePackageJson(manifest, dir)
|
28
22
|
]);
|
29
23
|
});
|
30
|
-
const passArgs = Object.entries(options).reduce((acc, [key,
|
31
|
-
if (
|
32
|
-
acc.push(`--${key}`,
|
24
|
+
const passArgs = Object.entries(options).reduce((acc, [key, value2]) => {
|
25
|
+
if (value2) {
|
26
|
+
acc.push(`--${key}`, value2);
|
33
27
|
}
|
34
28
|
return acc;
|
35
29
|
}, []);
|
@@ -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
|
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":";;;;;;;;;AAYA,OACG,CAAA,OAAA,CAAQ,SAAS,CACjB,CAAA,OAAA,CAAQ,CAAC,KAAO,EAAA,GAAG,CAAC,CACpB,CAAA,MAAA,CAAO,qBAAqB,cAAgB,EAAA,OAAO,EACnD,MAAO,CAAA,OAAO,EAAE,MAAQ,EAAA,GAAG,SAItB,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,sBAAsB,CAAA,CAAA;AAAA,GACxC;AACA,EAAA,MAAM,YAA0C,EAAC,CAAA;AACjD,EAAA,4BAAA,CACG,OAAQ,CAAA,CAAC,CAAC,GAAA,EAAK,QAAQ,CAAM,KAAA;AAC5B,IAAA,SAAA,CAA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,CAAA,GAAG,CAAG,EAAA;AAAA,QACzG,GAAK,EAAA,GAAA;AAAA,QACL,KAAO,EAAA,SAAA;AAAA,OACR,CAAA,CAAA;AACD,MAAM,MAAA,cAAA,GAAiB,IAAK,CAAA,KAAA,CAAM,EAAG,CAAA,YAAA,CAAa,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,kBAAkB,CAAG,EAAA,OAAO,CAAC,CAAA,CAAA;AAC9F,MAAA,cAAA,CAAe,OAAU,GAAA,UAAA,CAAA;AACzB,MAAG,EAAA,CAAA,aAAA,CAAc,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,kBAAkB,CAAG,EAAA,IAAA,CAAK,SAAU,CAAA,cAAA,EAAgB,IAAM,EAAA,CAAC,CAAC,CAAA,CAAA;AAAA,KAC5F,SAAA;AACA,MAAA,EAAA,CAAG,UAAW,CAAA,IAAA,CAAK,IAAK,CAAA,GAAA,EAAK,cAAc,CAAC,CAAA,CAAA;AAC5C,MAAG,EAAA,CAAA,UAAA,CAAW,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,kBAAkB,GAAG,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,cAAc,CAAC,CAAA,CAAA;AAAA,KAClF;AAAA,GACF;AACA,EAAW,UAAA,EAAA,CAAA;AACb,CAAC,CAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import
|
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()}));
|
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
|
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"}
|
package/dist/index.esm.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import './
|
2
|
-
import './
|
3
|
-
import './
|
1
|
+
import './utils/filterSupport.esm.js';
|
2
|
+
import './commands/publish.esm.js';
|
3
|
+
import './commands/build.esm.js';
|
4
4
|
import { program } from 'commander';
|
5
|
-
import pkg from './package.json.esm.js';
|
6
5
|
|
6
|
+
const pkg = require("../package.json");
|
7
7
|
program.version(pkg.version).description(pkg.description).option("--root <root>", "root path");
|
8
8
|
program.parse(process.argv);
|
9
9
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["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":[],"mappings":";;;;;AAOA,MAAM,GAAA,GAAM,QAAQ,iBAAiB,CAAA,CAAA;AAErC,OACG,CAAA,OAAA,CAAQ,GAAI,CAAA,OAAO,CACnB,CAAA,WAAA,CAAY,IAAI,WAAW,CAAA,CAC3B,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AAEtC,OAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA"}
|
package/dist/index.esm.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import"./
|
1
|
+
import"./utils/filterSupport.esm.min.js";import"./commands/publish.esm.min.js";import"./commands/build.esm.min.js";import{program as o}from"commander";const r=require("../package.json");o.version(r.version).description(r.description).option("--root <root>","root path"),o.parse(process.argv);
|
2
2
|
//# sourceMappingURL=index.esm.min.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.esm.min.js","sources":["../src/index.ts"],"sourcesContent":["import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\
|
1
|
+
{"version":3,"file":"index.esm.min.js","sources":["../src/index.ts"],"sourcesContent":["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":["pkg","require","program","version","description","option","parse","process","argv"],"mappings":"uJAOA,MAAMA,EAAMC,QAAQ,mBAEpBC,EACGC,QAAQH,EAAIG,SACZC,YAAYJ,EAAII,aAChBC,OAAO,gBAAiB,aAE3BH,EAAQI,MAAMC,QAAQC"}
|
package/dist/index.iife.js
CHANGED
@@ -205,62 +205,7 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
205
205
|
actionDone();
|
206
206
|
});
|
207
207
|
|
208
|
-
|
209
|
-
var version = "0.1.12";
|
210
|
-
var description = "YiJie's personal kits.";
|
211
|
-
var bin = {
|
212
|
-
jiek: "bin/jiek.js",
|
213
|
-
"jiek-dev": "bin/jiek-dev.js"
|
214
|
-
};
|
215
|
-
var jiek = {
|
216
|
-
inputs: [
|
217
|
-
"index.ts",
|
218
|
-
"rollup/index.ts"
|
219
|
-
]
|
220
|
-
};
|
221
|
-
var scripts = {
|
222
|
-
build: "jiek-dev build"
|
223
|
-
};
|
224
|
-
var dependencies = {
|
225
|
-
"@jiek/pkger": "workspace:^*",
|
226
|
-
"@jiek/utils": "workspace:^*",
|
227
|
-
"@rollup/plugin-json": "^6.0.1",
|
228
|
-
"@rollup/plugin-terser": "^0.4.4",
|
229
|
-
autoprefixer: "^10.4.16",
|
230
|
-
commander: "^12.0.0",
|
231
|
-
"js-yaml": "^4.1.0",
|
232
|
-
rollup: "^4.1.5",
|
233
|
-
"rollup-plugin-copy": "^3.5.0",
|
234
|
-
"rollup-plugin-dts": "^6.1.0",
|
235
|
-
"rollup-plugin-esbuild": "^6.1.0",
|
236
|
-
"rollup-plugin-postcss": "^4.0.2"
|
237
|
-
};
|
238
|
-
var optionalDependencies = {
|
239
|
-
"@pnpm/filter-workspace-packages": "^7.2.13"
|
240
|
-
};
|
241
|
-
var devDependencies = {
|
242
|
-
"@npm/types": "^1.0.2",
|
243
|
-
"@pnpm/workspace.pkgs-graph": "^2.0.15",
|
244
|
-
"@pnpm/filter-workspace-packages": "^7.2.13",
|
245
|
-
"@types/js-yaml": "^4.0.9",
|
246
|
-
"esbuild-register": "^3.5.0"
|
247
|
-
};
|
248
|
-
var files = [
|
249
|
-
"dist"
|
250
|
-
];
|
251
|
-
var pkg = {
|
252
|
-
name: name,
|
253
|
-
version: version,
|
254
|
-
description: description,
|
255
|
-
bin: bin,
|
256
|
-
jiek: jiek,
|
257
|
-
scripts: scripts,
|
258
|
-
dependencies: dependencies,
|
259
|
-
optionalDependencies: optionalDependencies,
|
260
|
-
devDependencies: devDependencies,
|
261
|
-
files: files
|
262
|
-
};
|
263
|
-
|
208
|
+
const pkg = require("../package.json");
|
264
209
|
commander.program.version(pkg.version).description(pkg.description).option("--root <root>", "root path");
|
265
210
|
commander.program.parse(process.argv);
|
266
211
|
|
package/dist/index.iife.js.map
CHANGED
@@ -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\nimport pkg from '../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,GAAA,UAAA,GACAA,qBAAK,CAAA,OAAA,CAAQ,QAAQ,GAAI,EAAA,EAAG,UAAU,CAAA,GACxC,QAAQ,GAAI,EAAA,CAAA;EAChB,EAAA,IAAI,YAAe,GAAA,KAAA,CAAA;EACnB,EAAI,IAAA,EAAA,CAAA;EACJ,EAAI,IAAA;EACF,IAAK,EAAA,GAAAC,+BAAA,CAAgB,MAAM,IAAI,CAAA,CAAA;EAAA,W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Aa,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACvDHV,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 { 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,GAAA,UAAA,GACAA,qBAAK,CAAA,OAAA,CAAQ,QAAQ,GAAI,EAAA,EAAG,UAAU,CAAA,GACxC,QAAQ,GAAI,EAAA,CAAA;EAChB,EAAA,IAAI,YAAe,GAAA,KAAA,CAAA;EACnB,EAAI,IAAA,E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,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;;;;;;"}
|
package/dist/index.iife.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,r,t,o,a,n,s,i,l
|
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);
|
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\nimport pkg from '../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,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,UAAKV,QAAQS,EAAM,gBAAiB,UAC/E,IAACmB,EAAYG,KACT,MAAA,IAAIL,MAAM,4DAElBrB,EAASuB,EAAYG,IACvB,CACA,MAAMC,sBAAEA,SAAgCC,EAAAA,sBAAsBnB,EAAI,CAAC,CACjET,OAAQA,GAAU,GAClB6B,oBAAoB,IAClB,CACFC,OAAQ1B,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WoE,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,8CCrDZ8C,EAAAvF,QAAAsE,QAAQ2B,GACRC,YAAYD,GACZ3C,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 { 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,EA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