jiek 2.2.7-alpha.3 → 2.2.7-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jiek-production-tag +0 -0
- package/dist/.internal/.chunks/{getWD.ZF0avqDB.cjs → filterSupport.4rM7f6jB.cjs} +38 -29
- package/dist/.internal/.chunks/{getWD.D6wq8Qc2.js → filterSupport.BXWpLBpT.js} +37 -28
- package/dist/.internal/.chunks/index.BHuJRlvZ.js +9059 -0
- package/dist/.internal/.chunks/index.Daihq2aI.cjs +9071 -0
- package/dist/.internal/.chunks/loadConfig.CFfzkm_p.js +110 -0
- package/dist/.internal/.chunks/loadConfig.OOKddvHF.cjs +117 -0
- package/dist/.internal/bin/common.cjs +757 -0
- package/dist/.internal/bin/common.d.cts +18 -0
- package/dist/.internal/bin/common.d.ts +18 -0
- package/dist/.internal/bin/common.js +750 -0
- package/dist/.internal/bridge.cjs +20 -2
- package/dist/.internal/bridge.js +19 -1
- package/dist/.internal/utils/filterSupport.cjs +1 -3
- package/dist/.internal/utils/filterSupport.js +1 -3
- package/dist/.internal/utils/loadConfig.cjs +8 -94
- package/dist/.internal/utils/loadConfig.js +7 -92
- package/dist/bin/build.cjs +2 -507
- package/dist/bin/index.cjs +5 -1
- package/package.json +2 -3
- package/src/bin/build.cts +2 -8
- package/src/bin/common.ts +3 -0
- package/src/bin/index.cts +2 -1
- package/src/commands/publish.ts +5 -0
- package/dist/.internal/.chunks/jiek_create-require.CWFWNQHj.cjs +0 -5
- package/dist/.internal/.chunks/jiek_create-require.CxSGbkTB.js +0 -5
- package/dist/.internal/commands/build/analyzer.cjs +0 -201
- package/dist/.internal/commands/build/analyzer.d.cts +0 -30
- package/dist/.internal/commands/build/analyzer.d.ts +0 -30
- package/dist/.internal/commands/build/analyzer.js +0 -195
- package/dist/.internal/commands/descriptions.cjs +0 -21
- package/dist/.internal/commands/descriptions.d.cts +0 -5
- package/dist/.internal/commands/descriptions.d.ts +0 -5
- package/dist/.internal/commands/descriptions.js +0 -17
- package/dist/.internal/commands/meta.cjs +0 -16
- package/dist/.internal/commands/meta.d.cts +0 -3
- package/dist/.internal/commands/meta.d.ts +0 -3
- package/dist/.internal/commands/meta.js +0 -15
- package/dist/.internal/commands/utils/optionParser.cjs +0 -8
- package/dist/.internal/commands/utils/optionParser.d.cts +0 -3
- package/dist/.internal/commands/utils/optionParser.d.ts +0 -3
- package/dist/.internal/commands/utils/optionParser.js +0 -6
- package/dist/.internal/server.cjs +0 -33
- package/dist/.internal/server.d.cts +0 -8
- package/dist/.internal/server.d.ts +0 -8
- package/dist/.internal/server.js +0 -27
- package/dist/.internal/utils/checkDependency.cjs +0 -39
- package/dist/.internal/utils/checkDependency.d.cts +0 -3
- package/dist/.internal/utils/checkDependency.d.ts +0 -3
- package/dist/.internal/utils/checkDependency.js +0 -34
- package/dist/.internal/utils/getRoot.cjs +0 -17
- package/dist/.internal/utils/getRoot.d.cts +0 -3
- package/dist/.internal/utils/getRoot.d.ts +0 -3
- package/dist/.internal/utils/getRoot.js +0 -11
- package/dist/.internal/utils/getWD.cjs +0 -15
- package/dist/.internal/utils/getWD.d.cts +0 -6
- package/dist/.internal/utils/getWD.d.ts +0 -6
- package/dist/.internal/utils/getWD.js +0 -10
- package/dist/.internal/utils/tsRegister.cjs +0 -25
- package/dist/.internal/utils/tsRegister.d.cts +0 -3
- package/dist/.internal/utils/tsRegister.d.ts +0 -3
- package/dist/.internal/utils/tsRegister.js +0 -26
package/dist/bin/build.cjs
CHANGED
@@ -1,515 +1,10 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
var path = require('node:path');
|
5
|
-
var process = require('node:process');
|
6
|
-
var commander = require('commander');
|
7
|
-
require('js-yaml');
|
8
|
-
require('#~/utils/getRoot');
|
9
|
-
var getWD = require('#~/utils/getWD');
|
10
|
-
var descriptions = require('#~/commands/descriptions');
|
11
|
-
var meta = require('#~/commands/meta');
|
12
|
-
var filterSupport = require('#~/utils/filterSupport');
|
13
|
-
var cliProgress = require('cli-progress');
|
14
|
-
var execa = require('execa');
|
15
|
-
var analyzer = require('#~/commands/build/analyzer');
|
16
|
-
var optionParser = require('#~/commands/utils/optionParser');
|
17
|
-
var base = require('#~/rollup/base');
|
18
|
-
var server = require('#~/server');
|
19
|
-
var checkDependency = require('#~/utils/checkDependency');
|
20
|
-
var loadConfig = require('#~/utils/loadConfig');
|
21
|
-
var tsRegister = require('#~/utils/tsRegister');
|
3
|
+
require('#~/bin/common');
|
22
4
|
var parseArgv = require('#~/bin/parseArgv');
|
23
5
|
|
24
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
25
7
|
|
26
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
27
|
-
var process__default = /*#__PURE__*/_interopDefault(process);
|
28
8
|
var parseArgv__default = /*#__PURE__*/_interopDefault(parseArgv);
|
29
9
|
|
30
|
-
|
31
|
-
|
32
|
-
let type$1 = "";
|
33
|
-
try {
|
34
|
-
require$1.resolve("@pnpm/filter-workspace-packages");
|
35
|
-
type$1 = "pnpm";
|
36
|
-
} catch {
|
37
|
-
}
|
38
|
-
|
39
|
-
var name = "jiek";
|
40
|
-
var type = "module";
|
41
|
-
var version = "2.2.7-alpha.2";
|
42
|
-
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
43
|
-
var author = "YiJie <yijie4188@gmail.com>";
|
44
|
-
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
45
|
-
var repository = {
|
46
|
-
url: "nwylzw/jiek",
|
47
|
-
directory: "packages/jiek"
|
48
|
-
};
|
49
|
-
var bugs = "https://github.com/NWYLZW/jiek/issues?q=is%3Aissue+is%3Aopen+jiek";
|
50
|
-
var keywords = [
|
51
|
-
"cli",
|
52
|
-
"zero-config",
|
53
|
-
"bundler",
|
54
|
-
"library",
|
55
|
-
"monorepo",
|
56
|
-
"builder",
|
57
|
-
"rollup",
|
58
|
-
"workspace"
|
59
|
-
];
|
60
|
-
var exports$1 = {
|
61
|
-
"./package.json": "./package.json",
|
62
|
-
".": "./src/index.ts",
|
63
|
-
"./bin-helper": {
|
64
|
-
require: "./bin-helper/index.cjs",
|
65
|
-
"default": "./bin-helper/index.js"
|
66
|
-
},
|
67
|
-
"./rollup": "./src/rollup/index.ts"
|
68
|
-
};
|
69
|
-
var imports = {
|
70
|
-
"#~/*": "./src/*.ts"
|
71
|
-
};
|
72
|
-
var bin = {
|
73
|
-
jiek: "bin/index.cjs",
|
74
|
-
jk: "bin/index.cjs",
|
75
|
-
"jiek-build": "bin/build.cjs",
|
76
|
-
jb: "bin/build.cjs"
|
77
|
-
};
|
78
|
-
var files = [
|
79
|
-
"LICENSE",
|
80
|
-
"README.md",
|
81
|
-
"bin",
|
82
|
-
"bin-helper",
|
83
|
-
"dist",
|
84
|
-
"src"
|
85
|
-
];
|
86
|
-
var scripts = {
|
87
|
-
prepublish: "jb -nm && jk",
|
88
|
-
postpublish: "jk",
|
89
|
-
test: "vitest run"
|
90
|
-
};
|
91
|
-
var peerDependencies = {
|
92
|
-
"@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0||>=1000.0.0",
|
93
|
-
"@rollup/plugin-terser": "^0.4.4",
|
94
|
-
"esbuild-register": "^3.5.0",
|
95
|
-
postcss: "^8.4.47",
|
96
|
-
"rollup-plugin-esbuild": "^6.1.0",
|
97
|
-
"rollup-plugin-postcss": "^4.0.2",
|
98
|
-
"rollup-plugin-swc3": "^0.12.1",
|
99
|
-
typescript: "^4.0.0||^5.0.0",
|
100
|
-
"vite-bundle-analyzer": "0.16.0-beta.3"
|
101
|
-
};
|
102
|
-
var dependencies = {
|
103
|
-
"@inquirer/prompts": "^7.2.0",
|
104
|
-
"@jiek/pkger": "workspace:^",
|
105
|
-
"@jiek/rollup-plugin-dts": "^6.3.8",
|
106
|
-
"@jiek/utils": "workspace:^",
|
107
|
-
"@rollup/plugin-commonjs": "^28.0.0",
|
108
|
-
"@rollup/plugin-inject": "^5.0.5",
|
109
|
-
"@rollup/plugin-json": "^6.0.1",
|
110
|
-
"@rollup/plugin-node-resolve": "^15.3.0",
|
111
|
-
"cli-progress": "^3.12.0",
|
112
|
-
commander: "^12.0.0",
|
113
|
-
"detect-indent": "^6.1.0",
|
114
|
-
execa: "~9.3.1",
|
115
|
-
"js-yaml": "^4.1.0",
|
116
|
-
"jsonc-parser": "^3.2.1",
|
117
|
-
koa: "^2.15.3",
|
118
|
-
rollup: "^4.0.0"
|
119
|
-
};
|
120
|
-
var devDependencies = {
|
121
|
-
"@npm/types": "^1.0.2",
|
122
|
-
"@pnpm/filter-workspace-packages": "^7.2.13",
|
123
|
-
"@pnpm/workspace.pkgs-graph": "^2.0.15",
|
124
|
-
"@rollup/plugin-terser": "^0.4.4",
|
125
|
-
"@types/cli-progress": "^3.11.5",
|
126
|
-
"@types/inquirer": "^9.0.7",
|
127
|
-
"@types/js-yaml": "^4.0.9",
|
128
|
-
"@types/koa": "^2.15.0",
|
129
|
-
"@types/micromatch": "^4.0.6",
|
130
|
-
"@types/react": "^18.3.14",
|
131
|
-
"esbuild-register": "^3.5.0",
|
132
|
-
micromatch: "^4.0.5",
|
133
|
-
"node-sass": "^9.0.0",
|
134
|
-
postcss: "^8.4.47",
|
135
|
-
"rollup-plugin-esbuild": "^6.1.0",
|
136
|
-
"rollup-plugin-postcss": "^4.0.2",
|
137
|
-
"rollup-plugin-swc3": "^0.12.1",
|
138
|
-
"vite-bundle-analyzer": "0.16.0-beta.3"
|
139
|
-
};
|
140
|
-
var publishConfig = {
|
141
|
-
directory: "./dist/.internal"
|
142
|
-
};
|
143
|
-
var pkg = {
|
144
|
-
name: name,
|
145
|
-
type: type,
|
146
|
-
version: version,
|
147
|
-
description: description$1,
|
148
|
-
author: author,
|
149
|
-
homepage: homepage,
|
150
|
-
repository: repository,
|
151
|
-
bugs: bugs,
|
152
|
-
keywords: keywords,
|
153
|
-
exports: exports$1,
|
154
|
-
imports: imports,
|
155
|
-
bin: bin,
|
156
|
-
files: files,
|
157
|
-
scripts: scripts,
|
158
|
-
peerDependencies: peerDependencies,
|
159
|
-
dependencies: dependencies,
|
160
|
-
devDependencies: devDependencies,
|
161
|
-
publishConfig: publishConfig
|
162
|
-
};
|
163
|
-
|
164
|
-
commander.program.name("jk/jiek").version(pkg.version).description(`${pkg.description} - Version ${pkg.version}`).option("-c, --config-path <configPath>", "Custom jiek config path").option("--env.<name>=<value>", "Set the environment variable.");
|
165
|
-
if (filterSupport.type !== "" && meta.IS_WORKSPACE) {
|
166
|
-
commander.program.option("-f, --filter <filter>", descriptions.filterDescription);
|
167
|
-
}
|
168
|
-
|
169
|
-
const FILE_TEMPLATE = (manifest) => `
|
170
|
-
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
171
|
-
`.trimStart();
|
172
|
-
const ROLLUP_BIN = require$1.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
173
|
-
const isDefault = process__default.default.env.JIEK_BIN__FILENAME === "build.cjs";
|
174
|
-
const description = `
|
175
|
-
Build the package according to the 'exports' field from the package.json.
|
176
|
-
If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
|
177
|
-
${isDefault ? "This command is the default command." : ""}
|
178
|
-
`.trim();
|
179
|
-
let DEFAULT_BUILDER_TYPE;
|
180
|
-
Object.entries(base.BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
|
181
|
-
try {
|
182
|
-
require$1.resolve(packageName);
|
183
|
-
DEFAULT_BUILDER_TYPE = type;
|
184
|
-
} catch {
|
185
|
-
}
|
186
|
-
});
|
187
|
-
if (!DEFAULT_BUILDER_TYPE) {
|
188
|
-
DEFAULT_BUILDER_TYPE = "esbuild";
|
189
|
-
}
|
190
|
-
const buildFilterDescription = `
|
191
|
-
${descriptions.filterDescription}
|
192
|
-
If you pass the --filter option, it will merge into the filters of the command.
|
193
|
-
`.trim();
|
194
|
-
const buildEntriesDescription = `
|
195
|
-
${descriptions.entriesDescription}
|
196
|
-
If you pass the --entries option, it will merge into the entries of the command.
|
197
|
-
`.trim();
|
198
|
-
let command = isDefault ? (() => {
|
199
|
-
const c = commander.program.name("jb/jiek-build").helpCommand(false);
|
200
|
-
if (meta.IS_WORKSPACE) {
|
201
|
-
c.argument("[filters]", buildFilterDescription);
|
202
|
-
} else {
|
203
|
-
c.argument("[entries]", buildEntriesDescription);
|
204
|
-
}
|
205
|
-
return c;
|
206
|
-
})() : commander.program.command(`build [${meta.IS_WORKSPACE ? "filters" : "entries"}]`);
|
207
|
-
command = command.description(description).option("-t, --type <TYPE>", `The type of build, support ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
|
208
|
-
if (!base.BUILDER_TYPES.includes(v)) {
|
209
|
-
throw new Error(`The value of 'type' must be ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
|
210
|
-
}
|
211
|
-
return String(v);
|
212
|
-
}, "esbuild").option("-o, --outdir <OUTDIR>", descriptions.outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", descriptions.entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", optionParser.parseBoolean).option("-nj, --noJs", "Do not output js files.", optionParser.parseBoolean).option("-nd, --noDts", "Do not output dts files.", optionParser.parseBoolean).option("-nm, --noMin", "Do not output minify files.", optionParser.parseBoolean).option(
|
213
|
-
"--minType <MINTYPE>",
|
214
|
-
'The type of minify, support "builder" and "terser".',
|
215
|
-
(v) => {
|
216
|
-
if (!["builder", "terser"].includes(v)) {
|
217
|
-
throw new Error('The value of `minType` must be "builder" or "terser"');
|
218
|
-
}
|
219
|
-
return String(v);
|
220
|
-
}
|
221
|
-
).option("-nc, --noClean", "Do not clean the output directory before building.", optionParser.parseBoolean).option(
|
222
|
-
"-om, --onlyMin",
|
223
|
-
"Only output minify files, but dts files will still be output, it only replaces the js files.",
|
224
|
-
optionParser.parseBoolean
|
225
|
-
);
|
226
|
-
command = command.option("--features.keepImportAttributes", "Keep the import attributes in the output.");
|
227
|
-
command = command.option("--tsconfig <TSCONFIG>", "The path of the tsconfig file which is used to generate js and dts files.", String).option("--dtsconfig <DTSCONFIG>", "The path of the tsconfig file which is used to generate dts files.", String);
|
228
|
-
command = command.option("-w, --watch", "Watch the file changes.", optionParser.parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
|
229
|
-
command = analyzer.registerAnalyzerCommandOptions(command);
|
230
|
-
command = command.option("-s, --silent", "Don't display logs.", optionParser.parseBoolean).option("-v, --verbose", "Display debug logs.", optionParser.parseBoolean);
|
231
|
-
command.action(async (commandFiltersOrEntries, options) => {
|
232
|
-
let {
|
233
|
-
type,
|
234
|
-
outdir,
|
235
|
-
watch,
|
236
|
-
silent,
|
237
|
-
verbose,
|
238
|
-
entries: optionEntries,
|
239
|
-
external,
|
240
|
-
noConvert,
|
241
|
-
noJs: withoutJs,
|
242
|
-
noDts: withoutDts,
|
243
|
-
noMin: withoutMin,
|
244
|
-
minType: minifyType,
|
245
|
-
noClean,
|
246
|
-
onlyMin,
|
247
|
-
tsconfig,
|
248
|
-
dtsconfig
|
249
|
-
} = options;
|
250
|
-
const resolvedType = type ?? DEFAULT_BUILDER_TYPE;
|
251
|
-
if (!withoutJs) {
|
252
|
-
await checkDependency.checkDependency(base.BUILDER_TYPE_PACKAGE_NAME_MAP[resolvedType]);
|
253
|
-
if (minifyType === "builder") {
|
254
|
-
minifyType = resolvedType;
|
255
|
-
}
|
256
|
-
}
|
257
|
-
if (!withoutMin && minifyType === "terser") {
|
258
|
-
await checkDependency.checkDependency("@rollup/plugin-terser");
|
259
|
-
}
|
260
|
-
let shouldPassThrough = false;
|
261
|
-
const passThroughOptions = process__default.default.argv.reduce(
|
262
|
-
(acc, value) => {
|
263
|
-
if (shouldPassThrough) {
|
264
|
-
acc.push(value);
|
265
|
-
}
|
266
|
-
if (value === "--") {
|
267
|
-
shouldPassThrough = true;
|
268
|
-
}
|
269
|
-
return acc;
|
270
|
-
},
|
271
|
-
[]
|
272
|
-
);
|
273
|
-
const shouldCreateServer = [
|
274
|
-
options.ana === true && options["ana.mode"] === "server"
|
275
|
-
].some(Boolean);
|
276
|
-
const server$1 = shouldCreateServer ? server.createServer(options.port, "localhost") : void 0;
|
277
|
-
const {
|
278
|
-
ANALYZER_ENV,
|
279
|
-
refreshAnalyzer
|
280
|
-
} = await analyzer.useAnalyzer(options, server$1);
|
281
|
-
const { build } = loadConfig.loadConfig();
|
282
|
-
silent = silent ?? build?.silent ?? false;
|
283
|
-
if (withoutMin && onlyMin) {
|
284
|
-
throw new Error("Cannot use both --without-minify and --only-minify");
|
285
|
-
}
|
286
|
-
if (onlyMin && withoutJs) {
|
287
|
-
throw new Error("Cannot use --without-js and --only-minify at the same time");
|
288
|
-
}
|
289
|
-
let entries = [
|
290
|
-
optionEntries,
|
291
|
-
meta.IS_WORKSPACE ? void 0 : commandFiltersOrEntries
|
292
|
-
].filter(Boolean).join(",");
|
293
|
-
if (entries.length === 0) {
|
294
|
-
entries = void 0;
|
295
|
-
}
|
296
|
-
const env = {
|
297
|
-
...ANALYZER_ENV,
|
298
|
-
JIEK_BUILDER: type,
|
299
|
-
JIEK_OUT_DIR: outdir,
|
300
|
-
JIEK_CLEAN: String(!noClean),
|
301
|
-
JIEK_ENTRIES: entries,
|
302
|
-
JIEK_EXTERNAL: external,
|
303
|
-
JIEK_CROSS_MODULE_CONVERTOR: String(!noConvert),
|
304
|
-
JIEK_WITHOUT_JS: String(withoutJs),
|
305
|
-
JIEK_WITHOUT_DTS: String(withoutDts),
|
306
|
-
JIEK_WITHOUT_MINIFY: String(withoutMin),
|
307
|
-
JIEK_ONLY_MINIFY: String(onlyMin),
|
308
|
-
JIEK_MINIFY_TYPE: minifyType,
|
309
|
-
JIEK_TSCONFIG: tsconfig,
|
310
|
-
JIEK_DTSCONFIG: dtsconfig,
|
311
|
-
JIEK_FEATURES: JSON.stringify({
|
312
|
-
keepImportAttributes: options["features.keepImportAttributes"]
|
313
|
-
}),
|
314
|
-
...process__default.default.env
|
315
|
-
};
|
316
|
-
const multiBars = new cliProgress.MultiBar({
|
317
|
-
clearOnComplete: false,
|
318
|
-
hideCursor: true,
|
319
|
-
format: "- {bar} | {status} | {pkgName} | {input} | {message}"
|
320
|
-
}, cliProgress.Presets.shades_classic);
|
321
|
-
const { wd } = getWD.getWD();
|
322
|
-
const wdNodeModules = path__default.default.resolve(wd, "node_modules");
|
323
|
-
if (!fs.existsSync(wdNodeModules)) {
|
324
|
-
fs.mkdirSync(wdNodeModules);
|
325
|
-
}
|
326
|
-
const resolveByJiekTemp = (...paths) => path__default.default.resolve(wdNodeModules, ".jiek", ...paths);
|
327
|
-
const jiekTemp = resolveByJiekTemp();
|
328
|
-
if (!fs.existsSync(jiekTemp)) {
|
329
|
-
try {
|
330
|
-
fs.mkdirSync(jiekTemp);
|
331
|
-
} catch (e) {
|
332
|
-
if (e.code !== "EEXIST") {
|
333
|
-
throw e;
|
334
|
-
}
|
335
|
-
}
|
336
|
-
}
|
337
|
-
let i = 0;
|
338
|
-
const buildPackage = async ([pkgCWD, manifest], {
|
339
|
-
resolveByJiekTemp: resolveByJiekTemp2
|
340
|
-
}) => {
|
341
|
-
if (manifest.name == null) {
|
342
|
-
throw new Error("package.json must have a name field");
|
343
|
-
}
|
344
|
-
const escapeManifestName = manifest.name.replace(/^@/g, "").replace(/\//g, "+");
|
345
|
-
const configFile = resolveByJiekTemp2(
|
346
|
-
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
347
|
-
);
|
348
|
-
fs.writeFileSync(configFile, FILE_TEMPLATE(manifest));
|
349
|
-
const command2 = [ROLLUP_BIN, "--silent", "-c", configFile];
|
350
|
-
if (tsRegister.tsRegisterName != null) {
|
351
|
-
command2.unshift(`node -r ${tsRegister.tsRegisterName}`);
|
352
|
-
}
|
353
|
-
if (watch) {
|
354
|
-
command2.push("--watch");
|
355
|
-
}
|
356
|
-
command2.push(...passThroughOptions);
|
357
|
-
const child = execa.execaCommand(command2.join(" "), {
|
358
|
-
ipc: true,
|
359
|
-
cwd: pkgCWD,
|
360
|
-
windowsHide: true,
|
361
|
-
env: {
|
362
|
-
...env,
|
363
|
-
JIEK_NAME: manifest.name,
|
364
|
-
JIEK_ROOT: wd
|
365
|
-
}
|
366
|
-
});
|
367
|
-
const bars = {};
|
368
|
-
const times = {};
|
369
|
-
const locks = {};
|
370
|
-
let inputMaxLen = 10;
|
371
|
-
child.on("message", (e) => {
|
372
|
-
if (silent && [
|
373
|
-
"init",
|
374
|
-
"progress",
|
375
|
-
"watchChange"
|
376
|
-
].includes(e.type)) return;
|
377
|
-
switch (e.type) {
|
378
|
-
case "init": {
|
379
|
-
const { leafMap, targetsLength } = e.data;
|
380
|
-
const leafs = Array.from(leafMap.entries()).flatMap(
|
381
|
-
([input, pathAndConditions]) => pathAndConditions.map(([path2, ...conditions]) => ({
|
382
|
-
input,
|
383
|
-
path: path2,
|
384
|
-
conditions
|
385
|
-
}))
|
386
|
-
);
|
387
|
-
let initMessage = `Package '${manifest.name}' has ${targetsLength} targets to build`;
|
388
|
-
if (watch) {
|
389
|
-
initMessage += " and watching...";
|
390
|
-
}
|
391
|
-
console.log(initMessage);
|
392
|
-
leafs.forEach(({ input }) => {
|
393
|
-
inputMaxLen = Math.max(inputMaxLen, input.length);
|
394
|
-
});
|
395
|
-
leafs.forEach(({ input, path: path2 }) => {
|
396
|
-
const key = `${input}:${path2}`;
|
397
|
-
if (bars[key]) return;
|
398
|
-
bars[key] = multiBars.create(50, 0, {
|
399
|
-
pkgName: manifest.name,
|
400
|
-
input: input.padEnd(inputMaxLen + 5),
|
401
|
-
status: "waiting".padEnd(10)
|
402
|
-
}, {
|
403
|
-
barsize: 20,
|
404
|
-
linewrap: true
|
405
|
-
});
|
406
|
-
});
|
407
|
-
break;
|
408
|
-
}
|
409
|
-
case "progress": {
|
410
|
-
const {
|
411
|
-
path: path2,
|
412
|
-
tags,
|
413
|
-
input,
|
414
|
-
event,
|
415
|
-
message
|
416
|
-
} = e.data;
|
417
|
-
const bar = bars[`${input}:${path2}`];
|
418
|
-
if (!bar) return;
|
419
|
-
const time = times[`${input}:${path2}`];
|
420
|
-
bar.update(
|
421
|
-
{
|
422
|
-
start: 0,
|
423
|
-
resolve: 20,
|
424
|
-
end: 50
|
425
|
-
}[event ?? "start"] ?? 0,
|
426
|
-
{
|
427
|
-
input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
|
428
|
-
status: event?.padEnd(10),
|
429
|
-
message: `${tags?.join(", ")}: ${message}`
|
430
|
-
}
|
431
|
-
);
|
432
|
-
break;
|
433
|
-
}
|
434
|
-
case "watchChange": {
|
435
|
-
const {
|
436
|
-
path: path2,
|
437
|
-
input
|
438
|
-
} = e.data;
|
439
|
-
const key = `${input}:${path2}`;
|
440
|
-
const bar = bars[key];
|
441
|
-
if (!bar) return;
|
442
|
-
let time = times[key] ?? 1;
|
443
|
-
if (!locks[key]) {
|
444
|
-
time += 1;
|
445
|
-
times[key] = time;
|
446
|
-
setTimeout(() => {
|
447
|
-
locks[key] = false;
|
448
|
-
}, 100);
|
449
|
-
bar.update(0, {
|
450
|
-
input: `${input}(x${time.toString().padStart(2, "0")})`.padEnd(inputMaxLen + 5),
|
451
|
-
status: "watching".padEnd(10),
|
452
|
-
message: "watching..."
|
453
|
-
});
|
454
|
-
}
|
455
|
-
locks[key] = true;
|
456
|
-
break;
|
457
|
-
}
|
458
|
-
case "modulesAnalyze": {
|
459
|
-
const {
|
460
|
-
data: {
|
461
|
-
type: type2,
|
462
|
-
modules: pkgModules
|
463
|
-
}
|
464
|
-
} = e;
|
465
|
-
void refreshAnalyzer(
|
466
|
-
pkgCWD,
|
467
|
-
pkgModules.map((m) => ({
|
468
|
-
...m,
|
469
|
-
type: type2,
|
470
|
-
filename: `${manifest.name}/${m.filename}`,
|
471
|
-
label: `${manifest.name}/${m.label}`
|
472
|
-
}))
|
473
|
-
);
|
474
|
-
break;
|
475
|
-
}
|
476
|
-
case "debug": {
|
477
|
-
console.log(...Array.isArray(e.data) ? e.data : [e.data]);
|
478
|
-
break;
|
479
|
-
}
|
480
|
-
}
|
481
|
-
});
|
482
|
-
await new Promise((resolve, reject) => {
|
483
|
-
let errorStr = `rollup build failed
|
484
|
-
package name: ${manifest.name}
|
485
|
-
cwd: ${pkgCWD}
|
486
|
-
|
487
|
-
`;
|
488
|
-
child.stderr?.on("data", (data) => {
|
489
|
-
errorStr += data;
|
490
|
-
});
|
491
|
-
child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(errorStr)));
|
492
|
-
verbose && child.stdout?.pipe(process__default.default.stdout);
|
493
|
-
});
|
494
|
-
};
|
495
|
-
const commandFilters = meta.IS_WORKSPACE ? commandFiltersOrEntries : void 0;
|
496
|
-
const filters = [
|
497
|
-
.../* @__PURE__ */ new Set([
|
498
|
-
...commander.program.getOptionValue("filter")?.split(",").map((s) => s.trim()).filter((s) => s.length > 0) ?? [],
|
499
|
-
...commandFilters?.split(",").map((s) => s.trim()).filter((s) => s.length > 0) ?? []
|
500
|
-
])
|
501
|
-
];
|
502
|
-
try {
|
503
|
-
const packages = (filters.length > 0 ? await filterSupport.filterPackagesGraph(filters) : [await filterSupport.getSelectedProjectsGraph()]).flatMap(({ value }) => Object.entries(value ?? {}));
|
504
|
-
await Promise.allSettled(
|
505
|
-
packages.map(async ([cwd, manifest]) => buildPackage([cwd, manifest], { resolveByJiekTemp }))
|
506
|
-
);
|
507
|
-
} finally {
|
508
|
-
multiBars.stop();
|
509
|
-
!silent && console.log("Build complete");
|
510
|
-
}
|
511
|
-
});
|
512
|
-
|
513
|
-
if (process__default.default.env.JIEK_BIN__FILENAME === "build.cjs") {
|
514
|
-
parseArgv__default.default();
|
515
|
-
}
|
10
|
+
parseArgv__default.default();
|
package/dist/bin/index.cjs
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
require('#~/bin/common');
|
3
4
|
var childProcess = require('node:child_process');
|
4
5
|
var fs = require('node:fs');
|
5
6
|
var path = require('node:path');
|
@@ -12,7 +13,6 @@ var filterSupport = require('#~/utils/filterSupport');
|
|
12
13
|
var loadConfig = require('#~/utils/loadConfig');
|
13
14
|
var resolveExports = require('#~/utils/resolveExports');
|
14
15
|
var getInternalModuleName = require('#~/utils/getInternalModuleName');
|
15
|
-
require('./build');
|
16
16
|
var parseArgv = require('#~/bin/parseArgv');
|
17
17
|
|
18
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
@@ -436,6 +436,10 @@ async function prepublish({ bumper: bumper$1 } = {}) {
|
|
436
436
|
)
|
437
437
|
);
|
438
438
|
}
|
439
|
+
const jiekProductionTag = path__default.default.resolve(resolvedOutdir, ".jiek-production-tag");
|
440
|
+
if (!fs__default.default.existsSync(jiekProductionTag)) {
|
441
|
+
fs__default.default.writeFileSync(jiekProductionTag, "");
|
442
|
+
}
|
439
443
|
});
|
440
444
|
}
|
441
445
|
async function postpublish() {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.2.7-alpha.
|
4
|
+
"version": "2.2.7-alpha.5",
|
5
5
|
"description": "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.",
|
6
6
|
"author": "YiJie <yijie4188@gmail.com>",
|
7
7
|
"homepage": "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme",
|
@@ -71,7 +71,6 @@
|
|
71
71
|
"cli-progress": "^3.12.0",
|
72
72
|
"commander": "^12.0.0",
|
73
73
|
"detect-indent": "^6.1.0",
|
74
|
-
"execa": "~9.3.1",
|
75
74
|
"js-yaml": "^4.1.0",
|
76
75
|
"jsonc-parser": "^3.2.1",
|
77
76
|
"koa": "^2.15.3",
|
@@ -112,7 +111,7 @@
|
|
112
111
|
}
|
113
112
|
},
|
114
113
|
"scripts": {
|
115
|
-
"prepublish": "jb -nm && jk",
|
114
|
+
"prepublish": "pnpm test && jb -nm && jk",
|
116
115
|
"test": "vitest run"
|
117
116
|
},
|
118
117
|
"typesVersions": {
|
package/src/bin/build.cts
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
import '
|
2
|
-
import '../commands/base'
|
3
|
-
import '../commands/build'
|
4
|
-
|
5
|
-
import process from 'node:process'
|
1
|
+
import '#~/bin/common'
|
6
2
|
|
7
3
|
import parseArgv from '#~/bin/parseArgv'
|
8
4
|
|
9
|
-
|
10
|
-
parseArgv()
|
11
|
-
}
|
5
|
+
parseArgv()
|
package/src/bin/index.cts
CHANGED
package/src/commands/publish.ts
CHANGED
@@ -514,6 +514,11 @@ async function prepublish({ bumper }: {
|
|
514
514
|
)
|
515
515
|
)
|
516
516
|
}
|
517
|
+
|
518
|
+
const jiekProductionTag = path.resolve(resolvedOutdir, '.jiek-production-tag')
|
519
|
+
if (!fs.existsSync(jiekProductionTag)) {
|
520
|
+
fs.writeFileSync(jiekProductionTag, '')
|
521
|
+
}
|
517
522
|
})
|
518
523
|
}
|
519
524
|
|