@niche-works/dev 0.4.1 → 0.5.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.
Files changed (224) hide show
  1. package/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/addExports/addExports.cjs +61 -0
  3. package/addExports/addExports.cjs.map +1 -0
  4. package/addExports/addExports.d.cts +11 -0
  5. package/addExports/addExports.d.mts +12 -0
  6. package/addExports/addExports.mjs +59 -0
  7. package/addExports/addExports.mjs.map +1 -0
  8. package/addExports/index.cjs +3 -0
  9. package/addExports/index.d.cts +3 -0
  10. package/addExports/index.d.mts +3 -0
  11. package/addExports/index.mjs +3 -0
  12. package/addExports/types.cjs +0 -0
  13. package/{src/addExports/types.ts → addExports/types.d.cts} +33 -33
  14. package/addExports/types.d.mts +33 -0
  15. package/addExports/types.mjs +1 -0
  16. package/addJsExtensions/addJsExtensions.cjs +31 -0
  17. package/addJsExtensions/addJsExtensions.cjs.map +1 -0
  18. package/addJsExtensions/addJsExtensions.d.cts +8 -0
  19. package/addJsExtensions/addJsExtensions.d.mts +9 -0
  20. package/addJsExtensions/addJsExtensions.mjs +28 -0
  21. package/addJsExtensions/addJsExtensions.mjs.map +1 -0
  22. package/addJsExtensions/index.cjs +3 -0
  23. package/addJsExtensions/index.d.cts +2 -0
  24. package/addJsExtensions/index.d.mts +2 -0
  25. package/addJsExtensions/index.mjs +3 -0
  26. package/checkExistence/checkExistence.cjs +23 -0
  27. package/checkExistence/checkExistence.cjs.map +1 -0
  28. package/checkExistence/checkExistence.d.cts +9 -0
  29. package/checkExistence/checkExistence.d.mts +10 -0
  30. package/checkExistence/checkExistence.mjs +21 -0
  31. package/checkExistence/checkExistence.mjs.map +1 -0
  32. package/checkExistence/index.cjs +3 -0
  33. package/checkExistence/index.d.cts +2 -0
  34. package/checkExistence/index.d.mts +2 -0
  35. package/checkExistence/index.mjs +3 -0
  36. package/createExternalOptionFunction/createExternalOptionFunction.cjs +25 -0
  37. package/createExternalOptionFunction/createExternalOptionFunction.cjs.map +1 -0
  38. package/createExternalOptionFunction/createExternalOptionFunction.d.cts +10 -0
  39. package/createExternalOptionFunction/createExternalOptionFunction.d.mts +11 -0
  40. package/createExternalOptionFunction/createExternalOptionFunction.mjs +25 -0
  41. package/createExternalOptionFunction/createExternalOptionFunction.mjs.map +1 -0
  42. package/createExternalOptionFunction/index.cjs +3 -0
  43. package/createExternalOptionFunction/index.d.cts +2 -0
  44. package/createExternalOptionFunction/index.d.mts +2 -0
  45. package/createExternalOptionFunction/index.mjs +3 -0
  46. package/createExternalOptionFunction/types.cjs +0 -0
  47. package/{src/createExternalOptionFunction/types.ts → createExternalOptionFunction/types.d.cts} +31 -34
  48. package/createExternalOptionFunction/types.d.mts +31 -0
  49. package/createExternalOptionFunction/types.mjs +1 -0
  50. package/createSassClassNameFunction/createSassClassNameFunction.cjs +19 -0
  51. package/createSassClassNameFunction/createSassClassNameFunction.cjs.map +1 -0
  52. package/createSassClassNameFunction/createSassClassNameFunction.d.cts +11 -0
  53. package/createSassClassNameFunction/createSassClassNameFunction.d.mts +12 -0
  54. package/createSassClassNameFunction/createSassClassNameFunction.mjs +18 -0
  55. package/createSassClassNameFunction/createSassClassNameFunction.mjs.map +1 -0
  56. package/createSassClassNameFunction/index.cjs +3 -0
  57. package/createSassClassNameFunction/index.d.cts +2 -0
  58. package/createSassClassNameFunction/index.d.mts +2 -0
  59. package/createSassClassNameFunction/index.mjs +3 -0
  60. package/editJsonFile/editJsonFile.cjs +29 -0
  61. package/editJsonFile/editJsonFile.cjs.map +1 -0
  62. package/editJsonFile/editJsonFile.d.cts +9 -0
  63. package/editJsonFile/editJsonFile.d.mts +10 -0
  64. package/editJsonFile/editJsonFile.mjs +26 -0
  65. package/editJsonFile/editJsonFile.mjs.map +1 -0
  66. package/editJsonFile/index.cjs +3 -0
  67. package/editJsonFile/index.d.cts +2 -0
  68. package/editJsonFile/index.d.mts +2 -0
  69. package/editJsonFile/index.mjs +3 -0
  70. package/generatePublishPackageJson/generatePublishPackageJson.cjs +46 -0
  71. package/generatePublishPackageJson/generatePublishPackageJson.cjs.map +1 -0
  72. package/generatePublishPackageJson/generatePublishPackageJson.d.cts +6 -0
  73. package/generatePublishPackageJson/generatePublishPackageJson.d.mts +7 -0
  74. package/generatePublishPackageJson/generatePublishPackageJson.mjs +44 -0
  75. package/generatePublishPackageJson/generatePublishPackageJson.mjs.map +1 -0
  76. package/generatePublishPackageJson/index.cjs +3 -0
  77. package/generatePublishPackageJson/index.d.cts +3 -0
  78. package/generatePublishPackageJson/index.d.mts +3 -0
  79. package/generatePublishPackageJson/index.mjs +3 -0
  80. package/generatePublishPackageJson/types.cjs +0 -0
  81. package/{src/generatePublishPackageJson/types.ts → generatePublishPackageJson/types.d.cts} +60 -61
  82. package/generatePublishPackageJson/types.d.mts +60 -0
  83. package/generatePublishPackageJson/types.mjs +1 -0
  84. package/index.cjs +41 -0
  85. package/index.d.cts +14 -0
  86. package/index.d.mts +14 -0
  87. package/index.mjs +28 -0
  88. package/indexes/constants.cjs +123 -0
  89. package/indexes/constants.cjs.map +1 -0
  90. package/indexes/constants.d.cts +66 -0
  91. package/indexes/constants.d.mts +66 -0
  92. package/indexes/constants.mjs +106 -0
  93. package/indexes/constants.mjs.map +1 -0
  94. package/indexes/index.cjs +3 -0
  95. package/indexes/index.d.cts +3 -0
  96. package/indexes/index.d.mts +3 -0
  97. package/indexes/index.mjs +3 -0
  98. package/indexes/indexes.cjs +125 -0
  99. package/indexes/indexes.cjs.map +1 -0
  100. package/indexes/indexes.d.cts +11 -0
  101. package/indexes/indexes.d.mts +12 -0
  102. package/indexes/indexes.mjs +123 -0
  103. package/indexes/indexes.mjs.map +1 -0
  104. package/indexes/types.cjs +0 -0
  105. package/{src/indexes/types.ts → indexes/types.d.cts} +81 -87
  106. package/indexes/types.d.mts +81 -0
  107. package/indexes/types.mjs +1 -0
  108. package/installFromLocal/index.cjs +3 -0
  109. package/installFromLocal/index.d.cts +3 -0
  110. package/installFromLocal/index.d.mts +3 -0
  111. package/installFromLocal/index.mjs +3 -0
  112. package/installFromLocal/installFromLocal.cjs +46 -0
  113. package/installFromLocal/installFromLocal.cjs.map +1 -0
  114. package/installFromLocal/installFromLocal.d.cts +11 -0
  115. package/installFromLocal/installFromLocal.d.mts +12 -0
  116. package/installFromLocal/installFromLocal.mjs +43 -0
  117. package/installFromLocal/installFromLocal.mjs.map +1 -0
  118. package/installFromLocal/types.cjs +0 -0
  119. package/{src/installFromLocal/types.ts → installFromLocal/types.d.cts} +21 -19
  120. package/installFromLocal/types.d.mts +21 -0
  121. package/installFromLocal/types.mjs +1 -0
  122. package/isMatchingPath/index.cjs +3 -0
  123. package/isMatchingPath/index.d.cts +3 -0
  124. package/isMatchingPath/index.d.mts +3 -0
  125. package/isMatchingPath/index.mjs +3 -0
  126. package/isMatchingPath/isMatchingPath.cjs +52 -0
  127. package/isMatchingPath/isMatchingPath.cjs.map +1 -0
  128. package/isMatchingPath/isMatchingPath.d.cts +13 -0
  129. package/isMatchingPath/isMatchingPath.d.mts +14 -0
  130. package/isMatchingPath/isMatchingPath.mjs +50 -0
  131. package/isMatchingPath/isMatchingPath.mjs.map +1 -0
  132. package/isMatchingPath/types.cjs +0 -0
  133. package/isMatchingPath/types.d.cts +72 -0
  134. package/isMatchingPath/types.d.mts +72 -0
  135. package/isMatchingPath/types.mjs +1 -0
  136. package/isTargetPath/index.cjs +3 -0
  137. package/isTargetPath/index.d.cts +3 -0
  138. package/isTargetPath/index.d.mts +3 -0
  139. package/isTargetPath/index.mjs +3 -0
  140. package/isTargetPath/isTargetPath.cjs +21 -0
  141. package/isTargetPath/isTargetPath.cjs.map +1 -0
  142. package/isTargetPath/isTargetPath.d.cts +7 -0
  143. package/isTargetPath/isTargetPath.d.mts +8 -0
  144. package/isTargetPath/isTargetPath.mjs +19 -0
  145. package/isTargetPath/isTargetPath.mjs.map +1 -0
  146. package/isTargetPath/types.cjs +0 -0
  147. package/{src/isTargetPath/types.ts → isTargetPath/types.d.cts} +33 -38
  148. package/isTargetPath/types.d.mts +33 -0
  149. package/isTargetPath/types.mjs +1 -0
  150. package/moveFilesToSubdir/index.cjs +3 -0
  151. package/moveFilesToSubdir/index.d.cts +3 -0
  152. package/moveFilesToSubdir/index.d.mts +3 -0
  153. package/moveFilesToSubdir/index.mjs +3 -0
  154. package/moveFilesToSubdir/moveFilesToSubdir.cjs +32 -0
  155. package/moveFilesToSubdir/moveFilesToSubdir.cjs.map +1 -0
  156. package/moveFilesToSubdir/moveFilesToSubdir.d.cts +10 -0
  157. package/moveFilesToSubdir/moveFilesToSubdir.d.mts +11 -0
  158. package/moveFilesToSubdir/moveFilesToSubdir.mjs +29 -0
  159. package/moveFilesToSubdir/moveFilesToSubdir.mjs.map +1 -0
  160. package/moveFilesToSubdir/types.cjs +0 -0
  161. package/{src/moveFilesToSubdir/types.ts → moveFilesToSubdir/types.d.cts} +18 -15
  162. package/moveFilesToSubdir/types.d.mts +18 -0
  163. package/moveFilesToSubdir/types.mjs +1 -0
  164. package/package.json +21 -29
  165. package/removeFiles/index.cjs +3 -0
  166. package/removeFiles/index.d.cts +2 -0
  167. package/removeFiles/index.d.mts +2 -0
  168. package/removeFiles/index.mjs +3 -0
  169. package/removeFiles/removeFiles.cjs +15 -0
  170. package/removeFiles/removeFiles.cjs.map +1 -0
  171. package/removeFiles/removeFiles.d.cts +6 -0
  172. package/removeFiles/removeFiles.d.mts +7 -0
  173. package/removeFiles/removeFiles.mjs +12 -0
  174. package/removeFiles/removeFiles.mjs.map +1 -0
  175. package/removeFiles/types.cjs +0 -0
  176. package/removeFiles/types.d.cts +9 -0
  177. package/removeFiles/types.d.mts +9 -0
  178. package/removeFiles/types.mjs +1 -0
  179. package/ver/index.cjs +3 -0
  180. package/ver/index.d.cts +3 -0
  181. package/ver/index.d.mts +3 -0
  182. package/ver/index.mjs +3 -0
  183. package/ver/types.cjs +0 -0
  184. package/{src/ver/types.ts → ver/types.d.cts} +16 -13
  185. package/ver/types.d.mts +16 -0
  186. package/ver/types.mjs +1 -0
  187. package/ver/ver.cjs +34 -0
  188. package/ver/ver.cjs.map +1 -0
  189. package/ver/ver.d.cts +11 -0
  190. package/ver/ver.d.mts +12 -0
  191. package/ver/ver.mjs +31 -0
  192. package/ver/ver.mjs.map +1 -0
  193. package/src/addExports/addExports.ts +0 -94
  194. package/src/addExports/index.ts +0 -2
  195. package/src/addJsExtensions/addJsExtensions.ts +0 -30
  196. package/src/addJsExtensions/index.ts +0 -1
  197. package/src/checkExistence/checkExistence.ts +0 -16
  198. package/src/checkExistence/index.ts +0 -1
  199. package/src/createExternalOptionFunction/createExternalOptionFunction.ts +0 -43
  200. package/src/createExternalOptionFunction/index.ts +0 -1
  201. package/src/editJsonFile/editJsonFile.ts +0 -30
  202. package/src/editJsonFile/index.ts +0 -1
  203. package/src/generatePublishPackageJson/generatePublishPackageJson.ts +0 -55
  204. package/src/generatePublishPackageJson/index.ts +0 -2
  205. package/src/index.ts +0 -11
  206. package/src/indexes/constants.ts +0 -135
  207. package/src/indexes/index.ts +0 -2
  208. package/src/indexes/indexes.ts +0 -194
  209. package/src/installFromLocal/index.ts +0 -2
  210. package/src/installFromLocal/installFromLocal.ts +0 -63
  211. package/src/isMatchingPath/index.ts +0 -2
  212. package/src/isMatchingPath/isMatchingPath.ts +0 -94
  213. package/src/isMatchingPath/types.ts +0 -95
  214. package/src/isTargetPath/index.ts +0 -2
  215. package/src/isTargetPath/isTargetPath.ts +0 -30
  216. package/src/moveFilesToSubdir/index.ts +0 -2
  217. package/src/moveFilesToSubdir/moveFilesToSubdir.ts +0 -40
  218. package/src/removeFiles/index.ts +0 -1
  219. package/src/removeFiles/removeFiles.ts +0 -11
  220. package/src/removeFiles/types.ts +0 -5
  221. package/src/ver/index.ts +0 -2
  222. package/src/ver/ver.ts +0 -38
  223. package/tsconfig.json +0 -46
  224. package/tsdown.config.ts +0 -41
