@uiwwsw/react-query-helper 1.2.1 → 1.2.2

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +26 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -146,7 +146,7 @@ npm exec react-query-helper -- --generate
146
146
  | --- | --- | --- |
147
147
  | `sourceDir` | ✅ | API 함수가 포함된 TypeScript 디렉토리 (루트 기준 경로) |
148
148
  | `outputDir` | ✅ | 생성된 훅과 옵션 파일이 저장될 디렉토리 |
149
- | `ignoredFiles` | ❌ | 코드 생성에서 제외할 파일 이름 배열 |
149
+ | `ignoredFiles` | ❌ | 코드 생성에서 제외할 파일/경로 패턴 배열 (`domain.ts`, `**/*.spec.ts`, `admin/internal/**`) |
150
150
  | `templateDir` | ❌ | 생성된 코드에서 `queryOption` 계열을 import 할 모듈 경로 또는 상대 디렉토리 |
151
151
  | `analyzer` | ❌ | 어떤 함수를 읽을지 필터링하는 설정 (`exported-only`, `async-only`, include/exclude 등) |
152
152
  | `template` | ❌ | 어떤 아티팩트를 생성할지와 이름 규칙을 제어하는 설정 |
package/dist/cli.js CHANGED
@@ -1869,6 +1869,26 @@ function shouldProcess(filePath) {
1869
1869
  const extension = extname3(filePath).toLowerCase();
1870
1870
  return extension === ".ts" || extension === ".tsx";
1871
1871
  }
1872
+ function escapeRegExp(value) {
1873
+ return value.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
1874
+ }
1875
+ function globToRegExp(pattern) {
1876
+ const normalized = normalizeModulePath(pattern);
1877
+ const placeholder = "__DOUBLE_STAR__";
1878
+ const escaped = escapeRegExp(normalized).replace(/\*\*/g, placeholder).replace(/\*/g, "[^/]*").replace(new RegExp(placeholder, "g"), ".*");
1879
+ return new RegExp(`^${escaped}$`);
1880
+ }
1881
+ function isIgnoredFile(filePath) {
1882
+ const relativePath = normalizeModulePath(relative3(config.resolvedSourceDir, filePath));
1883
+ const fileName = basename3(filePath);
1884
+ return config.ignoredFiles?.some((pattern) => {
1885
+ const normalizedPattern = normalizeModulePath(pattern);
1886
+ if (!normalizedPattern.includes("/") && !normalizedPattern.includes("*")) {
1887
+ return fileName === normalizedPattern;
1888
+ }
1889
+ return globToRegExp(normalizedPattern).test(relativePath);
1890
+ }) ?? false;
1891
+ }
1872
1892
  function printUsage() {
1873
1893
  console.log("Usage: react-query-helper [init | generate | watch | help]");
1874
1894
  console.log(" react-query-helper [--init | --generate | --watch | --help]");
@@ -1949,7 +1969,7 @@ async function processFile(filePath) {
1949
1969
  }
1950
1970
  const relativeDir = dirname4(relativePath);
1951
1971
  const fileName = basename3(filePath, extname3(filePath));
1952
- if (config.ignoredFiles?.includes(basename3(filePath))) {
1972
+ if (isIgnoredFile(filePath)) {
1953
1973
  console.log(`Skipping ignored file: ${filePath}`);
1954
1974
  return;
1955
1975
  }
@@ -1995,7 +2015,7 @@ async function runGenerate() {
1995
2015
  const files = await new Promise((resolve5, reject) => {
1996
2016
  const results = [];
1997
2017
  const watcher = watch(sourcePath, {
1998
- ignored: config.ignoredFiles?.map((file) => join4(sourcePath, "**", file)) || [],
2018
+ ignored: (watchedPath) => isIgnoredFile(String(watchedPath)),
1999
2019
  ignoreInitial: false,
2000
2020
  depth: 99
2001
2021
  }).on("add", (path) => results.push(path)).on("ready", () => {
@@ -2024,23 +2044,23 @@ async function runWatch() {
2024
2044
  ensureDirectory(outputRootPath);
2025
2045
  console.log(`\uD83D\uDCC1 Ensured output directory exists at ${outputRootPath}`);
2026
2046
  watch(sourcePath, {
2027
- ignored: config.ignoredFiles?.map((file) => join4(sourcePath, "**", file)) || [],
2047
+ ignored: (watchedPath) => isIgnoredFile(String(watchedPath)),
2028
2048
  ignoreInitial: false,
2029
2049
  depth: 99
2030
2050
  }).on("add", async (filePath) => {
2031
- if (!shouldProcess(filePath)) {
2051
+ if (!shouldProcess(filePath) || isIgnoredFile(filePath)) {
2032
2052
  return;
2033
2053
  }
2034
2054
  console.log(`\uD83D\uDCC4 File added: ${filePath}`);
2035
2055
  await processFile(filePath);
2036
2056
  }).on("change", async (filePath) => {
2037
- if (!shouldProcess(filePath)) {
2057
+ if (!shouldProcess(filePath) || isIgnoredFile(filePath)) {
2038
2058
  return;
2039
2059
  }
2040
2060
  console.log(`\uD83D\uDD04 File changed: ${filePath}`);
2041
2061
  await processFile(filePath);
2042
2062
  }).on("unlink", async (filePath) => {
2043
- if (!shouldProcess(filePath)) {
2063
+ if (!shouldProcess(filePath) || isIgnoredFile(filePath)) {
2044
2064
  return;
2045
2065
  }
2046
2066
  console.log(`\uD83D\uDDD1️ File unlinked: ${filePath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiwwsw/react-query-helper",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "module": "dist/index.js",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",