piclist 1.8.9 → 1.8.11

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.
Files changed (61) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +50 -29
  3. package/.prettierrc +18 -0
  4. package/CHANGELOG.md +18 -0
  5. package/bin/picgo +25 -25
  6. package/bin/picgo-server +522 -491
  7. package/dist/core/Lifecycle.d.ts +1 -1
  8. package/dist/core/PicGo.d.ts +4 -4
  9. package/dist/i18n/en.d.ts +1 -1
  10. package/dist/i18n/index.d.ts +3 -4
  11. package/dist/i18n/zh-TW.d.ts +1 -1
  12. package/dist/index.cjs.js +2 -2
  13. package/dist/index.esm.js +2 -2
  14. package/dist/lib/Commander.d.ts +2 -2
  15. package/dist/lib/LifecyclePlugins.d.ts +1 -1
  16. package/dist/lib/Logger.d.ts +1 -1
  17. package/dist/lib/PluginHandler.d.ts +1 -1
  18. package/dist/lib/PluginLoader.d.ts +1 -1
  19. package/dist/lib/Request.d.ts +1 -1
  20. package/dist/plugins/beforetransformer/compress.d.ts +1 -1
  21. package/dist/plugins/beforetransformer/watermark.d.ts +1 -1
  22. package/dist/plugins/beforeupload/buildInRename.d.ts +1 -1
  23. package/dist/plugins/commander/config.d.ts +1 -1
  24. package/dist/plugins/commander/i18n.d.ts +1 -1
  25. package/dist/plugins/commander/index.d.ts +1 -1
  26. package/dist/plugins/commander/init.d.ts +1 -1
  27. package/dist/plugins/commander/pluginHandler.d.ts +1 -1
  28. package/dist/plugins/commander/proxy.d.ts +1 -1
  29. package/dist/plugins/commander/setting.d.ts +1 -1
  30. package/dist/plugins/commander/upload.d.ts +1 -1
  31. package/dist/plugins/commander/use.d.ts +1 -1
  32. package/dist/plugins/transformer/base64.d.ts +1 -1
  33. package/dist/plugins/transformer/index.d.ts +1 -1
  34. package/dist/plugins/transformer/path.d.ts +1 -1
  35. package/dist/plugins/uploader/aliyun.d.ts +1 -1
  36. package/dist/plugins/uploader/awss3plist.d.ts +1 -1
  37. package/dist/plugins/uploader/github.d.ts +1 -1
  38. package/dist/plugins/uploader/imgur.d.ts +1 -1
  39. package/dist/plugins/uploader/index.d.ts +1 -1
  40. package/dist/plugins/uploader/local.d.ts +1 -1
  41. package/dist/plugins/uploader/lsky.d.ts +1 -1
  42. package/dist/plugins/uploader/piclist.d.ts +1 -1
  43. package/dist/plugins/uploader/qiniu.d.ts +1 -1
  44. package/dist/plugins/uploader/s3/uploader.d.ts +1 -1
  45. package/dist/plugins/uploader/s3/utils.d.ts +1 -1
  46. package/dist/plugins/uploader/sftp.d.ts +1 -1
  47. package/dist/plugins/uploader/smms.d.ts +1 -1
  48. package/dist/plugins/uploader/tcyun.d.ts +1 -1
  49. package/dist/plugins/uploader/telegraph.d.ts +1 -1
  50. package/dist/plugins/uploader/upyun.d.ts +1 -1
  51. package/dist/plugins/uploader/webdav.d.ts +1 -1
  52. package/dist/types/index.d.ts +5 -5
  53. package/dist/utils/common.d.ts +1 -1
  54. package/dist/utils/createContext.d.ts +1 -1
  55. package/dist/utils/db.d.ts +2 -2
  56. package/dist/utils/getClipboardImage.d.ts +1 -1
  57. package/dist/utils/initUtils.d.ts +1 -1
  58. package/dist/utils/interfaces.d.ts +3 -3
  59. package/dist/utils/sshClient.d.ts +10 -11
  60. package/package.json +10 -7
  61. package/rollup.config.js +93 -93