@@ -0,0 +1,12 @@
1
+ import { InstallFromLocalOptions } from "./types.mjs";
2
+
3
+ //#region src/installFromLocal/installFromLocal.d.ts
4
+ /**
5
+ * ローカルに配置されたパッケージを差し替える
6
+ * @param localNodeModulesPath ローカルのnode_modulesディレクトリのパス
7
+ * @param options オプション
8
+ */
9
+ declare function installFromLocal(localNodeModulesPath: string, options?: InstallFromLocalOptions): void;
10
+ //#endregion
11
+ export { installFromLocal as default };
12
+ //# sourceMappingURL=installFromLocal.d.mts.map
@@ -0,0 +1,43 @@
1
+ import checkExistence from "../checkExistence/checkExistence.mjs";
2
+ import "../checkExistence/index.mjs";
3
+ import fs from "fs-extra";
4
+ import path from "path";
5
+ import { reduce } from "remeda";
6
+
7
+ //#region src/installFromLocal/installFromLocal.ts
8
+ /**
9
+ * ローカルに配置されたパッケージを差し替える
10
+ * @param localNodeModulesPath ローカルのnode_modulesディレクトリのパス
11
+ * @param options オプション
12
+ */
13
+ function installFromLocal(localNodeModulesPath, options = {}) {
14
+ const { packageJsonPath = "./package.json", nodeModulesPath = "./node_modules", dryRun } = options;
15
+ const resolvedLocalNodeModulesPath = path.resolve(localNodeModulesPath);
16
+ const resolvedPackageJsonPath = path.resolve(packageJsonPath);
17
+ if (!checkExistence(resolvedLocalNodeModulesPath, resolvedPackageJsonPath)) return;
18
+ console.info(`${localNodeModulesPath} -> ${nodeModulesPath}`);
19
+ const packageJson = fs.readJSONSync(resolvedPackageJsonPath);
20
+ const localPackages = reduce({
21
+ ...packageJson.dependencies,
22
+ ...packageJson.devDependencies
23
+ }, (result, value, key) => {
24
+ if (value.startsWith(localNodeModulesPath)) result[key] = value;
25
+ else if (value.startsWith(`file:${localNodeModulesPath}`)) result[key] = value.substring(5);
26
+ return result;
27
+ }, {});
28
+ for (const packageName in localPackages) {
29
+ const localPackagePath = path.resolve(localPackages[packageName]);
30
+ if (fs.existsSync(localPackagePath)) {
31
+ const installedPackagePath = path.resolve(nodeModulesPath, packageName);
32
+ if (!dryRun) {
33
+ if (fs.existsSync(installedPackagePath)) fs.removeSync(installedPackagePath);
34
+ fs.copySync(localPackagePath, installedPackagePath);
35
+ }
36
+ console.info(`${packageName} is being copied...`);
37
+ }
38
+ }
39
+ }
40
+
41
+ //#endregion
42
+ export { installFromLocal as default };
43
+ //# sourceMappingURL=installFromLocal.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installFromLocal.mjs","names":[],"sources":["../../src/installFromLocal/installFromLocal.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport path from 'path';\r\nimport { reduce } from 'remeda';\r\nimport checkExistence from '../checkExistence';\r\nimport type { InstallFromLocalOptions } from './types';\r\n\r\n/**\r\n * ローカルに配置されたパッケージを差し替える\r\n * @param localNodeModulesPath ローカルのnode_modulesディレクトリのパス\r\n * @param options オプション\r\n */\r\nexport default function installFromLocal(\r\n localNodeModulesPath: string,\r\n options: InstallFromLocalOptions = {},\r\n) {\r\n const {\r\n packageJsonPath = './package.json',\r\n nodeModulesPath = './node_modules',\r\n dryRun,\r\n } = options;\r\n const resolvedLocalNodeModulesPath = path.resolve(localNodeModulesPath);\r\n const resolvedPackageJsonPath = path.resolve(packageJsonPath);\r\n\r\n if (!checkExistence(resolvedLocalNodeModulesPath, resolvedPackageJsonPath)) {\r\n return;\r\n }\r\n\r\n console.info(`${localNodeModulesPath} -> ${nodeModulesPath}`);\r\n\r\n // package.jsonからローカルのnode_modulesにあるパッケージを取得\r\n const packageJson = fs.readJSONSync(resolvedPackageJsonPath);\r\n const localPackages = reduce(\r\n { ...packageJson.dependencies, ...packageJson.devDependencies },\r\n (result: Record<string, string>, value: string, key) => {\r\n if (value.startsWith(localNodeModulesPath)) {\r\n result[key] = value;\r\n } else if (value.startsWith(`file:${localNodeModulesPath}`)) {\r\n result[key] = value.substring(5);\r\n }\r\n return result;\r\n },\r\n {},\r\n );\r\n\r\n for (const packageName in localPackages) {\r\n // ローカルパッケージの確認\r\n const localPackagePath = path.resolve(localPackages[packageName]);\r\n if (fs.existsSync(localPackagePath)) {\r\n // ローカルパッケージがある場合のみ処理\r\n const installedPackagePath = path.resolve(nodeModulesPath, packageName);\r\n if (!dryRun) {\r\n // コピーを行う\r\n if (fs.existsSync(installedPackagePath)) {\r\n // 古いパッケージは削除\r\n fs.removeSync(installedPackagePath);\r\n }\r\n // パッケージをコピー\r\n fs.copySync(localPackagePath, installedPackagePath);\r\n }\r\n console.info(`${packageName} is being copied...`);\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAWA,SAAwB,iBACtB,sBACA,UAAmC,EAAE,EACrC;CACA,MAAM,EACJ,kBAAkB,kBAClB,kBAAkB,kBAClB,WACE;CACJ,MAAM,+BAA+B,KAAK,QAAQ,qBAAqB;CACvE,MAAM,0BAA0B,KAAK,QAAQ,gBAAgB;AAE7D,KAAI,CAAC,eAAe,8BAA8B,wBAAwB,CACxE;AAGF,SAAQ,KAAK,GAAG,qBAAqB,MAAM,kBAAkB;CAG7D,MAAM,cAAc,GAAG,aAAa,wBAAwB;CAC5D,MAAM,gBAAgB,OACpB;EAAE,GAAG,YAAY;EAAc,GAAG,YAAY;EAAiB,GAC9D,QAAgC,OAAe,QAAQ;AACtD,MAAI,MAAM,WAAW,qBAAqB,CACxC,QAAO,OAAO;WACL,MAAM,WAAW,QAAQ,uBAAuB,CACzD,QAAO,OAAO,MAAM,UAAU,EAAE;AAElC,SAAO;IAET,EAAE,CACH;AAED,MAAK,MAAM,eAAe,eAAe;EAEvC,MAAM,mBAAmB,KAAK,QAAQ,cAAc,aAAa;AACjE,MAAI,GAAG,WAAW,iBAAiB,EAAE;GAEnC,MAAM,uBAAuB,KAAK,QAAQ,iBAAiB,YAAY;AACvE,OAAI,CAAC,QAAQ;AAEX,QAAI,GAAG,WAAW,qBAAqB,CAErC,IAAG,WAAW,qBAAqB;AAGrC,OAAG,SAAS,kBAAkB,qBAAqB;;AAErD,WAAQ,KAAK,GAAG,YAAY,qBAAqB"}
File without changes
@@ -1,19 +1,21 @@
1
- export type InstallFromLocalOptions = {
2
- /**
3
- * package.jsonのパス
4
- * @default './package.json'
5
- */
6
- packageJsonPath?: string;
7
-
8
- /**
9
- * node_modulesのパス
10
- * @default './node_modules'
11
- */
12
- nodeModulesPath?: string;
13
-
14
- /**
15
- * お試し
16
- * ファイルの操作は行わない
17
- */
18
- dryRun?: boolean;
19
- };
1
+ //#region src/installFromLocal/types.d.ts
2
+ type InstallFromLocalOptions = {
3
+ /**
4
+ * package.jsonのパス
5
+ * @default './package.json'
6
+ */
7
+ packageJsonPath?: string;
8
+ /**
9
+ * node_modulesのパス
10
+ * @default './node_modules'
11
+ */
12
+ nodeModulesPath?: string;
13
+ /**
14
+ * お試し
15
+ * ファイルの操作は行わない
16
+ */
17
+ dryRun?: boolean;
18
+ };
19
+ //#endregion
20
+ export { InstallFromLocalOptions };
21
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1,21 @@
1
+ //#region src/installFromLocal/types.d.ts
2
+ type InstallFromLocalOptions = {
3
+ /**
4
+ * package.jsonのパス
5
+ * @default './package.json'
6
+ */
7
+ packageJsonPath?: string;
8
+ /**
9
+ * node_modulesのパス
10
+ * @default './node_modules'
11
+ */
12
+ nodeModulesPath?: string;
13
+ /**
14
+ * お試し
15
+ * ファイルの操作は行わない
16
+ */
17
+ dryRun?: boolean;
18
+ };
19
+ //#endregion
20
+ export { InstallFromLocalOptions };
21
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,3 @@
1
+ const require_isMatchingPath_isMatchingPath = require('./isMatchingPath.cjs');
2
+
3
+ module.exports = require_isMatchingPath_isMatchingPath;
@@ -0,0 +1,3 @@
1
+ import { ConditionConfig, ConditionFn, ConditionFnOptions, ConditionValues, IsMatchingPathCondition, IsMatchingPathOptions } from "./types.cjs";
2
+ import isMatchingPath from "./isMatchingPath.cjs";
3
+ export { ConditionConfig, ConditionFn, ConditionFnOptions, ConditionValues, IsMatchingPathCondition, IsMatchingPathOptions, isMatchingPath as default };
@@ -0,0 +1,3 @@
1
+ import { ConditionConfig, ConditionFn, ConditionFnOptions, ConditionValues, IsMatchingPathCondition, IsMatchingPathOptions } from "./types.mjs";
2
+ import isMatchingPath from "./isMatchingPath.mjs";
3
+ export { ConditionConfig, ConditionFn, ConditionFnOptions, ConditionValues, IsMatchingPathCondition, IsMatchingPathOptions, isMatchingPath as default };
@@ -0,0 +1,3 @@
1
+ import isMatchingPath from "./isMatchingPath.mjs";
2
+
3
+ export { isMatchingPath as default };
@@ -0,0 +1,52 @@
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ let fs_extra = require("fs-extra");
3
+ fs_extra = require_runtime.__toESM(fs_extra, 1);
4
+ let path = require("path");
5
+ let remeda = require("remeda");
6
+
7
+ //#region src/isMatchingPath/isMatchingPath.ts
8
+ /**
9
+ * 処理対象のパスか判定する
10
+ * @param targetPath 検査対象のパス
11
+ * @param conditions 一致条件
12
+ * @param options オプション
13
+ * @returns 一致するか
14
+ */
15
+ function isMatchingPath(targetPath, conditions, options = {}) {
16
+ if (!conditions) return false;
17
+ const conditionList = Array.isArray(conditions) ? conditions : [conditions];
18
+ const posixPath = path.posix.normalize(targetPath);
19
+ const parsedPath = path.posix.parse(posixPath);
20
+ const parsedDir = path.posix.parse(parsedPath.dir);
21
+ const values = {
22
+ path: posixPath,
23
+ ...parsedPath,
24
+ dirpath: parsedPath.dir,
25
+ dirbase: parsedDir.base,
26
+ dirname: parsedDir.name,
27
+ dirext: parsedDir.ext
28
+ };
29
+ values.path = posixPath;
30
+ for (const condition of conditionList) if (_isMatching(values.path, values, condition, options)) return true;
31
+ return false;
32
+ }
33
+ function _isMatching(value, values, condition, options) {
34
+ if ((0, remeda.isString)(condition)) {
35
+ if (value.includes(condition)) return true;
36
+ } else if (condition instanceof RegExp) {
37
+ if (condition.test(value)) return true;
38
+ } else if ((0, remeda.isFunction)(condition)) return condition(values, options.conditionOptions ?? {});
39
+ else {
40
+ const { valueType = "path", entryType = "both", conditions } = condition;
41
+ if (entryType !== "both") {
42
+ const stat = fs_extra.default.statSync(values.path);
43
+ if (stat.isDirectory() && entryType !== "dir" || stat.isFile() && entryType !== "file") return false;
44
+ }
45
+ return (Array.isArray(conditions) ? conditions : [conditions]).every((cond) => _isMatching(values[valueType], values, cond, options));
46
+ }
47
+ return false;
48
+ }
49
+
50
+ //#endregion
51
+ module.exports = isMatchingPath;
52
+ //# sourceMappingURL=isMatchingPath.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMatchingPath.cjs","names":["fs"],"sources":["../../src/isMatchingPath/isMatchingPath.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport { posix as path } from 'path';\r\nimport { isFunction, isString } from 'remeda';\r\nimport type {\r\n ConditionFnOptions,\r\n ConditionValues,\r\n IsMatchingPathCondition,\r\n IsMatchingPathOptions,\r\n} from './types';\r\n\r\n/**\r\n * 処理対象のパスか判定する\r\n * @param targetPath 検査対象のパス\r\n * @param conditions 一致条件\r\n * @param options オプション\r\n * @returns 一致するか\r\n */\r\nexport default function isMatchingPath<\r\n O extends ConditionFnOptions = ConditionFnOptions,\r\n>(\r\n targetPath: string,\r\n conditions:\r\n | IsMatchingPathCondition<O>\r\n | IsMatchingPathCondition<O>[]\r\n | null\r\n | undefined,\r\n options: IsMatchingPathOptions<O> = {},\r\n) {\r\n if (!conditions) {\r\n return false;\r\n }\r\n const conditionList = Array.isArray(conditions) ? conditions : [conditions];\r\n // パスは'/'区切り\r\n const posixPath = path.normalize(targetPath);\r\n const parsedPath = path.parse(posixPath);\r\n const parsedDir = path.parse(parsedPath.dir);\r\n const values = {\r\n path: posixPath,\r\n ...parsedPath,\r\n dirpath: parsedPath.dir,\r\n dirbase: parsedDir.base,\r\n dirname: parsedDir.name,\r\n dirext: parsedDir.ext,\r\n };\r\n values.path = posixPath;\r\n\r\n for (const condition of conditionList) {\r\n if (_isMatching(values.path, values, condition, options)) {\r\n // conditionの内の何れかがtrueならば一致\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nfunction _isMatching<O extends ConditionFnOptions = ConditionFnOptions>(\r\n value: string,\r\n values: ConditionValues,\r\n condition: IsMatchingPathCondition<O>,\r\n options: IsMatchingPathOptions<O>,\r\n): boolean {\r\n if (isString(condition)) {\r\n // 条件が文字列\r\n if (value.includes(condition)) {\r\n return true;\r\n }\r\n } else if (condition instanceof RegExp) {\r\n // 条件が正規表現\r\n if (condition.test(value)) {\r\n return true;\r\n }\r\n } else if (isFunction(condition)) {\r\n // 条件が関数\r\n return condition(values, (options.conditionOptions ?? {}) as O);\r\n } else {\r\n // 条件が設定\r\n const { valueType = 'path', entryType = 'both', conditions } = condition;\r\n if (entryType !== 'both') {\r\n const stat = fs.statSync(values.path);\r\n if (\r\n (stat.isDirectory() && entryType !== 'dir') ||\r\n (stat.isFile() && entryType !== 'file')\r\n ) {\r\n return false;\r\n }\r\n }\r\n const conditionList = Array.isArray(conditions) ? conditions : [conditions];\r\n // 設定配下のconditionsはand条件\r\n return conditionList.every((cond) =>\r\n _isMatching(values[valueType], values, cond, options),\r\n );\r\n }\r\n return false;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAwB,eAGtB,YACA,YAKA,UAAoC,EAAE,EACtC;AACA,KAAI,CAAC,WACH,QAAO;CAET,MAAM,gBAAgB,MAAM,QAAQ,WAAW,GAAG,aAAa,CAAC,WAAW;CAE3E,MAAM,YAAY,WAAK,UAAU,WAAW;CAC5C,MAAM,aAAa,WAAK,MAAM,UAAU;CACxC,MAAM,YAAY,WAAK,MAAM,WAAW,IAAI;CAC5C,MAAM,SAAS;EACb,MAAM;EACN,GAAG;EACH,SAAS,WAAW;EACpB,SAAS,UAAU;EACnB,SAAS,UAAU;EACnB,QAAQ,UAAU;EACnB;AACD,QAAO,OAAO;AAEd,MAAK,MAAM,aAAa,cACtB,KAAI,YAAY,OAAO,MAAM,QAAQ,WAAW,QAAQ,CAEtD,QAAO;AAGX,QAAO;;AAGT,SAAS,YACP,OACA,QACA,WACA,SACS;AACT,0BAAa,UAAU,EAErB;MAAI,MAAM,SAAS,UAAU,CAC3B,QAAO;YAEA,qBAAqB,QAE9B;MAAI,UAAU,KAAK,MAAM,CACvB,QAAO;mCAEW,UAAU,CAE9B,QAAO,UAAU,QAAS,QAAQ,oBAAoB,EAAE,CAAO;MAC1D;EAEL,MAAM,EAAE,YAAY,QAAQ,YAAY,QAAQ,eAAe;AAC/D,MAAI,cAAc,QAAQ;GACxB,MAAM,OAAOA,iBAAG,SAAS,OAAO,KAAK;AACrC,OACG,KAAK,aAAa,IAAI,cAAc,SACpC,KAAK,QAAQ,IAAI,cAAc,OAEhC,QAAO;;AAKX,UAFsB,MAAM,QAAQ,WAAW,GAAG,aAAa,CAAC,WAAW,EAEtD,OAAO,SAC1B,YAAY,OAAO,YAAY,QAAQ,MAAM,QAAQ,CACtD;;AAEH,QAAO"}
@@ -0,0 +1,13 @@
1
+ import { ConditionFnOptions, IsMatchingPathCondition, IsMatchingPathOptions } from "./types.cjs";
2
+
3
+ //#region src/isMatchingPath/isMatchingPath.d.ts
4
+ /**
5
+ * 処理対象のパスか判定する
6
+ * @param targetPath 検査対象のパス
7
+ * @param conditions 一致条件
8
+ * @param options オプション
9
+ * @returns 一致するか
10
+ */
11
+ declare function isMatchingPath<O extends ConditionFnOptions = ConditionFnOptions>(targetPath: string, conditions: IsMatchingPathCondition<O> | IsMatchingPathCondition<O>[] | null | undefined, options?: IsMatchingPathOptions<O>): boolean;
12
+ export = isMatchingPath;
13
+ //# sourceMappingURL=isMatchingPath.d.cts.map
@@ -0,0 +1,14 @@
1
+ import { ConditionFnOptions, IsMatchingPathCondition, IsMatchingPathOptions } from "./types.mjs";
2
+
3
+ //#region src/isMatchingPath/isMatchingPath.d.ts
4
+ /**
5
+ * 処理対象のパスか判定する
6
+ * @param targetPath 検査対象のパス
7
+ * @param conditions 一致条件
8
+ * @param options オプション
9
+ * @returns 一致するか
10
+ */
11
+ declare function isMatchingPath<O extends ConditionFnOptions = ConditionFnOptions>(targetPath: string, conditions: IsMatchingPathCondition<O> | IsMatchingPathCondition<O>[] | null | undefined, options?: IsMatchingPathOptions<O>): boolean;
12
+ //#endregion
13
+ export { isMatchingPath as default };
14
+ //# sourceMappingURL=isMatchingPath.d.mts.map
@@ -0,0 +1,50 @@
1
+ import fs from "fs-extra";
2
+ import { posix } from "path";
3
+ import { isFunction, isString } from "remeda";
4
+
5
+ //#region src/isMatchingPath/isMatchingPath.ts
6
+ /**
7
+ * 処理対象のパスか判定する
8
+ * @param targetPath 検査対象のパス
9
+ * @param conditions 一致条件
10
+ * @param options オプション
11
+ * @returns 一致するか
12
+ */
13
+ function isMatchingPath(targetPath, conditions, options = {}) {
14
+ if (!conditions) return false;
15
+ const conditionList = Array.isArray(conditions) ? conditions : [conditions];
16
+ const posixPath = posix.normalize(targetPath);
17
+ const parsedPath = posix.parse(posixPath);
18
+ const parsedDir = posix.parse(parsedPath.dir);
19
+ const values = {
20
+ path: posixPath,
21
+ ...parsedPath,
22
+ dirpath: parsedPath.dir,
23
+ dirbase: parsedDir.base,
24
+ dirname: parsedDir.name,
25
+ dirext: parsedDir.ext
26
+ };
27
+ values.path = posixPath;
28
+ for (const condition of conditionList) if (_isMatching(values.path, values, condition, options)) return true;
29
+ return false;
30
+ }
31
+ function _isMatching(value, values, condition, options) {
32
+ if (isString(condition)) {
33
+ if (value.includes(condition)) return true;
34
+ } else if (condition instanceof RegExp) {
35
+ if (condition.test(value)) return true;
36
+ } else if (isFunction(condition)) return condition(values, options.conditionOptions ?? {});
37
+ else {
38
+ const { valueType = "path", entryType = "both", conditions } = condition;
39
+ if (entryType !== "both") {
40
+ const stat = fs.statSync(values.path);
41
+ if (stat.isDirectory() && entryType !== "dir" || stat.isFile() && entryType !== "file") return false;
42
+ }
43
+ return (Array.isArray(conditions) ? conditions : [conditions]).every((cond) => _isMatching(values[valueType], values, cond, options));
44
+ }
45
+ return false;
46
+ }
47
+
48
+ //#endregion
49
+ export { isMatchingPath as default };
50
+ //# sourceMappingURL=isMatchingPath.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMatchingPath.mjs","names":["path"],"sources":["../../src/isMatchingPath/isMatchingPath.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport { posix as path } from 'path';\r\nimport { isFunction, isString } from 'remeda';\r\nimport type {\r\n ConditionFnOptions,\r\n ConditionValues,\r\n IsMatchingPathCondition,\r\n IsMatchingPathOptions,\r\n} from './types';\r\n\r\n/**\r\n * 処理対象のパスか判定する\r\n * @param targetPath 検査対象のパス\r\n * @param conditions 一致条件\r\n * @param options オプション\r\n * @returns 一致するか\r\n */\r\nexport default function isMatchingPath<\r\n O extends ConditionFnOptions = ConditionFnOptions,\r\n>(\r\n targetPath: string,\r\n conditions:\r\n | IsMatchingPathCondition<O>\r\n | IsMatchingPathCondition<O>[]\r\n | null\r\n | undefined,\r\n options: IsMatchingPathOptions<O> = {},\r\n) {\r\n if (!conditions) {\r\n return false;\r\n }\r\n const conditionList = Array.isArray(conditions) ? conditions : [conditions];\r\n // パスは'/'区切り\r\n const posixPath = path.normalize(targetPath);\r\n const parsedPath = path.parse(posixPath);\r\n const parsedDir = path.parse(parsedPath.dir);\r\n const values = {\r\n path: posixPath,\r\n ...parsedPath,\r\n dirpath: parsedPath.dir,\r\n dirbase: parsedDir.base,\r\n dirname: parsedDir.name,\r\n dirext: parsedDir.ext,\r\n };\r\n values.path = posixPath;\r\n\r\n for (const condition of conditionList) {\r\n if (_isMatching(values.path, values, condition, options)) {\r\n // conditionの内の何れかがtrueならば一致\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nfunction _isMatching<O extends ConditionFnOptions = ConditionFnOptions>(\r\n value: string,\r\n values: ConditionValues,\r\n condition: IsMatchingPathCondition<O>,\r\n options: IsMatchingPathOptions<O>,\r\n): boolean {\r\n if (isString(condition)) {\r\n // 条件が文字列\r\n if (value.includes(condition)) {\r\n return true;\r\n }\r\n } else if (condition instanceof RegExp) {\r\n // 条件が正規表現\r\n if (condition.test(value)) {\r\n return true;\r\n }\r\n } else if (isFunction(condition)) {\r\n // 条件が関数\r\n return condition(values, (options.conditionOptions ?? {}) as O);\r\n } else {\r\n // 条件が設定\r\n const { valueType = 'path', entryType = 'both', conditions } = condition;\r\n if (entryType !== 'both') {\r\n const stat = fs.statSync(values.path);\r\n if (\r\n (stat.isDirectory() && entryType !== 'dir') ||\r\n (stat.isFile() && entryType !== 'file')\r\n ) {\r\n return false;\r\n }\r\n }\r\n const conditionList = Array.isArray(conditions) ? conditions : [conditions];\r\n // 設定配下のconditionsはand条件\r\n return conditionList.every((cond) =>\r\n _isMatching(values[valueType], values, cond, options),\r\n );\r\n }\r\n return false;\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAwB,eAGtB,YACA,YAKA,UAAoC,EAAE,EACtC;AACA,KAAI,CAAC,WACH,QAAO;CAET,MAAM,gBAAgB,MAAM,QAAQ,WAAW,GAAG,aAAa,CAAC,WAAW;CAE3E,MAAM,YAAYA,MAAK,UAAU,WAAW;CAC5C,MAAM,aAAaA,MAAK,MAAM,UAAU;CACxC,MAAM,YAAYA,MAAK,MAAM,WAAW,IAAI;CAC5C,MAAM,SAAS;EACb,MAAM;EACN,GAAG;EACH,SAAS,WAAW;EACpB,SAAS,UAAU;EACnB,SAAS,UAAU;EACnB,QAAQ,UAAU;EACnB;AACD,QAAO,OAAO;AAEd,MAAK,MAAM,aAAa,cACtB,KAAI,YAAY,OAAO,MAAM,QAAQ,WAAW,QAAQ,CAEtD,QAAO;AAGX,QAAO;;AAGT,SAAS,YACP,OACA,QACA,WACA,SACS;AACT,KAAI,SAAS,UAAU,EAErB;MAAI,MAAM,SAAS,UAAU,CAC3B,QAAO;YAEA,qBAAqB,QAE9B;MAAI,UAAU,KAAK,MAAM,CACvB,QAAO;YAEA,WAAW,UAAU,CAE9B,QAAO,UAAU,QAAS,QAAQ,oBAAoB,EAAE,CAAO;MAC1D;EAEL,MAAM,EAAE,YAAY,QAAQ,YAAY,QAAQ,eAAe;AAC/D,MAAI,cAAc,QAAQ;GACxB,MAAM,OAAO,GAAG,SAAS,OAAO,KAAK;AACrC,OACG,KAAK,aAAa,IAAI,cAAc,SACpC,KAAK,QAAQ,IAAI,cAAc,OAEhC,QAAO;;AAKX,UAFsB,MAAM,QAAQ,WAAW,GAAG,aAAa,CAAC,WAAW,EAEtD,OAAO,SAC1B,YAAY,OAAO,YAAY,QAAQ,MAAM,QAAQ,CACtD;;AAEH,QAAO"}
File without changes
@@ -0,0 +1,72 @@
1
+ import { ParsedPath } from "path";
2
+
3
+ //#region src/isMatchingPath/types.d.ts
4
+ /**
5
+ * 一致条件
6
+ *
7
+ * - string: 指定された文字列がパスに含まれているものに一致する際にtrue
8
+ * - RegExp: 指定された正規表現にパスが一致する際にtrue
9
+ * - ConditionConfig: 条件設定に従って検査し一致したときにtrue
10
+ */
11
+ type IsMatchingPathCondition<O extends ConditionFnOptions = ConditionFnOptions> = string | RegExp | ConditionConfig<O> | ConditionFn<O>;
12
+ type IsMatchingPathOptions<O extends ConditionFnOptions = ConditionFnOptions> = {
13
+ /**
14
+ * ConditionFnに渡すオプション
15
+ */
16
+ conditionOptions?: O;
17
+ };
18
+ /**
19
+ * 条件設定
20
+ */
21
+ type ConditionConfig<O extends ConditionFnOptions = ConditionFnOptions> = {
22
+ /**
23
+ * 検査対象の値
24
+ *
25
+ * - path: '/'で区切られたフルパス
26
+ * - base: 拡張子付きのディレクトリ名 or ファイル名
27
+ * - name: 拡張子を除いたディレクトリ名 or ファイル名
28
+ * - ext: '.'を含む拡張子。拡張子が無い場合は空文字
29
+ * - dirpath: '/'で区切られた親ディレクトリのフルパス
30
+ * - base: 拡張子付きの親ディレクトリ名
31
+ * - name: 拡張子を除いた親ディレクトリ名
32
+ * - ext: '.'を含む親ディレクトリの拡張子。拡張子が無い場合は空文字
33
+ */
34
+ valueType?: 'path' | 'base' | 'name' | 'ext' | 'dirpath' | 'dirbase' | 'dirname' | 'dirext';
35
+ /**
36
+ * 検査対象の種別
37
+ *
38
+ * - dir: ディレクトリ
39
+ * - file: ファイル
40
+ * - both: ディレクトリ & ファイル
41
+ */
42
+ entryType?: 'dir' | 'file' | 'both';
43
+ /**
44
+ * 一致条件
45
+ * 配列で指定した場合はand条件とする
46
+ *
47
+ * - string: 指定された文字列を含むものに一致
48
+ * - RegExp: 指定された正規表現に一致
49
+ */
50
+ conditions: string | RegExp | ConditionFn<O> | (string | RegExp | ConditionFn<O>)[];
51
+ };
52
+ /**
53
+ * カスタム条件関数
54
+ */
55
+ type ConditionFn<O extends ConditionFnOptions = ConditionFnOptions> = (values: ConditionValues, options: O) => boolean;
56
+ /**
57
+ * カスタム条件関数のオプション
58
+ */
59
+ type ConditionFnOptions = Record<string, any>;
60
+ /**
61
+ * 検証対象の値
62
+ */
63
+ type ConditionValues = {
64
+ path: string;
65
+ dirpath: string;
66
+ dirbase: string;
67
+ dirname: string;
68
+ dirext: string;
69
+ } & ParsedPath;
70
+ //#endregion
71
+ export { ConditionConfig, ConditionFn, ConditionFnOptions, ConditionValues, IsMatchingPathCondition, IsMatchingPathOptions };
72
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1,72 @@
1
+ import { ParsedPath } from "path";
2
+
3
+ //#region src/isMatchingPath/types.d.ts
4
+ /**
5
+ * 一致条件
6
+ *
7
+ * - string: 指定された文字列がパスに含まれているものに一致する際にtrue
8
+ * - RegExp: 指定された正規表現にパスが一致する際にtrue
9
+ * - ConditionConfig: 条件設定に従って検査し一致したときにtrue
10
+ */
11
+ type IsMatchingPathCondition<O extends ConditionFnOptions = ConditionFnOptions> = string | RegExp | ConditionConfig<O> | ConditionFn<O>;
12
+ type IsMatchingPathOptions<O extends ConditionFnOptions = ConditionFnOptions> = {
13
+ /**
14
+ * ConditionFnに渡すオプション
15
+ */
16
+ conditionOptions?: O;
17
+ };
18
+ /**
19
+ * 条件設定
20
+ */
21
+ type ConditionConfig<O extends ConditionFnOptions = ConditionFnOptions> = {
22
+ /**
23
+ * 検査対象の値
24
+ *
25
+ * - path: '/'で区切られたフルパス
26
+ * - base: 拡張子付きのディレクトリ名 or ファイル名
27
+ * - name: 拡張子を除いたディレクトリ名 or ファイル名
28
+ * - ext: '.'を含む拡張子。拡張子が無い場合は空文字
29
+ * - dirpath: '/'で区切られた親ディレクトリのフルパス
30
+ * - base: 拡張子付きの親ディレクトリ名
31
+ * - name: 拡張子を除いた親ディレクトリ名
32
+ * - ext: '.'を含む親ディレクトリの拡張子。拡張子が無い場合は空文字
33
+ */
34
+ valueType?: 'path' | 'base' | 'name' | 'ext' | 'dirpath' | 'dirbase' | 'dirname' | 'dirext';
35
+ /**
36
+ * 検査対象の種別
37
+ *
38
+ * - dir: ディレクトリ
39
+ * - file: ファイル
40
+ * - both: ディレクトリ & ファイル
41
+ */
42
+ entryType?: 'dir' | 'file' | 'both';
43
+ /**
44
+ * 一致条件
45
+ * 配列で指定した場合はand条件とする
46
+ *
47
+ * - string: 指定された文字列を含むものに一致
48
+ * - RegExp: 指定された正規表現に一致
49
+ */
50
+ conditions: string | RegExp | ConditionFn<O> | (string | RegExp | ConditionFn<O>)[];
51
+ };
52
+ /**
53
+ * カスタム条件関数
54
+ */
55
+ type ConditionFn<O extends ConditionFnOptions = ConditionFnOptions> = (values: ConditionValues, options: O) => boolean;
56
+ /**
57
+ * カスタム条件関数のオプション
58
+ */
59
+ type ConditionFnOptions = Record<string, any>;
60
+ /**
61
+ * 検証対象の値
62
+ */
63
+ type ConditionValues = {
64
+ path: string;
65
+ dirpath: string;
66
+ dirbase: string;
67
+ dirname: string;
68
+ dirext: string;
69
+ } & ParsedPath;
70
+ //#endregion
71
+ export { ConditionConfig, ConditionFn, ConditionFnOptions, ConditionValues, IsMatchingPathCondition, IsMatchingPathOptions };
72
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,3 @@
1
+ const require_isTargetPath_isTargetPath = require('./isTargetPath.cjs');
2
+
3
+ module.exports = require_isTargetPath_isTargetPath;
@@ -0,0 +1,3 @@
1
+ import { IsTargetPathOptions } from "./types.cjs";
2
+ import isTargetPath from "./isTargetPath.cjs";
3
+ export { IsTargetPathOptions, isTargetPath as default };
@@ -0,0 +1,3 @@
1
+ import { IsTargetPathOptions } from "./types.mjs";
2
+ import isTargetPath from "./isTargetPath.mjs";
3
+ export { IsTargetPathOptions, isTargetPath as default };
@@ -0,0 +1,3 @@
1
+ import isTargetPath from "./isTargetPath.mjs";
2
+
3
+ export { isTargetPath as default };
@@ -0,0 +1,21 @@
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ const require_isMatchingPath_isMatchingPath = require('../isMatchingPath/isMatchingPath.cjs');
3
+ require('../isMatchingPath/index.cjs');
4
+ let fs_extra = require("fs-extra");
5
+ fs_extra = require_runtime.__toESM(fs_extra, 1);
6
+
7
+ //#region src/isTargetPath/isTargetPath.ts
8
+ const IS_TARGET_TYPE = {
9
+ file: (stat) => stat.isFile(),
10
+ dir: (stat) => stat.isDirectory(),
11
+ both: (stat) => stat.isFile() || stat.isDirectory()
12
+ };
13
+ async function isTargetPath(itemPath, options = {}) {
14
+ const { itemType = "file", defaultInclude, defaultExclude, include = defaultInclude, exclude = defaultExclude, ...rest } = options;
15
+ const stat = fs_extra.default.statSync(itemPath);
16
+ return IS_TARGET_TYPE[itemType](stat) && (!include || require_isMatchingPath_isMatchingPath(itemPath, include, rest)) && (!exclude || !require_isMatchingPath_isMatchingPath(itemPath, exclude, rest));
17
+ }
18
+
19
+ //#endregion
20
+ module.exports = isTargetPath;
21
+ //# sourceMappingURL=isTargetPath.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isTargetPath.cjs","names":["fs","isMatchingPath"],"sources":["../../src/isTargetPath/isTargetPath.ts"],"sourcesContent":["import fs, { Stats } from 'fs-extra';\r\nimport type { ConditionFnOptions } from '../isMatchingPath';\r\nimport isMatchingPath from '../isMatchingPath';\r\nimport type { IsTargetPathOptions } from './types';\r\n\r\nconst IS_TARGET_TYPE = {\r\n file: (stat: Stats) => stat.isFile(),\r\n dir: (stat: Stats) => stat.isDirectory(),\r\n both: (stat: Stats) => stat.isFile() || stat.isDirectory(),\r\n} as const;\r\n\r\nexport default async function isTargetPath<\r\n O extends ConditionFnOptions = ConditionFnOptions,\r\n>(itemPath: string, options: IsTargetPathOptions<O> = {}) {\r\n const {\r\n itemType = 'file',\r\n defaultInclude,\r\n defaultExclude,\r\n include = defaultInclude,\r\n exclude = defaultExclude,\r\n ...rest\r\n } = options;\r\n const stat = fs.statSync(itemPath);\r\n\r\n return (\r\n IS_TARGET_TYPE[itemType](stat) &&\r\n (!include || isMatchingPath(itemPath, include, rest)) &&\r\n (!exclude || !isMatchingPath(itemPath, exclude, rest))\r\n );\r\n}\r\n"],"mappings":";;;;;;;AAKA,MAAM,iBAAiB;CACrB,OAAO,SAAgB,KAAK,QAAQ;CACpC,MAAM,SAAgB,KAAK,aAAa;CACxC,OAAO,SAAgB,KAAK,QAAQ,IAAI,KAAK,aAAa;CAC3D;AAED,eAA8B,aAE5B,UAAkB,UAAkC,EAAE,EAAE;CACxD,MAAM,EACJ,WAAW,QACX,gBACA,gBACA,UAAU,gBACV,UAAU,gBACV,GAAG,SACD;CACJ,MAAM,OAAOA,iBAAG,SAAS,SAAS;AAElC,QACE,eAAe,UAAU,KAAK,KAC7B,CAAC,WAAWC,sCAAe,UAAU,SAAS,KAAK,MACnD,CAAC,WAAW,CAACA,sCAAe,UAAU,SAAS,KAAK"}
@@ -0,0 +1,7 @@
1
+ import { ConditionFnOptions } from "../isMatchingPath/types.cjs";
2
+ import { IsTargetPathOptions } from "./types.cjs";
3
+
4
+ //#region src/isTargetPath/isTargetPath.d.ts
5
+ declare function isTargetPath<O extends ConditionFnOptions = ConditionFnOptions>(itemPath: string, options?: IsTargetPathOptions<O>): Promise<boolean>;
6
+ export = isTargetPath;
7
+ //# sourceMappingURL=isTargetPath.d.cts.map
@@ -0,0 +1,8 @@
1
+ import { ConditionFnOptions } from "../isMatchingPath/types.mjs";
2
+ import { IsTargetPathOptions } from "./types.mjs";
3
+
4
+ //#region src/isTargetPath/isTargetPath.d.ts
5
+ declare function isTargetPath<O extends ConditionFnOptions = ConditionFnOptions>(itemPath: string, options?: IsTargetPathOptions<O>): Promise<boolean>;
6
+ //#endregion
7
+ export { isTargetPath as default };
8
+ //# sourceMappingURL=isTargetPath.d.mts.map
@@ -0,0 +1,19 @@
1
+ import isMatchingPath from "../isMatchingPath/isMatchingPath.mjs";
2
+ import "../isMatchingPath/index.mjs";
3
+ import fs from "fs-extra";
4
+
5
+ //#region src/isTargetPath/isTargetPath.ts
6
+ const IS_TARGET_TYPE = {
7
+ file: (stat) => stat.isFile(),
8
+ dir: (stat) => stat.isDirectory(),
9
+ both: (stat) => stat.isFile() || stat.isDirectory()
10
+ };
11
+ async function isTargetPath(itemPath, options = {}) {
12
+ const { itemType = "file", defaultInclude, defaultExclude, include = defaultInclude, exclude = defaultExclude, ...rest } = options;
13
+ const stat = fs.statSync(itemPath);
14
+ return IS_TARGET_TYPE[itemType](stat) && (!include || isMatchingPath(itemPath, include, rest)) && (!exclude || !isMatchingPath(itemPath, exclude, rest));
15
+ }
16
+
17
+ //#endregion
18
+ export { isTargetPath as default };
19
+ //# sourceMappingURL=isTargetPath.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isTargetPath.mjs","names":[],"sources":["../../src/isTargetPath/isTargetPath.ts"],"sourcesContent":["import fs, { Stats } from 'fs-extra';\r\nimport type { ConditionFnOptions } from '../isMatchingPath';\r\nimport isMatchingPath from '../isMatchingPath';\r\nimport type { IsTargetPathOptions } from './types';\r\n\r\nconst IS_TARGET_TYPE = {\r\n file: (stat: Stats) => stat.isFile(),\r\n dir: (stat: Stats) => stat.isDirectory(),\r\n both: (stat: Stats) => stat.isFile() || stat.isDirectory(),\r\n} as const;\r\n\r\nexport default async function isTargetPath<\r\n O extends ConditionFnOptions = ConditionFnOptions,\r\n>(itemPath: string, options: IsTargetPathOptions<O> = {}) {\r\n const {\r\n itemType = 'file',\r\n defaultInclude,\r\n defaultExclude,\r\n include = defaultInclude,\r\n exclude = defaultExclude,\r\n ...rest\r\n } = options;\r\n const stat = fs.statSync(itemPath);\r\n\r\n return (\r\n IS_TARGET_TYPE[itemType](stat) &&\r\n (!include || isMatchingPath(itemPath, include, rest)) &&\r\n (!exclude || !isMatchingPath(itemPath, exclude, rest))\r\n );\r\n}\r\n"],"mappings":";;;;;AAKA,MAAM,iBAAiB;CACrB,OAAO,SAAgB,KAAK,QAAQ;CACpC,MAAM,SAAgB,KAAK,aAAa;CACxC,OAAO,SAAgB,KAAK,QAAQ,IAAI,KAAK,aAAa;CAC3D;AAED,eAA8B,aAE5B,UAAkB,UAAkC,EAAE,EAAE;CACxD,MAAM,EACJ,WAAW,QACX,gBACA,gBACA,UAAU,gBACV,UAAU,gBACV,GAAG,SACD;CACJ,MAAM,OAAO,GAAG,SAAS,SAAS;AAElC,QACE,eAAe,UAAU,KAAK,KAC7B,CAAC,WAAW,eAAe,UAAU,SAAS,KAAK,MACnD,CAAC,WAAW,CAAC,eAAe,UAAU,SAAS,KAAK"}
File without changes
@@ -1,38 +1,33 @@
1
- import type {
2
- ConditionFnOptions,
3
- IsMatchingPathCondition,
4
- } from '../isMatchingPath';
5
-
6
- export type IsTargetPathOptions<
7
- O extends ConditionFnOptions = ConditionFnOptions,
8
- > = {
9
- /**
10
- * 対象の種別
11
- * @default 'file'
12
- */
13
- itemType?: 'file' | 'dir' | 'both';
14
-
15
- /**
16
- * 対象とする条件
17
- * 未指定の場合は`defaultInclude`が適用される
18
- */
19
- include?: IsMatchingPathCondition<O>[];
20
-
21
- /**
22
- * 対象から除外する条件
23
- * 未指定の場合は`defaultExclude`が適用される
24
- */
25
- exclude?: IsMatchingPathCondition<O>[];
26
-
27
- /**
28
- * 対象とする条件のデフォルト
29
- * 未指定の場合は条件なし
30
- */
31
- defaultInclude?: IsMatchingPathCondition<O>[];
32
-
33
- /**
34
- * 対象から除外する条件のデフォルト
35
- * 未指定の場合は除外なし
36
- */
37
- defaultExclude?: IsMatchingPathCondition<O>[];
38
- };
1
+ import { ConditionFnOptions, IsMatchingPathCondition } from "../isMatchingPath/types.cjs";
2
+
3
+ //#region src/isTargetPath/types.d.ts
4
+ type IsTargetPathOptions<O extends ConditionFnOptions = ConditionFnOptions> = {
5
+ /**
6
+ * 対象の種別
7
+ * @default 'file'
8
+ */
9
+ itemType?: 'file' | 'dir' | 'both';
10
+ /**
11
+ * 対象とする条件
12
+ * 未指定の場合は`defaultInclude`が適用される
13
+ */
14
+ include?: IsMatchingPathCondition<O>[];
15
+ /**
16
+ * 対象から除外する条件
17
+ * 未指定の場合は`defaultExclude`が適用される
18
+ */
19
+ exclude?: IsMatchingPathCondition<O>[];
20
+ /**
21
+ * 対象とする条件のデフォルト
22
+ * 未指定の場合は条件なし
23
+ */
24
+ defaultInclude?: IsMatchingPathCondition<O>[];
25
+ /**
26
+ * 対象から除外する条件のデフォルト
27
+ * 未指定の場合は除外なし
28
+ */
29
+ defaultExclude?: IsMatchingPathCondition<O>[];
30
+ };
31
+ //#endregion
32
+ export { IsTargetPathOptions };
33
+ //# sourceMappingURL=types.d.cts.map