import { set } from "@weapp-core/shared"; /** * @description set-value 的写入方法签名 */ interface SetMethod { (path: set.InputType, value: any, options?: set.Options): void; } /** * @description 共享更新参数 */ interface SharedUpdateOptions { root: string; dest?: string; write?: boolean; cb?: (set: SetMethod) => void; } /** * @description project.config 更新参数 */ interface UpdateProjectConfigOptions extends SharedUpdateOptions { filename?: string; } /** * @description package.json 更新参数 */ interface UpdatePackageJsonOptions extends SharedUpdateOptions { command?: 'weapp-vite'; filename?: string; } /** * @description project.config.json 的核心字段类型 */ interface ProjectConfig { miniprogramRoot?: string; srcMiniprogramRoot?: string; setting: { packNpmManually: boolean; packNpmRelationList: { packageJsonPath: string; miniprogramNpmDistDir: string; }[]; }; } type JsonPrimitive = string | number | boolean | null; type JsonValue = JsonPrimitive | JsonObject | JsonValue[]; interface JsonObject { [key: string]: JsonValue | undefined; } interface PackageJsonData extends JsonObject { name?: string; homepage?: string; type?: string; scripts?: Record; devDependencies?: Record; } interface TsConfigData extends JsonObject {} /** * @description init 过程中推断出的项目布局信息。 */ interface ProjectLayout { srcRoot: string; } /** * @description init 过程中单个文件的上下文结构 */ interface ContextDocument { name: string; path: string; value: T | null; } /** * @description init 过程的上下文容器 */ interface Context { projectLayout: ProjectLayout; projectConfig: ContextDocument; packageJson: ContextDocument; viteConfig: ContextDocument; tsconfig: ContextDocument; tsconfigApp: ContextDocument; tsconfigServer: ContextDocument; tsconfigNode: ContextDocument; dts: ContextDocument; } export declare function initViteConfigFile(options: SharedUpdateOptions): Promise; export declare function initTsDtsFile(options: SharedUpdateOptions): Promise; export declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{ tsconfig: { references: { path: string; }[]; files: never[]; }; tsconfigApp: { extends: string; compilerOptions: { tsBuildInfoFile: string; target: string; lib: string[]; jsx: string; module: string; moduleResolution: string; moduleDetection: string; paths: { '@/*': string[]; }; resolveJsonModule: boolean; types: string[]; allowImportingTsExtensions: boolean; allowJs: boolean; allowSyntheticDefaultImports: boolean; esModuleInterop: boolean; isolatedModules: boolean; strict: boolean; noFallthroughCasesInSwitch: boolean; noUnusedLocals: boolean; noUnusedParameters: boolean; noEmit: boolean; verbatimModuleSyntax: boolean; noUncheckedSideEffectImports: boolean; erasableSyntaxOnly: boolean; skipLibCheck: boolean; }; include: string[]; }; tsconfigServer: { extends: string; compilerOptions: { tsBuildInfoFile: string; target: string; lib: string[]; types: string[]; }; files: never[]; }; tsconfigNode: { extends: string; compilerOptions: { tsBuildInfoFile: string; target: string; lib: string[]; module: string; moduleResolution: string; moduleDetection: string; types: string[]; allowImportingTsExtensions: boolean; resolveJsonModule: boolean; verbatimModuleSyntax: boolean; strict: boolean; noFallthroughCasesInSwitch: boolean; noUnusedLocals: boolean; noUnusedParameters: boolean; noEmit: boolean; noUncheckedSideEffectImports: boolean; erasableSyntaxOnly: boolean; skipLibCheck: boolean; }; include: string[]; }; }>; /** * @description 创建或更新 package.json */ export declare function createOrUpdatePackageJson(options: UpdatePackageJsonOptions): Promise; /** * @description 创建或更新 project.config.json */ export declare function createOrUpdateProjectConfig(options: UpdateProjectConfigOptions): Promise; /** * @description 重置全局上下文 */ export declare function resetContext(): void; /** * @description 初始化项目配置(project.config、package.json、tsconfig、vite.config 等) */ export declare function initConfig(options: { root?: string; command?: 'weapp-vite'; }): Promise; export type { Context };