zotero-plugin-scaffold 0.0.32 → 0.0.33
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 +1 -1
- package/dist/cli.mjs +62 -64
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +54 -50
- package/package.json +34 -36
package/README.md
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,41 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import process from 'node:process';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import consola from 'consola';
|
|
5
5
|
import updateNotifier from 'update-notifier';
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import 'std-env';
|
|
6
|
+
import { Config, Build, Serve, Release } from './index.mjs';
|
|
7
|
+
import 'node:path';
|
|
9
8
|
import 'c12';
|
|
10
9
|
import 'fs-extra';
|
|
11
10
|
import 'hookable';
|
|
12
|
-
import 'path';
|
|
13
11
|
import 'radash';
|
|
14
|
-
import '
|
|
12
|
+
import 'bumpp';
|
|
13
|
+
import 'chalk';
|
|
14
|
+
import 'std-env';
|
|
15
15
|
import 'esbuild';
|
|
16
16
|
import 'fast-glob';
|
|
17
17
|
import 'replace-in-file';
|
|
18
18
|
import 'web-ext';
|
|
19
|
+
import 'node:crypto';
|
|
19
20
|
import 'conventional-changelog';
|
|
20
21
|
import 'mime';
|
|
21
22
|
import 'octokit';
|
|
22
|
-
import 'child_process';
|
|
23
|
+
import 'node:child_process';
|
|
23
24
|
import 'chokidar';
|
|
24
|
-
import 'process';
|
|
25
25
|
|
|
26
26
|
const name = "zotero-plugin-scaffold";
|
|
27
|
-
const
|
|
27
|
+
const type = "module";
|
|
28
|
+
const version = "0.0.33";
|
|
29
|
+
const packageManager = "pnpm@9.5.0";
|
|
28
30
|
const description = "A scaffold for Zotero plugin development.";
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"update:deps": "pnpx taze minor -w -f -l",
|
|
36
|
-
test: "echo \"Error: no test specified\" && exit 1"
|
|
31
|
+
const author = "northword";
|
|
32
|
+
const license = "AGPL-3.0-or-later";
|
|
33
|
+
const homepage = "https://github.com/northword/zotero-plugin-scaffold#readme";
|
|
34
|
+
const repository = {
|
|
35
|
+
type: "git",
|
|
36
|
+
url: "https://github.com/northword/zotero-plugin-scaffold.git"
|
|
37
37
|
};
|
|
38
|
-
const
|
|
38
|
+
const bugs = {
|
|
39
|
+
url: "https://github.com/northword/zotero-plugin-scaffold/issues"
|
|
40
|
+
};
|
|
41
|
+
const keywords = [
|
|
42
|
+
"zotero",
|
|
43
|
+
"plugin",
|
|
44
|
+
"developer",
|
|
45
|
+
"scaffold",
|
|
46
|
+
"web-ext"
|
|
47
|
+
];
|
|
39
48
|
const exports = {
|
|
40
49
|
".": {
|
|
41
50
|
types: "./dist/index.d.ts",
|
|
@@ -51,23 +60,18 @@ const bin = {
|
|
|
51
60
|
const files = [
|
|
52
61
|
"dist"
|
|
53
62
|
];
|
|
54
|
-
const
|
|
55
|
-
"
|
|
56
|
-
"plugin",
|
|
57
|
-
"developer",
|
|
58
|
-
"scaffold",
|
|
59
|
-
"web-ext"
|
|
60
|
-
];
|
|
61
|
-
const author = "northword";
|
|
62
|
-
const license = "AGPL-3.0-or-later";
|
|
63
|
-
const repository = {
|
|
64
|
-
type: "git",
|
|
65
|
-
url: "https://github.com/northword/zotero-plugin-scaffold.git"
|
|
63
|
+
const engines = {
|
|
64
|
+
node: ">=18"
|
|
66
65
|
};
|
|
67
|
-
const
|
|
68
|
-
|
|
66
|
+
const scripts = {
|
|
67
|
+
dev: "unbuild --stub",
|
|
68
|
+
build: "tsc --noEmit && unbuild",
|
|
69
|
+
lint: "eslint .",
|
|
70
|
+
"lint:fix": "eslint . --fix",
|
|
71
|
+
release: "bumpp --commit \"chore(release): publish v%s\"",
|
|
72
|
+
"update:deps": "pnpx taze minor -w -f -l",
|
|
73
|
+
test: "echo \"Error: no test specified\" && exit 1"
|
|
69
74
|
};
|
|
70
|
-
const homepage = "https://github.com/northword/zotero-plugin-scaffold#readme";
|
|
71
75
|
const publishConfig = {
|
|
72
76
|
access: "public",
|
|
73
77
|
registry: "https://registry.npmjs.org"
|
|
@@ -76,12 +80,8 @@ const directories = {
|
|
|
76
80
|
lib: "dist",
|
|
77
81
|
doc: "docs"
|
|
78
82
|
};
|
|
79
|
-
const engines = {
|
|
80
|
-
node: ">=18"
|
|
81
|
-
};
|
|
82
|
-
const packageManager = "pnpm@9.4.0";
|
|
83
83
|
const dependencies = {
|
|
84
|
-
"@inquirer/prompts": "5.0
|
|
84
|
+
"@inquirer/prompts": "5.2.0",
|
|
85
85
|
bumpp: "9.4.1",
|
|
86
86
|
c12: "1.11.1",
|
|
87
87
|
chalk: "5.3.0",
|
|
@@ -89,28 +89,26 @@ const dependencies = {
|
|
|
89
89
|
commander: "12.1.0",
|
|
90
90
|
consola: "3.2.3",
|
|
91
91
|
"conventional-changelog": "6.0.0",
|
|
92
|
-
esbuild: "0.
|
|
92
|
+
esbuild: "0.23.0",
|
|
93
93
|
"fast-glob": "3.3.2",
|
|
94
94
|
"fs-extra": "11.2.0",
|
|
95
95
|
hookable: "5.5.3",
|
|
96
|
-
mime: "4.0.
|
|
96
|
+
mime: "4.0.4",
|
|
97
97
|
octokit: "4.0.2",
|
|
98
98
|
radash: "12.1.0",
|
|
99
|
-
"replace-in-file": "
|
|
99
|
+
"replace-in-file": "8.1.0",
|
|
100
100
|
"std-env": "3.7.0",
|
|
101
|
-
"update-notifier": "7.
|
|
102
|
-
"web-ext": "
|
|
101
|
+
"update-notifier": "7.1.0",
|
|
102
|
+
"web-ext": "8.2.0"
|
|
103
103
|
};
|
|
104
104
|
const devDependencies = {
|
|
105
|
-
"@
|
|
106
|
-
"@types/conventional-changelog": "3.1.5",
|
|
105
|
+
"@antfu/eslint-config": "^2.23.0",
|
|
107
106
|
"@types/fs-extra": "11.0.4",
|
|
108
|
-
"@types/node": "20.14.
|
|
107
|
+
"@types/node": "20.14.11",
|
|
109
108
|
"@types/update-notifier": "6.0.8",
|
|
110
|
-
eslint: "9.
|
|
111
|
-
|
|
112
|
-
typescript: "5.5.
|
|
113
|
-
"typescript-eslint": "8.0.0-alpha.30",
|
|
109
|
+
eslint: "9.7.0",
|
|
110
|
+
"eslint-plugin-format": "^0.1.2",
|
|
111
|
+
typescript: "5.5.3",
|
|
114
112
|
unbuild: "2.0.0"
|
|
115
113
|
};
|
|
116
114
|
const pnpm = {
|
|
@@ -122,26 +120,26 @@ const pnpm = {
|
|
|
122
120
|
};
|
|
123
121
|
const pkg = {
|
|
124
122
|
name: name,
|
|
123
|
+
type: type,
|
|
125
124
|
version: version,
|
|
125
|
+
packageManager: packageManager,
|
|
126
126
|
description: description,
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
author: author,
|
|
128
|
+
license: license,
|
|
129
|
+
homepage: homepage,
|
|
130
|
+
repository: repository,
|
|
131
|
+
bugs: bugs,
|
|
132
|
+
keywords: keywords,
|
|
129
133
|
exports: exports,
|
|
130
134
|
main: main$1,
|
|
131
135
|
module: module,
|
|
132
136
|
types: types,
|
|
133
137
|
bin: bin,
|
|
134
138
|
files: files,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
license: license,
|
|
138
|
-
repository: repository,
|
|
139
|
-
bugs: bugs,
|
|
140
|
-
homepage: homepage,
|
|
139
|
+
engines: engines,
|
|
140
|
+
scripts: scripts,
|
|
141
141
|
publishConfig: publishConfig,
|
|
142
142
|
directories: directories,
|
|
143
|
-
engines: engines,
|
|
144
|
-
packageManager: packageManager,
|
|
145
143
|
dependencies: dependencies,
|
|
146
144
|
devDependencies: devDependencies,
|
|
147
145
|
pnpm: pnpm
|
|
@@ -163,14 +161,14 @@ async function main() {
|
|
|
163
161
|
});
|
|
164
162
|
new Build(config).run();
|
|
165
163
|
});
|
|
166
|
-
cli.command("serve").description("Start development server.").action(async (
|
|
164
|
+
cli.command("serve").description("Start development server.").action(async (_options) => {
|
|
167
165
|
const config = await Config.loadConfig({});
|
|
168
166
|
new Serve(config).run();
|
|
169
167
|
});
|
|
170
|
-
cli.command("create").description("Create the plugin template.").action((
|
|
168
|
+
cli.command("create").description("Create the plugin template.").action((_options) => {
|
|
171
169
|
consola.error("The create not yet implemented");
|
|
172
170
|
});
|
|
173
|
-
cli.command("release").description("Release.").action(async (
|
|
171
|
+
cli.command("release").description("Release.").action(async (_options) => {
|
|
174
172
|
process.env.NODE_ENV = "production";
|
|
175
173
|
const config = await Config.loadConfig({});
|
|
176
174
|
new Release(config).run();
|
|
@@ -179,7 +177,7 @@ async function main() {
|
|
|
179
177
|
cli.outputHelp();
|
|
180
178
|
consola.error(`Unknown command name=${cmd}.`);
|
|
181
179
|
});
|
|
182
|
-
cli.parse(
|
|
180
|
+
cli.parse();
|
|
183
181
|
}
|
|
184
182
|
main().catch((err) => {
|
|
185
183
|
console.log("");
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Hookable } from 'hookable';
|
|
1
2
|
import { VersionBumpOptions } from 'bumpp';
|
|
2
3
|
import * as esbuild from 'esbuild';
|
|
3
4
|
import { BuildOptions } from 'esbuild';
|
|
4
|
-
import { Hookable } from 'hookable';
|
|
5
5
|
import { ConsolaInstance } from 'consola';
|
|
6
6
|
import { Octokit } from 'octokit';
|
|
7
7
|
import * as child_process from 'child_process';
|
|
@@ -353,10 +353,10 @@ interface Context extends Config$1 {
|
|
|
353
353
|
* @param [userConfig]
|
|
354
354
|
* @returns Config with userDefined.
|
|
355
355
|
*/
|
|
356
|
-
declare
|
|
356
|
+
declare function defineConfig(userConfig: UserConfig): UserConfig;
|
|
357
357
|
/**
|
|
358
358
|
* Loads config
|
|
359
|
-
* @param [
|
|
359
|
+
* @param [overrides] Highest Priority Configuration.
|
|
360
360
|
* @returns Config with userDefined and defaultConfig merged.
|
|
361
361
|
*/
|
|
362
362
|
declare function loadConfig(overrides?: OverrideConfig): Promise<Context>;
|
|
@@ -691,7 +691,7 @@ declare class Serve extends Base {
|
|
|
691
691
|
}
|
|
692
692
|
|
|
693
693
|
declare const Config: {
|
|
694
|
-
defineConfig:
|
|
694
|
+
defineConfig: typeof defineConfig;
|
|
695
695
|
loadConfig: typeof loadConfig;
|
|
696
696
|
};
|
|
697
697
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Hookable } from 'hookable';
|
|
1
2
|
import { VersionBumpOptions } from 'bumpp';
|
|
2
3
|
import * as esbuild from 'esbuild';
|
|
3
4
|
import { BuildOptions } from 'esbuild';
|
|
4
|
-
import { Hookable } from 'hookable';
|
|
5
5
|
import { ConsolaInstance } from 'consola';
|
|
6
6
|
import { Octokit } from 'octokit';
|
|
7
7
|
import * as child_process from 'child_process';
|
|
@@ -353,10 +353,10 @@ interface Context extends Config$1 {
|
|
|
353
353
|
* @param [userConfig]
|
|
354
354
|
* @returns Config with userDefined.
|
|
355
355
|
*/
|
|
356
|
-
declare
|
|
356
|
+
declare function defineConfig(userConfig: UserConfig): UserConfig;
|
|
357
357
|
/**
|
|
358
358
|
* Loads config
|
|
359
|
-
* @param [
|
|
359
|
+
* @param [overrides] Highest Priority Configuration.
|
|
360
360
|
* @returns Config with userDefined and defaultConfig merged.
|
|
361
361
|
*/
|
|
362
362
|
declare function loadConfig(overrides?: OverrideConfig): Promise<Context>;
|
|
@@ -691,7 +691,7 @@ declare class Serve extends Base {
|
|
|
691
691
|
}
|
|
692
692
|
|
|
693
693
|
declare const Config: {
|
|
694
|
-
defineConfig:
|
|
694
|
+
defineConfig: typeof defineConfig;
|
|
695
695
|
loadConfig: typeof loadConfig;
|
|
696
696
|
};
|
|
697
697
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import consola, { createConsola } from 'consola';
|
|
4
|
-
import { isCI, isWindows, isMacOS, isLinux } from 'std-env';
|
|
1
|
+
import path, { join, basename } from 'node:path';
|
|
5
2
|
import { loadConfig as loadConfig$1 } from 'c12';
|
|
6
3
|
import fs from 'fs-extra';
|
|
7
4
|
import { createHooks } from 'hookable';
|
|
8
|
-
import path, { join, basename } from 'path';
|
|
9
5
|
import { dash, template, assign, debounce } from 'radash';
|
|
10
|
-
import
|
|
6
|
+
import { ProgressEvent, versionBump } from 'bumpp';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import consola, { createConsola } from 'consola';
|
|
9
|
+
import { isCI, isWindows, isMacOS, isLinux } from 'std-env';
|
|
10
|
+
import process, { env, platform } from 'node:process';
|
|
11
11
|
import { build } from 'esbuild';
|
|
12
12
|
import glob from 'fast-glob';
|
|
13
|
-
import
|
|
13
|
+
import { replaceInFileSync } from 'replace-in-file';
|
|
14
14
|
import webext from 'web-ext';
|
|
15
|
+
import * as crypto from 'node:crypto';
|
|
15
16
|
import conventionalChangelog from 'conventional-changelog';
|
|
16
17
|
import mime from 'mime';
|
|
17
18
|
import { Octokit } from 'octokit';
|
|
18
|
-
import { execSync, spawn } from 'child_process';
|
|
19
|
+
import { execSync, spawn } from 'node:child_process';
|
|
19
20
|
import chokidar from 'chokidar';
|
|
20
|
-
import { exit } from 'process';
|
|
21
21
|
|
|
22
22
|
const LogLevels = {
|
|
23
23
|
trace: 5,
|
|
@@ -66,11 +66,11 @@ function dateFormat(fmt, date) {
|
|
|
66
66
|
"S+": date.getSeconds().toString()
|
|
67
67
|
};
|
|
68
68
|
for (const k in opt) {
|
|
69
|
-
ret = new RegExp(
|
|
69
|
+
ret = new RegExp(`(${k})`).exec(fmt);
|
|
70
70
|
if (ret) {
|
|
71
71
|
fmt = fmt.replace(
|
|
72
72
|
ret[1],
|
|
73
|
-
ret[1].length
|
|
73
|
+
ret[1].length === 1 ? opt[k] : opt[k].padStart(ret[1].length, "0")
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -80,14 +80,15 @@ function toArray(value) {
|
|
|
80
80
|
return Array.isArray(value) ? value : [value];
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
function defineConfig(userConfig) {
|
|
84
84
|
return userConfig;
|
|
85
|
-
}
|
|
85
|
+
}
|
|
86
86
|
async function loadConfig(overrides) {
|
|
87
87
|
const result = await loadConfig$1({
|
|
88
88
|
name: "zotero-plugin",
|
|
89
89
|
dotenv: true,
|
|
90
90
|
packageJson: true,
|
|
91
|
+
// eslint-disable-next-line ts/no-use-before-define
|
|
91
92
|
defaults: getDefaultConfig(),
|
|
92
93
|
overrides
|
|
93
94
|
});
|
|
@@ -96,9 +97,11 @@ async function loadConfig(overrides) {
|
|
|
96
97
|
function resolveConfig(config) {
|
|
97
98
|
const pkg = fs.readJsonSync(path.join("package.json"), {
|
|
98
99
|
encoding: "utf-8"
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
});
|
|
101
|
+
const [, owner, repo] = (pkg.repository?.url ?? "").match(
|
|
102
|
+
/:\/\/.+com\/([^/]+)\/([^.]+)\.git$/
|
|
103
|
+
);
|
|
104
|
+
const data = {
|
|
102
105
|
owner,
|
|
103
106
|
repo,
|
|
104
107
|
version: pkg.version,
|
|
@@ -124,7 +127,6 @@ function resolveConfig(config) {
|
|
|
124
127
|
}
|
|
125
128
|
return ctx;
|
|
126
129
|
}
|
|
127
|
-
const getDefaultConfig = () => defaultConfig;
|
|
128
130
|
const defaultConfig = {
|
|
129
131
|
source: "src",
|
|
130
132
|
dist: "build",
|
|
@@ -151,8 +153,8 @@ const defaultConfig = {
|
|
|
151
153
|
homepage_url: "__homepage__",
|
|
152
154
|
author: "__author__",
|
|
153
155
|
icons: {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
48: "content/icons/favicon@0.5x.png",
|
|
157
|
+
96: "content/icons/favicon.png"
|
|
156
158
|
},
|
|
157
159
|
applications: {
|
|
158
160
|
zotero: {
|
|
@@ -202,6 +204,7 @@ const defaultConfig = {
|
|
|
202
204
|
},
|
|
203
205
|
logLevel: "info"
|
|
204
206
|
};
|
|
207
|
+
const getDefaultConfig = () => defaultConfig;
|
|
205
208
|
|
|
206
209
|
function generateHashSync(filePath, algorithm) {
|
|
207
210
|
const data = fs.readFileSync(filePath);
|
|
@@ -267,7 +270,7 @@ class Build extends Base {
|
|
|
267
270
|
super(ctx);
|
|
268
271
|
__publicField$2(this, "buildTime");
|
|
269
272
|
__publicField$2(this, "isPreRelease");
|
|
270
|
-
(_a =
|
|
273
|
+
(_a = env).NODE_ENV ?? (_a.NODE_ENV = "production");
|
|
271
274
|
this.buildTime = "";
|
|
272
275
|
this.isPreRelease = this.version.includes("-");
|
|
273
276
|
}
|
|
@@ -278,7 +281,7 @@ class Build extends Base {
|
|
|
278
281
|
const t = /* @__PURE__ */ new Date();
|
|
279
282
|
this.buildTime = dateFormat("YYYY-mm-dd HH:MM:SS", t);
|
|
280
283
|
this.logger.start(
|
|
281
|
-
`Building version ${chalk.blue(this.version)} to ${chalk.blue(this.dist)} at ${chalk.blue(this.buildTime)} in ${chalk.blue(
|
|
284
|
+
`Building version ${chalk.blue(this.version)} to ${chalk.blue(this.dist)} at ${chalk.blue(this.buildTime)} in ${chalk.blue(env.NODE_ENV)} mode.`
|
|
282
285
|
);
|
|
283
286
|
await this.ctx.hooks.callHook("build:init", this.ctx);
|
|
284
287
|
fs.emptyDirSync(this.dist);
|
|
@@ -298,7 +301,7 @@ class Build extends Base {
|
|
|
298
301
|
await this.esbuild();
|
|
299
302
|
await this.ctx.hooks.callHook("build:bundle", this.ctx);
|
|
300
303
|
this.logger.info("Addon prepare OK.");
|
|
301
|
-
if (
|
|
304
|
+
if (env.NODE_ENV === "production") {
|
|
302
305
|
this.logger.info("Packing Addon");
|
|
303
306
|
await this.pack();
|
|
304
307
|
await this.ctx.hooks.callHook("build:pack", this.ctx);
|
|
@@ -333,13 +336,14 @@ class Build extends Base {
|
|
|
333
336
|
return;
|
|
334
337
|
const userData = fs.readJSONSync(
|
|
335
338
|
`${this.dist}/addon/manifest.json`
|
|
336
|
-
)
|
|
339
|
+
);
|
|
340
|
+
const template2 = {
|
|
337
341
|
...userData,
|
|
338
342
|
...this.name && { name: this.name },
|
|
339
343
|
...this.version && { version: this.version },
|
|
340
344
|
manifest_version: 2,
|
|
341
345
|
applications: {
|
|
342
|
-
|
|
346
|
+
// @ts-expect-error 此处不包含版本限制
|
|
343
347
|
zotero: {
|
|
344
348
|
id: this.id,
|
|
345
349
|
update_url: this.updateURL
|
|
@@ -366,9 +370,9 @@ class Build extends Base {
|
|
|
366
370
|
])
|
|
367
371
|
);
|
|
368
372
|
this.logger.debug("replace map: ", replaceMap);
|
|
369
|
-
const replaceResult =
|
|
373
|
+
const replaceResult = replaceInFileSync({
|
|
370
374
|
files: toArray(this.ctx.build.assets).map(
|
|
371
|
-
(asset) => `${this.dist}/${asset}`
|
|
375
|
+
(asset) => `${this.dist}/addon/${asset.split("/").slice(1).join("/")}`
|
|
372
376
|
),
|
|
373
377
|
from: Array.from(replaceMap.keys()),
|
|
374
378
|
to: Array.from(replaceMap.values()),
|
|
@@ -383,7 +387,7 @@ class Build extends Base {
|
|
|
383
387
|
const localeNames = glob.sync(`${this.dist}/addon/locale/**`, { onlyDirectories: true }).map((locale) => path.basename(locale));
|
|
384
388
|
this.logger.debug("locale names: ", localeNames);
|
|
385
389
|
for (const localeName of localeNames) {
|
|
386
|
-
if (this.ctx.build.fluent.prefixLocaleFiles
|
|
390
|
+
if (this.ctx.build.fluent.prefixLocaleFiles === true) {
|
|
387
391
|
glob.sync(`${this.dist}/addon/locale/${localeName}/**/*.ftl`, {}).forEach((f) => {
|
|
388
392
|
fs.moveSync(
|
|
389
393
|
f,
|
|
@@ -393,14 +397,14 @@ class Build extends Base {
|
|
|
393
397
|
});
|
|
394
398
|
}
|
|
395
399
|
const MessageInThisLang = /* @__PURE__ */ new Set();
|
|
396
|
-
|
|
400
|
+
replaceInFileSync({
|
|
397
401
|
files: [`${this.dist}/addon/locale/${localeName}/**/*.ftl`],
|
|
398
|
-
// @ts-ignore ReplaceInFileConfig has processor
|
|
399
402
|
processor: (fltContent) => {
|
|
400
403
|
const lines = fltContent.split("\n");
|
|
401
404
|
const prefixedLines = lines.map((line) => {
|
|
402
405
|
const match = line.match(
|
|
403
|
-
|
|
406
|
+
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
407
|
+
/^(?<message>[a-z]\S*)( *= *)(?<pattern>.*)$/im
|
|
404
408
|
);
|
|
405
409
|
if (match && match.groups) {
|
|
406
410
|
MessageInThisLang.add(match.groups.message);
|
|
@@ -413,12 +417,11 @@ class Build extends Base {
|
|
|
413
417
|
}
|
|
414
418
|
});
|
|
415
419
|
const MessagesInHTML = /* @__PURE__ */ new Set();
|
|
416
|
-
|
|
420
|
+
replaceInFileSync({
|
|
417
421
|
files: [
|
|
418
422
|
`${this.dist}/addon/**/*.xhtml`,
|
|
419
423
|
`${this.dist}/addon/**/*.html`
|
|
420
424
|
],
|
|
421
|
-
// @ts-ignore ReplaceInFileConfig has processor
|
|
422
425
|
processor: (input) => {
|
|
423
426
|
const matches = [
|
|
424
427
|
...input.matchAll(
|
|
@@ -446,7 +449,7 @@ class Build extends Base {
|
|
|
446
449
|
}
|
|
447
450
|
}
|
|
448
451
|
esbuild() {
|
|
449
|
-
if (this.ctx.build.esbuildOptions.length
|
|
452
|
+
if (this.ctx.build.esbuildOptions.length === 0)
|
|
450
453
|
return;
|
|
451
454
|
return Promise.all(
|
|
452
455
|
this.ctx.build.esbuildOptions.map(
|
|
@@ -457,7 +460,9 @@ class Build extends Base {
|
|
|
457
460
|
makeUpdateJson() {
|
|
458
461
|
const manifest = fs.readJSONSync(
|
|
459
462
|
`${this.dist}/addon/manifest.json`
|
|
460
|
-
)
|
|
463
|
+
);
|
|
464
|
+
const min = manifest.applications?.zotero?.strict_min_version;
|
|
465
|
+
const max = manifest.applications?.zotero?.strict_max_version;
|
|
461
466
|
const updateHash = generateHashSync(
|
|
462
467
|
path.join(this.dist, `${this.xpiName}.xpi`),
|
|
463
468
|
"sha512"
|
|
@@ -530,7 +535,7 @@ class Release extends Base {
|
|
|
530
535
|
if (!this.isCI) {
|
|
531
536
|
await this.bump();
|
|
532
537
|
} else {
|
|
533
|
-
if (glob.globSync(`${this.dist}/*.xpi`).length
|
|
538
|
+
if (glob.globSync(`${this.dist}/*.xpi`).length === 0) {
|
|
534
539
|
throw new Error("No xpi file found, are you sure you have run build?");
|
|
535
540
|
}
|
|
536
541
|
this.logger.info("Uploading XPI...");
|
|
@@ -576,10 +581,10 @@ class Release extends Base {
|
|
|
576
581
|
repo: this.repo,
|
|
577
582
|
tag
|
|
578
583
|
}).catch((e) => {
|
|
579
|
-
this.logger.log(`Release with tag ${tag} not found
|
|
584
|
+
this.logger.log(`Release with tag ${tag} not found. ${e}`);
|
|
580
585
|
return void 0;
|
|
581
586
|
}).then((res) => {
|
|
582
|
-
if (res && res.status
|
|
587
|
+
if (res && res.status === 200) {
|
|
583
588
|
return res.data;
|
|
584
589
|
}
|
|
585
590
|
});
|
|
@@ -590,7 +595,7 @@ class Release extends Base {
|
|
|
590
595
|
this.logger.error(e);
|
|
591
596
|
throw new Error("Create release failed.");
|
|
592
597
|
}).then((res) => {
|
|
593
|
-
if (res.status
|
|
598
|
+
if (res.status === 201) {
|
|
594
599
|
return res.data;
|
|
595
600
|
}
|
|
596
601
|
});
|
|
@@ -667,10 +672,10 @@ class Release extends Base {
|
|
|
667
672
|
});
|
|
668
673
|
}
|
|
669
674
|
getClient() {
|
|
670
|
-
if (!
|
|
675
|
+
if (!env.GITHUB_TOKEN)
|
|
671
676
|
throw new Error("No GITHUB_TOKEN.");
|
|
672
677
|
const client = new Octokit({
|
|
673
|
-
auth:
|
|
678
|
+
auth: env.GITHUB_TOKEN,
|
|
674
679
|
userAgent: `zotero-plugin-scaffold/${this.version}`
|
|
675
680
|
});
|
|
676
681
|
return client;
|
|
@@ -684,7 +689,6 @@ class Release extends Base {
|
|
|
684
689
|
}
|
|
685
690
|
|
|
686
691
|
function isRunning(query) {
|
|
687
|
-
const platform = process.platform;
|
|
688
692
|
let cmd = "";
|
|
689
693
|
switch (platform) {
|
|
690
694
|
case "win32":
|
|
@@ -699,8 +703,8 @@ function isRunning(query) {
|
|
|
699
703
|
}
|
|
700
704
|
try {
|
|
701
705
|
const stdout = execSync(cmd, { encoding: "utf8" });
|
|
702
|
-
return stdout.toLowerCase().
|
|
703
|
-
} catch
|
|
706
|
+
return stdout.toLowerCase().includes(query.toLowerCase());
|
|
707
|
+
} catch {
|
|
704
708
|
return false;
|
|
705
709
|
}
|
|
706
710
|
}
|
|
@@ -708,8 +712,8 @@ function isRunning(query) {
|
|
|
708
712
|
function killZotero() {
|
|
709
713
|
function kill() {
|
|
710
714
|
try {
|
|
711
|
-
if (
|
|
712
|
-
execSync(
|
|
715
|
+
if (env.ZOTERO_PLUGIN_KILL_COMMAND) {
|
|
716
|
+
execSync(env.ZOTERO_PLUGIN_KILL_COMMAND);
|
|
713
717
|
} else if (isWindows) {
|
|
714
718
|
execSync("taskkill /f /im zotero.exe");
|
|
715
719
|
} else if (isMacOS) {
|
|
@@ -719,7 +723,7 @@ function killZotero() {
|
|
|
719
723
|
} else {
|
|
720
724
|
consola.error("No commands found for this operating system.");
|
|
721
725
|
}
|
|
722
|
-
} catch
|
|
726
|
+
} catch {
|
|
723
727
|
consola.fail("Kill Zotero failed.");
|
|
724
728
|
}
|
|
725
729
|
}
|
|
@@ -820,15 +824,15 @@ class Serve extends Base {
|
|
|
820
824
|
"-profile",
|
|
821
825
|
this.profilePath
|
|
822
826
|
]);
|
|
823
|
-
zoteroProcess.stdout?.on("data", (
|
|
827
|
+
zoteroProcess.stdout?.on("data", (_data) => {
|
|
824
828
|
});
|
|
825
829
|
zoteroProcess.on("close", (code) => {
|
|
826
830
|
this.logger.info(`Zotero terminated with code ${code}.`);
|
|
827
|
-
exit(0);
|
|
831
|
+
process.exit(0);
|
|
828
832
|
});
|
|
829
833
|
process.on("SIGINT", () => {
|
|
830
834
|
zoteroProcess.kill();
|
|
831
|
-
exit();
|
|
835
|
+
process.exit();
|
|
832
836
|
});
|
|
833
837
|
return zoteroProcess;
|
|
834
838
|
}
|
|
@@ -891,7 +895,7 @@ class Serve extends Base {
|
|
|
891
895
|
const PrefsLines = fs.readFileSync(prefsPath, "utf-8").split("\n");
|
|
892
896
|
const filteredLines = PrefsLines.map((line) => {
|
|
893
897
|
if (line.includes("extensions.lastAppBuildId") || line.includes("extensions.lastAppVersion")) {
|
|
894
|
-
return;
|
|
898
|
+
return "";
|
|
895
899
|
}
|
|
896
900
|
if (line.includes("extensions.zotero.dataDir") && this.dataDir !== "") {
|
|
897
901
|
return `user_pref("extensions.zotero.dataDir", "${this.dataDir}");`;
|
package/package.json
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zotero-plugin-scaffold",
|
|
3
|
-
"version": "0.0.32",
|
|
4
|
-
"description": "A scaffold for Zotero plugin development.",
|
|
5
3
|
"type": "module",
|
|
4
|
+
"version": "0.0.33",
|
|
5
|
+
"description": "A scaffold for Zotero plugin development.",
|
|
6
|
+
"author": "northword",
|
|
7
|
+
"license": "AGPL-3.0-or-later",
|
|
8
|
+
"homepage": "https://github.com/northword/zotero-plugin-scaffold#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/northword/zotero-plugin-scaffold.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/northword/zotero-plugin-scaffold/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"zotero",
|
|
18
|
+
"plugin",
|
|
19
|
+
"developer",
|
|
20
|
+
"scaffold",
|
|
21
|
+
"web-ext"
|
|
22
|
+
],
|
|
6
23
|
"exports": {
|
|
7
24
|
".": {
|
|
8
25
|
"types": "./dist/index.d.ts",
|
|
@@ -18,23 +35,9 @@
|
|
|
18
35
|
"files": [
|
|
19
36
|
"dist"
|
|
20
37
|
],
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"plugin",
|
|
24
|
-
"developer",
|
|
25
|
-
"scaffold",
|
|
26
|
-
"web-ext"
|
|
27
|
-
],
|
|
28
|
-
"author": "northword",
|
|
29
|
-
"license": "AGPL-3.0-or-later",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "https://github.com/northword/zotero-plugin-scaffold.git"
|
|
33
|
-
},
|
|
34
|
-
"bugs": {
|
|
35
|
-
"url": "https://github.com/northword/zotero-plugin-scaffold/issues"
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
36
40
|
},
|
|
37
|
-
"homepage": "https://github.com/northword/zotero-plugin-scaffold#readme",
|
|
38
41
|
"publishConfig": {
|
|
39
42
|
"access": "public",
|
|
40
43
|
"registry": "https://registry.npmjs.org"
|
|
@@ -43,11 +46,8 @@
|
|
|
43
46
|
"lib": "dist",
|
|
44
47
|
"doc": "docs"
|
|
45
48
|
},
|
|
46
|
-
"engines": {
|
|
47
|
-
"node": ">=18"
|
|
48
|
-
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@inquirer/prompts": "5.0
|
|
50
|
+
"@inquirer/prompts": "5.2.0",
|
|
51
51
|
"bumpp": "9.4.1",
|
|
52
52
|
"c12": "1.11.1",
|
|
53
53
|
"chalk": "5.3.0",
|
|
@@ -55,35 +55,33 @@
|
|
|
55
55
|
"commander": "12.1.0",
|
|
56
56
|
"consola": "3.2.3",
|
|
57
57
|
"conventional-changelog": "6.0.0",
|
|
58
|
-
"esbuild": "0.
|
|
58
|
+
"esbuild": "0.23.0",
|
|
59
59
|
"fast-glob": "3.3.2",
|
|
60
60
|
"fs-extra": "11.2.0",
|
|
61
61
|
"hookable": "5.5.3",
|
|
62
|
-
"mime": "4.0.
|
|
62
|
+
"mime": "4.0.4",
|
|
63
63
|
"octokit": "4.0.2",
|
|
64
64
|
"radash": "12.1.0",
|
|
65
|
-
"replace-in-file": "
|
|
65
|
+
"replace-in-file": "8.1.0",
|
|
66
66
|
"std-env": "3.7.0",
|
|
67
|
-
"update-notifier": "7.
|
|
68
|
-
"web-ext": "
|
|
67
|
+
"update-notifier": "7.1.0",
|
|
68
|
+
"web-ext": "8.2.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@
|
|
72
|
-
"@types/conventional-changelog": "3.1.5",
|
|
71
|
+
"@antfu/eslint-config": "^2.23.0",
|
|
73
72
|
"@types/fs-extra": "11.0.4",
|
|
74
|
-
"@types/node": "20.14.
|
|
73
|
+
"@types/node": "20.14.11",
|
|
75
74
|
"@types/update-notifier": "6.0.8",
|
|
76
|
-
"eslint": "9.
|
|
77
|
-
"
|
|
78
|
-
"typescript": "5.5.
|
|
79
|
-
"typescript-eslint": "8.0.0-alpha.30",
|
|
75
|
+
"eslint": "9.7.0",
|
|
76
|
+
"eslint-plugin-format": "^0.1.2",
|
|
77
|
+
"typescript": "5.5.3",
|
|
80
78
|
"unbuild": "2.0.0"
|
|
81
79
|
},
|
|
82
80
|
"scripts": {
|
|
83
81
|
"dev": "unbuild --stub",
|
|
84
82
|
"build": "tsc --noEmit && unbuild",
|
|
85
|
-
"lint": "eslint .
|
|
86
|
-
"lint:fix": "eslint
|
|
83
|
+
"lint": "eslint .",
|
|
84
|
+
"lint:fix": "eslint . --fix",
|
|
87
85
|
"release": "bumpp --commit \"chore(release): publish v%s\"",
|
|
88
86
|
"update:deps": "pnpx taze minor -w -f -l",
|
|
89
87
|
"test": "echo \"Error: no test specified\" && exit 1"
|