@toktokhan-dev/cli-plugin-gen-api-react-query 0.1.8 → 0.1.10
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/index.d.ts +5 -0
- package/dist/index.js +34 -15
- package/package.json +3 -3
- package/templates/my/react-query-type.eta +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,11 @@ type GenerateSwaggerApiConfig = SwaggerSchemaOption & {
|
|
|
58
58
|
* infiniteQuery 를 생성할 함수 필터 목록 입니다.
|
|
59
59
|
* */
|
|
60
60
|
paginationSets: PaginationConfig[];
|
|
61
|
+
/**
|
|
62
|
+
* SSL 인증서 검증 무시 여부입니다. (self-signed certificate 등 사용 시 true 로 설정)
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
ignoreTlsError?: boolean;
|
|
61
66
|
};
|
|
62
67
|
/**
|
|
63
68
|
* @category Commands
|
package/dist/index.js
CHANGED
|
@@ -121,10 +121,18 @@ const writeSwaggerApiFile = (params) => {
|
|
|
121
121
|
});
|
|
122
122
|
};
|
|
123
123
|
async function generatePretty(path, contents) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
// prettier-plugin-organize-imports가 설치되어 있으면 사용, 없으면 스킵
|
|
125
|
+
let organized = contents;
|
|
126
|
+
try {
|
|
127
|
+
organized = await prettierString(contents, {
|
|
128
|
+
parser: 'babel-ts',
|
|
129
|
+
plugins: ['prettier-plugin-organize-imports'],
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
// 플러그인이 없거나 에러 발생 시 원본 사용
|
|
134
|
+
console.warn('⚠️ prettier-plugin-organize-imports not found, skipping import organization');
|
|
135
|
+
}
|
|
128
136
|
const formatted = await prettierString(organized, {
|
|
129
137
|
parser: 'typescript',
|
|
130
138
|
configPath: 'auto',
|
|
@@ -197,8 +205,12 @@ const genApi = defineCommand({
|
|
|
197
205
|
nextKey: 'cursor',
|
|
198
206
|
},
|
|
199
207
|
],
|
|
208
|
+
ignoreTlsError: false,
|
|
200
209
|
},
|
|
201
210
|
run: async (config) => {
|
|
211
|
+
if (config.ignoreTlsError) {
|
|
212
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
213
|
+
}
|
|
202
214
|
if (config.swaggerSchemaUrls && config.swaggerSchemaUrls.length === 0) {
|
|
203
215
|
throw new Error('No URLs provided');
|
|
204
216
|
}
|
|
@@ -347,20 +359,27 @@ function mergeTypeScriptContent(existing, newContent) {
|
|
|
347
359
|
const mergedTypesString = Object.values(mergedTypes).join('\n\n');
|
|
348
360
|
// 3) 기타 코드(타입/임포트 외)는 "새로운 내용"을 기준으로 유지
|
|
349
361
|
const removeHeaderComment = (content) => {
|
|
350
|
-
// 파일 상단의 블록
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
return
|
|
354
|
-
}
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
return
|
|
358
|
-
}
|
|
359
|
-
|
|
362
|
+
// 파일 상단의 모든 블록 코멘트와 라인 코멘트를 제거 (재귀적 처리)
|
|
363
|
+
const removeBlockComment = (str) => {
|
|
364
|
+
const result = str.replace(/^\s*\/\*[\s\S]*?\*\/\s*/, '');
|
|
365
|
+
return result === str ? str : removeBlockComment(result);
|
|
366
|
+
};
|
|
367
|
+
const removeLineComment = (str) => {
|
|
368
|
+
const result = str.replace(/^(?:\s*\/\/.*\n)+/, '');
|
|
369
|
+
return result === str ? str : removeLineComment(result);
|
|
370
|
+
};
|
|
371
|
+
// 블록 주석 제거 후 라인 주석 제거
|
|
372
|
+
return removeLineComment(removeBlockComment(content));
|
|
360
373
|
};
|
|
361
374
|
// 새 본문에서 타입 블록 제거 후 남은 코드
|
|
362
375
|
const newBodyWithoutTypes = (newBody || '').replace(typeBlockRegex, '');
|
|
363
|
-
|
|
376
|
+
let otherCodeFromNew = removeHeaderComment(newBodyWithoutTypes).trim();
|
|
377
|
+
// 본문 내에 남아있는 "!DO NOT EDIT THIS FILE" 주석 블록들을 모두 제거
|
|
378
|
+
otherCodeFromNew = otherCodeFromNew.replace(/\/\*\*?\s*\*\s*!DO NOT EDIT THIS FILE[\s\S]*?\*\//g, '');
|
|
379
|
+
// "tok-cli.config.ts 에서 설정된..." 주석도 제거
|
|
380
|
+
otherCodeFromNew = otherCodeFromNew.replace(/\/\*\*?\s*\*\s*tok-cli\.config\.ts[\s\S]*?\*\//g, '');
|
|
381
|
+
// 연속된 빈 줄 정리
|
|
382
|
+
otherCodeFromNew = otherCodeFromNew.replace(/\n\s*\n\s*\n+/g, '\n\n').trim();
|
|
364
383
|
// 4) 헤더 주석은 새 컨텐츠 상단의 헤더가 있으면 우선 사용, 없으면 기존의 것을 사용
|
|
365
384
|
const pickHeader = (content) => {
|
|
366
385
|
const block = content.match(/^\s*(\/\*[\s\S]*?\*\/)\s*/);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toktokhan-dev/cli-plugin-gen-api-react-query",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "A CLI plugin for generating API hooks with React Query built by TOKTOKHAN.DEV",
|
|
5
5
|
"author": "TOKTOKHAN.DEV <fe-system@toktokhan.dev>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"lodash": "^4.17.21",
|
|
39
39
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
40
40
|
"swagger-typescript-api": "13.0.22",
|
|
41
|
-
"@toktokhan-dev/
|
|
42
|
-
"@toktokhan-dev/
|
|
41
|
+
"@toktokhan-dev/node": "0.0.10",
|
|
42
|
+
"@toktokhan-dev/cli": "0.0.11"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/lodash": "^4.17.0",
|
|
@@ -40,10 +40,11 @@ export type InfiniteQueryHookParams<
|
|
|
40
40
|
TData = RequestFnReturn<T>,
|
|
41
41
|
OriginData = RequestFnReturn<T>,
|
|
42
42
|
Variables = Parameter<T>,
|
|
43
|
+
TPageParam = string
|
|
43
44
|
> = {
|
|
44
45
|
options?: Partial<
|
|
45
46
|
Omit<
|
|
46
|
-
UseInfiniteQueryOptions<OriginData, Error, TData, any,
|
|
47
|
+
UseInfiniteQueryOptions<OriginData, Error, TData, OriginData, any, TPageParam>,
|
|
47
48
|
'queryKey' | 'queryFn'
|
|
48
49
|
>
|
|
49
50
|
>;
|
|
@@ -80,10 +81,11 @@ export type SuspenseInfiniteQueryHookParams<
|
|
|
80
81
|
TData = RequestFnReturn<T>,
|
|
81
82
|
OriginData = RequestFnReturn<T>,
|
|
82
83
|
Variables = Parameter<T>,
|
|
84
|
+
TPageParam = string
|
|
83
85
|
> = {
|
|
84
86
|
options?: Partial<
|
|
85
87
|
Omit<
|
|
86
|
-
UseSuspenseInfiniteQueryOptions<OriginData, Error, TData, any,
|
|
88
|
+
UseSuspenseInfiniteQueryOptions<OriginData, Error, TData, OriginData, any, TPageParam>,
|
|
87
89
|
'queryKey' | 'queryFn'
|
|
88
90
|
>
|
|
89
91
|
>;
|