@niche-works/dev 0.1.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 (145) hide show
  1. package/addExports/addExports.cjs +71 -0
  2. package/addExports/addExports.cjs.map +1 -0
  3. package/addExports/addExports.d.cts +13 -0
  4. package/addExports/addExports.d.ts +13 -0
  5. package/addExports/addExports.js +71 -0
  6. package/addExports/addExports.js.map +1 -0
  7. package/addExports/index.cjs +5 -0
  8. package/addExports/index.cjs.map +1 -0
  9. package/addExports/index.d.cts +5 -0
  10. package/addExports/index.d.ts +5 -0
  11. package/addExports/index.js +5 -0
  12. package/addExports/index.js.map +1 -0
  13. package/addExports/types.cjs +1 -0
  14. package/addExports/types.cjs.map +1 -0
  15. package/addExports/types.d.cts +33 -0
  16. package/addExports/types.d.ts +33 -0
  17. package/addExports/types.js +1 -0
  18. package/addExports/types.js.map +1 -0
  19. package/checkExistence/checkExistence.cjs +15 -0
  20. package/checkExistence/checkExistence.cjs.map +1 -0
  21. package/checkExistence/checkExistence.d.cts +8 -0
  22. package/checkExistence/checkExistence.d.ts +8 -0
  23. package/checkExistence/checkExistence.js +15 -0
  24. package/checkExistence/checkExistence.js.map +1 -0
  25. package/checkExistence/index.cjs +5 -0
  26. package/checkExistence/index.cjs.map +1 -0
  27. package/checkExistence/index.d.cts +1 -0
  28. package/checkExistence/index.d.ts +1 -0
  29. package/checkExistence/index.js +5 -0
  30. package/checkExistence/index.js.map +1 -0
  31. package/editJsonFile/editJsonFile.cjs +22 -0
  32. package/editJsonFile/editJsonFile.cjs.map +1 -0
  33. package/editJsonFile/editJsonFile.d.cts +8 -0
  34. package/editJsonFile/editJsonFile.d.ts +8 -0
  35. package/editJsonFile/editJsonFile.js +22 -0
  36. package/editJsonFile/editJsonFile.js.map +1 -0
  37. package/editJsonFile/index.cjs +5 -0
  38. package/editJsonFile/index.cjs.map +1 -0
  39. package/editJsonFile/index.d.cts +1 -0
  40. package/editJsonFile/index.d.ts +1 -0
  41. package/editJsonFile/index.js +5 -0
  42. package/editJsonFile/index.js.map +1 -0
  43. package/index.cjs +19 -0
  44. package/index.cjs.map +1 -0
  45. package/index.d.cts +15 -0
  46. package/index.d.ts +15 -0
  47. package/index.js +19 -0
  48. package/index.js.map +1 -0
  49. package/indexes/constants.cjs +91 -0
  50. package/indexes/constants.cjs.map +1 -0
  51. package/indexes/constants.d.cts +66 -0
  52. package/indexes/constants.d.ts +66 -0
  53. package/indexes/constants.js +91 -0
  54. package/indexes/constants.js.map +1 -0
  55. package/indexes/index.cjs +5 -0
  56. package/indexes/index.cjs.map +1 -0
  57. package/indexes/index.d.cts +5 -0
  58. package/indexes/index.d.ts +5 -0
  59. package/indexes/index.js +5 -0
  60. package/indexes/index.js.map +1 -0
  61. package/indexes/indexes.cjs +161 -0
  62. package/indexes/indexes.cjs.map +1 -0
  63. package/indexes/indexes.d.cts +13 -0
  64. package/indexes/indexes.d.ts +13 -0
  65. package/indexes/indexes.js +161 -0
  66. package/indexes/indexes.js.map +1 -0
  67. package/indexes/types.cjs +1 -0
  68. package/indexes/types.cjs.map +1 -0
  69. package/indexes/types.d.cts +81 -0
  70. package/indexes/types.d.ts +81 -0
  71. package/indexes/types.js +1 -0
  72. package/indexes/types.js.map +1 -0
  73. package/installFromLocal/index.cjs +5 -0
  74. package/installFromLocal/index.cjs.map +1 -0
  75. package/installFromLocal/index.d.cts +2 -0
  76. package/installFromLocal/index.d.ts +2 -0
  77. package/installFromLocal/index.js +5 -0
  78. package/installFromLocal/index.js.map +1 -0
  79. package/installFromLocal/installFromLocal.cjs +48 -0
  80. package/installFromLocal/installFromLocal.cjs.map +1 -0
  81. package/installFromLocal/installFromLocal.d.cts +10 -0
  82. package/installFromLocal/installFromLocal.d.ts +10 -0
  83. package/installFromLocal/installFromLocal.js +48 -0
  84. package/installFromLocal/installFromLocal.js.map +1 -0
  85. package/installFromLocal/types.cjs +1 -0
  86. package/installFromLocal/types.cjs.map +1 -0
  87. package/installFromLocal/types.d.cts +19 -0
  88. package/installFromLocal/types.d.ts +19 -0
  89. package/installFromLocal/types.js +1 -0
  90. package/installFromLocal/types.js.map +1 -0
  91. package/isMatchingPath/_types.cjs +1 -0
  92. package/isMatchingPath/_types.cjs.map +1 -0
  93. package/isMatchingPath/_types.d.cts +52 -0
  94. package/isMatchingPath/_types.d.ts +52 -0
  95. package/isMatchingPath/_types.js +1 -0
  96. package/isMatchingPath/_types.js.map +1 -0
  97. package/isMatchingPath/index.cjs +5 -0
  98. package/isMatchingPath/index.cjs.map +1 -0
  99. package/isMatchingPath/index.d.cts +4 -0
  100. package/isMatchingPath/index.d.ts +4 -0
  101. package/isMatchingPath/index.js +5 -0
  102. package/isMatchingPath/index.js.map +1 -0
  103. package/isMatchingPath/isMatchingPath.cjs +57 -0
  104. package/isMatchingPath/isMatchingPath.cjs.map +1 -0
  105. package/isMatchingPath/isMatchingPath.d.cts +14 -0
  106. package/isMatchingPath/isMatchingPath.d.ts +14 -0
  107. package/isMatchingPath/isMatchingPath.js +57 -0
  108. package/isMatchingPath/isMatchingPath.js.map +1 -0
  109. package/isMatchingPath/types.cjs +1 -0
  110. package/isMatchingPath/types.cjs.map +1 -0
  111. package/isMatchingPath/types.d.cts +19 -0
  112. package/isMatchingPath/types.d.ts +19 -0
  113. package/isMatchingPath/types.js +1 -0
  114. package/isMatchingPath/types.js.map +1 -0
  115. package/moveFilesToSubdir/index.cjs +5 -0
  116. package/moveFilesToSubdir/index.cjs.map +1 -0
  117. package/moveFilesToSubdir/index.d.cts +1 -0
  118. package/moveFilesToSubdir/index.d.ts +1 -0
  119. package/moveFilesToSubdir/index.js +5 -0
  120. package/moveFilesToSubdir/index.js.map +1 -0
  121. package/moveFilesToSubdir/moveFilesToSubdir.cjs +19 -0
  122. package/moveFilesToSubdir/moveFilesToSubdir.cjs.map +1 -0
  123. package/moveFilesToSubdir/moveFilesToSubdir.d.cts +7 -0
  124. package/moveFilesToSubdir/moveFilesToSubdir.d.ts +7 -0
  125. package/moveFilesToSubdir/moveFilesToSubdir.js +19 -0
  126. package/moveFilesToSubdir/moveFilesToSubdir.js.map +1 -0
  127. package/package.json +35 -0
  128. package/ver/index.cjs +5 -0
  129. package/ver/index.cjs.map +1 -0
  130. package/ver/index.d.cts +2 -0
  131. package/ver/index.d.ts +2 -0
  132. package/ver/index.js +5 -0
  133. package/ver/index.js.map +1 -0
  134. package/ver/types.cjs +1 -0
  135. package/ver/types.cjs.map +1 -0
  136. package/ver/types.d.cts +14 -0
  137. package/ver/types.d.ts +14 -0
  138. package/ver/types.js +1 -0
  139. package/ver/types.js.map +1 -0
  140. package/ver/ver.cjs +31 -0
  141. package/ver/ver.cjs.map +1 -0
  142. package/ver/ver.d.cts +10 -0
  143. package/ver/ver.d.ts +10 -0
  144. package/ver/ver.js +31 -0
  145. package/ver/ver.js.map +1 -0
