@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.
Files changed (3) hide show
  1. package/dist/index.d.ts +118 -99
  2. package/dist/index.js +926 -924
  3. package/package.json +7 -6
package/dist/index.d.ts CHANGED
@@ -1,157 +1,176 @@
1
- import { PackageJson, TSConfig } from 'pkg-types';
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
- (path: set.InputType, value: any, options?: set.Options): void;
8
+ (path: set.InputType, value: any, options?: set.Options): void;
9
9
  }
10
10
  /**
11
11
  * @description 共享更新参数
12
12
  */
13
13
  interface SharedUpdateOptions {
14
- root: string;
15
- dest?: string;
16
- write?: boolean;
17
- cb?: (set: SetMethod) => void;
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
- filename?: string;
23
+ filename?: string;
24
24
  }
25
25
  /**
26
26
  * @description package.json 更新参数
27
27
  */
28
28
  interface UpdatePackageJsonOptions extends SharedUpdateOptions {
29
- command?: 'weapp-vite';
30
- filename?: string;
29
+ command?: 'weapp-vite';
30
+ filename?: string;
31
31
  }
32
32
  /**
33
33
  * @description project.config.json 的核心字段类型
34
34
  */
35
35
  interface ProjectConfig {
36
- miniprogramRoot?: string;
37
- srcMiniprogramRoot?: string;
38
- setting: {
39
- packNpmManually: boolean;
40
- packNpmRelationList: {
41
- packageJsonPath: string;
42
- miniprogramNpmDistDir: string;
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
- name: string;
52
- path: string;
53
- value: T | null;
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
- projectConfig: ContextDocument<ProjectConfig>;
60
- packageJson: ContextDocument<PackageJson>;
61
- viteConfig: ContextDocument<string>;
62
- tsconfig: ContextDocument<TSConfig>;
63
- tsconfigApp: ContextDocument<TSConfig>;
64
- tsconfigNode: ContextDocument<TSConfig>;
65
- dts: ContextDocument<string>;
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
- tsconfig: {
72
- references: {
73
- path: string;
74
- }[];
75
- files: never[];
76
- };
77
- tsconfigApp: {
78
- compilerOptions: {
79
- tsBuildInfoFile: string;
80
- target: string;
81
- lib: string[];
82
- jsx: string;
83
- module: string;
84
- moduleResolution: string;
85
- moduleDetection: string;
86
- baseUrl: string;
87
- paths: {
88
- '@/*': string[];
89
- };
90
- resolveJsonModule: boolean;
91
- types: string[];
92
- allowImportingTsExtensions: boolean;
93
- allowJs: boolean;
94
- allowSyntheticDefaultImports: boolean;
95
- esModuleInterop: boolean;
96
- isolatedModules: boolean;
97
- strict: boolean;
98
- noFallthroughCasesInSwitch: boolean;
99
- noUnusedLocals: boolean;
100
- noUnusedParameters: boolean;
101
- noEmit: boolean;
102
- verbatimModuleSyntax: boolean;
103
- noUncheckedSideEffectImports: boolean;
104
- erasableSyntaxOnly: boolean;
105
- skipLibCheck: boolean;
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
- tsconfigNode: {
110
- compilerOptions: {
111
- tsBuildInfoFile: string;
112
- target: string;
113
- lib: string[];
114
- module: string;
115
- moduleResolution: string;
116
- moduleDetection: string;
117
- types: string[];
118
- allowImportingTsExtensions: boolean;
119
- resolveJsonModule: boolean;
120
- verbatimModuleSyntax: boolean;
121
- strict: boolean;
122
- noFallthroughCasesInSwitch: boolean;
123
- noUnusedLocals: boolean;
124
- noUnusedParameters: boolean;
125
- noEmit: boolean;
126
- noUncheckedSideEffectImports: boolean;
127
- erasableSyntaxOnly: boolean;
128
- skipLibCheck: boolean;
129
- };
130
- include: string[];
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<PackageJson>;
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
- root?: string;
154
- command?: 'weapp-vite';
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 };