zotero-plugin-scaffold 0.1.8-beta.2 → 0.2.0-beta.10
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/chunks/github.mjs +15 -12
- package/dist/cli.mjs +59 -38
- package/dist/index.d.mts +75 -47
- package/dist/index.d.ts +75 -47
- package/dist/index.mjs +12 -9
- package/dist/shared/zotero-plugin-scaffold.77c9802c.mjs +63 -0
- package/dist/shared/zotero-plugin-scaffold.802444a9.mjs +2161 -0
- package/dist/vendor/index.d.mts +10 -2
- package/dist/vendor/index.d.ts +10 -2
- package/dist/vendor/index.mjs +5 -4
- package/package.json +12 -14
- package/dist/shared/zotero-plugin-scaffold.ac50adf5.mjs +0 -1750
package/dist/chunks/github.mjs
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
1
2
|
import { join, basename } from 'node:path';
|
|
2
3
|
import { env } from 'node:process';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import { globbySync } from 'globby';
|
|
5
4
|
import mime from 'mime';
|
|
6
5
|
import { Octokit } from 'octokit';
|
|
6
|
+
import { globSync, glob } from 'tinyglobby';
|
|
7
7
|
import { isCI } from 'std-env';
|
|
8
|
-
import {
|
|
8
|
+
import { B as Base } from '../shared/zotero-plugin-scaffold.802444a9.mjs';
|
|
9
9
|
import 'c12';
|
|
10
10
|
import 'es-toolkit';
|
|
11
|
+
import 'fs-extra/esm';
|
|
11
12
|
import 'hookable';
|
|
12
13
|
import 'node:readline';
|
|
13
14
|
import 'chalk';
|
|
15
|
+
import '../shared/zotero-plugin-scaffold.77c9802c.mjs';
|
|
16
|
+
import 'adm-zip';
|
|
14
17
|
import 'esbuild';
|
|
15
|
-
import 'replace-in-file';
|
|
16
|
-
import 'web-ext';
|
|
17
18
|
import 'node:crypto';
|
|
19
|
+
import 'node:fs';
|
|
18
20
|
import 'node:child_process';
|
|
19
21
|
import 'bumpp';
|
|
20
22
|
import 'chokidar';
|
|
21
|
-
import 'node:
|
|
22
|
-
import 'node:
|
|
23
|
+
import 'node:net';
|
|
24
|
+
import 'node:buffer';
|
|
25
|
+
import 'node:domain';
|
|
26
|
+
import 'node:events';
|
|
23
27
|
import 'node:http';
|
|
24
|
-
import 'fs-extra/esm';
|
|
25
28
|
import 'xvfb-ts';
|
|
26
29
|
|
|
27
30
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -38,7 +41,7 @@ class ReleaseBase extends Base {
|
|
|
38
41
|
}
|
|
39
42
|
checkFiles() {
|
|
40
43
|
const { dist } = this.ctx;
|
|
41
|
-
if (
|
|
44
|
+
if (globSync(`${dist}/*.xpi`).length === 0) {
|
|
42
45
|
throw new Error("No xpi file found, are you sure you have run build?");
|
|
43
46
|
}
|
|
44
47
|
}
|
|
@@ -113,10 +116,10 @@ class GitHub extends ReleaseBase {
|
|
|
113
116
|
return await this.client.rest.repos.uploadReleaseAsset({
|
|
114
117
|
...this.remote,
|
|
115
118
|
release_id: releaseID,
|
|
116
|
-
data:
|
|
119
|
+
data: await readFile(asset),
|
|
117
120
|
headers: {
|
|
118
121
|
"content-type": mime.getType(asset) || "application/octet-stream",
|
|
119
|
-
"content-length":
|
|
122
|
+
"content-length": (await stat(asset)).size
|
|
120
123
|
},
|
|
121
124
|
name: basename(asset)
|
|
122
125
|
}).then((res) => {
|
|
@@ -131,7 +134,7 @@ class GitHub extends ReleaseBase {
|
|
|
131
134
|
return;
|
|
132
135
|
}
|
|
133
136
|
const { dist, version } = this.ctx;
|
|
134
|
-
const assets =
|
|
137
|
+
const assets = (await glob(`${dist}/update*.json`)).map((p) => basename(p));
|
|
135
138
|
const release = await this.getReleaseByTag(updater) ?? await this.createRelease({
|
|
136
139
|
...this.remote,
|
|
137
140
|
tag_name: updater,
|
package/dist/cli.mjs
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import process, { exit, env } from 'node:process';
|
|
3
3
|
import { Command } from '@commander-js/extra-typings';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import '
|
|
4
|
+
import { E as ExitSignals, l as logger, C as Config, a as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.802444a9.mjs';
|
|
5
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
6
|
+
import { pathExists, ensureFile } from 'fs-extra';
|
|
7
|
+
import tinyUpdateNotifier from 'tiny-update-notifier';
|
|
7
8
|
import 'c12';
|
|
8
9
|
import 'es-toolkit';
|
|
9
|
-
import 'fs-extra';
|
|
10
|
+
import 'fs-extra/esm';
|
|
10
11
|
import 'hookable';
|
|
11
12
|
import 'node:readline';
|
|
12
13
|
import 'chalk';
|
|
13
14
|
import 'std-env';
|
|
15
|
+
import './shared/zotero-plugin-scaffold.77c9802c.mjs';
|
|
16
|
+
import 'tinyglobby';
|
|
17
|
+
import 'node:path';
|
|
18
|
+
import 'adm-zip';
|
|
14
19
|
import 'esbuild';
|
|
15
|
-
import 'globby';
|
|
16
|
-
import 'replace-in-file';
|
|
17
|
-
import 'web-ext';
|
|
18
20
|
import 'node:crypto';
|
|
21
|
+
import 'node:fs';
|
|
19
22
|
import 'node:child_process';
|
|
20
23
|
import 'bumpp';
|
|
21
24
|
import 'chokidar';
|
|
22
|
-
import 'node:
|
|
23
|
-
import 'node:
|
|
25
|
+
import 'node:net';
|
|
26
|
+
import 'node:buffer';
|
|
27
|
+
import 'node:domain';
|
|
28
|
+
import 'node:events';
|
|
24
29
|
import 'node:http';
|
|
25
|
-
import 'fs-extra/esm';
|
|
26
30
|
import 'xvfb-ts';
|
|
27
31
|
|
|
28
32
|
const name = "zotero-plugin-scaffold";
|
|
29
33
|
const type = "module";
|
|
30
|
-
const version = "0.
|
|
31
|
-
const packageManager = "pnpm@9.
|
|
34
|
+
const version = "0.2.0-beta.10";
|
|
35
|
+
const packageManager = "pnpm@9.15.0";
|
|
32
36
|
const description = "A scaffold for Zotero plugin development.";
|
|
33
37
|
const author = "northword";
|
|
34
38
|
const license = "AGPL-3.0-or-later";
|
|
@@ -96,42 +100,33 @@ const peerDependenciesMeta = {
|
|
|
96
100
|
};
|
|
97
101
|
const dependencies = {
|
|
98
102
|
"@commander-js/extra-typings": "^12.1.0",
|
|
99
|
-
"
|
|
100
|
-
bumpp: "^9.
|
|
103
|
+
"adm-zip": "^0.5.16",
|
|
104
|
+
bumpp: "^9.9.1",
|
|
101
105
|
c12: "^2.0.1",
|
|
102
106
|
chalk: "^5.3.0",
|
|
103
107
|
chokidar: "^4.0.1",
|
|
104
108
|
commander: "^12.1.0",
|
|
105
|
-
"es-toolkit": "^1.
|
|
109
|
+
"es-toolkit": "^1.29.0",
|
|
106
110
|
esbuild: "^0.24.0",
|
|
107
111
|
"fs-extra": "^11.2.0",
|
|
108
|
-
globby: "^14.0.2",
|
|
109
112
|
hookable: "^5.5.3",
|
|
110
113
|
mime: "^4.0.4",
|
|
111
114
|
octokit: "^4.0.2",
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
"web-ext": "^8.3.0",
|
|
115
|
+
"std-env": "^3.8.0",
|
|
116
|
+
"tiny-update-notifier": "^2.0.0",
|
|
117
|
+
tinyglobby: "^0.2.10",
|
|
116
118
|
"xvfb-ts": "^1.1.0"
|
|
117
119
|
};
|
|
118
120
|
const devDependencies = {
|
|
119
|
-
"@antfu/eslint-config": "^3.
|
|
121
|
+
"@antfu/eslint-config": "^3.11.2",
|
|
122
|
+
"@types/adm-zip": "^0.5.7",
|
|
120
123
|
"@types/fs-extra": "^11.0.4",
|
|
121
|
-
"@types/node": "^22.
|
|
122
|
-
|
|
123
|
-
eslint: "^
|
|
124
|
-
"eslint-plugin-format": "^0.1.2",
|
|
124
|
+
"@types/node": "^22.10.2",
|
|
125
|
+
eslint: "^9.16.0",
|
|
126
|
+
"eslint-plugin-format": "^0.1.3",
|
|
125
127
|
typescript: "^5.7.2",
|
|
126
128
|
unbuild: "^2.0.0"
|
|
127
129
|
};
|
|
128
|
-
const pnpm = {
|
|
129
|
-
peerDependencyRules: {
|
|
130
|
-
allowAny: [
|
|
131
|
-
"node-fetch"
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
130
|
const pkg = {
|
|
136
131
|
name: name,
|
|
137
132
|
type: type,
|
|
@@ -157,16 +152,40 @@ const pkg = {
|
|
|
157
152
|
peerDependencies: peerDependencies,
|
|
158
153
|
peerDependenciesMeta: peerDependenciesMeta,
|
|
159
154
|
dependencies: dependencies,
|
|
160
|
-
devDependencies: devDependencies
|
|
161
|
-
pnpm: pnpm
|
|
155
|
+
devDependencies: devDependencies
|
|
162
156
|
};
|
|
163
157
|
|
|
164
|
-
|
|
158
|
+
async function checkGitIgnore() {
|
|
159
|
+
if (!pathExists(".git"))
|
|
160
|
+
return;
|
|
161
|
+
await ensureFile(".gitignore");
|
|
162
|
+
const contents = (await readFile(".gitignore", "utf-8")).split("\n");
|
|
163
|
+
const ignores = ["node_modules", ".env", ".scaffold"];
|
|
164
|
+
ignores.forEach((ignore) => {
|
|
165
|
+
if (!contents.includes(ignore))
|
|
166
|
+
contents.push(ignore);
|
|
167
|
+
});
|
|
168
|
+
await writeFile(".gitignore", contents.join("\n"));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function updateNotifier(name, version) {
|
|
172
|
+
tinyUpdateNotifier({ pkg: { name, version } }).then((update) => {
|
|
173
|
+
if (update) {
|
|
174
|
+
const notify = () => {
|
|
175
|
+
logger.newLine();
|
|
176
|
+
logger.info(`New version of ${update.name} available!`);
|
|
177
|
+
logger.info(`Update: ${update.current} \u2192 ${update.latest} (${update.type})`);
|
|
178
|
+
logger.newLine();
|
|
179
|
+
};
|
|
180
|
+
ExitSignals.forEach((sig) => process.once(sig, notify));
|
|
181
|
+
}
|
|
182
|
+
}).catch();
|
|
183
|
+
}
|
|
184
|
+
|
|
165
185
|
async function main() {
|
|
166
186
|
var _a;
|
|
167
187
|
const { name, version } = pkg;
|
|
168
|
-
updateNotifier(
|
|
169
|
-
process.removeAllListeners("SIGINT");
|
|
188
|
+
updateNotifier(name, version);
|
|
170
189
|
(_a = env).NODE_ENV ?? (_a.NODE_ENV = "development");
|
|
171
190
|
const cli = new Command();
|
|
172
191
|
cli.version(version).usage("<command> [options]");
|
|
@@ -212,7 +231,9 @@ async function main() {
|
|
|
212
231
|
});
|
|
213
232
|
cli.parse();
|
|
214
233
|
}
|
|
215
|
-
main().
|
|
234
|
+
main().then(() => {
|
|
235
|
+
checkGitIgnore();
|
|
236
|
+
}).catch(onError);
|
|
216
237
|
process.on("uncaughtException", onError);
|
|
217
238
|
function onError(err) {
|
|
218
239
|
logger.error(err);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import { Hookable } from 'hookable';
|
|
2
2
|
import * as esbuild from 'esbuild';
|
|
3
3
|
import { BuildOptions } from 'esbuild';
|
|
4
|
-
import * as child_process from 'child_process';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Log level
|
|
7
|
+
*/
|
|
8
|
+
declare enum LOG_LEVEL {
|
|
9
|
+
trace = 0,
|
|
10
|
+
debug = 1,
|
|
11
|
+
info = 2,
|
|
12
|
+
warn = 3,
|
|
13
|
+
error = 4
|
|
14
|
+
}
|
|
15
|
+
type LogLevelType = keyof typeof LOG_LEVEL;
|
|
6
16
|
/**
|
|
7
17
|
* Logger
|
|
8
18
|
*/
|
|
9
19
|
declare class Log {
|
|
20
|
+
private static instance;
|
|
10
21
|
private logLevel;
|
|
11
|
-
constructor(
|
|
22
|
+
constructor(level?: LOG_LEVEL);
|
|
23
|
+
static getInstance(): Log;
|
|
24
|
+
setLogLevel(level: LogLevelType): void;
|
|
12
25
|
private formatArgs;
|
|
13
26
|
private logArgs;
|
|
14
27
|
log(...args: any[]): void;
|
|
@@ -222,7 +235,7 @@ interface Config$1 {
|
|
|
222
235
|
*
|
|
223
236
|
* @default "info"
|
|
224
237
|
*/
|
|
225
|
-
logLevel:
|
|
238
|
+
logLevel: LogLevelType;
|
|
226
239
|
}
|
|
227
240
|
interface BuildConfig {
|
|
228
241
|
/**
|
|
@@ -382,7 +395,6 @@ interface BuildHooks {
|
|
|
382
395
|
"build:copyAssets": (ctx: Context) => void | Promise<void>;
|
|
383
396
|
"build:makeManifest": (ctx: Context) => void | Promise<void>;
|
|
384
397
|
"build:fluent": (ctx: Context) => void | Promise<void>;
|
|
385
|
-
"build:replace": (ctx: Context) => void | Promise<void>;
|
|
386
398
|
"build:bundle": (ctx: Context) => void | Promise<void>;
|
|
387
399
|
"build:pack": (ctx: Context) => void | Promise<void>;
|
|
388
400
|
"build:makeUpdateJSON": (ctx: Context) => void | Promise<void>;
|
|
@@ -616,7 +628,7 @@ interface TestConfig {
|
|
|
616
628
|
* 这些目录中的所有 `*.spec.js` 文件将被执行。
|
|
617
629
|
* 文件将按字母顺序排序。
|
|
618
630
|
*
|
|
619
|
-
* @default "test
|
|
631
|
+
* @default "test"
|
|
620
632
|
*/
|
|
621
633
|
entries: string | string[];
|
|
622
634
|
/**
|
|
@@ -627,14 +639,16 @@ interface TestConfig {
|
|
|
627
639
|
* 这些首选项将在测试开始前设置。
|
|
628
640
|
*/
|
|
629
641
|
prefs: Record<string, string | boolean | number>;
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
642
|
+
mocha: {
|
|
643
|
+
/**
|
|
644
|
+
* The timeout of the test.
|
|
645
|
+
*
|
|
646
|
+
* 测试的超时时间。
|
|
647
|
+
*
|
|
648
|
+
* @default 10000
|
|
649
|
+
*/
|
|
650
|
+
timeout: number;
|
|
651
|
+
};
|
|
638
652
|
/**
|
|
639
653
|
* Abort the test when the first test fails.
|
|
640
654
|
*
|
|
@@ -651,6 +665,19 @@ interface TestConfig {
|
|
|
651
665
|
* @default false
|
|
652
666
|
*/
|
|
653
667
|
exitOnFinish: boolean;
|
|
668
|
+
/**
|
|
669
|
+
* Run Zotero in deadless mode.
|
|
670
|
+
*
|
|
671
|
+
* - Supported for Linux only.
|
|
672
|
+
* - Default to true when in CI environments.
|
|
673
|
+
*
|
|
674
|
+
* 使用无头模式运行 Zotero。
|
|
675
|
+
*
|
|
676
|
+
* - 仅支持 Linux
|
|
677
|
+
* - 在 CI 模式下,默认为 true
|
|
678
|
+
*
|
|
679
|
+
* @default false
|
|
680
|
+
*/
|
|
654
681
|
headless: boolean;
|
|
655
682
|
/**
|
|
656
683
|
* The delay time before running the test. Make sure the plugin is fully loaded before running the test.
|
|
@@ -669,7 +696,7 @@ interface TestConfig {
|
|
|
669
696
|
*
|
|
670
697
|
* 如果设置,测试将等待函数返回 true 后再运行测试。
|
|
671
698
|
*
|
|
672
|
-
* @default "()=>true"
|
|
699
|
+
* @default "() => true"
|
|
673
700
|
*
|
|
674
701
|
* @example
|
|
675
702
|
* ```js
|
|
@@ -677,17 +704,20 @@ interface TestConfig {
|
|
|
677
704
|
* ```
|
|
678
705
|
*/
|
|
679
706
|
waitForPlugin: string;
|
|
707
|
+
/**
|
|
708
|
+
* @todo not
|
|
709
|
+
*/
|
|
710
|
+
watch: boolean;
|
|
680
711
|
hooks: Partial<TestHooks>;
|
|
681
712
|
}
|
|
682
713
|
interface TestHooks {
|
|
683
714
|
"test:init": (ctx: Context) => void | Promise<void>;
|
|
684
715
|
"test:prebuild": (ctx: Context) => void | Promise<void>;
|
|
685
716
|
"test:listen": (ctx: Context) => void | Promise<void>;
|
|
686
|
-
"test:mkdir": (ctx: Context) => void | Promise<void>;
|
|
687
717
|
"test:copyAssets": (ctx: Context) => void | Promise<void>;
|
|
688
718
|
"test:bundleTests": (ctx: Context) => void | Promise<void>;
|
|
689
719
|
"test:run": (ctx: Context) => void | Promise<void>;
|
|
690
|
-
"test:
|
|
720
|
+
"test:exit": (ctx: Context) => void;
|
|
691
721
|
}
|
|
692
722
|
interface Hooks extends BuildHooks, ServeHooks, ReleaseHooks, TestHooks {
|
|
693
723
|
}
|
|
@@ -751,21 +781,15 @@ declare class Build extends Base {
|
|
|
751
781
|
/**
|
|
752
782
|
* Copys files in `Config.build.assets` to `Config.dist`
|
|
753
783
|
*/
|
|
754
|
-
|
|
784
|
+
makeAssets(): Promise<void>;
|
|
755
785
|
/**
|
|
756
786
|
* Override user's manifest
|
|
757
787
|
*
|
|
758
|
-
* Write `applications.gecko` to `manifest.json`
|
|
759
|
-
*
|
|
760
|
-
*/
|
|
761
|
-
makeManifest(): void;
|
|
762
|
-
/**
|
|
763
|
-
* Replace all `placeholder.key` to `placeholder.value` for all files in `dist`
|
|
764
788
|
*/
|
|
765
|
-
|
|
766
|
-
prepareLocaleFiles(): void
|
|
789
|
+
makeManifest(): Promise<void>;
|
|
790
|
+
prepareLocaleFiles(): Promise<void>;
|
|
767
791
|
esbuild(): Promise<esbuild.BuildResult<esbuild.BuildOptions>[]> | undefined;
|
|
768
|
-
makeUpdateJson(): void
|
|
792
|
+
makeUpdateJson(): Promise<void>;
|
|
769
793
|
pack(): Promise<void>;
|
|
770
794
|
}
|
|
771
795
|
|
|
@@ -790,6 +814,8 @@ declare class Release extends Base {
|
|
|
790
814
|
declare class Serve extends Base {
|
|
791
815
|
private builder;
|
|
792
816
|
private runner?;
|
|
817
|
+
private _zoteroBinPath?;
|
|
818
|
+
private _profilePath?;
|
|
793
819
|
constructor(ctx: Context);
|
|
794
820
|
run(): Promise<void>;
|
|
795
821
|
/**
|
|
@@ -799,29 +825,24 @@ declare class Serve extends Base {
|
|
|
799
825
|
onChange(path: string): Promise<void>;
|
|
800
826
|
reload(): Promise<void>;
|
|
801
827
|
exit: () => never;
|
|
828
|
+
private onZoteroExit;
|
|
829
|
+
get zoteroBinPath(): string;
|
|
830
|
+
get profilePath(): string;
|
|
831
|
+
get dataDir(): string;
|
|
802
832
|
}
|
|
803
833
|
|
|
804
834
|
declare class Test extends Base {
|
|
805
835
|
private builder;
|
|
806
|
-
private
|
|
807
|
-
private
|
|
808
|
-
private _testPluginDir?;
|
|
809
|
-
private _testPluginRef;
|
|
810
|
-
private _testPluginID;
|
|
811
|
-
private _testBuildDir?;
|
|
812
|
-
private _server?;
|
|
813
|
-
private _process?;
|
|
814
|
-
get startArgs(): string[];
|
|
836
|
+
private runner?;
|
|
837
|
+
private communicator;
|
|
815
838
|
constructor(ctx: Context);
|
|
816
839
|
run(): Promise<void>;
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
createBootstrap(): Promise<void>;
|
|
820
|
-
createTestResources(): Promise<void>;
|
|
840
|
+
createTestPlugin(): Promise<void>;
|
|
841
|
+
copyTestLibraries(): Promise<void>;
|
|
821
842
|
bundleTests(): Promise<void>;
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end";
|
|
843
|
+
startHttpServer(): Promise<void>;
|
|
844
|
+
onHttpDataUpdated(body: {
|
|
845
|
+
type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end" | "debug";
|
|
825
846
|
data?: {
|
|
826
847
|
title: string;
|
|
827
848
|
str: string;
|
|
@@ -829,12 +850,19 @@ declare class Test extends Base {
|
|
|
829
850
|
stack?: string;
|
|
830
851
|
};
|
|
831
852
|
}): Promise<void>;
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
installZoteroLinux(): Promise<void>;
|
|
853
|
+
watch(): Promise<void>;
|
|
854
|
+
onCodeChanged(_path: string): Promise<void>;
|
|
835
855
|
startZoteroHeadless(): Promise<void>;
|
|
836
|
-
startZotero(): Promise<
|
|
837
|
-
exit
|
|
856
|
+
startZotero(): Promise<void>;
|
|
857
|
+
private exit;
|
|
858
|
+
private get zoteroBinPath();
|
|
859
|
+
private get profilePath();
|
|
860
|
+
private get dataDir();
|
|
861
|
+
private get testPluginDir();
|
|
862
|
+
private get cacheDir();
|
|
863
|
+
private get testPluginRef();
|
|
864
|
+
private get testPluginID();
|
|
865
|
+
private get prefs();
|
|
838
866
|
}
|
|
839
867
|
|
|
840
868
|
declare const Config: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import { Hookable } from 'hookable';
|
|
2
2
|
import * as esbuild from 'esbuild';
|
|
3
3
|
import { BuildOptions } from 'esbuild';
|
|
4
|
-
import * as child_process from 'child_process';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Log level
|
|
7
|
+
*/
|
|
8
|
+
declare enum LOG_LEVEL {
|
|
9
|
+
trace = 0,
|
|
10
|
+
debug = 1,
|
|
11
|
+
info = 2,
|
|
12
|
+
warn = 3,
|
|
13
|
+
error = 4
|
|
14
|
+
}
|
|
15
|
+
type LogLevelType = keyof typeof LOG_LEVEL;
|
|
6
16
|
/**
|
|
7
17
|
* Logger
|
|
8
18
|
*/
|
|
9
19
|
declare class Log {
|
|
20
|
+
private static instance;
|
|
10
21
|
private logLevel;
|
|
11
|
-
constructor(
|
|
22
|
+
constructor(level?: LOG_LEVEL);
|
|
23
|
+
static getInstance(): Log;
|
|
24
|
+
setLogLevel(level: LogLevelType): void;
|
|
12
25
|
private formatArgs;
|
|
13
26
|
private logArgs;
|
|
14
27
|
log(...args: any[]): void;
|
|
@@ -222,7 +235,7 @@ interface Config$1 {
|
|
|
222
235
|
*
|
|
223
236
|
* @default "info"
|
|
224
237
|
*/
|
|
225
|
-
logLevel:
|
|
238
|
+
logLevel: LogLevelType;
|
|
226
239
|
}
|
|
227
240
|
interface BuildConfig {
|
|
228
241
|
/**
|
|
@@ -382,7 +395,6 @@ interface BuildHooks {
|
|
|
382
395
|
"build:copyAssets": (ctx: Context) => void | Promise<void>;
|
|
383
396
|
"build:makeManifest": (ctx: Context) => void | Promise<void>;
|
|
384
397
|
"build:fluent": (ctx: Context) => void | Promise<void>;
|
|
385
|
-
"build:replace": (ctx: Context) => void | Promise<void>;
|
|
386
398
|
"build:bundle": (ctx: Context) => void | Promise<void>;
|
|
387
399
|
"build:pack": (ctx: Context) => void | Promise<void>;
|
|
388
400
|
"build:makeUpdateJSON": (ctx: Context) => void | Promise<void>;
|
|
@@ -616,7 +628,7 @@ interface TestConfig {
|
|
|
616
628
|
* 这些目录中的所有 `*.spec.js` 文件将被执行。
|
|
617
629
|
* 文件将按字母顺序排序。
|
|
618
630
|
*
|
|
619
|
-
* @default "test
|
|
631
|
+
* @default "test"
|
|
620
632
|
*/
|
|
621
633
|
entries: string | string[];
|
|
622
634
|
/**
|
|
@@ -627,14 +639,16 @@ interface TestConfig {
|
|
|
627
639
|
* 这些首选项将在测试开始前设置。
|
|
628
640
|
*/
|
|
629
641
|
prefs: Record<string, string | boolean | number>;
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
642
|
+
mocha: {
|
|
643
|
+
/**
|
|
644
|
+
* The timeout of the test.
|
|
645
|
+
*
|
|
646
|
+
* 测试的超时时间。
|
|
647
|
+
*
|
|
648
|
+
* @default 10000
|
|
649
|
+
*/
|
|
650
|
+
timeout: number;
|
|
651
|
+
};
|
|
638
652
|
/**
|
|
639
653
|
* Abort the test when the first test fails.
|
|
640
654
|
*
|
|
@@ -651,6 +665,19 @@ interface TestConfig {
|
|
|
651
665
|
* @default false
|
|
652
666
|
*/
|
|
653
667
|
exitOnFinish: boolean;
|
|
668
|
+
/**
|
|
669
|
+
* Run Zotero in deadless mode.
|
|
670
|
+
*
|
|
671
|
+
* - Supported for Linux only.
|
|
672
|
+
* - Default to true when in CI environments.
|
|
673
|
+
*
|
|
674
|
+
* 使用无头模式运行 Zotero。
|
|
675
|
+
*
|
|
676
|
+
* - 仅支持 Linux
|
|
677
|
+
* - 在 CI 模式下,默认为 true
|
|
678
|
+
*
|
|
679
|
+
* @default false
|
|
680
|
+
*/
|
|
654
681
|
headless: boolean;
|
|
655
682
|
/**
|
|
656
683
|
* The delay time before running the test. Make sure the plugin is fully loaded before running the test.
|
|
@@ -669,7 +696,7 @@ interface TestConfig {
|
|
|
669
696
|
*
|
|
670
697
|
* 如果设置,测试将等待函数返回 true 后再运行测试。
|
|
671
698
|
*
|
|
672
|
-
* @default "()=>true"
|
|
699
|
+
* @default "() => true"
|
|
673
700
|
*
|
|
674
701
|
* @example
|
|
675
702
|
* ```js
|
|
@@ -677,17 +704,20 @@ interface TestConfig {
|
|
|
677
704
|
* ```
|
|
678
705
|
*/
|
|
679
706
|
waitForPlugin: string;
|
|
707
|
+
/**
|
|
708
|
+
* @todo not
|
|
709
|
+
*/
|
|
710
|
+
watch: boolean;
|
|
680
711
|
hooks: Partial<TestHooks>;
|
|
681
712
|
}
|
|
682
713
|
interface TestHooks {
|
|
683
714
|
"test:init": (ctx: Context) => void | Promise<void>;
|
|
684
715
|
"test:prebuild": (ctx: Context) => void | Promise<void>;
|
|
685
716
|
"test:listen": (ctx: Context) => void | Promise<void>;
|
|
686
|
-
"test:mkdir": (ctx: Context) => void | Promise<void>;
|
|
687
717
|
"test:copyAssets": (ctx: Context) => void | Promise<void>;
|
|
688
718
|
"test:bundleTests": (ctx: Context) => void | Promise<void>;
|
|
689
719
|
"test:run": (ctx: Context) => void | Promise<void>;
|
|
690
|
-
"test:
|
|
720
|
+
"test:exit": (ctx: Context) => void;
|
|
691
721
|
}
|
|
692
722
|
interface Hooks extends BuildHooks, ServeHooks, ReleaseHooks, TestHooks {
|
|
693
723
|
}
|
|
@@ -751,21 +781,15 @@ declare class Build extends Base {
|
|
|
751
781
|
/**
|
|
752
782
|
* Copys files in `Config.build.assets` to `Config.dist`
|
|
753
783
|
*/
|
|
754
|
-
|
|
784
|
+
makeAssets(): Promise<void>;
|
|
755
785
|
/**
|
|
756
786
|
* Override user's manifest
|
|
757
787
|
*
|
|
758
|
-
* Write `applications.gecko` to `manifest.json`
|
|
759
|
-
*
|
|
760
|
-
*/
|
|
761
|
-
makeManifest(): void;
|
|
762
|
-
/**
|
|
763
|
-
* Replace all `placeholder.key` to `placeholder.value` for all files in `dist`
|
|
764
788
|
*/
|
|
765
|
-
|
|
766
|
-
prepareLocaleFiles(): void
|
|
789
|
+
makeManifest(): Promise<void>;
|
|
790
|
+
prepareLocaleFiles(): Promise<void>;
|
|
767
791
|
esbuild(): Promise<esbuild.BuildResult<esbuild.BuildOptions>[]> | undefined;
|
|
768
|
-
makeUpdateJson(): void
|
|
792
|
+
makeUpdateJson(): Promise<void>;
|
|
769
793
|
pack(): Promise<void>;
|
|
770
794
|
}
|
|
771
795
|
|
|
@@ -790,6 +814,8 @@ declare class Release extends Base {
|
|
|
790
814
|
declare class Serve extends Base {
|
|
791
815
|
private builder;
|
|
792
816
|
private runner?;
|
|
817
|
+
private _zoteroBinPath?;
|
|
818
|
+
private _profilePath?;
|
|
793
819
|
constructor(ctx: Context);
|
|
794
820
|
run(): Promise<void>;
|
|
795
821
|
/**
|
|
@@ -799,29 +825,24 @@ declare class Serve extends Base {
|
|
|
799
825
|
onChange(path: string): Promise<void>;
|
|
800
826
|
reload(): Promise<void>;
|
|
801
827
|
exit: () => never;
|
|
828
|
+
private onZoteroExit;
|
|
829
|
+
get zoteroBinPath(): string;
|
|
830
|
+
get profilePath(): string;
|
|
831
|
+
get dataDir(): string;
|
|
802
832
|
}
|
|
803
833
|
|
|
804
834
|
declare class Test extends Base {
|
|
805
835
|
private builder;
|
|
806
|
-
private
|
|
807
|
-
private
|
|
808
|
-
private _testPluginDir?;
|
|
809
|
-
private _testPluginRef;
|
|
810
|
-
private _testPluginID;
|
|
811
|
-
private _testBuildDir?;
|
|
812
|
-
private _server?;
|
|
813
|
-
private _process?;
|
|
814
|
-
get startArgs(): string[];
|
|
836
|
+
private runner?;
|
|
837
|
+
private communicator;
|
|
815
838
|
constructor(ctx: Context);
|
|
816
839
|
run(): Promise<void>;
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
createBootstrap(): Promise<void>;
|
|
820
|
-
createTestResources(): Promise<void>;
|
|
840
|
+
createTestPlugin(): Promise<void>;
|
|
841
|
+
copyTestLibraries(): Promise<void>;
|
|
821
842
|
bundleTests(): Promise<void>;
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end";
|
|
843
|
+
startHttpServer(): Promise<void>;
|
|
844
|
+
onHttpDataUpdated(body: {
|
|
845
|
+
type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end" | "debug";
|
|
825
846
|
data?: {
|
|
826
847
|
title: string;
|
|
827
848
|
str: string;
|
|
@@ -829,12 +850,19 @@ declare class Test extends Base {
|
|
|
829
850
|
stack?: string;
|
|
830
851
|
};
|
|
831
852
|
}): Promise<void>;
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
installZoteroLinux(): Promise<void>;
|
|
853
|
+
watch(): Promise<void>;
|
|
854
|
+
onCodeChanged(_path: string): Promise<void>;
|
|
835
855
|
startZoteroHeadless(): Promise<void>;
|
|
836
|
-
startZotero(): Promise<
|
|
837
|
-
exit
|
|
856
|
+
startZotero(): Promise<void>;
|
|
857
|
+
private exit;
|
|
858
|
+
private get zoteroBinPath();
|
|
859
|
+
private get profilePath();
|
|
860
|
+
private get dataDir();
|
|
861
|
+
private get testPluginDir();
|
|
862
|
+
private get cacheDir();
|
|
863
|
+
private get testPluginRef();
|
|
864
|
+
private get testPluginID();
|
|
865
|
+
private get prefs();
|
|
838
866
|
}
|
|
839
867
|
|
|
840
868
|
declare const Config: {
|