jiek 0.2.1 → 0.2.2-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/bin/jiek.js +8 -1
  2. package/dist/base.esm.d.ts +55 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.esm.d.ts +2 -0
  5. package/dist/cli.esm.js +10 -0
  6. package/dist/cli.esm.js.map +1 -0
  7. package/dist/cli.esm.min.js +2 -0
  8. package/dist/cli.esm.min.js.map +1 -0
  9. package/dist/cli.iife.js +658 -0
  10. package/dist/cli.iife.js.map +1 -0
  11. package/dist/cli.iife.min.js +2 -0
  12. package/dist/cli.iife.min.js.map +1 -0
  13. package/dist/cli.umd.js +661 -0
  14. package/dist/cli.umd.js.map +1 -0
  15. package/dist/cli.umd.min.js +2 -0
  16. package/dist/cli.umd.min.js.map +1 -0
  17. package/dist/commands/build.esm.js +3 -4
  18. package/dist/commands/build.esm.js.map +1 -1
  19. package/dist/commands/build.esm.min.js +1 -1
  20. package/dist/commands/build.esm.min.js.map +1 -1
  21. package/dist/commands/init.esm.js +271 -0
  22. package/dist/commands/init.esm.js.map +1 -0
  23. package/dist/commands/init.esm.min.js +2 -0
  24. package/dist/commands/init.esm.min.js.map +1 -0
  25. package/dist/index.d.ts +56 -1
  26. package/dist/index.esm.d.ts +5 -1
  27. package/dist/index.esm.js +2 -7
  28. package/dist/index.esm.js.map +1 -1
  29. package/dist/index.esm.min.js +1 -1
  30. package/dist/index.esm.min.js.map +1 -1
  31. package/dist/index.iife.js +6 -289
  32. package/dist/index.iife.js.map +1 -1
  33. package/dist/index.iife.min.js +1 -1
  34. package/dist/index.iife.min.js.map +1 -1
  35. package/dist/index.umd.js +6 -291
  36. package/dist/index.umd.js.map +1 -1
  37. package/dist/index.umd.min.js +1 -1
  38. package/dist/index.umd.min.js.map +1 -1
  39. package/dist/utils/filterSupport.esm.js +4 -15
  40. package/dist/utils/filterSupport.esm.js.map +1 -1
  41. package/dist/utils/filterSupport.esm.min.js +1 -1
  42. package/dist/utils/filterSupport.esm.min.js.map +1 -1
  43. package/dist/utils/getRoot.esm.js +14 -0
  44. package/dist/utils/getRoot.esm.js.map +1 -0
  45. package/dist/utils/getRoot.esm.min.js +2 -0
  46. package/dist/utils/getRoot.esm.min.js.map +1 -0
  47. package/dist/utils/getWD.esm.js +25 -0
  48. package/dist/utils/getWD.esm.js.map +1 -0
  49. package/dist/utils/getWD.esm.min.js +2 -0
  50. package/dist/utils/getWD.esm.min.js.map +1 -0
  51. package/dist/utils/loadConfig.esm.js +75 -0
  52. package/dist/utils/loadConfig.esm.js.map +1 -0
  53. package/dist/utils/loadConfig.esm.min.js +2 -0
  54. package/dist/utils/loadConfig.esm.min.js.map +1 -0
  55. package/dist/utils/tsRegister.esm.js +24 -0
  56. package/dist/utils/tsRegister.esm.js.map +1 -0
  57. package/dist/utils/tsRegister.esm.min.js +2 -0
  58. package/dist/utils/tsRegister.esm.min.js.map +1 -0
  59. package/package.json +14 -4
  60. package/bin/jiek-dev.js +0 -4
