piclist 0.0.1
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/.eslintrc.js +25 -0
- package/.github/workflows/alpha.yml +22 -0
- package/.github/workflows/main.yml +22 -0
- package/.github/workflows/manually.yml +19 -0
- package/CHANGELOG.md +549 -0
- package/License +21 -0
- package/README.md +116 -0
- package/bin/picgo +22 -0
- package/dist/core/Lifecycle.d.ts +15 -0
- package/dist/core/PicGo.d.ts +49 -0
- package/dist/i18n/en.d.ts +2 -0
- package/dist/i18n/index.d.ts +18 -0
- package/dist/i18n/zh-CN.d.ts +91 -0
- package/dist/i18n/zh-TW.d.ts +2 -0
- package/dist/index.cjs.js +3807 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +3769 -0
- package/dist/lib/Commander.d.ts +22 -0
- package/dist/lib/LifecyclePlugins.d.ts +17 -0
- package/dist/lib/Logger.d.ts +19 -0
- package/dist/lib/PluginHandler.d.ts +10 -0
- package/dist/lib/PluginLoader.d.ts +27 -0
- package/dist/lib/Request.d.ts +12 -0
- package/dist/plugins/commander/config.d.ts +3 -0
- package/dist/plugins/commander/i18n.d.ts +3 -0
- package/dist/plugins/commander/index.d.ts +3 -0
- package/dist/plugins/commander/init.d.ts +3 -0
- package/dist/plugins/commander/pluginHandler.d.ts +3 -0
- package/dist/plugins/commander/proxy.d.ts +3 -0
- package/dist/plugins/commander/setting.d.ts +5 -0
- package/dist/plugins/commander/upload.d.ts +3 -0
- package/dist/plugins/commander/use.d.ts +3 -0
- package/dist/plugins/transformer/base64.d.ts +5 -0
- package/dist/plugins/transformer/index.d.ts +3 -0
- package/dist/plugins/transformer/path.d.ts +5 -0
- 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/plugins/uploader/index.d.ts +3 -0
- 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 +537 -0
- package/dist/types/oldRequest.d.ts +19 -0
- package/dist/utils/common.d.ts +106 -0
- package/dist/utils/createContext.d.ts +6 -0
- package/dist/utils/db.d.ts +15 -0
- package/dist/utils/enum.d.ts +27 -0
- package/dist/utils/eventBus.d.ts +4 -0
- package/dist/utils/getClipboardImage.d.ts +4 -0
- package/dist/utils/initUtils.d.ts +26 -0
- package/dist/utils/interfaces.d.ts +203 -0
- package/dist/utils/static.d.ts +1 -0
- package/logo.png +0 -0
- package/package.json +133 -0
- package/rollup.config.js +87 -0
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# PicList-Core
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://actions-badge.atrox.dev/picgo/picgo-core/goto?ref=master)
|
|
6
|
+

