@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
@@ -1,63 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import { reduce } from 'remeda';
4
- import checkExistence from '../checkExistence';
5
- import type { InstallFromLocalOptions } from './types';
6
-
7
- /**
8
- * ローカルに配置されたパッケージを差し替える
9
- * @param localNodeModulesPath ローカルのnode_modulesディレクトリのパス
10
- * @param options オプション
11
- */
12
- export default function installFromLocal(
13
- localNodeModulesPath: string,
14
- options: InstallFromLocalOptions = {},
15
- ) {
16
- const {
17
- packageJsonPath = './package.json',
18
- nodeModulesPath = './node_modules',
19
- dryRun,
20
- } = options;
21
- const resolvedLocalNodeModulesPath = path.resolve(localNodeModulesPath);
22
- const resolvedPackageJsonPath = path.resolve(packageJsonPath);
23
-
24
- if (!checkExistence(resolvedLocalNodeModulesPath, resolvedPackageJsonPath)) {
25
- return;
26
- }
27
-
28
- console.info(`${localNodeModulesPath} -> ${nodeModulesPath}`);
29
-
30
- // package.jsonからローカルのnode_modulesにあるパッケージを取得
31
- const packageJson = fs.readJSONSync(resolvedPackageJsonPath);
32
- const localPackages = reduce(
33
- { ...packageJson.dependencies, ...packageJson.devDependencies },
34
- (result: Record<string, string>, value: string, key) => {
35
- if (value.startsWith(localNodeModulesPath)) {
36
- result[key] = value;
37
- } else if (value.startsWith(`file:${localNodeModulesPath}`)) {
38
- result[key] = value.substring(5);
39
- }
40
- return result;
41
- },
42
- {},
43
- );
44
-
45
- for (const packageName in localPackages) {
46
- // ローカルパッケージの確認
47
- const localPackagePath = path.resolve(localPackages[packageName]);
48
- if (fs.existsSync(localPackagePath)) {
49
- // ローカルパッケージがある場合のみ処理
50
- const installedPackagePath = path.resolve(nodeModulesPath, packageName);
51
- if (!dryRun) {
52
- // コピーを行う
53
- if (fs.existsSync(installedPackagePath)) {
54
- // 古いパッケージは削除
55
- fs.removeSync(installedPackagePath);
56
- }
57
- // パッケージをコピー
58
- fs.copySync(localPackagePath, installedPackagePath);
59
- }
60
- console.info(`${packageName} is being copied...`);
61
- }
62
- }
63
- }
@@ -1,2 +0,0 @@
1
- export { default } from './isMatchingPath';
2
- export type * from './types';
@@ -1,94 +0,0 @@
1
- import fs from 'fs-extra';
2
- import { posix as path } from 'path';
3
- import { isFunction, isString } from 'remeda';
4
- import type {
5
- ConditionFnOptions,
6
- ConditionValues,
7
- IsMatchingPathCondition,
8
- IsMatchingPathOptions,
9
- } from './types';
10
-
11
- /**
12
- * 処理対象のパスか判定する
13
- * @param targetPath 検査対象のパス
14
- * @param conditions 一致条件
15
- * @param options オプション
16
- * @returns 一致するか
17
- */
18
- export default function isMatchingPath<
19
- O extends ConditionFnOptions = ConditionFnOptions,
20
- >(
21
- targetPath: string,
22
- conditions:
23
- | IsMatchingPathCondition<O>
24
- | IsMatchingPathCondition<O>[]
25
- | null
26
- | undefined,
27
- options: IsMatchingPathOptions<O> = {},
28
- ) {
29
- if (!conditions) {
30
- return false;
31
- }
32
- const conditionList = Array.isArray(conditions) ? conditions : [conditions];
33
- // パスは'/'区切り
34
- const posixPath = path.normalize(targetPath);
35
- const parsedPath = path.parse(posixPath);
36
- const parsedDir = path.parse(parsedPath.dir);
37
- const values = {
38
- path: posixPath,
39
- ...parsedPath,
40
- dirpath: parsedPath.dir,
41
- dirbase: parsedDir.base,
42
- dirname: parsedDir.name,
43
- dirext: parsedDir.ext,
44
- };
45
- values.path = posixPath;
46
-
47
- for (const condition of conditionList) {
48
- if (_isMatching(values.path, values, condition, options)) {
49
- // conditionの内の何れかがtrueならば一致
50
- return true;
51
- }
52
- }
53
- return false;
54
- }
55
-
56
- function _isMatching<O extends ConditionFnOptions = ConditionFnOptions>(
57
- value: string,
58
- values: ConditionValues,
59
- condition: IsMatchingPathCondition<O>,
60
- options: IsMatchingPathOptions<O>,
61
- ): boolean {
62
- if (isString(condition)) {
63
- // 条件が文字列
64
- if (value.includes(condition)) {
65
- return true;
66
- }
67
- } else if (condition instanceof RegExp) {
68
- // 条件が正規表現
69
- if (condition.test(value)) {
70
- return true;
71
- }
72
- } else if (isFunction(condition)) {
73
- // 条件が関数
74
- return condition(values, (options.conditionOptions ?? {}) as O);
75
- } else {
76
- // 条件が設定
77
- const { valueType = 'path', entryType = 'both', conditions } = condition;
78
- if (entryType !== 'both') {
79
- const stat = fs.statSync(values.path);
80
- if (
81
- (stat.isDirectory() && entryType !== 'dir') ||
82
- (stat.isFile() && entryType !== 'file')
83
- ) {
84
- return false;
85
- }
86
- }
87
- const conditionList = Array.isArray(conditions) ? conditions : [conditions];
88
- // 設定配下のconditionsはand条件
89
- return conditionList.every((cond) =>
90
- _isMatching(values[valueType], values, cond, options),
91
- );
92
- }
93
- return false;
94
- }
@@ -1,95 +0,0 @@
1
- import type { ParsedPath } from 'path';
2
-
3
- /**
4
- * 一致条件
5
- *
6
- * - string: 指定された文字列がパスに含まれているものに一致する際にtrue
7
- * - RegExp: 指定された正規表現にパスが一致する際にtrue
8
- * - ConditionConfig: 条件設定に従って検査し一致したときにtrue
9
- */
10
- export type IsMatchingPathCondition<
11
- O extends ConditionFnOptions = ConditionFnOptions,
12
- > = string | RegExp | ConditionConfig<O> | ConditionFn<O>;
13
-
14
- export type IsMatchingPathOptions<
15
- O extends ConditionFnOptions = ConditionFnOptions,
16
- > = {
17
- /**
18
- * ConditionFnに渡すオプション
19
- */
20
- conditionOptions?: O;
21
- };
22
-
23
- /**
24
- * 条件設定
25
- */
26
- export type ConditionConfig<O extends ConditionFnOptions = ConditionFnOptions> =
27
- {
28
- /**
29
- * 検査対象の値
30
- *
31
- * - path: '/'で区切られたフルパス
32
- * - base: 拡張子付きのディレクトリ名 or ファイル名
33
- * - name: 拡張子を除いたディレクトリ名 or ファイル名
34
- * - ext: '.'を含む拡張子。拡張子が無い場合は空文字
35
- * - dirpath: '/'で区切られた親ディレクトリのフルパス
36
- * - base: 拡張子付きの親ディレクトリ名
37
- * - name: 拡張子を除いた親ディレクトリ名
38
- * - ext: '.'を含む親ディレクトリの拡張子。拡張子が無い場合は空文字
39
- */
40
- valueType?:
41
- | 'path'
42
- | 'base'
43
- | 'name'
44
- | 'ext'
45
- | 'dirpath'
46
- | 'dirbase'
47
- | 'dirname'
48
- | 'dirext';
49
-
50
- /**
51
- * 検査対象の種別
52
- *
53
- * - dir: ディレクトリ
54
- * - file: ファイル
55
- * - both: ディレクトリ & ファイル
56
- */
57
- entryType?: 'dir' | 'file' | 'both';
58
-
59
- /**
60
- * 一致条件
61
- * 配列で指定した場合はand条件とする
62
- *
63
- * - string: 指定された文字列を含むものに一致
64
- * - RegExp: 指定された正規表現に一致
65
- */
66
- conditions:
67
- | string
68
- | RegExp
69
- | ConditionFn<O>
70
- | (string | RegExp | ConditionFn<O>)[];
71
- };
72
-
73
- /**
74
- * カスタム条件関数
75
- */
76
- export type ConditionFn<O extends ConditionFnOptions = ConditionFnOptions> = (
77
- values: ConditionValues,
78
- options: O,
79
- ) => boolean;
80
-
81
- /**
82
- * カスタム条件関数のオプション
83
- */
84
- export type ConditionFnOptions = Record<string, any>;
85
-
86
- /**
87
- * 検証対象の値
88
- */
89
- export type ConditionValues = {
90
- path: string;
91
- dirpath: string;
92
- dirbase: string;
93
- dirname: string;
94
- dirext: string;
95
- } & ParsedPath;
@@ -1,2 +0,0 @@
1
- export { default } from './isTargetPath';
2
- export type * from './types';
@@ -1,30 +0,0 @@
1
- import fs, { Stats } from 'fs-extra';
2
- import type { ConditionFnOptions } from '../isMatchingPath';
3
- import isMatchingPath from '../isMatchingPath';
4
- import type { IsTargetPathOptions } from './types';
5
-
6
- const IS_TARGET_TYPE = {
7
- file: (stat: Stats) => stat.isFile(),
8
- dir: (stat: Stats) => stat.isDirectory(),
9
- both: (stat: Stats) => stat.isFile() || stat.isDirectory(),
10
- } as const;
11
-
12
- export default async function isTargetPath<
13
- O extends ConditionFnOptions = ConditionFnOptions,
14
- >(itemPath: string, options: IsTargetPathOptions<O> = {}) {
15
- const {
16
- itemType = 'file',
17
- defaultInclude,
18
- defaultExclude,
19
- include = defaultInclude,
20
- exclude = defaultExclude,
21
- ...rest
22
- } = options;
23
- const stat = fs.statSync(itemPath);
24
-
25
- return (
26
- IS_TARGET_TYPE[itemType](stat) &&
27
- (!include || isMatchingPath(itemPath, include, rest)) &&
28
- (!exclude || !isMatchingPath(itemPath, exclude, rest))
29
- );
30
- }
@@ -1,2 +0,0 @@
1
- export { default } from './moveFilesToSubdir';
2
- export type * from './types';
@@ -1,40 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import isTargetPath from '../isTargetPath';
4
- import type { MoveFilesToSubdirOptions } from './types';
5
-
6
- /**
7
- * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する
8
- * @param dirPath 対象のディレクトリのパス
9
- */
10
- export default async function moveFilesToSubdir(
11
- dirPath: string,
12
- options: MoveFilesToSubdirOptions = {},
13
- ) {
14
- const { process, index, ...rest } = options;
15
- const items = await fs.readdir(dirPath);
16
- for (const item of items) {
17
- const itemPath = path.join(dirPath, item);
18
- if (isTargetPath(itemPath, rest)) {
19
- const { name, ext } = path.parse(item);
20
- // 移動先のディレクトリパスを生成
21
- const subdirPath = path.join(dirPath, name);
22
- // 移動先のディレクトリが存在しなければ作成
23
- fs.ensureDirSync(subdirPath);
24
- // 移動
25
- fs.moveSync(itemPath, path.join(subdirPath, item));
26
- if (index) {
27
- fs.writeFileSync(
28
- path.join(subdirPath, `index.${ext}`),
29
- `export { default } from ${name}`,
30
- {
31
- encoding: 'utf8',
32
- },
33
- );
34
- }
35
- if (process) {
36
- process(subdirPath, item);
37
- }
38
- }
39
- }
40
- }
@@ -1 +0,0 @@
1
- export { default } from './removeFiles';
@@ -1,11 +0,0 @@
1
- import type { Options, Pattern } from 'fast-glob';
2
- import fg from 'fast-glob';
3
- import fs from 'fs-extra';
4
-
5
- export default async function removeFiles(
6
- source: Pattern | Pattern[],
7
- options: Options = {},
8
- ) {
9
- const files = await fg(source, options);
10
- await Promise.all(files.map((file) => fs.remove(file)));
11
- }
@@ -1,5 +0,0 @@
1
- import type { Options } from 'fast-glob';
2
-
3
- export type RemoveFilesOptions = {
4
- fastGlobOptions?: Options;
5
- };
package/src/ver/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export type * from './types';
2
- export { default } from './ver';
package/src/ver/ver.ts DELETED
@@ -1,38 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import type { VerOptions } from './types';
4
-
5
- /**
6
- * ワークスペースのパッケージにバージョンを反映する
7
- * @param version バージョン
8
- * @param options オプション
9
- */
10
- export default async function ver(version: string, options: VerOptions = {}) {
11
- const {
12
- workspacePackageJsonPath = 'package.json',
13
- packagesPath = 'packages',
14
- } = options;
15
-
16
- if (fs.existsSync(workspacePackageJsonPath)) {
17
- // ワークスペースのpackage.jsonを更新
18
- _updatePkgJson(version, workspacePackageJsonPath);
19
- }
20
- const pkgs = fs.readdirSync(packagesPath);
21
- for (const pkg of pkgs) {
22
- const packagePath = path.join(packagesPath, pkg);
23
- const packageJsonPath = path.join(packagePath, 'package.json');
24
- if (fs.existsSync(packageJsonPath)) {
25
- // 各パッケージのpackage.jsonを更新
26
- _updatePkgJson(version, packageJsonPath);
27
- }
28
- }
29
- }
30
-
31
- function _updatePkgJson(version: string, packageJsonPath: string) {
32
- const packageJson = fs.readJsonSync(packageJsonPath, { encoding: 'utf8' });
33
- packageJson.version = version;
34
- fs.writeJsonSync(packageJsonPath, packageJson, {
35
- encoding: 'utf8',
36
- spaces: 2,
37
- });
38
- }
package/tsconfig.json DELETED
@@ -1,46 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2023",
4
- "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "lib": ["ES2023", "DOM", "DOM.Iterable"],
7
- "types": ["node"],
8
- "skipLibCheck": true,
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "verbatimModuleSyntax": true,
13
- "moduleDetection": "force",
14
- "noEmit": true,
15
- /* Linting */
16
- "strict": true,
17
- "noUnusedLocals": true,
18
- "noUnusedParameters": true,
19
- "erasableSyntaxOnly": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "noUncheckedSideEffectImports": true,
22
- /* Source */
23
- "rootDir": "src",
24
- "outDir": "dist",
25
- "declarationDir": "dist",
26
- "typeRoots": ["./node_modules/@types"],
27
- "jsx": "react-jsx",
28
- "allowJs": true,
29
- "checkJs": true,
30
- "declaration": true,
31
- "declarationMap": false,
32
- "sourceMap": false,
33
- "inlineSources": false,
34
- "removeComments": false,
35
- "importHelpers": true,
36
- "noImplicitAny": false,
37
- "esModuleInterop": true,
38
- "forceConsistentCasingInFileNames": true,
39
- "strictNullChecks": false,
40
- "strictPropertyInitialization": false,
41
- "preserveSymlinks": false,
42
- "ignoreDeprecations": "6.0"
43
- },
44
- "include": ["src"],
45
- "exclude": ["src/**/*.test.*"]
46
- }
package/tsdown.config.ts DELETED
@@ -1,41 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import { defineConfig } from 'tsdown';
4
- import addJsExtensions from './src/addJsExtensions';
5
- import generatePublishPackageJson from './src/generatePublishPackageJson';
6
- import removeFiles from './src/removeFiles';
7
-
8
- export default defineConfig((options) => ({
9
- entry: ['./src/**/*.ts'],
10
- unbundle: true,
11
- sourcemap: true,
12
- clean: true,
13
- dts: true,
14
- format: ['cjs', 'esm'],
15
- minify: false,
16
- plugins: [
17
- {
18
- name: 'post-build',
19
- async buildEnd() {
20
- const opts = options ?? {};
21
- if (opts.watch) {
22
- return;
23
- }
24
-
25
- const outDir = opts.outDir ?? 'dist';
26
- await Promise.all([
27
- // import,requireの補完
28
- addJsExtensions(outDir),
29
- // package.jsonの編集
30
- generatePublishPackageJson({
31
- jsonWriteOptions: { spaces: 2 },
32
- }),
33
- // その他のファイルのコピー
34
- fs.copyFile('LICENSE', path.join(outDir, 'LICENSE')),
35
- fs.copyFile('README.md', path.join(outDir, 'README.md')),
36
- ]);
37
- await removeFiles(`${outDir}/**/*.d.cts`);
38
- },
39
- },
40
- ],
41
- }));