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