@niche-works/dev 0.4.1 → 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.
- package/_virtual/_rolldown/runtime.cjs +29 -0
- package/addExports/addExports.cjs +61 -0
- package/addExports/addExports.cjs.map +1 -0
- package/addExports/addExports.d.cts +11 -0
- package/addExports/addExports.d.mts +12 -0
- package/addExports/addExports.mjs +59 -0
- package/addExports/addExports.mjs.map +1 -0
- package/addExports/index.cjs +3 -0
- package/addExports/index.d.cts +3 -0
- package/addExports/index.d.mts +3 -0
- package/addExports/index.mjs +3 -0
- package/addExports/types.cjs +0 -0
- package/{src/addExports/types.ts → addExports/types.d.cts} +33 -33
- package/addExports/types.d.mts +33 -0
- package/addExports/types.mjs +1 -0
- package/addJsExtensions/addJsExtensions.cjs +31 -0
- package/addJsExtensions/addJsExtensions.cjs.map +1 -0
- package/addJsExtensions/addJsExtensions.d.cts +8 -0
- package/addJsExtensions/addJsExtensions.d.mts +9 -0
- package/addJsExtensions/addJsExtensions.mjs +28 -0
- package/addJsExtensions/addJsExtensions.mjs.map +1 -0
- package/addJsExtensions/index.cjs +3 -0
- package/addJsExtensions/index.d.cts +2 -0
- package/addJsExtensions/index.d.mts +2 -0
- package/addJsExtensions/index.mjs +3 -0
- package/checkExistence/checkExistence.cjs +23 -0
- package/checkExistence/checkExistence.cjs.map +1 -0
- package/checkExistence/checkExistence.d.cts +9 -0
- package/checkExistence/checkExistence.d.mts +10 -0
- package/checkExistence/checkExistence.mjs +21 -0
- package/checkExistence/checkExistence.mjs.map +1 -0
- package/checkExistence/index.cjs +3 -0
- package/checkExistence/index.d.cts +2 -0
- package/checkExistence/index.d.mts +2 -0
- package/checkExistence/index.mjs +3 -0
- package/createExternalOptionFunction/createExternalOptionFunction.cjs +25 -0
- package/createExternalOptionFunction/createExternalOptionFunction.cjs.map +1 -0
- package/createExternalOptionFunction/createExternalOptionFunction.d.cts +10 -0
- package/createExternalOptionFunction/createExternalOptionFunction.d.mts +11 -0
- package/createExternalOptionFunction/createExternalOptionFunction.mjs +25 -0
- package/createExternalOptionFunction/createExternalOptionFunction.mjs.map +1 -0
- package/createExternalOptionFunction/index.cjs +3 -0
- package/createExternalOptionFunction/index.d.cts +2 -0
- package/createExternalOptionFunction/index.d.mts +2 -0
- package/createExternalOptionFunction/index.mjs +3 -0
- package/createExternalOptionFunction/types.cjs +0 -0
- package/{src/createExternalOptionFunction/types.ts → createExternalOptionFunction/types.d.cts} +31 -34
- package/createExternalOptionFunction/types.d.mts +31 -0
- package/createExternalOptionFunction/types.mjs +1 -0
- package/editJsonFile/editJsonFile.cjs +29 -0
- package/editJsonFile/editJsonFile.cjs.map +1 -0
- package/editJsonFile/editJsonFile.d.cts +9 -0
- package/editJsonFile/editJsonFile.d.mts +10 -0
- package/editJsonFile/editJsonFile.mjs +26 -0
- package/editJsonFile/editJsonFile.mjs.map +1 -0
- package/editJsonFile/index.cjs +3 -0
- package/editJsonFile/index.d.cts +2 -0
- package/editJsonFile/index.d.mts +2 -0
- package/editJsonFile/index.mjs +3 -0
- package/generatePublishPackageJson/generatePublishPackageJson.cjs +46 -0
- package/generatePublishPackageJson/generatePublishPackageJson.cjs.map +1 -0
- package/generatePublishPackageJson/generatePublishPackageJson.d.cts +6 -0
- package/generatePublishPackageJson/generatePublishPackageJson.d.mts +7 -0
- package/generatePublishPackageJson/generatePublishPackageJson.mjs +44 -0
- package/generatePublishPackageJson/generatePublishPackageJson.mjs.map +1 -0
- package/generatePublishPackageJson/index.cjs +3 -0
- package/generatePublishPackageJson/index.d.cts +3 -0
- package/generatePublishPackageJson/index.d.mts +3 -0
- package/generatePublishPackageJson/index.mjs +3 -0
- package/generatePublishPackageJson/types.cjs +0 -0
- package/{src/generatePublishPackageJson/types.ts → generatePublishPackageJson/types.d.cts} +60 -61
- package/generatePublishPackageJson/types.d.mts +60 -0
- package/generatePublishPackageJson/types.mjs +1 -0
- package/index.cjs +38 -0
- package/index.d.cts +13 -0
- package/index.d.mts +13 -0
- package/index.mjs +26 -0
- package/indexes/constants.cjs +123 -0
- package/indexes/constants.cjs.map +1 -0
- package/indexes/constants.d.cts +66 -0
- package/indexes/constants.d.mts +66 -0
- package/indexes/constants.mjs +106 -0
- package/indexes/constants.mjs.map +1 -0
- package/indexes/index.cjs +3 -0
- package/indexes/index.d.cts +3 -0
- package/indexes/index.d.mts +3 -0
- package/indexes/index.mjs +3 -0
- package/indexes/indexes.cjs +125 -0
- package/indexes/indexes.cjs.map +1 -0
- package/indexes/indexes.d.cts +11 -0
- package/indexes/indexes.d.mts +12 -0
- package/indexes/indexes.mjs +123 -0
- package/indexes/indexes.mjs.map +1 -0
- package/indexes/types.cjs +0 -0
- package/{src/indexes/types.ts → indexes/types.d.cts} +81 -87
- package/indexes/types.d.mts +81 -0
- package/indexes/types.mjs +1 -0
- package/installFromLocal/index.cjs +3 -0
- package/installFromLocal/index.d.cts +3 -0
- package/installFromLocal/index.d.mts +3 -0
- package/installFromLocal/index.mjs +3 -0
- package/installFromLocal/installFromLocal.cjs +46 -0
- package/installFromLocal/installFromLocal.cjs.map +1 -0
- package/installFromLocal/installFromLocal.d.cts +11 -0
- package/installFromLocal/installFromLocal.d.mts +12 -0
- package/installFromLocal/installFromLocal.mjs +43 -0
- package/installFromLocal/installFromLocal.mjs.map +1 -0
- package/installFromLocal/types.cjs +0 -0
- package/{src/installFromLocal/types.ts → installFromLocal/types.d.cts} +21 -19
- package/installFromLocal/types.d.mts +21 -0
- package/installFromLocal/types.mjs +1 -0
- package/isMatchingPath/index.cjs +3 -0
- package/isMatchingPath/index.d.cts +3 -0
- package/isMatchingPath/index.d.mts +3 -0
- package/isMatchingPath/index.mjs +3 -0
- package/isMatchingPath/isMatchingPath.cjs +52 -0
- package/isMatchingPath/isMatchingPath.cjs.map +1 -0
- package/isMatchingPath/isMatchingPath.d.cts +13 -0
- package/isMatchingPath/isMatchingPath.d.mts +14 -0
- package/isMatchingPath/isMatchingPath.mjs +50 -0
- package/isMatchingPath/isMatchingPath.mjs.map +1 -0
- package/isMatchingPath/types.cjs +0 -0
- package/isMatchingPath/types.d.cts +72 -0
- package/isMatchingPath/types.d.mts +72 -0
- package/isMatchingPath/types.mjs +1 -0
- package/isTargetPath/index.cjs +3 -0
- package/isTargetPath/index.d.cts +3 -0
- package/isTargetPath/index.d.mts +3 -0
- package/isTargetPath/index.mjs +3 -0
- package/isTargetPath/isTargetPath.cjs +21 -0
- package/isTargetPath/isTargetPath.cjs.map +1 -0
- package/isTargetPath/isTargetPath.d.cts +7 -0
- package/isTargetPath/isTargetPath.d.mts +8 -0
- package/isTargetPath/isTargetPath.mjs +19 -0
- package/isTargetPath/isTargetPath.mjs.map +1 -0
- package/isTargetPath/types.cjs +0 -0
- package/{src/isTargetPath/types.ts → isTargetPath/types.d.cts} +33 -38
- package/isTargetPath/types.d.mts +33 -0
- package/isTargetPath/types.mjs +1 -0
- package/moveFilesToSubdir/index.cjs +3 -0
- package/moveFilesToSubdir/index.d.cts +3 -0
- package/moveFilesToSubdir/index.d.mts +3 -0
- package/moveFilesToSubdir/index.mjs +3 -0
- package/moveFilesToSubdir/moveFilesToSubdir.cjs +32 -0
- package/moveFilesToSubdir/moveFilesToSubdir.cjs.map +1 -0
- package/moveFilesToSubdir/moveFilesToSubdir.d.cts +10 -0
- package/moveFilesToSubdir/moveFilesToSubdir.d.mts +11 -0
- package/moveFilesToSubdir/moveFilesToSubdir.mjs +29 -0
- package/moveFilesToSubdir/moveFilesToSubdir.mjs.map +1 -0
- package/moveFilesToSubdir/types.cjs +0 -0
- package/{src/moveFilesToSubdir/types.ts → moveFilesToSubdir/types.d.cts} +18 -15
- package/moveFilesToSubdir/types.d.mts +18 -0
- package/moveFilesToSubdir/types.mjs +1 -0
- package/package.json +20 -29
- package/removeFiles/index.cjs +3 -0
- package/removeFiles/index.d.cts +2 -0
- package/removeFiles/index.d.mts +2 -0
- package/removeFiles/index.mjs +3 -0
- package/removeFiles/removeFiles.cjs +15 -0
- package/removeFiles/removeFiles.cjs.map +1 -0
- package/removeFiles/removeFiles.d.cts +6 -0
- package/removeFiles/removeFiles.d.mts +7 -0
- package/removeFiles/removeFiles.mjs +12 -0
- package/removeFiles/removeFiles.mjs.map +1 -0
- package/removeFiles/types.cjs +0 -0
- package/removeFiles/types.d.cts +9 -0
- package/removeFiles/types.d.mts +9 -0
- package/removeFiles/types.mjs +1 -0
- package/ver/index.cjs +3 -0
- package/ver/index.d.cts +3 -0
- package/ver/index.d.mts +3 -0
- package/ver/index.mjs +3 -0
- package/ver/types.cjs +0 -0
- package/{src/ver/types.ts → ver/types.d.cts} +16 -13
- package/ver/types.d.mts +16 -0
- package/ver/types.mjs +1 -0
- package/ver/ver.cjs +34 -0
- package/ver/ver.cjs.map +1 -0
- package/ver/ver.d.cts +11 -0
- package/ver/ver.d.mts +12 -0
- package/ver/ver.mjs +31 -0
- package/ver/ver.mjs.map +1 -0
- package/src/addExports/addExports.ts +0 -94
- package/src/addExports/index.ts +0 -2
- package/src/addJsExtensions/addJsExtensions.ts +0 -30
- package/src/addJsExtensions/index.ts +0 -1
- package/src/checkExistence/checkExistence.ts +0 -16
- package/src/checkExistence/index.ts +0 -1
- package/src/createExternalOptionFunction/createExternalOptionFunction.ts +0 -43
- package/src/createExternalOptionFunction/index.ts +0 -1
- package/src/editJsonFile/editJsonFile.ts +0 -30
- package/src/editJsonFile/index.ts +0 -1
- package/src/generatePublishPackageJson/generatePublishPackageJson.ts +0 -55
- package/src/generatePublishPackageJson/index.ts +0 -2
- package/src/index.ts +0 -11
- package/src/indexes/constants.ts +0 -135
- package/src/indexes/index.ts +0 -2
- package/src/indexes/indexes.ts +0 -194
- package/src/installFromLocal/index.ts +0 -2
- package/src/installFromLocal/installFromLocal.ts +0 -63
- package/src/isMatchingPath/index.ts +0 -2
- package/src/isMatchingPath/isMatchingPath.ts +0 -94
- package/src/isMatchingPath/types.ts +0 -95
- package/src/isTargetPath/index.ts +0 -2
- package/src/isTargetPath/isTargetPath.ts +0 -30
- package/src/moveFilesToSubdir/index.ts +0 -2
- package/src/moveFilesToSubdir/moveFilesToSubdir.ts +0 -40
- package/src/removeFiles/index.ts +0 -1
- package/src/removeFiles/removeFiles.ts +0 -11
- package/src/removeFiles/types.ts +0 -5
- package/src/ver/index.ts +0 -2
- package/src/ver/ver.ts +0 -38
- package/tsconfig.json +0 -46
- package/tsdown.config.ts +0 -41
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* @param
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* indexファイルの作成
|
|
13
|
-
*/
|
|
14
|
-
index?: boolean;
|
|
15
|
-
};
|
|
1
|
+
import { IsTargetPathOptions } from "../isTargetPath/types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/moveFilesToSubdir/types.d.ts
|
|
4
|
+
type MoveFilesToSubdirOptions = Omit<IsTargetPathOptions, 'itemType'> & {
|
|
5
|
+
/**
|
|
6
|
+
* ファイル毎の後処理
|
|
7
|
+
* @param subdirPath サブディレクトリのパス
|
|
8
|
+
* @param fileName ファイル名
|
|
9
|
+
*/
|
|
10
|
+
process?: (subdirPath: string, fileName: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* indexファイルの作成
|
|
13
|
+
*/
|
|
14
|
+
index?: boolean;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { MoveFilesToSubdirOptions };
|
|
18
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IsTargetPathOptions } from "../isTargetPath/types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/moveFilesToSubdir/types.d.ts
|
|
4
|
+
type MoveFilesToSubdirOptions = Omit<IsTargetPathOptions, 'itemType'> & {
|
|
5
|
+
/**
|
|
6
|
+
* ファイル毎の後処理
|
|
7
|
+
* @param subdirPath サブディレクトリのパス
|
|
8
|
+
* @param fileName ファイル名
|
|
9
|
+
*/
|
|
10
|
+
process?: (subdirPath: string, fileName: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* indexファイルの作成
|
|
13
|
+
*/
|
|
14
|
+
index?: boolean;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { MoveFilesToSubdirOptions };
|
|
18
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niche-works/dev",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"utils"
|
|
6
6
|
],
|
|
@@ -12,36 +12,27 @@
|
|
|
12
12
|
"author": "Mitsuhiro Seino",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"exports": {
|
|
15
|
-
".":
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
}
|
|
18
31
|
},
|
|
19
|
-
"main": "./src/index.ts",
|
|
20
|
-
"module": "./src/index.ts",
|
|
21
32
|
"dependencies": {
|
|
33
|
+
"fast-glob": "^3.3.3",
|
|
22
34
|
"fs-extra": "^11.3.4",
|
|
23
35
|
"remeda": "^2.33.6",
|
|
24
|
-
"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/fs-extra": "^11.0.4",
|
|
28
|
-
"@types/node": "^25.5.0",
|
|
29
|
-
"fast-glob": "^3.3.3",
|
|
30
|
-
"prettier": "^3.8.1",
|
|
31
|
-
"prettier-plugin-organize-imports": "^4.3.0",
|
|
32
|
-
"prettier-plugin-packagejson": "^3.0.2",
|
|
33
|
-
"tsdown": "^0.21.9",
|
|
34
|
-
"tsx": "^4.21.0",
|
|
35
|
-
"type-fest": "^5.5.0",
|
|
36
|
-
"typescript": "^6.0.2"
|
|
37
|
-
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"build": "tsdown",
|
|
40
|
-
"check": "tsc --noEmit",
|
|
41
|
-
"dev": "tsdown --watch",
|
|
42
|
-
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json}\"",
|
|
43
|
-
"indexes": "tsx scripts/indexes.ts",
|
|
44
|
-
"lint": "tsdown --dry-run",
|
|
45
|
-
"tidy": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json}\" --config ./prettier.tidy.config.js"
|
|
36
|
+
"type-fest": "^5.5.0"
|
|
46
37
|
}
|
|
47
|
-
}
|
|
38
|
+
}
|
|
@@ -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,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 @@
|
|
|
1
|
+
export { };
|
package/ver/index.cjs
ADDED
package/ver/index.d.cts
ADDED
package/ver/index.d.mts
ADDED
package/ver/index.mjs
ADDED
package/ver/types.cjs
ADDED
|
File without changes
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
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
|
package/ver/types.d.mts
ADDED
|
@@ -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
|
package/ver/ver.cjs.map
ADDED
|
@@ -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
|
package/ver/ver.mjs.map
ADDED
|
@@ -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,94 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import { posix as path } from 'path';
|
|
3
|
-
import isTargetPath from '../isTargetPath';
|
|
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 (isTargetPath(itemPath, { include, exclude })) {
|
|
85
|
-
// exportの対象の場合
|
|
86
|
-
exportsIndex.push({
|
|
87
|
-
key: current,
|
|
88
|
-
path: path.join(dist, current, name),
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return exportsIndex;
|
|
94
|
-
}
|
package/src/addExports/index.ts
DELETED
|
@@ -1,30 +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
|
-
* ローカルファイルのimportやrequireに拡張子を付与する
|
|
11
|
-
* @param dir
|
|
12
|
-
*/
|
|
13
|
-
export default async function addJsExtensions(dir: string) {
|
|
14
|
-
const files = await fg(`${dir}/**/*.{js,cjs}`);
|
|
15
|
-
for (const file of files) {
|
|
16
|
-
const content = await fs.readFile(file, 'utf-8');
|
|
17
|
-
const ext = file.endsWith('.cjs') ? '.cjs' : '.js';
|
|
18
|
-
const fixed = content.replace(PATTERNS[ext], (match, pos1) => {
|
|
19
|
-
if (pos1.endsWith(ext)) {
|
|
20
|
-
// 既に拡張子あり
|
|
21
|
-
return match;
|
|
22
|
-
}
|
|
23
|
-
// 拡張子を付与
|
|
24
|
-
return match.replace(pos1, `${pos1}${ext}`);
|
|
25
|
-
});
|
|
26
|
-
if (content !== fixed) {
|
|
27
|
-
await fs.writeFile(file, fixed);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -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,43 +0,0 @@
|
|
|
1
|
-
import isMatchingPath from '../isMatchingPath';
|
|
2
|
-
import type {
|
|
3
|
-
CreateExternalOptionFunctionOptions,
|
|
4
|
-
ExternalOptionFunction,
|
|
5
|
-
} from './types';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* rolldownやrollupなどで内部モジュールのimport以外をexternalとして扱うための関数を作る関数
|
|
9
|
-
* @param options
|
|
10
|
-
*/
|
|
11
|
-
export default function createExternalOptionFunction(
|
|
12
|
-
options: CreateExternalOptionFunctionOptions = {},
|
|
13
|
-
): ExternalOptionFunction {
|
|
14
|
-
const { isExternal, isInternal } = options;
|
|
15
|
-
return (
|
|
16
|
-
source: string,
|
|
17
|
-
_importer: string | undefined,
|
|
18
|
-
isResolved: boolean,
|
|
19
|
-
) => {
|
|
20
|
-
const isMatchingPathOptions = {
|
|
21
|
-
conditionOptions: {
|
|
22
|
-
source,
|
|
23
|
-
importer: _importer,
|
|
24
|
-
isResolved,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
if (isMatchingPath(source, isExternal, isMatchingPathOptions)) {
|
|
28
|
-
// 外部モジュール扱い
|
|
29
|
-
return true;
|
|
30
|
-
} else if (isMatchingPath(source, isInternal, isMatchingPathOptions)) {
|
|
31
|
-
// 内部モジュール扱い
|
|
32
|
-
return;
|
|
33
|
-
} else if (!isResolved) {
|
|
34
|
-
// 相対パスでもなく、srcディレクトリ配下でもないものは外部モジュール扱い
|
|
35
|
-
return (
|
|
36
|
-
!source.startsWith('.') &&
|
|
37
|
-
!source.startsWith('/') &&
|
|
38
|
-
!source.startsWith('src/')
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
return;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './createExternalOptionFunction';
|
|
@@ -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';
|