@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niche-works/dev",
3
- "version": "0.3.0",
3
+ "version": "0.4.2",
4
4
  "keywords": [
5
5
  "utils"
6
6
  ],
@@ -12,37 +12,27 @@
12
12
  "author": "Mitsuhiro Seino",
13
13
  "type": "module",
14
14
  "exports": {
15
- ".": "./src/index.ts",
16
- "./*": "./src/*/index.ts",
17
- "./*/constants": "./src/*/constants.ts"
18
- },
19
- "main": "./src/index.ts",
20
- "module": "./src/index.ts",
21
- "scripts": {
22
- "build": "tsup",
23
- "check": "tsc --noEmit",
24
- "dev": "tsup --watch",
25
- "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json}\"",
26
- "indexes": "tsx scripts/indexes.ts",
27
- "lint": "tsup --dry-run",
28
- "tidy": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json}\" --config ./prettier.tidy.config.js"
15
+ ".": {
16
+ "import": "./index.mjs",
17
+ "require": "./index.cjs"
18
+ },
19
+ "./*": {
20
+ "import": "./*/index.mjs",
21
+ "require": "./*/index.cjs"
22
+ },
23
+ "./constants": {
24
+ "import": "./constants.mjs",
25
+ "require": "./constants.cjs"
26
+ },
27
+ "./*/constants": {
28
+ "import": "./*/constants.mjs",
29
+ "require": "./*/constants.cjs"
30
+ }
29
31
  },
30
32
  "dependencies": {
33
+ "fast-glob": "^3.3.3",
31
34
  "fs-extra": "^11.3.4",
32
35
  "remeda": "^2.33.6",
33
- "tslib": "^2.8.1"
34
- },
35
- "devDependencies": {
36
- "@types/fs-extra": "^11.0.4",
37
- "@types/node": "^25.5.0",
38
- "fast-glob": "^3.3.3",
39
- "prettier": "^3.8.1",
40
- "prettier-plugin-organize-imports": "^4.3.0",
41
- "prettier-plugin-packagejson": "^3.0.2",
42
- "tsup": "^8.5.1",
43
- "tsx": "^4.21.0",
44
- "type-fest": "^5.5.0",
45
- "typescript": "^6.0.2"
46
- },
47
- "packageManager": "pnpm@10.32.1"
36
+ "type-fest": "^5.5.0"
37
+ }
48
38
  }
