jiek 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.iife.js +24 -19
- 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 +24 -19
- 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 +1 -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 +15 -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 +17 -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/package.json +1 -1
package/dist/index.iife.js
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
(function (fs, path, bumper, getWorkspaceDir, filterWorkspacePackages, childProcess, commander, pkger, childProcess$1, jsYaml) {
|
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,10 @@
|
|
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);
|
23
28
|
|
24
29
|
let resolve;
|
25
30
|
function actionDone() {
|
@@ -43,7 +48,7 @@
|
|
43
48
|
|
44
49
|
commander.program.command("publish").aliases(["pub", "p"]).option("--filter <filter>", "filter packages").option("--root <root>", "root path").option("--bumper <bumper>", "bump version", "patch").action(async ({ root: rootOption, filter, bumper: bumper$1, ...options }) => {
|
45
50
|
actionRestore();
|
46
|
-
const root = rootOption ?
|
51
|
+
const root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : process.cwd();
|
47
52
|
const wd = getWorkspaceDir.getWorkspaceDir(root);
|
48
53
|
const { selectedProjectsGraph } = await filterWorkspacePackages.filterPackagesFromDir(wd, [{
|
49
54
|
filter: filter ?? "",
|
@@ -72,20 +77,20 @@
|
|
72
77
|
...m,
|
73
78
|
version: newVersion
|
74
79
|
};
|
75
|
-
|
76
|
-
|
80
|
+
fs__default.default.renameSync(path__default.default.join(dir, "package.json"), path__default.default.join(dir, "package.json.bak"));
|
81
|
+
fs__default.default.writeFileSync(path__default.default.join(dir, "package.json"), JSON.stringify(newManifest, null, 2));
|
77
82
|
console.log(newManifest);
|
78
83
|
try {
|
79
84
|
childProcess__namespace.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
|
80
85
|
cwd: dir,
|
81
86
|
stdio: "inherit"
|
82
87
|
});
|
83
|
-
const oldPackageJson = JSON.parse(
|
88
|
+
const oldPackageJson = JSON.parse(fs__default.default.readFileSync(path__default.default.join(dir, "package.json.bak"), "utf-8"));
|
84
89
|
oldPackageJson.version = newVersion;
|
85
|
-
|
90
|
+
fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), JSON.stringify(oldPackageJson, null, 2));
|
86
91
|
} finally {
|
87
|
-
|
88
|
-
|
92
|
+
fs__default.default.unlinkSync(path__default.default.join(dir, "package.json"));
|
93
|
+
fs__default.default.renameSync(path__default.default.join(dir, "package.json.bak"), path__default.default.join(dir, "package.json"));
|
89
94
|
}
|
90
95
|
}
|
91
96
|
actionDone();
|
@@ -103,20 +108,20 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
103
108
|
`.trimStart();
|
104
109
|
commander.program.command("build").option("--filter <filter>", "filter packages").option("--root <root>", "root path").action(async ({ root: rootOption, filter, ...options }) => {
|
105
110
|
actionRestore();
|
106
|
-
const root = rootOption ?
|
111
|
+
const root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : process.cwd();
|
107
112
|
const wd = getWorkspaceDir.getWorkspaceDir(root);
|
108
|
-
const pnpmWorkspaceFilePath =
|
109
|
-
const pnpmWorkspaceFileContent =
|
113
|
+
const pnpmWorkspaceFilePath = path__default.default.resolve(wd, "pnpm-workspace.yaml");
|
114
|
+
const pnpmWorkspaceFileContent = fs__default.default.readFileSync(pnpmWorkspaceFilePath, "utf-8");
|
110
115
|
const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
|
111
116
|
if (root === wd && !filter) {
|
112
117
|
throw new Error("root path is workspace root, please provide a filter");
|
113
118
|
}
|
114
119
|
if (root !== wd && !filter) {
|
115
|
-
const packageJSONIsExist =
|
120
|
+
const packageJSONIsExist = fs__default.default.existsSync(path__default.default.resolve(root, "package.json"));
|
116
121
|
if (!packageJSONIsExist) {
|
117
122
|
throw new Error("root path is not workspace root, please provide a filter");
|
118
123
|
}
|
119
|
-
const packageJSON = JSON.parse(
|
124
|
+
const packageJSON = JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(root, "package.json"), "utf-8"));
|
120
125
|
if (!packageJSON.name) {
|
121
126
|
throw new Error("root path is not workspace root, please provide a filter");
|
122
127
|
}
|
@@ -130,9 +135,9 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
130
135
|
workspaceDir: wd,
|
131
136
|
patterns: pnpmWorkspace.packages
|
132
137
|
});
|
133
|
-
const jiekTempDir = (...paths) =>
|
134
|
-
if (!
|
135
|
-
|
138
|
+
const jiekTempDir = (...paths) => path__default.default.resolve(wd, "node_modules/.jiek", ...paths);
|
139
|
+
if (!fs__default.default.existsSync(jiekTempDir()))
|
140
|
+
fs__default.default.mkdirSync(jiekTempDir());
|
136
141
|
const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
137
142
|
let i = 0;
|
138
143
|
for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {
|
@@ -141,7 +146,7 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
141
146
|
const configFile = jiekTempDir(
|
142
147
|
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
143
148
|
);
|
144
|
-
|
149
|
+
fs__default.default.writeFileSync(configFile, FILE_TEMPLATE(newManifest));
|
145
150
|
let prefix = "";
|
146
151
|
if (process.env.NODE_ENV === "test") {
|
147
152
|
const registerPath = require.resolve("esbuild-register");
|
package/dist/index.iife.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.iife.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\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 .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["pkger","program","bumper","getWorkspaceDir","filterPackagesFromDir","bump","childProcess","load"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAAA,IAAI,OAAA,CAAA;EAIG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AAA,CAAA;EACb,CAAC,CAAA;;AC5FHL,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
|
1
|
+
{"version":3,"file":"index.iife.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\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 .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["pkger","program","bumper","path","getWorkspaceDir","filterPackagesFromDir","bump","fs","childProcess","load"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA,IAAI,OAAA,CAAA;EAIG,SAAS,UAAa,GAAA;EAC3B,EAAQ,OAAA,EAAA,CAAA;EACV,CAAA;EAEO,SAAS,aAAgB,GAAA;EAC9B,EAAe,IAAI,OAAA,CAAc,CAAK,CAAA,KAAA,OAAA,GAAU,CAAC,CAAA,CAAA;EACnD;;ECNgB,SAAA,gBAAA,CAAiB,UAG9B,GAAa,EAAA;EACd,EAAM,MAAA;EAAA,IACJ,IAAA,EAAM,EAAE,MAAQ,EAAA,UAAA,EAAY,KAAK,CAAG,EAAA,GAAG,IAAK,EAAA,GAAI,EAAC;EAAA,IAAG,OAAA;EAAA,GAClD,GAAA,QAAA,CAAA;EACJ,EAAA,MAAM,SAAS,UACb,KAAA,KAAA,CAAM,OAAQ,CAAA,OAAO,IAAI,OAAU,GAAA,KAAA,CAAA,CAAA,CAAA;EAErC,EAAO,OAAA;EAAA,IACL,GAAG,QAAA;EAAA,IACH,GAAGA,WAAM,CAAA,EAAE,QAAQ,GAAK,EAAA,GAAG,MAAM,CAAA;EAAA,GACnC,CAAA;EACF;;ACLAC,mBAAA,CACG,OAAQ,CAAA,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,EAAY,aAAc,CAAA,WAAW,CAAC,CAAA,CAAA;EACvD,IAAA,IAAI,MAAS,GAAA,EAAA,CAAA;EACb,IAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,MAAQ,EAAA;EACnC,MAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,kBAAkB,CAAA,CAAA;EACvD,MAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,OAAA,CAAQ,yBAAyB,CAAA,CAAA;EAC5D,MAAS,MAAA,GAAA,CAAA,cAAA,EAAiB,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA,CAAA,CAAA,CAAA;EAAA,KACzD;EAEA,IAAAC,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;;AC5FHP,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
|
package/dist/index.iife.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,r,o,
|
1
|
+
!function(e,r,t,o,a,s,n,i,l,c){"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),k=u(s),g=u(l);let m;function j(){m()}function y(){new Promise((e=>m=e))}function b(e,r){const{jiek:{inputs:t,cwd:o,...a}={},exports:s}=e,n=t??(Array.isArray(s)?s:void 0);return{...e,...i.pkger({inputs:n,cwd:r,...a})}}n.program.command("publish").aliases(["pub","p"]).option("--filter <filter>","filter packages").option("--root <root>","root path").option("--bumper <bumper>","bump version","patch").action((async({root:e,filter:r,bumper:s,...n})=>{y();const i=e?d.default.isAbsolute(e)?e:d.default.resolve(process.cwd(),e):process.cwd(),l=o.getWorkspaceDir(i),{selectedProjectsGraph:c}=await a.filterPackagesFromDir(l,[{filter:r??"",followProdDepsOnly:!0}],{prefix:i,workspaceDir:l,patterns:["packages/*"]}),p=[];Object.entries(c).forEach((([,{package:{dir:e,manifest:r}}])=>{p.push([e,b(r,e)])}));const u=Object.entries(n).reduce(((e,[r,t])=>(t&&e.push(`--${r}`,t),e)),[]);for(const[e,r]of p){const o=t.bump(r.version,s),a={...r,version:o};f.default.renameSync(d.default.join(e,"package.json"),d.default.join(e,"package.json.bak")),f.default.writeFileSync(d.default.join(e,"package.json"),JSON.stringify(a,null,2)),console.log(a);try{k.execSync(["pnpm","publish","--access","public","--no-git-checks",...u].join(" "),{cwd:e,stdio:"inherit"});const r=JSON.parse(f.default.readFileSync(d.default.join(e,"package.json.bak"),"utf-8"));r.version=o,f.default.writeFileSync(d.default.join(e,"package.json.bak"),JSON.stringify(r,null,2))}finally{f.default.unlinkSync(d.default.join(e,"package.json")),f.default.renameSync(d.default.join(e,"package.json.bak"),d.default.join(e,"package.json"))}}j()}));const w=e=>`\nconst pkg = ${JSON.stringify(e,null,2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template(templateArg, pkg)\n`.trimStart();n.program.command("build").option("--filter <filter>","filter packages").option("--root <root>","root path").action((async({root:e,filter:r,...t})=>{y();const s=e?d.default.isAbsolute(e)?e:d.default.resolve(process.cwd(),e):process.cwd(),n=o.getWorkspaceDir(s),i=d.default.resolve(n,"pnpm-workspace.yaml"),l=f.default.readFileSync(i,"utf-8"),p=c.load(l);if(s===n&&!r)throw new Error("root path is workspace root, please provide a filter");if(s!==n&&!r){if(!f.default.existsSync(d.default.resolve(s,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const e=JSON.parse(f.default.readFileSync(d.default.resolve(s,"package.json"),"utf-8"));if(!e.name)throw new Error("root path is not workspace root, please provide a filter");r=e.name}const{selectedProjectsGraph:u}=await a.filterPackagesFromDir(n,[{filter:r??"",followProdDepsOnly:!0}],{prefix:s,workspaceDir:n,patterns:p.packages}),k=(...e)=>d.default.resolve(n,"node_modules/.jiek",...e);f.default.existsSync(k())||f.default.mkdirSync(k());const m=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let h=0;for(const[e,{package:{manifest:r}}]of Object.entries(u)){const t=b(r,e),o=r.name?.replace(/^@/g,"").replace(/\//g,"+"),a=k(`${o??"anonymous-"+h++}.rollup.config.js`);f.default.writeFileSync(a,w(t));let s="";if("test"===process.env.NODE_ENV){s=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}g.execSync(`${s}${m} -c ${a}`,{cwd:e,stdio:"inherit"})}j()})),n.program.parse(process.argv)}(fs,path,bumper,getWorkspaceDir,filterWorkspacePackages,childProcess,commander,pkger,childProcess$1,jsYaml);
|
2
2
|
//# sourceMappingURL=index.iife.min.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.iife.min.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\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 .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["resolve","actionDone","actionRestore","Promise","r","mergePackageJson","manifest","cwd","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","commander","program","command","aliases","option","action","async","root","rootOption","filter","bumper","options","path","isAbsolute","process","wd","getWorkspaceDir","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","mainfests","Object","entries","forEach","package","dir","push","passArgs","reduce","acc","key","value","m","newVersion","bump","version","newManifest","fs","renameSync","join","writeFileSync","JSON","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","parse","readFileSync","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","pnpmWorkspaceFilePath","pnpmWorkspaceFileContent","pnpmWorkspace","load","Error","existsSync","packageJSON","name","packages","jiekTempDir","paths","mkdirSync","rollupBinaryPath","require","replace","i","escapeManifestName","configFile","argv"],"mappings":"iUAAA,IAAIA,EAIG,SAASC,IACND,GACV,CAEO,SAASE,IACC,IAAIC,SAAmBC,GAAAJ,EAAUI,GAClD,CCNgB,SAAAC,EAAiBC,EAG9BC,GACK,MACJC,MAAQC,OAAQC,EAAYH,IAAKI,KAAMH,GAAS,CAAC,EAAAI,QAAGA,GAClDN,EACEG,EAASC,IACbG,MAAMC,QAAQF,GAAWA,OAAU,GAE9B,MAAA,IACFN,KACAS,EAAMA,MAAA,CAAEN,SAAQF,SAAQC,IAE/B,CCLAQ,EAAAC,QACGC,QAAQ,WACRC,QAAQ,CAAC,MAAO,MAChBC,OAAO,oBAAqB,mBAC5BA,OAAO,gBAAiB,aACxBA,OAAO,oBAAqB,eAAgB,SAC5CC,QAAOC,OAASC,KAAMC,EAAYC,SAAQC,OAAAA,KAAWC,MAKtCzB,IACd,MAAMqB,EAAOC,EACTI,EAAKC,WAAWL,GACdA,EACAI,EAAK5B,QAAQ8B,QAAQvB,MAAOiB,GAC9BM,QAAQvB,MACNwB,EAAKC,kBAAgBT,IACrBU,sBAAEA,SAAgCC,EAAAA,sBAAsBH,EAAI,CAAC,CACjEN,OAAQA,GAAU,GAClBU,oBAAoB,IAClB,CACFC,OAAQb,EACRc,aAAcN,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EAAYrB,EAAchB,IAC3C,IAAInB,EAAS,GACT,GAAyB,SAAzBN,QAAQ0C,IAAIC,SAAqB,CAG1BrC,EAAA,iBAFYoD,QAAQxF,QAAQ,0BAClBwF,QAAQxF,QAAQ,6BAErC,CAEAgE,EAAaC,SAAS,GAAG7B,IAASmD,QAAuBK,IAAc,CACrErF,IAAKqC,EAAKsB,MAAO,WAErB,CAEWjE,GAAA,IC3FfgB,EAAAA,QAAQmD,MAAMtC,QAAQ+D"}
|
1
|
+
{"version":3,"file":"index.iife.min.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\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 .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["resolve","actionDone","actionRestore","Promise","r","mergePackageJson","manifest","cwd","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","commander","program","command","aliases","option","action","async","root","rootOption","filter","bumper","options","path","isAbsolute","process","wd","getWorkspaceDir","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","mainfests","Object","entries","forEach","package","dir","push","passArgs","reduce","acc","key","value","m","newVersion","bump","version","newManifest","fs","renameSync","join","writeFileSync","JSON","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","parse","default","readFileSync","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","pnpmWorkspaceFilePath","pnpmWorkspaceFileContent","pnpmWorkspace","load","Error","existsSync","packageJSON","name","packages","jiekTempDir","paths","mkdirSync","rollupBinaryPath","require","replace","i","escapeManifestName","configFile","argv"],"mappings":"8ZAAA,IAAIA,EAIG,SAASC,IACND,GACV,CAEO,SAASE,IACC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
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.fs, global.path, global.bumper, global.getWorkspaceDir, global.filterWorkspacePackages, global.childProcess, global.commander, global.pkger, global.childProcess$1, global.jsYaml));
|
5
5
|
})(this, (function (fs, path, bumper, getWorkspaceDir, filterWorkspacePackages, childProcess, commander, pkger, childProcess$1, jsYaml) { 'use strict';
|
6
6
|
|
7
|
-
function
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
8
|
+
|
9
|
+
function _interopNamespace(e) {
|
10
|
+
if (e && e.__esModule) return e;
|
8
11
|
var n = Object.create(null);
|
9
12
|
if (e) {
|
10
13
|
Object.keys(e).forEach(function (k) {
|
@@ -21,8 +24,10 @@
|
|
21
24
|
return Object.freeze(n);
|
22
25
|
}
|
23
26
|
|
24
|
-
var
|
25
|
-
var
|
27
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
28
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
29
|
+
var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
|
30
|
+
var childProcess__namespace$1 = /*#__PURE__*/_interopNamespace(childProcess$1);
|
26
31
|
|
27
32
|
let resolve;
|
28
33
|
function actionDone() {
|
@@ -46,7 +51,7 @@
|
|
46
51
|
|
47
52
|
commander.program.command("publish").aliases(["pub", "p"]).option("--filter <filter>", "filter packages").option("--root <root>", "root path").option("--bumper <bumper>", "bump version", "patch").action(async ({ root: rootOption, filter, bumper: bumper$1, ...options }) => {
|
48
53
|
actionRestore();
|
49
|
-
const root = rootOption ?
|
54
|
+
const root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : process.cwd();
|
50
55
|
const wd = getWorkspaceDir.getWorkspaceDir(root);
|
51
56
|
const { selectedProjectsGraph } = await filterWorkspacePackages.filterPackagesFromDir(wd, [{
|
52
57
|
filter: filter ?? "",
|
@@ -75,20 +80,20 @@
|
|
75
80
|
...m,
|
76
81
|
version: newVersion
|
77
82
|
};
|
78
|
-
|
79
|
-
|
83
|
+
fs__default.default.renameSync(path__default.default.join(dir, "package.json"), path__default.default.join(dir, "package.json.bak"));
|
84
|
+
fs__default.default.writeFileSync(path__default.default.join(dir, "package.json"), JSON.stringify(newManifest, null, 2));
|
80
85
|
console.log(newManifest);
|
81
86
|
try {
|
82
87
|
childProcess__namespace.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
|
83
88
|
cwd: dir,
|
84
89
|
stdio: "inherit"
|
85
90
|
});
|
86
|
-
const oldPackageJson = JSON.parse(
|
91
|
+
const oldPackageJson = JSON.parse(fs__default.default.readFileSync(path__default.default.join(dir, "package.json.bak"), "utf-8"));
|
87
92
|
oldPackageJson.version = newVersion;
|
88
|
-
|
93
|
+
fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), JSON.stringify(oldPackageJson, null, 2));
|
89
94
|
} finally {
|
90
|
-
|
91
|
-
|
95
|
+
fs__default.default.unlinkSync(path__default.default.join(dir, "package.json"));
|
96
|
+
fs__default.default.renameSync(path__default.default.join(dir, "package.json.bak"), path__default.default.join(dir, "package.json"));
|
92
97
|
}
|
93
98
|
}
|
94
99
|
actionDone();
|
@@ -106,20 +111,20 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
106
111
|
`.trimStart();
|
107
112
|
commander.program.command("build").option("--filter <filter>", "filter packages").option("--root <root>", "root path").action(async ({ root: rootOption, filter, ...options }) => {
|
108
113
|
actionRestore();
|
109
|
-
const root = rootOption ?
|
114
|
+
const root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : process.cwd();
|
110
115
|
const wd = getWorkspaceDir.getWorkspaceDir(root);
|
111
|
-
const pnpmWorkspaceFilePath =
|
112
|
-
const pnpmWorkspaceFileContent =
|
116
|
+
const pnpmWorkspaceFilePath = path__default.default.resolve(wd, "pnpm-workspace.yaml");
|
117
|
+
const pnpmWorkspaceFileContent = fs__default.default.readFileSync(pnpmWorkspaceFilePath, "utf-8");
|
113
118
|
const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
|
114
119
|
if (root === wd && !filter) {
|
115
120
|
throw new Error("root path is workspace root, please provide a filter");
|
116
121
|
}
|
117
122
|
if (root !== wd && !filter) {
|
118
|
-
const packageJSONIsExist =
|
123
|
+
const packageJSONIsExist = fs__default.default.existsSync(path__default.default.resolve(root, "package.json"));
|
119
124
|
if (!packageJSONIsExist) {
|
120
125
|
throw new Error("root path is not workspace root, please provide a filter");
|
121
126
|
}
|
122
|
-
const packageJSON = JSON.parse(
|
127
|
+
const packageJSON = JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(root, "package.json"), "utf-8"));
|
123
128
|
if (!packageJSON.name) {
|
124
129
|
throw new Error("root path is not workspace root, please provide a filter");
|
125
130
|
}
|
@@ -133,9 +138,9 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
133
138
|
workspaceDir: wd,
|
134
139
|
patterns: pnpmWorkspace.packages
|
135
140
|
});
|
136
|
-
const jiekTempDir = (...paths) =>
|
137
|
-
if (!
|
138
|
-
|
141
|
+
const jiekTempDir = (...paths) => path__default.default.resolve(wd, "node_modules/.jiek", ...paths);
|
142
|
+
if (!fs__default.default.existsSync(jiekTempDir()))
|
143
|
+
fs__default.default.mkdirSync(jiekTempDir());
|
139
144
|
const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
140
145
|
let i = 0;
|
141
146
|
for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {
|
@@ -144,7 +149,7 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
144
149
|
const configFile = jiekTempDir(
|
145
150
|
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
146
151
|
);
|
147
|
-
|
152
|
+
fs__default.default.writeFileSync(configFile, FILE_TEMPLATE(newManifest));
|
148
153
|
let prefix = "";
|
149
154
|
if (process.env.NODE_ENV === "test") {
|
150
155
|
const registerPath = require.resolve("esbuild-register");
|
package/dist/index.umd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\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 .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["pkger","program","bumper","getWorkspaceDir","filterPackagesFromDir","bump","childProcess","load"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAAA,IAAI,OAAA,CAAA;EAIG,SAAS,UAAa,GAAA;EAC3B,EAAQ,OAAA,EAAA,CAAA;EACV,CAAA;EAEO,SAAS,aAAgB,GAAA;EAC9B,EAAe,IAAI,OAAA,CAAc,CAAK,CAAA,KAAA,OAAA,GAAU,CAAC,CAAA,CAAA;EACnD;;ECNgB,SAAA,gBAAA,CAAiB,UAG9B,GAAa,EAAA;EACd,EAAM,MAAA;EAAA,IACJ,IAAA,EAAM,EAAE,MAAQ,EAAA,UAAA,EAAY,KAAK,CAAG,EAAA,GAAG,IAAK,EAAA,GAAI,EAAC;EAAA,IAAG,OAAA;EAAA,GAClD,GAAA,QAAA,CAAA;EACJ,EAAA,MAAM,SAAS,UACb,KAAA,KAAA,CAAM,OAAQ,CAAA,OAAO,IAAI,OAAU,GAAA,KAAA,CAAA,CAAA,CAAA;EAErC,EAAO,OAAA;EAAA,IACL,GAAG,QAAA;EAAA,IACH,GAAGA,WAAM,CAAA,EAAE,QAAQ,GAAK,EAAA,GAAG,MAAM,CAAA;EAAA,GACnC,CAAA;EACF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A;EACvD,IAAA,IAAI,MAAS,GAAA,EAAA,CAAA;EACb,IAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,MAAQ,EAAA;EACnC,MAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,kBAAkB,CAAA,CAAA;EACvD,MAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,OAAA,CAAQ,yBAAyB,CAAA,CAAA;EAC5D,MAAS,MAAA,GAAA,CAAA,cAAA,EAAiB,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA,CAAA,CAAA,CAAA;EAAA,KACzD;EAEA,IAAAE,yBAAA,CAAa,SAAS,CAAG,EAAA,MAAM,GAAG,gBAAgB,CAAA,IAAA,EAAO,UAAU,CAAI,CAAA,EAAA;EAAA,MACrE,GAAK,EAAA,GAAA;EAAA,MAAK,KAAO,EAAA,SAAA;EAAA,KAClB,CAAA,CAAA;EAAA,GACH;EAEA,EAAW,UAAA,EAAA,CAAA;EACb,CAAC,CAAA;;AC5FHL,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\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 .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["pkger","program","bumper","path","getWorkspaceDir","filterPackagesFromDir","bump","fs","childProcess","load"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA,IAAI,OAAA,CAAA;EAIG,SAAS,UAAa,GAAA;EAC3B,EAAQ,OAAA,EAAA,CAAA;EACV,CAAA;EAEO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,UAAA,EAAA,CAAA;EACb,CAAC,CAAA;;AC5FHP,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
|
package/dist/index.umd.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("node:fs"),require("node:path"),require("@jiek/utils/bumper"),require("@jiek/utils/getWorkspaceDir"),require("@pnpm/filter-workspace-packages"),require("child_process"),require("commander"),require("@jiek/pkger"),require("node:child_process"),require("js-yaml")):"function"==typeof define&&define.amd?define(["node:fs","node:path","@jiek/utils/bumper","@jiek/utils/getWorkspaceDir","@pnpm/filter-workspace-packages","child_process","commander","@jiek/pkger","node:child_process","js-yaml"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).fs,e.path,e.bumper,e.getWorkspaceDir,e.filterWorkspacePackages,e.childProcess,e.commander,e.pkger,e.childProcess$1,e.jsYaml)}(this,(function(e,r,o,
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("node:fs"),require("node:path"),require("@jiek/utils/bumper"),require("@jiek/utils/getWorkspaceDir"),require("@pnpm/filter-workspace-packages"),require("child_process"),require("commander"),require("@jiek/pkger"),require("node:child_process"),require("js-yaml")):"function"==typeof define&&define.amd?define(["node:fs","node:path","@jiek/utils/bumper","@jiek/utils/getWorkspaceDir","@pnpm/filter-workspace-packages","child_process","commander","@jiek/pkger","node:child_process","js-yaml"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).fs,e.path,e.bumper,e.getWorkspaceDir,e.filterWorkspacePackages,e.childProcess,e.commander,e.pkger,e.childProcess$1,e.jsYaml)}(this,(function(e,r,t,o,i,s,a,n,l,c){"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),k=u(s),g=u(l);let m;function j(){m()}function y(){new Promise((e=>m=e))}function b(e,r){const{jiek:{inputs:t,cwd:o,...i}={},exports:s}=e,a=t??(Array.isArray(s)?s:void 0);return{...e,...n.pkger({inputs:a,cwd:r,...i})}}a.program.command("publish").aliases(["pub","p"]).option("--filter <filter>","filter packages").option("--root <root>","root path").option("--bumper <bumper>","bump version","patch").action((async({root:e,filter:r,bumper:s,...a})=>{y();const n=e?d.default.isAbsolute(e)?e:d.default.resolve(process.cwd(),e):process.cwd(),l=o.getWorkspaceDir(n),{selectedProjectsGraph:c}=await i.filterPackagesFromDir(l,[{filter:r??"",followProdDepsOnly:!0}],{prefix:n,workspaceDir:l,patterns:["packages/*"]}),p=[];Object.entries(c).forEach((([,{package:{dir:e,manifest:r}}])=>{p.push([e,b(r,e)])}));const u=Object.entries(a).reduce(((e,[r,t])=>(t&&e.push(`--${r}`,t),e)),[]);for(const[e,r]of p){const o=t.bump(r.version,s),i={...r,version:o};f.default.renameSync(d.default.join(e,"package.json"),d.default.join(e,"package.json.bak")),f.default.writeFileSync(d.default.join(e,"package.json"),JSON.stringify(i,null,2)),console.log(i);try{k.execSync(["pnpm","publish","--access","public","--no-git-checks",...u].join(" "),{cwd:e,stdio:"inherit"});const r=JSON.parse(f.default.readFileSync(d.default.join(e,"package.json.bak"),"utf-8"));r.version=o,f.default.writeFileSync(d.default.join(e,"package.json.bak"),JSON.stringify(r,null,2))}finally{f.default.unlinkSync(d.default.join(e,"package.json")),f.default.renameSync(d.default.join(e,"package.json.bak"),d.default.join(e,"package.json"))}}j()}));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").option("--filter <filter>","filter packages").option("--root <root>","root path").action((async({root:e,filter:r,...t})=>{y();const s=e?d.default.isAbsolute(e)?e:d.default.resolve(process.cwd(),e):process.cwd(),a=o.getWorkspaceDir(s),n=d.default.resolve(a,"pnpm-workspace.yaml"),l=f.default.readFileSync(n,"utf-8"),p=c.load(l);if(s===a&&!r)throw new Error("root path is workspace root, please provide a filter");if(s!==a&&!r){if(!f.default.existsSync(d.default.resolve(s,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const e=JSON.parse(f.default.readFileSync(d.default.resolve(s,"package.json"),"utf-8"));if(!e.name)throw new Error("root path is not workspace root, please provide a filter");r=e.name}const{selectedProjectsGraph:u}=await i.filterPackagesFromDir(a,[{filter:r??"",followProdDepsOnly:!0}],{prefix:s,workspaceDir:a,patterns:p.packages}),k=(...e)=>d.default.resolve(a,"node_modules/.jiek",...e);f.default.existsSync(k())||f.default.mkdirSync(k());const m=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let w=0;for(const[e,{package:{manifest:r}}]of Object.entries(u)){const t=b(r,e),o=r.name?.replace(/^@/g,"").replace(/\//g,"+"),i=k(`${o??"anonymous-"+w++}.rollup.config.js`);f.default.writeFileSync(i,h(t));let s="";if("test"===process.env.NODE_ENV){s=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}g.execSync(`${s}${m} -c ${i}`,{cwd:e,stdio:"inherit"})}j()})),a.program.parse(process.argv)}));
|
2
2
|
//# sourceMappingURL=index.umd.min.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.umd.min.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\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 .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["resolve","actionDone","actionRestore","Promise","r","mergePackageJson","manifest","cwd","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","commander","program","command","aliases","option","action","async","root","rootOption","filter","bumper","options","path","isAbsolute","process","wd","getWorkspaceDir","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","mainfests","Object","entries","forEach","package","dir","push","passArgs","reduce","acc","key","value","m","newVersion","bump","version","newManifest","fs","renameSync","join","writeFileSync","JSON","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","parse","readFileSync","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","pnpmWorkspaceFilePath","pnpmWorkspaceFileContent","pnpmWorkspace","load","Error","existsSync","packageJSON","name","packages","jiekTempDir","paths","mkdirSync","rollupBinaryPath","require","replace","i","escapeManifestName","configFile","argv"],"mappings":"ujCAAA,IAAIA,EAIG,SAASC,IACND,GACV,CAEO,SAASE,IACC,IAAIC,SAAmBC,GAAAJ,EAAUI,GAClD,CCNgB,SAAAC,EAAiBC,EAG9BC,GACK,MACJC,MAAQC,OAAQC,EAAYH,IAAKI,KAAMH,GAAS,CAAC,EAAAI,QAAGA,GAClDN,EACEG,EAASC,IACbG,MAAMC,QAAQF,GAAWA,OAAU,GAE9B,MAAA,IACFN,KACAS,EAAMA,MAAA,CAAEN,SAAQF,SAAQC,IAE/B,CCLAQ,EAAAC,QACGC,QAAQ,WACRC,QAAQ,CAAC,MAAO,MAChBC,OAAO,oBAAqB,mBAC5BA,OAAO,gBAAiB,aACxBA,OAAO,oBAAqB,eAAgB,SAC5CC,QAAOC,OAASC,KAAMC,EAAYC,SAAQC,OAAAA,KAAWC,MAKtCzB,IACd,MAAMqB,EAAOC,EACTI,EAAKC,WAAWL,GACdA,EACAI,EAAK5B,QAAQ8B,QAAQvB,MAAOiB,GAC9BM,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clD,EAAiBC,EAAUsC,GAEzC+C,EAAqBrF,EAAS4E,MAAMO,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtEG,EAAaR,EACjB,GAAGO,GAAsB,aAAaD,wBAExClC,EAAGG,cAAciC,EAAYrB,EAAchB,IAC3C,IAAInB,EAAS,GACT,GAAyB,SAAzBN,QAAQ0C,IAAIC,SAAqB,CAG1BrC,EAAA,iBAFYoD,QAAQxF,QAAQ,0BAClBwF,QAAQxF,QAAQ,6BAErC,CAEAgE,EAAaC,SAAS,GAAG7B,IAASmD,QAAuBK,IAAc,CACrErF,IAAKqC,EAAKsB,MAAO,WAErB,CAEWjE,GAAA,IC3FfgB,EAAAA,QAAQmD,MAAMtC,QAAQ+D"}
|
1
|
+
{"version":3,"file":"index.umd.min.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\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 .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["resolve","actionDone","actionRestore","Promise","r","mergePackageJson","manifest","cwd","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","commander","program","command","aliases","option","action","async","root","rootOption","filter","bumper","options","path","isAbsolute","process","wd","getWorkspaceDir","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","mainfests","Object","entries","forEach","package","dir","push","passArgs","reduce","acc","key","value","m","newVersion","bump","version","newManifest","fs","renameSync","join","writeFileSync","JSON","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","parse","default","readFileSync","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","pnpmWorkspaceFilePath","pnpmWorkspaceFileContent","pnpmWorkspace","load","Error","existsSync","packageJSON","name","packages","jiekTempDir","paths","mkdirSync","rollupBinaryPath","require","replace","i","escapeManifestName","configFile","argv"],"mappings":"opCAAA,IAAIA,EAIG,SAASC,IACND,GACV,CAEO,SAASE,IACC,IAAIC,SAAmBC,GAAAJ,EAAUI,GAClD,CCNgB,SAAAC,EAAiBC,EAG9BC,GACK,MACJC,MAAQC,OAAQC,EAAYH,IAAKI,KAAMH,GAAS,CAAC,EAAAI,QAAGA,GAClDN,EACEG,EAASC,IACbG,MAAMC,QAAQF,GAAWA,OAAU,GAE9B,MAAA,IACFN,KACAS,EAAMA,MAAA,CAAEN,SAAQF,SAAQC,IAE/B,CCLAQ,EAAAC,QACGC,QAAQ,WACRC,QAAQ,CAAC,MAAO,MAChBC,OAAO,oBAAqB,mBAC5BA,OAAO,gBAAiB,aACxBA,OAAO,oBAAqB,eAAgB,SAC5CC,QAAOC,OAASC,KAAMC,EAAYC,SAAQC,OAAAA,KAAWC,MAKtCzB,IACd,MAAMqB,EAAOC,EACTI,EAAAA,QAAKC,WAAWL,GACdA,EACAI,EAAAA,QAAK5B,QAAQ8B,QAAQvB,MAAOiB,GAC9BM,QAAQvB,MACNwB,EAAKC,kBAAgBT,IACrBU,sBAAEA,SAAgCC,EAAAA,sBAAsBH,EAAI,CAAC,CACjEN,OAAQA,GAAU,GAClBU,oBAAoB,IAClB,CACFC,OAAQb,EACRc,aAAcN,EACdO,SAAU,CAAC,gBAEPC,EAA0C,GAChDC,OACGC,QAAQR,GACRS,SAAQ,IAAMC,SAAWC,MAAKtC,iBAC7BiC,EAAUM,KAAK,CACbD,EAAKvC,EAAiBC,EAAUsC,IACjC,IAEC,MAAAE,EAAWN,OACdC,QAAQd,GACRoB,QAAO,CAACC,GAAMC,EAAKC,MACdA,GACFF,EAAIH,KAAK,KAAKI,IAAOC,GAEhBF,IACN,IACL,IAAA,MAAYJ,EAAKO,KAAMZ,EAAW,CAChC,MAAMa,EAAaC,EAAAA,KAAKF,EAAEG,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AAc,CACrEtF,IAAKqC,EAAKsB,MAAO,WAErB,CAEWjE,GAAA,IC3FfgB,EAAAA,QAAQmD,MAAMtC,QAAQgE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"commonOptions.esm.js","sources":["../../../src/rollup/utils/commonOptions.ts"],"sourcesContent":["import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n sourcemap: true\n})\n"],"names":[],"mappings":"AAEA,MAAM,YAAA,GAAe,CAA0B,MAAc,KAAA,MAAA,CAAA;AAEtD,MAAM,sBAAsB,YAAa,CAAA;AAAA,EAC9C,GAAK,EAAA,MAAA;AAAA,EACL,OAAS,EAAA,OAAA;AAAA,EACT,SAAW,EAAA,IAAA;AACb,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"commonOptions.esm.js","sources":["../../../src/rollup/utils/commonOptions.ts"],"sourcesContent":["import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n"],"names":[],"mappings":"AAEA,MAAM,YAAA,GAAe,CAA0B,MAAc,KAAA,MAAA,CAAA;AAEtD,MAAM,sBAAsB,YAAa,CAAA;AAAA,EAC9C,GAAK,EAAA,MAAA;AAAA,EACL,OAAS,EAAA,OAAA;AAAA,EACT,OAAS,EAAA,MAAA;AAAA,EACT,SAAW,EAAA,IAAA;AACb,CAAC;;;;"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
const
|
1
|
+
const o={dir:"dist",exports:"named",interop:"auto",sourcemap:!0};export{o as commonOutputOptions};
|
2
2
|
//# sourceMappingURL=commonOptions.esm.min.js.map
|