jiek 0.1.11 → 0.1.12-alpha.2
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 +3 -0
- 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 +109 -58
- 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 +111 -60
- 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/utils/commonOptions.esm.js +1 -0
- package/dist/rollup/utils/commonOptions.esm.js.map +1 -1
- package/dist/rollup/utils/commonOptions.esm.min.js +1 -1
- package/dist/rollup/utils/commonOptions.esm.min.js.map +1 -1
- package/dist/rollup.esm.js +8 -2
- package/dist/rollup.esm.js.map +1 -1
- package/dist/rollup.esm.min.js +1 -1
- package/dist/rollup.esm.min.js.map +1 -1
- package/dist/rollup.iife.js +22 -9
- package/dist/rollup.iife.js.map +1 -1
- package/dist/rollup.iife.min.js +1 -1
- package/dist/rollup.iife.min.js.map +1 -1
- package/dist/rollup.umd.js +24 -11
- package/dist/rollup.umd.js.map +1 -1
- package/dist/rollup.umd.min.js +1 -1
- package/dist/rollup.umd.min.js.map +1 -1
- package/dist/utils/filterSupport.esm.js +78 -0
- package/dist/utils/filterSupport.esm.js.map +1 -0
- package/dist/utils/filterSupport.esm.min.js +2 -0
- package/dist/utils/filterSupport.esm.min.js.map +1 -0
- package/package.json +16 -9
@@ -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,MAAM,wBAAyB,EAAA,IAAK,EAAC,CAAA;AAEzC,EAAA,IAAI,MAAO,CAAA,IAAA,CAAK,KAAK,CAAA,CAAE,WAAW,CAAG,EAAA;AACnC,IAAM,MAAA,IAAI,MAAM,kBAAkB,CAAA,CAAA;AAAA,GACpC;AACA,EAAM,MAAA,WAAA,GAAc,IAAI,KAAoB,KAAA,IAAA,CAAK,QAAQ,EAAI,EAAA,oBAAA,EAAsB,GAAG,KAAK,CAAA,CAAA;AAC3F,EAAA,IAAI,CAAC,EAAA,CAAG,UAAW,CAAA,WAAA,EAAa,CAAA;AAAG,IAAG,EAAA,CAAA,SAAA,CAAU,aAAa,CAAA,CAAA;AAE7D,EAAA,MAAM,mBAAmB,OAAQ,CAAA,OAAA,CAAQ,QAAQ,CAC9C,CAAA,OAAA,CAAQ,oBAAoB,iBAAiB,CAAA,CAAA;AAChD,EAAA,IAAI,CAAI,GAAA,CAAA,CAAA;AACR,EAAA,KAAA,MAAW,CAAC,GAAK,EAAA,QAAQ,KAAK,MAAO,CAAA,OAAA,CAAQ,KAAK,CAAG,EAAA;AACnD,IAAM,MAAA,WAAA,GAAc,gBAAiB,CAAA,QAAA,EAAU,GAAG,CAAA,CAAA;AAElD,IAAM,MAAA,kBAAA,GAAqB,SAAS,IAAM,EAAA,OAAA,CAAQ,OAAO,EAAE,CAAA,CAAE,OAAQ,CAAA,KAAA,EAAO,GAAG,CAAA,CAAA;AAC/E,IAAA,MAAM,UAAa,GAAA,WAAA;AAAA,MACjB,CAAG,EAAA,kBAAA,IAAsB,CAAa,UAAA,EAAA,CAAA,EAAG,CAAE,CAAA,CAAA,iBAAA,CAAA;AAAA,KAC7C,CAAA;AACA,IAAA,EAAA,CAAG,aAAc,CAAA,UAAA,EAAY,aAAc,CAAA,WAAW,CAAC,CAAA,CAAA;AACvD,IAAA,IAAI,MAAS,GAAA,EAAA,CAAA;AACb,IAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,MAAQ,EAAA;AACnC,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":"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"}
|
@@ -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,6 +1,9 @@
|
|
1
|
+
import './utils/filterSupport.esm.js';
|
1
2
|
import './commands/publish.esm.js';
|
2
3
|
import './commands/build.esm.js';
|
3
4
|
import { program } from 'commander';
|
4
5
|
|
6
|
+
const pkg = require("../package.json");
|
7
|
+
program.version(pkg.version).description(pkg.description).option("--root <root>", "root path");
|
5
8
|
program.parse(process.argv);
|
6
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 './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":[],"mappings":"
|
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"./commands/publish.esm.min.js";import"./commands/build.esm.min.js";import{program as
|
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 './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["program","parse","process","argv"],"mappings":"
|
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
@@ -1,7 +1,10 @@
|
|
1
|
-
(function (fs, path,
|
1
|
+
(function (fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, pkger, childProcess$1) {
|
2
2
|
'use strict';
|
3
3
|
|
4
|
-
function
|
4
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
5
|
+
|
6
|
+
function _interopNamespace(e) {
|
7
|
+
if (e && e.__esModule) return e;
|
5
8
|
var n = Object.create(null);
|
6
9
|
if (e) {
|
7
10
|
Object.keys(e).forEach(function (k) {
|
@@ -18,8 +21,79 @@
|
|
18
21
|
return Object.freeze(n);
|
19
22
|
}
|
20
23
|
|
21
|
-
var
|
22
|
-
var
|
24
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
25
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
26
|
+
var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
|
27
|
+
var childProcess__namespace$1 = /*#__PURE__*/_interopNamespace(childProcess$1);
|
28
|
+
|
29
|
+
let type = "";
|
30
|
+
try {
|
31
|
+
require.resolve("@pnpm/filter-workspace-packages");
|
32
|
+
type = "pnpm";
|
33
|
+
} catch {
|
34
|
+
}
|
35
|
+
if (type !== "") {
|
36
|
+
commander.program.option("-f, --filter <filter>", "filter packages");
|
37
|
+
}
|
38
|
+
async function getSelectedProjectsGraph() {
|
39
|
+
let filter = commander.program.getOptionValue("filter");
|
40
|
+
const rootOption = commander.program.getOptionValue("root");
|
41
|
+
const root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : process.cwd();
|
42
|
+
let notWorkspace = false;
|
43
|
+
let wd;
|
44
|
+
try {
|
45
|
+
wd = getWorkspaceDir.getWorkspaceDir(root, type);
|
46
|
+
} catch (e) {
|
47
|
+
if ("message" in e && e.message === "workspace root not found") {
|
48
|
+
wd = root;
|
49
|
+
notWorkspace = true;
|
50
|
+
} else {
|
51
|
+
throw e;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
if (!notWorkspace && type === "pnpm") {
|
55
|
+
const pnpmWorkspaceFilePath = path__default.default.resolve(wd, "pnpm-workspace.yaml");
|
56
|
+
const pnpmWorkspaceFileContent = fs__default.default.readFileSync(pnpmWorkspaceFilePath, "utf-8");
|
57
|
+
const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
|
58
|
+
if (root === wd && !filter) {
|
59
|
+
throw new Error("root path is workspace root, please provide a filter");
|
60
|
+
}
|
61
|
+
if (root !== wd && !filter) {
|
62
|
+
const packageJSONIsExist = fs__default.default.existsSync(path__default.default.resolve(root, "package.json"));
|
63
|
+
if (!packageJSONIsExist) {
|
64
|
+
throw new Error("root path is not workspace root, please provide a filter");
|
65
|
+
}
|
66
|
+
const packageJSON = JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(root, "package.json"), "utf-8"));
|
67
|
+
if (!packageJSON.name) {
|
68
|
+
throw new Error("root path is not workspace root, please provide a filter");
|
69
|
+
}
|
70
|
+
filter = packageJSON.name;
|
71
|
+
}
|
72
|
+
const { selectedProjectsGraph } = await filterWorkspacePackages.filterPackagesFromDir(wd, [{
|
73
|
+
filter: filter ?? "",
|
74
|
+
followProdDepsOnly: true
|
75
|
+
}], {
|
76
|
+
prefix: root,
|
77
|
+
workspaceDir: wd,
|
78
|
+
patterns: pnpmWorkspace.packages
|
79
|
+
});
|
80
|
+
return {
|
81
|
+
wd,
|
82
|
+
root,
|
83
|
+
value: Object.entries(selectedProjectsGraph).reduce((acc, [key, value]) => {
|
84
|
+
acc[key] = value.package.manifest;
|
85
|
+
return acc;
|
86
|
+
}, {})
|
87
|
+
};
|
88
|
+
}
|
89
|
+
return {
|
90
|
+
wd,
|
91
|
+
root,
|
92
|
+
value: {
|
93
|
+
[wd]: JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(wd, "package.json"), "utf-8"))
|
94
|
+
}
|
95
|
+
};
|
96
|
+
}
|
23
97
|
|
24
98
|
let resolve;
|
25
99
|
function actionDone() {
|
@@ -41,28 +115,23 @@
|
|
41
115
|
};
|
42
116
|
}
|
43
117
|
|
44
|
-
commander.program.command("publish").aliases(["pub", "p"]).option("--
|
118
|
+
commander.program.command("publish").aliases(["pub", "p"]).option("--bumper <bumper>", "bump version", "patch").action(async ({ bumper: bumper$1, ...options }) => {
|
45
119
|
actionRestore();
|
46
|
-
const
|
47
|
-
const
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
}], {
|
52
|
-
prefix: root,
|
53
|
-
workspaceDir: wd,
|
54
|
-
patterns: ["packages/*"]
|
55
|
-
});
|
120
|
+
const { value = {} } = await getSelectedProjectsGraph() ?? {};
|
121
|
+
const selectedProjectsGraphEntries = Object.entries(value);
|
122
|
+
if (selectedProjectsGraphEntries.length === 0) {
|
123
|
+
throw new Error("no packages selected");
|
124
|
+
}
|
56
125
|
const mainfests = [];
|
57
|
-
|
126
|
+
selectedProjectsGraphEntries.forEach(([dir, manifest]) => {
|
58
127
|
mainfests.push([
|
59
128
|
dir,
|
60
129
|
mergePackageJson(manifest, dir)
|
61
130
|
]);
|
62
131
|
});
|
63
|
-
const passArgs = Object.entries(options).reduce((acc, [key,
|
64
|
-
if (
|
65
|
-
acc.push(`--${key}`,
|
132
|
+
const passArgs = Object.entries(options).reduce((acc, [key, value2]) => {
|
133
|
+
if (value2) {
|
134
|
+
acc.push(`--${key}`, value2);
|
66
135
|
}
|
67
136
|
return acc;
|
68
137
|
}, []);
|
@@ -72,20 +141,20 @@
|
|
72
141
|
...m,
|
73
142
|
version: newVersion
|
74
143
|
};
|
75
|
-
|
76
|
-
|
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));
|
77
146
|
console.log(newManifest);
|
78
147
|
try {
|
79
148
|
childProcess__namespace.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
|
80
149
|
cwd: dir,
|
81
150
|
stdio: "inherit"
|
82
151
|
});
|
83
|
-
const oldPackageJson = JSON.parse(
|
152
|
+
const oldPackageJson = JSON.parse(fs__default.default.readFileSync(path__default.default.join(dir, "package.json.bak"), "utf-8"));
|
84
153
|
oldPackageJson.version = newVersion;
|
85
|
-
|
154
|
+
fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), JSON.stringify(oldPackageJson, null, 2));
|
86
155
|
} finally {
|
87
|
-
|
88
|
-
|
156
|
+
fs__default.default.unlinkSync(path__default.default.join(dir, "package.json"));
|
157
|
+
fs__default.default.renameSync(path__default.default.join(dir, "package.json.bak"), path__default.default.join(dir, "package.json"));
|
89
158
|
}
|
90
159
|
}
|
91
160
|
actionDone();
|
@@ -101,47 +170,27 @@ const templateArg = jiek.templateArgFilePath
|
|
101
170
|
}
|
102
171
|
module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/index.ts" : "jiek/rollup"}').template(templateArg, pkg)
|
103
172
|
`.trimStart();
|
104
|
-
commander.program.command("build").
|
173
|
+
commander.program.command("build").action(async () => {
|
105
174
|
actionRestore();
|
106
|
-
const
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
throw new Error("root path is workspace root, please provide a filter");
|
113
|
-
}
|
114
|
-
if (root !== wd && !filter) {
|
115
|
-
const packageJSONIsExist = fs.existsSync(path.resolve(root, "package.json"));
|
116
|
-
if (!packageJSONIsExist) {
|
117
|
-
throw new Error("root path is not workspace root, please provide a filter");
|
118
|
-
}
|
119
|
-
const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, "package.json"), "utf-8"));
|
120
|
-
if (!packageJSON.name) {
|
121
|
-
throw new Error("root path is not workspace root, please provide a filter");
|
122
|
-
}
|
123
|
-
filter = packageJSON.name;
|
175
|
+
const {
|
176
|
+
wd,
|
177
|
+
value = {}
|
178
|
+
} = await getSelectedProjectsGraph() ?? {};
|
179
|
+
if (Object.keys(value).length === 0) {
|
180
|
+
throw new Error("no package found");
|
124
181
|
}
|
125
|
-
const
|
126
|
-
|
127
|
-
|
128
|
-
}], {
|
129
|
-
prefix: root,
|
130
|
-
workspaceDir: wd,
|
131
|
-
patterns: pnpmWorkspace.packages
|
132
|
-
});
|
133
|
-
const jiekTempDir = (...paths) => path.resolve(wd, "node_modules/.jiek", ...paths);
|
134
|
-
if (!fs.existsSync(jiekTempDir()))
|
135
|
-
fs.mkdirSync(jiekTempDir());
|
182
|
+
const jiekTempDir = (...paths) => path__default.default.resolve(wd, "node_modules/.jiek", ...paths);
|
183
|
+
if (!fs__default.default.existsSync(jiekTempDir()))
|
184
|
+
fs__default.default.mkdirSync(jiekTempDir());
|
136
185
|
const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
137
186
|
let i = 0;
|
138
|
-
for (const [dir,
|
187
|
+
for (const [dir, manifest] of Object.entries(value)) {
|
139
188
|
const newManifest = mergePackageJson(manifest, dir);
|
140
189
|
const escapeManifestName = manifest.name?.replace(/^@/g, "").replace(/\//g, "+");
|
141
190
|
const configFile = jiekTempDir(
|
142
191
|
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
143
192
|
);
|
144
|
-
|
193
|
+
fs__default.default.writeFileSync(configFile, FILE_TEMPLATE(newManifest));
|
145
194
|
let prefix = "";
|
146
195
|
if (process.env.NODE_ENV === "test") {
|
147
196
|
const registerPath = require.resolve("esbuild-register");
|
@@ -156,7 +205,9 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
156
205
|
actionDone();
|
157
206
|
});
|
158
207
|
|
208
|
+
const pkg = require("../package.json");
|
209
|
+
commander.program.version(pkg.version).description(pkg.description).option("--root <root>", "root path");
|
159
210
|
commander.program.parse(process.argv);
|
160
211
|
|
161
|
-
})(fs, path,
|
212
|
+
})(fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, pkger, childProcess$1);
|
162
213
|
//# sourceMappingURL=index.iife.js.map
|