jiek 0.1.11 → 0.1.12-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.esm.js +5 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +164 -58
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.umd.js +166 -60
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/package.json.esm.js +58 -0
- package/dist/package.json.esm.js.map +1 -0
- package/dist/package.json.esm.min.js +2 -0
- package/dist/package.json.esm.min.js.map +1 -0
- 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 +13 -7
- package/dist/rollup.esm.js.map +1 -1
- package/dist/rollup.esm.min.js +1 -1
- package/dist/rollup.esm.min.js.map +1 -1
- package/dist/rollup.iife.js +22 -9
- package/dist/rollup.iife.js.map +1 -1
- package/dist/rollup.iife.min.js +1 -1
- package/dist/rollup.iife.min.js.map +1 -1
- package/dist/rollup.umd.js +24 -11
- package/dist/rollup.umd.js.map +1 -1
- package/dist/rollup.umd.min.js +1 -1
- package/dist/rollup.umd.min.js.map +1 -1
- package/dist/src/commands/build.esm.js +53 -0
- package/dist/src/commands/build.esm.js.map +1 -0
- package/dist/src/commands/build.esm.min.js +2 -0
- package/dist/src/commands/build.esm.min.js.map +1 -0
- package/dist/src/commands/publish.esm.js +54 -0
- package/dist/src/commands/publish.esm.js.map +1 -0
- package/dist/src/commands/publish.esm.min.js +2 -0
- package/dist/src/commands/publish.esm.min.js.map +1 -0
- package/dist/src/inner.esm.js +10 -0
- package/dist/src/inner.esm.js.map +1 -0
- package/dist/src/inner.esm.min.js +2 -0
- package/dist/src/inner.esm.min.js.map +1 -0
- package/dist/src/merge-package-json.esm.js +16 -0
- package/dist/src/merge-package-json.esm.js.map +1 -0
- package/dist/src/merge-package-json.esm.min.js +2 -0
- package/dist/src/merge-package-json.esm.min.js.map +1 -0
- package/dist/src/rollup/plugins/globals.esm.js +31 -0
- package/dist/src/rollup/plugins/globals.esm.js.map +1 -0
- package/dist/src/rollup/plugins/globals.esm.min.js +2 -0
- package/dist/src/rollup/plugins/globals.esm.min.js.map +1 -0
- package/dist/src/rollup/plugins/skip.esm.js +16 -0
- package/dist/src/rollup/plugins/skip.esm.js.map +1 -0
- package/dist/src/rollup/plugins/skip.esm.min.js +2 -0
- package/dist/src/rollup/plugins/skip.esm.min.js.map +1 -0
- package/dist/src/rollup/utils/commonOptions.esm.js +10 -0
- package/dist/src/rollup/utils/commonOptions.esm.js.map +1 -0
- package/dist/src/rollup/utils/commonOptions.esm.min.js +2 -0
- package/dist/src/rollup/utils/commonOptions.esm.min.js.map +1 -0
- package/dist/src/rollup/utils/externalResolver.esm.js +10 -0
- package/dist/src/rollup/utils/externalResolver.esm.js.map +1 -0
- package/dist/src/rollup/utils/externalResolver.esm.min.js +2 -0
- package/dist/src/rollup/utils/externalResolver.esm.min.js.map +1 -0
- package/dist/src/rollup/utils/globalResolver.esm.js +26 -0
- package/dist/src/rollup/utils/globalResolver.esm.js.map +1 -0
- package/dist/src/rollup/utils/globalResolver.esm.min.js +2 -0
- package/dist/src/rollup/utils/globalResolver.esm.min.js.map +1 -0
- package/dist/src/rollup/utils/withMinify.esm.js +15 -0
- package/dist/src/rollup/utils/withMinify.esm.js.map +1 -0
- package/dist/src/rollup/utils/withMinify.esm.min.js +2 -0
- package/dist/src/rollup/utils/withMinify.esm.min.js.map +1 -0
- package/dist/src/utils/filterSupport.esm.js +78 -0
- package/dist/src/utils/filterSupport.esm.js.map +1 -0
- package/dist/src/utils/filterSupport.esm.min.js +2 -0
- package/dist/src/utils/filterSupport.esm.min.js.map +1 -0
- package/package.json +5 -2
package/dist/index.esm.js
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
import './
|
2
|
-
import './commands/
|
1
|
+
import './src/utils/filterSupport.esm.js';
|
2
|
+
import './src/commands/publish.esm.js';
|
3
|
+
import './src/commands/build.esm.js';
|
3
4
|
import { program } from 'commander';
|
5
|
+
import pkg from './package.json.esm.js';
|
4
6
|
|
7
|
+
program.version(pkg.version).description(pkg.description).option("--root <root>", "root path");
|
5
8
|
program.parse(process.argv);
|
6
9
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nimport pkg from '../package.json'\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":[],"mappings":";;;;;;AAQA,OACG,CAAA,OAAA,CAAQ,GAAI,CAAA,OAAO,CACnB,CAAA,WAAA,CAAY,IAAI,WAAW,CAAA,CAC3B,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AAEtC,OAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA"}
|
package/dist/index.esm.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import"./commands/publish.esm.min.js";import"./commands/build.esm.min.js";import{program as
|
1
|
+
import"./src/utils/filterSupport.esm.min.js";import"./src/commands/publish.esm.min.js";import"./src/commands/build.esm.min.js";import{program as o}from"commander";import r from"./package.json.esm.min.js";o.version(r.version).description(r.description).option("--root <root>","root path"),o.parse(process.argv);
|
2
2
|
//# sourceMappingURL=index.esm.min.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.esm.min.js","sources":["../src/index.ts"],"sourcesContent":["import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["program","parse","process","argv"],"mappings":"
|
1
|
+
{"version":3,"file":"index.esm.min.js","sources":["../src/index.ts"],"sourcesContent":["import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nimport pkg from '../package.json'\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["program","version","pkg","description","option","parse","process","argv"],"mappings":"4MAQAA,EACGC,QAAQC,EAAID,SACZE,YAAYD,EAAIC,aAChBC,OAAO,gBAAiB,aAE3BJ,EAAQK,MAAMC,QAAQC"}
|
package/dist/index.iife.js
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
(function (fs, path,
|
1
|
+
(function (fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, pkger, childProcess$1) {
|
2
2
|
'use strict';
|
3
3
|
|
4
|
-
function
|
4
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
5
|
+
|
6
|
+
function _interopNamespace(e) {
|
7
|
+
if (e && e.__esModule) return e;
|
5
8
|
var n = Object.create(null);
|
6
9
|
if (e) {
|
7
10
|
Object.keys(e).forEach(function (k) {
|
@@ -18,8 +21,79 @@
|
|
18
21
|
return Object.freeze(n);
|
19
22
|
}
|
20
23
|
|
21
|
-
var
|
22
|
-
var
|
24
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
25
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
26
|
+
var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
|
27
|
+
var childProcess__namespace$1 = /*#__PURE__*/_interopNamespace(childProcess$1);
|
28
|
+
|
29
|
+
let type = "";
|
30
|
+
try {
|
31
|
+
require.resolve("@pnpm/filter-workspace-packages");
|
32
|
+
type = "pnpm";
|
33
|
+
} catch {
|
34
|
+
}
|
35
|
+
if (type !== "") {
|
36
|
+
commander.program.option("-f, --filter <filter>", "filter packages");
|
37
|
+
}
|
38
|
+
async function getSelectedProjectsGraph() {
|
39
|
+
let filter = commander.program.getOptionValue("filter");
|
40
|
+
const rootOption = commander.program.getOptionValue("root");
|
41
|
+
const root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : process.cwd();
|
42
|
+
let notWorkspace = false;
|
43
|
+
let wd;
|
44
|
+
try {
|
45
|
+
wd = getWorkspaceDir.getWorkspaceDir(root, type);
|
46
|
+
} catch (e) {
|
47
|
+
if ("message" in e && e.message === "workspace root not found") {
|
48
|
+
wd = root;
|
49
|
+
notWorkspace = true;
|
50
|
+
} else {
|
51
|
+
throw e;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
if (!notWorkspace && type === "pnpm") {
|
55
|
+
const pnpmWorkspaceFilePath = path__default.default.resolve(wd, "pnpm-workspace.yaml");
|
56
|
+
const pnpmWorkspaceFileContent = fs__default.default.readFileSync(pnpmWorkspaceFilePath, "utf-8");
|
57
|
+
const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
|
58
|
+
if (root === wd && !filter) {
|
59
|
+
throw new Error("root path is workspace root, please provide a filter");
|
60
|
+
}
|
61
|
+
if (root !== wd && !filter) {
|
62
|
+
const packageJSONIsExist = fs__default.default.existsSync(path__default.default.resolve(root, "package.json"));
|
63
|
+
if (!packageJSONIsExist) {
|
64
|
+
throw new Error("root path is not workspace root, please provide a filter");
|
65
|
+
}
|
66
|
+
const packageJSON = JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(root, "package.json"), "utf-8"));
|
67
|
+
if (!packageJSON.name) {
|
68
|
+
throw new Error("root path is not workspace root, please provide a filter");
|
69
|
+
}
|
70
|
+
filter = packageJSON.name;
|
71
|
+
}
|
72
|
+
const { selectedProjectsGraph } = await filterWorkspacePackages.filterPackagesFromDir(wd, [{
|
73
|
+
filter: filter ?? "",
|
74
|
+
followProdDepsOnly: true
|
75
|
+
}], {
|
76
|
+
prefix: root,
|
77
|
+
workspaceDir: wd,
|
78
|
+
patterns: pnpmWorkspace.packages
|
79
|
+
});
|
80
|
+
return {
|
81
|
+
wd,
|
82
|
+
root,
|
83
|
+
value: Object.entries(selectedProjectsGraph).reduce((acc, [key, value]) => {
|
84
|
+
acc[key] = value.package.manifest;
|
85
|
+
return acc;
|
86
|
+
}, {})
|
87
|
+
};
|
88
|
+
}
|
89
|
+
return {
|
90
|
+
wd,
|
91
|
+
root,
|
92
|
+
value: {
|
93
|
+
[wd]: JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(wd, "package.json"), "utf-8"))
|
94
|
+
}
|
95
|
+
};
|
96
|
+
}
|
23
97
|
|
24
98
|
let resolve;
|
25
99
|
function actionDone() {
|
@@ -41,28 +115,23 @@
|
|
41
115
|
};
|
42
116
|
}
|
43
117
|
|
44
|
-
commander.program.command("publish").aliases(["pub", "p"]).option("--
|
118
|
+
commander.program.command("publish").aliases(["pub", "p"]).option("--bumper <bumper>", "bump version", "patch").action(async ({ bumper: bumper$1, ...options }) => {
|
45
119
|
actionRestore();
|
46
|
-
const
|
47
|
-
const
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
}], {
|
52
|
-
prefix: root,
|
53
|
-
workspaceDir: wd,
|
54
|
-
patterns: ["packages/*"]
|
55
|
-
});
|
120
|
+
const { value = {} } = await getSelectedProjectsGraph() ?? {};
|
121
|
+
const selectedProjectsGraphEntries = Object.entries(value);
|
122
|
+
if (selectedProjectsGraphEntries.length === 0) {
|
123
|
+
throw new Error("no packages selected");
|
124
|
+
}
|
56
125
|
const mainfests = [];
|
57
|
-
|
126
|
+
selectedProjectsGraphEntries.forEach(([dir, manifest]) => {
|
58
127
|
mainfests.push([
|
59
128
|
dir,
|
60
129
|
mergePackageJson(manifest, dir)
|
61
130
|
]);
|
62
131
|
});
|
63
|
-
const passArgs = Object.entries(options).reduce((acc, [key,
|
64
|
-
if (
|
65
|
-
acc.push(`--${key}`,
|
132
|
+
const passArgs = Object.entries(options).reduce((acc, [key, value2]) => {
|
133
|
+
if (value2) {
|
134
|
+
acc.push(`--${key}`, value2);
|
66
135
|
}
|
67
136
|
return acc;
|
68
137
|
}, []);
|
@@ -72,20 +141,20 @@
|
|
72
141
|
...m,
|
73
142
|
version: newVersion
|
74
143
|
};
|
75
|
-
|
76
|
-
|
144
|
+
fs__default.default.renameSync(path__default.default.join(dir, "package.json"), path__default.default.join(dir, "package.json.bak"));
|
145
|
+
fs__default.default.writeFileSync(path__default.default.join(dir, "package.json"), JSON.stringify(newManifest, null, 2));
|
77
146
|
console.log(newManifest);
|
78
147
|
try {
|
79
148
|
childProcess__namespace.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
|
80
149
|
cwd: dir,
|
81
150
|
stdio: "inherit"
|
82
151
|
});
|
83
|
-
const oldPackageJson = JSON.parse(
|
152
|
+
const oldPackageJson = JSON.parse(fs__default.default.readFileSync(path__default.default.join(dir, "package.json.bak"), "utf-8"));
|
84
153
|
oldPackageJson.version = newVersion;
|
85
|
-
|
154
|
+
fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), JSON.stringify(oldPackageJson, null, 2));
|
86
155
|
} finally {
|
87
|
-
|
88
|
-
|
156
|
+
fs__default.default.unlinkSync(path__default.default.join(dir, "package.json"));
|
157
|
+
fs__default.default.renameSync(path__default.default.join(dir, "package.json.bak"), path__default.default.join(dir, "package.json"));
|
89
158
|
}
|
90
159
|
}
|
91
160
|
actionDone();
|
@@ -101,47 +170,27 @@ const templateArg = jiek.templateArgFilePath
|
|
101
170
|
}
|
102
171
|
module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/index.ts" : "jiek/rollup"}').template(templateArg, pkg)
|
103
172
|
`.trimStart();
|
104
|
-
commander.program.command("build").
|
173
|
+
commander.program.command("build").action(async () => {
|
105
174
|
actionRestore();
|
106
|
-
const
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
throw new Error("root path is workspace root, please provide a filter");
|
113
|
-
}
|
114
|
-
if (root !== wd && !filter) {
|
115
|
-
const packageJSONIsExist = fs.existsSync(path.resolve(root, "package.json"));
|
116
|
-
if (!packageJSONIsExist) {
|
117
|
-
throw new Error("root path is not workspace root, please provide a filter");
|
118
|
-
}
|
119
|
-
const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, "package.json"), "utf-8"));
|
120
|
-
if (!packageJSON.name) {
|
121
|
-
throw new Error("root path is not workspace root, please provide a filter");
|
122
|
-
}
|
123
|
-
filter = packageJSON.name;
|
175
|
+
const {
|
176
|
+
wd,
|
177
|
+
value = {}
|
178
|
+
} = await getSelectedProjectsGraph() ?? {};
|
179
|
+
if (Object.keys(value).length === 0) {
|
180
|
+
throw new Error("no package found");
|
124
181
|
}
|
125
|
-
const
|
126
|
-
|
127
|
-
|
128
|
-
}], {
|
129
|
-
prefix: root,
|
130
|
-
workspaceDir: wd,
|
131
|
-
patterns: pnpmWorkspace.packages
|
132
|
-
});
|
133
|
-
const jiekTempDir = (...paths) => path.resolve(wd, "node_modules/.jiek", ...paths);
|
134
|
-
if (!fs.existsSync(jiekTempDir()))
|
135
|
-
fs.mkdirSync(jiekTempDir());
|
182
|
+
const jiekTempDir = (...paths) => path__default.default.resolve(wd, "node_modules/.jiek", ...paths);
|
183
|
+
if (!fs__default.default.existsSync(jiekTempDir()))
|
184
|
+
fs__default.default.mkdirSync(jiekTempDir());
|
136
185
|
const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
137
186
|
let i = 0;
|
138
|
-
for (const [dir,
|
187
|
+
for (const [dir, manifest] of Object.entries(value)) {
|
139
188
|
const newManifest = mergePackageJson(manifest, dir);
|
140
189
|
const escapeManifestName = manifest.name?.replace(/^@/g, "").replace(/\//g, "+");
|
141
190
|
const configFile = jiekTempDir(
|
142
191
|
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
143
192
|
);
|
144
|
-
|
193
|
+
fs__default.default.writeFileSync(configFile, FILE_TEMPLATE(newManifest));
|
145
194
|
let prefix = "";
|
146
195
|
if (process.env.NODE_ENV === "test") {
|
147
196
|
const registerPath = require.resolve("esbuild-register");
|
@@ -156,7 +205,64 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
156
205
|
actionDone();
|
157
206
|
});
|
158
207
|
|
208
|
+
var name = "jiek";
|
209
|
+
var version = "0.1.12";
|
210
|
+
var description = "YiJie's personal kits.";
|
211
|
+
var bin = {
|
212
|
+
jiek: "bin/jiek.js",
|
213
|
+
"jiek-dev": "bin/jiek-dev.js"
|
214
|
+
};
|
215
|
+
var jiek = {
|
216
|
+
inputs: [
|
217
|
+
"index.ts",
|
218
|
+
"rollup/index.ts"
|
219
|
+
]
|
220
|
+
};
|
221
|
+
var scripts = {
|
222
|
+
build: "jiek-dev build"
|
223
|
+
};
|
224
|
+
var dependencies = {
|
225
|
+
"@jiek/pkger": "workspace:^*",
|
226
|
+
"@jiek/utils": "workspace:^*",
|
227
|
+
"@rollup/plugin-json": "^6.0.1",
|
228
|
+
"@rollup/plugin-terser": "^0.4.4",
|
229
|
+
autoprefixer: "^10.4.16",
|
230
|
+
commander: "^12.0.0",
|
231
|
+
"js-yaml": "^4.1.0",
|
232
|
+
rollup: "^4.1.5",
|
233
|
+
"rollup-plugin-copy": "^3.5.0",
|
234
|
+
"rollup-plugin-dts": "^6.1.0",
|
235
|
+
"rollup-plugin-esbuild": "^6.1.0",
|
236
|
+
"rollup-plugin-postcss": "^4.0.2"
|
237
|
+
};
|
238
|
+
var optionalDependencies = {
|
239
|
+
"@pnpm/filter-workspace-packages": "^7.2.13"
|
240
|
+
};
|
241
|
+
var devDependencies = {
|
242
|
+
"@npm/types": "^1.0.2",
|
243
|
+
"@pnpm/workspace.pkgs-graph": "^2.0.15",
|
244
|
+
"@pnpm/filter-workspace-packages": "^7.2.13",
|
245
|
+
"@types/js-yaml": "^4.0.9",
|
246
|
+
"esbuild-register": "^3.5.0"
|
247
|
+
};
|
248
|
+
var files = [
|
249
|
+
"dist"
|
250
|
+
];
|
251
|
+
var pkg = {
|
252
|
+
name: name,
|
253
|
+
version: version,
|
254
|
+
description: description,
|
255
|
+
bin: bin,
|
256
|
+
jiek: jiek,
|
257
|
+
scripts: scripts,
|
258
|
+
dependencies: dependencies,
|
259
|
+
optionalDependencies: optionalDependencies,
|
260
|
+
devDependencies: devDependencies,
|
261
|
+
files: files
|
262
|
+
};
|
263
|
+
|
264
|
+
commander.program.version(pkg.version).description(pkg.description).option("--root <root>", "root path");
|
159
265
|
commander.program.parse(process.argv);
|
160
266
|
|
161
|
-
})(fs, path,
|
267
|
+
})(fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, pkger, childProcess$1);
|
162
268
|
//# sourceMappingURL=index.iife.js.map
|
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,SAAS,UAAa,GAAA;EAC3B,EAAQ,OAAA,EAAA,CAAA;EACV,CAAA;EAEO,SAAS,aAAgB,GAA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;;;"}
|
1
|
+
{"version":3,"file":"index.iife.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([dir, manifest]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nimport pkg from '../package.json'\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["program","path","getWorkspaceDir","fs","load","filterPackagesFromDir","pkger","bumper","value","bump","childProcess"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQO,IAAI,IAAO,GAAA,EAAA,CAAA;EAElB,IAAI;EACF,EAAA,OAAA,CAAQ,QAAQ,iCAAiC,CAAA,CAAA;EACjD,EAAO,IAAA,GAAA,MAAA,CAAA;EACT,CAAQ,CAAA,MAAA;EAAc,CAAA;EACtB,IAAI,SAAS,EAAI,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,CAAA;AAEtCA,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,n,s,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),g=u(i),k=u(c);let m,j="";try{require.resolve("@pnpm/filter-workspace-packages"),j="pnpm"}catch{}async function w(){let e=a.program.getOptionValue("filter");const r=a.program.getOptionValue("root"),s=r?d.default.isAbsolute(r)?r:d.default.resolve(process.cwd(),r):process.cwd();let i,l=!1;try{i=t.getWorkspaceDir(s,j)}catch(e){if(!("message"in e)||"workspace root not found"!==e.message)throw e;i=s,l=!0}if(!l&&"pnpm"===j){const r=d.default.resolve(i,"pnpm-workspace.yaml"),t=f.default.readFileSync(r,"utf-8"),a=n.load(t);if(s===i&&!e)throw new Error("root path is workspace root, please provide a filter");if(s!==i&&!e){if(!f.default.existsSync(d.default.resolve(s,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const r=JSON.parse(f.default.readFileSync(d.default.resolve(s,"package.json"),"utf-8"));if(!r.name)throw new Error("root path is not workspace root, please provide a filter");e=r.name}const{selectedProjectsGraph:l}=await o.filterPackagesFromDir(i,[{filter:e??"",followProdDepsOnly:!0}],{prefix:s,workspaceDir:i,patterns:a.packages});return{wd:i,root:s,value:Object.entries(l).reduce(((e,[r,t])=>(e[r]=t.package.manifest,e)),{})}}return{wd:i,root:s,value:{[i]:JSON.parse(f.default.readFileSync(d.default.resolve(i,"package.json"),"utf-8"))}}}function y(){m()}function v(){new Promise((e=>m=e))}function b(e,r){const{jiek:{inputs:t,cwd:o,...a}={},exports:n}=e,s=t??(Array.isArray(n)?n:void 0);return{...e,...l.pkger({inputs:s,cwd:r,...a})}}""!==j&&a.program.option("-f, --filter <filter>","filter packages"),a.program.command("publish").aliases(["pub","p"]).option("--bumper <bumper>","bump version","patch").action((async({bumper:e,...r})=>{v();const{value:t={}}=await w()??{},o=Object.entries(t);if(0===o.length)throw new Error("no packages selected");const a=[];o.forEach((([e,r])=>{a.push([e,b(r,e)])}));const n=Object.entries(r).reduce(((e,[r,t])=>(t&&e.push(`--${r}`,t),e)),[]);for(const[r,t]of a){const o=s.bump(t.version,e),a={...t,version:o};f.default.renameSync(d.default.join(r,"package.json"),d.default.join(r,"package.json.bak")),f.default.writeFileSync(d.default.join(r,"package.json"),JSON.stringify(a,null,2)),console.log(a);try{g.execSync(["pnpm","publish","--access","public","--no-git-checks",...n].join(" "),{cwd:r,stdio:"inherit"});const e=JSON.parse(f.default.readFileSync(d.default.join(r,"package.json.bak"),"utf-8"));e.version=o,f.default.writeFileSync(d.default.join(r,"package.json.bak"),JSON.stringify(e,null,2))}finally{f.default.unlinkSync(d.default.join(r,"package.json")),f.default.renameSync(d.default.join(r,"package.json.bak"),d.default.join(r,"package.json"))}}y()}));const h=e=>`\nconst pkg = ${JSON.stringify(e,null,2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template(templateArg, pkg)\n`.trimStart();a.program.command("build").action((async()=>{v();const{wd:e,value:r={}}=await w()??{};if(0===Object.keys(r).length)throw new Error("no package found");const t=(...r)=>d.default.resolve(e,"node_modules/.jiek",...r);f.default.existsSync(t())||f.default.mkdirSync(t());const o=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let a=0;for(const[e,n]of Object.entries(r)){const r=b(n,e),s=n.name?.replace(/^@/g,"").replace(/\//g,"+"),i=t(`${s??"anonymous-"+a++}.rollup.config.js`);f.default.writeFileSync(i,h(r));let l="";if("test"===process.env.NODE_ENV){l=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}k.execSync(`${l}${o} -c ${i}`,{cwd:e,stdio:"inherit"})}y()}));var O="0.1.12",S="YiJie's personal kits.";a.program.version(O).description(S).option("--root <root>","root path"),a.program.parse(process.argv)}(fs,path,getWorkspaceDir,filterWorkspacePackages,commander,jsYaml,bumper,childProcess,pkger,childProcess$1);
|
2
2
|
//# sourceMappingURL=index.iife.min.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.iife.min.js","sources":["../src/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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AAM,iBAEpD,MAAA,IAAIwD,MAAM,4DAEZ,MAAAE,EAAcrB,KAAKQ,MAAMZ,EAAGa,aAAazC,EAAK5B,QAAQuB,EAAM,gBAAiB,UAC/E,IAAC0D,EAAYC,KACT,MAAA,IAAIH,MAAM,4DAElBtD,EAASwD,EAAYC,IACvB,CACA,MAAMjD,sBAAEA,SAAgCC,EAAAA,sBAAsBH,EAAI,CAAC,CACjEN,OAAQA,GAAU,GAClBU,oBAAoB,IAClB,CACFC,OAAQb,EACRc,aAAcN,EACdO,SAAUuC,EAAcM,WAEpBC,EAAc,IAAIC,IAAoBzD,EAAK5B,QAAQ+B,EAAI,wBAAyBsD,GACjF7B,EAAGwB,WAAWI,MAAmB5B,EAAA8B,UAAUF,KAEhD,MAAMG,EAAmBC,QAAQxF,QAAQ,UACtCyF,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAY9C,GAAOD,SAASrC,SAAEA,OAAiBkC,OAAOC,QAAQR,GAAwB,CAC9E,MAAAsB,EAAclD,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.iife.min.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([dir, manifest]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nimport pkg from '../package.json'\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["resolve","type","require","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","default","pnpmWorkspaceFileContent","fs","readFileSync","pnpmWorkspace","load","Error","existsSync","packageJSON","JSON","parse","name","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","packages","value","Object","entries","reduce","acc","key","package","manifest","actionDone","actionRestore","Promise","r","mergePackageJson","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","option","command","aliases","action","bumper","options","selectedProjectsGraphEntries","length","mainfests","forEach","dir","push","passArgs","m","newVersion","bump","version","newManifest","renameSync","join","writeFileSync","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","commander","keys","jiekTempDir","paths","mkdirSync","rollupBinaryPath","replace","i","escapeManifestName","configFile","pkg","description","argv"],"mappings":"8ZAQO,ICRHA,EDQOC,EAAO,GAElB,IACEC,QAAQF,QAAQ,mCACTC,EAAA,MACT,CAAQ,MAAc,CActBE,eAAsBC,IAChB,IAAAC,EAASC,EAAAA,QAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAAA,QAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAAA,QAAKC,WAAWH,GACdA,EACAE,EAAAA,QAAKV,QAAQY,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,IACIC,EADAC,GAAe,EAEf,IACGD,EAAAE,EAAAA,gBAAgBP,EAAMR,SACpBgB,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDH,EAAAL,EACUM,GAAA,CAInB,CACI,IAACA,GAAyB,SAATd,EAAiB,CACpC,MAAMkB,EAAwBT,EAAAU,QAAKpB,QAAQc,EAAI,uBACzCO,EAA2BC,EAAAF,QAAGG,aAAaJ,EAAuB,SAClEK,EAAgBC,OAAKJ,GAGvB,GAAAZ,IAASK,IAAOT,EACZ,MAAA,IAAIqB,MAAM,wDAGd,GAAAjB,IAASK,IAAOT,EAAQ,CAE1B,IAD2BiB,EAAGF,QAAAO,WAAWjB,EAAAA,QAAKV,QAAQS,EAAM,iBAEpD,MAAA,IAAIiB,MAAM,4DAEZ,MAAAE,EAAcC,KAAKC,MAAMR,EAAGF,QAAAG,aAAab,UAAKV,QAAQS,EAAM,gBAAiB,UAC/E,IAACmB,EAAYG,KACT,MAAA,IAAIL,MAAM,4DAElBrB,EAASuB,EAAYG,IACvB,CACA,MAAMC,sBAAEA,SAAgCC,EAAAA,sBAAsBnB,EAAI,CAAC,CACjET,OAAQA,GAAU,GAClB6B,oBAAoB,IAClB,CACFC,OAAQ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