@@ -0,0 +1,3 @@
1
+ const require_removeFiles_removeFiles = require('./removeFiles.cjs');
2
+
3
+ module.exports = require_removeFiles_removeFiles;
@@ -0,0 +1,2 @@
1
+ import removeFiles from "./removeFiles.cjs";
2
+ export = removeFiles;
@@ -0,0 +1,2 @@
1
+ import removeFiles from "./removeFiles.mjs";
2
+ export { removeFiles as default };
@@ -0,0 +1,3 @@
1
+ import removeFiles from "./removeFiles.mjs";
2
+
3
+ export { removeFiles as default };
@@ -0,0 +1,15 @@
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 fast_glob = require("fast-glob");
5
+ fast_glob = require_runtime.__toESM(fast_glob, 1);
6
+
7
+ //#region src/removeFiles/removeFiles.ts
8
+ async function removeFiles(source, options = {}) {
9
+ const files = await (0, fast_glob.default)(source, options);
10
+ await Promise.all(files.map((file) => fs_extra.default.remove(file)));
11
+ }
12
+
13
+ //#endregion
14
+ module.exports = removeFiles;
15
+ //# sourceMappingURL=removeFiles.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeFiles.cjs","names":["fs"],"sources":["../../src/removeFiles/removeFiles.ts"],"sourcesContent":["import fg from 'fast-glob';\r\nimport type { Options, Pattern } from 'fast-glob/out/index';\r\nimport fs from 'fs-extra';\r\n\r\nexport default async function removeFiles(\r\n source: Pattern | Pattern[],\r\n options: Options = {},\r\n) {\r\n const files = await fg(source, options);\r\n await Promise.all(files.map((file) => fs.remove(file)));\r\n}\r\n"],"mappings":";;;;;;;AAIA,eAA8B,YAC5B,QACA,UAAmB,EAAE,EACrB;CACA,MAAM,QAAQ,6BAAS,QAAQ,QAAQ;AACvC,OAAM,QAAQ,IAAI,MAAM,KAAK,SAASA,iBAAG,OAAO,KAAK,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Options, Pattern } from "fast-glob/out/index";
2
+
3
+ //#region src/removeFiles/removeFiles.d.ts
4
+ declare function removeFiles(source: Pattern | Pattern[], options?: Options): Promise<void>;
5
+ export = removeFiles;
6
+ //# sourceMappingURL=removeFiles.d.cts.map
@@ -0,0 +1,7 @@
1
+ import { Options, Pattern } from "fast-glob/out/index";
2
+
3
+ //#region src/removeFiles/removeFiles.d.ts
4
+ declare function removeFiles(source: Pattern | Pattern[], options?: Options): Promise<void>;
5
+ //#endregion
6
+ export { removeFiles as default };
7
+ //# sourceMappingURL=removeFiles.d.mts.map
@@ -0,0 +1,12 @@
1
+ import fs from "fs-extra";
2
+ import fg from "fast-glob";
3
+
4
+ //#region src/removeFiles/removeFiles.ts
5
+ async function removeFiles(source, options = {}) {
6
+ const files = await fg(source, options);
7
+ await Promise.all(files.map((file) => fs.remove(file)));
8
+ }
9
+
10
+ //#endregion
11
+ export { removeFiles as default };
12
+ //# sourceMappingURL=removeFiles.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeFiles.mjs","names":[],"sources":["../../src/removeFiles/removeFiles.ts"],"sourcesContent":["import fg from 'fast-glob';\r\nimport type { Options, Pattern } from 'fast-glob/out/index';\r\nimport fs from 'fs-extra';\r\n\r\nexport default async function removeFiles(\r\n source: Pattern | Pattern[],\r\n options: Options = {},\r\n) {\r\n const files = await fg(source, options);\r\n await Promise.all(files.map((file) => fs.remove(file)));\r\n}\r\n"],"mappings":";;;;AAIA,eAA8B,YAC5B,QACA,UAAmB,EAAE,EACrB;CACA,MAAM,QAAQ,MAAM,GAAG,QAAQ,QAAQ;AACvC,OAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,GAAG,OAAO,KAAK,CAAC,CAAC"}
File without changes
@@ -0,0 +1,9 @@
1
+ import { Options } from "fast-glob/out";
2
+
3
+ //#region src/removeFiles/types.d.ts
4
+ type RemoveFilesOptions = {
5
+ fastGlobOptions?: Options;
6
+ };
7
+ //#endregion
8
+ export { RemoveFilesOptions };
9
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1,9 @@
1
+ import { Options } from "fast-glob/out";
2
+
3
+ //#region src/removeFiles/types.d.ts
4
+ type RemoveFilesOptions = {
5
+ fastGlobOptions?: Options;
6
+ };
7
+ //#endregion
8
+ export { RemoveFilesOptions };
9
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ export { };
package/ver/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ const require_ver_ver = require('./ver.cjs');
2
+
3
+ module.exports = require_ver_ver;
@@ -0,0 +1,3 @@
1
+ import { VerOptions } from "./types.cjs";
2
+ import ver from "./ver.cjs";
3
+ export { VerOptions, ver as default };
@@ -0,0 +1,3 @@
1
+ import { VerOptions } from "./types.mjs";
2
+ import ver from "./ver.mjs";
3
+ export { VerOptions, ver as default };
package/ver/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import ver from "./ver.mjs";
2
+
3
+ export { ver as default };
package/ver/types.cjs ADDED
File without changes
@@ -1,13 +1,16 @@
1
- export type VerOptions = {
2
- /**
3
- * ワークスペースのパッケージjsonのパス
4
- * @default `./package.json`
5
- */
6
- workspacePackageJsonPath?: string;
7
-
8
- /**
9
- * パッケージが置かれたディレクトリのパス
10
- * @default `./packages`
11
- */
12
- packagesPath?: string;
13
- };
1
+ //#region src/ver/types.d.ts
2
+ type VerOptions = {
3
+ /**
4
+ * ワークスペースのパッケージjsonのパス
5
+ * @default `./package.json`
6
+ */
7
+ workspacePackageJsonPath?: string;
8
+ /**
9
+ * パッケージが置かれたディレクトリのパス
10
+ * @default `./packages`
11
+ */
12
+ packagesPath?: string;
13
+ };
14
+ //#endregion
15
+ export { VerOptions };
16
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1,16 @@
1
+ //#region src/ver/types.d.ts
2
+ type VerOptions = {
3
+ /**
4
+ * ワークスペースのパッケージjsonのパス
5
+ * @default `./package.json`
6
+ */
7
+ workspacePackageJsonPath?: string;
8
+ /**
9
+ * パッケージが置かれたディレクトリのパス
10
+ * @default `./packages`
11
+ */
12
+ packagesPath?: string;
13
+ };
14
+ //#endregion
15
+ export { VerOptions };
16
+ //# sourceMappingURL=types.d.mts.map
package/ver/types.mjs ADDED
@@ -0,0 +1 @@
1
+ export { };
package/ver/ver.cjs ADDED
@@ -0,0 +1,34 @@
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
+ path = require_runtime.__toESM(path, 1);
6
+
7
+ //#region src/ver/ver.ts
8
+ /**
9
+ * ワークスペースのパッケージにバージョンを反映する
10
+ * @param version バージョン
11
+ * @param options オプション
12
+ */
13
+ async function ver(version, options = {}) {
14
+ const { workspacePackageJsonPath = "package.json", packagesPath = "packages" } = options;
15
+ if (fs_extra.default.existsSync(workspacePackageJsonPath)) _updatePkgJson(version, workspacePackageJsonPath);
16
+ const pkgs = fs_extra.default.readdirSync(packagesPath);
17
+ for (const pkg of pkgs) {
18
+ const packagePath = path.default.join(packagesPath, pkg);
19
+ const packageJsonPath = path.default.join(packagePath, "package.json");
20
+ if (fs_extra.default.existsSync(packageJsonPath)) _updatePkgJson(version, packageJsonPath);
21
+ }
22
+ }
23
+ function _updatePkgJson(version, packageJsonPath) {
24
+ const packageJson = fs_extra.default.readJsonSync(packageJsonPath, { encoding: "utf8" });
25
+ packageJson.version = version;
26
+ fs_extra.default.writeJsonSync(packageJsonPath, packageJson, {
27
+ encoding: "utf8",
28
+ spaces: 2
29
+ });
30
+ }
31
+
32
+ //#endregion
33
+ module.exports = ver;
34
+ //# sourceMappingURL=ver.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ver.cjs","names":["fs"],"sources":["../../src/ver/ver.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport path from 'path';\r\nimport type { VerOptions } from './types';\r\n\r\n/**\r\n * ワークスペースのパッケージにバージョンを反映する\r\n * @param version バージョン\r\n * @param options オプション\r\n */\r\nexport default async function ver(version: string, options: VerOptions = {}) {\r\n const {\r\n workspacePackageJsonPath = 'package.json',\r\n packagesPath = 'packages',\r\n } = options;\r\n\r\n if (fs.existsSync(workspacePackageJsonPath)) {\r\n // ワークスペースのpackage.jsonを更新\r\n _updatePkgJson(version, workspacePackageJsonPath);\r\n }\r\n const pkgs = fs.readdirSync(packagesPath);\r\n for (const pkg of pkgs) {\r\n const packagePath = path.join(packagesPath, pkg);\r\n const packageJsonPath = path.join(packagePath, 'package.json');\r\n if (fs.existsSync(packageJsonPath)) {\r\n // 各パッケージのpackage.jsonを更新\r\n _updatePkgJson(version, packageJsonPath);\r\n }\r\n }\r\n}\r\n\r\nfunction _updatePkgJson(version: string, packageJsonPath: string) {\r\n const packageJson = fs.readJsonSync(packageJsonPath, { encoding: 'utf8' });\r\n packageJson.version = version;\r\n fs.writeJsonSync(packageJsonPath, packageJson, {\r\n encoding: 'utf8',\r\n spaces: 2,\r\n });\r\n}\r\n"],"mappings":";;;;;;;;;;;;AASA,eAA8B,IAAI,SAAiB,UAAsB,EAAE,EAAE;CAC3E,MAAM,EACJ,2BAA2B,gBAC3B,eAAe,eACb;AAEJ,KAAIA,iBAAG,WAAW,yBAAyB,CAEzC,gBAAe,SAAS,yBAAyB;CAEnD,MAAM,OAAOA,iBAAG,YAAY,aAAa;AACzC,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,cAAc,aAAK,KAAK,cAAc,IAAI;EAChD,MAAM,kBAAkB,aAAK,KAAK,aAAa,eAAe;AAC9D,MAAIA,iBAAG,WAAW,gBAAgB,CAEhC,gBAAe,SAAS,gBAAgB;;;AAK9C,SAAS,eAAe,SAAiB,iBAAyB;CAChE,MAAM,cAAcA,iBAAG,aAAa,iBAAiB,EAAE,UAAU,QAAQ,CAAC;AAC1E,aAAY,UAAU;AACtB,kBAAG,cAAc,iBAAiB,aAAa;EAC7C,UAAU;EACV,QAAQ;EACT,CAAC"}
package/ver/ver.d.cts ADDED
@@ -0,0 +1,11 @@
1
+ import { VerOptions } from "./types.cjs";
2
+
3
+ //#region src/ver/ver.d.ts
4
+ /**
5
+ * ワークスペースのパッケージにバージョンを反映する
6
+ * @param version バージョン
7
+ * @param options オプション
8
+ */
9
+ declare function ver(version: string, options?: VerOptions): Promise<void>;
10
+ export = ver;
11
+ //# sourceMappingURL=ver.d.cts.map
package/ver/ver.d.mts ADDED
@@ -0,0 +1,12 @@
1
+ import { VerOptions } from "./types.mjs";
2
+
3
+ //#region src/ver/ver.d.ts
4
+ /**
5
+ * ワークスペースのパッケージにバージョンを反映する
6
+ * @param version バージョン
7
+ * @param options オプション
8
+ */
9
+ declare function ver(version: string, options?: VerOptions): Promise<void>;
10
+ //#endregion
11
+ export { ver as default };
12
+ //# sourceMappingURL=ver.d.mts.map
package/ver/ver.mjs ADDED
@@ -0,0 +1,31 @@
1
+ import fs from "fs-extra";
2
+ import path from "path";
3
+
4
+ //#region src/ver/ver.ts
5
+ /**
6
+ * ワークスペースのパッケージにバージョンを反映する
7
+ * @param version バージョン
8
+ * @param options オプション
9
+ */
10
+ async function ver(version, options = {}) {
11
+ const { workspacePackageJsonPath = "package.json", packagesPath = "packages" } = options;
12
+ if (fs.existsSync(workspacePackageJsonPath)) _updatePkgJson(version, workspacePackageJsonPath);
13
+ const pkgs = fs.readdirSync(packagesPath);
14
+ for (const pkg of pkgs) {
15
+ const packagePath = path.join(packagesPath, pkg);
16
+ const packageJsonPath = path.join(packagePath, "package.json");
17
+ if (fs.existsSync(packageJsonPath)) _updatePkgJson(version, packageJsonPath);
18
+ }
19
+ }
20
+ function _updatePkgJson(version, packageJsonPath) {
21
+ const packageJson = fs.readJsonSync(packageJsonPath, { encoding: "utf8" });
22
+ packageJson.version = version;
23
+ fs.writeJsonSync(packageJsonPath, packageJson, {
24
+ encoding: "utf8",
25
+ spaces: 2
26
+ });
27
+ }
28
+
29
+ //#endregion
30
+ export { ver as default };
31
+ //# sourceMappingURL=ver.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ver.mjs","names":[],"sources":["../../src/ver/ver.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport path from 'path';\r\nimport type { VerOptions } from './types';\r\n\r\n/**\r\n * ワークスペースのパッケージにバージョンを反映する\r\n * @param version バージョン\r\n * @param options オプション\r\n */\r\nexport default async function ver(version: string, options: VerOptions = {}) {\r\n const {\r\n workspacePackageJsonPath = 'package.json',\r\n packagesPath = 'packages',\r\n } = options;\r\n\r\n if (fs.existsSync(workspacePackageJsonPath)) {\r\n // ワークスペースのpackage.jsonを更新\r\n _updatePkgJson(version, workspacePackageJsonPath);\r\n }\r\n const pkgs = fs.readdirSync(packagesPath);\r\n for (const pkg of pkgs) {\r\n const packagePath = path.join(packagesPath, pkg);\r\n const packageJsonPath = path.join(packagePath, 'package.json');\r\n if (fs.existsSync(packageJsonPath)) {\r\n // 各パッケージのpackage.jsonを更新\r\n _updatePkgJson(version, packageJsonPath);\r\n }\r\n }\r\n}\r\n\r\nfunction _updatePkgJson(version: string, packageJsonPath: string) {\r\n const packageJson = fs.readJsonSync(packageJsonPath, { encoding: 'utf8' });\r\n packageJson.version = version;\r\n fs.writeJsonSync(packageJsonPath, packageJson, {\r\n encoding: 'utf8',\r\n spaces: 2,\r\n });\r\n}\r\n"],"mappings":";;;;;;;;;AASA,eAA8B,IAAI,SAAiB,UAAsB,EAAE,EAAE;CAC3E,MAAM,EACJ,2BAA2B,gBAC3B,eAAe,eACb;AAEJ,KAAI,GAAG,WAAW,yBAAyB,CAEzC,gBAAe,SAAS,yBAAyB;CAEnD,MAAM,OAAO,GAAG,YAAY,aAAa;AACzC,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,cAAc,KAAK,KAAK,cAAc,IAAI;EAChD,MAAM,kBAAkB,KAAK,KAAK,aAAa,eAAe;AAC9D,MAAI,GAAG,WAAW,gBAAgB,CAEhC,gBAAe,SAAS,gBAAgB;;;AAK9C,SAAS,eAAe,SAAiB,iBAAyB;CAChE,MAAM,cAAc,GAAG,aAAa,iBAAiB,EAAE,UAAU,QAAQ,CAAC;AAC1E,aAAY,UAAU;AACtB,IAAG,cAAc,iBAAiB,aAAa;EAC7C,UAAU;EACV,QAAQ;EACT,CAAC"}
@@ -1,98 +0,0 @@
1
- import fs from 'fs-extra';
2
- import { posix as path } from 'path';
3
- import isMatchingPath from '../isMatchingPath';
4
- import type { AddExportsOptions } from './types';
5
-
6
- /**
7
- * index.tsが配置されているモジュールをpackage.jsonのexportsに追加する
8
- * @param targetPath
9
- * @param options
10
- */
11
- export default function addExports(
12
- targetPath: string = 'src',
13
- options: AddExportsOptions = {},
14
- ) {
15
- let {
16
- packageJsonPath = 'package.json',
17
- include = [],
18
- dist = 'dist',
19
- dryRun,
20
- ...rest
21
- } = options;
22
-
23
- // 処理対象を設定
24
- include = [
25
- // indexファイルを対象
26
- {
27
- valueType: 'base',
28
- entryType: 'file',
29
- conditions: /^index.(ts|tsx)$/i,
30
- },
31
- ...include,
32
- ];
33
-
34
- // exportsをpackage.jsonに追加
35
- const exportsIndex = _addExports(targetPath, {
36
- packageJsonPath,
37
- include,
38
- dist,
39
- ...rest,
40
- });
41
-
42
- const packageJson = fs.readJsonSync(packageJsonPath, { encoding: 'utf8' });
43
- packageJson.exports = {};
44
- exportsIndex.sort((a, b) => (a.key > b.key ? 1 : -1));
45
- for (const index of exportsIndex) {
46
- packageJson.exports[index.key ? './' + index.key : '.'] =
47
- './' + index.path + '.js';
48
- }
49
- if (dryRun) {
50
- console.log(packageJson);
51
- } else {
52
- fs.writeJsonSync(packageJsonPath, packageJson, {
53
- encoding: 'utf8',
54
- spaces: 2,
55
- });
56
- }
57
- }
58
-
59
- function _addExports(
60
- targetPath: string,
61
- options: AddExportsOptions,
62
- current: string = '',
63
- ) {
64
- const { include = [], exclude = [], dist = 'dist' } = options;
65
-
66
- const stat = fs.statSync(targetPath);
67
- if (!stat.isDirectory()) {
68
- console.error(`"${targetPath}" is not directory.`);
69
- }
70
- const items = fs.readdirSync(targetPath);
71
- items.sort();
72
- const exportsIndex: { key: string; path: string }[] = [];
73
-
74
- for (const item of items) {
75
- const itemPath = path.join(targetPath, item);
76
- const stat = fs.statSync(itemPath);
77
- const { name } = path.parse(itemPath);
78
-
79
- if (stat.isDirectory()) {
80
- // ディレクトリの場合は先に子要素を処理
81
- exportsIndex.push(
82
- ..._addExports(itemPath, options, path.join(current, item)),
83
- );
84
- } else if (
85
- stat.isFile() &&
86
- isMatchingPath(itemPath, include) &&
87
- !isMatchingPath(itemPath, exclude)
88
- ) {
89
- // exportの対象の場合
90
- exportsIndex.push({
91
- key: current,
92
- path: path.join(dist, current, name),
93
- });
94
- }
95
- }
96
-
97
- return exportsIndex;
98
- }
@@ -1,2 +0,0 @@
1
- export { default } from './addExports';
2
- export type * from './types';
@@ -1,31 +0,0 @@
1
- import fg from 'fast-glob';
2
- import fs from 'fs-extra';
3
-
4
- const PATTERNS = {
5
- '.js': /(?:from|import)\s*["'](\.\.?\/[^"']+)["']/g,
6
- '.cjs': /require\(["'](\.\.?\/[^"']+)["']\)/g,
7
- };
8
-
9
- /**
10
- * JSONファイルを更新する
11
- * @param jsonFilePath
12
- * @param editor
13
- */
14
- export default async function addJsExtensions(dir: string) {
15
- const files = await fg(`${dir}/**/*.{js,cjs}`);
16
- for (const file of files) {
17
- const content = await fs.readFile(file, 'utf-8');
18
- const ext = file.endsWith('.cjs') ? '.cjs' : '.js';
19
- const fixed = content.replace(PATTERNS[ext], (match, pos1) => {
20
- if (pos1.endsWith(ext)) {
21
- // 既に拡張子あり
22
- return match;
23
- }
24
- // 拡張子を付与
25
- return match.replace(pos1, `${pos1}${ext}`);
26
- });
27
- if (content !== fixed) {
28
- await fs.writeFile(file, fixed);
29
- }
30
- }
31
- }
@@ -1 +0,0 @@
1
- export { default } from './addJsExtensions';
@@ -1,16 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- /**
4
- * ディレクトリ、ファイルの存在チェック
5
- * @param targetPaths
6
- * @param options
7
- */
8
- export default function checkExistence(...targetPaths: string[]) {
9
- return targetPaths.every((targetPath) => {
10
- if (!fs.existsSync(targetPath)) {
11
- console.error(`${targetPath}が存在しません。`);
12
- return false;
13
- }
14
- return true;
15
- });
16
- }
@@ -1 +0,0 @@
1
- export { default } from './checkExistence';
@@ -1,30 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import { isFunction, merge } from 'remeda';
4
- import checkExistence from '../checkExistence';
5
-
6
- /**
7
- * JSONファイルを更新する
8
- * @param jsonFilePath
9
- * @param editor
10
- */
11
- function editJsonFile(
12
- jsonFilePath: string,
13
- editor: ((obj: any) => object) | object,
14
- ) {
15
- const resolvedJsonFilePath = path.resolve(jsonFilePath);
16
- if (checkExistence(resolvedJsonFilePath)) {
17
- const obj = fs.readJSONSync(resolvedJsonFilePath);
18
- let editedJson;
19
- if (isFunction(editor)) {
20
- // 関数で編集する場合
21
- editedJson = editor(obj);
22
- } else {
23
- // 差分を反映する場合
24
- editedJson = merge(obj, editor);
25
- }
26
- fs.writeJSONSync(resolvedJsonFilePath, editedJson, { spaces: 2 });
27
- }
28
- }
29
-
30
- export default editJsonFile;
@@ -1 +0,0 @@
1
- export { default } from './editJsonFile';
@@ -1,55 +0,0 @@
1
- import fs from 'fs-extra';
2
- import type { GeneratePublishPackageJsonOptions } from './types';
3
-
4
- async function generatePublishPackageJson(
5
- options: GeneratePublishPackageJsonOptions = {},
6
- ) {
7
- const {
8
- packageJsonPath = './package.json',
9
- outputPackageJsonPath = './dist/package.json',
10
- exports = {
11
- '.': {
12
- import: './index.js',
13
- reqire: './index.cjs',
14
- type: './index.d.ts',
15
- },
16
- './*': {
17
- import: './*/index.js',
18
- reqire: './*/index.cjs',
19
- type: './*/index.d.ts',
20
- },
21
- './constants': {
22
- import: './constants.js',
23
- reqire: './constants.cjs',
24
- type: './constants.d.ts',
25
- },
26
- './*/constants': {
27
- import: './*/constants.js',
28
- reqire: './*/constants.cjs',
29
- type: './*/constants.d.ts',
30
- },
31
- },
32
- transform = (pkgJson) => pkgJson,
33
- jsonReadOptions,
34
- jsonWriteOptions,
35
- } = options;
36
- const packageJson = await fs.readJSON(packageJsonPath, jsonReadOptions);
37
- const distPackageJson = {
38
- name: packageJson.name,
39
- version: packageJson.version,
40
- keywords: packageJson.keywords,
41
- repository: packageJson.repository,
42
- license: packageJson.license,
43
- author: packageJson.author,
44
- type: packageJson.type,
45
- exports,
46
- dependencies: packageJson.dependencies,
47
- };
48
- await fs.writeJSON(
49
- outputPackageJsonPath,
50
- transform(distPackageJson),
51
- jsonWriteOptions,
52
- );
53
- }
54
-
55
- export default generatePublishPackageJson;
@@ -1,2 +0,0 @@
1
- export { default } from './generatePublishPackageJson';
2
- export type * from './types';
package/src/index.ts DELETED
@@ -1,10 +0,0 @@
1
- export { default as addExports } from './addExports';
2
- export { default as addJsExtensions } from './addJsExtensions';
3
- export { default as checkExistence } from './checkExistence';
4
- export { default as editJsonFile } from './editJsonFile';
5
- export { default as generatePublishPackageJson } from './generatePublishPackageJson';
6
- export { default as indexes } from './indexes';
7
- export { default as installFromLocal } from './installFromLocal';
8
- export { default as isMatchingPath } from './isMatchingPath';
9
- export { default as moveFilesToSubdir } from './moveFilesToSubdir';
10
- export { default as ver } from './ver';