picgo 1.4.26 → 1.5.0-alpha.2
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/.eslintignore +2 -0
- package/.github/workflows/alpha.yml +22 -0
- package/CHANGELOG.md +43 -0
- package/README.md +14 -1
- package/bin/picgo +1 -1
- package/dist/{src/core → core}/Lifecycle.d.ts +15 -15
- package/dist/{src/core → core}/PicGo.d.ts +44 -44
- package/dist/i18n/en.d.ts +2 -0
- package/dist/i18n/index.d.ts +16 -0
- package/dist/i18n/zh-CN.d.ts +65 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +2 -0
- package/dist/{src/lib → lib}/Commander.d.ts +16 -16
- package/dist/{src/lib → lib}/LifecyclePlugins.d.ts +16 -16
- package/dist/{src/lib → lib}/Logger.d.ts +16 -16
- package/dist/{src/lib → lib}/PluginHandler.d.ts +10 -10
- package/dist/{src/lib → lib}/PluginLoader.d.ts +27 -27
- package/dist/{src/lib → lib}/Request.d.ts +11 -11
- package/dist/{src/plugins → plugins}/commander/config.d.ts +3 -3
- package/dist/plugins/commander/i18n.d.ts +3 -0
- package/dist/{src/plugins → plugins}/commander/index.d.ts +3 -3
- package/dist/{src/plugins → plugins}/commander/init.d.ts +3 -3
- package/dist/{src/plugins → plugins}/commander/pluginHandler.d.ts +3 -3
- package/dist/{src/plugins → plugins}/commander/proxy.d.ts +3 -3
- package/dist/{src/plugins → plugins}/commander/setting.d.ts +5 -5
- package/dist/{src/plugins → plugins}/commander/upload.d.ts +3 -3
- package/dist/{src/plugins → plugins}/commander/use.d.ts +3 -3
- package/dist/{src/plugins → plugins}/transformer/base64.d.ts +5 -5
- package/dist/{src/plugins → plugins}/transformer/index.d.ts +3 -3
- package/dist/{src/plugins → plugins}/transformer/path.d.ts +5 -5
- package/dist/plugins/uploader/aliyun.d.ts +2 -0
- package/dist/plugins/uploader/github.d.ts +2 -0
- package/dist/plugins/uploader/imgur.d.ts +2 -0
- package/dist/{src/plugins → plugins}/uploader/index.d.ts +3 -3
- package/dist/plugins/uploader/qiniu.d.ts +2 -0
- package/dist/plugins/uploader/smms.d.ts +2 -0
- package/dist/plugins/uploader/tcyun.d.ts +8 -0
- package/dist/plugins/uploader/upyun.d.ts +2 -0
- package/dist/types/index.d.ts +468 -0
- package/dist/{src/utils → utils}/common.d.ts +102 -101
- package/dist/{src/utils → utils}/createContext.d.ts +6 -6
- package/dist/{src/utils → utils}/db.d.ts +15 -15
- package/dist/{src/utils → utils}/enum.d.ts +27 -27
- package/dist/{src/utils → utils}/eventBus.d.ts +4 -4
- package/dist/{src/utils → utils}/getClipboardImage.d.ts +4 -3
- package/dist/{src/utils → utils}/initUtils.d.ts +26 -26
- package/dist/{src/utils → utils}/interfaces.d.ts +203 -203
- package/package.json +27 -22
- package/rollup.config.js +82 -0
- package/dist/package.json +0 -127
- package/dist/src/core/Lifecycle.js +0 -123
- package/dist/src/core/PicGo.js +0 -210
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +0 -6
- package/dist/src/lib/Commander.js +0 -56
- package/dist/src/lib/LifecyclePlugins.js +0 -52
- package/dist/src/lib/Logger.js +0 -82
- package/dist/src/lib/PluginHandler.js +0 -260
- package/dist/src/lib/PluginLoader.js +0 -145
- package/dist/src/lib/Request.js +0 -42
- package/dist/src/plugins/commander/config.js +0 -11
- package/dist/src/plugins/commander/index.js +0 -21
- package/dist/src/plugins/commander/init.js +0 -122
- package/dist/src/plugins/commander/pluginHandler.js +0 -43
- package/dist/src/plugins/commander/proxy.js +0 -14
- package/dist/src/plugins/commander/setting.js +0 -102
- package/dist/src/plugins/commander/upload.js +0 -35
- package/dist/src/plugins/commander/use.js +0 -87
- package/dist/src/plugins/transformer/base64.js +0 -9
- package/dist/src/plugins/transformer/index.js +0 -16
- package/dist/src/plugins/transformer/path.js +0 -42
- package/dist/src/plugins/uploader/aliyun.d.ts +0 -7
- package/dist/src/plugins/uploader/aliyun.js +0 -129
- package/dist/src/plugins/uploader/github.d.ts +0 -7
- package/dist/src/plugins/uploader/github.js +0 -101
- package/dist/src/plugins/uploader/imgur.d.ts +0 -7
- package/dist/src/plugins/uploader/imgur.js +0 -81
- package/dist/src/plugins/uploader/index.js +0 -26
- package/dist/src/plugins/uploader/qiniu.d.ts +0 -7
- package/dist/src/plugins/uploader/qiniu.js +0 -132
- package/dist/src/plugins/uploader/smms.d.ts +0 -7
- package/dist/src/plugins/uploader/smms.js +0 -74
- package/dist/src/plugins/uploader/tcyun.d.ts +0 -13
- package/dist/src/plugins/uploader/tcyun.js +0 -218
- package/dist/src/plugins/uploader/upyun.d.ts +0 -7
- package/dist/src/plugins/uploader/upyun.js +0 -128
- package/dist/src/types/index.d.ts +0 -471
- package/dist/src/utils/clipboard/linux.sh +0 -18
- package/dist/src/utils/clipboard/mac.applescript +0 -0
- package/dist/src/utils/clipboard/windows.ps1 +0 -26
- package/dist/src/utils/clipboard/windows10.ps1 +0 -47
- package/dist/src/utils/clipboard/wsl.sh +0 -18
- package/dist/src/utils/common.js +0 -353
- package/dist/src/utils/createContext.js +0 -45
- package/dist/src/utils/db.js +0 -85
- package/dist/src/utils/enum.js +0 -33
- package/dist/src/utils/eventBus.js +0 -6
- package/dist/src/utils/getClipboardImage.js +0 -101
- package/dist/src/utils/initUtils.js +0 -120
- package/dist/src/utils/interfaces.js +0 -3
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "picgo",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-alpha.2",
|
|
4
4
|
"description": "A tool for picture uploading",
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"typings": "dist/index.d.ts",
|
|
7
8
|
"bin": {
|
|
8
9
|
"picgo": "./bin/picgo"
|
|
9
10
|
},
|
|
@@ -14,15 +15,13 @@
|
|
|
14
15
|
"start": "node ./bin/picgo",
|
|
15
16
|
"lint": "eslint src/**/*.ts && npm run build",
|
|
16
17
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
17
|
-
"build": "
|
|
18
|
-
"
|
|
19
|
-
"dev": "tsc -w -p .",
|
|
18
|
+
"build": "rimraf ./dist && rollup -c rollup.config.js",
|
|
19
|
+
"dev": "rollup -c rollup.config.js -w",
|
|
20
20
|
"patch": "npm version patch && git push origin master && git push origin --tags",
|
|
21
21
|
"minor": "npm version minor && git push origin master && git push origin --tags",
|
|
22
22
|
"major": "npm version major && git push origin master && git push origin --tags",
|
|
23
23
|
"cz": "git-cz",
|
|
24
|
-
"release": "bump-version"
|
|
25
|
-
"debug": "tsc -p . --sourcemap && npm run copy"
|
|
24
|
+
"release": "bump-version"
|
|
26
25
|
},
|
|
27
26
|
"keywords": [
|
|
28
27
|
"picture",
|
|
@@ -51,14 +50,17 @@
|
|
|
51
50
|
"author": "Molunerfinn",
|
|
52
51
|
"license": "MIT",
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
53
|
+
"@picgo/bump-version": "^1.1.2",
|
|
54
|
+
"@rollup/plugin-commonjs": "^21.0.0",
|
|
55
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
56
|
+
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
57
|
+
"@rollup/plugin-replace": "^3.0.0",
|
|
56
58
|
"@types/cross-spawn": "^6.0.0",
|
|
57
59
|
"@types/ejs": "^3.0.5",
|
|
58
60
|
"@types/fs-extra": "^5.0.4",
|
|
59
|
-
"@types/globby": "^9.1.0",
|
|
60
61
|
"@types/image-size": "^0.0.29",
|
|
61
62
|
"@types/inquirer": "^0.0.42",
|
|
63
|
+
"@types/lodash": "^4.14.175",
|
|
62
64
|
"@types/lowdb": "^1.0.4",
|
|
63
65
|
"@types/md5": "^2.1.32",
|
|
64
66
|
"@types/mime-types": "^2.1.0",
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
"@typescript-eslint/eslint-plugin": "3",
|
|
71
73
|
"@typescript-eslint/parser": "^3.2.0",
|
|
72
74
|
"babel-eslint": "^10.1.0",
|
|
73
|
-
"
|
|
75
|
+
"builtins": "^4.0.0",
|
|
74
76
|
"conventional-changelog": "^3.0.6",
|
|
75
77
|
"copyfiles": "^2.1.0",
|
|
76
78
|
"cz-customizable": "^5.10.0",
|
|
@@ -80,34 +82,41 @@
|
|
|
80
82
|
"eslint-plugin-node": "11",
|
|
81
83
|
"eslint-plugin-promise": "4",
|
|
82
84
|
"eslint-plugin-standard": "4",
|
|
85
|
+
"execa": "^5.1.1",
|
|
83
86
|
"husky": "^1.3.1",
|
|
84
87
|
"pre-commit": "^1.2.2",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
+
"rollup": "^2.58.0",
|
|
89
|
+
"rollup-plugin-string": "^3.0.0",
|
|
90
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
91
|
+
"rollup-plugin-typescript2": "^0.30.0",
|
|
92
|
+
"typescript": "^4.4.3"
|
|
88
93
|
},
|
|
89
94
|
"dependencies": {
|
|
95
|
+
"@picgo/i18n": "^1.0.0",
|
|
90
96
|
"chalk": "^2.4.1",
|
|
91
97
|
"commander": "^8.1.0",
|
|
92
98
|
"comment-json": "^2.3.1",
|
|
93
99
|
"cross-spawn": "^6.0.5",
|
|
94
100
|
"dayjs": "^1.7.4",
|
|
95
|
-
"download-git-repo": "^
|
|
101
|
+
"download-git-repo": "^3.0.2",
|
|
96
102
|
"ejs": "^2.6.1",
|
|
97
103
|
"fs-extra": "^6.0.1",
|
|
98
|
-
"globby": "^
|
|
104
|
+
"globby": "^11.0.4",
|
|
99
105
|
"image-size": "^0.8.3",
|
|
100
106
|
"inquirer": "^6.0.0",
|
|
101
107
|
"is-wsl": "^2.2.0",
|
|
108
|
+
"lodash": "^4.17.21",
|
|
102
109
|
"lodash-id": "^0.14.0",
|
|
103
110
|
"lowdb": "^1.0.0",
|
|
104
111
|
"md5": "^2.2.1",
|
|
112
|
+
"mime-types": "2.1.33",
|
|
105
113
|
"minimatch": "^3.0.4",
|
|
114
|
+
"minimist": "^1.2.5",
|
|
106
115
|
"qiniu": "^7.2.1",
|
|
107
116
|
"request": "^2.87.0",
|
|
108
117
|
"request-promise-native": "^1.0.5",
|
|
109
118
|
"resolve": "^1.8.1",
|
|
110
|
-
"rimraf": "^
|
|
119
|
+
"rimraf": "^3.0.2"
|
|
111
120
|
},
|
|
112
121
|
"repository": {
|
|
113
122
|
"type": "git",
|
|
@@ -117,10 +126,6 @@
|
|
|
117
126
|
"current": "smms"
|
|
118
127
|
},
|
|
119
128
|
"plugins": {},
|
|
120
|
-
"resolutions": {
|
|
121
|
-
"**/**/lodash": "^4.17.12",
|
|
122
|
-
"**/**/minimist": ">0.2.1"
|
|
123
|
-
},
|
|
124
129
|
"engines": {
|
|
125
130
|
"node": ">= 12.0.0"
|
|
126
131
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { terser } from 'rollup-plugin-terser'
|
|
2
|
+
import pkg from './package.json'
|
|
3
|
+
import typescript from 'rollup-plugin-typescript2'
|
|
4
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
5
|
+
import { string } from 'rollup-plugin-string'
|
|
6
|
+
import json from '@rollup/plugin-json'
|
|
7
|
+
import builtins from 'builtins'
|
|
8
|
+
import replace from '@rollup/plugin-replace'
|
|
9
|
+
|
|
10
|
+
const version = process.env.VERSION || pkg.version
|
|
11
|
+
const sourcemap = 'inline'
|
|
12
|
+
const banner = `/*
|
|
13
|
+
* picgo@${version}, https://github.com/PicGo/PicGo-Core
|
|
14
|
+
* (c) 2018-${new Date().getFullYear()} PicGo Group
|
|
15
|
+
* Released under the MIT License.
|
|
16
|
+
*/`
|
|
17
|
+
const input = './src/index.ts'
|
|
18
|
+
|
|
19
|
+
const commonOptions = {
|
|
20
|
+
// Creating regex of the packages to make sure sub-paths of the
|
|
21
|
+
// packages such as `lowdb/adapters/FileSync` are also treated as external
|
|
22
|
+
// See https://github.com/rollup/rollup/issues/3684#issuecomment-926558056
|
|
23
|
+
external: [
|
|
24
|
+
...Object.keys(pkg.dependencies),
|
|
25
|
+
...builtins()
|
|
26
|
+
].map(packageName => new RegExp(`^${packageName}(/.*)?`)),
|
|
27
|
+
plugins: [
|
|
28
|
+
typescript({
|
|
29
|
+
tsconfigOverride: {
|
|
30
|
+
compilerOptions: {
|
|
31
|
+
target: 'ES2017',
|
|
32
|
+
module: 'ES2015'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
terser(),
|
|
37
|
+
commonjs(),
|
|
38
|
+
string({
|
|
39
|
+
// Required to be specified
|
|
40
|
+
include: [
|
|
41
|
+
'**/*.applescript',
|
|
42
|
+
'**/*.ps1',
|
|
43
|
+
'**/*.sh'
|
|
44
|
+
]
|
|
45
|
+
}),
|
|
46
|
+
json(),
|
|
47
|
+
replace({
|
|
48
|
+
'process.env.PICGO_VERSION': JSON.stringify(pkg.version),
|
|
49
|
+
preventAssignment: true
|
|
50
|
+
})
|
|
51
|
+
],
|
|
52
|
+
input
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** @type import('rollup').RollupOptions */
|
|
56
|
+
const nodeCjs = {
|
|
57
|
+
output: [{
|
|
58
|
+
file: 'dist/index.cjs.js',
|
|
59
|
+
format: 'cjs',
|
|
60
|
+
banner,
|
|
61
|
+
sourcemap
|
|
62
|
+
}],
|
|
63
|
+
...commonOptions
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const nodeEsm = {
|
|
67
|
+
output: [{
|
|
68
|
+
file: 'dist/index.esm.js',
|
|
69
|
+
format: 'esm',
|
|
70
|
+
banner,
|
|
71
|
+
sourcemap
|
|
72
|
+
}],
|
|
73
|
+
...commonOptions
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const bundles = []
|
|
77
|
+
const env = process.env.BUNDLES || ''
|
|
78
|
+
if (env.includes('cjs')) bundles.push(nodeCjs)
|
|
79
|
+
if (env.includes('esm')) bundles.push(nodeEsm)
|
|
80
|
+
if (bundles.length === 0) bundles.push(nodeCjs, nodeEsm)
|
|
81
|
+
|
|
82
|
+
export default bundles
|
package/dist/package.json
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "picgo",
|
|
3
|
-
"version": "1.4.26",
|
|
4
|
-
"description": "A tool for picture uploading",
|
|
5
|
-
"main": "dist/src/index.js",
|
|
6
|
-
"typings": "dist/src/index.d.ts",
|
|
7
|
-
"bin": {
|
|
8
|
-
"picgo": "./bin/picgo"
|
|
9
|
-
},
|
|
10
|
-
"publishConfig": {
|
|
11
|
-
"access": "public"
|
|
12
|
-
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"start": "node ./bin/picgo",
|
|
15
|
-
"lint": "eslint src/**/*.ts && npm run build",
|
|
16
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
17
|
-
"build": "tsc -p . && npm run copy",
|
|
18
|
-
"copy": "copyfiles -f src/utils/clipboard/* dist/src/utils/clipboard && copyfiles -f src/types/* dist/src/types",
|
|
19
|
-
"dev": "tsc -w -p .",
|
|
20
|
-
"patch": "npm version patch && git push origin master && git push origin --tags",
|
|
21
|
-
"minor": "npm version minor && git push origin master && git push origin --tags",
|
|
22
|
-
"major": "npm version major && git push origin master && git push origin --tags",
|
|
23
|
-
"cz": "git-cz",
|
|
24
|
-
"release": "bump-version",
|
|
25
|
-
"debug": "tsc -p . --sourcemap && npm run copy"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"picture",
|
|
29
|
-
"upload",
|
|
30
|
-
"util"
|
|
31
|
-
],
|
|
32
|
-
"husky": {
|
|
33
|
-
"hooks": {
|
|
34
|
-
"pre-commit": "npm run lint",
|
|
35
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"config": {
|
|
39
|
-
"commitizen": {
|
|
40
|
-
"path": "./node_modules/cz-customizable"
|
|
41
|
-
},
|
|
42
|
-
"cz-customizable": {
|
|
43
|
-
"config": "./node_modules/@picgo/bump-version/.cz-config.js"
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
"commitlint": {
|
|
47
|
-
"extends": [
|
|
48
|
-
"./node_modules/@picgo/bump-version/commitlint-picgo"
|
|
49
|
-
]
|
|
50
|
-
},
|
|
51
|
-
"author": "Molunerfinn",
|
|
52
|
-
"license": "MIT",
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"@commitlint/cli": "^7.5.2",
|
|
55
|
-
"@picgo/bump-version": "^1.0.1",
|
|
56
|
-
"@types/cross-spawn": "^6.0.0",
|
|
57
|
-
"@types/ejs": "^3.0.5",
|
|
58
|
-
"@types/fs-extra": "^5.0.4",
|
|
59
|
-
"@types/globby": "^9.1.0",
|
|
60
|
-
"@types/image-size": "^0.0.29",
|
|
61
|
-
"@types/inquirer": "^0.0.42",
|
|
62
|
-
"@types/lowdb": "^1.0.4",
|
|
63
|
-
"@types/md5": "^2.1.32",
|
|
64
|
-
"@types/mime-types": "^2.1.0",
|
|
65
|
-
"@types/minimatch": "^3.0.3",
|
|
66
|
-
"@types/node": "^10.5.2",
|
|
67
|
-
"@types/request-promise-native": "^1.0.15",
|
|
68
|
-
"@types/resolve": "^0.0.8",
|
|
69
|
-
"@types/rimraf": "^3.0.0",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "3",
|
|
71
|
-
"@typescript-eslint/parser": "^3.2.0",
|
|
72
|
-
"babel-eslint": "^10.1.0",
|
|
73
|
-
"commitizen": "^3.0.7",
|
|
74
|
-
"conventional-changelog": "^3.0.6",
|
|
75
|
-
"copyfiles": "^2.1.0",
|
|
76
|
-
"cz-customizable": "^5.10.0",
|
|
77
|
-
"eslint": "7",
|
|
78
|
-
"eslint-config-standard-with-typescript": "^18.0.2",
|
|
79
|
-
"eslint-plugin-import": "2",
|
|
80
|
-
"eslint-plugin-node": "11",
|
|
81
|
-
"eslint-plugin-promise": "4",
|
|
82
|
-
"eslint-plugin-standard": "4",
|
|
83
|
-
"husky": "^1.3.1",
|
|
84
|
-
"pre-commit": "^1.2.2",
|
|
85
|
-
"tslint": "^5.10.0",
|
|
86
|
-
"tslint-config-standard": "^8.0.1",
|
|
87
|
-
"typescript": "^3.9.5"
|
|
88
|
-
},
|
|
89
|
-
"dependencies": {
|
|
90
|
-
"chalk": "^2.4.1",
|
|
91
|
-
"commander": "^8.1.0",
|
|
92
|
-
"comment-json": "^2.3.1",
|
|
93
|
-
"cross-spawn": "^6.0.5",
|
|
94
|
-
"dayjs": "^1.7.4",
|
|
95
|
-
"download-git-repo": "^1.1.0",
|
|
96
|
-
"ejs": "^2.6.1",
|
|
97
|
-
"fs-extra": "^6.0.1",
|
|
98
|
-
"globby": "^8.0.2",
|
|
99
|
-
"image-size": "^0.8.3",
|
|
100
|
-
"inquirer": "^6.0.0",
|
|
101
|
-
"is-wsl": "^2.2.0",
|
|
102
|
-
"lodash-id": "^0.14.0",
|
|
103
|
-
"lowdb": "^1.0.0",
|
|
104
|
-
"md5": "^2.2.1",
|
|
105
|
-
"minimatch": "^3.0.4",
|
|
106
|
-
"qiniu": "^7.2.1",
|
|
107
|
-
"request": "^2.87.0",
|
|
108
|
-
"request-promise-native": "^1.0.5",
|
|
109
|
-
"resolve": "^1.8.1",
|
|
110
|
-
"rimraf": "^2.6.3"
|
|
111
|
-
},
|
|
112
|
-
"repository": {
|
|
113
|
-
"type": "git",
|
|
114
|
-
"url": "git+https://github.com/PicGo/PicGo-Core.git"
|
|
115
|
-
},
|
|
116
|
-
"picBed": {
|
|
117
|
-
"current": "smms"
|
|
118
|
-
},
|
|
119
|
-
"plugins": {},
|
|
120
|
-
"resolutions": {
|
|
121
|
-
"**/**/lodash": "^4.17.12",
|
|
122
|
-
"**/**/minimist": ">0.2.1"
|
|
123
|
-
},
|
|
124
|
-
"engines": {
|
|
125
|
-
"node": ">= 12.0.0"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const events_1 = require("events");
|
|
4
|
-
const common_1 = require("../utils/common");
|
|
5
|
-
const enum_1 = require("../utils/enum");
|
|
6
|
-
const createContext_1 = require("../utils/createContext");
|
|
7
|
-
class Lifecycle extends events_1.EventEmitter {
|
|
8
|
-
constructor(ctx) {
|
|
9
|
-
super();
|
|
10
|
-
this.ctx = ctx;
|
|
11
|
-
}
|
|
12
|
-
async start(input) {
|
|
13
|
-
// ensure every upload process has an unique context
|
|
14
|
-
const ctx = createContext_1.createContext(this.ctx);
|
|
15
|
-
try {
|
|
16
|
-
// images input
|
|
17
|
-
if (!Array.isArray(input)) {
|
|
18
|
-
throw new Error('Input must be an array.');
|
|
19
|
-
}
|
|
20
|
-
ctx.input = input;
|
|
21
|
-
ctx.output = [];
|
|
22
|
-
// lifecycle main
|
|
23
|
-
await this.beforeTransform(ctx);
|
|
24
|
-
await this.doTransform(ctx);
|
|
25
|
-
await this.beforeUpload(ctx);
|
|
26
|
-
await this.doUpload(ctx);
|
|
27
|
-
await this.afterUpload(ctx);
|
|
28
|
-
return ctx;
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
ctx.log.warn(enum_1.IBuildInEvent.FAILED);
|
|
32
|
-
ctx.emit(enum_1.IBuildInEvent.UPLOAD_PROGRESS, -1);
|
|
33
|
-
ctx.emit(enum_1.IBuildInEvent.FAILED, e);
|
|
34
|
-
ctx.log.error(e);
|
|
35
|
-
if (ctx.getConfig('debug')) {
|
|
36
|
-
throw e;
|
|
37
|
-
}
|
|
38
|
-
return ctx;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async beforeTransform(ctx) {
|
|
42
|
-
ctx.emit(enum_1.IBuildInEvent.UPLOAD_PROGRESS, 0);
|
|
43
|
-
ctx.emit(enum_1.IBuildInEvent.BEFORE_TRANSFORM, ctx);
|
|
44
|
-
ctx.log.info('Before transform');
|
|
45
|
-
await this.handlePlugins(ctx.helper.beforeTransformPlugins, ctx);
|
|
46
|
-
return ctx;
|
|
47
|
-
}
|
|
48
|
-
async doTransform(ctx) {
|
|
49
|
-
ctx.emit(enum_1.IBuildInEvent.UPLOAD_PROGRESS, 30);
|
|
50
|
-
const type = ctx.getConfig('picBed.transformer') || 'path';
|
|
51
|
-
let currentTransformer = type;
|
|
52
|
-
let transformer = ctx.helper.transformer.get(type);
|
|
53
|
-
if (!transformer) {
|
|
54
|
-
transformer = ctx.helper.transformer.get('path');
|
|
55
|
-
currentTransformer = 'path';
|
|
56
|
-
ctx.log.warn(`Can't find transformer - ${type}, switch to default transformer - path`);
|
|
57
|
-
}
|
|
58
|
-
ctx.log.info(`Transforming... Current transformer is [${currentTransformer}]`);
|
|
59
|
-
await (transformer === null || transformer === void 0 ? void 0 : transformer.handle(ctx));
|
|
60
|
-
return ctx;
|
|
61
|
-
}
|
|
62
|
-
async beforeUpload(ctx) {
|
|
63
|
-
ctx.emit(enum_1.IBuildInEvent.UPLOAD_PROGRESS, 60);
|
|
64
|
-
ctx.log.info('Before upload');
|
|
65
|
-
ctx.emit(enum_1.IBuildInEvent.BEFORE_UPLOAD, ctx);
|
|
66
|
-
await this.handlePlugins(ctx.helper.beforeUploadPlugins, ctx);
|
|
67
|
-
return ctx;
|
|
68
|
-
}
|
|
69
|
-
async doUpload(ctx) {
|
|
70
|
-
let type = ctx.getConfig('picBed.uploader') || ctx.getConfig('picBed.current') || 'smms';
|
|
71
|
-
let uploader = ctx.helper.uploader.get(type);
|
|
72
|
-
let currentTransformer = type;
|
|
73
|
-
if (!uploader) {
|
|
74
|
-
type = 'smms';
|
|
75
|
-
currentTransformer = 'smms';
|
|
76
|
-
uploader = ctx.helper.uploader.get('smms');
|
|
77
|
-
ctx.log.warn(`Can't find uploader - ${type}, switch to default uploader - smms`);
|
|
78
|
-
}
|
|
79
|
-
ctx.log.info(`Uploading... Current uploader is [${currentTransformer}]`);
|
|
80
|
-
await (uploader === null || uploader === void 0 ? void 0 : uploader.handle(ctx));
|
|
81
|
-
for (const outputImg of ctx.output) {
|
|
82
|
-
outputImg.type = type;
|
|
83
|
-
}
|
|
84
|
-
return ctx;
|
|
85
|
-
}
|
|
86
|
-
async afterUpload(ctx) {
|
|
87
|
-
ctx.emit(enum_1.IBuildInEvent.AFTER_UPLOAD, ctx);
|
|
88
|
-
ctx.emit(enum_1.IBuildInEvent.UPLOAD_PROGRESS, 100);
|
|
89
|
-
await this.handlePlugins(ctx.helper.afterUploadPlugins, ctx);
|
|
90
|
-
let msg = '';
|
|
91
|
-
const length = ctx.output.length;
|
|
92
|
-
for (let i = 0; i < length; i++) {
|
|
93
|
-
if (typeof ctx.output[i].imgUrl !== 'undefined') {
|
|
94
|
-
msg += common_1.handleUrlEncode(ctx.output[i].imgUrl);
|
|
95
|
-
if (i !== length - 1) {
|
|
96
|
-
msg += '\n';
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
delete ctx.output[i].base64Image;
|
|
100
|
-
delete ctx.output[i].buffer;
|
|
101
|
-
}
|
|
102
|
-
ctx.emit(enum_1.IBuildInEvent.FINISHED, ctx);
|
|
103
|
-
ctx.log.success(`\n${msg}`);
|
|
104
|
-
return ctx;
|
|
105
|
-
}
|
|
106
|
-
async handlePlugins(lifeCyclePlugins, ctx) {
|
|
107
|
-
const plugins = lifeCyclePlugins.getList();
|
|
108
|
-
const pluginNames = lifeCyclePlugins.getIdList();
|
|
109
|
-
const lifeCycleName = lifeCyclePlugins.getName();
|
|
110
|
-
await Promise.all(plugins.map(async (plugin, index) => {
|
|
111
|
-
try {
|
|
112
|
-
ctx.log.info(`${lifeCycleName}: ${pluginNames[index]} running`);
|
|
113
|
-
await plugin.handle(ctx);
|
|
114
|
-
}
|
|
115
|
-
catch (e) {
|
|
116
|
-
ctx.log.error(`${lifeCycleName}: ${pluginNames[index]} error`);
|
|
117
|
-
throw e;
|
|
118
|
-
}
|
|
119
|
-
}));
|
|
120
|
-
return ctx;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.default = Lifecycle;
|
package/dist/src/core/PicGo.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
26
|
-
const path_1 = __importDefault(require("path"));
|
|
27
|
-
const events_1 = require("events");
|
|
28
|
-
const os_1 = require("os");
|
|
29
|
-
const Commander_1 = __importDefault(require("../lib/Commander"));
|
|
30
|
-
const Logger_1 = __importDefault(require("../lib/Logger"));
|
|
31
|
-
const Lifecycle_1 = __importDefault(require("./Lifecycle"));
|
|
32
|
-
const LifecyclePlugins_1 = __importStar(require("../lib/LifecyclePlugins"));
|
|
33
|
-
const uploader_1 = __importDefault(require("../plugins/uploader"));
|
|
34
|
-
const transformer_1 = __importDefault(require("../plugins/transformer"));
|
|
35
|
-
const PluginLoader_1 = __importDefault(require("../lib/PluginLoader"));
|
|
36
|
-
const lodash_1 = require("lodash");
|
|
37
|
-
const getClipboardImage_1 = __importDefault(require("../utils/getClipboardImage"));
|
|
38
|
-
const Request_1 = __importDefault(require("../lib/Request"));
|
|
39
|
-
const db_1 = __importDefault(require("../utils/db"));
|
|
40
|
-
const PluginHandler_1 = __importDefault(require("../lib/PluginHandler"));
|
|
41
|
-
const enum_1 = require("../utils/enum");
|
|
42
|
-
const package_json_1 = require("../../package.json");
|
|
43
|
-
const eventBus_1 = require("../utils/eventBus");
|
|
44
|
-
const common_1 = require("../utils/common");
|
|
45
|
-
class PicGo extends events_1.EventEmitter {
|
|
46
|
-
constructor(configPath = '') {
|
|
47
|
-
super();
|
|
48
|
-
this.VERSION = package_json_1.version;
|
|
49
|
-
this.configPath = configPath;
|
|
50
|
-
this.output = [];
|
|
51
|
-
this.input = [];
|
|
52
|
-
this.helper = {
|
|
53
|
-
transformer: new LifecyclePlugins_1.default('transformer'),
|
|
54
|
-
uploader: new LifecyclePlugins_1.default('uploader'),
|
|
55
|
-
beforeTransformPlugins: new LifecyclePlugins_1.default('beforeTransformPlugins'),
|
|
56
|
-
beforeUploadPlugins: new LifecyclePlugins_1.default('beforeUploadPlugins'),
|
|
57
|
-
afterUploadPlugins: new LifecyclePlugins_1.default('afterUploadPlugins')
|
|
58
|
-
};
|
|
59
|
-
this.initConfigPath();
|
|
60
|
-
this.log = new Logger_1.default(this);
|
|
61
|
-
this.cmd = new Commander_1.default(this);
|
|
62
|
-
this.pluginHandler = new PluginHandler_1.default(this);
|
|
63
|
-
this.initConfig();
|
|
64
|
-
this.init();
|
|
65
|
-
}
|
|
66
|
-
get pluginLoader() {
|
|
67
|
-
return this._pluginLoader;
|
|
68
|
-
}
|
|
69
|
-
initConfigPath() {
|
|
70
|
-
if (this.configPath === '') {
|
|
71
|
-
this.configPath = os_1.homedir() + '/.picgo/config.json';
|
|
72
|
-
}
|
|
73
|
-
if (path_1.default.extname(this.configPath).toUpperCase() !== '.JSON') {
|
|
74
|
-
this.configPath = '';
|
|
75
|
-
throw Error('The configuration file only supports JSON format.');
|
|
76
|
-
}
|
|
77
|
-
this.baseDir = path_1.default.dirname(this.configPath);
|
|
78
|
-
const exist = fs_extra_1.default.pathExistsSync(this.configPath);
|
|
79
|
-
if (!exist) {
|
|
80
|
-
fs_extra_1.default.ensureFileSync(`${this.configPath}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
initConfig() {
|
|
84
|
-
this.db = new db_1.default(this);
|
|
85
|
-
this._config = this.db.read().value();
|
|
86
|
-
}
|
|
87
|
-
init() {
|
|
88
|
-
try {
|
|
89
|
-
this.Request = new Request_1.default(this);
|
|
90
|
-
this._pluginLoader = new PluginLoader_1.default(this);
|
|
91
|
-
// load self plugins
|
|
92
|
-
LifecyclePlugins_1.setCurrentPluginName('picgo');
|
|
93
|
-
uploader_1.default(this).register(this);
|
|
94
|
-
transformer_1.default(this).register(this);
|
|
95
|
-
LifecyclePlugins_1.setCurrentPluginName('');
|
|
96
|
-
// load third-party plugins
|
|
97
|
-
this._pluginLoader.load();
|
|
98
|
-
this.lifecycle = new Lifecycle_1.default(this);
|
|
99
|
-
}
|
|
100
|
-
catch (e) {
|
|
101
|
-
this.emit(enum_1.IBuildInEvent.UPLOAD_PROGRESS, -1);
|
|
102
|
-
this.log.error(e);
|
|
103
|
-
throw e;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
registerCommands() {
|
|
107
|
-
if (this.configPath !== '') {
|
|
108
|
-
this.cmd.init();
|
|
109
|
-
this.cmd.loadCommands();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
getConfig(name) {
|
|
113
|
-
if (!name) {
|
|
114
|
-
console.log(this._config);
|
|
115
|
-
return this._config;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
return lodash_1.get(this._config, name);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
saveConfig(config) {
|
|
122
|
-
if (!common_1.isInputConfigValid(config)) {
|
|
123
|
-
this.log.warn('the format of config is invalid, please provide object');
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
this.setConfig(config);
|
|
127
|
-
this.db.saveConfig(config);
|
|
128
|
-
}
|
|
129
|
-
removeConfig(key, propName) {
|
|
130
|
-
if (!key || !propName)
|
|
131
|
-
return;
|
|
132
|
-
if (common_1.isConfigKeyInBlackList(key)) {
|
|
133
|
-
this.log.warn(`the config.${key} can't be removed`);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
this.unsetConfig(key, propName);
|
|
137
|
-
this.db.unset(key, propName);
|
|
138
|
-
}
|
|
139
|
-
setConfig(config) {
|
|
140
|
-
if (!common_1.isInputConfigValid(config)) {
|
|
141
|
-
this.log.warn('the format of config is invalid, please provide object');
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
Object.keys(config).forEach((name) => {
|
|
145
|
-
if (common_1.isConfigKeyInBlackList(name)) {
|
|
146
|
-
this.log.warn(`the config.${name} can't be modified`);
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
148
|
-
delete config[name];
|
|
149
|
-
}
|
|
150
|
-
lodash_1.set(this._config, name, config[name]);
|
|
151
|
-
eventBus_1.eventBus.emit(enum_1.IBusEvent.CONFIG_CHANGE, {
|
|
152
|
-
configName: name,
|
|
153
|
-
value: config[name]
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
unsetConfig(key, propName) {
|
|
158
|
-
if (!key || !propName)
|
|
159
|
-
return;
|
|
160
|
-
if (common_1.isConfigKeyInBlackList(key)) {
|
|
161
|
-
this.log.warn(`the config.${key} can't be unset`);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
lodash_1.unset(this.getConfig(key), propName);
|
|
165
|
-
}
|
|
166
|
-
get request() {
|
|
167
|
-
// TODO: replace request with got: https://github.com/sindresorhus/got
|
|
168
|
-
return this.Request.request;
|
|
169
|
-
}
|
|
170
|
-
async upload(input) {
|
|
171
|
-
if (this.configPath === '') {
|
|
172
|
-
this.log.error('The configuration file only supports JSON format.');
|
|
173
|
-
return [];
|
|
174
|
-
}
|
|
175
|
-
// upload from clipboard
|
|
176
|
-
if (input === undefined || input.length === 0) {
|
|
177
|
-
try {
|
|
178
|
-
const { imgPath, shouldKeepAfterUploading } = await getClipboardImage_1.default(this);
|
|
179
|
-
if (imgPath === 'no image') {
|
|
180
|
-
throw new Error('image not found in clipboard');
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
this.once(enum_1.IBuildInEvent.FAILED, () => {
|
|
184
|
-
if (!shouldKeepAfterUploading) {
|
|
185
|
-
// 删除 picgo 生成的图片文件,例如 `~/.picgo/20200621205720.png`
|
|
186
|
-
fs_extra_1.default.remove(imgPath).catch((e) => { this.log.error(e); });
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
this.once('finished', () => {
|
|
190
|
-
if (!shouldKeepAfterUploading) {
|
|
191
|
-
fs_extra_1.default.remove(imgPath).catch((e) => { this.log.error(e); });
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
const { output } = await this.lifecycle.start([imgPath]);
|
|
195
|
-
return output;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
catch (e) {
|
|
199
|
-
this.emit(enum_1.IBuildInEvent.FAILED, e);
|
|
200
|
-
throw e;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
// upload from path
|
|
205
|
-
const { output } = await this.lifecycle.start(input);
|
|
206
|
-
return output;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
exports.default = PicGo;
|
package/dist/src/index.d.ts
DELETED
package/dist/src/index.js
DELETED