zotero-plugin-scaffold 0.6.0 → 0.6.1
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/README.md +47 -1
- package/dist/cli.d.mts +7 -1
- package/dist/cli.mjs +26 -22
- package/dist/index.d.mts +9 -845
- package/dist/index.mjs +7 -7
- package/dist/shared/zotero-plugin-scaffold.CzBjWbS8.mjs +257 -0
- package/dist/shared/{zotero-plugin-scaffold.C-SXQX4J.mjs → zotero-plugin-scaffold.WLeAAj6o.mjs} +190 -362
- package/dist/shared/zotero-plugin-scaffold.oqywMJh-.d.mts +832 -0
- package/dist/vendor/index.mjs +5 -1
- package/package.json +41 -18
- package/dist/shared/zotero-plugin-scaffold.v8dJZZ-v.mjs +0 -61
package/README.md
CHANGED
|
@@ -1,11 +1,57 @@
|
|
|
1
1
|
# Zotero Plugin Development Scaffold
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/zotero-plugin-scaffold)
|
|
4
|
+
[](https://www.npmjs.com/package/zotero-plugin-scaffold)
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
[](https://github.com/antfu/eslint-config)
|
|
8
|
+
|
|
9
|
+
This is an npm package designed to assist in the development of Zotero plugins. It provides features such as compiling plugins, starting Zotero and installing plugins from source code, reloading plugins when the source code changes, and releasing plugins, and so on.
|
|
10
|
+
|
|
11
|
+
Initially, the code of this package was part of the [zotero-plugin-template](https://github.com/windingwind/zotero-plugin-template) repository. To allow downstream developers to easily stay up-to-date, we have abstracted these scripts into a standalone npm package.
|
|
12
|
+
|
|
13
|
+
This project is under active development, and some APIs may change. However, it is ready for production and has been [used in several projects](https://github.com/northword/zotero-plugin-scaffold/network/dependents).
|
|
14
|
+
|
|
15
|
+
For best practices regarding this package, please refer to [zotero-plugin-template](https://github.com/windingwind/zotero-plugin-template).
|
|
4
16
|
|
|
5
17
|
## Documentation
|
|
6
18
|
|
|
7
19
|
[Read the Docs to Learn More](https://northword.github.io/zotero-plugin-scaffold).
|
|
8
20
|
|
|
21
|
+
## Contributing
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Git Clone
|
|
25
|
+
git clone https://github.com/northword/zotero-plugin-scaffold.git zotero-plugin-scaffold
|
|
26
|
+
cd zotero-plugin-scaffold/
|
|
27
|
+
|
|
28
|
+
# Install deps
|
|
29
|
+
corepack enable
|
|
30
|
+
pnpm install
|
|
31
|
+
|
|
32
|
+
# Development Mode
|
|
33
|
+
# This command creates a typescript runtime using jiti,
|
|
34
|
+
# and the modified code does not need to be built again.
|
|
35
|
+
pnpm run dev
|
|
36
|
+
|
|
37
|
+
# link local scaffold to your plugin
|
|
38
|
+
cd your-plugin-work-dir/
|
|
39
|
+
pnpm link ../zotero-plugin-scaffold/packages/scaffold/
|
|
40
|
+
cd zotero-plugin-scaffold/
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Now you can make changes to Scaffold and test them in your plugin.
|
|
44
|
+
|
|
45
|
+
When you're done modifying, make sure that you can pass the build and that the code style meets the requirements of this repository.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Build
|
|
49
|
+
pnpm run build
|
|
50
|
+
|
|
51
|
+
# ES Lint
|
|
52
|
+
pnpm run lint:fix
|
|
53
|
+
```
|
|
54
|
+
|
|
9
55
|
## License
|
|
10
56
|
|
|
11
57
|
GNU Affero General Public License Version 3.
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { B as Base, C as Context, O as OverrideConfig } from './shared/zotero-plugin-scaffold.oqywMJh-.mjs';
|
|
2
|
+
import 'hookable';
|
|
3
|
+
import 'esbuild';
|
|
4
|
+
|
|
5
|
+
type Constructor<T> = new (ctx: Context) => T;
|
|
6
|
+
declare function runCommand<T extends Base>(CommandClass: Constructor<T>, config: OverrideConfig): Promise<void>;
|
|
1
7
|
declare function mainWithErrorHandler(): Promise<void>;
|
|
2
8
|
|
|
3
|
-
export { mainWithErrorHandler as default };
|
|
9
|
+
export { mainWithErrorHandler as default, runCommand };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import {
|
|
3
|
+
import { E as ExitSignals, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.WLeAAj6o.mjs';
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
import { pathExists } from 'fs-extra';
|
|
6
|
+
import { l as logger } from './shared/zotero-plugin-scaffold.CzBjWbS8.mjs';
|
|
6
7
|
import tinyUpdateNotifier from 'tiny-update-notifier';
|
|
7
8
|
import 'c12';
|
|
8
9
|
import 'es-toolkit';
|
|
9
10
|
import 'fs-extra/esm';
|
|
10
11
|
import 'hookable';
|
|
11
|
-
import 'node:readline';
|
|
12
|
-
import 'node:util';
|
|
13
|
-
import 'std-env';
|
|
14
|
-
import './shared/zotero-plugin-scaffold.v8dJZZ-v.mjs';
|
|
15
12
|
import 'tinyglobby';
|
|
16
13
|
import 'node:path';
|
|
17
|
-
import 'adm-zip';
|
|
18
14
|
import 'esbuild';
|
|
19
|
-
import 'node:crypto';
|
|
20
|
-
import 'node:fs';
|
|
21
15
|
import '@fluent/syntax';
|
|
16
|
+
import 'node:fs';
|
|
22
17
|
import '@swc/core';
|
|
18
|
+
import 'node:crypto';
|
|
19
|
+
import 'adm-zip';
|
|
23
20
|
import 'node:child_process';
|
|
21
|
+
import 'std-env';
|
|
24
22
|
import 'bumpp';
|
|
25
23
|
import 'octokit';
|
|
26
24
|
import 'chokidar';
|
|
@@ -30,9 +28,11 @@ import 'node:domain';
|
|
|
30
28
|
import 'node:events';
|
|
31
29
|
import 'xvfb-ts';
|
|
32
30
|
import 'node:http';
|
|
31
|
+
import 'node:readline';
|
|
32
|
+
import 'node:util';
|
|
33
33
|
|
|
34
34
|
const name = "zotero-plugin-scaffold";
|
|
35
|
-
const version = "0.6.
|
|
35
|
+
const version = "0.6.1";
|
|
36
36
|
const pkg = {
|
|
37
37
|
name: name,
|
|
38
38
|
version: version};
|
|
@@ -71,32 +71,30 @@ async function main() {
|
|
|
71
71
|
process.env.NODE_ENV ??= "development";
|
|
72
72
|
const cli = new Command();
|
|
73
73
|
cli.version(version).usage("<command> [options]");
|
|
74
|
-
cli.command("build").description("Build the plugin").option("--dev", "Builds the plugin in dev mode").option("--dist <dir>", "The relative path for the new output directory (default: build)").action((options) => {
|
|
74
|
+
cli.command("build").description("Build the plugin").option("--dev", "Builds the plugin in dev mode").option("--dist <dir>", "The relative path for the new output directory (default: build)").action(async (options) => {
|
|
75
75
|
process.env.NODE_ENV = options.dev ? "development" : "production";
|
|
76
|
-
|
|
76
|
+
await runCommand(Build, {
|
|
77
77
|
dist: options.dist
|
|
78
|
-
})
|
|
78
|
+
});
|
|
79
79
|
});
|
|
80
|
-
cli.command("serve").alias("dev").description("Start development server").action((_options) => {
|
|
81
|
-
|
|
80
|
+
cli.command("serve").alias("dev").description("Start development server").action(async (_options) => {
|
|
81
|
+
await runCommand(Serve, {});
|
|
82
82
|
});
|
|
83
|
-
cli.command("test").description("Run tests").option("--abort-on-fail", "Abort the test suite on first failure").option("--exit-on-finish", "Exit the test suite after all tests have run").option("--no-watch", "Exit the test suite after all tests have run").action((options) => {
|
|
83
|
+
cli.command("test").description("Run tests").option("--abort-on-fail", "Abort the test suite on first failure").option("--exit-on-finish", "Exit the test suite after all tests have run").option("--no-watch", "Exit the test suite after all tests have run").action(async (options) => {
|
|
84
84
|
process.env.NODE_ENV = "test";
|
|
85
|
-
|
|
85
|
+
await runCommand(Test, {
|
|
86
86
|
test: {
|
|
87
87
|
abortOnFail: options.abortOnFail,
|
|
88
88
|
watch: !options.exitOnFinish && options.watch
|
|
89
89
|
}
|
|
90
|
-
}).then((ctx) => {
|
|
91
|
-
new Test(ctx).run();
|
|
92
90
|
});
|
|
93
91
|
});
|
|
94
|
-
cli.command("create").description("Create the plugin template").action((_options) => {
|
|
92
|
+
cli.command("create").description("Create the plugin template").action(async (_options) => {
|
|
95
93
|
logger.error("The create not yet implemented");
|
|
96
94
|
});
|
|
97
95
|
cli.command("release").description("Release the plugin").argument("[version]", "Target version: major, minor, patch, pre*, or specify version").option("--preid <preid>", "ID for prerelease").option("-y, --yes", "Skip confirmation").action(async (version2, options) => {
|
|
98
96
|
process.env.NODE_ENV = "production";
|
|
99
|
-
|
|
97
|
+
await runCommand(Release, {
|
|
100
98
|
release: {
|
|
101
99
|
bumpp: {
|
|
102
100
|
release: version2,
|
|
@@ -104,7 +102,7 @@ async function main() {
|
|
|
104
102
|
confirm: !options.yes
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
|
-
})
|
|
105
|
+
});
|
|
108
106
|
});
|
|
109
107
|
cli.arguments("<command>").action((cmd) => {
|
|
110
108
|
cli.outputHelp();
|
|
@@ -112,6 +110,12 @@ async function main() {
|
|
|
112
110
|
});
|
|
113
111
|
cli.parse();
|
|
114
112
|
}
|
|
113
|
+
async function runCommand(CommandClass, config) {
|
|
114
|
+
const ctx = await Config.loadConfig(config);
|
|
115
|
+
const instance = new CommandClass(ctx);
|
|
116
|
+
process.on("SIGINT", instance.exit.bind(instance));
|
|
117
|
+
await instance.run();
|
|
118
|
+
}
|
|
115
119
|
async function mainWithErrorHandler() {
|
|
116
120
|
main().then(() => {
|
|
117
121
|
checkGitIgnore();
|
|
@@ -126,4 +130,4 @@ function onError(err) {
|
|
|
126
130
|
process.exit(1);
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
export { mainWithErrorHandler as default };
|
|
133
|
+
export { mainWithErrorHandler as default, runCommand };
|