jiek 2.1.1 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +124 -3
- package/dist/cli-only-build.cjs +1 -1
- package/dist/cli-only-build.js +1 -1
- package/dist/cli.cjs +20 -2
- package/dist/cli.js +20 -2
- package/package.json +1 -1
- package/src/commands/publish.ts +27 -2
package/README.md
CHANGED
@@ -73,14 +73,135 @@ yarn add -D jiek
|
|
73
73
|
}
|
74
74
|
```
|
75
75
|
|
76
|
-
>
|
76
|
+
> 如果你需要在发布前对要发布的内容进行检查,你可以通过 `prepublish` 子指令来在你的 dist 产物目录(可配置)下会生成相关的 `package.json` 文件,你可以检阅相关生成的文件。
|
77
77
|
|
78
78
|
- 当配置好了上述的 hook 后,通过 `jk publish` 就可以一键完成构建发布动作了。
|
79
79
|
|
80
80
|
## CLI
|
81
81
|
|
82
|
-
```
|
83
|
-
|
82
|
+
```bash
|
83
|
+
jk/jiek [options] [command]
|
84
|
+
jb/jiek-build [options] [filters/entries]
|
85
|
+
```
|
86
|
+
|
87
|
+
### 自定义构建入口
|
88
|
+
|
89
|
+
你可以通过 `--entries` 来指定构建入口,这里的入口定义是基于 `package.json` 中的 `exports` 字段来进行的。
|
90
|
+
|
91
|
+
```bash
|
92
|
+
jb -e .
|
93
|
+
jb --entries .
|
94
|
+
jb --entries ./foo
|
95
|
+
jb --entries ./foo,./bar
|
96
|
+
```
|
97
|
+
|
98
|
+
当你的项目是一个非 `monorepo` 项目时,你可以直接通过 `jb [entries]` 来进行构建。
|
99
|
+
|
100
|
+
```bash
|
101
|
+
jb .
|
102
|
+
jb ./foo
|
103
|
+
jb ./foo,./bar
|
104
|
+
```
|
105
|
+
|
106
|
+
### 过滤器
|
107
|
+
|
108
|
+
你可以通过 `--filter` 来过滤需要构建的包,我们使用了和 pnpm 一样的过滤器规则,所以你可以在这里查阅 [pnpm 的过滤器规则](https://pnpm.io/filtering)
|
109
|
+
|
110
|
+
```bash
|
111
|
+
jb --filter @monorepo/*
|
112
|
+
jb --filter @monorepo/utils
|
113
|
+
jb -f utils
|
114
|
+
```
|
115
|
+
|
116
|
+
当你的项目是一个 `monorepo` 项目时,你可以直接通过 `jb [filters]` 来进行构建。
|
117
|
+
|
118
|
+
```bash
|
119
|
+
jb @monorepo/*
|
120
|
+
jb @monorepo/utils
|
121
|
+
jb utils
|
122
|
+
```
|
123
|
+
|
124
|
+
### 自定义构建工具
|
125
|
+
|
126
|
+
我们支持多种构建工具,你可以通过 `--type <type: esbuild | swc>` 来指定构建工具。
|
127
|
+
|
128
|
+
- 默认会使用 `esbuild`(`rollup-plugin-esbuild`)
|
129
|
+
- 如果你的依赖空间中存在 `swc`(`rollup-plugin-swc3`) 依赖,那么我们会自动切换到 `swc`
|
130
|
+
- 如果俩个都存在,默认会使用 `esbuild`
|
131
|
+
|
132
|
+
```bash
|
133
|
+
jb --type swc
|
134
|
+
```
|
135
|
+
|
136
|
+
> 如果使用类型的构建工具依赖没有安装,那我们会提示你安装对应的依赖。
|
137
|
+
|
138
|
+
### 最小化
|
139
|
+
|
140
|
+
我们提供了多种方式来支持最小化的构建,默认会自动启用,同时我们默认会选择使用构建工具内置的最小化插件来进行最小化。
|
141
|
+
|
142
|
+
- 你可以通过 `--minType` 选择使用 `terser`(`rollup-plugin-terser`) 来进行最小化,如果你没有安装 `terser`,我们会提示你安装。
|
143
|
+
- 你可以通过 `--noMin` 来关闭生成最小化产物。
|
144
|
+
- 你可以通过 `--onlyMinify` 来只生成最小化产物,这样我们会直接替换原产物路径,而不是添加一个 `.min` 后缀再进行输出。
|
145
|
+
|
146
|
+
```bash
|
147
|
+
jb --minType terser
|
148
|
+
jb --onlyMinify
|
149
|
+
```
|
150
|
+
|
151
|
+
### 去除指定构建内容
|
152
|
+
|
153
|
+
你可以通过 `--noJs` 来关闭 `js` 的构建,通过 `--noDts` 来关闭 `dts` 的构建。
|
154
|
+
|
155
|
+
```bash
|
156
|
+
jb --noJs
|
157
|
+
jb --noDts
|
158
|
+
```
|
159
|
+
|
160
|
+
### 自定义产物目录
|
161
|
+
|
162
|
+
你可以通过 `--outdir` 来指定产物目录。
|
163
|
+
|
164
|
+
```bash
|
165
|
+
jb --outdir lib
|
166
|
+
```
|
167
|
+
|
168
|
+
### 监听模式
|
169
|
+
|
170
|
+
你可以通过 `--watch` 来开启监听模式。
|
171
|
+
|
172
|
+
```bash
|
173
|
+
jb --watch
|
174
|
+
```
|
175
|
+
|
176
|
+
### 外部模块
|
177
|
+
|
178
|
+
除了通过 `package.json` 中的 `dependencies`、`peerDependencies`、`optionalDependencies` 来自动标记外部模块外,你还可以通过 `--external` 来手动标记外部模块。
|
179
|
+
|
180
|
+
```bash
|
181
|
+
jb --external react
|
182
|
+
jb --external react,react-dom
|
183
|
+
```
|
184
|
+
|
185
|
+
### 关闭产物的自动清理
|
186
|
+
|
187
|
+
你可以通过 `--noClean` 来关闭产物的自动清理。
|
188
|
+
|
189
|
+
```bash
|
190
|
+
jb --noClean
|
191
|
+
```
|
192
|
+
|
193
|
+
### 自定义 tsconfig 路径
|
194
|
+
|
195
|
+
你可以通过 `--tsconfig` 来指定 `tsconfig` 的路径。
|
196
|
+
|
197
|
+
```bash
|
198
|
+
jb --tsconfig ./tsconfig.custom-build.json
|
199
|
+
```
|
200
|
+
|
201
|
+
同时你还可以通过 `--dtsconfig` 来指定 `dts` 插件使用的 `tsconfig` 的路径(当然我不建议你这么做)。
|
202
|
+
|
203
|
+
```bash
|
204
|
+
jb --dtsconfig ./tsconfig.custom-dts.json
|
84
205
|
```
|
85
206
|
|
86
207
|
## 为什么不使用 X?
|
package/dist/cli-only-build.cjs
CHANGED
@@ -116,7 +116,7 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
|
|
116
116
|
|
117
117
|
var name = "jiek";
|
118
118
|
var type = "module";
|
119
|
-
var version = "2.1.
|
119
|
+
var version = "2.1.2";
|
120
120
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
121
121
|
var author = "YiJie <yijie4188@gmail.com>";
|
122
122
|
var repository = {
|
package/dist/cli-only-build.js
CHANGED
@@ -108,7 +108,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
|
|
108
108
|
|
109
109
|
var name = "jiek";
|
110
110
|
var type = "module";
|
111
|
-
var version = "2.1.
|
111
|
+
var version = "2.1.2";
|
112
112
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
113
113
|
var author = "YiJie <yijie4188@gmail.com>";
|
114
114
|
var repository = {
|
package/dist/cli.cjs
CHANGED
@@ -4780,5 +4780,23 @@ commander.program.action(async () => {
|
|
4780
4780
|
commander.program.help();
|
4781
4781
|
}
|
4782
4782
|
});
|
4783
|
-
|
4784
|
-
|
4783
|
+
const prepublishDescription = `
|
4784
|
+
Prepare package.json for publish, you can add \`jk\` to the \`prepublish\` script in package.json, the command will automatically run \`jk prepublish\`.
|
4785
|
+
.e.g
|
4786
|
+
{
|
4787
|
+
"scripts": {
|
4788
|
+
"prepublish": "jk"
|
4789
|
+
}
|
4790
|
+
}
|
4791
|
+
`.trim();
|
4792
|
+
commander.program.command("prepublish").description(prepublishDescription).action(prepublish);
|
4793
|
+
const postpublishDescription = `
|
4794
|
+
Restore package.json after publish, you can add \`jk\` to the \`postpublish\` script in package.json, the command will automatically run \`jk postpublish\`.
|
4795
|
+
.e.g
|
4796
|
+
{
|
4797
|
+
"scripts": {
|
4798
|
+
"postpublish": "jk"
|
4799
|
+
}
|
4800
|
+
}
|
4801
|
+
`.trim();
|
4802
|
+
commander.program.command("postpublish").description(postpublishDescription).action(postpublish);
|
package/dist/cli.js
CHANGED
@@ -4750,5 +4750,23 @@ program.action(async () => {
|
|
4750
4750
|
program.help();
|
4751
4751
|
}
|
4752
4752
|
});
|
4753
|
-
|
4754
|
-
|
4753
|
+
const prepublishDescription = `
|
4754
|
+
Prepare package.json for publish, you can add \`jk\` to the \`prepublish\` script in package.json, the command will automatically run \`jk prepublish\`.
|
4755
|
+
.e.g
|
4756
|
+
{
|
4757
|
+
"scripts": {
|
4758
|
+
"prepublish": "jk"
|
4759
|
+
}
|
4760
|
+
}
|
4761
|
+
`.trim();
|
4762
|
+
program.command("prepublish").description(prepublishDescription).action(prepublish);
|
4763
|
+
const postpublishDescription = `
|
4764
|
+
Restore package.json after publish, you can add \`jk\` to the \`postpublish\` script in package.json, the command will automatically run \`jk postpublish\`.
|
4765
|
+
.e.g
|
4766
|
+
{
|
4767
|
+
"scripts": {
|
4768
|
+
"postpublish": "jk"
|
4769
|
+
}
|
4770
|
+
}
|
4771
|
+
`.trim();
|
4772
|
+
program.command("postpublish").description(postpublishDescription).action(postpublish);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.1.
|
4
|
+
"version": "2.1.3",
|
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
|
"repository": {
|
package/src/commands/publish.ts
CHANGED
@@ -413,5 +413,30 @@ program
|
|
413
413
|
}
|
414
414
|
})
|
415
415
|
|
416
|
-
|
417
|
-
|
416
|
+
const prepublishDescription = `
|
417
|
+
Prepare package.json for publish, you can add \`jk\` to the \`prepublish\` script in package.json, the command will automatically run \`jk prepublish\`.
|
418
|
+
.e.g
|
419
|
+
{
|
420
|
+
"scripts": {
|
421
|
+
"prepublish": "jk"
|
422
|
+
}
|
423
|
+
}
|
424
|
+
`.trim()
|
425
|
+
program
|
426
|
+
.command('prepublish')
|
427
|
+
.description(prepublishDescription)
|
428
|
+
.action(prepublish)
|
429
|
+
|
430
|
+
const postpublishDescription = `
|
431
|
+
Restore package.json after publish, you can add \`jk\` to the \`postpublish\` script in package.json, the command will automatically run \`jk postpublish\`.
|
432
|
+
.e.g
|
433
|
+
{
|
434
|
+
"scripts": {
|
435
|
+
"postpublish": "jk"
|
436
|
+
}
|
437
|
+
}
|
438
|
+
`.trim()
|
439
|
+
program
|
440
|
+
.command('postpublish')
|
441
|
+
.description(postpublishDescription)
|
442
|
+
.action(postpublish)
|