package/dist/index.umd.js CHANGED
@@ -1,297 +1,12 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('node:fs'), require('node:path'), require('@jiek/utils/getWorkspaceDir'), require('@pnpm/filter-workspace-packages'), require('commander'), require('js-yaml'), require('@jiek/utils/bumper'), require('child_process'), require('detect-indent'), require('jsonc-parser'), require('@jiek/pkger'), require('node:child_process')) :
3
- typeof define === 'function' && define.amd ? define(['node:fs', 'node:path', '@jiek/utils/getWorkspaceDir', '@pnpm/filter-workspace-packages', 'commander', 'js-yaml', '@jiek/utils/bumper', 'child_process', 'detect-indent', 'jsonc-parser', '@jiek/pkger', 'node:child_process'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.fs, global.path, global.getWorkspaceDir, global.filterWorkspacePackages, global.commander, global.jsYaml, global.bumper, global.childProcess, global.detectIndent, global.jsoncParser, global.pkger, global.childProcess$1));
5
- })(this, (function (fs, path, getWorkspaceDir, filterWorkspacePackages, commander, jsYaml, bumper, childProcess, detectIndent, jsoncParser, pkger, childProcess$1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jiek = {}));
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+ const defineConfig = (config) => config;
8
8
 
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n.default = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var fs__default = /*#__PURE__*/_interopDefault(fs);
28
- var path__default = /*#__PURE__*/_interopDefault(path);
29
- var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
30
- var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
31
- var childProcess__namespace$1 = /*#__PURE__*/_interopNamespace(childProcess$1);
32
-
33
- let type = "";
34
- try {
35
- require.resolve("@pnpm/filter-workspace-packages");
36
- type = "pnpm";
37
- } catch {
38
- }
39
- if (type !== "") {
40
- commander.program.option("-f, --filter <filter>", "filter packages");
41
- }
42
- async function getSelectedProjectsGraph() {
43
- let filter = commander.program.getOptionValue("filter");
44
- const rootOption = commander.program.getOptionValue("root");
45
- const root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : process.cwd();
46
- let notWorkspace = false;
47
- let wd;
48
- try {
49
- wd = getWorkspaceDir.getWorkspaceDir(root, type);
50
- } catch (e) {
51
- if ("message" in e && e.message === "workspace root not found") {
52
- wd = root;
53
- notWorkspace = true;
54
- } else {
55
- throw e;
56
- }
57
- }
58
- if (!notWorkspace && type === "pnpm") {
59
- const pnpmWorkspaceFilePath = path__default.default.resolve(wd, "pnpm-workspace.yaml");
60
- const pnpmWorkspaceFileContent = fs__default.default.readFileSync(pnpmWorkspaceFilePath, "utf-8");
61
- const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
62
- if (root === wd && !filter) {
63
- throw new Error("root path is workspace root, please provide a filter");
64
- }
65
- if (root !== wd && !filter) {
66
- const packageJSONIsExist = fs__default.default.existsSync(path__default.default.resolve(root, "package.json"));
67
- if (!packageJSONIsExist) {
68
- throw new Error("root path is not workspace root, please provide a filter");
69
- }
70
- const packageJSON = JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(root, "package.json"), "utf-8"));
71
- if (!packageJSON.name) {
72
- throw new Error("root path is not workspace root, please provide a filter");
73
- }
74
- filter = packageJSON.name;
75
- }
76
- const { selectedProjectsGraph } = await filterWorkspacePackages.filterPackagesFromDir(wd, [{
77
- filter: filter ?? "",
78
- followProdDepsOnly: true
79
- }], {
80
- prefix: root,
81
- workspaceDir: wd,
82
- patterns: pnpmWorkspace.packages
83
- });
84
- return {
85
- wd,
86
- root,
87
- value: Object.entries(selectedProjectsGraph).reduce((acc, [key, value]) => {
88
- acc[key] = value.package.manifest;
89
- return acc;
90
- }, {})
91
- };
92
- }
93
- return {
94
- wd,
95
- root,
96
- value: {
97
- [wd]: JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(wd, "package.json"), "utf-8"))
98
- }
99
- };
100
- }
101
-
102
- let resolve;
103
- function actionDone() {
104
- resolve();
105
- }
106
- function actionRestore() {
107
- new Promise((r) => resolve = r);
108
- }
109
-
110
- function commondir(files, cwd = process.cwd()) {
111
- const resolvedFiles = files.map((file) => {
112
- if (path__default.default.isAbsolute(file))
113
- return file;
114
- return path__default.default.resolve(cwd, file);
115
- });
116
- const sep = "/";
117
- const [first = ""] = resolvedFiles;
118
- const parts = first.split(sep);
119
- let common = "";
120
- for (let i = 0; i < parts.length; i++) {
121
- const segment = parts[i];
122
- if (resolvedFiles.every((file) => file.startsWith(common + segment))) {
123
- common += segment + sep;
124
- } else {
125
- break;
126
- }
127
- }
128
- return common;
129
- }
130
-
131
- function mergePackageJson(manifest, cwd) {
132
- const {
133
- jiek: { cwd: _, ...jiek } = {}
134
- } = manifest;
135
- let { exports } = manifest;
136
- let includeIndex = false;
137
- if (typeof exports === "string") {
138
- includeIndex = true;
139
- exports = { ".": exports };
140
- }
141
- if (exports === void 0) {
142
- exports = { ".": "./src/index.ts" };
143
- }
144
- if (typeof exports === "object") {
145
- if (Array.isArray(exports) && exports.length > 0) {
146
- includeIndex = true;
147
- } else {
148
- includeIndex = !!exports["."];
149
- }
150
- }
151
- const inputs = Array.isArray(exports) ? exports : Object.entries(exports).reduce((acc, [key, value]) => {
152
- if (typeof value === "string")
153
- return key === "." ? [value, ...acc] : acc.concat(value);
154
- if (Array.isArray(value))
155
- return acc.concat(value);
156
- throw new TypeError(`Unexpected value type for key "${key}" in exports, expected string, got ${typeof value}`);
157
- }, []);
158
- if (inputs.length === 0)
159
- throw new Error("No inputs found");
160
- const absoluteInputs = inputs.map(
161
- (input) => path__default.default.isAbsolute(input) ? input : path__default.default.resolve(cwd, input)
162
- );
163
- let cDir = path__default.default.dirname(absoluteInputs[0]);
164
- if (absoluteInputs.length > 1) {
165
- cDir = commondir(absoluteInputs, cwd);
166
- }
167
- const resolvedInputs = absoluteInputs.map((input) => {
168
- return path__default.default.relative(cDir, input);
169
- });
170
- return {
171
- ...manifest,
172
- ...pkger.pkger({
173
- cwd,
174
- noIndex: !includeIndex,
175
- source: path__default.default.relative(cwd, cDir),
176
- inputs: resolvedInputs,
177
- ...jiek
178
- })
179
- };
180
- }
181
-
182
- commander.program.command("publish").aliases(["pub", "p"]).option("-b, --bumper <bumper>", "bump version", "patch").option("-p, --preview", "preview publish").action(async ({ preview, bumper: bumper$1, ...options }) => {
183
- actionRestore();
184
- const { value = {} } = await getSelectedProjectsGraph() ?? {};
185
- const selectedProjectsGraphEntries = Object.entries(value);
186
- if (selectedProjectsGraphEntries.length === 0) {
187
- throw new Error("no packages selected");
188
- }
189
- const mainfests = selectedProjectsGraphEntries.map(([dir, manifest]) => [
190
- dir,
191
- mergePackageJson(manifest, dir)
192
- ]);
193
- const passArgs = Object.entries(options).reduce((acc, [key, value2]) => {
194
- if (value2) {
195
- acc.push(`--${key}`, value2);
196
- }
197
- return acc;
198
- }, []);
199
- for (const [dir, manifest] of mainfests) {
200
- const oldJSONString = fs__default.default.readFileSync(path__default.default.join(dir, "package.json"), "utf-8");
201
- const oldJSON = JSON.parse(oldJSONString) ?? "0.0.0";
202
- const newVersion = bumper.bump(oldJSON.version, bumper$1);
203
- const { indent = " " } = detectIndent__default.default(oldJSONString);
204
- const formattingOptions = {
205
- tabSize: indent.length,
206
- insertSpaces: true
207
- };
208
- let newJSONString = oldJSONString;
209
- newJSONString = jsoncParser.applyEdits(newJSONString, jsoncParser.modify(
210
- newJSONString,
211
- ["version"],
212
- newVersion,
213
- { formattingOptions }
214
- ));
215
- for (const [key, value2] of Object.entries(manifest)) {
216
- if (JSON.stringify(value2) === JSON.stringify(oldJSON[key]))
217
- continue;
218
- newJSONString = jsoncParser.applyEdits(newJSONString, jsoncParser.modify(
219
- newJSONString,
220
- ["publishConfig", key],
221
- value2,
222
- { formattingOptions }
223
- ));
224
- }
225
- try {
226
- fs__default.default.renameSync(path__default.default.join(dir, "package.json"), path__default.default.join(dir, "package.json.bak"));
227
- fs__default.default.writeFileSync(path__default.default.join(dir, "package.json"), newJSONString);
228
- console.log(newJSONString);
229
- if (preview) {
230
- console.warn("preview mode");
231
- continue;
232
- }
233
- childProcess__namespace.execSync(["pnpm", "publish", "--access", "public", "--no-git-checks", ...passArgs].join(" "), {
234
- cwd: dir,
235
- stdio: "inherit"
236
- });
237
- const modifyVersionPackageJSON = jsoncParser.applyEdits(oldJSONString, jsoncParser.modify(oldJSONString, ["version"], newVersion, {}));
238
- fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), modifyVersionPackageJSON);
239
- } finally {
240
- fs__default.default.unlinkSync(path__default.default.join(dir, "package.json"));
241
- fs__default.default.renameSync(path__default.default.join(dir, "package.json.bak"), path__default.default.join(dir, "package.json"));
242
- }
243
- }
244
- actionDone();
245
- });
246
-
247
- const FILE_TEMPLATE = (manifest) => `
248
- const pkg = ${JSON.stringify(manifest, null, 2)}
249
- const { jiek = {} } = pkg
250
- const templateArg = jiek.templateArgFilePath
251
- ? require.resolve(jiek.templateArgFilePath)
252
- : {
253
- styled: jiek.styled
254
- }
255
- module.exports = require('jiek/rollup').template(templateArg, pkg)
256
- `.trimStart();
257
- commander.program.command("build").action(async () => {
258
- actionRestore();
259
- const {
260
- wd,
261
- value = {}
262
- } = await getSelectedProjectsGraph() ?? {};
263
- if (Object.keys(value).length === 0) {
264
- throw new Error("no package found");
265
- }
266
- const jiekTempDir = (...paths) => path__default.default.resolve(wd, "node_modules/.jiek", ...paths);
267
- if (!fs__default.default.existsSync(jiekTempDir()))
268
- fs__default.default.mkdirSync(jiekTempDir());
269
- const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
270
- let i = 0;
271
- for (const [dir, manifest] of Object.entries(value)) {
272
- const newManifest = mergePackageJson(manifest, dir);
273
- const escapeManifestName = manifest.name?.replace(/^@/g, "").replace(/\//g, "+");
274
- const configFile = jiekTempDir(
275
- `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
276
- );
277
- fs__default.default.writeFileSync(configFile, FILE_TEMPLATE(newManifest));
278
- let prefix = "";
279
- if (process.env.NODE_ENV === "test") {
280
- const registerPath = require.resolve("esbuild-register");
281
- const loaderPath = require.resolve("esbuild-register/loader");
282
- prefix = `node --import ${registerPath} -r ${loaderPath} `;
283
- }
284
- childProcess__namespace$1.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {
285
- cwd: dir,
286
- stdio: "inherit"
287
- });
288
- }
289
- actionDone();
290
- });
291
-
292
- const pkg = require("../package.json");
293
- commander.program.version(pkg.version).description(pkg.description).option("--root <root>", "root path");
294
- commander.program.parse(process.argv);
9
+ exports.defineConfig = defineConfig;
295
10
 
296
11
  }));
297
12
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/utils/commondir.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 path from 'node:path'\n\nexport function commondir(files: string[], cwd = process.cwd()): string {\n const resolvedFiles = files.map(file => {\n if (path.isAbsolute(file)) return file\n return path.resolve(cwd, file)\n })\n const sep = '/'\n const [first = ''] = resolvedFiles\n const parts = first.split(sep)\n let common = ''\n for (let i = 0; i < parts.length; i++) {\n const segment = parts[i]\n if (resolvedFiles.every(file => file.startsWith(common + segment))) {\n common += segment + sep\n } else {\n break\n }\n }\n return common\n}\n","import path from 'node:path'\n\nimport { type Options, pkger } from '@jiek/pkger'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nimport { commondir } from './utils/commondir'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { cwd: _, ...jiek } = {}\n } = manifest\n let { exports } = manifest\n let includeIndex = false\n if (typeof exports === 'string') {\n includeIndex = true\n exports = { '.': exports }\n }\n if (exports === undefined) {\n exports = { '.': './src/index.ts' }\n }\n if (typeof exports === 'object') {\n if (Array.isArray(exports) && exports.length > 0) {\n includeIndex = true\n } else {\n includeIndex = !!(<Record<string, unknown>>exports)['.']\n }\n }\n const inputs = Array.isArray(exports)\n ? exports as string[]\n : Object\n .entries(<Record<string, unknown>>exports)\n .reduce((acc, [key, value]) => {\n if (typeof value === 'string') return key === '.'\n ? [value, ...acc]\n : acc.concat(value)\n if (Array.isArray(value)) return acc.concat(value)\n\n throw new TypeError(`Unexpected value type for key \"${key}\" in exports, expected string, got ${typeof value}`)\n }, [] as string[])\n if (inputs.length === 0)\n throw new Error('No inputs found')\n\n const absoluteInputs = inputs.map(input => path.isAbsolute(input)\n ? input\n : path.resolve(cwd, input)\n )\n let cDir = path.dirname(absoluteInputs[0])\n if (absoluteInputs.length > 1) {\n cDir = commondir(absoluteInputs, cwd)\n }\n const resolvedInputs = absoluteInputs.map(input => {\n return path.relative(cDir, input)\n })\n return {\n ...manifest,\n ...pkger({\n cwd,\n noIndex: !includeIndex,\n source: path.relative(cwd, cDir),\n inputs: resolvedInputs,\n ...jiek\n })\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('jiek/rollup').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["program","path","getWorkspaceDir","f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MAAM,GAAA,GAAM,QAAQ,iBAAiB,CAAA,CAAA;AAErCb,mBACG,CAAA,OAAA,CAAQ,GAAI,CAAA,OAAO,CACnB,CAAA,WAAA,CAAY,IAAI,WAAW,CAAA,CAC3B,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AAEtCA,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["import type { Config } from './base'\n\nexport const defineConfig = (config: Config) => config\n\nexport * from './base'\n"],"names":[],"mappings":";;;;;;AAEa,OAAA,YAAA,GAAe,CAAC,MAAmB,KAAA;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("node:fs"),require("node:path"),require("@jiek/utils/getWorkspaceDir"),require("@pnpm/filter-workspace-packages"),require("commander"),require("js-yaml"),require("@jiek/utils/bumper"),require("child_process"),require("detect-indent"),require("jsonc-parser"),require("@jiek/pkger"),require("node:child_process")):"function"==typeof define&&define.amd?define(["node:fs","node:path","@jiek/utils/getWorkspaceDir","@pnpm/filter-workspace-packages","commander","js-yaml","@jiek/utils/bumper","child_process","detect-indent","jsonc-parser","@jiek/pkger","node:child_process"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).fs,e.path,e.getWorkspaceDir,e.filterWorkspacePackages,e.commander,e.jsYaml,e.bumper,e.childProcess,e.detectIndent,e.jsoncParser,e.pkger,e.childProcess$1)}(this,(function(e,r,t,o,n,i,s,a,c,l,p,u){"use strict";function d(e){return e&&e.__esModule?e:{default:e}}function f(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var g=d(e),m=d(r),k=f(a),y=d(c),j=f(u);let w,h="";try{require.resolve("@pnpm/filter-workspace-packages"),h="pnpm"}catch{}async function b(){let e=n.program.getOptionValue("filter");const r=n.program.getOptionValue("root"),s=r?m.default.isAbsolute(r)?r:m.default.resolve(process.cwd(),r):process.cwd();let a,c=!1;try{a=t.getWorkspaceDir(s,h)}catch(e){if(!("message"in e)||"workspace root not found"!==e.message)throw e;a=s,c=!0}if(!c&&"pnpm"===h){const r=m.default.resolve(a,"pnpm-workspace.yaml"),t=g.default.readFileSync(r,"utf-8"),n=i.load(t);if(s===a&&!e)throw new Error("root path is workspace root, please provide a filter");if(s!==a&&!e){if(!g.default.existsSync(m.default.resolve(s,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const r=JSON.parse(g.default.readFileSync(m.default.resolve(s,"package.json"),"utf-8"));if(!r.name)throw new Error("root path is not workspace root, please provide a filter");e=r.name}const{selectedProjectsGraph:c}=await o.filterPackagesFromDir(a,[{filter:e??"",followProdDepsOnly:!0}],{prefix:s,workspaceDir:a,patterns:n.packages});return{wd:a,root:s,value:Object.entries(c).reduce(((e,[r,t])=>(e[r]=t.package.manifest,e)),{})}}return{wd:a,root:s,value:{[a]:JSON.parse(g.default.readFileSync(m.default.resolve(a,"package.json"),"utf-8"))}}}function v(){w()}function O(){new Promise((e=>w=e))}function S(e,r){const{jiek:{cwd:t,...o}={}}=e;let{exports:n}=e,i=!1;"string"==typeof n&&(i=!0,n={".":n}),void 0===n&&(n={".":"./src/index.ts"}),"object"==typeof n&&(i=!!(Array.isArray(n)&&n.length>0)||!!n["."]);const s=Array.isArray(n)?n:Object.entries(n).reduce(((e,[r,t])=>{if("string"==typeof t)return"."===r?[t,...e]:e.concat(t);if(Array.isArray(t))return e.concat(t);throw new TypeError(`Unexpected value type for key "${r}" in exports, expected string, got ${typeof t}`)}),[]);if(0===s.length)throw new Error("No inputs found");const a=s.map((e=>m.default.isAbsolute(e)?e:m.default.resolve(r,e)));let c=m.default.dirname(a[0]);a.length>1&&(c=function(e,r=process.cwd()){const t=e.map((e=>m.default.isAbsolute(e)?e:m.default.resolve(r,e))),[o=""]=t,n=o.split("/");let i="";for(let e=0;e<n.length;e++){const r=n[e];if(!t.every((e=>e.startsWith(i+r))))break;i+=r+"/"}return i}(a,r));const l=a.map((e=>m.default.relative(c,e)));return{...e,...p.pkger({cwd:r,noIndex:!i,source:m.default.relative(r,c),inputs:l,...o})}}""!==h&&n.program.option("-f, --filter <filter>","filter packages"),n.program.command("publish").aliases(["pub","p"]).option("-b, --bumper <bumper>","bump version","patch").option("-p, --preview","preview publish").action((async({preview:e,bumper:r,...t})=>{O();const{value:o={}}=await b()??{},n=Object.entries(o);if(0===n.length)throw new Error("no packages selected");const i=n.map((([e,r])=>[e,S(r,e)])),a=Object.entries(t).reduce(((e,[r,t])=>(t&&e.push(`--${r}`,t),e)),[]);for(const[t,o]of i){const n=g.default.readFileSync(m.default.join(t,"package.json"),"utf-8"),i=JSON.parse(n)??"0.0.0",c=s.bump(i.version,r),{indent:p=" "}=y.default(n),u={tabSize:p.length,insertSpaces:!0};let d=n;d=l.applyEdits(d,l.modify(d,["version"],c,{formattingOptions:u}));for(const[e,r]of Object.entries(o))JSON.stringify(r)!==JSON.stringify(i[e])&&(d=l.applyEdits(d,l.modify(d,["publishConfig",e],r,{formattingOptions:u})));try{if(g.default.renameSync(m.default.join(t,"package.json"),m.default.join(t,"package.json.bak")),g.default.writeFileSync(m.default.join(t,"package.json"),d),console.log(d),e){console.warn("preview mode");continue}k.execSync(["pnpm","publish","--access","public","--no-git-checks",...a].join(" "),{cwd:t,stdio:"inherit"});const r=l.applyEdits(n,l.modify(n,["version"],c,{}));g.default.writeFileSync(m.default.join(t,"package.json.bak"),r)}finally{g.default.unlinkSync(m.default.join(t,"package.json")),g.default.renameSync(m.default.join(t,"package.json.bak"),m.default.join(t,"package.json"))}}v()}));const q=e=>`\nconst pkg = ${JSON.stringify(e,null,2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('jiek/rollup').template(templateArg, pkg)\n`.trimStart();n.program.command("build").action((async()=>{O();const{wd:e,value:r={}}=await b()??{};if(0===Object.keys(r).length)throw new Error("no package found");const t=(...r)=>m.default.resolve(e,"node_modules/.jiek",...r);g.default.existsSync(t())||g.default.mkdirSync(t());const o=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let n=0;for(const[e,i]of Object.entries(r)){const r=S(i,e),s=i.name?.replace(/^@/g,"").replace(/\//g,"+"),a=t(`${s??"anonymous-"+n++}.rollup.config.js`);g.default.writeFileSync(a,q(r));let c="";if("test"===process.env.NODE_ENV){c=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}j.execSync(`${c}${o} -c ${a}`,{cwd:e,stdio:"inherit"})}v()}));const x=require("../package.json");n.program.version(x.version).description(x.description).option("--root <root>","root path"),n.program.parse(process.argv)}));
1
+ !function(e,f){"object"==typeof exports&&"undefined"!=typeof module?f(exports):"function"==typeof define&&define.amd?define(["exports"],f):f((e="undefined"!=typeof globalThis?globalThis:e||self).jiek={})}(this,(function(e){"use strict";e.defineConfig=e=>e}));
2
2
  //# sourceMappingURL=index.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.min.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/utils/commondir.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 path from 'node:path'\n\nimport { type Options, pkger } from '@jiek/pkger'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nimport { commondir } from './utils/commondir'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { cwd: _, ...jiek } = {}\n } = manifest\n let { exports } = manifest\n let includeIndex = false\n if (typeof exports === 'string') {\n includeIndex = true\n exports = { '.': exports }\n }\n if (exports === undefined) {\n exports = { '.': './src/index.ts' }\n }\n if (typeof exports === 'object') {\n if (Array.isArray(exports) && exports.length > 0) {\n includeIndex = true\n } else {\n includeIndex = !!(<Record<string, unknown>>exports)['.']\n }\n }\n const inputs = Array.isArray(exports)\n ? exports as string[]\n : Object\n .entries(<Record<string, unknown>>exports)\n .reduce((acc, [key, value]) => {\n if (typeof value === 'string') return key === '.'\n ? [value, ...acc]\n : acc.concat(value)\n if (Array.isArray(value)) return acc.concat(value)\n\n throw new TypeError(`Unexpected value type for key \"${key}\" in exports, expected string, got ${typeof value}`)\n }, [] as string[])\n if (inputs.length === 0)\n throw new Error('No inputs found')\n\n const absoluteInputs = inputs.map(input => path.isAbsolute(input)\n ? input\n : path.resolve(cwd, input)\n )\n let cDir = path.dirname(absoluteInputs[0])\n if (absoluteInputs.length > 1) {\n cDir = commondir(absoluteInputs, cwd)\n }\n const resolvedInputs = absoluteInputs.map(input => {\n return path.relative(cDir, input)\n })\n return {\n ...manifest,\n ...pkger({\n cwd,\n noIndex: !includeIndex,\n source: path.relative(cwd, cDir),\n inputs: resolvedInputs,\n ...jiek\n })\n }\n}\n","import path from 'node:path'\n\nexport function commondir(files: string[], cwd = process.cwd()): string {\n const resolvedFiles = files.map(file => {\n if (path.isAbsolute(file)) return file\n return path.resolve(cwd, file)\n })\n const sep = '/'\n const [first = ''] = resolvedFiles\n const parts = first.split(sep)\n let common = ''\n for (let i = 0; i < parts.length; i++) {\n const segment = parts[i]\n if (resolvedFiles.every(file => file.startsWith(common + segment))) {\n common += segment + sep\n } else {\n break\n }\n }\n return common\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('jiek/rollup').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["resolve","type","require","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","default","pnpmWorkspaceFileContent","fs","readFileSync","pnpmWorkspace","load","Error","existsSync","packageJSON","JSON","parse","name","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","packages","value","Object","entries","reduce","acc","key","package","manifest","actionDone","actionRestore","Promise","r","mergePackageJson","jiek","_","exports","includeIndex","Array","isArray","length","inputs","concat","TypeError","absoluteInputs","map","input","cDir","dirname","files","resolvedFiles","file","first","parts","split","common","i","segment","every","startsWith","commondir","resolvedInputs","relative","pkger","noIndex","source","option","command","aliases","action","preview","bumper","options","selectedProjectsGraphEntries","mainfests","dir","passArgs","push","oldJSONString","join","oldJSON","newVersion","bump","version","indent","detectIndent","formattingOptions","tabSize","insertSpaces","newJSONString","applyEdits","modify","stringify","renameSync","writeFileSync","console","log","warn","childProcess","execSync","stdio","modifyVersionPackageJSON","unlinkSync","FILE_TEMPLATE","trimStart","commander","keys","jiekTempDir","paths","mkdirSync","rollupBinaryPath","replace","newManifest","escapeManifestName","configFile","env","NODE_ENV","pkg","description","argv"],"mappings":"4wCAQO,ICRHA,EDQOC,EAAO,GAElB,IACEC,QAAQF,QAAQ,mCACTC,EAAA,MACT,CAAQ,MAAc,CActBE,eAAsBC,IAChB,IAAAC,EAASC,EAAAA,QAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAAA,QAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAAA,QAAKC,WAAWH,GACdA,EACAE,EAAAA,QAAKV,QAAQY,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,IACIC,EADAC,GAAe,EAEf,IACGD,EAAAE,EAAAA,gBAAgBP,EAAMR,SACpBgB,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDH,EAAAL,EACUM,GAAA,CAInB,CACI,IAACA,GAAyB,SAATd,EAAiB,CACpC,MAAMkB,EAAwBT,EAAAU,QAAKpB,QAAQc,EAAI,uBACzCO,EAA2BC,EAAAF,QAAGG,aAAaJ,EAAuB,SAClEK,EAAgBC,OAAKJ,GAGvB,GAAAZ,IAASK,IAAOT,EACZ,MAAA,IAAIqB,MAAM,wDAGd,GAAAjB,IAASK,IAAOT,EAAQ,CAE1B,IAD2BiB,EAAGF,QAAAO,WAAWjB,EAAAA,QAAKV,QAAQS,EAAM,iBAEpD,MAAA,IAAIiB,MAAM,4DAEZ,MAAAE,EAAcC,KAAKC,MAAMR,EAAGF,QAAAG,aAAab,UAAKV,QAAQS,EAAM,gBAAiB,UAC/E,IAACmB,EAAYG,KACT,MAAA,IAAIL,MAAM,4DAElBrB,EAASuB,EAAYG,IACvB,CACA,MAAMC,sBAAEA,SAAgCC,EAAAA,sBAAsBnB,EAAI,CAAC,CACjET,OAAQA,GAAU,GAClB6B,oBAAoB,IAClB,CACFC,OAAQ1B,EACR2B,aAActB,EACduB,SAAUb,EAAcc,WAEnB,MAAA,C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vEf,MAAM0E,EAAiB3E,GAAsB,iBAC/BjB,KAAKiF,UAAUhE,EAAU,KAAM,wOAQ3C4E,YAEFC,EAAArH,QACG+E,QAAQ,SACRE,QAAOpF,UACQ6C,IACR,MAAAlC,GACJA,EAAAyB,MAAIA,EAAQ,CAAC,SACLnC,KAA8B,GAExC,GAAkC,IAA9BoC,OAAOoF,KAAKrF,GAAOmB,OACf,MAAA,IAAIhC,MAAM,oBAEZ,MAAAmG,EAAc,IAAIC,IAAoBpH,EAAAU,QAAKpB,QAAQc,EAAI,wBAAyBgH,GACjFxG,EAAAF,QAAGO,WAAWkG,MAAmBvG,UAAAyG,UAAUF,KAEhD,MAAMG,EAAmB9H,QAAQF,QAAQ,UACtCiI,QAAQ,mBAAoB,mBAC/B,IAAIvD,EAAI,EACR,IAAA,MAAYmB,EAAK/C,KAAaN,OAAOC,QAAQF,GAAQ,CAC7C,MAAA2F,EAAc/E,EAAiBL,EAAU+C,GAEzCsC,EAAqBrF,EAASf,MAAMkG,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtEG,EAAaP,EACjB,GAAGM,GAAsB,aAAazD,wBAExCpD,EAAAA,QAAG0F,cAAcoB,EAAYX,EAAcS,IAC3C,IAAI/F,EAAS,GACT,GAAyB,SAAzBvB,QAAQyH,IAAIC,SAAqB,CAG1BnG,EAAA,iBAFYjC,QAAQF,QAAQ,0BAClBE,QAAQF,QAAQ,6BAErC,CAEAoH,EAAaC,SAAS,GAAGlF,IAAS6F,QAAuBI,IAAc,CACrEvH,IAAKgF,EAAKyB,MAAO,WAErB,CAEWvE,GAAA,ICnDf,MAAMwF,EAAMrI,QAAQ,mBAGjByH,EAAArH,QAAA+F,QAAQkC,EAAIlC,SACZmC,YAAYD,EAAIC,aAChBpD,OAAO,gBAAiB,aAE3B9E,EAAAA,QAAQwB,MAAMlB,QAAQ6H"}
1
+ {"version":3,"file":"index.umd.min.js","sources":["../src/index.ts"],"sourcesContent":["import type { Config } from './base'\n\nexport const defineConfig = (config: Config) => config\n\nexport * from './base'\n"],"names":["config"],"mappings":"2PAE6BA,GAAmBA"}
@@ -1,9 +1,10 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
4
3
  import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages';
5
4
  import { program } from 'commander';
6
5
  import { load } from 'js-yaml';
6
+ import { getRoot } from './getRoot.esm.js';
7
+ import { getWD } from './getWD.esm.js';
7
8
 
8
9
  let type = "";
9
10
  try {
@@ -16,20 +17,8 @@ if (type !== "") {
16
17
  }
17
18
  async function getSelectedProjectsGraph() {
18
19
  let filter = program.getOptionValue("filter");
19
- const rootOption = program.getOptionValue("root");
20
- const root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : process.cwd();
21
- let notWorkspace = false;
22
- let wd;
23
- try {
24
- wd = getWorkspaceDir(root, type);
25
- } catch (e) {
26
- if ("message" in e && e.message === "workspace root not found") {
27
- wd = root;
28
- notWorkspace = true;
29
- } else {
30
- throw e;
31
- }
32
- }
20
+ const root = getRoot();
21
+ const { wd, notWorkspace } = getWD();
33
22
  if (!notWorkspace && type === "pnpm") {
34
23
  const pnpmWorkspaceFilePath = path.resolve(wd, "pnpm-workspace.yaml");
35
24
  const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, "utf-8");
@@ -1 +1 @@
1
- {"version":3,"file":"filterSupport.esm.js","sources":["../../src/utils/filterSupport.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"],"names":[],"mappings":";;;;;;;AAQO,IAAI,IAA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K,EAAA,CAAC,GAAK,EAAA,KAAK,CAAM,KAAA;AAC7B,QAAI,GAAA,CAAA,GAAG,CAAI,GAAA,KAAA,CAAM,OAAQ,CAAA,QAAA,CAAA;AACzB,QAAO,OAAA,GAAA,CAAA;AAAA,OACT,EAAG,EAAyC,CAAA;AAAA,KAChD,CAAA;AAAA,GACF;AACA,EAAO,OAAA;AAAA,IACL,EAAA;AAAA,IAAI,IAAA;AAAA,IACJ,KAAO,EAAA;AAAA,MACL,CAAC,EAAE,GAAG,IAAA,CAAK,KAAM,CAAA,EAAA,CAAG,YAAa,CAAA,IAAA,CAAK,OAAQ,CAAA,EAAA,EAAI,cAAc,CAAA,EAAG,OAAO,CAAC,CAAA;AAAA,KAC7E;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"filterSupport.esm.js","sources":["../../src/utils/filterSupport.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\nimport { getRoot } from './getRoot'\nimport { getWD } from './getWD'\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 root = getRoot()\n const { wd, notWorkspace } = getWD()\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"],"names":[],"mappings":";;;;;;;;AAWO,IAAI,IAAO,GAAA,GAAA;AAElB,IAAI;AACF,EAAA,OAAA,CAAQ,QAAQ,iCAAiC,CAAA,CAAA;AACjD,EAAO,IAAA,GAAA,MAAA,CAAA;AACT,CAAQ,CAAA,MAAA;AAAc,CAAA;AACtB,IAAI,SAAS,EAAI,EAAA;AACf,EACG,OAAA,CAAA,MAAA,CAAO,yBAAyB,iBAAiB,CAAA,CAAA;AACtD,CAAA;AAUA,eAAsB,wBAAmD,GAAA;AACvE,EAAI,IAAA,MAAA,GAAS,OAAQ,CAAA,cAAA,CAAe,QAAQ,CAAA,CAAA;AAC5C,EAAA,MAAM,OAAO,OAAQ,EAAA,CAAA;AACrB,EAAA,MAAM,EAAE,EAAA,EAAI,YAAa,EAAA,GAAI,KAAM,EAAA,CAAA;AACnC,EAAI,IAAA,CAAC,YAAgB,IAAA,IAAA,KAAS,MAAQ,EAAA;AACpC,IAAA,MAAM,qBAAwB,GAA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AAAA,MACL,EAAA;AAAA,MAAI,IAAA;AAAA,MACJ,KAAA,EAAO,MAAO,CAAA,OAAA,CAAQ,qBAAqB,CAAA,CACxC,MAAO,CAAA,CAAC,GAAK,EAAA,CAAC,GAAK,EAAA,KAAK,CAAM,KAAA;AAC7B,QAAI,GAAA,CAAA,GAAG,CAAI,GAAA,KAAA,CAAM,OAAQ,CAAA,QAAA,CAAA;AACzB,QAAO,OAAA,GAAA,CAAA;AAAA,OACT,EAAG,EAAyC,CAAA;AAAA,KAChD,CAAA;AAAA,GACF;AACA,EAAO,OAAA;AAAA,IACL,EAAA;AAAA,IAAI,IAAA;AAAA,IACJ,KAAO,EAAA;AAAA,MACL,CAAC,EAAE,GAAG,IAAA,CAAK,KAAM,CAAA,EAAA,CAAG,YAAa,CAAA,IAAA,CAAK,OAAQ,CAAA,EAAA,EAAI,cAAc,CAAA,EAAG,OAAO,CAAC,CAAA;AAAA,KAC7E;AAAA,GACF,CAAA;AACF;;;;"}
@@ -1,2 +1,2 @@
1
- import e from"node:fs";import r from"node:path";import{getWorkspaceDir as o}from"@jiek/utils/getWorkspaceDir";import{filterPackagesFromDir as t}from"@pnpm/filter-workspace-packages";import{program as a}from"commander";import{load as s}from"js-yaml";let p="";try{require.resolve("@pnpm/filter-workspace-packages"),p="pnpm"}catch{}async function i(){let i=a.getOptionValue("filter");const n=a.getOptionValue("root"),c=n?r.isAbsolute(n)?n:r.resolve(process.cwd(),n):process.cwd();let l,f=!1;try{l=o(c,p)}catch(e){if(!("message"in e)||"workspace root not found"!==e.message)throw e;l=c,f=!0}if(!f&&"pnpm"===p){const o=r.resolve(l,"pnpm-workspace.yaml"),a=e.readFileSync(o,"utf-8"),p=s(a);if(c===l&&!i)throw new Error("root path is workspace root, please provide a filter");if(c!==l&&!i){if(!e.existsSync(r.resolve(c,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const o=JSON.parse(e.readFileSync(r.resolve(c,"package.json"),"utf-8"));if(!o.name)throw new Error("root path is not workspace root, please provide a filter");i=o.name}const{selectedProjectsGraph:n}=await t(l,[{filter:i??"",followProdDepsOnly:!0}],{prefix:c,workspaceDir:l,patterns:p.packages});return{wd:l,root:c,value:Object.entries(n).reduce(((e,[r,o])=>(e[r]=o.package.manifest,e)),{})}}return{wd:l,root:c,value:{[l]:JSON.parse(e.readFileSync(r.resolve(l,"package.json"),"utf-8"))}}}""!==p&&a.option("-f, --filter <filter>","filter packages");export{i as getSelectedProjectsGraph,p as type};
1
+ import e from"node:fs";import r from"node:path";import{filterPackagesFromDir as o}from"@pnpm/filter-workspace-packages";import{program as t}from"commander";import{load as a}from"js-yaml";import{getRoot as p}from"./getRoot.esm.min.js";import{getWD as s}from"./getWD.esm.min.js";let i="";try{require.resolve("@pnpm/filter-workspace-packages"),i="pnpm"}catch{}async function n(){let n=t.getOptionValue("filter");const c=p(),{wd:l,notWorkspace:f}=s();if(!f&&"pnpm"===i){const t=r.resolve(l,"pnpm-workspace.yaml"),p=e.readFileSync(t,"utf-8"),s=a(p);if(c===l&&!n)throw new Error("root path is workspace root, please provide a filter");if(c!==l&&!n){if(!e.existsSync(r.resolve(c,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const o=JSON.parse(e.readFileSync(r.resolve(c,"package.json"),"utf-8"));if(!o.name)throw new Error("root path is not workspace root, please provide a filter");n=o.name}const{selectedProjectsGraph:i}=await o(l,[{filter:n??"",followProdDepsOnly:!0}],{prefix:c,workspaceDir:l,patterns:s.packages});return{wd:l,root:c,value:Object.entries(i).reduce(((e,[r,o])=>(e[r]=o.package.manifest,e)),{})}}return{wd:l,root:c,value:{[l]:JSON.parse(e.readFileSync(r.resolve(l,"package.json"),"utf-8"))}}}""!==i&&t.option("-f, --filter <filter>","filter packages");export{n as getSelectedProjectsGraph,i as type};
2
2
  //# sourceMappingURL=filterSupport.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filterSupport.esm.min.js","sources":["../../src/utils/filterSupport.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"],"names":["type","require","resolve","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","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","option"],"mappings":"yPAQO,IAAIA,EAAO,GAElB,IACEC,QAAQC,QAAQ,mCACTF,EAAA,MACT,CAAQ,MAAc,CActBG,eAAsBC,IAChB,IAAAC,EAASC,EAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAKC,WAAWH,GACdA,EACAE,EAAKR,QAAQU,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,IACIC,EADAC,GAAe,EAEf,IACGD,EAAAE,EAAgBP,EAAMT,SACpBiB,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDH,EAAAL,EACUM,GAAA,CAInB,CACI,IAACA,GAAyB,SAATf,EAAiB,CACpC,MAAMmB,EAAwBT,EAAKR,QAAQY,EAAI,uBACzCM,EAA2BC,EAAGC,aAAaH,EAAuB,SAClEI,EAAgBC,EAAKJ,GAGvB,GAAAX,IAASK,IAAOT,EACZ,MAAA,IAAIoB,MAAM,wDAGd,GAAAhB,IAASK,IAAOT,EAAQ,CAE1B,IAD2BgB,EAAGK,WAAWhB,EAAKR,QAAQO,EAAM,iBAEpD,MAAA,IAAIgB,MAAM,4DAEZ,MAAAE,EAAcC,KAAKC,MAAMR,EAAGC,aAAaZ,EAAKR,QAAQO,EAAM,gBAAiB,UAC/E,IAACkB,EAAYG,KACT,MAAA,IAAIL,MAAM,4DAElBpB,EAASsB,EAAYG,IACvB,CACA,MAAMC,sBAAEA,SAAgCC,EAAsBlB,EAAI,CAAC,CACjET,OAAQA,GAAU,GAClB4B,oBAAoB,IAClB,CACFC,OAAQzB,EACR0B,aAAcrB,EACdsB,SAAUb,EAAcc,WAEnB,MAAA,CACLvB,KAAIL,OACJ6B,MAAOC,OAAOC,QAAQT,GACnBU,QAAO,CAACC,GAAMC,EAAKL,MACdI,EAAAC,GAAOL,EAAMM,QAAQC,SAClBH,IACN,IAET,CACO,MAAA,CACL5B,KAAIL,OACJ6B,MAAO,CACLxB,CAACA,GAAKc,KAAKC,MAAMR,EAAGC,aAAaZ,EAAKR,QAAQY,EAAI,gBAAiB,WAGzE,CA9Ea,KAATd,GAECM,EAAAwC,OAAO,wBAAyB"}
1
+ {"version":3,"file":"filterSupport.esm.min.js","sources":["../../src/utils/filterSupport.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\nimport { getRoot } from './getRoot'\nimport { getWD } from './getWD'\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 root = getRoot()\n const { wd, notWorkspace } = getWD()\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"],"names":["type","require","resolve","async","getSelectedProjectsGraph","filter","program","getOptionValue","root","getRoot","wd","notWorkspace","getWD","pnpmWorkspaceFilePath","path","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","option"],"mappings":"qRAWO,IAAIA,EAAO,GAElB,IACEC,QAAQC,QAAQ,mCACTF,EAAA,MACT,CAAQ,MAAc,CActBG,eAAsBC,IAChB,IAAAC,EAASC,EAAQC,eAAe,UACpC,MAAMC,EAAOC,KACPC,GAAEA,EAAAC,aAAIA,GAAiBC,IACzB,IAACD,GAAyB,SAATX,EAAiB,CACpC,MAAMa,EAAwBC,EAAKZ,QAAQQ,EAAI,uBACzCK,EAA2BC,EAAGC,aAAaJ,EAAuB,SAClEK,EAAgBC,EAAKJ,GAGvB,GAAAP,IAASE,IAAOL,EACZ,MAAA,IAAIe,MAAM,wDAGd,GAAAZ,IAASE,IAAOL,EAAQ,CAE1B,IAD2BW,EAAGK,WAAWP,EAAKZ,QAAQM,EAAM,iBAEpD,MAAA,IAAIY,MAAM,4DAEZ,MAAAE,EAAcC,KAAKC,MAAMR,EAAGC,aAAaH,EAAKZ,QAAQM,EAAM,gBAAiB,UAC/E,IAACc,EAAYG,KACT,MAAA,IAAIL,MAAM,4DAElBf,EAASiB,EAAYG,IACvB,CACA,MAAMC,sBAAEA,SAAgCC,EAAsBjB,EAAI,CAAC,CACjEL,OAAQA,GAAU,GAClBuB,oBAAoB,IAClB,CACFC,OAAQrB,EACRsB,aAAcpB,EACdqB,SAAUb,EAAcc,WAEnB,MAAA,CACLtB,KAAIF,OACJyB,MAAOC,OAAOC,QAAQT,GACnBU,QAAO,CAACC,GAAMC,EAAKL,MACdI,EAAAC,GAAOL,EAAMM,QAAQC,SAClBH,IACN,IAET,CACO,MAAA,CACL3B,KAAIF,OACJyB,MAAO,CACLvB,CAACA,GAAKa,KAAKC,MAAMR,EAAGC,aAAaH,EAAKZ,QAAQQ,EAAI,gBAAiB,WAGzE,CA7Da,KAATV,GAECM,EAAAmC,OAAO,wBAAyB"}
@@ -0,0 +1,14 @@
1
+ import path from 'node:path';
2
+ import { program } from 'commander';
3
+
4
+ let root;
5
+ function getRoot() {
6
+ if (root)
7
+ return root;
8
+ const rootOption = program.getOptionValue("root");
9
+ root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : process.cwd();
10
+ return root;
11
+ }
12
+
13
+ export { getRoot };
14
+ //# sourceMappingURL=getRoot.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRoot.esm.js","sources":["../../src/utils/getRoot.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { program } from 'commander'\n\nlet root: string\nexport function getRoot() {\n if (root) return root\n\n const rootOption = program.getOptionValue('root')\n root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n return root\n}\n"],"names":[],"mappings":";;;AAIA,IAAI,IAAA,CAAA;AACG,SAAS,OAAU,GAAA;AACxB,EAAI,IAAA,IAAA;AAAM,IAAO,OAAA,IAAA,CAAA;AAEjB,EAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,cAAA,CAAe,MAAM,CAAA,CAAA;AAChD,EAAA,IAAA,GAAO,UACH,GAAA,IAAA,CAAK,UAAW,CAAA,UAAU,IACxB,UACA,GAAA,IAAA,CAAK,OAAQ,CAAA,OAAA,CAAQ,GAAI,EAAA,EAAG,UAAU,CAAA,GACxC,QAAQ,GAAI,EAAA,CAAA;AAChB,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
@@ -0,0 +1,2 @@
1
+ import o from"node:path";import{program as r}from"commander";let e;function t(){if(e)return e;const t=r.getOptionValue("root");return e=t?o.isAbsolute(t)?t:o.resolve(process.cwd(),t):process.cwd(),e}export{t as getRoot};
2
+ //# sourceMappingURL=getRoot.esm.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRoot.esm.min.js","sources":["../../src/utils/getRoot.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { program } from 'commander'\n\nlet root: string\nexport function getRoot() {\n if (root) return root\n\n const rootOption = program.getOptionValue('root')\n root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n return root\n}\n"],"names":["root","getRoot","rootOption","program","getOptionValue","path","isAbsolute","resolve","process","cwd"],"mappings":"6DAIA,IAAIA,EACG,SAASC,IACV,GAAAD,EAAa,OAAAA,EAEX,MAAAE,EAAaC,EAAQC,eAAe,QAMnC,OALPJ,EAAOE,EACHG,EAAKC,WAAWJ,GACdA,EACAG,EAAKE,QAAQC,QAAQC,MAAOP,GAC9BM,QAAQC,MACLT,CACT"}
@@ -0,0 +1,25 @@
1
+ import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
2
+ import { type } from './filterSupport.esm.js';
3
+ import { getRoot } from './getRoot.esm.js';
4
+
5
+ let wd;
6
+ let notWorkspace = false;
7
+ function getWD() {
8
+ if (wd)
9
+ return { wd, notWorkspace };
10
+ const root = getRoot();
11
+ try {
12
+ wd = getWorkspaceDir(root, type);
13
+ } catch (e) {
14
+ if ("message" in e && e.message === "workspace root not found") {
15
+ wd = root;
16
+ notWorkspace = true;
17
+ } else {
18
+ throw e;
19
+ }
20
+ }
21
+ return { wd, notWorkspace };
22
+ }
23
+
24
+ export { getWD };
25
+ //# sourceMappingURL=getWD.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWD.esm.js","sources":["../../src/utils/getWD.ts"],"sourcesContent":["import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\n\nimport { type } from './filterSupport'\nimport { getRoot } from './getRoot'\n\nlet wd: string\nlet notWorkspace = false\n\nexport function getWD() {\n if (wd) return { wd, notWorkspace }\n\n const root = getRoot()\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 return { wd, notWorkspace }\n}\n"],"names":[],"mappings":";;;;AAKA,IAAI,EAAA,CAAA;AACJ,IAAI,YAAe,GAAA,KAAA,CAAA;AAEZ,SAAS,KAAQ,GAAA;AACtB,EAAI,IAAA,EAAA;AAAI,IAAO,OAAA,EAAE,IAAI,YAAa,EAAA,CAAA;AAElC,EAAA,MAAM,OAAO,OAAQ,EAAA,CAAA;AACrB,EAAI,IAAA;AACF,IAAK,EAAA,GAAA,eAAA,CAAgB,MAAM,IAAI,CAAA,CAAA;AAAA,WACxB,CAAG,EAAA;AAEV,IAAA,IAAI,SAAa,IAAA,CAAA,IAAK,CAAE,CAAA,OAAA,KAAY,0BAA4B,EAAA;AAC9D,MAAK,EAAA,GAAA,IAAA,CAAA;AACL,MAAe,YAAA,GAAA,IAAA,CAAA;AAAA,KACV,MAAA;AACL,MAAM,MAAA,CAAA,CAAA;AAAA,KACR;AAAA,GACF;AACA,EAAO,OAAA,EAAE,IAAI,YAAa,EAAA,CAAA;AAC5B;;;;"}
@@ -0,0 +1,2 @@
1
+ import{getWorkspaceDir as o}from"@jiek/utils/getWorkspaceDir";import{type as t}from"./filterSupport.esm.min.js";import{getRoot as r}from"./getRoot.esm.min.js";let e,s=!1;function i(){if(e)return{wd:e,notWorkspace:s};const i=r();try{e=o(i,t)}catch(o){if(!("message"in o)||"workspace root not found"!==o.message)throw o;e=i,s=!0}return{wd:e,notWorkspace:s}}export{i as getWD};
2
+ //# sourceMappingURL=getWD.esm.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWD.esm.min.js","sources":["../../src/utils/getWD.ts"],"sourcesContent":["import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\n\nimport { type } from './filterSupport'\nimport { getRoot } from './getRoot'\n\nlet wd: string\nlet notWorkspace = false\n\nexport function getWD() {\n if (wd) return { wd, notWorkspace }\n\n const root = getRoot()\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 return { wd, notWorkspace }\n}\n"],"names":["wd","notWorkspace","getWD","root","getRoot","getWorkspaceDir","type","e","message"],"mappings":"+JAKA,IAAIA,EACAC,GAAe,EAEZ,SAASC,IACV,GAAAF,EAAW,MAAA,CAAEA,KAAIC,gBAErB,MAAME,EAAOC,IACT,IACGJ,EAAAK,EAAgBF,EAAMG,SACpBC,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDP,EAAAG,EACUF,GAAA,CAInB,CACO,MAAA,CAAED,KAAIC,eACf"}