zotero-plugin-scaffold 0.6.0 → 0.7.0
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 +30 -22
- package/dist/index.d.mts +11 -848
- package/dist/index.mjs +11 -7
- package/dist/shared/zotero-plugin-scaffold.CzBjWbS8.mjs +257 -0
- package/dist/shared/zotero-plugin-scaffold.D2qdHZn7.mjs +4960 -0
- package/dist/shared/zotero-plugin-scaffold.DmiRKKLw.d.mts +858 -0
- package/dist/vendor/index.mjs +5 -1
- package/package.json +41 -25
- package/dist/shared/zotero-plugin-scaffold.C-SXQX4J.mjs +0 -3032
- 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.DmiRKKLw.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,28 +1,31 @@
|
|
|
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.D2qdHZn7.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';
|
|
24
|
+
import 'node:os';
|
|
25
|
+
import 'node:url';
|
|
26
|
+
import 'node:assert';
|
|
27
|
+
import 'node:v8';
|
|
28
|
+
import 'node:util';
|
|
26
29
|
import 'chokidar';
|
|
27
30
|
import 'node:net';
|
|
28
31
|
import 'node:buffer';
|
|
@@ -30,9 +33,10 @@ import 'node:domain';
|
|
|
30
33
|
import 'node:events';
|
|
31
34
|
import 'xvfb-ts';
|
|
32
35
|
import 'node:http';
|
|
36
|
+
import 'node:readline';
|
|
33
37
|
|
|
34
38
|
const name = "zotero-plugin-scaffold";
|
|
35
|
-
const version = "0.
|
|
39
|
+
const version = "0.7.0";
|
|
36
40
|
const pkg = {
|
|
37
41
|
name: name,
|
|
38
42
|
version: version};
|
|
@@ -71,32 +75,30 @@ async function main() {
|
|
|
71
75
|
process.env.NODE_ENV ??= "development";
|
|
72
76
|
const cli = new Command();
|
|
73
77
|
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) => {
|
|
78
|
+
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
79
|
process.env.NODE_ENV = options.dev ? "development" : "production";
|
|
76
|
-
|
|
80
|
+
await runCommand(Build, {
|
|
77
81
|
dist: options.dist
|
|
78
|
-
})
|
|
82
|
+
});
|
|
79
83
|
});
|
|
80
|
-
cli.command("serve").alias("dev").description("Start development server").action((_options) => {
|
|
81
|
-
|
|
84
|
+
cli.command("serve").alias("dev").description("Start development server").action(async (_options) => {
|
|
85
|
+
await runCommand(Serve, {});
|
|
82
86
|
});
|
|
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) => {
|
|
87
|
+
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
88
|
process.env.NODE_ENV = "test";
|
|
85
|
-
|
|
89
|
+
await runCommand(Test, {
|
|
86
90
|
test: {
|
|
87
91
|
abortOnFail: options.abortOnFail,
|
|
88
92
|
watch: !options.exitOnFinish && options.watch
|
|
89
93
|
}
|
|
90
|
-
}).then((ctx) => {
|
|
91
|
-
new Test(ctx).run();
|
|
92
94
|
});
|
|
93
95
|
});
|
|
94
|
-
cli.command("create").description("Create the plugin template").action((_options) => {
|
|
96
|
+
cli.command("create").description("Create the plugin template").action(async (_options) => {
|
|
95
97
|
logger.error("The create not yet implemented");
|
|
96
98
|
});
|
|
97
99
|
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
100
|
process.env.NODE_ENV = "production";
|
|
99
|
-
|
|
101
|
+
await runCommand(Release, {
|
|
100
102
|
release: {
|
|
101
103
|
bumpp: {
|
|
102
104
|
release: version2,
|
|
@@ -104,7 +106,7 @@ async function main() {
|
|
|
104
106
|
confirm: !options.yes
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
|
-
})
|
|
109
|
+
});
|
|
108
110
|
});
|
|
109
111
|
cli.arguments("<command>").action((cmd) => {
|
|
110
112
|
cli.outputHelp();
|
|
@@ -112,6 +114,12 @@ async function main() {
|
|
|
112
114
|
});
|
|
113
115
|
cli.parse();
|
|
114
116
|
}
|
|
117
|
+
async function runCommand(CommandClass, config) {
|
|
118
|
+
const ctx = await Config.loadConfig(config);
|
|
119
|
+
const instance = new CommandClass(ctx);
|
|
120
|
+
process.on("SIGINT", instance.exit.bind(instance));
|
|
121
|
+
await instance.run();
|
|
122
|
+
}
|
|
115
123
|
async function mainWithErrorHandler() {
|
|
116
124
|
main().then(() => {
|
|
117
125
|
checkGitIgnore();
|
|
@@ -126,4 +134,4 @@ function onError(err) {
|
|
|
126
134
|
process.exit(1);
|
|
127
135
|
}
|
|
128
136
|
|
|
129
|
-
export { mainWithErrorHandler as default };
|
|
137
|
+
export { mainWithErrorHandler as default, runCommand };
|