|
|
7
|
+
[](https://github.com/PicGo/bump-version)
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
A tool for picture uploading. Both CLI & api supports. It also supports plugin system, please check [Awesome-PicGo](https://github.com/PicGo/Awesome-PicGo) to find powerful plugins.
|
|
13
|
+
|
|
14
|
+
**Typora supports PicGo-Core natively**. If you like PicGo-Core and have time, welcome to help me translate the documentation of PicGo-Core into English.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
PicList should be installed with node.js >= 12 (v1.5.0-alpha.4 and small) & node.js >= 16 (since v1.5.0-alpha.5).
|
|
19
|
+
|
|
20
|
+
### Global install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install piclist -g
|
|
24
|
+
|
|
25
|
+
# or
|
|
26
|
+
|
|
27
|
+
yarn global add piclist
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Local install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install piclist -D
|
|
34
|
+
|
|
35
|
+
# or
|
|
36
|
+
|
|
37
|
+
yarn add piclist -D
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
### Use in CLI
|
|
43
|
+
|
|
44
|
+
> PicGo uses `SM.MS` as the default upload pic-bed.
|
|
45
|
+
|
|
46
|
+
Show help:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
$ picgo -h
|
|
50
|
+
|
|
51
|
+
Usage: picgo [options] [command]
|
|
52
|
+
|
|
53
|
+
Options:
|
|
54
|
+
|
|
55
|
+
-v, --version output the version number
|
|
56
|
+
-d, --debug debug mode
|
|
57
|
+
-s, --silent silent mode
|
|
58
|
+
-c, --config <path> set config path
|
|
59
|
+
-h, --help output usage information
|
|
60
|
+
|
|
61
|
+
Commands:
|
|
62
|
+
|
|
63
|
+
install|add <plugins...> install picgo plugin
|
|
64
|
+
uninstall|rm <plugins...> uninstall picgo plugin
|
|
65
|
+
update <plugins...> update picgo plugin
|
|
66
|
+
set|config <module> [name] configure config of picgo modules
|
|
67
|
+
upload|u [input...] upload, go go go
|
|
68
|
+
use [module] use modules of picgo
|
|
69
|
+
init [options] <template> [project] create picgo plugin\'s development templates
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Upload a picture from path
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
picgo upload /xxx/xx/xx.jpg
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### Upload a picture from clipboard
|
|
79
|
+
|
|
80
|
+
> picture from clipboard will be converted to `png`
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
picgo upload
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Thanks to [vs-picgo](https://github.com/Spades-S/vs-picgo) && [Spades-S](https://github.com/Spades-S) for providing the method to upload picture from clipboard.
|
|
87
|
+
|
|
88
|
+
### Use in node project
|
|
89
|
+
|
|
90
|
+
#### Common JS
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
const { PicGo } = require('picgo')
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### ES Module
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
import { PicGo } from 'picgo'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### API usage example
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
const picgo = new PicGo()
|
|
106
|
+
|
|
107
|
+
// upload a picture from path
|
|
108
|
+
picgo.upload(['/xxx/xxx.jpg'])
|
|
109
|
+
|
|
110
|
+
// upload a picture from clipboard
|
|
111
|
+
picgo.upload()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Documentation
|
|
115
|
+
|
|
116
|
+
For more details, you can checkout [documentation](https://picgo.github.io/PicGo-Core-Doc/).
|
package/bin/picgo
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const minimist = require('minimist')
|
|
4
|
+
const argv = minimist(process.argv.slice(2))
|
|
5
|
+
let configPath = argv.c || argv.config || ''
|
|
6
|
+
if (configPath !== true && configPath !== '') {
|
|
7
|
+
configPath = path.resolve(configPath)
|
|
8
|
+
} else {
|
|
9
|
+
configPath = ''
|
|
10
|
+
}
|
|
11
|
+
const { PicGo } = require('..')
|
|
12
|
+
const picgo = new PicGo(configPath)
|
|
13
|
+
picgo.registerCommands()
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
picgo.cmd.program.parse(process.argv)
|
|
17
|
+
} catch (e) {
|
|
18
|
+
picgo.log.error(e)
|
|
19
|
+
if (process.argv.includes('--debug')) {
|
|
20
|
+
Promise.reject(e)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { IPicGo } from '../types';
|
|
4
|
+
export declare class Lifecycle extends EventEmitter {
|
|
5
|
+
private readonly ctx;
|
|
6
|
+
constructor(ctx: IPicGo);
|
|
7
|
+
start(input: any[]): Promise<IPicGo>;
|
|
8
|
+
private beforeTransform;
|
|
9
|
+
private doTransform;
|
|
10
|
+
private beforeUpload;
|
|
11
|
+
private doUpload;
|
|
12
|
+
private afterUpload;
|
|
13
|
+
private handlePlugins;
|
|
14
|
+
}
|
|
15
|
+
export default Lifecycle;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import Commander from '../lib/Commander';
|
|
4
|
+
import { Logger } from '../lib/Logger';
|
|
5
|
+
import { IHelper, IImgInfo, IPicGo, IStringKeyMap, IPluginLoader, II18nManager, IPicGoPlugin, IPicGoPluginInterface, IRequest } from '../types';
|
|
6
|
+
import Request from '../lib/Request';
|
|
7
|
+
import PluginHandler from '../lib/PluginHandler';
|
|
8
|
+
export declare class PicGo extends EventEmitter implements IPicGo {
|
|
9
|
+
private _config;
|
|
10
|
+
private lifecycle;
|
|
11
|
+
private db;
|
|
12
|
+
private _pluginLoader;
|
|
13
|
+
configPath: string;
|
|
14
|
+
baseDir: string;
|
|
15
|
+
helper: IHelper;
|
|
16
|
+
log: Logger;
|
|
17
|
+
cmd: Commander;
|
|
18
|
+
output: IImgInfo[];
|
|
19
|
+
input: any[];
|
|
20
|
+
pluginHandler: PluginHandler;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated will be removed in v1.5.0+
|
|
23
|
+
*
|
|
24
|
+
* use request instead
|
|
25
|
+
*/
|
|
26
|
+
Request: Request;
|
|
27
|
+
i18n: II18nManager;
|
|
28
|
+
VERSION: string;
|
|
29
|
+
GUI_VERSION?: string;
|
|
30
|
+
get pluginLoader(): IPluginLoader;
|
|
31
|
+
constructor(configPath?: string);
|
|
32
|
+
private initConfigPath;
|
|
33
|
+
private initConfig;
|
|
34
|
+
private init;
|
|
35
|
+
/**
|
|
36
|
+
* easily mannually load a plugin
|
|
37
|
+
* if provide plugin name, will register plugin by name
|
|
38
|
+
* or just instantiate a plugin
|
|
39
|
+
*/
|
|
40
|
+
use(plugin: IPicGoPlugin, name?: string): IPicGoPluginInterface;
|
|
41
|
+
registerCommands(): void;
|
|
42
|
+
getConfig<T>(name?: string): T;
|
|
43
|
+
saveConfig(config: IStringKeyMap<any>): void;
|
|
44
|
+
removeConfig(key: string, propName: string): void;
|
|
45
|
+
setConfig(config: IStringKeyMap<any>): void;
|
|
46
|
+
unsetConfig(key: string, propName: string): void;
|
|
47
|
+
get request(): IRequest['request'];
|
|
48
|
+
upload(input?: any[]): Promise<IImgInfo[] | Error>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ILocalesKey } from './zh-CN';
|
|
2
|
+
import { IPicGo } from '../types';
|
|
3
|
+
import { IStringKeyMap, II18nManager } from '../types/index';
|
|
4
|
+
import { ILocale } from '@picgo/i18n/dist/types';
|
|
5
|
+
declare class I18nManager implements II18nManager {
|
|
6
|
+
private readonly i18n;
|
|
7
|
+
private readonly objectAdapter;
|
|
8
|
+
private readonly ctx;
|
|
9
|
+
constructor(ctx: IPicGo);
|
|
10
|
+
private loadOutterI18n;
|
|
11
|
+
private getOutterI18nFolder;
|
|
12
|
+
translate<T extends string>(key: ILocalesKey | T, args?: IStringKeyMap<string>): string;
|
|
13
|
+
setLanguage(language: string): void;
|
|
14
|
+
addLocale(language: string, locales: ILocale): boolean;
|
|
15
|
+
addLanguage(language: string, locales: ILocale): boolean;
|
|
16
|
+
getLanguageList(): string[];
|
|
17
|
+
}
|
|
18
|
+
export { I18nManager };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export declare const ZH_CN: {
|
|
2
|
+
UPLOAD_FAILED: string;
|
|
3
|
+
CHECK_SETTINGS: string;
|
|
4
|
+
CHECK_SETTINGS_AND_NETWORK: string;
|
|
5
|
+
UPLOAD_FAILED_REASON: string;
|
|
6
|
+
SERVER_ERROR: string;
|
|
7
|
+
AUTH_FAILED: string;
|
|
8
|
+
PICBED_SMMS: string;
|
|
9
|
+
PICBED_SMMS_TOKEN: string;
|
|
10
|
+
PICBED_SMMS_BACKUP_DOMAIN: string;
|
|
11
|
+
PICBED_SMMS_MESSAGE_BACKUP_DOMAIN: string;
|
|
12
|
+
PICBED_ALICLOUD: string;
|
|
13
|
+
PICBED_ALICLOUD_ACCESSKEYID: string;
|
|
14
|
+
PICBED_ALICLOUD_ACCESSKEYSECRET: string;
|
|
15
|
+
PICBED_ALICLOUD_BUCKET: string;
|
|
16
|
+
PICBED_ALICLOUD_AREA: string;
|
|
17
|
+
PICBED_ALICLOUD_PATH: string;
|
|
18
|
+
PICBED_ALICLOUD_CUSTOMURL: string;
|
|
19
|
+
PICBED_ALICLOUD_OPTIONS: string;
|
|
20
|
+
PICBED_ALICLOUD_MESSAGE_AREA: string;
|
|
21
|
+
PICBED_ALICLOUD_MESSAGE_PATH: string;
|
|
22
|
+
PICBED_ALICLOUD_MESSAGE_OPTIONS: string;
|
|
23
|
+
PICBED_ALICLOUD_MESSAGE_CUSTOMURL: string;
|
|
24
|
+
PICBED_TENCENTCLOUD: string;
|
|
25
|
+
PICBED_TENCENTCLOUD_VERSION: string;
|
|
26
|
+
PICBED_TENCENTCLOUD_SECRETID: string;
|
|
27
|
+
PICBED_TENCENTCLOUD_SECRETKEY: string;
|
|
28
|
+
PICBED_TENCENTCLOUD_APPID: string;
|
|
29
|
+
PICBED_TENCENTCLOUD_BUCKET: string;
|
|
30
|
+
PICBED_TENCENTCLOUD_AREA: string;
|
|
31
|
+
PICBED_TENCENTCLOUD_PATH: string;
|
|
32
|
+
PICBED_TENCENTCLOUD_OPTIONS: string;
|
|
33
|
+
PICBED_TENCENTCLOUD_CUSTOMURL: string;
|
|
34
|
+
PICBED_TENCENTCLOUD_MESSAGE_APPID: string;
|
|
35
|
+
PICBED_TENCENTCLOUD_MESSAGE_AREA: string;
|
|
36
|
+
PICBED_TENCENTCLOUD_MESSAGE_PATH: string;
|
|
37
|
+
PICBED_TENCENTCLOUD_MESSAGE_CUSTOMURL: string;
|
|
38
|
+
PICBED_TENCENTCLOUD_MESSAGE_OPTIONS: string;
|
|
39
|
+
PICBED_GITHUB: string;
|
|
40
|
+
PICBED_GITHUB_TOKEN: string;
|
|
41
|
+
PICBED_GITHUB_REPO: string;
|
|
42
|
+
PICBED_GITHUB_PATH: string;
|
|
43
|
+
PICBED_GITHUB_BRANCH: string;
|
|
44
|
+
PICBED_GITHUB_CUSTOMURL: string;
|
|
45
|
+
PICBED_GITHUB_MESSAGE_REPO: string;
|
|
46
|
+
PICBED_GITHUB_MESSAGE_BRANCH: string;
|
|
47
|
+
PICBED_GITHUB_MESSAGE_PATH: string;
|
|
48
|
+
PICBED_GITHUB_MESSAGE_CUSTOMURL: string;
|
|
49
|
+
PICBED_QINIU: string;
|
|
50
|
+
PICBED_QINIU_ACCESSKEY: string;
|
|
51
|
+
PICBED_QINIU_SECRETKEY: string;
|
|
52
|
+
PICBED_QINIU_BUCKET: string;
|
|
53
|
+
PICBED_QINIU_PATH: string;
|
|
54
|
+
PICBED_QINIU_URL: string;
|
|
55
|
+
PICBED_QINIU_OPTIONS: string;
|
|
56
|
+
PICBED_QINIU_AREA: string;
|
|
57
|
+
PICBED_QINIU_MESSAGE_PATH: string;
|
|
58
|
+
PICBED_QINIU_MESSAGE_AREA: string;
|
|
59
|
+
PICBED_QINIU_MESSAGE_OPTIONS: string;
|
|
60
|
+
PICBED_QINIU_MESSAGE_URL: string;
|
|
61
|
+
PICBED_IMGUR: string;
|
|
62
|
+
PICBED_IMGUR_CLIENTID: string;
|
|
63
|
+
PICBED_IMGUR_PROXY: string;
|
|
64
|
+
PICBED_IMGUR_MESSAGE_PROXY: string;
|
|
65
|
+
PICBED_UPYUN: string;
|
|
66
|
+
PICBED_UPYUN_BUCKET: string;
|
|
67
|
+
PICBED_UPYUN_OPERATOR: string;
|
|
68
|
+
PICBED_UPYUN_PASSWORD: string;
|
|
69
|
+
PICBED_UPYUN_PATH: string;
|
|
70
|
+
PICBED_UPYUN_URL: string;
|
|
71
|
+
PICBED_UPYUN_OPTIONS: string;
|
|
72
|
+
PICBED_UPYUN_MESSAGE_OPERATOR: string;
|
|
73
|
+
PICBED_UPYUN_MESSAGE_PASSWORD: string;
|
|
74
|
+
PICBED_UPYUN_MESSAGE_URL: string;
|
|
75
|
+
PICBED_UPYUN_MESSAGE_OPTIONS: string;
|
|
76
|
+
PICBED_UPYUN_MESSAGE_PATH: string;
|
|
77
|
+
PLUGIN_HANDLER_PLUGIN_INSTALL_SUCCESS: string;
|
|
78
|
+
PLUGIN_HANDLER_PLUGIN_INSTALL_FAILED: string;
|
|
79
|
+
PLUGIN_HANDLER_PLUGIN_INSTALL_FAILED_REASON: string;
|
|
80
|
+
PLUGIN_HANDLER_PLUGIN_INSTALL_FAILED_PATH: string;
|
|
81
|
+
PLUGIN_HANDLER_PLUGIN_UNINSTALL_SUCCESS: string;
|
|
82
|
+
PLUGIN_HANDLER_PLUGIN_UNINSTALL_FAILED: string;
|
|
83
|
+
PLUGIN_HANDLER_PLUGIN_UNINSTALL_FAILED_REASON: string;
|
|
84
|
+
PLUGIN_HANDLER_PLUGIN_UNINSTALL_FAILED_VALID: string;
|
|
85
|
+
PLUGIN_HANDLER_PLUGIN_UPDATE_SUCCESS: string;
|
|
86
|
+
PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED: string;
|
|
87
|
+
PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED_REASON: string;
|
|
88
|
+
PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED_VALID: string;
|
|
89
|
+
};
|
|
90
|
+
export declare type ILocalesKey = keyof typeof ZH_CN;
|
|
91
|
+
export declare type ILocales = typeof ZH_CN;
|