jiek 2.0.1 → 2.0.2-alpha.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. package/{dist/cli-only-build.cjs → cli-only-build.cjs} +19 -87
  2. package/{dist/cli-only-build.js → cli-only-build.js} +19 -87
  3. package/{dist/cli.cjs → cli.cjs} +385 -531
  4. package/cli.d.cts +14 -0
  5. package/cli.d.ts +14 -0
  6. package/{dist/cli.js → cli.js} +385 -530
  7. package/{dist/index.d.cts → index.d.cts} +0 -53
  8. package/{dist/index.d.ts → index.d.ts} +0 -53
  9. package/package.json +29 -36
  10. package/{dist/rollup → rollup}/index.cjs +2 -2
  11. package/{dist/rollup → rollup}/index.js +2 -2
  12. package/README.md +0 -78
  13. package/bin/jiek-build.js +0 -16
  14. package/bin/jiek.js +0 -13
  15. package/dist/cli.d.cts +0 -67
  16. package/dist/cli.d.ts +0 -67
  17. package/src/cli-only-build.ts +0 -7
  18. package/src/cli.ts +0 -3
  19. package/src/commands/base.ts +0 -18
  20. package/src/commands/build.ts +0 -462
  21. package/src/commands/descriptions.ts +0 -17
  22. package/src/commands/init.ts +0 -373
  23. package/src/commands/meta.ts +0 -5
  24. package/src/commands/publish.ts +0 -204
  25. package/src/index.ts +0 -8
  26. package/src/inner.ts +0 -11
  27. package/src/rollup/base.ts +0 -137
  28. package/src/rollup/index.ts +0 -565
  29. package/src/rollup/plugins/progress.ts +0 -26
  30. package/src/rollup/plugins/skip.ts +0 -21
  31. package/src/rollup/utils/commonOptions.ts +0 -9
  32. package/src/rollup/utils/externalResolver.ts +0 -35
  33. package/src/rollup/utils/globalResolver.ts +0 -13
  34. package/src/rollup/utils/withMinify.ts +0 -18
  35. package/src/utils/filterSupport.ts +0 -91
  36. package/src/utils/getExports.ts +0 -140
  37. package/src/utils/getRoot.ts +0 -16
  38. package/src/utils/getWD.ts +0 -31
  39. package/src/utils/loadConfig.ts +0 -111
  40. package/src/utils/recusiveListFiles.ts +0 -13
  41. package/src/utils/ts.ts +0 -94
  42. package/src/utils/tsRegister.ts +0 -26
  43. /package/{dist/cli-only-build.d.cts → cli-only-build.d.cts} +0 -0
  44. /package/{dist/cli-only-build.d.ts → cli-only-build.d.ts} +0 -0
  45. /package/{dist/index.cjs → index.cjs} +0 -0
  46. /package/{dist/index.js → index.js} +0 -0
  47. /package/{dist/rollup → rollup}/index.d.cts +0 -0
  48. /package/{dist/rollup → rollup}/index.d.ts +0 -0
@@ -90,59 +90,6 @@ declare module 'jiek' {
90
90
  }
91
91
  }
92
92
 
