zotero-plugin-scaffold 0.8.2 → 0.8.4
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 +2 -4
- package/bin/zotero-plugin.mjs +1 -1
- package/dist/cli.d.ts +9 -0
- package/dist/cli.js +100 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +3 -0
- package/dist/shared/scaffold-base-DINIqpGc.d.mts +12 -0
- package/dist/shared/scaffold-index-BAX-e18l.d.mts +873 -0
- package/dist/shared/scaffold-replace-BTU0g6CT.mjs +240 -0
- package/dist/shared/scaffold-src-BXURNLxp.mjs +4309 -0
- package/dist/vendor.d.ts +18 -0
- package/dist/vendor.js +4 -0
- package/package.json +34 -31
- package/dist/cli.d.mts +0 -9
- package/dist/cli.mjs +0 -137
- package/dist/index.d.mts +0 -83
- package/dist/index.mjs +0 -33
- package/dist/shared/zotero-plugin-scaffold.D0-KTF5z.d.mts +0 -880
- package/dist/shared/zotero-plugin-scaffold.DQYuTa0n.mjs +0 -4977
- package/dist/shared/zotero-plugin-scaffold.qsx_2VJx.mjs +0 -263
- package/dist/vendor/index.d.mts +0 -14
- package/dist/vendor/index.mjs +0 -11
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Zotero Plugin Development Scaffold
|
|
2
2
|
|
|
3
|
-
[](https://
|
|
4
|
-
[](https://
|
|
3
|
+
[](https://npmx.dev/package/zotero-plugin-scaffold)
|
|
4
|
+
[](https://npmx.dev/package/zotero-plugin-scaffold)
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|
[](https://github.com/antfu/eslint-config)
|
|
@@ -30,8 +30,6 @@ corepack enable
|
|
|
30
30
|
pnpm install
|
|
31
31
|
|
|
32
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
33
|
pnpm run dev
|
|
36
34
|
|
|
37
35
|
# link local scaffold to your plugin
|
package/bin/zotero-plugin.mjs
CHANGED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { n as OverrideConfig, t as Context } from "./shared/scaffold-index-BAX-e18l.mjs";
|
|
2
|
+
import { t as Base } from "./shared/scaffold-base-DINIqpGc.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/cli.d.ts
|
|
5
|
+
type Constructor<T> = new (ctx: Context) => T;
|
|
6
|
+
declare function runCommand<T extends Base>(CommandClass: Constructor<T>, config: OverrideConfig): Promise<void>;
|
|
7
|
+
declare function mainWithErrorHandler(): Promise<void>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { mainWithErrorHandler as default, runCommand };
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { l as logger } from "./shared/scaffold-replace-BTU0g6CT.mjs";
|
|
2
|
+
import { a as Release, i as ExitSignals, n as Test, o as Build, r as Serve, t as Config } from "./shared/scaffold-src-BXURNLxp.mjs";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import { pathExists } from "fs-extra";
|
|
7
|
+
import tinyUpdateNotifier from "tiny-update-notifier";
|
|
8
|
+
//#region package.json
|
|
9
|
+
var name = "zotero-plugin-scaffold";
|
|
10
|
+
var version = "0.8.4";
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/utils/gitignore.ts
|
|
13
|
+
async function checkGitIgnore() {
|
|
14
|
+
if (!pathExists(".git")) return;
|
|
15
|
+
if (!pathExists(".gitignore")) {
|
|
16
|
+
logger.warn("No .gitignore file found");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const contents = await readFile(".gitignore", "utf-8");
|
|
20
|
+
const miss = [
|
|
21
|
+
"node_modules",
|
|
22
|
+
".env",
|
|
23
|
+
".scaffold"
|
|
24
|
+
].filter((ignore) => !contents.match(ignore));
|
|
25
|
+
if (miss.length !== 0) logger.warn(`We recommend adding the following to your .gitignore file: ${miss.join(", ")}`);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/utils/updater.ts
|
|
29
|
+
function updateNotifier(name, version) {
|
|
30
|
+
tinyUpdateNotifier({ pkg: {
|
|
31
|
+
name,
|
|
32
|
+
version
|
|
33
|
+
} }).then((update) => {
|
|
34
|
+
if (update) {
|
|
35
|
+
const notify = () => {
|
|
36
|
+
logger.newLine();
|
|
37
|
+
logger.info(`New version of ${update.name} available!`);
|
|
38
|
+
logger.info(`Update: ${update.current} → ${update.latest} (${update.type})`);
|
|
39
|
+
logger.newLine();
|
|
40
|
+
};
|
|
41
|
+
ExitSignals.forEach((sig) => process.once(sig, notify));
|
|
42
|
+
}
|
|
43
|
+
}).catch();
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/cli.ts
|
|
47
|
+
async function main() {
|
|
48
|
+
updateNotifier(name, version);
|
|
49
|
+
process.env.NODE_ENV ??= "development";
|
|
50
|
+
const cli = new Command();
|
|
51
|
+
cli.version(version).usage("<command> [options]");
|
|
52
|
+
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) => {
|
|
53
|
+
process.env.NODE_ENV = options.dev ? "development" : "production";
|
|
54
|
+
await runCommand(Build, { dist: options.dist });
|
|
55
|
+
});
|
|
56
|
+
cli.command("serve").alias("dev").description("Start development server").action(async (_options) => {
|
|
57
|
+
await runCommand(Serve, {});
|
|
58
|
+
});
|
|
59
|
+
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) => {
|
|
60
|
+
process.env.NODE_ENV = "test";
|
|
61
|
+
await runCommand(Test, { test: {
|
|
62
|
+
abortOnFail: options.abortOnFail,
|
|
63
|
+
watch: !options.exitOnFinish && options.watch
|
|
64
|
+
} });
|
|
65
|
+
});
|
|
66
|
+
cli.command("create").description("Create the plugin template").action(async (_options) => {
|
|
67
|
+
logger.error("The create not yet implemented");
|
|
68
|
+
});
|
|
69
|
+
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 (version, options) => {
|
|
70
|
+
process.env.NODE_ENV = "production";
|
|
71
|
+
await runCommand(Release, { release: { bumpp: {
|
|
72
|
+
release: version,
|
|
73
|
+
preid: options.preid,
|
|
74
|
+
confirm: !options.yes
|
|
75
|
+
} } });
|
|
76
|
+
});
|
|
77
|
+
cli.arguments("<command>").action((cmd) => {
|
|
78
|
+
cli.outputHelp();
|
|
79
|
+
logger.error(`Unknown command name "${cmd}".`);
|
|
80
|
+
});
|
|
81
|
+
cli.parse();
|
|
82
|
+
}
|
|
83
|
+
async function runCommand(CommandClass, config) {
|
|
84
|
+
const instance = new CommandClass(await Config.loadConfig(config));
|
|
85
|
+
process.on("SIGINT", instance.exit.bind(instance));
|
|
86
|
+
await instance.run();
|
|
87
|
+
}
|
|
88
|
+
async function mainWithErrorHandler() {
|
|
89
|
+
main().then(() => {
|
|
90
|
+
checkGitIgnore();
|
|
91
|
+
}).catch(onError);
|
|
92
|
+
process.on("uncaughtException", onError);
|
|
93
|
+
}
|
|
94
|
+
function onError(err) {
|
|
95
|
+
logger.error(err);
|
|
96
|
+
if (err.output) logger.log(err.output.stderr);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { mainWithErrorHandler as default, runCommand };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { n as OverrideConfig, r as UserConfig, t as Context } from "./shared/scaffold-index-BAX-e18l.mjs";
|
|
2
|
+
import { t as Base } from "./shared/scaffold-base-DINIqpGc.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/config.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Helper for user define configuration.
|
|
7
|
+
*/
|
|
8
|
+
declare function defineConfig(userConfig: UserConfig): UserConfig;
|
|
9
|
+
/**
|
|
10
|
+
* Loads config
|
|
11
|
+
* @param [overrides] Highest Priority Configuration.
|
|
12
|
+
* @returns Config with userDefined and defaultConfig merged.
|
|
13
|
+
*/
|
|
14
|
+
declare function loadConfig(overrides?: OverrideConfig): Promise<Context>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/core/builder/index.d.ts
|
|
17
|
+
declare class Build extends Base {
|
|
18
|
+
private buildTime;
|
|
19
|
+
constructor(ctx: Context);
|
|
20
|
+
/**
|
|
21
|
+
* Default build runner
|
|
22
|
+
*/
|
|
23
|
+
run(): Promise<void>;
|
|
24
|
+
private prepareAssets;
|
|
25
|
+
bundle(): Promise<void>;
|
|
26
|
+
buildInProduction(): Promise<void>;
|
|
27
|
+
exit(): void;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/core/releaser/index.d.ts
|
|
31
|
+
declare class Release extends Base {
|
|
32
|
+
constructor(ctx: Context);
|
|
33
|
+
/**
|
|
34
|
+
* Runs release
|
|
35
|
+
*
|
|
36
|
+
* if is not CI,bump version, git add (package.json), git commit, git tag, git push;
|
|
37
|
+
* if is CI, do not bump version, do not run git, create release (tag is `v${version}`) and upload xpi,
|
|
38
|
+
* then, create or update release (tag is "release"), update `update.json`.
|
|
39
|
+
*/
|
|
40
|
+
run(): Promise<void>;
|
|
41
|
+
getChangelog(): Promise<string>;
|
|
42
|
+
private isEnabled;
|
|
43
|
+
exit(): void;
|
|
44
|
+
get resolvedCommitMessage(): string;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/core/server.d.ts
|
|
48
|
+
declare class Serve extends Base {
|
|
49
|
+
private builder;
|
|
50
|
+
private runner?;
|
|
51
|
+
private _zoteroBinPath?;
|
|
52
|
+
constructor(ctx: Context);
|
|
53
|
+
run(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* watch source dir and build when file changed
|
|
56
|
+
*/
|
|
57
|
+
watch(): Promise<void>;
|
|
58
|
+
reload(): Promise<void>;
|
|
59
|
+
exit: () => never;
|
|
60
|
+
private onZoteroExit;
|
|
61
|
+
get zoteroBinPath(): string;
|
|
62
|
+
get profilePath(): string | undefined;
|
|
63
|
+
get dataDir(): string | undefined;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/core/tester/index.d.ts
|
|
67
|
+
declare class Test extends Base {
|
|
68
|
+
private builder;
|
|
69
|
+
private zotero?;
|
|
70
|
+
private reporter;
|
|
71
|
+
private testBundler?;
|
|
72
|
+
constructor(ctx: Context);
|
|
73
|
+
run(): Promise<void>;
|
|
74
|
+
watch(): Promise<void>;
|
|
75
|
+
startZotero(): Promise<void>;
|
|
76
|
+
private onZoteroExit;
|
|
77
|
+
exit: (code?: string | number) => never;
|
|
78
|
+
private get zoteroBinPath();
|
|
79
|
+
private get prefs();
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/index.d.ts
|
|
83
|
+
declare const Config: {
|
|
84
|
+
defineConfig: typeof defineConfig;
|
|
85
|
+
loadConfig: typeof loadConfig;
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
export { Build, Config, Release, Serve, Test, defineConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { i as Logger, t as Context } from "./scaffold-index-BAX-e18l.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/base.d.ts
|
|
4
|
+
declare abstract class Base {
|
|
5
|
+
ctx: Context;
|
|
6
|
+
constructor(ctx: Context);
|
|
7
|
+
abstract run(): void | Promise<void>;
|
|
8
|
+
abstract exit(): void;
|
|
9
|
+
get logger(): Logger;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Base as t };
|