zotero-plugin-scaffold 0.0.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 +168 -0
- package/bin/zotero-plugin.mjs +15 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +81 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.js +174 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/lib/build.d.ts +25 -0
- package/dist/lib/build.js +194 -0
- package/dist/lib/create.d.ts +19 -0
- package/dist/lib/create.js +40 -0
- package/dist/lib/lint.d.ts +6 -0
- package/dist/lib/lint.js +9 -0
- package/dist/lib/release.d.ts +255 -0
- package/dist/lib/release.js +165 -0
- package/dist/lib/serve.d.ts +22 -0
- package/dist/lib/serve.js +233 -0
- package/dist/types.d.ts +346 -0
- package/dist/types.js +1 -0
- package/dist/utils/crypto.d.ts +2 -0
- package/dist/utils/crypto.js +23 -0
- package/dist/utils/libBase.d.ts +15 -0
- package/dist/utils/libBase.js +33 -0
- package/dist/utils/log.d.ts +11 -0
- package/dist/utils/log.js +52 -0
- package/dist/utils/process.d.ts +1 -0
- package/dist/utils/process.js +21 -0
- package/dist/utils/string.d.ts +1 -0
- package/dist/utils/string.js +18 -0
- package/docs/.vitepress/.gitkeep +0 -0
- package/docs/index.md +0 -0
- package/package.json +101 -0
- package/types/release-it.d.ts +104 -0
- package/types/web-ext.d.ts +54 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { isCI } from "ci-info";
|
|
3
|
+
var LOG_LEVEL;
|
|
4
|
+
(function (LOG_LEVEL) {
|
|
5
|
+
LOG_LEVEL[LOG_LEVEL["trace"] = 0] = "trace";
|
|
6
|
+
LOG_LEVEL[LOG_LEVEL["debug"] = 1] = "debug";
|
|
7
|
+
LOG_LEVEL[LOG_LEVEL["info"] = 2] = "info";
|
|
8
|
+
LOG_LEVEL[LOG_LEVEL["warn"] = 3] = "warn";
|
|
9
|
+
LOG_LEVEL[LOG_LEVEL["error"] = 4] = "error";
|
|
10
|
+
})(LOG_LEVEL || (LOG_LEVEL = {}));
|
|
11
|
+
export default class Log {
|
|
12
|
+
logLevel;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
if (config) {
|
|
15
|
+
this.logLevel = isCI ? 0 : LOG_LEVEL[config.logLevel];
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.logLevel = 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// shouldLog(isExternal?: boolean) {
|
|
22
|
+
// return this.verbosityLevel === 2 || (this.isVerbose && isExternal);
|
|
23
|
+
// }
|
|
24
|
+
log(...args) {
|
|
25
|
+
args = args.map((arg) => {
|
|
26
|
+
if (typeof arg == "object")
|
|
27
|
+
return JSON.stringify(arg, null, 2);
|
|
28
|
+
return arg;
|
|
29
|
+
});
|
|
30
|
+
console.log(...args);
|
|
31
|
+
}
|
|
32
|
+
error(...args) {
|
|
33
|
+
if (this.logLevel <= 4)
|
|
34
|
+
console.log(chalk.red("ERROR"), ...args);
|
|
35
|
+
}
|
|
36
|
+
warn(...args) {
|
|
37
|
+
if (this.logLevel <= 3)
|
|
38
|
+
this.log(chalk.yellow("WARNING"), ...args);
|
|
39
|
+
}
|
|
40
|
+
info(...args) {
|
|
41
|
+
if (this.logLevel <= 2)
|
|
42
|
+
this.log(chalk.green("INFO"), ...args);
|
|
43
|
+
}
|
|
44
|
+
debug(...args) {
|
|
45
|
+
if (this.logLevel <= 1)
|
|
46
|
+
this.log(chalk.grey("DEBUG"), ...args);
|
|
47
|
+
}
|
|
48
|
+
trace(...args) {
|
|
49
|
+
if (this.logLevel <= 0)
|
|
50
|
+
this.log(chalk.grey(...args));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isRunning(query: string, cb: (status: boolean) => void): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
export function isRunning(query, cb) {
|
|
3
|
+
const platform = process.platform;
|
|
4
|
+
let cmd = "";
|
|
5
|
+
switch (platform) {
|
|
6
|
+
case "win32":
|
|
7
|
+
cmd = `tasklist`;
|
|
8
|
+
break;
|
|
9
|
+
case "darwin":
|
|
10
|
+
cmd = `ps -ax | grep ${query}`;
|
|
11
|
+
break;
|
|
12
|
+
case "linux":
|
|
13
|
+
cmd = `ps -A`;
|
|
14
|
+
break;
|
|
15
|
+
default:
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
exec(cmd, (err, stdout, stderr) => {
|
|
19
|
+
cb(stdout.toLowerCase().indexOf(query.toLowerCase()) > -1);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dateFormat(fmt: string, date: Date): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function dateFormat(fmt, date) {
|
|
2
|
+
let ret;
|
|
3
|
+
const opt = {
|
|
4
|
+
"Y+": date.getFullYear().toString(),
|
|
5
|
+
"m+": (date.getMonth() + 1).toString(),
|
|
6
|
+
"d+": date.getDate().toString(),
|
|
7
|
+
"H+": date.getHours().toString(),
|
|
8
|
+
"M+": date.getMinutes().toString(),
|
|
9
|
+
"S+": date.getSeconds().toString(),
|
|
10
|
+
};
|
|
11
|
+
for (const k in opt) {
|
|
12
|
+
ret = new RegExp("(" + k + ")").exec(fmt);
|
|
13
|
+
if (ret) {
|
|
14
|
+
fmt = fmt.replace(ret[1], ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0"));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return fmt;
|
|
18
|
+
}
|
|
File without changes
|
package/docs/index.md
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zotero-plugin-scaffold",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "A scaffold for Zotero plugin development.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"zotero-plugin": "bin/zotero-plugin.mjs"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"zotero",
|
|
12
|
+
"plugin",
|
|
13
|
+
"developer",
|
|
14
|
+
"scaffold",
|
|
15
|
+
"web-ext"
|
|
16
|
+
],
|
|
17
|
+
"author": "northword",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/northword/zotero-plugin-scaffold.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/northword/zotero-plugin-scaffold/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/northword/zotero-plugin-scaffold#readme",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"registry": "https://registry.npmjs.org"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"bin/**/*",
|
|
33
|
+
"dist/**/*.d.ts",
|
|
34
|
+
"dist/**/*.js",
|
|
35
|
+
"docs/**/*",
|
|
36
|
+
"types/**/*.d.ts"
|
|
37
|
+
],
|
|
38
|
+
"directories": {
|
|
39
|
+
"lib": "dist",
|
|
40
|
+
"doc": "docs"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
},
|
|
45
|
+
"packageManager": "pnpm@8.14.0",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@inquirer/prompts": "^3.3.2",
|
|
48
|
+
"@octokit/rest": "^20.0.2",
|
|
49
|
+
"bumpp": "^9.3.0",
|
|
50
|
+
"chalk": "^5.3.0",
|
|
51
|
+
"chokidar": "^3.5.3",
|
|
52
|
+
"ci-info": "^4.0.0",
|
|
53
|
+
"commander": "^11.1.0",
|
|
54
|
+
"compressing": "^1.10.0",
|
|
55
|
+
"cosmiconfig": "^9.0.0",
|
|
56
|
+
"dotenv": "^16.4.1",
|
|
57
|
+
"esbuild": "^0.19.12",
|
|
58
|
+
"fast-glob": "^3.3.2",
|
|
59
|
+
"fs-extra": "^11.2.0",
|
|
60
|
+
"lodash": "^4.17.21",
|
|
61
|
+
"mime": "^4.0.1",
|
|
62
|
+
"ora": "^8.0.1",
|
|
63
|
+
"release-it": "^17.0.3",
|
|
64
|
+
"replace-in-file": "^7.1.0",
|
|
65
|
+
"update-notifier": "^7.0.0",
|
|
66
|
+
"web-ext": "^7.11.0"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
70
|
+
"@types/fs-extra": "^11.0.4",
|
|
71
|
+
"@types/lodash": "^4.14.202",
|
|
72
|
+
"@types/node": "^20.11.9",
|
|
73
|
+
"@types/update-notifier": "^6.0.8",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
|
75
|
+
"@typescript-eslint/parser": "^6.19.1",
|
|
76
|
+
"eslint": "^8.56.0",
|
|
77
|
+
"eslint-config-prettier": "^9.1.0",
|
|
78
|
+
"prettier": "^3.2.4",
|
|
79
|
+
"typescript": "^5.3.3"
|
|
80
|
+
},
|
|
81
|
+
"release-it": {
|
|
82
|
+
"git": {
|
|
83
|
+
"commitMessage": "chore(publish): release v${version}",
|
|
84
|
+
"tagName": "v${version}"
|
|
85
|
+
},
|
|
86
|
+
"npm": {
|
|
87
|
+
"publish": false
|
|
88
|
+
},
|
|
89
|
+
"github": {
|
|
90
|
+
"release": false
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"scripts": {
|
|
94
|
+
"dev": "tsc --watch",
|
|
95
|
+
"build": "tsc",
|
|
96
|
+
"lint": "eslint --max-warnings=0 . && prettier --check .",
|
|
97
|
+
"lint:fix": "eslint --fix . && prettier --write .",
|
|
98
|
+
"release": "release-it --only-version --preReleaseId=beta",
|
|
99
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
declare module "release-it" {
|
|
2
|
+
export default function runTasks(
|
|
3
|
+
opts: ReleaseItConfig,
|
|
4
|
+
di?: any,
|
|
5
|
+
): Promise<ReleaseItRunTaskResult>;
|
|
6
|
+
export const Config: any;
|
|
7
|
+
export const Plugin: any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ReleaseItRunTaskResult {
|
|
11
|
+
name: string;
|
|
12
|
+
changelog: any;
|
|
13
|
+
lastestVersion: any;
|
|
14
|
+
version: any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Release it
|
|
19
|
+
* @see https://github.com/release-it/release-it/blob/main/README.md
|
|
20
|
+
*/
|
|
21
|
+
interface ReleaseItConfigBase {
|
|
22
|
+
hooks?: Record<string, string | string[]>;
|
|
23
|
+
git?: {
|
|
24
|
+
changelog?: string;
|
|
25
|
+
requireCleanWorkingDir?: boolean;
|
|
26
|
+
requireBranch?: boolean;
|
|
27
|
+
requireUpstream?: boolean;
|
|
28
|
+
requireCommits?: boolean;
|
|
29
|
+
requireCommitsFail?: boolean;
|
|
30
|
+
commitsPath?: string;
|
|
31
|
+
addUntrackedFiles?: boolean;
|
|
32
|
+
commit?: boolean;
|
|
33
|
+
commitMessage?: string;
|
|
34
|
+
commitArgs?: [];
|
|
35
|
+
tag?: boolean;
|
|
36
|
+
tagExclude?: null;
|
|
37
|
+
tagName?: string;
|
|
38
|
+
tagMatch?: string;
|
|
39
|
+
getLatestTagFromAllRefs?: boolean;
|
|
40
|
+
tagAnnotation?: string;
|
|
41
|
+
tagArgs?: string[];
|
|
42
|
+
push?: boolean;
|
|
43
|
+
pushArgs?: string[];
|
|
44
|
+
pushRepo?: string;
|
|
45
|
+
};
|
|
46
|
+
npm?: {
|
|
47
|
+
publish?: boolean;
|
|
48
|
+
publishPath?: string;
|
|
49
|
+
publishArgs?: string[];
|
|
50
|
+
tag?: null;
|
|
51
|
+
otp?: null;
|
|
52
|
+
ignoreVersion?: boolean;
|
|
53
|
+
allowSameVersion?: boolean;
|
|
54
|
+
versionArgs?: string[];
|
|
55
|
+
skipChecks?: boolean;
|
|
56
|
+
timeout?: number;
|
|
57
|
+
};
|
|
58
|
+
github?: {
|
|
59
|
+
release?: boolean;
|
|
60
|
+
releaseName?: string;
|
|
61
|
+
releaseNotes?: null;
|
|
62
|
+
autoGenerate?: boolean;
|
|
63
|
+
preRelease?: boolean;
|
|
64
|
+
draft?: boolean;
|
|
65
|
+
tokenRef?: string;
|
|
66
|
+
assets?: string[];
|
|
67
|
+
host?: string;
|
|
68
|
+
timeout?: number;
|
|
69
|
+
proxy?: null;
|
|
70
|
+
skipChecks?: false;
|
|
71
|
+
web?: boolean;
|
|
72
|
+
comments?: {
|
|
73
|
+
submit?: boolean;
|
|
74
|
+
issue?: string;
|
|
75
|
+
pr?: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
gitlab?: {
|
|
79
|
+
release?: boolean;
|
|
80
|
+
releaseName?: string;
|
|
81
|
+
releaseNotes?: null;
|
|
82
|
+
milestones?: [];
|
|
83
|
+
tokenRef?: string;
|
|
84
|
+
tokenHeader?: string;
|
|
85
|
+
certificateAuthorityFile?: null;
|
|
86
|
+
assets?: string[];
|
|
87
|
+
origin?: null;
|
|
88
|
+
skipChecks?: boolean;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface ReleaseItConfigConstructor {
|
|
93
|
+
"dry-run"?: boolean;
|
|
94
|
+
"only-version"?: boolean;
|
|
95
|
+
increment?: boolean;
|
|
96
|
+
preReleaseId?: "alpha" | "beta" | "next" | "rc" | string;
|
|
97
|
+
ci?: boolean;
|
|
98
|
+
changelog?: boolean;
|
|
99
|
+
verbose?: boolean | number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
interface ReleaseItConfig
|
|
103
|
+
extends ReleaseItConfigConstructor,
|
|
104
|
+
ReleaseItConfigBase {}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare module "web-ext" {
|
|
2
|
+
export default webext = {
|
|
3
|
+
cmd,
|
|
4
|
+
main,
|
|
5
|
+
};
|
|
6
|
+
export const cmd: {
|
|
7
|
+
build(
|
|
8
|
+
params: {
|
|
9
|
+
sourceDir: string;
|
|
10
|
+
artifactsDir: string;
|
|
11
|
+
/**
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
asNeeded?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
overwriteDest?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @default []
|
|
21
|
+
*/
|
|
22
|
+
ignoreFiles?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* @default '{name}-{version}.zip'
|
|
25
|
+
*/
|
|
26
|
+
filename?: string;
|
|
27
|
+
},
|
|
28
|
+
options?: any,
|
|
29
|
+
): Promise<any>;
|
|
30
|
+
|
|
31
|
+
lint(params: LintParams, options?: any): Promise<any>;
|
|
32
|
+
run(params: any, options?: any): Promise<any>;
|
|
33
|
+
sign(params: any, options?: any): Promise<any>;
|
|
34
|
+
docs(params: any, options?: any): Promise<any>;
|
|
35
|
+
};
|
|
36
|
+
export const main: {
|
|
37
|
+
//
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface LintParams {
|
|
42
|
+
artifactsDir: string;
|
|
43
|
+
boring: string;
|
|
44
|
+
firefoxPreview?: any[];
|
|
45
|
+
ignoreFiles: any;
|
|
46
|
+
metadata: any;
|
|
47
|
+
output: any;
|
|
48
|
+
pretty: any;
|
|
49
|
+
privileged: any;
|
|
50
|
+
sourceDir: any;
|
|
51
|
+
selfHosted: any;
|
|
52
|
+
verbose: any;
|
|
53
|
+
warningsAsErrors: any;
|
|
54
|
+
}
|