@niche-works/dev 0.3.0 → 0.4.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 (208) 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/createExternalOptionFunction/types.d.cts +31 -0
  48. package/createExternalOptionFunction/types.d.mts +31 -0
  49. package/createExternalOptionFunction/types.mjs +1 -0
  50. package/editJsonFile/editJsonFile.cjs +29 -0
  51. package/editJsonFile/editJsonFile.cjs.map +1 -0
  52. package/editJsonFile/editJsonFile.d.cts +9 -0
  53. package/editJsonFile/editJsonFile.d.mts +10 -0
  54. package/editJsonFile/editJsonFile.mjs +26 -0
  55. package/editJsonFile/editJsonFile.mjs.map +1 -0
  56. package/editJsonFile/index.cjs +3 -0
  57. package/editJsonFile/index.d.cts +2 -0
  58. package/editJsonFile/index.d.mts +2 -0
  59. package/editJsonFile/index.mjs +3 -0
  60. package/generatePublishPackageJson/generatePublishPackageJson.cjs +46 -0
  61. package/generatePublishPackageJson/generatePublishPackageJson.cjs.map +1 -0
  62. package/generatePublishPackageJson/generatePublishPackageJson.d.cts +6 -0
  63. package/generatePublishPackageJson/generatePublishPackageJson.d.mts +7 -0
  64. package/generatePublishPackageJson/generatePublishPackageJson.mjs +44 -0
  65. package/generatePublishPackageJson/generatePublishPackageJson.mjs.map +1 -0
  66. package/generatePublishPackageJson/index.cjs +3 -0
  67. package/generatePublishPackageJson/index.d.cts +3 -0
  68. package/generatePublishPackageJson/index.d.mts +3 -0
  69. package/generatePublishPackageJson/index.mjs +3 -0
  70. package/generatePublishPackageJson/types.cjs +0 -0
  71. package/{src/generatePublishPackageJson/types.ts → generatePublishPackageJson/types.d.cts} +60 -61
  72. package/generatePublishPackageJson/types.d.mts +60 -0
  73. package/generatePublishPackageJson/types.mjs +1 -0
  74. package/index.cjs +38 -0
  75. package/index.d.cts +13 -0
  76. package/index.d.mts +13 -0
  77. package/index.mjs +26 -0
  78. package/indexes/constants.cjs +123 -0
  79. package/indexes/constants.cjs.map +1 -0
  80. package/indexes/constants.d.cts +66 -0
  81. package/indexes/constants.d.mts +66 -0
  82. package/indexes/constants.mjs +106 -0
  83. package/indexes/constants.mjs.map +1 -0
  84. package/indexes/index.cjs +3 -0
  85. package/indexes/index.d.cts +3 -0
  86. package/indexes/index.d.mts +3 -0
  87. package/indexes/index.mjs +3 -0
  88. package/indexes/indexes.cjs +125 -0
  89. package/indexes/indexes.cjs.map +1 -0
  90. package/indexes/indexes.d.cts +11 -0
  91. package/indexes/indexes.d.mts +12 -0
  92. package/indexes/indexes.mjs +123 -0
  93. package/indexes/indexes.mjs.map +1 -0
  94. package/indexes/types.cjs +0 -0
  95. package/{src/indexes/types.ts → indexes/types.d.cts} +81 -87
  96. package/indexes/types.d.mts +81 -0
  97. package/indexes/types.mjs +1 -0
  98. package/installFromLocal/index.cjs +3 -0
  99. package/installFromLocal/index.d.cts +3 -0
  100. package/installFromLocal/index.d.mts +3 -0
  101. package/installFromLocal/index.mjs +3 -0
  102. package/installFromLocal/installFromLocal.cjs +46 -0
  103. package/installFromLocal/installFromLocal.cjs.map +1 -0
  104. package/installFromLocal/installFromLocal.d.cts +11 -0
  105. package/installFromLocal/installFromLocal.d.mts +12 -0
  106. package/installFromLocal/installFromLocal.mjs +43 -0
  107. package/installFromLocal/installFromLocal.mjs.map +1 -0
  108. package/installFromLocal/types.cjs +0 -0
  109. package/{src/installFromLocal/types.ts → installFromLocal/types.d.cts} +21 -19
  110. package/installFromLocal/types.d.mts +21 -0
  111. package/installFromLocal/types.mjs +1 -0
  112. package/isMatchingPath/index.cjs +3 -0
  113. package/isMatchingPath/index.d.cts +3 -0
  114. package/isMatchingPath/index.d.mts +3 -0
  115. package/isMatchingPath/index.mjs +3 -0
  116. package/isMatchingPath/isMatchingPath.cjs +52 -0
  117. package/isMatchingPath/isMatchingPath.cjs.map +1 -0
  118. package/isMatchingPath/isMatchingPath.d.cts +13 -0
  119. package/isMatchingPath/isMatchingPath.d.mts +14 -0
  120. package/isMatchingPath/isMatchingPath.mjs +50 -0
  121. package/isMatchingPath/isMatchingPath.mjs.map +1 -0
  122. package/isMatchingPath/types.cjs +0 -0
  123. package/isMatchingPath/types.d.cts +72 -0
  124. package/isMatchingPath/types.d.mts +72 -0
  125. package/isMatchingPath/types.mjs +1 -0
  126. package/isTargetPath/index.cjs +3 -0
  127. package/isTargetPath/index.d.cts +3 -0
  128. package/isTargetPath/index.d.mts +3 -0
  129. package/isTargetPath/index.mjs +3 -0
  130. package/isTargetPath/isTargetPath.cjs +21 -0
  131. package/isTargetPath/isTargetPath.cjs.map +1 -0
  132. package/isTargetPath/isTargetPath.d.cts +7 -0
  133. package/isTargetPath/isTargetPath.d.mts +8 -0
  134. package/isTargetPath/isTargetPath.mjs +19 -0
  135. package/isTargetPath/isTargetPath.mjs.map +1 -0
  136. package/isTargetPath/types.cjs +0 -0
  137. package/isTargetPath/types.d.cts +33 -0
  138. package/isTargetPath/types.d.mts +33 -0
  139. package/isTargetPath/types.mjs +1 -0
  140. package/moveFilesToSubdir/index.cjs +3 -0
  141. package/moveFilesToSubdir/index.d.cts +3 -0
  142. package/moveFilesToSubdir/index.d.mts +3 -0
  143. package/moveFilesToSubdir/index.mjs +3 -0
  144. package/moveFilesToSubdir/moveFilesToSubdir.cjs +32 -0
  145. package/moveFilesToSubdir/moveFilesToSubdir.cjs.map +1 -0
  146. package/moveFilesToSubdir/moveFilesToSubdir.d.cts +10 -0
  147. package/moveFilesToSubdir/moveFilesToSubdir.d.mts +11 -0
  148. package/moveFilesToSubdir/moveFilesToSubdir.mjs +29 -0
  149. package/moveFilesToSubdir/moveFilesToSubdir.mjs.map +1 -0
  150. package/moveFilesToSubdir/types.cjs +0 -0
  151. package/moveFilesToSubdir/types.d.cts +18 -0
  152. package/moveFilesToSubdir/types.d.mts +18 -0
  153. package/moveFilesToSubdir/types.mjs +1 -0
  154. package/package.json +20 -30
  155. package/removeFiles/index.cjs +3 -0
  156. package/removeFiles/index.d.cts +2 -0
  157. package/removeFiles/index.d.mts +2 -0
  158. package/removeFiles/index.mjs +3 -0
  159. package/removeFiles/removeFiles.cjs +15 -0
  160. package/removeFiles/removeFiles.cjs.map +1 -0
  161. package/removeFiles/removeFiles.d.cts +6 -0
  162. package/removeFiles/removeFiles.d.mts +7 -0
  163. package/removeFiles/removeFiles.mjs +12 -0
  164. package/removeFiles/removeFiles.mjs.map +1 -0
  165. package/removeFiles/types.cjs +0 -0
  166. package/removeFiles/types.d.cts +9 -0
  167. package/removeFiles/types.d.mts +9 -0
  168. package/removeFiles/types.mjs +1 -0
  169. package/ver/index.cjs +3 -0
  170. package/ver/index.d.cts +3 -0
  171. package/ver/index.d.mts +3 -0
  172. package/ver/index.mjs +3 -0
  173. package/ver/types.cjs +0 -0
  174. package/{src/ver/types.ts → ver/types.d.cts} +16 -13
  175. package/ver/types.d.mts +16 -0
  176. package/ver/types.mjs +1 -0
  177. package/ver/ver.cjs +34 -0
  178. package/ver/ver.cjs.map +1 -0
  179. package/ver/ver.d.cts +11 -0
  180. package/ver/ver.d.mts +12 -0
  181. package/ver/ver.mjs +31 -0
  182. package/ver/ver.mjs.map +1 -0
  183. package/src/addExports/addExports.ts +0 -98
  184. package/src/addExports/index.ts +0 -2
  185. package/src/addJsExtensions/addJsExtensions.ts +0 -31
  186. package/src/addJsExtensions/index.ts +0 -1
  187. package/src/checkExistence/checkExistence.ts +0 -16
  188. package/src/checkExistence/index.ts +0 -1
  189. package/src/editJsonFile/editJsonFile.ts +0 -30
  190. package/src/editJsonFile/index.ts +0 -1
  191. package/src/generatePublishPackageJson/generatePublishPackageJson.ts +0 -55
  192. package/src/generatePublishPackageJson/index.ts +0 -2
  193. package/src/index.ts +0 -10
  194. package/src/indexes/constants.ts +0 -135
  195. package/src/indexes/index.ts +0 -2
  196. package/src/indexes/indexes.ts +0 -194
  197. package/src/installFromLocal/index.ts +0 -2
  198. package/src/installFromLocal/installFromLocal.ts +0 -63
  199. package/src/isMatchingPath/_types.ts +0 -65
  200. package/src/isMatchingPath/index.ts +0 -2
  201. package/src/isMatchingPath/isMatchingPath.ts +0 -88
  202. package/src/isMatchingPath/types.ts +0 -21
  203. package/src/moveFilesToSubdir/index.ts +0 -1
  204. package/src/moveFilesToSubdir/moveFilesToSubdir.ts +0 -23
  205. package/src/ver/index.ts +0 -2
  206. package/src/ver/ver.ts +0 -38
  207. package/tsconfig.json +0 -46
  208. package/tsup.config.ts +0 -36
