Skip to content

Commit f0ffe84

Browse files
committed
fix: update and clean code comments
1 parent b67e9e8 commit f0ffe84

6 files changed

Lines changed: 42 additions & 42 deletions

File tree

src/config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const defineConfig = (userConfig: UserConfig): UserConfig => {
1919

2020
/**
2121
* Loads config
22-
* @param [file="zotero-plugin.config.{ts,js,mjs,cjs}"] The path of config file.
22+
* @param [override={}] Highest Priority Configuration.
2323
* @returns Config with userDefined and defaultConfig merged.
2424
*/
2525
export async function loadConfig(overrides?: OverrideConfig): Promise<Context> {
@@ -146,5 +146,4 @@ const defaultConfig = {
146146
},
147147
},
148148
logLevel: "info",
149-
dotEnvPath: ".env",
150149
} satisfies Config;

src/lib/build.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default class Build extends Base {
7676
}
7777

7878
/**
79-
* Copys files in `Config.assets` to `Config.dist`
79+
* Copys files in `Config.build.assets` to `Config.dist`
8080
*/
8181
copyAssets() {
8282
const files = glob.sync(this.ctx.build.assets);
@@ -87,6 +87,12 @@ export default class Build extends Base {
8787
});
8888
}
8989

90+
/**
91+
* Override user's manifest
92+
*
93+
* Write `applications.gecko` to `manifest.json`
94+
*
95+
*/
9096
makeManifest() {
9197
if (!this.ctx.build.makeManifest.enable) return;
9298
const userData = fs.readJSONSync(

src/lib/run.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/lib/serve.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ export default class Serve extends Base {
102102
});
103103
}
104104

105+
/**
106+
* Starts zotero with plugins pre-installed as proxy file
107+
*/
105108
async startZotero() {
106109
let isZoteroReady = false;
107110
if (!fs.existsSync(this.zoteroBinPath)) {
@@ -174,7 +177,11 @@ export default class Serve extends Base {
174177
},
175178
);
176179
}
177-
180+
/**
181+
* Preparing the development environment
182+
*
183+
* When asProxy=true, generate a proxy file to replace prefs.
184+
*/
178185
prepareDevEnv() {
179186
const addonProxyFilePath = path.join(
180187
this.profilePath,
@@ -320,11 +327,9 @@ export default class Serve extends Base {
320327
}
321328

322329
private get zoteroBinPath() {
323-
// this.logger.debug("zoteroBinPath", process.env.zoteroBinPath);
324330
return process.env.ZOTERO_PLUGIN_ZOTERO_BIN_PATH ?? "";
325331
}
326332
private get profilePath() {
327-
// this.logger.debug("profilePath", process.env.profilePath);
328333
return process.env.ZOTERO_PLUGIN_PROFILE_PATH ?? "";
329334
}
330335
private get dataDir() {

src/types/config.ts

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface Config {
2626
* 构建目录。
2727
*
2828
* 脚手架将在 `${dist}/addon` 存放构建后打包前的代码。
29-
* 在 `${dist}/${package_json.name}.xpi` 存放打包结果。
29+
* 在 `${dist}/${xpiName}.xpi` 存放打包结果。
3030
*
3131
* @default "build"
3232
*/
@@ -50,7 +50,7 @@ export interface Config {
5050
*
5151
* 插件命名空间
5252
*
53-
* @default _.kebabCase(name)
53+
* @default _.dash(name)
5454
*/
5555
namespace: string;
5656

@@ -67,26 +67,29 @@ export interface Config {
6767
*/
6868
updateURL: string;
6969

70+
/**
71+
* 构建所需的配置
72+
*/
7073
build: BuildConfig;
74+
75+
/**
76+
* serve 所需的配置
77+
*/
7178
server: ServerConfig;
7279

7380
/**
7481
* TODO: 使用 addonLint 检查 XPI
7582
*/
7683
addonLint: object;
77-
/**
78-
* .dotenv 文件路径
79-
*
80-
* @default `.env`
81-
* @deprecated
82-
*/
83-
dotEnvPath: string;
84+
8485
/**
8586
* 发布相关配置
8687
*
8788
*/
8889
release: {
89-
// releaseIt: Partial<ReleaseItConfig>;
90+
/**
91+
* bumpp 配置
92+
*/
9093
bumpp: VersionBumpOptions;
9194
};
9295
/**
@@ -171,18 +174,18 @@ export interface BuildConfig {
171174
* ```json
172175
* {
173176
* manifest_version: 2,
174-
* name: "__addonName__",
175-
* version: "__buildVersion__",
177+
* name: "${name}",
178+
* version: "${version}",
176179
* applications: {
177180
* zotero: {
178-
* id: "__addonID__",
179-
* update_url: "__updateURL__",
181+
* id: "${id}",
182+
* update_url: "${updateURL}",
180183
* strict_min_version: "6.999",
181184
* strict_max_version: "7.0.*",
182185
* },
183186
* gecko: {
184-
* id: "__addonID__",
185-
* update_url: "__updateURL__",
187+
* id: "${id}",
188+
* update_url: "${updateURL}",
186189
* strict_min_version: "102",
187190
* };
188191
* };
@@ -201,7 +204,6 @@ export interface BuildConfig {
201204
/**
202205
* 是否启用
203206
*
204-
*
205207
* @default true
206208
*/
207209
enable: boolean | "only-production";
@@ -220,16 +222,7 @@ export interface BuildConfig {
220222
// tagName: "release" | "updater" | string;
221223
};
222224
/**
223-
* The function called when build-in build resolved.
224-
*
225-
* Usually some extra build process.
226-
* All configurations will be parameterized to this function.
227-
*
228-
* 在默认构建步骤执行结束后执行的函数.
229-
*
230-
* 通常是一些额外的构建流程.
231-
* 所有的配置将作为参数传入此函数.
232-
*
225+
* The lifecycle hooks.
233226
*/
234227
hooks: Partial<BuildHooks>;
235228
}
@@ -275,8 +268,7 @@ export interface ServerConfig {
275268
*/
276269
asProxy: boolean;
277270
/**
278-
* The function called after Zotero started, before build-in watcher ready.
279-
*
271+
* The lifecycle hook.
280272
*/
281273
hooks: Partial<ServeHooks>;
282274
}

src/types/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ type RequiredRecursively<T> = {
1010
};
1111

1212
interface OverrideConfig extends RecursivePartial<Config> {}
13-
13+
/**
14+
* User config
15+
*
16+
* 用户输入的配置,总配置全可选基础上添加部分为必填
17+
*/
1418
interface UserConfig extends RecursivePartial<Config> {
1519
name: string;
1620
id: string;

0 commit comments

Comments
 (0)