@@ -0,0 +1,52 @@
1
+ import { ParsedPath } from 'path';
2
+
3
+ /**
4
+ * 条件設定
5
+ */
6
+ type ConditionConfig = {
7
+ /**
8
+ * 検査対象の値
9
+ *
10
+ * - path: '/'で区切られたフルパス
11
+ * - base: 拡張子付きのディレクトリ名 or ファイル名
12
+ * - name: 拡張子を除いたディレクトリ名 or ファイル名
13
+ * - ext: '.'を含む拡張子。拡張子が無い場合は空文字
14
+ * - dirpath: '/'で区切られた親ディレクトリのフルパス
15
+ * - base: 拡張子付きの親ディレクトリ名
16
+ * - name: 拡張子を除いた親ディレクトリ名
17
+ * - ext: '.'を含む親ディレクトリの拡張子。拡張子が無い場合は空文字
18
+ */
19
+ valueType?: 'path' | 'base' | 'name' | 'ext' | 'dirpath' | 'dirbase' | 'dirname' | 'dirext';
20
+ /**
21
+ * 検査対象の種別
22
+ *
23
+ * - dir: ディレクトリ
24
+ * - file: ファイル
25
+ * - both: ディレクトリ & ファイル
26
+ */
27
+ entryType?: 'dir' | 'file' | 'both';
28
+ /**
29
+ * 一致条件
30
+ * 配列で指定した場合はand条件とする
31
+ *
32
+ * - string: 指定された文字列を含むものに一致
33
+ * - RegExp: 指定された正規表現に一致
34
+ */
35
+ conditions: string | RegExp | ConditionFn | (string | RegExp | ConditionFn)[];
36
+ };
37
+ /**
38
+ * カスタム条件関数
39
+ */
40
+ type ConditionFn = (values: ConditionValues, options: Record<string, any>) => boolean;
41
+ /**
42
+ * 検証対象の値
43
+ */
44
+ type ConditionValues = {
45
+ path: string;
46
+ dirpath: string;
47
+ dirbase: string;
48
+ dirname: string;
49
+ dirext: string;
50
+ } & ParsedPath;
51
+
52
+ export type { ConditionConfig, ConditionFn, ConditionValues };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _isMatchingPath = require('./isMatchingPath'); var _isMatchingPath2 = _interopRequireDefault(_isMatchingPath);
2
+
3
+
4
+ exports.default = _isMatchingPath2.default;
5
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\isMatchingPath\\index.cjs"],"names":[],"mappings":"AAAA,2RAAsD;AACtD;AACE;AACF,2CAAC","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\isMatchingPath\\index.cjs","sourcesContent":[null]}
@@ -0,0 +1,4 @@
1
+ export { default } from './isMatchingPath.cjs';
2
+ export { IsMatchingPathCondition, IsMatchingPathOptions } from './types.cjs';
3
+ import './_types.cjs';
4
+ import 'path';
@@ -0,0 +1,4 @@
1
+ export { default } from './isMatchingPath.js';
2
+ export { IsMatchingPathCondition, IsMatchingPathOptions } from './types.js';
3
+ import './_types.js';
4
+ import 'path';
@@ -0,0 +1,5 @@
1
+ import { default as default2 } from "./isMatchingPath";
2
+ export {
3
+ default2 as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/isMatchingPath/index.ts"],"sourcesContent":["export { default } from './isMatchingPath';\r\nexport type * from './types';\r\n"],"mappings":"AAAA,SAAS,WAAAA,gBAAe;","names":["default"]}
@@ -0,0 +1,57 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
2
+ var _path = require('path');
3
+ var _remeda = require('remeda');
4
+ function isMatchingPath(targetPath, conditions, options = {}) {
5
+ if (!conditions) {
6
+ return false;
7
+ }
8
+ const conditionList = Array.isArray(conditions) ? conditions : [conditions];
9
+ const posixPath = _path.posix.normalize(targetPath);
10
+ const parsedPath = _path.posix.parse(posixPath);
11
+ const parsedDir = _path.posix.parse(parsedPath.dir);
12
+ const values = {
13
+ path: posixPath,
14
+ ...parsedPath,
15
+ dirpath: parsedPath.dir,
16
+ dirbase: parsedDir.base,
17
+ dirname: parsedDir.name,
18
+ dirext: parsedDir.ext
19
+ };
20
+ values.path = posixPath;
21
+ for (const condition of conditionList) {
22
+ if (_isMatching(values.path, values, condition, options)) {
23
+ return true;
24
+ }
25
+ }
26
+ return false;
27
+ }
28
+ function _isMatching(value, values, condition, options) {
29
+ if (_remeda.isString.call(void 0, condition)) {
30
+ if (value.includes(condition)) {
31
+ return true;
32
+ }
33
+ } else if (condition instanceof RegExp) {
34
+ if (condition.test(value)) {
35
+ return true;
36
+ }
37
+ } else if (_remeda.isFunction.call(void 0, condition)) {
38
+ return condition(values, _nullishCoalesce(options.conditionOptions, () => ( {})));
39
+ } else {
40
+ const { valueType = "path", entryType = "both", conditions } = condition;
41
+ if (entryType !== "both") {
42
+ const stat = _fsextra2.default.statSync(values.path);
43
+ if (stat.isDirectory() && entryType !== "dir" || stat.isFile() && entryType !== "file") {
44
+ return false;
45
+ }
46
+ }
47
+ const conditionList = Array.isArray(conditions) ? conditions : [conditions];
48
+ return conditionList.every(
49
+ (cond) => _isMatching(values[valueType], values, cond, options)
50
+ );
51
+ }
52
+ return false;
53
+ }
54
+
55
+
56
+ exports.default = isMatchingPath;
57
+ //# sourceMappingURL=isMatchingPath.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\isMatchingPath\\isMatchingPath.cjs"],"names":[],"mappings":"AAAA,kWAAyB;AACzB,4BAAoC;AACpC,gCAA6C;AAC7C,SAAS,cAAc,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;AAC9D,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE;AACnB,IAAI,OAAO,KAAK;AAChB,EAAE;AACF,EAAE,MAAM,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,CAAC,UAAU,CAAC;AAC7E,EAAE,MAAM,UAAU,EAAE,WAAI,CAAC,SAAS,CAAC,UAAU,CAAC;AAC9C,EAAE,MAAM,WAAW,EAAE,WAAI,CAAC,KAAK,CAAC,SAAS,CAAC;AAC1C,EAAE,MAAM,UAAU,EAAE,WAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;AAC9C,EAAE,MAAM,OAAO,EAAE;AACjB,IAAI,IAAI,EAAE,SAAS;AACnB,IAAI,GAAG,UAAU;AACjB,IAAI,OAAO,EAAE,UAAU,CAAC,GAAG;AAC3B,IAAI,OAAO,EAAE,SAAS,CAAC,IAAI;AAC3B,IAAI,OAAO,EAAE,SAAS,CAAC,IAAI;AAC3B,IAAI,MAAM,EAAE,SAAS,CAAC;AACtB,EAAE,CAAC;AACH,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS;AACzB,EAAE,IAAI,CAAC,MAAM,UAA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O,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,CAAC,UAAU,CAAC;AAC/E,IAAI,OAAO,aAAa,CAAC,KAAK;AAC9B,MAAM,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;AACpE,IAAI,CAAC;AACL,EAAE;AACF,EAAE,OAAO,KAAK;AACd;AACA;AACE;AACF,iCAAC","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\isMatchingPath\\isMatchingPath.cjs","sourcesContent":[null]}
@@ -0,0 +1,14 @@
1
+ import { IsMatchingPathCondition, IsMatchingPathOptions } from './types.cjs';
2
+ import './_types.cjs';
3
+ import 'path';
4
+
5
+ /**
6
+ * 処理対象のパスか判定する
7
+ * @param targetPath 検査対象のパス
8
+ * @param conditions 一致条件
9
+ * @param options オプション
10
+ * @returns 一致するか
11
+ */
12
+ declare function isMatchingPath(targetPath: string, conditions: IsMatchingPathCondition | IsMatchingPathCondition[], options?: IsMatchingPathOptions): boolean;
13
+
14
+ export { isMatchingPath as default };
@@ -0,0 +1,14 @@
1
+ import { IsMatchingPathCondition, IsMatchingPathOptions } from './types.js';
2
+ import './_types.js';
3
+ import 'path';
4
+
5
+ /**
6
+ * 処理対象のパスか判定する
7
+ * @param targetPath 検査対象のパス
8
+ * @param conditions 一致条件
9
+ * @param options オプション
10
+ * @returns 一致するか
11
+ */
12
+ declare function isMatchingPath(targetPath: string, conditions: IsMatchingPathCondition | IsMatchingPathCondition[], options?: IsMatchingPathOptions): boolean;
13
+
14
+ export { isMatchingPath as default };
@@ -0,0 +1,57 @@
1
+ import fs from "fs-extra";
2
+ import { posix as path } from "path";
3
+ import { isFunction, isString } from "remeda";
4
+ function isMatchingPath(targetPath, conditions, options = {}) {
5
+ if (!conditions) {
6
+ return false;
7
+ }
8
+ const conditionList = Array.isArray(conditions) ? conditions : [conditions];
9
+ const posixPath = path.normalize(targetPath);
10
+ const parsedPath = path.parse(posixPath);
11
+ const parsedDir = path.parse(parsedPath.dir);
12
+ const values = {
13
+ path: posixPath,
14
+ ...parsedPath,
15
+ dirpath: parsedPath.dir,
16
+ dirbase: parsedDir.base,
17
+ dirname: parsedDir.name,
18
+ dirext: parsedDir.ext
19
+ };
20
+ values.path = posixPath;
21
+ for (const condition of conditionList) {
22
+ if (_isMatching(values.path, values, condition, options)) {
23
+ return true;
24
+ }
25
+ }
26
+ return false;
27
+ }
28
+ function _isMatching(value, values, condition, options) {
29
+ if (isString(condition)) {
30
+ if (value.includes(condition)) {
31
+ return true;
32
+ }
33
+ } else if (condition instanceof RegExp) {
34
+ if (condition.test(value)) {
35
+ return true;
36
+ }
37
+ } else if (isFunction(condition)) {
38
+ return condition(values, options.conditionOptions ?? {});
39
+ } else {
40
+ const { valueType = "path", entryType = "both", conditions } = condition;
41
+ if (entryType !== "both") {
42
+ const stat = fs.statSync(values.path);
43
+ if (stat.isDirectory() && entryType !== "dir" || stat.isFile() && entryType !== "file") {
44
+ return false;
45
+ }
46
+ }
47
+ const conditionList = Array.isArray(conditions) ? conditions : [conditions];
48
+ return conditionList.every(
49
+ (cond) => _isMatching(values[valueType], values, cond, options)
50
+ );
51
+ }
52
+ return false;
53
+ }
54
+ export {
55
+ isMatchingPath as default
56
+ };
57
+ //# sourceMappingURL=isMatchingPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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 { ConditionValues } from './_types';\r\nimport type { IsMatchingPathCondition, IsMatchingPathOptions } 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 targetPath: string,\r\n conditions: IsMatchingPathCondition | IsMatchingPathCondition[],\r\n options: IsMatchingPathOptions = {},\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(\r\n value: string,\r\n values: ConditionValues,\r\n condition: IsMatchingPathCondition,\r\n options: IsMatchingPathOptions,\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 ?? {});\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":"AAAA,OAAO,QAAQ;AACf,SAAS,SAAS,YAAY;AAC9B,SAAS,YAAY,gBAAgB;AAWtB,SAAR,eACL,YACA,YACA,UAAiC,CAAC,GAClC;AACA,MAAI,CAAC,YA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A,EACF;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1 @@
1
+ "use strict";//# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\isMatchingPath\\types.cjs"],"names":[],"mappings":"AAAA","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\isMatchingPath\\types.cjs"}
@@ -0,0 +1,19 @@
1
+ import { ConditionConfig, ConditionFn } from './_types.cjs';
2
+ import 'path';
3
+
4
+ /**
5
+ * 一致条件
6
+ *
7
+ * - string: 指定された文字列がパスに含まれているものに一致する際にtrue
8
+ * - RegExp: 指定された正規表現にパスが一致する際にtrue
9
+ * - ConditionConfig: 条件設定に従って検査し一致したときにtrue
10
+ */
11
+ type IsMatchingPathCondition = string | RegExp | ConditionConfig | ConditionFn;
12
+ type IsMatchingPathOptions = {
13
+ /**
14
+ * ConditionFnに渡すオプション
15
+ */
16
+ conditionOptions?: Record<string, any>;
17
+ };
18
+
19
+ export type { IsMatchingPathCondition, IsMatchingPathOptions };
@@ -0,0 +1,19 @@
1
+ import { ConditionConfig, ConditionFn } from './_types.js';
2
+ import 'path';
3
+
4
+ /**
5
+ * 一致条件
6
+ *
7
+ * - string: 指定された文字列がパスに含まれているものに一致する際にtrue
8
+ * - RegExp: 指定された正規表現にパスが一致する際にtrue
9
+ * - ConditionConfig: 条件設定に従って検査し一致したときにtrue
10
+ */
11
+ type IsMatchingPathCondition = string | RegExp | ConditionConfig | ConditionFn;
12
+ type IsMatchingPathOptions = {
13
+ /**
14
+ * ConditionFnに渡すオプション
15
+ */
16
+ conditionOptions?: Record<string, any>;
17
+ };
18
+
19
+ export type { IsMatchingPathCondition, IsMatchingPathOptions };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _moveFilesToSubdir = require('./moveFilesToSubdir'); var _moveFilesToSubdir2 = _interopRequireDefault(_moveFilesToSubdir);
2
+
3
+
4
+ exports.default = _moveFilesToSubdir2.default;
5
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\moveFilesToSubdir\\index.cjs"],"names":[],"mappings":"AAAA,uSAAyD;AACzD;AACE;AACF,8CAAC","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\moveFilesToSubdir\\index.cjs","sourcesContent":[null]}
@@ -0,0 +1 @@
1
+ export { default } from './moveFilesToSubdir.cjs';
@@ -0,0 +1 @@
1
+ export { default } from './moveFilesToSubdir.js';
@@ -0,0 +1,5 @@
1
+ import { default as default2 } from "./moveFilesToSubdir";
2
+ export {
3
+ default2 as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/moveFilesToSubdir/index.ts"],"sourcesContent":["export { default } from './moveFilesToSubdir';\r\n"],"mappings":"AAAA,SAAS,WAAAA,gBAAe;","names":["default"]}
@@ -0,0 +1,19 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
2
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
3
+ async function moveFilesToSubdir(dirPath) {
4
+ const items = await _fsextra2.default.readdir(dirPath);
5
+ for (const item of items) {
6
+ const itemPath = _path2.default.join(dirPath, item);
7
+ const stat = _fsextra2.default.statSync(itemPath);
8
+ if (stat.isFile()) {
9
+ const fileName = _path2.default.parse(item).name;
10
+ const subdirPath = _path2.default.join(dirPath, fileName);
11
+ _fsextra2.default.ensureDirSync(subdirPath);
12
+ _fsextra2.default.moveSync(itemPath, _path2.default.join(subdirPath, item));
13
+ }
14
+ }
15
+ }
16
+
17
+
18
+ exports.default = moveFilesToSubdir;
19
+ //# sourceMappingURL=moveFilesToSubdir.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\moveFilesToSubdir\\moveFilesToSubdir.cjs"],"names":[],"mappings":"AAAA,8PAAyB;AACzB,wEAAuB;AACvB,MAAM,SAAS,iBAAiB,CAAC,OAAO,EAAE;AAC1C,EAAE,MAAM,MAAM,EAAE,MAAM,iBAAE,CAAC,OAAO,CAAC,OAAO,CAAC;AACzC,EAAE,IAAI,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE;AAC5B,IAAI,MAAM,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC;AAC7C,IAAI,MAAM,KAAK,EAAE,iBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACtC,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE;AACvB,MAAM,MAAM,SAAS,EAAE,cAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI;AAC5C,MAAM,MAAM,WAAW,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC;AACrD,MAAM,iBAAE,CAAC,aAAa,CAAC,UAAU,CAAC;AAClC,MAAM,iBAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AACxD,IAAI;AACJ,EAAE;AACF;AACA;AACE;AACF,oCAAC","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\moveFilesToSubdir\\moveFilesToSubdir.cjs","sourcesContent":[null]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する
3
+ * @param dirPath 対象のディレクトリのパス
4
+ */
5
+ declare function moveFilesToSubdir(dirPath: string): Promise<void>;
6
+
7
+ export { moveFilesToSubdir as default };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する
3
+ * @param dirPath 対象のディレクトリのパス
4
+ */
5
+ declare function moveFilesToSubdir(dirPath: string): Promise<void>;
6
+
7
+ export { moveFilesToSubdir as default };
@@ -0,0 +1,19 @@
1
+ import fs from "fs-extra";
2
+ import path from "path";
3
+ async function moveFilesToSubdir(dirPath) {
4
+ const items = await fs.readdir(dirPath);
5
+ for (const item of items) {
6
+ const itemPath = path.join(dirPath, item);
7
+ const stat = fs.statSync(itemPath);
8
+ if (stat.isFile()) {
9
+ const fileName = path.parse(item).name;
10
+ const subdirPath = path.join(dirPath, fileName);
11
+ fs.ensureDirSync(subdirPath);
12
+ fs.moveSync(itemPath, path.join(subdirPath, item));
13
+ }
14
+ }
15
+ }
16
+ export {
17
+ moveFilesToSubdir as default
18
+ };
19
+ //# sourceMappingURL=moveFilesToSubdir.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/moveFilesToSubdir/moveFilesToSubdir.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport path from 'path';\r\n\r\n/**\r\n * 対象のディレクトリ直下のファイルを、拡張子を除いた同名のサブディレクトリ直下に移動する\r\n * @param dirPath 対象のディレクトリのパス\r\n */\r\nexport default async function moveFilesToSubdir(dirPath: string) {\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 const stat = fs.statSync(itemPath);\r\n if (stat.isFile()) {\r\n const fileName = path.parse(item).name;\r\n // 移動先のディレクトリパスを生成\r\n const subdirPath = path.join(dirPath, fileName);\r\n // 移動先のディレクトリが存在しなければ作成\r\n fs.ensureDirSync(subdirPath);\r\n // 移動先のファイルパスを生成\r\n fs.moveSync(itemPath, path.join(subdirPath, item));\r\n }\r\n }\r\n}\r\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAMjB,eAAO,kBAAyC,SAAiB;AAC/D,QAAM,QAAQ,MAAM,GAAG,QAAQ,OAAO;AACtC,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAW,KAAK,KAAK,SAAS,IAAI;AACxC,UAAM,OAAO,GAAG,SAAS,QAAQ;AACjC,QAAI,KAAK,OAAO,GAAG;AACjB,YAAM,WAAW,KAAK,MAAM,IAAI,EAAE;AAElC,YAAM,aAAa,KAAK,KAAK,SAAS,QAAQ;AAE9C,SAAG,cAAc,UAAU;AAE3B,SAAG,SAAS,UAAU,KAAK,KAAK,YAAY,IAAI,CAAC;AAAA,IACnD;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@niche-works/dev",
3
+ "version": "0.1.0",
4
+ "keywords": [
5
+ "utils"
6
+ ],
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/mitsuhiroseino/niche-works-dev.git"
10
+ },
11
+ "license": "MIT",
12
+ "author": "Mitsuhiro Seino",
13
+ "type": "module",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./index.js",
17
+ "reqire": "./index.cjs",
18
+ "type": "./index.d.ts"
19
+ },
20
+ "./*": {
21
+ "import": "./*/index.js",
22
+ "reqire": "./*/index.cjs",
23
+ "type": "./*/index.d.ts"
24
+ },
25
+ "./*/constants": {
26
+ "import": "./*/constants.js",
27
+ "reqire": "./*/constants.cjs",
28
+ "type": "./*/constants.d.ts"
29
+ }
30
+ },
31
+ "dependencies": {
32
+ "fs-extra": "^11.3.4",
33
+ "remeda": "^2.33.6"
34
+ }
35
+ }
package/ver/index.cjs ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _ver = require('./ver'); var _ver2 = _interopRequireDefault(_ver);
2
+
3
+
4
+ exports.default = _ver2.default;
5
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\ver\\index.cjs"],"names":[],"mappings":"AAAA,+OAA2C;AAC3C;AACE;AACF,gCAAC","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\ver\\index.cjs","sourcesContent":[null]}
@@ -0,0 +1,2 @@
1
+ export { VerOptions } from './types.cjs';
2
+ export { default } from './ver.cjs';
package/ver/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { VerOptions } from './types.js';
2
+ export { default } from './ver.js';
package/ver/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { default as default2 } from "./ver";
2
+ export {
3
+ default2 as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ver/index.ts"],"sourcesContent":["export type * from './types';\r\nexport { default } from './ver';\r\n"],"mappings":"AACA,SAAS,WAAAA,gBAAe;","names":["default"]}
package/ver/types.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";//# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\ver\\types.cjs"],"names":[],"mappings":"AAAA","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\ver\\types.cjs"}
@@ -0,0 +1,14 @@
1
+ type VerOptions = {
2
+ /**
3
+ * ワークスペースのパッケージjsonのパス
4
+ * デフォルトは`./package.json`
5
+ */
6
+ workspacePackageJsonPath?: string;
7
+ /**
8
+ * パッケージが置かれたディレクトリのパス
9
+ * デフォルトは`./packages`
10
+ */
11
+ packagesPath?: string;
12
+ };
13
+
14
+ export type { VerOptions };
package/ver/types.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ type VerOptions = {
2
+ /**
3
+ * ワークスペースのパッケージjsonのパス
4
+ * デフォルトは`./package.json`
5
+ */
6
+ workspacePackageJsonPath?: string;
7
+ /**
8
+ * パッケージが置かれたディレクトリのパス
9
+ * デフォルトは`./packages`
10
+ */
11
+ packagesPath?: string;
12
+ };
13
+
14
+ export type { VerOptions };
package/ver/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/ver/ver.cjs ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
2
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
3
+ async function ver(version, options = {}) {
4
+ const {
5
+ workspacePackageJsonPath = "package.json",
6
+ packagesPath = "packages"
7
+ } = options;
8
+ if (_fsextra2.default.existsSync(workspacePackageJsonPath)) {
9
+ _updatePkgJson(version, workspacePackageJsonPath);
10
+ }
11
+ const pkgs = _fsextra2.default.readdirSync(packagesPath);
12
+ for (const pkg of pkgs) {
13
+ const packagePath = _path2.default.join(packagesPath, pkg);
14
+ const packageJsonPath = _path2.default.join(packagePath, "package.json");
15
+ if (_fsextra2.default.existsSync(packageJsonPath)) {
16
+ _updatePkgJson(version, packageJsonPath);
17
+ }
18
+ }
19
+ }
20
+ function _updatePkgJson(version, packageJsonPath) {
21
+ const packageJson = _fsextra2.default.readJsonSync(packageJsonPath, { encoding: "utf8" });
22
+ packageJson.version = version;
23
+ _fsextra2.default.writeJsonSync(packageJsonPath, packageJson, {
24
+ encoding: "utf8",
25
+ spaces: 2
26
+ });
27
+ }
28
+
29
+
30
+ exports.default = ver;
31
+ //# sourceMappingURL=ver.cjs.map
@@ -0,0 +1 @@
1
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\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\ver\\ver.cjs","sourcesContent":[null]}
package/ver/ver.d.cts ADDED
@@ -0,0 +1,10 @@
1
+ import { VerOptions } from './types.cjs';
2
+
3
+ /**
4
+ * ワークスペースのパッケージにバージョンを反映する
5
+ * @param version バージョン
6
+ * @param options オプション
7
+ */
8
+ declare function ver(version: string, options?: VerOptions): Promise<void>;
9
+
10
+ export { ver as default };
package/ver/ver.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { VerOptions } from './types.js';
2
+
3
+ /**
4
+ * ワークスペースのパッケージにバージョンを反映する
5
+ * @param version バージョン
6
+ * @param options オプション
7
+ */
8
+ declare function ver(version: string, options?: VerOptions): Promise<void>;
9
+
10
+ export { ver as default };
package/ver/ver.js ADDED
@@ -0,0 +1,31 @@
1
+ import fs from "fs-extra";
2
+ import path from "path";
3
+ async function ver(version, options = {}) {
4
+ const {
5
+ workspacePackageJsonPath = "package.json",
6
+ packagesPath = "packages"
7
+ } = options;
8
+ if (fs.existsSync(workspacePackageJsonPath)) {
9
+ _updatePkgJson(version, workspacePackageJsonPath);
10
+ }
11
+ const pkgs = fs.readdirSync(packagesPath);
12
+ for (const pkg of pkgs) {
13
+ const packagePath = path.join(packagesPath, pkg);
14
+ const packageJsonPath = path.join(packagePath, "package.json");
15
+ if (fs.existsSync(packageJsonPath)) {
16
+ _updatePkgJson(version, packageJsonPath);
17
+ }
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
+ export {
29
+ ver as default
30
+ };
31
+ //# sourceMappingURL=ver.js.map
package/ver/ver.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"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":"AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAQjB,eAAO,IAA2B,SAAiB,UAAsB,CAAC,GAAG;AAC3E,QAAM;AAAA,IACJ,2BAA2B;AAAA,IAC3B,eAAe;AAAA,EACjB,IAAI;AAEJ,MAAI,GAAG,WAAW,wBAAwB,GAAG;AAE3C,mBAAe,SAAS,wBAAwB;AAAA,EAClD;AACA,QAAM,OAAO,GAAG,YAAY,YAAY;AACxC,aAAW,OAAO,MAAM;AACtB,UAAM,cAAc,KAAK,KAAK,cAAc,GAAG;AAC/C,UAAM,kBAAkB,KAAK,KAAK,aAAa,cAAc;AAC7D,QAAI,GAAG,WAAW,eAAe,GAAG;AAElC,qBAAe,SAAS,eAAe;AAAA,IACzC;AAAA,EACF;AACF;AAEA,SAAS,eAAe,SAAiB,iBAAyB;AAChE,QAAM,cAAc,GAAG,aAAa,iBAAiB,EAAE,UAAU,OAAO,CAAC;AACzE,cAAY,UAAU;AACtB,KAAG,cAAc,iBAAiB,aAAa;AAAA,IAC7C,UAAU;AAAA,IACV,QAAQ;AAAA,EACV,CAAC;AACH;","names":[]}