93
- declare module 'jiek' {
94
- type InitNamedFunction = (argument: string, paths: {
95
- full: string;
96
- relative: string;
97
- basename?: string;
98
- }) => [name?: string, path?: string];
99
- type InitNamed = InitNamedFunction | {
100
- [key: string]: string | InitNamedFunction;
101
- };
102
- interface Config {
103
- init?: {
104
- /**
105
- * the package.json template file path or file content
106
- *
107
- * if it can be parsed as json, it will be parsed
108
- * if it is a relative file path, it will be resolved to an absolute path based on the current working directory
109
- * if it is an absolute file path, it will be used directly
110
- * @default '.jiek.template.package.json'
111
- */
112
- template?: string;
113
- /**
114
- * the readme content
115
- *
116
- * $name will be replaced with the package name
117
- * $license will be replaced with the license
118
- */
119
- readme?: string | ((ctx: {
120
- dir: string;
121
- packageJson: Record<string, any>;
122
- }) => string);
123
- /**
124
- * the readme template file path
125
- * @default '.jiek.template.readme.md'
126
- */
127
- readmeTemplate?: string;
128
- bug?: {
129
- /**
130
- * @default 'bug_report.yml'
131
- */
132
- template?: string;
133
- /**
134
- * @default ['bug']
135
- */
136
- labels?: string[] | ((ctx: {
137
- name: string;
138
- dir: string;
139
- }) => string[]);
140
- };
141
- named?: InitNamed;
142
- };
143
- }
144
- }
145
-
146
93
  declare module 'jiek' {
147
94
  interface Config {
148
95
  publish?: {
@@ -90,59 +90,6 @@ declare module 'jiek' {
90
90
  }
91
91
  }
92
92
 
93
- declare module 'jiek' {
94
- type InitNamedFunction = (argument: string, paths: {
95
- full: string;
96
- relative: string;
97
- basename?: string;
98
- }) => [name?: string, path?: string];
99
- type InitNamed = InitNamedFunction | {
100
- [key: string]: string | InitNamedFunction;
101
- };
102
- interface Config {
103
- init?: {
104
- /**
105
- * the package.json template file path or file content
106
- *
107
- * if it can be parsed as json, it will be parsed
108
- * if it is a relative file path, it will be resolved to an absolute path based on the current working directory
109
- * if it is an absolute file path, it will be used directly
110
- * @default '.jiek.template.package.json'
111
- */
112
- template?: string;
113
- /**
114
- * the readme content
115
- *
116
- * $name will be replaced with the package name
117
- * $license will be replaced with the license
118
- */
119
- readme?: string | ((ctx: {
120
- dir: string;
121
- packageJson: Record<string, any>;
122
- }) => string);
123
- /**
124
- * the readme template file path
125
- * @default '.jiek.template.readme.md'
126
- */
127
- readmeTemplate?: string;
128
- bug?: {
129
- /**
130
- * @default 'bug_report.yml'
131
- */
132
- template?: string;
133
- /**
134
- * @default ['bug']
135
- */
136
- labels?: string[] | ((ctx: {
137
- name: string;
138
- dir: string;
139
- }) => string[]);
140
- };
141
- named?: InitNamed;
142
- };
143
- }
144
- }
145
-
146
93
  declare module 'jiek' {
147
94
  interface Config {
148
95
  publish?: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "2.0.1",
4
+ "version": "2.0.2-alpha.10",
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": {
@@ -16,13 +16,6 @@
16
16
  "jiek-build": "bin/jiek-build.js",
17
17
  "jb": "bin/jiek-build.js"
18
18
  },
19
- "files": [
20
- "dist",
21
- "src",
22
- "bin",
23
- "LICENSE",
24
- "README.md"
25
- ],
26
19
  "exports": {
27
20
  "./package.json": "./package.json",
28
21
  ".": {
@@ -51,6 +44,7 @@
51
44
  },
52
45
  "dependencies": {
53
46
  "@jiek/rollup-plugin-dts": "^6.2.1",
47
+ "@inquirer/prompts": "^7.1.0",
54
48
  "@rollup/plugin-commonjs": "^28.0.0",
55
49
  "@rollup/plugin-json": "^6.0.1",
56
50
  "@rollup/plugin-node-resolve": "^15.3.0",
@@ -58,12 +52,11 @@
58
52
  "commander": "^12.0.0",
59
53
  "detect-indent": "^6.1.0",
60
54
  "execa": "9.3.1",
61
- "inquirer": "^8.2.6",
62
55
  "js-yaml": "^4.1.0",
63
56
  "jsonc-parser": "^3.2.1",
64
57
  "rollup": "4.13.2",
65
- "@jiek/pkger": "^0.2.0",
66
- "@jiek/utils": "^0.2.3"
58
+ "@jiek/utils": "^0.2.3",
59
+ "@jiek/pkger": "^0.2.0"
67
60
  },
68
61
  "peerDependencies": {
69
62
  "@rollup/plugin-terser": "^0.4.4",
@@ -75,6 +68,23 @@
75
68
  "rollup-plugin-swc3": "^0.12.1",
76
69
  "typescript": "^4.0.0||^5.0.0"
77
70
  },
71
+ "devDependencies": {
72
+ "@npm/types": "^1.0.2",
73
+ "@pnpm/filter-workspace-packages": "^7.2.13",
74
+ "@pnpm/workspace.pkgs-graph": "^2.0.15",
75
+ "@rollup/plugin-terser": "^0.4.4",
76
+ "@types/cli-progress": "^3.11.5",
77
+ "@types/inquirer": "^9.0.7",
78
+ "@types/js-yaml": "^4.0.9",
79
+ "@types/micromatch": "^4.0.6",
80
+ "esbuild-register": "^3.5.0",
81
+ "micromatch": "^4.0.5",
82
+ "node-sass": "^9.0.0",
83
+ "postcss": "^8.4.47",
84
+ "rollup-plugin-postcss": "^4.0.2",
85
+ "rollup-plugin-esbuild": "^6.1.0",
86
+ "rollup-plugin-swc3": "^0.12.1"
87
+ },
78
88
  "peerDependenciesMeta": {
79
89
  "@rollup/plugin-terser": {
80
90
  "optional": true
@@ -101,37 +111,20 @@
101
111
  "optional": true
102
112
  }
103
113
  },
104
- "devDependencies": {
105
- "@npm/types": "^1.0.2",
106
- "@pnpm/filter-workspace-packages": "^7.2.13",
107
- "@pnpm/workspace.pkgs-graph": "^2.0.15",
108
- "@rollup/plugin-terser": "^0.4.4",
109
- "@types/cli-progress": "^3.11.5",
110
- "@types/inquirer": "^9.0.7",
111
- "@types/js-yaml": "^4.0.9",
112
- "@types/micromatch": "^4.0.6",
113
- "esbuild-register": "^3.5.0",
114
- "micromatch": "^4.0.5",
115
- "node-sass": "^9.0.0",
116
- "postcss": "^8.4.47",
117
- "rollup-plugin-postcss": "^4.0.2",
118
- "rollup-plugin-esbuild": "^6.1.0",
119
- "rollup-plugin-swc3": "^0.12.1"
120
- },
121
114
  "scripts": {
122
- "prepublish": "jb --noMin"
115
+ "prepublish": "jb -nm && jk"
123
116
  },
124
- "main": "./dist/index.cjs",
125
- "module": "./dist/index.js",
126
117
  "typesVersions": {
127
118
  "<5.0": {
128
119
  "*": [
129
120
  "*",
130
- "./dist/*",
131
- "./dist/*/index.d.ts",
132
- "./dist/*/index.d.mts",
133
- "./dist/*/index.d.cts"
121
+ "./*",
122
+ "./*/index.d.ts",
123
+ "./*/index.d.mts",
124
+ "./*/index.d.cts"
134
125
  ]
135
126
  }
136
- }
127
+ },
128
+ "main": "./dist/index.cjs",
129
+ "module": "./dist/index.js"
137
130
  }
@@ -4503,7 +4503,7 @@ const {
4503
4503
  JIEK_WITHOUT_DTS,
4504
4504
  JIEK_WITHOUT_MINIFY,
4505
4505
  JIEK_MINIFY_TYPE,
4506
- JIEK_NO_CLEAN,
4506
+ JIEK_CLEAN,
4507
4507
  JIEK_ONLY_MINIFY,
4508
4508
  JIEK_TSCONFIG,
4509
4509
  JIEK_DTSCONFIG
@@ -4527,7 +4527,7 @@ const WITHOUT_JS = JIEK_WITHOUT_JS === "true";
4527
4527
  const WITHOUT_DTS = JIEK_WITHOUT_DTS === "true";
4528
4528
  const WITHOUT_MINIFY = JIEK_WITHOUT_MINIFY === "true";
4529
4529
  const ONLY_MINIFY = JIEK_ONLY_MINIFY === "true";
4530
- const CLEAN = JIEK_NO_CLEAN !== "true";
4530
+ const CLEAN = JIEK_CLEAN === "true";
4531
4531
  const MINIFY_DEFAULT_VALUE = WITHOUT_MINIFY ? false : ONLY_MINIFY ? "only-minify" : true;
4532
4532
  const BUILDER_OPTIONS = {
4533
4533
  type: JIEK_BUILDER ?? "esbuild"
@@ -4490,7 +4490,7 @@ const {
4490
4490
  JIEK_WITHOUT_DTS,
4491
4491
  JIEK_WITHOUT_MINIFY,
4492
4492
  JIEK_MINIFY_TYPE,
4493
- JIEK_NO_CLEAN,
4493
+ JIEK_CLEAN,
4494
4494
  JIEK_ONLY_MINIFY,
4495
4495
  JIEK_TSCONFIG,
4496
4496
  JIEK_DTSCONFIG
@@ -4514,7 +4514,7 @@ const WITHOUT_JS = JIEK_WITHOUT_JS === "true";
4514
4514
  const WITHOUT_DTS = JIEK_WITHOUT_DTS === "true";
4515
4515
  const WITHOUT_MINIFY = JIEK_WITHOUT_MINIFY === "true";
4516
4516
  const ONLY_MINIFY = JIEK_ONLY_MINIFY === "true";
4517
- const CLEAN = JIEK_NO_CLEAN !== "true";
4517
+ const CLEAN = JIEK_CLEAN === "true";
4518
4518
  const MINIFY_DEFAULT_VALUE = WITHOUT_MINIFY ? false : ONLY_MINIFY ? "only-minify" : true;
4519
4519
  const BUILDER_OPTIONS = {
4520
4520
  type: JIEK_BUILDER ?? "esbuild"
package/README.md DELETED
@@ -1,78 +0,0 @@
1
- # Jiek
2
-
3
- | zh-Hans
4
- | [en](https://github.com/NWYLZW/jiek/blob/master/packages/jiek/.about/en/README.md)
5
-
6
- [![npm version](https://img.shields.io/npm/v/jiek)](https://npmjs.com/package/jiek)
7
- [![npm downloads](https://img.shields.io/npm/dm/jiek)](https://npm.chart.dev/jiek)
8
-
9
- > 基于 `package.json` 元数据并适用于 `Monorepo` 的**轻便**工具库编译管理套件。
10
-
11
- - [x] 自动推断:基于 `package.json` 的相关字段自动推断出构建规则,减少配置文件的编写,更加轻便与符合标准
12
- - `exports`:根据入口文件推断构建目标与类型
13
- - `imports`:定义路径别名,并在构建的时候自动 bundle 进来
14
- - `type: module`:根据选项智能决定输出文件后缀,不需要考虑 `cjs` 与 `esm` 的适配问题
15
- - `dependencies`、`peerDependencies`、`optionalDependencies`:自动将符合规则的依赖标记为 `external`
16
- - `devDependencies`:将标记为开发依赖的 bundle 进对应的最终产物之中
17
- - [ ] 构建工具:支持多种构建工具,无需纠结于用 swc 还是 esbuild 又或者是 tsc
18
- - [x] `esbuild`
19
- - [x] `swc`
20
- - [ ] `typescript`
21
- - [x] 工作空间友好:支持在 pnpm 下的工作空间开发范式
22
- - [ ] 支持更多的 PM
23
- - [ ] 更好的工作空间任务流
24
- - [x] 类型定义文件:支持聚合生成类型定义文件
25
- - [x] 监听模式:适配 rollup 的监听模式
26
- - [x] 发布适配:支持同构生成 `package.json` 等相关字段
27
- - [ ] 根据 `package.json` 中的路径自动替换 README.md 中的相对路径链接为对应的网络链接
28
- - [x] CommonJS:产物兼容正在使用 cjs 的用户
29
- - [ ] 插件化
30
- - [ ] Dotenv:支持 dotenv 配置文件
31
- - [ ] Replacer:支持替换文件内容
32
-
33
- ## 安装
34
-
35
- ```bash
36
- npm i -D jiek
37
- # or
38
- pnpm i -D jiek
39
- # or
40
- yarn add -D jiek
41
- ```
42
-
43
- ## 快速起步
44
-
45
- 通过一些简单的方式能又快又轻松的生成需要的产物。
46
-
47
- - 在 `package.json` 中添加入口文件,这里需要设置为原文件路径。
48
-
49
- 你可以在 Node.js 文档中查看更多对于 [exports](https://nodejs.org/api/packages.html#exports) 的相关内容。
50
-
51
- ```json
52
- {
53
- ...
54
- "exports": "./src/index.ts",
55
- ...
56
- }
57
- ```
58
-
59
- - 假设你在工作空间下有一个包名字为 `@monorepo/utils` ,那么你可以运行 `jb utils` 来构建这个包。
60
-
61
- - 当你完成了开发的相关步骤后,在发布阶段你可以使用 `jk -f utils publish` 来发布你的包,本工具会自动转化并填充 `package.json` 对应的字段。
62
-
63
- 你可以添加 `-p/--preview` 参数来预览待发布的 `package.json` 的内容。
64
-
65
- ## CLI
66
-
67
- ```text
68
- Usage: jk [options] [command]
69
- ```
70
-
71
- ## 为什么不使用 X?
72
-
73
- 在这里与 `jiek` 类似的工具有:[tsup](https://github.com/egoist/tsup)、[unbuild](https://github.com/unjs/unbuild)、[bunchee](https://github.com/huozhi/bunchee)、[pkgroll](https://github.com/privatenumber/pkgroll)、[tsdown](https://github.com/sxzz/tsdown)。但是他们都有着一些共同问题没有解决,比如说:
74
-
75
- - `monorepo` 的支持存在一定的问题,在依赖工作空间其他的包时必须重新编译相关依赖
76
- - 编写入口文件的规则过于繁琐,不够自然
77
- - 无法处理 `tsconfig.json` 中的 `Project Reference` 相关问题
78
- - 根据`conditions`
package/bin/jiek-build.js DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
- import { existsSync } from 'node:fs'
3
- import { createRequire } from 'node:module'
4
- import { dirname, resolve } from 'node:path'
5
- import process from 'node:process'
6
-
7
- process.env.JIEK_IS_ONLY_BUILD = 'true'
8
-
9
- const __dirname = dirname(import.meta.url.replace('file://', ''))
10
- if (existsSync(resolve(__dirname, '../.jiek-dev-tag'))) {
11
- const require = createRequire(import.meta.url)
12
- require('esbuild-register')
13
- require('../src/cli-only-build.ts')
14
- } else {
15
- import('jiek/cli-only-build')
16
- }
package/bin/jiek.js DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
- import { existsSync } from 'node:fs'
3
- import { createRequire } from 'node:module'
4
- import { dirname, resolve } from 'node:path'
5
-
6
- const __dirname = dirname(import.meta.url.replace('file://', ''))
7
- if (existsSync(resolve(__dirname, '../.jiek-dev-tag'))) {
8
- const require = createRequire(import.meta.url)
9
- require('esbuild-register')
10
- require('../src/cli.ts')
11
- } else {
12
- import('jiek/cli')
13
- }
package/dist/cli.d.cts DELETED
@@ -1,67 +0,0 @@
1
- declare module 'jiek' {
2
- type InitNamedFunction = (argument: string, paths: {
3
- full: string;
4
- relative: string;
5
- basename?: string;
6
- }) => [name?: string, path?: string];
7
- type InitNamed = InitNamedFunction | {
8
- [key: string]: string | InitNamedFunction;
9
- };
10
- interface Config {
11
- init?: {
12
- /**
13
- * the package.json template file path or file content
14
- *
15
- * if it can be parsed as json, it will be parsed
16
- * if it is a relative file path, it will be resolved to an absolute path based on the current working directory
17
- * if it is an absolute file path, it will be used directly
18
- * @default '.jiek.template.package.json'
19
- */
20
- template?: string;
21
- /**
22
- * the readme content
23
- *
24
- * $name will be replaced with the package name
25
- * $license will be replaced with the license
26
- */
27
- readme?: string | ((ctx: {
28
- dir: string;
29
- packageJson: Record<string, any>;
30
- }) => string);
31
- /**
32
- * the readme template file path
33
- * @default '.jiek.template.readme.md'
34
- */
35
- readmeTemplate?: string;
36
- bug?: {
37
- /**
38
- * @default 'bug_report.yml'
39
- */
40
- template?: string;
41
- /**
42
- * @default ['bug']
43
- */
44
- labels?: string[] | ((ctx: {
45
- name: string;
46
- dir: string;
47
- }) => string[]);
48
- };
49
- named?: InitNamed;
50
- };
51
- }
52
- }
53
-
54
- declare module 'jiek' {
55
- interface Config {
56
- publish?: {
57
- /**
58
- * @default false
59
- */
60
- withSuffix?: boolean;
61
- /**
62
- * @default true
63
- */
64
- withSource?: boolean;
65
- };
66
- }
67
- }
package/dist/cli.d.ts DELETED
@@ -1,67 +0,0 @@
1
- declare module 'jiek' {
2
- type InitNamedFunction = (argument: string, paths: {
3
- full: string;
4
- relative: string;
5
- basename?: string;
6
- }) => [name?: string, path?: string];
7
- type InitNamed = InitNamedFunction | {
8
- [key: string]: string | InitNamedFunction;
9
- };
10
- interface Config {
11
- init?: {
12
- /**
13
- * the package.json template file path or file content
14
- *
15
- * if it can be parsed as json, it will be parsed
16
- * if it is a relative file path, it will be resolved to an absolute path based on the current working directory
17
- * if it is an absolute file path, it will be used directly
18
- * @default '.jiek.template.package.json'
19
- */
20
- template?: string;
21
- /**
22
- * the readme content
23
- *
24
- * $name will be replaced with the package name
25
- * $license will be replaced with the license
26
- */
27
- readme?: string | ((ctx: {
28
- dir: string;
29
- packageJson: Record<string, any>;
30
- }) => string);
31
- /**
32
- * the readme template file path
33
- * @default '.jiek.template.readme.md'
34
- */
35
- readmeTemplate?: string;
36
- bug?: {
37
- /**
38
- * @default 'bug_report.yml'
39
- */
40
- template?: string;
41
- /**
42
- * @default ['bug']
43
- */
44
- labels?: string[] | ((ctx: {
45
- name: string;
46
- dir: string;
47
- }) => string[]);
48
- };
49
- named?: InitNamed;
50
- };
51
- }
52
- }
53
-
54
- declare module 'jiek' {
55
- interface Config {
56
- publish?: {
57
- /**
58
- * @default false
59
- */
60
- withSuffix?: boolean;
61
- /**
62
- * @default true
63
- */
64
- withSource?: boolean;
65
- };
66
- }
67
- }
@@ -1,7 +0,0 @@
1
- import './utils/filterSupport'
2
- import './commands/base'
3
- import './commands/build'
4
-
5
- import { program } from 'commander'
6
-
7
- program.parse(process.argv)
package/src/cli.ts DELETED
@@ -1,3 +0,0 @@
1
- import './commands/init'
2
- import './commands/publish'
3
- import 'jiek/cli-only-build'
@@ -1,18 +0,0 @@
1
- import { program } from 'commander'
2
- import pkg from 'jiek/package.json'
3
-
4
- import { filterDescription } from '#~/commands/descriptions.ts'
5
- import { IS_WORKSPACE } from '#~/commands/meta.ts'
6
- import { type } from '#~/utils/filterSupport.ts'
7
-
8
- program
9
- .name('jk/jiek')
10
- .version(pkg.version)
11
- .description(`${pkg.description} - Version ${pkg.version}`)
12
- .option('--root <root>', 'The root path of the project')
13
- .option('-c, --config-path <configPath>', 'Custom jiek config path')
14
-
15
- if (type !== '' && IS_WORKSPACE) {
16
- program
17
- .option('-f, --filter <filter>', filterDescription)
18
- }