@@ -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
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,33 @@
1
+ import { ConditionFnOptions, IsMatchingPathCondition } from "../isMatchingPath/types.mjs";
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.mts.map
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,3 @@
1
+ const require_moveFilesToSubdir_moveFilesToSubdir = require('./moveFilesToSubdir.cjs');
2
+
3
+ module.exports = require_moveFilesToSubdir_moveFilesToSubdir;
@@ -0,0 +1,3 @@
1
+ import { MoveFilesToSubdirOptions } from "./types.cjs";
2
+ import moveFilesToSubdir from "./moveFilesToSubdir.cjs";
3
+ export { MoveFilesToSubdirOptions, moveFilesToSubdir as default };
@@ -0,0 +1,3 @@
1
+ import { MoveFilesToSubdirOptions } from "./types.mjs";
2
+ import moveFilesToSubdir from "./moveFilesToSubdir.mjs";
3
+ export { MoveFilesToSubdirOptions, moveFilesToSubdir as default };
@@ -0,0 +1,3 @@
1
+ import moveFilesToSubdir from "./moveFilesToSubdir.mjs";
2
+
3
+ export { moveFilesToSubdir as default };
@@ -0,0 +1,32 @@
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ const require_isTargetPath_isTargetPath = require('../isTargetPath/isTargetPath.cjs');
3
+ require('../isTargetPath/index.cjs');
4
+ let fs_extra = require("fs-extra");
5
+ fs_extra = require_runtime.__toESM(fs_extra, 1);
6
+ let path = require("path");
7
+ path = require_runtime.__toESM(path, 1);
8
+
9
+ //#region src/moveFilesToSubdir/moveFilesToSubdir.ts
10
+ /**
11
+ * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する
12
+ * @param dirPath 対象のディレクトリのパス
13
+ */
14
+ async function moveFilesToSubdir(dirPath, options = {}) {
15
+ const { process, index, ...rest } = options;
16
+ const items = await fs_extra.default.readdir(dirPath);
17
+ for (const item of items) {
18
+ const itemPath = path.default.join(dirPath, item);
19
+ if (require_isTargetPath_isTargetPath(itemPath, rest)) {
20
+ const { name, ext } = path.default.parse(item);
21
+ const subdirPath = path.default.join(dirPath, name);
22
+ fs_extra.default.ensureDirSync(subdirPath);
23
+ fs_extra.default.moveSync(itemPath, path.default.join(subdirPath, item));
24
+ if (index) fs_extra.default.writeFileSync(path.default.join(subdirPath, `index.${ext}`), `export { default } from ${name}`, { encoding: "utf8" });
25
+ if (process) process(subdirPath, item);
26
+ }
27
+ }
28
+ }
29
+
30
+ //#endregion
31
+ module.exports = moveFilesToSubdir;
32
+ //# sourceMappingURL=moveFilesToSubdir.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moveFilesToSubdir.cjs","names":["fs","isTargetPath"],"sources":["../../src/moveFilesToSubdir/moveFilesToSubdir.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport path from 'path';\r\nimport isTargetPath from '../isTargetPath';\r\nimport type { MoveFilesToSubdirOptions } from './types';\r\n\r\n/**\r\n * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する\r\n * @param dirPath 対象のディレクトリのパス\r\n */\r\nexport default async function moveFilesToSubdir(\r\n dirPath: string,\r\n options: MoveFilesToSubdirOptions = {},\r\n) {\r\n const { process, index, ...rest } = options;\r\n const items = await fs.readdir(dirPath);\r\n for (const item of items) {\r\n const itemPath = path.join(dirPath, item);\r\n if (isTargetPath(itemPath, rest)) {\r\n const { name, ext } = path.parse(item);\r\n // 移動先のディレクトリパスを生成\r\n const subdirPath = path.join(dirPath, name);\r\n // 移動先のディレクトリが存在しなければ作成\r\n fs.ensureDirSync(subdirPath);\r\n // 移動\r\n fs.moveSync(itemPath, path.join(subdirPath, item));\r\n if (index) {\r\n fs.writeFileSync(\r\n path.join(subdirPath, `index.${ext}`),\r\n `export { default } from ${name}`,\r\n {\r\n encoding: 'utf8',\r\n },\r\n );\r\n }\r\n if (process) {\r\n process(subdirPath, item);\r\n }\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AASA,eAA8B,kBAC5B,SACA,UAAoC,EAAE,EACtC;CACA,MAAM,EAAE,SAAS,OAAO,GAAG,SAAS;CACpC,MAAM,QAAQ,MAAMA,iBAAG,QAAQ,QAAQ;AACvC,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,aAAK,KAAK,SAAS,KAAK;AACzC,MAAIC,kCAAa,UAAU,KAAK,EAAE;GAChC,MAAM,EAAE,MAAM,QAAQ,aAAK,MAAM,KAAK;GAEtC,MAAM,aAAa,aAAK,KAAK,SAAS,KAAK;AAE3C,oBAAG,cAAc,WAAW;AAE5B,oBAAG,SAAS,UAAU,aAAK,KAAK,YAAY,KAAK,CAAC;AAClD,OAAI,MACF,kBAAG,cACD,aAAK,KAAK,YAAY,SAAS,MAAM,EACrC,2BAA2B,QAC3B,EACE,UAAU,QACX,CACF;AAEH,OAAI,QACF,SAAQ,YAAY,KAAK"}
@@ -0,0 +1,10 @@
1
+ import { MoveFilesToSubdirOptions } from "./types.cjs";
2
+
3
+ //#region src/moveFilesToSubdir/moveFilesToSubdir.d.ts
4
+ /**
5
+ * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する
6
+ * @param dirPath 対象のディレクトリのパス
7
+ */
8
+ declare function moveFilesToSubdir(dirPath: string, options?: MoveFilesToSubdirOptions): Promise<void>;
9
+ export = moveFilesToSubdir;
10
+ //# sourceMappingURL=moveFilesToSubdir.d.cts.map
@@ -0,0 +1,11 @@
1
+ import { MoveFilesToSubdirOptions } from "./types.mjs";
2
+
3
+ //#region src/moveFilesToSubdir/moveFilesToSubdir.d.ts
4
+ /**
5
+ * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する
6
+ * @param dirPath 対象のディレクトリのパス
7
+ */
8
+ declare function moveFilesToSubdir(dirPath: string, options?: MoveFilesToSubdirOptions): Promise<void>;
9
+ //#endregion
10
+ export { moveFilesToSubdir as default };
11
+ //# sourceMappingURL=moveFilesToSubdir.d.mts.map
@@ -0,0 +1,29 @@
1
+ import isTargetPath from "../isTargetPath/isTargetPath.mjs";
2
+ import "../isTargetPath/index.mjs";
3
+ import fs from "fs-extra";
4
+ import path from "path";
5
+
6
+ //#region src/moveFilesToSubdir/moveFilesToSubdir.ts
7
+ /**
8
+ * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する
9
+ * @param dirPath 対象のディレクトリのパス
10
+ */
11
+ async function moveFilesToSubdir(dirPath, options = {}) {
12
+ const { process, index, ...rest } = options;
13
+ const items = await fs.readdir(dirPath);
14
+ for (const item of items) {
15
+ const itemPath = path.join(dirPath, item);
16
+ if (isTargetPath(itemPath, rest)) {
17
+ const { name, ext } = path.parse(item);
18
+ const subdirPath = path.join(dirPath, name);
19
+ fs.ensureDirSync(subdirPath);
20
+ fs.moveSync(itemPath, path.join(subdirPath, item));
21
+ if (index) fs.writeFileSync(path.join(subdirPath, `index.${ext}`), `export { default } from ${name}`, { encoding: "utf8" });
22
+ if (process) process(subdirPath, item);
23
+ }
24
+ }
25
+ }
26
+
27
+ //#endregion
28
+ export { moveFilesToSubdir as default };
29
+ //# sourceMappingURL=moveFilesToSubdir.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moveFilesToSubdir.mjs","names":[],"sources":["../../src/moveFilesToSubdir/moveFilesToSubdir.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport path from 'path';\r\nimport isTargetPath from '../isTargetPath';\r\nimport type { MoveFilesToSubdirOptions } from './types';\r\n\r\n/**\r\n * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する\r\n * @param dirPath 対象のディレクトリのパス\r\n */\r\nexport default async function moveFilesToSubdir(\r\n dirPath: string,\r\n options: MoveFilesToSubdirOptions = {},\r\n) {\r\n const { process, index, ...rest } = options;\r\n const items = await fs.readdir(dirPath);\r\n for (const item of items) {\r\n const itemPath = path.join(dirPath, item);\r\n if (isTargetPath(itemPath, rest)) {\r\n const { name, ext } = path.parse(item);\r\n // 移動先のディレクトリパスを生成\r\n const subdirPath = path.join(dirPath, name);\r\n // 移動先のディレクトリが存在しなければ作成\r\n fs.ensureDirSync(subdirPath);\r\n // 移動\r\n fs.moveSync(itemPath, path.join(subdirPath, item));\r\n if (index) {\r\n fs.writeFileSync(\r\n path.join(subdirPath, `index.${ext}`),\r\n `export { default } from ${name}`,\r\n {\r\n encoding: 'utf8',\r\n },\r\n );\r\n }\r\n if (process) {\r\n process(subdirPath, item);\r\n }\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;AASA,eAA8B,kBAC5B,SACA,UAAoC,EAAE,EACtC;CACA,MAAM,EAAE,SAAS,OAAO,GAAG,SAAS;CACpC,MAAM,QAAQ,MAAM,GAAG,QAAQ,QAAQ;AACvC,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,KAAK,SAAS,KAAK;AACzC,MAAI,aAAa,UAAU,KAAK,EAAE;GAChC,MAAM,EAAE,MAAM,QAAQ,KAAK,MAAM,KAAK;GAEtC,MAAM,aAAa,KAAK,KAAK,SAAS,KAAK;AAE3C,MAAG,cAAc,WAAW;AAE5B,MAAG,SAAS,UAAU,KAAK,KAAK,YAAY,KAAK,CAAC;AAClD,OAAI,MACF,IAAG,cACD,KAAK,KAAK,YAAY,SAAS,MAAM,EACrC,2BAA2B,QAC3B,EACE,UAAU,QACX,CACF;AAEH,OAAI,QACF,SAAQ,YAAY,KAAK"}
File without changes
@@ -0,0 +1,18 @@
1
+ import { IsTargetPathOptions } from "../isTargetPath/types.cjs";
2
+
3
+ //#region src/moveFilesToSubdir/types.d.ts
4
+ type MoveFilesToSubdirOptions = Omit<IsTargetPathOptions, 'itemType'> & {
5
+ /**
6
+ * ファイル毎の後処理
7
+ * @param subdirPath サブディレクトリのパス
8
+ * @param fileName ファイル名
9
+ */
10
+ process?: (subdirPath: string, fileName: string) => void;
11
+ /**
12
+ * indexファイルの作成
13
+ */
14
+ index?: boolean;
15
+ };
16
+ //#endregion
17
+ export { MoveFilesToSubdirOptions };
18
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1,18 @@
1
+ import { IsTargetPathOptions } from "../isTargetPath/types.mjs";
2
+
3
+ //#region src/moveFilesToSubdir/types.d.ts
4
+ type MoveFilesToSubdirOptions = Omit<IsTargetPathOptions, 'itemType'> & {
5
+ /**
6
+ * ファイル毎の後処理
7
+ * @param subdirPath サブディレクトリのパス
8
+ * @param fileName ファイル名
9
+ */
10
+ process?: (subdirPath: string, fileName: string) => void;
11
+ /**
12
+ * indexファイルの作成
13
+ */
14
+ index?: boolean;
15
+ };
16
+ //#endregion
17
+ export { MoveFilesToSubdirOptions };
18
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ export { };