@dune2/cli 0.2.9 → 0.2.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.
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +4 -110
- package/dist/normalizeConfig.d.ts +7 -0
- package/dist/types-4aff0a8d.d.ts +111 -0
- package/package.json +4 -1
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { GaxiosResponse } from 'gaxios';
|
|
2
2
|
import { sheets_v4 } from 'googleapis';
|
|
3
|
-
import {
|
|
3
|
+
import { C as Config } from './types-4aff0a8d.js';
|
|
4
|
+
export { A as ApiConfig, C as Config, I as I18nConfig } from './types-4aff0a8d.js';
|
|
5
|
+
import 'openapi-types';
|
|
4
6
|
|
|
5
7
|
declare class GoogleSheet {
|
|
6
8
|
private sheets;
|
|
@@ -49,116 +51,8 @@ declare function numberToLetter(n: number): string;
|
|
|
49
51
|
|
|
50
52
|
declare function resolveSheetId(str?: string): string | undefined;
|
|
51
53
|
|
|
52
|
-
interface I18nConfig {
|
|
53
|
-
i18nDir?: string;
|
|
54
|
-
i18nFileName?: string;
|
|
55
|
-
defaultLocale?: string;
|
|
56
|
-
/**
|
|
57
|
-
* 可以是 id 或者 url,如果是 url 则会自动解析出 id
|
|
58
|
-
* id: 1C9-Dol3oO20W9_FhiVlxNsDhOaaejJIgAZYRkonGmfk
|
|
59
|
-
* url: https://docs.google.com/spreadsheets/d/1C9-Dol3oO20W9_FhiVlxNsDhOaaejJIgAZYRkonGmfk/edit#gid=1740568548
|
|
60
|
-
*/
|
|
61
|
-
sheetId?: string;
|
|
62
|
-
sheetRange?: string;
|
|
63
|
-
/**
|
|
64
|
-
* 对应 语言、i18nKey 所在的列标识符 如(A,B,C...)
|
|
65
|
-
* 传入时将忽略默认的配置
|
|
66
|
-
* @default {key: "B", zh: "C", en: "D", in: "E",}
|
|
67
|
-
*/
|
|
68
|
-
position?: {
|
|
69
|
-
key: string;
|
|
70
|
-
[key: string]: string;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* 从 Google Sheets 哪一行开始解析
|
|
74
|
-
* 默认从第2行开始,模板文件第一行是表头
|
|
75
|
-
* @default 2
|
|
76
|
-
*/
|
|
77
|
-
parseStartIndex?: number;
|
|
78
|
-
/**
|
|
79
|
-
* 包括的文件
|
|
80
|
-
* glob 语法
|
|
81
|
-
*/
|
|
82
|
-
include?: string[];
|
|
83
|
-
/**
|
|
84
|
-
* 是否禁用提取功能,某些项是不需要提取的,只需要同不Google sheet
|
|
85
|
-
* @default false
|
|
86
|
-
*/
|
|
87
|
-
disableExtract?: boolean;
|
|
88
|
-
}
|
|
89
|
-
interface ApiConfig {
|
|
90
|
-
/**
|
|
91
|
-
* swagger JSON 的路径 可以是 本地 可以是远程
|
|
92
|
-
*/
|
|
93
|
-
swaggerJSONPath: string;
|
|
94
|
-
/**
|
|
95
|
-
* 用在生成代码里快捷连接跳转到 swagger ui
|
|
96
|
-
* 必须携带 urls.primaryName 参数
|
|
97
|
-
* @example http://192.168.104.10:31082/swagger/?urls.primaryName=%E5%90%8E%E5%8F%B0%E7%AE%A1%E7%90%86%E7%9B%B8%E5%85%B3API
|
|
98
|
-
*/
|
|
99
|
-
swaggerUiUrl?: string;
|
|
100
|
-
/**
|
|
101
|
-
* 输出的文件夹路径
|
|
102
|
-
* @default "./src/apis"
|
|
103
|
-
*/
|
|
104
|
-
output?: string;
|
|
105
|
-
/**
|
|
106
|
-
* 配置`requestFn` 方法引入的路径,生成的代码里会用到,生成代码如下
|
|
107
|
-
* 导入的变量必须是命名为`requestFn`
|
|
108
|
-
* ```ts
|
|
109
|
-
* // 需要命名为 requestFn
|
|
110
|
-
* import requestFn from '@/utils/request'
|
|
111
|
-
* import { foo as requestFn } from '@/utils/request'
|
|
112
|
-
* ```
|
|
113
|
-
* @default `import requestFn from '@/utils/request'`
|
|
114
|
-
* @deprecated 优先使用 `urlTransformer`
|
|
115
|
-
*/
|
|
116
|
-
requestFnImportPath?: string;
|
|
117
|
-
/**
|
|
118
|
-
* 配置`queryClient` 路径,导入的变量必须是命名为`queryClient`
|
|
119
|
-
* @example `import queryClient from '@/utils/request'`
|
|
120
|
-
* @example `import { queryClient } from '@/utils/request'`
|
|
121
|
-
* @example `import { xxClient as queryClient } from '@/utils/request'`
|
|
122
|
-
*/
|
|
123
|
-
queryClientImportPath?: string;
|
|
124
|
-
/**
|
|
125
|
-
* 配置`RequestBuilder` 路径,导入的变量必须是命名为`RequestBuilder`
|
|
126
|
-
* @example `import RequestBuilder from '@/utils/RequestBuilder'`
|
|
127
|
-
* @default `import { RequestBuilder } from '@dune2/tools'`
|
|
128
|
-
*/
|
|
129
|
-
RequestBuilderImportPath?: string;
|
|
130
|
-
/**
|
|
131
|
-
* 是否启用ts,`true`会生成`.ts`文件,`false`会生成`.js`文件
|
|
132
|
-
* @default true
|
|
133
|
-
*/
|
|
134
|
-
enableTs?: boolean;
|
|
135
|
-
/**
|
|
136
|
-
* 响应的scheme转换,默认获取获取 data 字段,取不到回退到 scheme
|
|
137
|
-
* @default (schema) => schema.properties?.data ?? schema
|
|
138
|
-
*/
|
|
139
|
-
responseSchemaTransformer?: (schema: OpenAPIV3.SchemaObject) => any;
|
|
140
|
-
/**
|
|
141
|
-
* 生成代码完毕后是否自动格式化,默认格式化
|
|
142
|
-
* 需要安装 prettier
|
|
143
|
-
* @default true
|
|
144
|
-
*/
|
|
145
|
-
format?: boolean;
|
|
146
|
-
/**
|
|
147
|
-
* url 转换器,可以是字符串,也可以是函数
|
|
148
|
-
*
|
|
149
|
-
* 字符串会被当成prefix, 会在url前面加上
|
|
150
|
-
*
|
|
151
|
-
* 函数会被当成转换器
|
|
152
|
-
*/
|
|
153
|
-
urlTransformer?: string | ((url: string) => string);
|
|
154
|
-
}
|
|
155
|
-
interface Config {
|
|
156
|
-
i18n?: I18nConfig[];
|
|
157
|
-
api?: ApiConfig[];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
54
|
declare function defineConfig<T extends Config = Config>(c: T): T;
|
|
161
55
|
declare const configName = "dune.config.js";
|
|
162
56
|
declare function getConfig(): Promise<Config>;
|
|
163
57
|
|
|
164
|
-
export {
|
|
58
|
+
export { configName, defineConfig, getConfig, googleSheet, letterToNumber, numberToLetter, resolveSheetId };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { C as Config, A as ApiConfig } from './types-4aff0a8d.js';
|
|
2
|
+
import 'openapi-types';
|
|
3
|
+
|
|
4
|
+
declare function normalizeConfig(config: Config): Config;
|
|
5
|
+
declare function apiConfigNormalizer(item: ApiConfig): ApiConfig;
|
|
6
|
+
|
|
7
|
+
export { apiConfigNormalizer, normalizeConfig };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
|
|
3
|
+
interface I18nConfig {
|
|
4
|
+
i18nDir?: string;
|
|
5
|
+
i18nFileName?: string;
|
|
6
|
+
defaultLocale?: string;
|
|
7
|
+
/**
|
|
8
|
+
* 可以是 id 或者 url,如果是 url 则会自动解析出 id
|
|
9
|
+
* id: 1C9-Dol3oO20W9_FhiVlxNsDhOaaejJIgAZYRkonGmfk
|
|
10
|
+
* url: https://docs.google.com/spreadsheets/d/1C9-Dol3oO20W9_FhiVlxNsDhOaaejJIgAZYRkonGmfk/edit#gid=1740568548
|
|
11
|
+
*/
|
|
12
|
+
sheetId?: string;
|
|
13
|
+
sheetRange?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 对应 语言、i18nKey 所在的列标识符 如(A,B,C...)
|
|
16
|
+
* 传入时将忽略默认的配置
|
|
17
|
+
* @default {key: "B", zh: "C", en: "D", in: "E",}
|
|
18
|
+
*/
|
|
19
|
+
position?: {
|
|
20
|
+
key: string;
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 从 Google Sheets 哪一行开始解析
|
|
25
|
+
* 默认从第2行开始,模板文件第一行是表头
|
|
26
|
+
* @default 2
|
|
27
|
+
*/
|
|
28
|
+
parseStartIndex?: number;
|
|
29
|
+
/**
|
|
30
|
+
* 包括的文件
|
|
31
|
+
* glob 语法
|
|
32
|
+
*/
|
|
33
|
+
include?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* 是否禁用提取功能,某些项是不需要提取的,只需要同不Google sheet
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
disableExtract?: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface ApiConfig {
|
|
41
|
+
/**
|
|
42
|
+
* swagger JSON 的路径 可以是 本地 可以是远程
|
|
43
|
+
*/
|
|
44
|
+
swaggerJSONPath: string;
|
|
45
|
+
/**
|
|
46
|
+
* 用在生成代码里快捷连接跳转到 swagger ui
|
|
47
|
+
* 必须携带 urls.primaryName 参数
|
|
48
|
+
* @example http://192.168.104.10:31082/swagger/?urls.primaryName=%E5%90%8E%E5%8F%B0%E7%AE%A1%E7%90%86%E7%9B%B8%E5%85%B3API
|
|
49
|
+
*/
|
|
50
|
+
swaggerUiUrl?: string;
|
|
51
|
+
/**
|
|
52
|
+
* 输出的文件夹路径
|
|
53
|
+
* @default "./src/apis"
|
|
54
|
+
*/
|
|
55
|
+
output?: string;
|
|
56
|
+
/**
|
|
57
|
+
* 配置`requestFn` 方法引入的路径,生成的代码里会用到,生成代码如下
|
|
58
|
+
* 导入的变量必须是命名为`requestFn`
|
|
59
|
+
* ```ts
|
|
60
|
+
* // 需要命名为 requestFn
|
|
61
|
+
* import requestFn from '@/utils/request'
|
|
62
|
+
* import { foo as requestFn } from '@/utils/request'
|
|
63
|
+
* ```
|
|
64
|
+
* @default `import requestFn from '@/utils/request'`
|
|
65
|
+
* @deprecated 优先使用 `urlTransformer`
|
|
66
|
+
*/
|
|
67
|
+
requestFnImportPath?: string;
|
|
68
|
+
/**
|
|
69
|
+
* 配置`queryClient` 路径,导入的变量必须是命名为`queryClient`
|
|
70
|
+
* @example `import queryClient from '@/utils/request'`
|
|
71
|
+
* @example `import { queryClient } from '@/utils/request'`
|
|
72
|
+
* @example `import { xxClient as queryClient } from '@/utils/request'`
|
|
73
|
+
*/
|
|
74
|
+
queryClientImportPath?: string;
|
|
75
|
+
/**
|
|
76
|
+
* 配置`RequestBuilder` 路径,导入的变量必须是命名为`RequestBuilder`
|
|
77
|
+
* @example `import RequestBuilder from '@/utils/RequestBuilder'`
|
|
78
|
+
* @default `import { RequestBuilder } from '@dune2/tools'`
|
|
79
|
+
*/
|
|
80
|
+
RequestBuilderImportPath?: string;
|
|
81
|
+
/**
|
|
82
|
+
* 是否启用ts,`true`会生成`.ts`文件,`false`会生成`.js`文件
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
enableTs?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* 响应的scheme转换,默认获取获取 data 字段,取不到回退到 scheme
|
|
88
|
+
* @default (schema) => schema.properties?.data ?? schema
|
|
89
|
+
*/
|
|
90
|
+
responseSchemaTransformer?: (schema: OpenAPIV3.SchemaObject) => any;
|
|
91
|
+
/**
|
|
92
|
+
* 生成代码完毕后是否自动格式化,默认格式化
|
|
93
|
+
* 需要安装 prettier
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
format?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* url 转换器,可以是字符串,也可以是函数
|
|
99
|
+
*
|
|
100
|
+
* 字符串会被当成prefix, 会在url前面加上
|
|
101
|
+
*
|
|
102
|
+
* 函数会被当成转换器
|
|
103
|
+
*/
|
|
104
|
+
urlTransformer?: string | ((url: string) => string);
|
|
105
|
+
}
|
|
106
|
+
interface Config {
|
|
107
|
+
i18n?: I18nConfig[];
|
|
108
|
+
api?: ApiConfig[];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { ApiConfig as A, Config as C, I18nConfig as I };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dune2/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"./cli": {
|
|
10
10
|
"import": "./dist/cli.js"
|
|
11
11
|
},
|
|
12
|
+
"./normalizeConfig": {
|
|
13
|
+
"import": "./dist/normalizeConfig.js.js"
|
|
14
|
+
},
|
|
12
15
|
"./package.json": "./package.json"
|
|
13
16
|
},
|
|
14
17
|
"types": "dist/index.d.ts",
|