@@ -1,6 +1,6 @@
1
1
  import { Command } from 'commander';
2
- import { type Inquirer } from 'inquirer';
3
- import type { IPlugin, ICommander, IPicGo } from '../types';
2
+ import { Inquirer } from 'inquirer';
3
+ import { IPlugin, ICommander, IPicGo } from '../types';
4
4
  export declare class Commander implements ICommander {
5
5
  private readonly name;
6
6
  static currentPlugin: string | null;
@@ -1,4 +1,4 @@
1
- import type { IPlugin, ILifecyclePlugins } from '../types';
1
+ import { IPlugin, ILifecyclePlugins } from '../types';
2
2
  export declare class LifecyclePlugins implements ILifecyclePlugins {
3
3
  static currentPlugin: string | null;
4
4
  private readonly list;
@@ -1,4 +1,4 @@
1
- import type { ILogArgvType, ILogArgvTypeWithError, ILogger, IPicGo } from '../types';
1
+ import { ILogArgvType, ILogArgvTypeWithError, ILogger, IPicGo } from '../types';
2
2
  export declare class Logger implements ILogger {
3
3
  private readonly level;
4
4
  private readonly ctx;
@@ -1,4 +1,4 @@
1
- import type { IProcessEnv, IPluginHandler, IPluginHandlerOptions, IPicGo, IPluginHandlerResult } from '../types';
1
+ import { IProcessEnv, IPluginHandler, IPluginHandlerOptions, IPicGo, IPluginHandlerResult } from '../types';
2
2
  export declare class PluginHandler implements IPluginHandler {
3
3
  private readonly ctx;
4
4
  constructor(ctx: IPicGo);
@@ -1,4 +1,4 @@
1
- import type { IPicGo, IPicGoPlugin, IPluginLoader, IPicGoPluginInterface } from '../types/index';
1
+ import { IPicGo, IPicGoPlugin, IPluginLoader, IPicGoPluginInterface } from '../types/index';
2
2
  /**
3
3
  * Local plugin loader, file system is required
4
4
  */
@@ -7,6 +7,6 @@ export declare class Request implements IRequest {
7
7
  constructor(ctx: IPicGo);
8
8
  private init;
9
9
  private handleProxy;
10
- request<T, U extends (IRequestConfig<U> extends IOldReqOptions ? IOldReqOptions : IRequestConfig<U> extends AxiosRequestConfig ? AxiosRequestConfig : never)>(options: U): Promise<IResponse<T, U>>;
10
+ request<T, U extends IRequestConfig<U> extends IOldReqOptions ? IOldReqOptions : IRequestConfig<U> extends AxiosRequestConfig ? AxiosRequestConfig : never>(options: U): Promise<IResponse<T, U>>;
11
11
  }
12
12
  export default Request;
@@ -1,4 +1,4 @@
1
- import type { IPicGo, IPluginConfig } from '../../types';
1
+ import { IPicGo, IPluginConfig } from '../../types';
2
2
  declare const _default: {
3
3
  config: (ctx: IPicGo) => IPluginConfig[];
4
4
  };
@@ -1,4 +1,4 @@
1
- import type { IPicGo, IPluginConfig } from '../../types';
1
+ import { IPicGo, IPluginConfig } from '../../types';
2
2
  declare const _default: {
3
3
  config: (ctx: IPicGo) => IPluginConfig[];
4
4
  };
@@ -1,4 +1,4 @@
1
- import type { IPicGo, IPluginConfig } from '../../types';
1
+ import { IPicGo, IPluginConfig } from '../../types';
2
2
  declare const _default: {
3
3
  config: (ctx: IPicGo) => IPluginConfig[];
4
4
  };
@@ -1,3 +1,3 @@
1
- import type { IPlugin } from '../../types';
1
+ import { IPlugin } from '../../types';
2
2
  declare const config: IPlugin;
3
3
  export default config;
@@ -1,3 +1,3 @@
1
- import type { IPlugin } from '../../types';
1
+ import { IPlugin } from '../../types';
2
2
  declare const i18n: IPlugin;
3
3
  export default i18n;
@@ -1,3 +1,3 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  declare const _default: (ctx: IPicGo) => void;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import type { IPlugin } from '../../types';
1
+ import { IPlugin } from '../../types';
2
2
  declare const init: IPlugin;
3
3
  export default init;
@@ -1,3 +1,3 @@
1
- import type { IPlugin } from '../../types';
1
+ import { IPlugin } from '../../types';
2
2
  declare const pluginHandler: IPlugin;
3
3
  export default pluginHandler;
@@ -1,3 +1,3 @@
1
- import type { IPlugin } from '../../types';
1
+ import { IPlugin } from '../../types';
2
2
  declare const proxy: IPlugin;
3
3
  export default proxy;
@@ -1,4 +1,4 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  declare const setting: {
3
3
  handle: (ctx: IPicGo) => void;
4
4
  };
@@ -1,3 +1,3 @@
1
- import type { IPlugin } from '../../types';
1
+ import { IPlugin } from '../../types';
2
2
  declare const upload: IPlugin;
3
3
  export default upload;
@@ -1,3 +1,3 @@
1
- import type { IPlugin } from '../../types';
1
+ import { IPlugin } from '../../types';
2
2
  declare const use: IPlugin;
3
3
  export default use;
@@ -1,4 +1,4 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  declare const _default: {
3
3
  handle: (ctx: IPicGo) => Promise<IPicGo>;
4
4
  };
@@ -1,3 +1,3 @@
1
- import type { IPicGoPlugin } from '../../types';
1
+ import { IPicGoPlugin } from '../../types';
2
2
  declare const buildInTransformers: IPicGoPlugin;
3
3
  export default buildInTransformers;
@@ -1,4 +1,4 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  declare const _default: {
3
3
  handle: (ctx: IPicGo) => Promise<IPicGo>;
4
4
  };
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,3 +1,3 @@
1
- import type { IPicGoPlugin } from '../../types';
1
+ import { IPicGoPlugin } from '../../types';
2
2
  declare const buildInUploaders: IPicGoPlugin;
3
3
  export default buildInUploaders;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { IPicGo } from '../../types';
2
+ import { IPicGo } from '../../types';
3
3
  export interface IMGTYPE {
4
4
  imgUrl?: string;
5
5
  type?: string;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,4 +1,4 @@
1
- import type { IAwsS3PListUserConfig, IImgInfo } from '../../../types';
1
+ import { IAwsS3PListUserConfig, IImgInfo } from '../../../types';
2
2
  export interface IUploadResult {
3
3
  index: number;
4
4
  key: string;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { HttpsProxyAgent, HttpProxyAgent } from 'hpagent';
3
- import type { IImgInfo } from '../../../types';
3
+ import { IImgInfo } from '../../../types';
4
4
  export declare function formatPath(info: IImgInfo, format?: string): string;
5
5
  export declare function extractInfo(info: IImgInfo): Promise<{
6
6
  body?: Buffer;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,4 +1,4 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export interface ISignature {
3
3
  signature: string;
4
4
  appId: string;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,2 +1,2 @@
1
- import type { IPicGo } from '../../types';
1
+ import { IPicGo } from '../../types';
2
2
  export default function register(ctx: IPicGo): void;
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import type { Command } from 'commander';
4
- import type { Inquirer } from 'inquirer';
5
- import type { FormatEnum, GravityEnum } from 'sharp';
6
- import type { IRequestPromiseOptions } from './oldRequest';
3
+ import { Command } from 'commander';
4
+ import { Inquirer } from 'inquirer';
5
+ import { FormatEnum, GravityEnum } from 'sharp';
6
+ import { IRequestPromiseOptions } from './oldRequest';
7
7
  export interface IPicGo extends NodeJS.EventEmitter {
8
8
  /**
9
9
  * picgo configPath
@@ -218,7 +218,7 @@ export interface IRequestLibOnlyOptions {
218
218
  }
219
219
  export type IRequestConfig<T> = T extends IRequestLibOnlyOptions ? IOldReqOptions : AxiosRequestConfig;
220
220
  export interface IRequest {
221
- request: <T, U extends (IRequestConfig<U> extends IOldReqOptions ? IOldReqOptions : IRequestConfig<U> extends AxiosRequestConfig ? AxiosRequestConfig : never)>(config: U) => Promise<IResponse<T, U>>;
221
+ request: <T, U extends IRequestConfig<U> extends IOldReqOptions ? IOldReqOptions : IRequestConfig<U> extends AxiosRequestConfig ? AxiosRequestConfig : never>(config: U) => Promise<IResponse<T, U>>;
222
222
  }
223
223
  export type ILogColor = 'blue' | 'green' | 'yellow' | 'red';
224
224
  /**
@@ -3,7 +3,7 @@
3
3
  /// <reference types="node" />
4
4
  import sharp from 'sharp';
5
5
  import crypto from 'crypto';
6
- import type { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger, IPicGo, IBuildInCompressOptions, IBuildInWaterMarkOptions } from '../types';
6
+ import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger, IPicGo, IBuildInCompressOptions, IBuildInWaterMarkOptions } from '../types';
7
7
  export declare function randomStringGenerator(length: number): string;
8
8
  export declare function renameFileNameWithTimestamp(oldName: string): string;
9
9
  export declare function renameFileNameWithRandomString(oldName: string, length?: number): string;
@@ -1,4 +1,4 @@
1
- import type { IPicGo } from '../types';
1
+ import { IPicGo } from '../types';
2
2
  /**
3
3
  * create an unique context for each upload process
4
4
  * @param ctx
@@ -1,5 +1,5 @@
1
- import type { IConfig, IPicGo } from '../types';
2
- import type { IJSON } from '@picgo/store/dist/types';
1
+ import { IConfig, IPicGo } from '../types';
2
+ import { IJSON } from '@picgo/store/dist/types';
3
3
  declare class DB {
4
4
  private readonly ctx;
5
5
  private readonly db;
@@ -1,4 +1,4 @@
1
- import type { IPicGo, IClipboardImage } from '../types';
1
+ import { IPicGo, IClipboardImage } from '../types';
2
2
  export type Platform = 'darwin' | 'win32' | 'win10' | 'linux' | 'wsl';
3
3
  declare const getClipboardImage: (ctx: IPicGo) => Promise<IClipboardImage>;
4
4
  export default getClipboardImage;
@@ -1,4 +1,4 @@
1
- import type { IPicGo, IOptions } from '../types';
1
+ import { IPicGo, IOptions } from '../types';
2
2
  /**
3
3
  * Generate template files to destination files.
4
4
  * @param {PicGo} ctx
@@ -1,8 +1,8 @@
1
1
  /** This file is deprecated */
2
2
  /// <reference types="node" />
3
- import type { PicGo } from '../core/PicGo';
4
- import type LifecyclePlugins from '../lib/LifecyclePlugins';
5
- import type { IWebdavPlistConfig } from '../types';
3
+ import { PicGo } from '../core/PicGo';
4
+ import { LifecyclePlugins } from '../lib/LifecyclePlugins';
5
+ import { IWebdavPlistConfig } from '../types';
6
6
  /**
7
7
  * for plugin config
8
8
  */
@@ -1,16 +1,15 @@
1
- import { NodeSSH } from 'node-ssh-no-cpu-features';
2
- import type { ISftpPlistConfig } from '../types';
1
+ import { ISftpPlistConfig } from '../types';
3
2
  declare class SSHClient {
4
- private static _instance;
5
- private static _client;
6
- private _isConnected;
7
- static get instance(): SSHClient;
8
- static get client(): NodeSSH;
9
- private changeWinStylePathToUnix;
10
- connect(config: ISftpPlistConfig): Promise<boolean>;
11
- upload(local: string, remote: string, config: ISftpPlistConfig): Promise<boolean>;
3
+ private static instance;
4
+ private client;
5
+ isConnected: boolean;
6
+ private constructor();
7
+ static getInstance(): SSHClient;
8
+ private static changeWinStylePathToUnix;
9
+ connect(config: ISftpPlistConfig): Promise<void>;
10
+ upload(local: string, remote: string, config: ISftpPlistConfig): Promise<void>;
12
11
  private mkdir;
13
- chown(remote: string, user: string, group?: string): Promise<boolean>;
12
+ chown(remote: string, user: string, group?: string): Promise<void>;
14
13
  private exec;
15
14
  close(): void;
16
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piclist",
3
- "version": "1.8.9",
3
+ "version": "1.8.11",
4
4
  "description": "Modified PicGo core, A tool for picture uploading",
5
5
  "author": {
6
6
  "name": "Kuingsmile",
@@ -25,11 +25,13 @@
25
25
  "start": "node ./bin/picgo",
26
26
  "server": "node ./bin/picgo-server",
27
27
  "lint": "eslint src/**/*.ts",
28
+ "lint:fix": "eslint src/**/*.ts --fix",
28
29
  "build": "cross-env NODE_ENV=production rimraf ./dist && rollup -c rollup.config.js",
29
30
  "dev": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
30
31
  "cz": "git-cz",
31
32
  "release": "bump-version",
32
- "lint:dpdm": "dpdm -T --tsconfig ./tsconfig.json --no-tree --no-warning --exit-code circular:1 src/index.ts"
33
+ "lint:dpdm": "dpdm -T --tsconfig ./tsconfig.json --no-tree --no-warning --exit-code circular:1 src/index.ts",
34
+ "publish:npm": "cross-env NODE_ENV=production rimraf ./dist && rollup -c rollup.config.js && npm publish"
33
35
  },
34
36
  "keywords": [
35
37
  "picture",
@@ -85,15 +87,16 @@
85
87
  "cz-customizable": "^5.10.0",
86
88
  "dpdm": "^3.14.0",
87
89
  "eslint": "^8.57.0",
88
- "eslint-config-standard-with-typescript": "^39.1.1",
90
+ "eslint-config-prettier": "^9.1.0",
91
+ "eslint-import-resolver-typescript": "^3.6.1",
89
92
  "eslint-plugin-import": "^2.29.1",
90
93
  "eslint-plugin-n": "^16.3.1",
91
- "eslint-plugin-node": "^11.1.0",
94
+ "eslint-plugin-prettier": "^5.1.3",
92
95
  "eslint-plugin-promise": "^6.2.0",
93
- "eslint-plugin-standard": "^5.0.0",
94
96
  "husky": "^1.3.1",
95
97
  "node-bump-version": "^1.0.2",
96
98
  "pre-commit": "^1.2.2",
99
+ "prettier": "^3.3.2",
97
100
  "rollup": "^2.79.1",
98
101
  "rollup-plugin-copy": "^3.5.0",
99
102
  "rollup-plugin-string": "^3.0.0",
@@ -112,7 +115,7 @@
112
115
  "chalk": "^2.4.1",
113
116
  "commander": "^8.1.0",
114
117
  "cross-spawn": "^7.0.3",
115
- "dayjs": "^1.11.10",
118
+ "dayjs": "^1.11.11",
116
119
  "download-git-repo": "^3.0.2",
117
120
  "ejs": "^2.6.1",
118
121
  "file-type": "16.2.0",
@@ -131,7 +134,7 @@
131
134
  "minimatch": "^3.0.4",
132
135
  "minimist": "^1.2.8",
133
136
  "multer": "^1.4.5-lts.1",
134
- "node-ssh-no-cpu-features": "^1.0.1",
137
+ "node-ssh-no-cpu-features": "^2.0.0",
135
138
  "qiniu": "7.9.0",
136
139
  "resolve": "^1.8.1",
137
140
  "rimraf": "^5.0.1",
package/rollup.config.js CHANGED
@@ -1,93 +1,93 @@
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 copy from 'rollup-plugin-copy'
6
- import { string } from 'rollup-plugin-string'
7
- import json from '@rollup/plugin-json'
8
- import builtins from 'builtins'
9
- import replace from '@rollup/plugin-replace'
10
- const version = process.env.VERSION || pkg.version
11
- const sourcemap = 'inline'
12
- const banner = `/*
13
- * piclist@${version}, https://github.com/Kuingsmile/PicList-Core
14
- * (c) 2022-${new Date().getFullYear()} Kuingsmile
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
- copy({
37
- targets: [
38
- { src: 'assets', dest: 'dist' }
39
- ]
40
- }),
41
- // terser(),
42
- commonjs(),
43
- string({
44
- // Required to be specified
45
- include: [
46
- '**/*.applescript',
47
- '**/*.ps1',
48
- '**/*.sh'
49
- ]
50
- }),
51
- json(),
52
- replace({
53
- 'process.env.PICGO_VERSION': JSON.stringify(pkg.version),
54
- preventAssignment: true
55
- })
56
- ],
57
- input
58
- }
59
-
60
- const isDev = process.env.NODE_ENV === 'development'
61
-
62
- if (!isDev) {
63
- commonOptions.plugins.push(terser())
64
- }
65
-
66
- /** @type import('rollup').RollupOptions */
67
- const nodeCjs = {
68
- output: [{
69
- file: 'dist/index.cjs.js',
70
- format: 'cjs',
71
- banner,
72
- sourcemap
73
- }],
74
- ...commonOptions
75
- }
76
-
77
- const nodeEsm = {
78
- output: [{
79
- file: 'dist/index.esm.js',
80
- format: 'esm',
81
- banner,
82
- sourcemap
83
- }],
84
- ...commonOptions
85
- }
86
-
87
- const bundles = []
88
- const env = process.env.BUNDLES || ''
89
- if (env.includes('cjs')) bundles.push(nodeCjs)
90
- if (env.includes('esm')) bundles.push(nodeEsm)
91
- if (bundles.length === 0) bundles.push(nodeCjs, nodeEsm)
92
-
93
- export default bundles
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 copy from 'rollup-plugin-copy'
6
+ import { string } from 'rollup-plugin-string'
7
+ import json from '@rollup/plugin-json'
8
+ import builtins from 'builtins'
9
+ import replace from '@rollup/plugin-replace'
10
+ const version = process.env.VERSION || pkg.version
11
+ const sourcemap = 'inline'
12
+ const banner = `/*
13
+ * piclist@${version}, https://github.com/Kuingsmile/PicList-Core
14
+ * (c) 2022-${new Date().getFullYear()} Kuingsmile
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
+ copy({
37
+ targets: [
38
+ { src: 'assets', dest: 'dist' }
39
+ ]
40
+ }),
41
+ // terser(),
42
+ commonjs(),
43
+ string({
44
+ // Required to be specified
45
+ include: [
46
+ '**/*.applescript',
47
+ '**/*.ps1',
48
+ '**/*.sh'
49
+ ]
50
+ }),
51
+ json(),
52
+ replace({
53
+ 'process.env.PICGO_VERSION': JSON.stringify(pkg.version),
54
+ preventAssignment: true
55
+ })
56
+ ],
57
+ input
58
+ }
59
+
60
+ const isDev = process.env.NODE_ENV === 'development'
61
+
62
+ if (!isDev) {
63
+ commonOptions.plugins.push(terser())
64
+ }
65
+
66
+ /** @type import('rollup').RollupOptions */
67
+ const nodeCjs = {
68
+ output: [{
69
+ file: 'dist/index.cjs.js',
70
+ format: 'cjs',
71
+ banner,
72
+ sourcemap
73
+ }],
74
+ ...commonOptions
75
+ }
76
+
77
+ const nodeEsm = {
78
+ output: [{
79
+ file: 'dist/index.esm.js',
80
+ format: 'esm',
81
+ banner,
82
+ sourcemap
83
+ }],
84
+ ...commonOptions
85
+ }
86
+
87
+ const bundles = []
88
+ const env = process.env.BUNDLES || ''
89
+ if (env.includes('cjs')) bundles.push(nodeCjs)
90
+ if (env.includes('esm')) bundles.push(nodeEsm)
91
+ if (bundles.length === 0) bundles.push(nodeCjs, nodeEsm)
92
+
93
+ export default bundles