@weapp-core/init 6.0.0 → 6.0.1
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/README.md +39 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +2 -1
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @weapp-core/init
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
|
|
5
|
+
`@weapp-core/init` 用于初始化 weapp-vite 项目的基础配置文件,包含 `project.config`、`package.json`、`.gitignore`,并在需要时生成 `vite.config` 与 TypeScript 相关文件。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- 初始化/更新小程序项目配置
|
|
10
|
+
- 自动写入 `package.json` 与 `.gitignore`
|
|
11
|
+
- 可根据命令类型生成 `vite.config` 与 `tsconfig` 系列文件
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @weapp-core/init
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 使用
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { initConfig } from '@weapp-core/init'
|
|
23
|
+
|
|
24
|
+
await initConfig({
|
|
25
|
+
root: process.cwd(),
|
|
26
|
+
command: 'weapp-vite',
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 配置
|
|
31
|
+
|
|
32
|
+
`initConfig(options)` 选项:
|
|
33
|
+
|
|
34
|
+
- `root`:项目根目录(默认 `process.cwd()`)
|
|
35
|
+
- `command`:当为 `weapp-vite` 时会额外生成 `vite.config` 与 TS 配置文件
|
|
36
|
+
|
|
37
|
+
## 相关链接
|
|
38
|
+
|
|
39
|
+
- 仓库:https://github.com/weapp-vite/weapp-vite
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,37 @@
|
|
|
1
1
|
import { PackageJson, TSConfig } from 'pkg-types';
|
|
2
2
|
import { set } from '@weapp-core/shared';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @description set-value 的写入方法签名
|
|
6
|
+
*/
|
|
4
7
|
interface SetMethod {
|
|
5
8
|
(path: set.InputType, value: any, options?: set.Options): void;
|
|
6
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @description 共享更新参数
|
|
12
|
+
*/
|
|
7
13
|
interface SharedUpdateOptions {
|
|
8
14
|
root: string;
|
|
9
15
|
dest?: string;
|
|
10
16
|
write?: boolean;
|
|
11
17
|
cb?: (set: SetMethod) => void;
|
|
12
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* @description project.config 更新参数
|
|
21
|
+
*/
|
|
13
22
|
interface UpdateProjectConfigOptions extends SharedUpdateOptions {
|
|
14
23
|
filename?: string;
|
|
15
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* @description package.json 更新参数
|
|
27
|
+
*/
|
|
16
28
|
interface UpdatePackageJsonOptions extends SharedUpdateOptions {
|
|
17
29
|
command?: 'weapp-vite';
|
|
18
30
|
filename?: string;
|
|
19
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* @description project.config.json 的核心字段类型
|
|
34
|
+
*/
|
|
20
35
|
interface ProjectConfig {
|
|
21
36
|
miniprogramRoot?: string;
|
|
22
37
|
srcMiniprogramRoot?: string;
|
|
@@ -29,11 +44,17 @@ interface ProjectConfig {
|
|
|
29
44
|
};
|
|
30
45
|
}
|
|
31
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @description init 过程中单个文件的上下文结构
|
|
49
|
+
*/
|
|
32
50
|
interface ContextDocument<T> {
|
|
33
51
|
name: string;
|
|
34
52
|
path: string;
|
|
35
53
|
value: T | null;
|
|
36
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* @description init 过程的上下文容器
|
|
57
|
+
*/
|
|
37
58
|
interface Context {
|
|
38
59
|
projectConfig: ContextDocument<ProjectConfig>;
|
|
39
60
|
packageJson: ContextDocument<PackageJson>;
|
|
@@ -110,12 +131,24 @@ declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
|
|
|
110
131
|
};
|
|
111
132
|
}>;
|
|
112
133
|
|
|
134
|
+
/**
|
|
135
|
+
* @description 创建或更新 package.json
|
|
136
|
+
*/
|
|
113
137
|
declare function createOrUpdatePackageJson(options: UpdatePackageJsonOptions): Promise<PackageJson>;
|
|
114
138
|
|
|
139
|
+
/**
|
|
140
|
+
* @description 创建或更新 project.config.json
|
|
141
|
+
*/
|
|
115
142
|
declare function createOrUpdateProjectConfig(options: UpdateProjectConfigOptions): Promise<ProjectConfig>;
|
|
116
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @description 重置全局上下文
|
|
146
|
+
*/
|
|
117
147
|
declare function resetContext(): void;
|
|
118
148
|
|
|
149
|
+
/**
|
|
150
|
+
* @description 初始化项目配置(project.config、package.json、tsconfig、vite.config 等)
|
|
151
|
+
*/
|
|
119
152
|
declare function initConfig(options: {
|
|
120
153
|
root?: string;
|
|
121
154
|
command?: 'weapp-vite';
|
package/dist/index.js
CHANGED
|
@@ -716,7 +716,7 @@ import logger2 from "@weapp-core/logger";
|
|
|
716
716
|
import { defu, get, set } from "@weapp-core/shared";
|
|
717
717
|
|
|
718
718
|
// ../../packages/weapp-vite/package.json
|
|
719
|
-
var version = "6.
|
|
719
|
+
var version = "6.5.1";
|
|
720
720
|
|
|
721
721
|
// src/npm.ts
|
|
722
722
|
import https from "https";
|
|
@@ -974,6 +974,7 @@ yarn-error.log*
|
|
|
974
974
|
dist
|
|
975
975
|
dist-plugin
|
|
976
976
|
dist-web
|
|
977
|
+
dist/web
|
|
977
978
|
vite.config.ts.timestamp-*.mjs`;
|
|
978
979
|
function normalizeLineEndings(value) {
|
|
979
980
|
return value.replace(/\r\n/g, "\n");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/init",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.1",
|
|
5
5
|
"description": "@weapp-core/init",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"fs-extra": "^11.3.3",
|
|
43
|
-
"@weapp-core/logger": "^3.0.
|
|
44
|
-
"@weapp-core/shared": "^3.0.
|
|
43
|
+
"@weapp-core/logger": "^3.0.3",
|
|
44
|
+
"@weapp-core/shared": "^3.0.1"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"dev": "tsup --watch --sourcemap",
|