piclist 2.0.4 → 2.1.0

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.
@@ -0,0 +1,5 @@
1
+ import { IPicGo } from '../../types';
2
+ declare const configCmd: {
3
+ handle: (ctx: IPicGo) => void;
4
+ };
5
+ export default configCmd;
@@ -1,5 +1,5 @@
1
1
  import { IPicGo } from '../../types';
2
- export declare function formatPathHelper({ path, startSlash, endSlash, rootToEmpty }: {
2
+ export declare function formatPathHelper({ path, startSlash, endSlash, rootToEmpty, }: {
3
3
  path?: string;
4
4
  startSlash?: boolean;
5
5
  endSlash?: boolean;
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { Inquirer } from 'inquirer';
3
3
  import { FormatEnum, GravityEnum } from 'sharp';
4
+ import type { ConfigManager } from '../utils/configManager';
4
5
  import { IRequestPromiseOptions } from './oldRequest';
5
6
  export interface IPicGo extends NodeJS.EventEmitter {
6
7
  configPath: string;
@@ -13,6 +14,7 @@ export interface IPicGo extends NodeJS.EventEmitter {
13
14
  processedInput: any[];
14
15
  pluginLoader: IPluginLoader;
15
16
  pluginHandler: IPluginHandler;
17
+ configManager: ConfigManager;
16
18
  /**
17
19
  * @deprecated will be removed in v1.5.0+
18
20
  */
@@ -139,6 +141,7 @@ export interface IImgInfo {
139
141
  height?: number;
140
142
  extname?: string;
141
143
  imgUrl?: string;
144
+ filePath?: string;
142
145
  [propName: string]: any;
143
146
  }
144
147
  export interface IPathTransformedImgInfo extends IImgInfo {
@@ -358,6 +361,19 @@ export interface IAwsS3PListUserConfig {
358
361
  disableBucketPrefixToURL?: boolean | string;
359
362
  options?: string;
360
363
  }
364
+ /** Base config item with metadata */
365
+ export interface IConfigItem {
366
+ _id: string;
367
+ _configName: string;
368
+ _createdAt: number;
369
+ _updatedAt: number;
370
+ [key: string]: any;
371
+ }
372
+ /** Multi-config structure for uploaders */
373
+ export interface IUploaderConfigList {
374
+ configList: IConfigItem[];
375
+ defaultId: string;
376
+ }
361
377
  /** PicGo 配置文件类型定义 */
362
378
  export interface IConfig {
363
379
  picBed: {
@@ -377,6 +393,8 @@ export interface IConfig {
377
393
  proxy?: string;
378
394
  [others: string]: any;
379
395
  };
396
+ /** Multi-config structure for uploaders (new format) */
397
+ uploader?: Record<string, IUploaderConfigList>;
380
398
  picgoPlugins: Record<string, boolean>;
381
399
  debug?: boolean;
382
400
  silent?: boolean;
@@ -540,49 +558,27 @@ export type availableConvertFormat = keyof FormatEnum;
540
558
  export type availableWatermarkPosition = keyof GravityEnum;
541
559
  export interface IBuildInWaterMarkOptions {
542
560
  isAddWatermark?: boolean;
543
- isAddWatermarkMap?: {
544
- [key: string]: boolean;
545
- };
561
+ isAddWatermarkMap?: Record<string, boolean>;
546
562
  watermarkType?: 'text' | 'image';
547
- watermarkTypeMap?: {
548
- [key: string]: 'text' | 'image';
549
- };
563
+ watermarkTypeMap?: Record<string, 'text' | 'image'>;
550
564
  isFullScreenWatermark?: boolean;
551
- isFullScreenWatermarkMap?: {
552
- [key: string]: boolean;
553
- };
565
+ isFullScreenWatermarkMap?: Record<string, boolean>;
554
566
  watermarkDegree?: number;
555
- watermarkDegreeMap?: {
556
- [key: string]: number;
557
- };
567
+ watermarkDegreeMap?: Record<string, number>;
558
568
  watermarkText?: string;
559
- watermarkTextMap?: {
560
- [key: string]: string;
561
- };
569
+ watermarkTextMap?: Record<string, string>;
562
570
  watermarkFontPath?: string;
563
- watermarkFontPathMap?: {
564
- [key: string]: string;
565
- };
571
+ watermarkFontPathMap?: Record<string, string>;
566
572
  watermarkScaleRatio?: number;
567
- watermarkScaleRatioMap?: {
568
- [key: string]: number;
569
- };
573
+ watermarkScaleRatioMap?: Record<string, number>;
570
574
  watermarkColor?: string;
571
- watermarkColorMap?: {
572
- [key: string]: string;
573
- };
575
+ watermarkColorMap?: Record<string, string>;
574
576
  watermarkImagePath?: string;
575
- watermarkImagePathMap?: {
576
- [key: string]: string;
577
- };
577
+ watermarkImagePathMap?: Record<string, string>;
578
578
  watermarkPosition?: availableWatermarkPosition;
579
- watermarkPositionMap?: {
580
- [key: string]: availableWatermarkPosition;
581
- };
579
+ watermarkPositionMap?: Record<string, availableWatermarkPosition>;
582
580
  watermarkImageOpacity?: number;
583
- watermarkImageOpacityMap?: {
584
- [key: string]: number;
585
- };
581
+ watermarkImageOpacityMap?: Record<string, number>;
586
582
  [propName: string]: any;
587
583
  }
588
584
  export interface IBuildInWaterMarkOptionsTreated {
@@ -601,65 +597,35 @@ export interface IBuildInWaterMarkOptionsTreated {
601
597
  }
602
598
  export interface IBuildInCompressOptions {
603
599
  quality?: number;
604
- qualityMap?: {
605
- [key: string]: number;
606
- };
600
+ qualityMap?: Record<string, number>;
607
601
  isConvert?: boolean;
608
- isConvertMap?: {
609
- [key: string]: boolean;
610
- };
602
+ isConvertMap?: Record<string, boolean>;
611
603
  convertFormat?: availableConvertFormat;
612
- convertFormatMap?: {
613
- [key: string]: availableConvertFormat;
614
- };
604
+ convertFormatMap?: Record<string, availableConvertFormat>;
615
605
  isReSize?: boolean;
616
- isReSizeMap?: {
617
- [key: string]: boolean;
618
- };
606
+ isReSizeMap?: Record<string, boolean>;
619
607
  reSizeWidth?: number;
620
- reSizeWidthMap?: {
621
- [key: string]: number;
622
- };
608
+ reSizeWidthMap?: Record<string, number>;
623
609
  reSizeHeight?: number;
624
- reSizeHeightMap?: {
625
- [key: string]: number;
626
- };
610
+ reSizeHeightMap?: Record<string, number>;
627
611
  skipReSizeOfSmallImg?: boolean;
628
- skipReSizeOfSmallImgMap?: {
629
- [key: string]: boolean;
630
- };
612
+ skipReSizeOfSmallImgMap?: Record<string, boolean>;
631
613
  isReSizeByPercent?: boolean;
632
- isReSizeByPercentMap?: {
633
- [key: string]: boolean;
634
- };
614
+ isReSizeByPercentMap?: Record<string, boolean>;
635
615
  reSizePercent?: number;
636
- reSizePercentMap?: {
637
- [key: string]: number;
638
- };
616
+ reSizePercentMap?: Record<string, number>;
639
617
  isRotate?: boolean;
640
- isRotateMap?: {
641
- [key: string]: boolean;
642
- };
618
+ isRotateMap?: Record<string, boolean>;
643
619
  rotateDegree?: number;
644
- rotateDegreeMap?: {
645
- [key: string]: number;
646
- };
620
+ rotateDegreeMap?: Record<string, number>;
647
621
  isRemoveExif?: boolean;
648
- isRemoveExifMap?: {
649
- [key: string]: boolean;
650
- };
622
+ isRemoveExifMap?: Record<string, boolean>;
651
623
  isFlip?: boolean;
652
- isFlipMap?: {
653
- [key: string]: boolean;
654
- };
624
+ isFlipMap?: Record<string, boolean>;
655
625
  isFlop?: boolean;
656
- isFlopMap?: {
657
- [key: string]: boolean;
658
- };
626
+ isFlopMap?: Record<string, boolean>;
659
627
  formatConvertObj?: any;
660
- formatConvertObjMap?: {
661
- [key: string]: any;
662
- };
628
+ formatConvertObjMap?: Record<string, any>;
663
629
  [propName: string]: any;
664
630
  }
665
631
  export interface IBuildInCompressOptionsTreated {
@@ -0,0 +1,15 @@
1
+ import { IConfigItem, IPicGo } from '../types';
2
+ export declare class ConfigManager {
3
+ private readonly ctx;
4
+ constructor(ctx: IPicGo);
5
+ migrateToMultiConfig(uploaderName: string): void;
6
+ getCurrentUploaderConfig(uploaderName: string): IConfigItem | null;
7
+ getAllUploaderConfigs(uploaderName: string): IConfigItem[];
8
+ addUploaderConfig(uploaderName: string, configName: string, configData: any): IConfigItem;
9
+ updateUploaderConfig(uploaderName: string, configId: string, configData: any): boolean;
10
+ deleteUploaderConfig(uploaderName: string, configId: string): boolean;
11
+ setDefaultConfig(uploaderName: string, configId: string): boolean;
12
+ private syncConfigToPicBed;
13
+ getConfigByName(uploaderName: string, configName: string): IConfigItem | null;
14
+ renameConfig(uploaderName: string, configId: string, newName: string): boolean;
15
+ }
@@ -7,11 +7,14 @@ declare class DB {
7
7
  private readonly db;
8
8
  constructor(ctx: IPicGo);
9
9
  read(flush?: boolean): IJSON;
10
- get(key?: string): any;
10
+ getSingle(key?: string): any;
11
+ get(key: string): any;
12
+ get(key: string[]): any[];
11
13
  set(key: string, value: any): void;
12
14
  has(key: string): boolean;
13
15
  unset(key: string, value: any): boolean;
14
16
  saveConfig(config: Partial<IConfig>): void;
15
17
  removeConfig(config: IConfig): void;
18
+ getConfigPath(): string;
16
19
  }
17
20
  export default DB;
package/eslint.config.js CHANGED
@@ -1,47 +1,45 @@
1
- import eslint from '@eslint/js'
1
+ import js from '@eslint/js'
2
2
  import { defineConfig } from 'eslint/config'
3
- import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
3
+ import configPrettier from 'eslint-config-prettier'
4
+ import jsonc from 'eslint-plugin-jsonc'
5
+ import pluginPrettier from 'eslint-plugin-prettier/recommended'
4
6
  import simpleImportSort from 'eslint-plugin-simple-import-sort'
5
7
  import eslintPluginUnicorn from 'eslint-plugin-unicorn'
6
8
  import globals from 'globals'
9
+ import jsoncParser from 'jsonc-eslint-parser'
7
10
  import tseslint from 'typescript-eslint'
8
-
9
11
  export default defineConfig(
10
12
  {
11
- files: [
12
- './src/*.{ts,tsx,cts,mts,js,cjs,mjs}',
13
- './scripts/*.{ts,js,mjs}',
14
- './test/*.{ts,js,mjs}',
15
- './bin/picgo',
16
- './bin/picgo-server'
17
- ]
18
- },
19
- {
20
- ignores: ['**/node_modules/**', '**/dist/**', '**/webpack.config.js', 'vitest.workspace.mjs']
13
+ ignores: ['**/node_modules/**', '**/dist/**', 'vitest.workspace.mjs'],
21
14
  },
22
- eslint.configs.recommended,
15
+ js.configs.recommended,
23
16
  ...tseslint.configs.recommended,
24
17
  ...tseslint.configs.stylistic,
25
18
  {
19
+ files: [
20
+ 'src/**/*.{ts,tsx,cts,mts,js,cjs,mjs}',
21
+ 'scripts/**/*.{ts,js,mjs}',
22
+ 'test/**/*.{ts,js,mjs}',
23
+ './bin/picgo',
24
+ './bin/picgo-server',
25
+ 'eslint.config.js',
26
+ 'rollup.config.js',
27
+ ],
28
+ languageOptions: {
29
+ parserOptions: {
30
+ warnOnUnsupportedTypeScriptVersion: false,
31
+ },
32
+ globals: globals.node,
33
+ },
26
34
  plugins: {
27
35
  'simple-import-sort': simpleImportSort,
28
- unicorn: eslintPluginUnicorn
36
+ unicorn: eslintPluginUnicorn,
29
37
  },
30
38
  rules: {
39
+ 'unicorn/prefer-node-protocol': 'error',
40
+ 'unicorn/prefer-module': 'error',
31
41
  'simple-import-sort/imports': 'error',
32
- 'simple-import-sort/exports': 'error'
33
- }
34
- },
35
- {
36
- languageOptions: {
37
- parserOptions: {
38
- warnOnUnsupportedTypeScriptVersion: false
39
- },
40
- globals: globals.node
41
- }
42
- },
43
- {
44
- rules: {
42
+ 'simple-import-sort/exports': 'error',
45
43
  eqeqeq: 'error',
46
44
  'no-caller': 'error',
47
45
  'no-constant-condition': ['error', { checkLoops: false }],
@@ -56,22 +54,18 @@ export default defineConfig(
56
54
  'prefer-const': 'error',
57
55
  'prefer-object-spread': 'error',
58
56
  'unicode-bom': ['error', 'never'],
59
- // Enabled in eslint:recommended, but not applicable here
57
+ 'no-console': 'off',
58
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
59
+ 'no-unused-vars': 'off',
60
60
  'no-extra-boolean-cast': 'off',
61
61
  'no-case-declarations': 'off',
62
62
  'no-cond-assign': 'off',
63
63
  'no-control-regex': 'off',
64
64
  'no-inner-declarations': 'off',
65
65
  'no-empty': 'off',
66
-
67
66
  // @typescript-eslint/eslint-plugin
68
- 'no-unused-expressions': 'off',
69
67
  '@typescript-eslint/no-unused-expressions': 'off',
70
68
  '@typescript-eslint/ban-ts-comment': 'off',
71
- '@typescript-eslint/class-literal-property-style': 'off',
72
- '@typescript-eslint/consistent-indexed-object-style': 'off',
73
- '@typescript-eslint/consistent-generic-constructors': 'off',
74
- '@typescript-eslint/no-duplicate-enum-values': 'off',
75
69
  '@typescript-eslint/no-empty-function': 'off',
76
70
  '@typescript-eslint/no-namespace': 'off',
77
71
  '@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
@@ -80,12 +74,46 @@ export default defineConfig(
80
74
  '@typescript-eslint/no-explicit-any': 'off',
81
75
  '@typescript-eslint/no-empty-object-type': 'off', // {} is a totally useful and valid type.
82
76
  '@typescript-eslint/no-require-imports': 'off',
83
- '@typescript-eslint/no-unused-vars': 'off',
84
77
  '@typescript-eslint/no-inferrable-types': 'off',
85
78
  // Pending https://github.com/typescript-eslint/typescript-eslint/issues/4820
86
79
  '@typescript-eslint/prefer-optional-chain': 'off',
87
- 'unicorn/prefer-node-protocol': 'error'
88
- }
80
+ '@typescript-eslint/no-unused-vars': [
81
+ 'error',
82
+ {
83
+ args: 'all',
84
+ argsIgnorePattern: '^_',
85
+ caughtErrors: 'all',
86
+ caughtErrorsIgnorePattern: '^_',
87
+ },
88
+ ],
89
+ },
90
+ },
91
+ ...jsonc.configs['flat/recommended-with-jsonc'],
92
+ {
93
+ files: ['**/*.json', '**/*.jsonc', '**/*.json5'],
94
+ languageOptions: {
95
+ parser: jsoncParser,
96
+ },
97
+ rules: {
98
+ 'jsonc/array-bracket-spacing': ['error', 'never'],
99
+ 'jsonc/comma-dangle': ['error', 'never'],
100
+ 'jsonc/indent': ['error', 2],
101
+ 'jsonc/no-comments': 'off',
102
+ 'jsonc/quotes': ['error', 'double'],
103
+ },
104
+ },
105
+ {
106
+ files: ['src/i18n/**/*.json'],
107
+ rules: {
108
+ 'jsonc/sort-keys': [
109
+ 'error',
110
+ 'asc', // 升序排列
111
+ {
112
+ caseSensitive: false,
113
+ natural: true,
114
+ },
115
+ ],
116
+ },
89
117
  },
90
118
  {
91
119
  files: ['**/*.mjs', '**/*.mts'],
@@ -97,9 +125,10 @@ export default defineConfig(
97
125
  { name: '__dirname' },
98
126
  { name: 'require' },
99
127
  { name: 'module' },
100
- { name: 'exports' }
101
- ]
102
- }
128
+ { name: 'exports' },
129
+ ],
130
+ },
103
131
  },
104
- eslintPluginPrettierRecommended
132
+ configPrettier,
133
+ pluginPrettier,
105
134
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piclist",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "Modified PicGo core, A tool for picture uploading",
5
5
  "author": {
6
6
  "name": "Kuingsmile",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "license": "MIT",
56
56
  "devDependencies": {
57
- "@eslint/js": "^9.39.1",
57
+ "@eslint/js": "^9.39.2",
58
58
  "@rollup/plugin-commonjs": "^29.0.0",
59
59
  "@rollup/plugin-json": "^6.1.0",
60
60
  "@rollup/plugin-node-resolve": "^16.0.3",
@@ -72,57 +72,57 @@
72
72
  "@types/resolve": "^1.20.6",
73
73
  "@types/text-to-svg": "^3.1.4",
74
74
  "@types/tunnel": "^0.0.7",
75
- "@typescript-eslint/eslint-plugin": "^8.46.3",
76
- "@typescript-eslint/parser": "^8.46.3",
77
75
  "cross-env": "^10.1.0",
78
76
  "dpdm": "^3.14.0",
79
- "eslint": "^9.39.1",
77
+ "eslint": "^9.39.2",
80
78
  "eslint-config-prettier": "^10.1.8",
79
+ "eslint-plugin-jsonc": "^2.21.0",
81
80
  "eslint-plugin-prettier": "^5.5.4",
82
81
  "eslint-plugin-simple-import-sort": "^12.1.1",
83
82
  "eslint-plugin-unicorn": "^62.0.0",
84
83
  "husky": "^9.1.7",
84
+ "jsonc-eslint-parser": "^2.4.2",
85
85
  "node-bump-version": "^2.0.0",
86
- "prettier": "^3.6.2",
87
- "rollup": "^4.53.1",
86
+ "prettier": "^3.7.4",
87
+ "rimraf": "^6.1.2",
88
+ "rollup": "^4.55.1",
88
89
  "rollup-plugin-copy": "^3.5.0",
89
90
  "rollup-plugin-string": "^3.0.0",
90
91
  "typescript": "^5.8.3",
91
- "typescript-eslint": "^8.46.3",
92
- "rimraf": "^6.1.0"
92
+ "typescript-eslint": "^8.52.0"
93
93
  },
94
94
  "dependencies": {
95
- "@aws-sdk/client-s3": "3.931.0",
96
- "@aws-sdk/lib-storage": "3.931.0",
97
- "@aws-sdk/s3-request-presigner": "3.931.0",
98
- "@piclist/store": "^3.0.0",
95
+ "@aws-sdk/client-s3": "3.965.0",
96
+ "@aws-sdk/lib-storage": "3.965.0",
97
+ "@aws-sdk/s3-request-presigner": "3.965.0",
99
98
  "@piclist/i18n": "^2.0.0",
100
- "@smithy/node-http-handler": "4.4.5",
99
+ "@piclist/store": "^3.0.1",
100
+ "@smithy/node-http-handler": "4.4.7",
101
101
  "axios": "^1.13.2",
102
- "chalk": "^5.4.1",
102
+ "chalk": "^5.6.2",
103
103
  "commander": "^8.1.0",
104
104
  "cross-spawn": "^7.0.6",
105
105
  "dayjs": "^1.11.19",
106
- "file-type": "21.1.0",
107
- "form-data": "^4.0.4",
108
- "fs-extra": "^11.3.2",
106
+ "file-type": "21.3.0",
107
+ "form-data": "^4.0.5",
108
+ "fs-extra": "^11.3.3",
109
109
  "heic-convert": "^2.1.0",
110
110
  "hpagent": "1.2.0",
111
111
  "image-size": "^2.0.2",
112
112
  "inquirer": "^6.0.0",
113
113
  "is-wsl": "^3.1.0",
114
114
  "js-yaml": "^4.1.1",
115
- "lodash-es": "^4.17.21",
115
+ "lodash-es": "^4.17.22",
116
116
  "mime": "4.1.0",
117
117
  "minimist": "^1.2.8",
118
118
  "multer": "^2.0.2",
119
119
  "node-ssh-no-cpu-features": "^2.0.0",
120
120
  "qiniu": "7.14.0",
121
121
  "resolve": "^1.22.11",
122
- "sharp": "^0.34.4",
122
+ "sharp": "^0.34.5",
123
123
  "text-to-svg": "^3.1.5",
124
124
  "tunnel": "^0.0.6",
125
- "uuid": "^11.1.0",
125
+ "uuid": "^13.0.0",
126
126
  "webdav": "^5.8.0"
127
127
  },
128
128
  "repository": {
package/renovate.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": ["config:recommended"]
4
+ }
package/rollup.config.js CHANGED
@@ -26,28 +26,28 @@ const commonOptions = {
26
26
  // See https://github.com/rollup/rollup/issues/3684#issuecomment-926558056
27
27
  external: [
28
28
  ...Object.keys(pkg.dependencies).map(packageName => new RegExp(`^${packageName}(/.*)?`)),
29
- ...builtinModules.map(moduleName => new RegExp(`^(node:)?${moduleName}(/.*)?`))
29
+ ...builtinModules.map(moduleName => new RegExp(`^(node:)?${moduleName}(/.*)?`)),
30
30
  ],
31
31
  plugins: [
32
32
  typescript({
33
- tsconfig: './tsconfig.json'
33
+ tsconfig: './tsconfig.json',
34
34
  }),
35
35
  copy({
36
- targets: [{ src: 'assets', dest: 'dist' }]
36
+ targets: [{ src: 'assets', dest: 'dist' }],
37
37
  }),
38
38
  // terser(),
39
39
  commonjs(),
40
40
  string({
41
41
  // Required to be specified
42
- include: ['**/*.applescript', '**/*.ps1', '**/*.sh']
42
+ include: ['**/*.applescript', '**/*.ps1', '**/*.sh'],
43
43
  }),
44
44
  json(),
45
45
  replace({
46
46
  'process.env.PICGO_VERSION': JSON.stringify(pkg.version),
47
- preventAssignment: true
48
- })
47
+ preventAssignment: true,
48
+ }),
49
49
  ],
50
- input
50
+ input,
51
51
  }
52
52
 
53
53
  const isDev = process.env.NODE_ENV === 'development'
@@ -64,10 +64,10 @@ const nodeEsm = {
64
64
  file: 'dist/index.js',
65
65
  format: 'esm',
66
66
  banner,
67
- sourcemap
68
- }
67
+ sourcemap,
68
+ },
69
69
  ],
70
- ...commonOptions
70
+ ...commonOptions,
71
71
  }
72
72
 
73
73
  const bundles = []