@uiwwsw/react-query-helper 1.2.4 → 1.2.6
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/README.md +2 -1
- package/dist/cli.js +2 -2
- package/dist/config-loader.d.ts +31 -0
- package/dist/config-loader.d.ts.map +1 -0
- package/dist/config.d.ts +0 -29
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -229
- package/package.json +15 -2
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
|
|
50
50
|
- **설정 기반 자동화**: `rqh.config.ts`만 구성하면 API 디렉토리 감지부터 출력 디렉토리 지정까지 모두 자동화됩니다.
|
|
51
51
|
- **초기화 지원**: `react-query-helper --init`으로 기본 설정 파일을 바로 생성할 수 있습니다.
|
|
52
|
+
- **런타임/개발 분리**: generate/watch/config 로딩은 개발 시점 전용이고, 생성된 결과가 참조하는 런타임 helper 엔트리에는 `fs` 같은 Node 전용 코드가 포함되지 않도록 분리되어 있습니다.
|
|
52
53
|
- **Watch & Generate 모드**: 개발 중 실시간 감시(`--watch`), 초기 세팅이나 재생성 시 일괄 생성(`--generate`)을 모두 지원합니다.
|
|
53
54
|
- **일관된 옵션 관리**: `queryOption`, `mutationOption`, `infiniteOption` 유틸리티로 전역 캐싱 전략과 에러 핸들링을 통일할 수 있습니다.
|
|
54
55
|
- **Prettier 통합**: 생성된 파일은 자동으로 포맷팅되어 코드 리뷰 시 불필요한 변경을 줄입니다.
|
|
@@ -87,7 +88,7 @@ npm exec react-query-helper -- --init
|
|
|
87
88
|
|
|
88
89
|
```ts
|
|
89
90
|
// rqh.config.ts
|
|
90
|
-
import type { AutoQueryConfig } from "@uiwwsw/react-query-helper";
|
|
91
|
+
import type { AutoQueryConfig } from "@uiwwsw/react-query-helper/config";
|
|
91
92
|
|
|
92
93
|
const config: AutoQueryConfig = {
|
|
93
94
|
sourceDir: "./libs", // API 함수들이 위치한 경로
|
package/dist/cli.js
CHANGED
|
@@ -1707,7 +1707,7 @@ function generateOptionsCode(functionInfos, importPath, { keySegments, fileName,
|
|
|
1707
1707
|
return newContent;
|
|
1708
1708
|
}
|
|
1709
1709
|
|
|
1710
|
-
// src/config.ts
|
|
1710
|
+
// src/config-loader.ts
|
|
1711
1711
|
import { existsSync } from "fs";
|
|
1712
1712
|
import { readFile, unlink, writeFile } from "fs/promises";
|
|
1713
1713
|
import { randomUUID } from "crypto";
|
|
@@ -1814,7 +1814,7 @@ var config;
|
|
|
1814
1814
|
var customAnalyzerModule = null;
|
|
1815
1815
|
var customTemplateModule = null;
|
|
1816
1816
|
var DEFAULT_CONFIG_FILE_NAME = "rqh.config.ts";
|
|
1817
|
-
var DEFAULT_CONFIG_TEMPLATE = `import type { AutoQueryConfig } from "@uiwwsw/react-query-helper";
|
|
1817
|
+
var DEFAULT_CONFIG_TEMPLATE = `import type { AutoQueryConfig } from "@uiwwsw/react-query-helper/config";
|
|
1818
1818
|
|
|
1819
1819
|
const config: AutoQueryConfig = {
|
|
1820
1820
|
sourceDir: "./libs",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AutoQueryConfig } from "./config";
|
|
2
|
+
export declare class ConfigLoadError extends Error {
|
|
3
|
+
readonly configPath?: string | undefined;
|
|
4
|
+
readonly cause?: unknown | undefined;
|
|
5
|
+
constructor(message: string, configPath?: string | undefined, cause?: unknown | undefined);
|
|
6
|
+
}
|
|
7
|
+
export interface CustomAnalyzerModule {
|
|
8
|
+
analyzeFile: (filePath: string, config: ResolvedAutoQueryConfig) => Promise<unknown> | unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface CustomTemplateModule {
|
|
11
|
+
generateOptionsCode: (params: {
|
|
12
|
+
functionInfos: unknown[];
|
|
13
|
+
importPath: string;
|
|
14
|
+
keySegments: string[];
|
|
15
|
+
fileName: string;
|
|
16
|
+
templateImportPath: string;
|
|
17
|
+
config: ResolvedAutoQueryConfig;
|
|
18
|
+
}) => Promise<string> | string;
|
|
19
|
+
}
|
|
20
|
+
export interface ResolvedAutoQueryConfig extends AutoQueryConfig {
|
|
21
|
+
configPath?: string;
|
|
22
|
+
configDir: string;
|
|
23
|
+
resolvedSourceDir: string;
|
|
24
|
+
resolvedOutputDir: string;
|
|
25
|
+
resolvedTemplateDir?: string;
|
|
26
|
+
resolvedCustomAnalyzerPath?: string;
|
|
27
|
+
resolvedCustomTemplatePath?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function resolveConfigPath(cwd?: string): string | undefined;
|
|
30
|
+
export declare function loadConfig(): Promise<ResolvedAutoQueryConfig>;
|
|
31
|
+
//# sourceMappingURL=config-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,qBAAa,eAAgB,SAAQ,KAAK;aAGtB,UAAU,CAAC,EAAE,MAAM;aACnB,KAAK,CAAC,EAAE,OAAO;gBAF/B,OAAO,EAAE,MAAM,EACC,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,KAAK,CAAC,EAAE,OAAO,YAAA;CAKlC;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAChG;AAED,MAAM,WAAW,oBAAoB;IACnC,mBAAmB,EAAE,CAAC,MAAM,EAAE;QAC5B,aAAa,EAAE,OAAO,EAAE,CAAC;QACzB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC;QACjB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,MAAM,EAAE,uBAAuB,CAAC;KACjC,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC;AAkDD,wBAAgB,iBAAiB,CAAC,GAAG,SAAgB,sBAIpD;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAkDnE"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export declare class ConfigLoadError extends Error {
|
|
2
|
-
readonly configPath?: string | undefined;
|
|
3
|
-
readonly cause?: unknown | undefined;
|
|
4
|
-
constructor(message: string, configPath?: string | undefined, cause?: unknown | undefined);
|
|
5
|
-
}
|
|
6
1
|
import type { AnalyzerConfig } from "./core/analyzer";
|
|
7
2
|
import type { TemplateConfig } from "./core/generator";
|
|
8
3
|
export interface AutoQueryConfig {
|
|
@@ -16,28 +11,4 @@ export interface AutoQueryConfig {
|
|
|
16
11
|
customAnalyzerPath?: string;
|
|
17
12
|
customTemplatePath?: string;
|
|
18
13
|
}
|
|
19
|
-
export interface CustomAnalyzerModule {
|
|
20
|
-
analyzeFile: (filePath: string, config: ResolvedAutoQueryConfig) => Promise<unknown> | unknown;
|
|
21
|
-
}
|
|
22
|
-
export interface CustomTemplateModule {
|
|
23
|
-
generateOptionsCode: (params: {
|
|
24
|
-
functionInfos: unknown[];
|
|
25
|
-
importPath: string;
|
|
26
|
-
keySegments: string[];
|
|
27
|
-
fileName: string;
|
|
28
|
-
templateImportPath: string;
|
|
29
|
-
config: ResolvedAutoQueryConfig;
|
|
30
|
-
}) => Promise<string> | string;
|
|
31
|
-
}
|
|
32
|
-
export interface ResolvedAutoQueryConfig extends AutoQueryConfig {
|
|
33
|
-
configPath?: string;
|
|
34
|
-
configDir: string;
|
|
35
|
-
resolvedSourceDir: string;
|
|
36
|
-
resolvedOutputDir: string;
|
|
37
|
-
resolvedTemplateDir?: string;
|
|
38
|
-
resolvedCustomAnalyzerPath?: string;
|
|
39
|
-
resolvedCustomTemplatePath?: string;
|
|
40
|
-
}
|
|
41
|
-
export declare function resolveConfigPath(cwd?: string): string | undefined;
|
|
42
|
-
export declare function loadConfig(): Promise<ResolvedAutoQueryConfig>;
|
|
43
14
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
package/dist/config.js
ADDED
|
File without changes
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,226 +1,3 @@
|
|
|
1
|
-
// src/core/analyzer.ts
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import { readFileSync } from "fs";
|
|
4
|
-
function shouldIncludeFunction(info, config = {}) {
|
|
5
|
-
const exportFilter = config.exportFilter ?? "exported-only";
|
|
6
|
-
const functionMatchMode = config.functionMatchMode ?? "all";
|
|
7
|
-
if (exportFilter === "exported-only" && !info.isExported) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
if (functionMatchMode === "async-only" && !info.isAsync) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
if (functionMatchMode === "sync-only" && info.isAsync) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
if (config.includeNames?.length && !config.includeNames.includes(info.name)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
if (config.excludeNames?.includes(info.name)) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
function unwrapFunctionLike(node) {
|
|
25
|
-
if (!node) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
|
|
29
|
-
return node;
|
|
30
|
-
}
|
|
31
|
-
if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node)) {
|
|
32
|
-
return unwrapFunctionLike(node.expression);
|
|
33
|
-
}
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
function getFunctionInfo(name, parameters, isAsync, isExported, sourceFile) {
|
|
37
|
-
return {
|
|
38
|
-
name,
|
|
39
|
-
parameters: parameters.map((param) => param.name.getText(sourceFile)),
|
|
40
|
-
isAsync,
|
|
41
|
-
isExported
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function analyzeFile(filePath, config = {}) {
|
|
45
|
-
const sourceCode = readFileSync(filePath, "utf8");
|
|
46
|
-
const scriptKind = filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
47
|
-
const sourceFile = ts.createSourceFile(filePath, sourceCode, ts.ScriptTarget.Latest, true, scriptKind);
|
|
48
|
-
const functionInfos = [];
|
|
49
|
-
const hasExportModifier = (node) => ts.canHaveModifiers(node) && !!ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword);
|
|
50
|
-
ts.forEachChild(sourceFile, (node) => {
|
|
51
|
-
if (ts.isVariableStatement(node)) {
|
|
52
|
-
const isExported = hasExportModifier(node);
|
|
53
|
-
node.declarationList.declarations.forEach((declaration) => {
|
|
54
|
-
if (ts.isVariableDeclaration(declaration) && ts.isIdentifier(declaration.name)) {
|
|
55
|
-
const initializer = unwrapFunctionLike(declaration.initializer);
|
|
56
|
-
if (initializer) {
|
|
57
|
-
functionInfos.push(getFunctionInfo(declaration.name.text, initializer.parameters, !!initializer.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword), isExported, sourceFile));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
} else if (ts.isFunctionDeclaration(node) && node.name) {
|
|
62
|
-
functionInfos.push(getFunctionInfo(node.name.text, node.parameters, !!node.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword), hasExportModifier(node), sourceFile));
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return functionInfos.filter((info) => shouldIncludeFunction(info, config));
|
|
66
|
-
}
|
|
67
|
-
// src/core/generator.ts
|
|
68
|
-
var DEFAULT_IMPORT_NAMES = {
|
|
69
|
-
query: "queryOption",
|
|
70
|
-
mutation: "mutationOption",
|
|
71
|
-
infinite: "infiniteOption"
|
|
72
|
-
};
|
|
73
|
-
var DEFAULT_OUTPUT_NAMES = {
|
|
74
|
-
query: "QueryOption",
|
|
75
|
-
mutation: "MutationOption",
|
|
76
|
-
infinite: "InfiniteQueryOption"
|
|
77
|
-
};
|
|
78
|
-
function getKeySegments(info, fileName, keySegments, keyStyle) {
|
|
79
|
-
switch (keyStyle) {
|
|
80
|
-
case "function-only":
|
|
81
|
-
return [info.name];
|
|
82
|
-
case "file-only":
|
|
83
|
-
return [fileName, info.name];
|
|
84
|
-
case "path":
|
|
85
|
-
default:
|
|
86
|
-
return [...keySegments, info.name];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function generateOptionsCode(functionInfos, importPath, { keySegments, fileName, templateImportPath, template }) {
|
|
90
|
-
if (functionInfos.length === 0) {
|
|
91
|
-
return "";
|
|
92
|
-
}
|
|
93
|
-
const enabledArtifacts = template?.enabledArtifacts?.length ? template.enabledArtifacts : ["query", "mutation", "infinite"];
|
|
94
|
-
const importNames = {
|
|
95
|
-
...DEFAULT_IMPORT_NAMES,
|
|
96
|
-
...template?.importNames
|
|
97
|
-
};
|
|
98
|
-
const outputNames = {
|
|
99
|
-
...DEFAULT_OUTPUT_NAMES,
|
|
100
|
-
...template?.outputNames
|
|
101
|
-
};
|
|
102
|
-
const helperImports = enabledArtifacts.map((artifact) => importNames[artifact]);
|
|
103
|
-
const functionNames = functionInfos.map((info) => info.name);
|
|
104
|
-
const keyStyle = template?.keyStyle ?? "path";
|
|
105
|
-
let newContent = `import { ${functionNames.join(", ")} } from "${importPath}";
|
|
106
|
-
`;
|
|
107
|
-
newContent += `import { ${helperImports.join(", ")} } from "${templateImportPath}";
|
|
108
|
-
|
|
109
|
-
`;
|
|
110
|
-
functionInfos.forEach((info) => {
|
|
111
|
-
const keyArray = JSON.stringify(getKeySegments(info, fileName, keySegments, keyStyle));
|
|
112
|
-
const keyName = `${info.name}Key`;
|
|
113
|
-
newContent += `export const ${keyName} = ${keyArray} as const;
|
|
114
|
-
`;
|
|
115
|
-
enabledArtifacts.forEach((artifact) => {
|
|
116
|
-
newContent += `export const ${info.name}${outputNames[artifact]} = ${importNames[artifact]}(${keyName}, ${info.name});
|
|
117
|
-
`;
|
|
118
|
-
});
|
|
119
|
-
newContent += `
|
|
120
|
-
`;
|
|
121
|
-
});
|
|
122
|
-
return newContent;
|
|
123
|
-
}
|
|
124
|
-
// src/config.ts
|
|
125
|
-
import { existsSync } from "fs";
|
|
126
|
-
import { readFile, unlink, writeFile } from "fs/promises";
|
|
127
|
-
import { randomUUID } from "crypto";
|
|
128
|
-
import { dirname, extname, join, resolve } from "path";
|
|
129
|
-
import { pathToFileURL } from "url";
|
|
130
|
-
import ts2 from "typescript";
|
|
131
|
-
|
|
132
|
-
class ConfigLoadError extends Error {
|
|
133
|
-
configPath;
|
|
134
|
-
cause;
|
|
135
|
-
constructor(message, configPath, cause) {
|
|
136
|
-
super(message);
|
|
137
|
-
this.configPath = configPath;
|
|
138
|
-
this.cause = cause;
|
|
139
|
-
this.name = "ConfigLoadError";
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
var defaultConfig = {
|
|
143
|
-
sourceDir: "./libs",
|
|
144
|
-
outputDir: "./src/options",
|
|
145
|
-
ignoredFiles: ["domain.ts", "adaptor.ts"],
|
|
146
|
-
templateDir: "@uiwwsw/react-query-helper"
|
|
147
|
-
};
|
|
148
|
-
var CONFIG_FILE_NAMES = [
|
|
149
|
-
"rqh.config.ts",
|
|
150
|
-
"rqh.config.mts",
|
|
151
|
-
"rqh.config.cts",
|
|
152
|
-
"rqh.config.js",
|
|
153
|
-
"rqh.config.mjs",
|
|
154
|
-
"rqh.config.cjs"
|
|
155
|
-
];
|
|
156
|
-
var TYPESCRIPT_CONFIG_EXTENSIONS = new Set([".ts", ".mts", ".cts"]);
|
|
157
|
-
async function importTypeScriptConfig(configPath) {
|
|
158
|
-
const source = await readFile(configPath, "utf8");
|
|
159
|
-
const transpiled = ts2.transpileModule(source, {
|
|
160
|
-
compilerOptions: {
|
|
161
|
-
module: ts2.ModuleKind.ESNext,
|
|
162
|
-
target: ts2.ScriptTarget.ES2020,
|
|
163
|
-
moduleResolution: ts2.ModuleResolutionKind.Bundler,
|
|
164
|
-
esModuleInterop: true
|
|
165
|
-
},
|
|
166
|
-
fileName: configPath
|
|
167
|
-
});
|
|
168
|
-
const tempFilePath = join(dirname(configPath), `.rqh.config.${randomUUID()}.mjs`);
|
|
169
|
-
await writeFile(tempFilePath, transpiled.outputText, "utf8");
|
|
170
|
-
try {
|
|
171
|
-
return await import(pathToFileURL(tempFilePath).href);
|
|
172
|
-
} finally {
|
|
173
|
-
await unlink(tempFilePath).catch(() => {
|
|
174
|
-
return;
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
async function importConfig(configPath) {
|
|
179
|
-
if (TYPESCRIPT_CONFIG_EXTENSIONS.has(extname(configPath).toLowerCase())) {
|
|
180
|
-
return importTypeScriptConfig(configPath);
|
|
181
|
-
}
|
|
182
|
-
return import(pathToFileURL(configPath).href);
|
|
183
|
-
}
|
|
184
|
-
function resolveConfigPath(cwd = process.cwd()) {
|
|
185
|
-
return CONFIG_FILE_NAMES.map((fileName) => join(cwd, fileName)).find((configPath) => existsSync(configPath));
|
|
186
|
-
}
|
|
187
|
-
async function loadConfig() {
|
|
188
|
-
const configPath = resolveConfigPath();
|
|
189
|
-
if (configPath) {
|
|
190
|
-
const importedConfig = await importConfig(configPath).catch((error) => {
|
|
191
|
-
throw new ConfigLoadError(`Failed to load config from ${configPath}.`, configPath, error);
|
|
192
|
-
});
|
|
193
|
-
const userConfig = importedConfig.default ?? importedConfig;
|
|
194
|
-
if (!userConfig || typeof userConfig !== "object") {
|
|
195
|
-
throw new ConfigLoadError(`Config at ${configPath} must export an object.`, configPath);
|
|
196
|
-
}
|
|
197
|
-
const mergedConfig = {
|
|
198
|
-
...defaultConfig,
|
|
199
|
-
...userConfig
|
|
200
|
-
};
|
|
201
|
-
const configDir2 = dirname(configPath);
|
|
202
|
-
return {
|
|
203
|
-
...mergedConfig,
|
|
204
|
-
configPath,
|
|
205
|
-
configDir: configDir2,
|
|
206
|
-
resolvedSourceDir: resolve(configDir2, mergedConfig.sourceDir),
|
|
207
|
-
resolvedOutputDir: resolve(configDir2, mergedConfig.outputDir),
|
|
208
|
-
resolvedTemplateDir: mergedConfig.templateDir && mergedConfig.templateDir.startsWith(".") ? resolve(configDir2, mergedConfig.templateDir) : mergedConfig.templateDir,
|
|
209
|
-
resolvedCustomAnalyzerPath: mergedConfig.customAnalyzerPath && mergedConfig.customAnalyzerPath.startsWith(".") ? resolve(configDir2, mergedConfig.customAnalyzerPath) : mergedConfig.customAnalyzerPath,
|
|
210
|
-
resolvedCustomTemplatePath: mergedConfig.customTemplatePath && mergedConfig.customTemplatePath.startsWith(".") ? resolve(configDir2, mergedConfig.customTemplatePath) : mergedConfig.customTemplatePath
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
const configDir = process.cwd();
|
|
214
|
-
return {
|
|
215
|
-
...defaultConfig,
|
|
216
|
-
configDir,
|
|
217
|
-
resolvedSourceDir: resolve(configDir, defaultConfig.sourceDir),
|
|
218
|
-
resolvedOutputDir: resolve(configDir, defaultConfig.outputDir),
|
|
219
|
-
resolvedTemplateDir: defaultConfig.templateDir,
|
|
220
|
-
resolvedCustomAnalyzerPath: undefined,
|
|
221
|
-
resolvedCustomTemplatePath: undefined
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
1
|
// src/utils/query.ts
|
|
225
2
|
var queryOption = (key, fn) => {
|
|
226
3
|
return (...payload) => ({
|
|
@@ -257,12 +34,7 @@ var infiniteOption = (key, fn) => {
|
|
|
257
34
|
});
|
|
258
35
|
};
|
|
259
36
|
export {
|
|
260
|
-
resolveConfigPath,
|
|
261
37
|
queryOption,
|
|
262
38
|
mutationOption,
|
|
263
|
-
|
|
264
|
-
infiniteOption,
|
|
265
|
-
generateOptionsCode,
|
|
266
|
-
analyzeFile,
|
|
267
|
-
ConfigLoadError
|
|
39
|
+
infiniteOption
|
|
268
40
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiwwsw/react-query-helper",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"module": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,11 +40,24 @@
|
|
|
40
40
|
".": {
|
|
41
41
|
"import": "./dist/index.js",
|
|
42
42
|
"types": "./dist/index.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./config": {
|
|
45
|
+
"import": "./dist/config.js",
|
|
46
|
+
"types": "./dist/config.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./core/analyzer": {
|
|
49
|
+
"import": "./dist/core/analyzer.js",
|
|
50
|
+
"types": "./dist/core/analyzer.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./core/generator": {
|
|
53
|
+
"import": "./dist/core/generator.js",
|
|
54
|
+
"types": "./dist/core/generator.d.ts"
|
|
43
55
|
}
|
|
44
56
|
},
|
|
57
|
+
"sideEffects": false,
|
|
45
58
|
"scripts": {
|
|
46
59
|
"start": "bun run src/index.ts",
|
|
47
|
-
"build": "tsc && bun build src/cli.ts --outdir dist --target node --external typescript --external prettier && bun build src/index.ts --outdir dist --target node --external typescript --external prettier && node scripts/prepend-shebang.cjs dist/cli.js",
|
|
60
|
+
"build": "tsc && bun build src/cli.ts --outdir dist --target node --external typescript --external prettier && bun build src/index.ts --outdir dist --target node --external typescript --external prettier && bun build src/config.ts --outdir dist --target node --external typescript --external prettier && node scripts/prepend-shebang.cjs dist/cli.js",
|
|
48
61
|
"dev": "bun run src/cli.ts --watch",
|
|
49
62
|
"generate": "bun run src/cli.ts --generate"
|
|
50
63
|
},
|