zotero-plugin-scaffold 0.0.7 → 0.0.9
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 +32 -34
- package/dist/cli.d.mts +3 -0
- package/dist/cli.d.ts +3 -1
- package/dist/cli.mjs +211 -0
- package/dist/index.d.mts +685 -0
- package/dist/index.d.ts +682 -7
- package/dist/index.mjs +939 -0
- package/package.json +50 -49
- package/bin/zotero-plugin.mjs +0 -15
- package/dist/cli.js +0 -81
- package/dist/config.d.ts +0 -15
- package/dist/config.js +0 -168
- package/dist/index.js +0 -10
- package/dist/lib/base.d.ts +0 -15
- package/dist/lib/base.js +0 -33
- package/dist/lib/build.d.ts +0 -25
- package/dist/lib/build.js +0 -195
- package/dist/lib/create.d.ts +0 -19
- package/dist/lib/create.js +0 -40
- package/dist/lib/lint.d.ts +0 -6
- package/dist/lib/lint.js +0 -9
- package/dist/lib/release.d.ts +0 -256
- package/dist/lib/release.js +0 -188
- package/dist/lib/serve.d.ts +0 -23
- package/dist/lib/serve.js +0 -249
- package/dist/types.d.ts +0 -340
- package/dist/types.js +0 -1
- package/dist/utils/crypto.d.ts +0 -2
- package/dist/utils/crypto.js +0 -23
- package/dist/utils/log.d.ts +0 -11
- package/dist/utils/log.js +0 -53
- package/dist/utils/process.d.ts +0 -1
- package/dist/utils/process.js +0 -21
- package/dist/utils/string.d.ts +0 -1
- package/dist/utils/string.js +0 -18
- package/docs/.vitepress/.gitkeep +0 -0
- package/docs/index.md +0 -0
- package/template/default/.github/workflows/release.yaml +0 -56
- package/template/default/.gitkeep +0 -0
- package/template/default/bootstrap.js +0 -78
- package/template/mark-it-red/.gitkeep +0 -0
- package/types/release-it.d.ts +0 -104
- package/types/web-ext.d.ts +0 -54
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This repository serves only as a proof-of-concept for the above.
|
|
|
8
8
|
|
|
9
9
|
## Using in a blank project
|
|
10
10
|
|
|
11
|
-
> WIP
|
|
11
|
+
> WIP: Not yet implemented
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
# npm
|
|
@@ -40,7 +40,7 @@ cd zotero-plugin-scaffold/
|
|
|
40
40
|
|
|
41
41
|
# build
|
|
42
42
|
pnpm install
|
|
43
|
-
pnpm
|
|
43
|
+
pnpm build # or pnpm dev
|
|
44
44
|
|
|
45
45
|
# npm link
|
|
46
46
|
cd your-plugin-work-dir/
|
|
@@ -52,10 +52,7 @@ pnpm link ../zotero-plugin-scaffold
|
|
|
52
52
|
The configuration file needs to be stored in the following location. If the configuration file is not found, an error will be thrown.
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
zotero-plugin.config.ts
|
|
56
|
-
# also avaliable in *.js *.mjs *.cjs *.ts
|
|
57
|
-
# Or The `zotero-plugin`` property in `package.json`
|
|
58
|
-
# see https://github.com/cosmiconfig/cosmiconfig?tab=readme-ov-file#usage-for-end-users
|
|
55
|
+
zotero-plugin.config.ts # also avaliable in *.js *.mjs *.cjs *.ts
|
|
59
56
|
```
|
|
60
57
|
|
|
61
58
|
You can import `defineConfig` in js module to get type hints. If no value is specified for an optional property, the default value will be used.
|
|
@@ -64,18 +61,28 @@ You can import `defineConfig` in js module to get type hints. If no value is spe
|
|
|
64
61
|
import { defineConfig } from "zotero-plugin-scaffold";
|
|
65
62
|
|
|
66
63
|
export default defineConfig({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
name: pkg.config.addonName,
|
|
65
|
+
id: pkg.config.addonID,
|
|
66
|
+
namespace: pkg.config.addonRef,
|
|
67
|
+
updateURL: `https://raw.githubusercontent.com/{{owner}}/{{repo}}/main/update.json`,
|
|
68
|
+
xpiDownloadLink:
|
|
69
|
+
"https://github.com/{{owner}}/{{repo}}/releases/download/v{{version}}/{{xpiName}}.xpi",
|
|
70
|
+
build: {
|
|
71
|
+
esbuildOptions: [
|
|
72
|
+
{
|
|
73
|
+
entryPoints: ["src/index.ts"],
|
|
74
|
+
define: {
|
|
75
|
+
__env__: `"${process.env.NODE_ENV}"`,
|
|
76
|
+
},
|
|
77
|
+
bundle: true,
|
|
78
|
+
target: "firefox115",
|
|
79
|
+
},
|
|
80
|
+
],
|
|
74
81
|
},
|
|
75
82
|
});
|
|
76
83
|
```
|
|
77
84
|
|
|
78
|
-
Full config please refrence in [src/types
|
|
85
|
+
Full config please refrence in [src/types](./src/types/index.ts).
|
|
79
86
|
|
|
80
87
|
### 03. Create a env file
|
|
81
88
|
|
|
@@ -88,22 +95,15 @@ NOTE: Do not check-in this file to the repository!
|
|
|
88
95
|
```
|
|
89
96
|
|
|
90
97
|
```ini
|
|
91
|
-
#
|
|
92
|
-
# The path delimiter should be escaped as `\\` for win32.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
# Please input the directory where the database is located in dataDir
|
|
101
|
-
# If this field is kept empty, Zotero will start with the default data.
|
|
102
|
-
# https://www.zotero.org/support/zotero_data
|
|
103
|
-
dataDir =
|
|
104
|
-
|
|
105
|
-
# Other environment variables (optional)
|
|
106
|
-
# GITHUB_TOKEN =
|
|
98
|
+
# The path of the Zotero binary file.
|
|
99
|
+
# The path delimiter should be escaped as `\\` for win32.
|
|
100
|
+
# The path is `*/Zotero.app/Contents/MacOS/zotero` for MacOS.
|
|
101
|
+
ZOTERO_PLUGIN_ZOTERO_BIN_PATH = /path/to/zotero.exe
|
|
102
|
+
|
|
103
|
+
# The path of the profile used for development.
|
|
104
|
+
# Start the profile manager by `/path/to/zotero.exe -p` to create a profile for development.
|
|
105
|
+
# @see https://www.zotero.org/support/kb/profile_directory
|
|
106
|
+
ZOTERO_PLUGIN_PROFILE_PATH = /path/to/profile
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
### 04. Add scripts to package.json
|
|
@@ -123,9 +123,6 @@ dataDir =
|
|
|
123
123
|
```bash
|
|
124
124
|
pnpm run start
|
|
125
125
|
pnpm run build
|
|
126
|
-
|
|
127
|
-
# Or, run cmd in terminal
|
|
128
|
-
pnpm exec zotero-plugin build
|
|
129
126
|
```
|
|
130
127
|
|
|
131
128
|
## Using in NodeJS code
|
|
@@ -149,7 +146,8 @@ cd zotero-plugin-scaffold/
|
|
|
149
146
|
# Install deps
|
|
150
147
|
pnpm install
|
|
151
148
|
|
|
152
|
-
#
|
|
149
|
+
# Development Mode
|
|
150
|
+
# This command creates a js runtime using jiti, and the modified code does not need to be built again.
|
|
153
151
|
pnpm run dev
|
|
154
152
|
|
|
155
153
|
# Build
|
package/dist/cli.d.mts
ADDED
package/dist/cli.d.ts
CHANGED
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { Config, Build, Serve, Release } from './index.mjs';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import consola from 'consola';
|
|
4
|
+
import updateNotifier from 'update-notifier';
|
|
5
|
+
import 'c12';
|
|
6
|
+
import 'fs-extra';
|
|
7
|
+
import 'hookable';
|
|
8
|
+
import 'path';
|
|
9
|
+
import 'radash';
|
|
10
|
+
import 'crypto';
|
|
11
|
+
import 'chalk';
|
|
12
|
+
import 'std-env';
|
|
13
|
+
import 'esbuild';
|
|
14
|
+
import 'fast-glob';
|
|
15
|
+
import 'replace-in-file';
|
|
16
|
+
import 'web-ext';
|
|
17
|
+
import 'bumpp';
|
|
18
|
+
import 'conventional-changelog';
|
|
19
|
+
import 'mime';
|
|
20
|
+
import 'octokit';
|
|
21
|
+
import 'child_process';
|
|
22
|
+
import 'chokidar';
|
|
23
|
+
import 'process';
|
|
24
|
+
|
|
25
|
+
const name = "zotero-plugin-scaffold";
|
|
26
|
+
const version = "0.0.9";
|
|
27
|
+
const description = "A scaffold for Zotero plugin development.";
|
|
28
|
+
const scripts = {
|
|
29
|
+
dev: "unbuild --stub",
|
|
30
|
+
build: "tsc --noEmit && unbuild",
|
|
31
|
+
lint: "eslint --max-warnings=0 . && prettier --check .",
|
|
32
|
+
"lint:fix": "eslint --fix . && prettier --write .",
|
|
33
|
+
release: "release-it --only-version --preReleaseId=beta",
|
|
34
|
+
test: "echo \"Error: no test specified\" && exit 1"
|
|
35
|
+
};
|
|
36
|
+
const type = "module";
|
|
37
|
+
const exports = {
|
|
38
|
+
".": {
|
|
39
|
+
types: "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.mjs"
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const main$1 = "./dist/index.mjs";
|
|
44
|
+
const module = "./dist/index.mjs";
|
|
45
|
+
const types = "./dist/index.d.ts";
|
|
46
|
+
const bin = {
|
|
47
|
+
"zotero-plugin": "./dist/cli.mjs"
|
|
48
|
+
};
|
|
49
|
+
const files = [
|
|
50
|
+
"dist"
|
|
51
|
+
];
|
|
52
|
+
const keywords = [
|
|
53
|
+
"zotero",
|
|
54
|
+
"plugin",
|
|
55
|
+
"developer",
|
|
56
|
+
"scaffold",
|
|
57
|
+
"web-ext"
|
|
58
|
+
];
|
|
59
|
+
const author = "northword";
|
|
60
|
+
const license = "MIT";
|
|
61
|
+
const repository = {
|
|
62
|
+
type: "git",
|
|
63
|
+
url: "https://github.com/northword/zotero-plugin-scaffold.git"
|
|
64
|
+
};
|
|
65
|
+
const bugs = {
|
|
66
|
+
url: "https://github.com/northword/zotero-plugin-scaffold/issues"
|
|
67
|
+
};
|
|
68
|
+
const homepage = "https://github.com/northword/zotero-plugin-scaffold#readme";
|
|
69
|
+
const publishConfig = {
|
|
70
|
+
access: "public",
|
|
71
|
+
registry: "https://registry.npmjs.org"
|
|
72
|
+
};
|
|
73
|
+
const directories = {
|
|
74
|
+
lib: "dist",
|
|
75
|
+
doc: "docs"
|
|
76
|
+
};
|
|
77
|
+
const engines = {
|
|
78
|
+
node: ">=18"
|
|
79
|
+
};
|
|
80
|
+
const packageManager = "pnpm@8.15.5";
|
|
81
|
+
const dependencies = {
|
|
82
|
+
"@inquirer/prompts": "4.3.1",
|
|
83
|
+
bumpp: "9.4.0",
|
|
84
|
+
c12: "1.10.0",
|
|
85
|
+
chalk: "5.3.0",
|
|
86
|
+
chokidar: "3.6.0",
|
|
87
|
+
commander: "12.0.0",
|
|
88
|
+
consola: "3.2.3",
|
|
89
|
+
"conventional-changelog": "5.1.0",
|
|
90
|
+
esbuild: "0.20.2",
|
|
91
|
+
"fast-glob": "3.3.2",
|
|
92
|
+
"fs-extra": "11.2.0",
|
|
93
|
+
hookable: "5.5.3",
|
|
94
|
+
mime: "4.0.1",
|
|
95
|
+
octokit: "3.1.2",
|
|
96
|
+
radash: "12.1.0",
|
|
97
|
+
"replace-in-file": "7.1.0",
|
|
98
|
+
"std-env": "3.7.0",
|
|
99
|
+
"update-notifier": "7.0.0",
|
|
100
|
+
"web-ext": "7.11.0"
|
|
101
|
+
};
|
|
102
|
+
const devDependencies = {
|
|
103
|
+
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
104
|
+
"@types/conventional-changelog": "3.1.5",
|
|
105
|
+
"@types/fs-extra": "11.0.4",
|
|
106
|
+
"@types/node": "20.12.2",
|
|
107
|
+
"@types/update-notifier": "6.0.8",
|
|
108
|
+
"@typescript-eslint/eslint-plugin": "7.4.0",
|
|
109
|
+
"@typescript-eslint/parser": "7.4.0",
|
|
110
|
+
eslint: "8.57.0",
|
|
111
|
+
"eslint-config-prettier": "9.1.0",
|
|
112
|
+
prettier: "3.2.5",
|
|
113
|
+
"release-it": "17.1.1",
|
|
114
|
+
typescript: "5.4.3",
|
|
115
|
+
unbuild: "2.0.0"
|
|
116
|
+
};
|
|
117
|
+
const pnpm = {
|
|
118
|
+
peerDependencyRules: {
|
|
119
|
+
allowAny: [
|
|
120
|
+
"node-fetch"
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const pkg = {
|
|
125
|
+
name: name,
|
|
126
|
+
version: version,
|
|
127
|
+
description: description,
|
|
128
|
+
scripts: scripts,
|
|
129
|
+
type: type,
|
|
130
|
+
exports: exports,
|
|
131
|
+
main: main$1,
|
|
132
|
+
module: module,
|
|
133
|
+
types: types,
|
|
134
|
+
bin: bin,
|
|
135
|
+
files: files,
|
|
136
|
+
keywords: keywords,
|
|
137
|
+
author: author,
|
|
138
|
+
license: license,
|
|
139
|
+
repository: repository,
|
|
140
|
+
bugs: bugs,
|
|
141
|
+
homepage: homepage,
|
|
142
|
+
publishConfig: publishConfig,
|
|
143
|
+
directories: directories,
|
|
144
|
+
engines: engines,
|
|
145
|
+
packageManager: packageManager,
|
|
146
|
+
dependencies: dependencies,
|
|
147
|
+
devDependencies: devDependencies,
|
|
148
|
+
pnpm: pnpm,
|
|
149
|
+
"release-it": {
|
|
150
|
+
git: {
|
|
151
|
+
commitMessage: "chore(publish): release v${version}",
|
|
152
|
+
tagName: "v${version}"
|
|
153
|
+
},
|
|
154
|
+
npm: {
|
|
155
|
+
publish: false
|
|
156
|
+
},
|
|
157
|
+
github: {
|
|
158
|
+
release: false
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
async function main() {
|
|
164
|
+
var _a;
|
|
165
|
+
updateNotifier({ pkg }).notify();
|
|
166
|
+
(_a = process.env).NODE_ENV ?? (_a.NODE_ENV = "development");
|
|
167
|
+
const cli = new Command();
|
|
168
|
+
cli.version(pkg.version).usage("<command> [options]");
|
|
169
|
+
cli.command("build").description("Build the plugin.").option("--dev", "Builds the plugin in dev mode.").option(
|
|
170
|
+
"--dist <dir>",
|
|
171
|
+
"the full path for the new output directory, relative to the current workspace (default: build)"
|
|
172
|
+
).action(async (options) => {
|
|
173
|
+
process.env.NODE_ENV = options.dev ? "development" : "production";
|
|
174
|
+
const config = await Config.loadConfig({
|
|
175
|
+
dist: options.dist
|
|
176
|
+
});
|
|
177
|
+
new Build(config).run();
|
|
178
|
+
});
|
|
179
|
+
cli.command("serve").description("Start development server.").action(async (options) => {
|
|
180
|
+
const config = await Config.loadConfig({});
|
|
181
|
+
new Serve(config).run();
|
|
182
|
+
});
|
|
183
|
+
cli.command("create").description("Create the plugin template.").action((options) => {
|
|
184
|
+
consola.error("The create not yet implemented");
|
|
185
|
+
});
|
|
186
|
+
cli.command("release").description("Release.").action(async (options) => {
|
|
187
|
+
consola.error("The release not yet implemented");
|
|
188
|
+
process.env.NODE_ENV = "production";
|
|
189
|
+
const config = await Config.loadConfig({});
|
|
190
|
+
new Release(config).run();
|
|
191
|
+
});
|
|
192
|
+
cli.arguments("<command>").action((cmd) => {
|
|
193
|
+
cli.outputHelp();
|
|
194
|
+
consola.error(`Unknown command name=${cmd}.`);
|
|
195
|
+
});
|
|
196
|
+
cli.parse(process.argv);
|
|
197
|
+
}
|
|
198
|
+
main().catch((err) => {
|
|
199
|
+
console.log("");
|
|
200
|
+
consola.error(err);
|
|
201
|
+
console.log("");
|
|
202
|
+
process.exit(1);
|
|
203
|
+
});
|
|
204
|
+
process.on("unhandledRejection", (err) => {
|
|
205
|
+
console.log("");
|
|
206
|
+
consola.error(err);
|
|
207
|
+
console.log("");
|
|
208
|
+
process.exit(1);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
export { main as default };
|