@weapp-core/init 6.0.1 → 6.0.3
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/dist/index.d.ts +118 -99
- package/dist/index.js +926 -924
- package/package.json +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,157 +1,176 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { set } from '@weapp-core/shared';
|
|
1
|
+
import { set } from "@weapp-core/shared";
|
|
3
2
|
|
|
3
|
+
//#region src/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* @description set-value 的写入方法签名
|
|
6
6
|
*/
|
|
7
7
|
interface SetMethod {
|
|
8
|
-
|
|
8
|
+
(path: set.InputType, value: any, options?: set.Options): void;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* @description 共享更新参数
|
|
12
12
|
*/
|
|
13
13
|
interface SharedUpdateOptions {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
root: string;
|
|
15
|
+
dest?: string;
|
|
16
|
+
write?: boolean;
|
|
17
|
+
cb?: (set: SetMethod) => void;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* @description project.config 更新参数
|
|
21
21
|
*/
|
|
22
22
|
interface UpdateProjectConfigOptions extends SharedUpdateOptions {
|
|
23
|
-
|
|
23
|
+
filename?: string;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* @description package.json 更新参数
|
|
27
27
|
*/
|
|
28
28
|
interface UpdatePackageJsonOptions extends SharedUpdateOptions {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
command?: 'weapp-vite';
|
|
30
|
+
filename?: string;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* @description project.config.json 的核心字段类型
|
|
34
34
|
*/
|
|
35
35
|
interface ProjectConfig {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
miniprogramRoot?: string;
|
|
37
|
+
srcMiniprogramRoot?: string;
|
|
38
|
+
setting: {
|
|
39
|
+
packNpmManually: boolean;
|
|
40
|
+
packNpmRelationList: {
|
|
41
|
+
packageJsonPath: string;
|
|
42
|
+
miniprogramNpmDistDir: string;
|
|
43
|
+
}[];
|
|
44
|
+
};
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/context.d.ts
|
|
48
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
49
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
50
|
+
interface JsonObject {
|
|
51
|
+
[key: string]: JsonValue | undefined;
|
|
52
|
+
}
|
|
53
|
+
interface PackageJsonData extends JsonObject {
|
|
54
|
+
name?: string;
|
|
55
|
+
homepage?: string;
|
|
56
|
+
type?: string;
|
|
57
|
+
scripts?: Record<string, string>;
|
|
58
|
+
devDependencies?: Record<string, string>;
|
|
59
|
+
}
|
|
60
|
+
interface TsConfigData extends JsonObject {}
|
|
47
61
|
/**
|
|
48
62
|
* @description init 过程中单个文件的上下文结构
|
|
49
63
|
*/
|
|
50
64
|
interface ContextDocument<T> {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
name: string;
|
|
66
|
+
path: string;
|
|
67
|
+
value: T | null;
|
|
54
68
|
}
|
|
55
69
|
/**
|
|
56
70
|
* @description init 过程的上下文容器
|
|
57
71
|
*/
|
|
58
72
|
interface Context {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
projectConfig: ContextDocument<ProjectConfig>;
|
|
74
|
+
packageJson: ContextDocument<PackageJsonData>;
|
|
75
|
+
viteConfig: ContextDocument<string>;
|
|
76
|
+
tsconfig: ContextDocument<TsConfigData>;
|
|
77
|
+
tsconfigApp: ContextDocument<TsConfigData>;
|
|
78
|
+
tsconfigNode: ContextDocument<TsConfigData>;
|
|
79
|
+
dts: ContextDocument<string>;
|
|
66
80
|
}
|
|
67
|
-
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/configFiles.d.ts
|
|
68
83
|
declare function initViteConfigFile(options: SharedUpdateOptions): Promise<string>;
|
|
69
84
|
declare function initTsDtsFile(options: SharedUpdateOptions): Promise<string>;
|
|
70
85
|
declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
include: string[];
|
|
86
|
+
tsconfig: {
|
|
87
|
+
references: {
|
|
88
|
+
path: string;
|
|
89
|
+
}[];
|
|
90
|
+
files: never[];
|
|
91
|
+
};
|
|
92
|
+
tsconfigApp: {
|
|
93
|
+
compilerOptions: {
|
|
94
|
+
tsBuildInfoFile: string;
|
|
95
|
+
target: string;
|
|
96
|
+
lib: string[];
|
|
97
|
+
jsx: string;
|
|
98
|
+
module: string;
|
|
99
|
+
moduleResolution: string;
|
|
100
|
+
moduleDetection: string;
|
|
101
|
+
baseUrl: string;
|
|
102
|
+
paths: {
|
|
103
|
+
'@/*': string[];
|
|
104
|
+
};
|
|
105
|
+
resolveJsonModule: boolean;
|
|
106
|
+
types: string[];
|
|
107
|
+
allowImportingTsExtensions: boolean;
|
|
108
|
+
allowJs: boolean;
|
|
109
|
+
allowSyntheticDefaultImports: boolean;
|
|
110
|
+
esModuleInterop: boolean;
|
|
111
|
+
isolatedModules: boolean;
|
|
112
|
+
strict: boolean;
|
|
113
|
+
noFallthroughCasesInSwitch: boolean;
|
|
114
|
+
noUnusedLocals: boolean;
|
|
115
|
+
noUnusedParameters: boolean;
|
|
116
|
+
noEmit: boolean;
|
|
117
|
+
verbatimModuleSyntax: boolean;
|
|
118
|
+
noUncheckedSideEffectImports: boolean;
|
|
119
|
+
erasableSyntaxOnly: boolean;
|
|
120
|
+
skipLibCheck: boolean;
|
|
108
121
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
include: string[];
|
|
123
|
+
};
|
|
124
|
+
tsconfigNode: {
|
|
125
|
+
compilerOptions: {
|
|
126
|
+
tsBuildInfoFile: string;
|
|
127
|
+
target: string;
|
|
128
|
+
lib: string[];
|
|
129
|
+
module: string;
|
|
130
|
+
moduleResolution: string;
|
|
131
|
+
moduleDetection: string;
|
|
132
|
+
types: string[];
|
|
133
|
+
allowImportingTsExtensions: boolean;
|
|
134
|
+
resolveJsonModule: boolean;
|
|
135
|
+
verbatimModuleSyntax: boolean;
|
|
136
|
+
strict: boolean;
|
|
137
|
+
noFallthroughCasesInSwitch: boolean;
|
|
138
|
+
noUnusedLocals: boolean;
|
|
139
|
+
noUnusedParameters: boolean;
|
|
140
|
+
noEmit: boolean;
|
|
141
|
+
noUncheckedSideEffectImports: boolean;
|
|
142
|
+
erasableSyntaxOnly: boolean;
|
|
143
|
+
skipLibCheck: boolean;
|
|
131
144
|
};
|
|
145
|
+
include: string[];
|
|
146
|
+
};
|
|
132
147
|
}>;
|
|
133
|
-
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/packageJson.d.ts
|
|
134
150
|
/**
|
|
135
151
|
* @description 创建或更新 package.json
|
|
136
152
|
*/
|
|
137
|
-
declare function createOrUpdatePackageJson(options: UpdatePackageJsonOptions): Promise<
|
|
138
|
-
|
|
153
|
+
declare function createOrUpdatePackageJson(options: UpdatePackageJsonOptions): Promise<PackageJsonData>;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/projectConfig.d.ts
|
|
139
156
|
/**
|
|
140
157
|
* @description 创建或更新 project.config.json
|
|
141
158
|
*/
|
|
142
159
|
declare function createOrUpdateProjectConfig(options: UpdateProjectConfigOptions): Promise<ProjectConfig>;
|
|
143
|
-
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/state.d.ts
|
|
144
162
|
/**
|
|
145
163
|
* @description 重置全局上下文
|
|
146
164
|
*/
|
|
147
165
|
declare function resetContext(): void;
|
|
148
|
-
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/index.d.ts
|
|
149
168
|
/**
|
|
150
169
|
* @description 初始化项目配置(project.config、package.json、tsconfig、vite.config 等)
|
|
151
170
|
*/
|
|
152
171
|
declare function initConfig(options: {
|
|
153
|
-
|
|
154
|
-
|
|
172
|
+
root?: string;
|
|
173
|
+
command?: 'weapp-vite';
|
|
155
174
|
}): Promise<Context>;
|
|
156
|
-
|
|
157
|
-
export { type Context, createOrUpdatePackageJson, createOrUpdateProjectConfig, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile, resetContext };
|
|
175
|
+
//#endregion
|
|
176
|
+
export { type Context, createOrUpdatePackageJson, createOrUpdateProjectConfig, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile, resetContext };
|