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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare enum ILogType {
|
|
2
|
+
success = "success",
|
|
3
|
+
info = "info",
|
|
4
|
+
warn = "warn",
|
|
5
|
+
error = "error"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* these events will be catched by users
|
|
9
|
+
*/
|
|
10
|
+
export declare enum IBuildInEvent {
|
|
11
|
+
UPLOAD_PROGRESS = "uploadProgress",
|
|
12
|
+
FAILED = "failed",
|
|
13
|
+
BEFORE_TRANSFORM = "beforeTransform",
|
|
14
|
+
BEFORE_UPLOAD = "beforeUpload",
|
|
15
|
+
AFTER_UPLOAD = "afterUpload",
|
|
16
|
+
FINISHED = "finished",
|
|
17
|
+
INSTALL = "install",
|
|
18
|
+
UNINSTALL = "uninstall",
|
|
19
|
+
UPDATE = "update",
|
|
20
|
+
NOTIFICATION = "notification"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* these events will be catched only by picgo
|
|
24
|
+
*/
|
|
25
|
+
export declare enum IBusEvent {
|
|
26
|
+
CONFIG_CHANGE = "CONFIG_CHANGE"
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IPicGo, IOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate template files to destination files.
|
|
4
|
+
* @param {PicGo} ctx
|
|
5
|
+
* @param {IOptions} options
|
|
6
|
+
*/
|
|
7
|
+
declare const generate: (ctx: IPicGo, options: IOptions) => Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Return the filters' result
|
|
10
|
+
* @param ctx PicGo
|
|
11
|
+
* @param exp condition expression
|
|
12
|
+
* @param data options data
|
|
13
|
+
*/
|
|
14
|
+
declare const filters: (ctx: IPicGo, exp: any, data: any) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Render files to a virtual tree object
|
|
17
|
+
* @param {array} files
|
|
18
|
+
*/
|
|
19
|
+
declare const render: (files: string[], source: string, options: any) => any;
|
|
20
|
+
/**
|
|
21
|
+
* Write rendered files' content to real file
|
|
22
|
+
* @param {string} dir
|
|
23
|
+
* @param {object} files
|
|
24
|
+
*/
|
|
25
|
+
declare const writeFileTree: (dir: string, files: any) => void;
|
|
26
|
+
export { filters, generate, render, writeFileTree };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/** This file is deprecated */
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { PicGo } from '../core/PicGo';
|
|
4
|
+
import LifecyclePlugins from '../lib/LifecyclePlugins';
|
|
5
|
+
/**
|
|
6
|
+
* for plugin config
|
|
7
|
+
*/
|
|
8
|
+
export interface IPluginConfig {
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
default?: any;
|
|
13
|
+
[propName: string]: any;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* for lifecycle plugins
|
|
17
|
+
*/
|
|
18
|
+
export interface IHelper {
|
|
19
|
+
transformer: LifecyclePlugins;
|
|
20
|
+
uploader: LifecyclePlugins;
|
|
21
|
+
beforeTransformPlugins: LifecyclePlugins;
|
|
22
|
+
beforeUploadPlugins: LifecyclePlugins;
|
|
23
|
+
afterUploadPlugins: LifecyclePlugins;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* for uploading image info
|
|
27
|
+
*/
|
|
28
|
+
export interface IImgInfo {
|
|
29
|
+
buffer?: Buffer;
|
|
30
|
+
base64Image?: string;
|
|
31
|
+
fileName?: string;
|
|
32
|
+
width?: number;
|
|
33
|
+
height?: number;
|
|
34
|
+
extname?: string;
|
|
35
|
+
[propName: string]: any;
|
|
36
|
+
}
|
|
37
|
+
export interface IPathTransformedImgInfo extends IImgInfo {
|
|
38
|
+
success: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** SM.MS 图床配置项 */
|
|
41
|
+
export interface ISmmsConfig {
|
|
42
|
+
token: string;
|
|
43
|
+
}
|
|
44
|
+
/** 七牛云图床配置项 */
|
|
45
|
+
export interface IQiniuConfig {
|
|
46
|
+
accessKey: string;
|
|
47
|
+
secretKey: string;
|
|
48
|
+
/** 存储空间名 */
|
|
49
|
+
bucket: string;
|
|
50
|
+
/** 自定义域名 */
|
|
51
|
+
url: string;
|
|
52
|
+
/** 存储区域编号 */
|
|
53
|
+
area: 'z0' | 'z1' | 'z2' | 'na0' | 'as0';
|
|
54
|
+
/** 网址后缀,比如使用 `?imageslim` 可进行[图片瘦身](https://developer.qiniu.com/dora/api/1271/image-thin-body-imageslim) */
|
|
55
|
+
options: string;
|
|
56
|
+
/** 自定义存储路径,比如 `img/` */
|
|
57
|
+
path: string;
|
|
58
|
+
}
|
|
59
|
+
/** 又拍云图床配置项 */
|
|
60
|
+
export interface IUpyunConfig {
|
|
61
|
+
/** 存储空间名,及你的服务名 */
|
|
62
|
+
bucket: string;
|
|
63
|
+
/** 操作员 */
|
|
64
|
+
operator: string;
|
|
65
|
+
/** 密码 */
|
|
66
|
+
password: string;
|
|
67
|
+
/** 针对图片的一些后缀处理参数 */
|
|
68
|
+
options: string;
|
|
69
|
+
/** 自定义存储路径,比如 `img/` */
|
|
70
|
+
path: string;
|
|
71
|
+
/** 加速域名,注意要加 `http://` 或者 `https://` */
|
|
72
|
+
url: string;
|
|
73
|
+
}
|
|
74
|
+
/** 腾讯云图床配置项 */
|
|
75
|
+
export interface ITcyunConfig {
|
|
76
|
+
secretId: string;
|
|
77
|
+
secretKey: string;
|
|
78
|
+
/** 存储桶名,v4 和 v5 版本不一样 */
|
|
79
|
+
bucket: string;
|
|
80
|
+
appId: string;
|
|
81
|
+
/** 存储区域,例如 ap-beijing-1 */
|
|
82
|
+
area: string;
|
|
83
|
+
/** 自定义存储路径,比如 img/ */
|
|
84
|
+
path: string;
|
|
85
|
+
/** 自定义域名,注意要加 `http://` 或者 `https://` */
|
|
86
|
+
customUrl: string;
|
|
87
|
+
/** COS 版本,v4 或者 v5 */
|
|
88
|
+
version: 'v5' | 'v4';
|
|
89
|
+
}
|
|
90
|
+
/** GitHub 图床配置项 */
|
|
91
|
+
export interface IGithubConfig {
|
|
92
|
+
/** 仓库名,格式是 `username/reponame` */
|
|
93
|
+
repo: string;
|
|
94
|
+
/** github token */
|
|
95
|
+
token: string;
|
|
96
|
+
/** 自定义存储路径,比如 `img/` */
|
|
97
|
+
path: string;
|
|
98
|
+
/** 自定义域名,注意要加 `http://` 或者 `https://` */
|
|
99
|
+
customUrl: string;
|
|
100
|
+
/** 分支名,默认是 `master` */
|
|
101
|
+
branch: string;
|
|
102
|
+
}
|
|
103
|
+
/** 阿里云图床配置项 */
|
|
104
|
+
export interface IAliyunConfig {
|
|
105
|
+
accessKeyId: string;
|
|
106
|
+
accessKeySecret: string;
|
|
107
|
+
/** 存储空间名 */
|
|
108
|
+
bucket: string;
|
|
109
|
+
/** 存储区域代号 */
|
|
110
|
+
area: string;
|
|
111
|
+
/** 自定义存储路径 */
|
|
112
|
+
path: string;
|
|
113
|
+
/** 自定义域名,注意要加 `http://` 或者 `https://` */
|
|
114
|
+
customUrl: string;
|
|
115
|
+
/** 针对图片的一些后缀处理参数 PicGo 2.2.0+ PicGo-Core 1.4.0+ */
|
|
116
|
+
options: string;
|
|
117
|
+
}
|
|
118
|
+
/** Imgur 图床配置项 */
|
|
119
|
+
export interface IImgurConfig {
|
|
120
|
+
/** imgur 的 `clientId` */
|
|
121
|
+
clientId: string;
|
|
122
|
+
/** 代理地址,仅支持 http 代理 */
|
|
123
|
+
proxy: string;
|
|
124
|
+
}
|
|
125
|
+
/** PicGo 配置文件类型定义 */
|
|
126
|
+
export interface IConfig {
|
|
127
|
+
picBed: {
|
|
128
|
+
uploader: string;
|
|
129
|
+
current?: string;
|
|
130
|
+
smms?: ISmmsConfig;
|
|
131
|
+
qiniu?: IQiniuConfig;
|
|
132
|
+
upyun?: IUpyunConfig;
|
|
133
|
+
tcyun?: ITcyunConfig;
|
|
134
|
+
github?: IGithubConfig;
|
|
135
|
+
aliyun?: IAliyunConfig;
|
|
136
|
+
imgur?: IImgurConfig;
|
|
137
|
+
transformer?: string;
|
|
138
|
+
proxy: string;
|
|
139
|
+
};
|
|
140
|
+
picgoPlugins: {
|
|
141
|
+
[propName: string]: boolean;
|
|
142
|
+
};
|
|
143
|
+
debug?: boolean;
|
|
144
|
+
silent?: boolean;
|
|
145
|
+
settings?: {
|
|
146
|
+
logLevel: string;
|
|
147
|
+
logPath: string;
|
|
148
|
+
};
|
|
149
|
+
/** 下载插件时 npm 命令自定义的 registry */
|
|
150
|
+
registry: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* for plugin
|
|
154
|
+
*/
|
|
155
|
+
export interface IPlugin {
|
|
156
|
+
handle: ((ctx: PicGo) => Promise<any>) | ((ctx: PicGo) => void);
|
|
157
|
+
[propName: string]: any;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* for spawn output
|
|
161
|
+
*/
|
|
162
|
+
export interface IResult {
|
|
163
|
+
code: number;
|
|
164
|
+
data: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* for transformer - path
|
|
168
|
+
*/
|
|
169
|
+
export interface IImgSize {
|
|
170
|
+
width: number;
|
|
171
|
+
height: number;
|
|
172
|
+
real?: boolean;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* for initUtils
|
|
176
|
+
*/
|
|
177
|
+
export interface IOptions {
|
|
178
|
+
template: string;
|
|
179
|
+
dest: string;
|
|
180
|
+
hasSlash: boolean;
|
|
181
|
+
inPlace: boolean;
|
|
182
|
+
clone: boolean;
|
|
183
|
+
offline: boolean;
|
|
184
|
+
tmp: string;
|
|
185
|
+
project: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* for clipboard image
|
|
189
|
+
*/
|
|
190
|
+
export interface IClipboardImage {
|
|
191
|
+
imgPath: string;
|
|
192
|
+
isExistFile: boolean;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* for install command environment variable
|
|
196
|
+
*/
|
|
197
|
+
export interface IProcessEnv {
|
|
198
|
+
[propName: string]: Undefinable<string>;
|
|
199
|
+
}
|
|
200
|
+
export declare type ILogArgvType = string | number;
|
|
201
|
+
export declare type ILogArgvTypeWithError = ILogArgvType | Error;
|
|
202
|
+
export declare type Nullable<T> = T | null;
|
|
203
|
+
export declare type Undefinable<T> = T | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CLIPBOARD_IMAGE_FOLDER = "picgo-clipboard-images";
|
package/logo.png
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "piclist",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Modified PicGo core, A tool for picture uploading",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"typings": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"picgo": "./bin/picgo"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"start": "node ./bin/picgo",
|
|
16
|
+
"lint": "eslint src/**/*.ts && npm run build",
|
|
17
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
18
|
+
"build": "cross-env NODE_ENV=production rimraf ./dist && rollup -c rollup.config.js",
|
|
19
|
+
"dev": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
|
|
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
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"picture",
|
|
28
|
+
"upload",
|
|
29
|
+
"util"
|
|
30
|
+
],
|
|
31
|
+
"husky": {
|
|
32
|
+
"hooks": {
|
|
33
|
+
"pre-commit": "npm run lint",
|
|
34
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"config": {
|
|
38
|
+
"commitizen": {
|
|
39
|
+
"path": "./node_modules/cz-customizable"
|
|
40
|
+
},
|
|
41
|
+
"cz-customizable": {
|
|
42
|
+
"config": "./node_modules/@picgo/bump-version/.cz-config.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"commitlint": {
|
|
46
|
+
"extends": [
|
|
47
|
+
"./node_modules/@picgo/bump-version/commitlint-picgo"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"author": "Kuingsmile",
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"devDependencies": {
|
|
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",
|
|
58
|
+
"@types/cross-spawn": "^6.0.0",
|
|
59
|
+
"@types/ejs": "^3.0.5",
|
|
60
|
+
"@types/fs-extra": "^5.0.4",
|
|
61
|
+
"@types/image-size": "^0.0.29",
|
|
62
|
+
"@types/inquirer": "^0.0.42",
|
|
63
|
+
"@types/js-yaml": "^4.0.5",
|
|
64
|
+
"@types/lodash": "^4.14.175",
|
|
65
|
+
"@types/md5": "^2.1.32",
|
|
66
|
+
"@types/mime-types": "^2.1.0",
|
|
67
|
+
"@types/minimatch": "^3.0.3",
|
|
68
|
+
"@types/node": "16.11.7",
|
|
69
|
+
"@types/resolve": "^0.0.8",
|
|
70
|
+
"@types/rimraf": "^3.0.0",
|
|
71
|
+
"@types/tunnel": "^0.0.3",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "3",
|
|
73
|
+
"@typescript-eslint/parser": "^3.2.0",
|
|
74
|
+
"babel-eslint": "^10.1.0",
|
|
75
|
+
"builtins": "^4.0.0",
|
|
76
|
+
"conventional-changelog": "^3.0.6",
|
|
77
|
+
"copyfiles": "^2.1.0",
|
|
78
|
+
"cross-env": "^7.0.3",
|
|
79
|
+
"cz-customizable": "^5.10.0",
|
|
80
|
+
"eslint": "7",
|
|
81
|
+
"eslint-config-standard-with-typescript": "^18.0.2",
|
|
82
|
+
"eslint-plugin-import": "2",
|
|
83
|
+
"eslint-plugin-node": "11",
|
|
84
|
+
"eslint-plugin-promise": "4",
|
|
85
|
+
"eslint-plugin-standard": "4",
|
|
86
|
+
"execa": "^5.1.1",
|
|
87
|
+
"husky": "^1.3.1",
|
|
88
|
+
"pre-commit": "^1.2.2",
|
|
89
|
+
"rollup": "^2.58.0",
|
|
90
|
+
"rollup-plugin-string": "^3.0.0",
|
|
91
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
92
|
+
"rollup-plugin-typescript2": "^0.30.0",
|
|
93
|
+
"typescript": "^4.8.2"
|
|
94
|
+
},
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"@picgo/i18n": "^1.0.0",
|
|
97
|
+
"@picgo/store": "^2.0.2",
|
|
98
|
+
"axios": "^0.27.2",
|
|
99
|
+
"chalk": "^2.4.1",
|
|
100
|
+
"commander": "^8.1.0",
|
|
101
|
+
"comment-json": "^2.3.1",
|
|
102
|
+
"cross-spawn": "^6.0.5",
|
|
103
|
+
"dayjs": "^1.7.4",
|
|
104
|
+
"download-git-repo": "^3.0.2",
|
|
105
|
+
"ejs": "^2.6.1",
|
|
106
|
+
"fs-extra": "^6.0.1",
|
|
107
|
+
"globby": "^11.0.4",
|
|
108
|
+
"image-size": "^0.8.3",
|
|
109
|
+
"inquirer": "^6.0.0",
|
|
110
|
+
"is-wsl": "^2.2.0",
|
|
111
|
+
"js-yaml": "^4.1.0",
|
|
112
|
+
"lodash": "^4.17.21",
|
|
113
|
+
"md5": "^2.2.1",
|
|
114
|
+
"mime-types": "2.1.33",
|
|
115
|
+
"minimatch": "^3.0.4",
|
|
116
|
+
"minimist": "^1.2.5",
|
|
117
|
+
"qiniu": "^7.2.1",
|
|
118
|
+
"resolve": "^1.8.1",
|
|
119
|
+
"rimraf": "^3.0.2",
|
|
120
|
+
"tunnel": "^0.0.6"
|
|
121
|
+
},
|
|
122
|
+
"repository": {
|
|
123
|
+
"type": "git",
|
|
124
|
+
"url": "git+https://github.com/Kuingsmile/PicList-Core.git"
|
|
125
|
+
},
|
|
126
|
+
"picBed": {
|
|
127
|
+
"current": "smms"
|
|
128
|
+
},
|
|
129
|
+
"plugins": {},
|
|
130
|
+
"engines": {
|
|
131
|
+
"node": ">= 12.0.0"
|
|
132
|
+
}
|
|
133
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
const version = process.env.VERSION || pkg.version
|
|
10
|
+
const sourcemap = 'inline'
|
|
11
|
+
const banner = `/*
|
|
12
|
+
* picgo@${version}, https://github.com/PicGo/PicGo-Core
|
|
13
|
+
* (c) 2018-${new Date().getFullYear()} PicGo Group
|
|
14
|
+
* Released under the MIT License.
|
|
15
|
+
*/`
|
|
16
|
+
const input = './src/index.ts'
|
|
17
|
+
|
|
18
|
+
const commonOptions = {
|
|
19
|
+
// Creating regex of the packages to make sure sub-paths of the
|
|
20
|
+
// packages such as `lowdb/adapters/FileSync` are also treated as external
|
|
21
|
+
// See https://github.com/rollup/rollup/issues/3684#issuecomment-926558056
|
|
22
|
+
external: [
|
|
23
|
+
...Object.keys(pkg.dependencies),
|
|
24
|
+
...builtins()
|
|
25
|
+
].map(packageName => new RegExp(`^${packageName}(/.*)?`)),
|
|
26
|
+
plugins: [
|
|
27
|
+
typescript({
|
|
28
|
+
tsconfigOverride: {
|
|
29
|
+
compilerOptions: {
|
|
30
|
+
target: 'ES2017',
|
|
31
|
+
module: 'ES2015'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
// terser(),
|
|
36
|
+
commonjs(),
|
|
37
|
+
string({
|
|
38
|
+
// Required to be specified
|
|
39
|
+
include: [
|
|
40
|
+
'**/*.applescript',
|
|
41
|
+
'**/*.ps1',
|
|
42
|
+
'**/*.sh'
|
|
43
|
+
]
|
|
44
|
+
}),
|
|
45
|
+
json(),
|
|
46
|
+
replace({
|
|
47
|
+
'process.env.PICGO_VERSION': JSON.stringify(pkg.version),
|
|
48
|
+
preventAssignment: true
|
|
49
|
+
})
|
|
50
|
+
],
|
|
51
|
+
input
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const isDev = process.env.NODE_ENV === 'development'
|
|
55
|
+
|
|
56
|
+
if (!isDev) {
|
|
57
|
+
commonOptions.plugins.push(terser())
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @type import('rollup').RollupOptions */
|
|
61
|
+
const nodeCjs = {
|
|
62
|
+
output: [{
|
|
63
|
+
file: 'dist/index.cjs.js',
|
|
64
|
+
format: 'cjs',
|
|
65
|
+
banner,
|
|
66
|
+
sourcemap
|
|
67
|
+
}],
|
|
68
|
+
...commonOptions
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const nodeEsm = {
|
|
72
|
+
output: [{
|
|
73
|
+
file: 'dist/index.esm.js',
|
|
74
|
+
format: 'esm',
|
|
75
|
+
banner,
|
|
76
|
+
sourcemap
|
|
77
|
+
}],
|
|
78
|
+
...commonOptions
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const bundles = []
|
|
82
|
+
const env = process.env.BUNDLES || ''
|
|
83
|
+
if (env.includes('cjs')) bundles.push(nodeCjs)
|
|
84
|
+
if (env.includes('esm')) bundles.push(nodeEsm)
|
|
85
|
+
if (bundles.length === 0) bundles.push(nodeCjs, nodeEsm)
|
|
86
|
+
|
|
87
|
+
export default bundles
|