@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.
- 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/createSassClassNameFunction/createSassClassNameFunction.cjs +19 -0
- package/createSassClassNameFunction/createSassClassNameFunction.cjs.map +1 -0
- package/createSassClassNameFunction/createSassClassNameFunction.d.cts +11 -0
- package/createSassClassNameFunction/createSassClassNameFunction.d.mts +12 -0
- package/createSassClassNameFunction/createSassClassNameFunction.mjs +18 -0
- package/createSassClassNameFunction/createSassClassNameFunction.mjs.map +1 -0
- package/createSassClassNameFunction/index.cjs +3 -0
- package/createSassClassNameFunction/index.d.cts +2 -0
- package/createSassClassNameFunction/index.d.mts +2 -0
- package/createSassClassNameFunction/index.mjs +3 -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 +41 -0
- package/index.d.cts +14 -0
- package/index.d.mts +14 -0
- package/index.mjs +28 -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 +21 -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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_isTargetPath_isTargetPath = require('../isTargetPath/isTargetPath.cjs');
|
|
3
|
+
require('../isTargetPath/index.cjs');
|
|
4
|
+
let fs_extra = require("fs-extra");
|
|
5
|
+
fs_extra = require_runtime.__toESM(fs_extra, 1);
|
|
6
|
+
let path = require("path");
|
|
7
|
+
|
|
8
|
+
//#region src/addExports/addExports.ts
|
|
9
|
+
/**
|
|
10
|
+
* index.tsが配置されているモジュールをpackage.jsonのexportsに追加する
|
|
11
|
+
* @param targetPath
|
|
12
|
+
* @param options
|
|
13
|
+
*/
|
|
14
|
+
function addExports(targetPath = "src", options = {}) {
|
|
15
|
+
let { packageJsonPath = "package.json", include = [], dist = "dist", dryRun, ...rest } = options;
|
|
16
|
+
include = [{
|
|
17
|
+
valueType: "base",
|
|
18
|
+
entryType: "file",
|
|
19
|
+
conditions: /^index.(ts|tsx)$/i
|
|
20
|
+
}, ...include];
|
|
21
|
+
const exportsIndex = _addExports(targetPath, {
|
|
22
|
+
packageJsonPath,
|
|
23
|
+
include,
|
|
24
|
+
dist,
|
|
25
|
+
...rest
|
|
26
|
+
});
|
|
27
|
+
const packageJson = fs_extra.default.readJsonSync(packageJsonPath, { encoding: "utf8" });
|
|
28
|
+
packageJson.exports = {};
|
|
29
|
+
exportsIndex.sort((a, b) => a.key > b.key ? 1 : -1);
|
|
30
|
+
for (const index of exportsIndex) packageJson.exports[index.key ? "./" + index.key : "."] = "./" + index.path + ".js";
|
|
31
|
+
if (dryRun) console.log(packageJson);
|
|
32
|
+
else fs_extra.default.writeJsonSync(packageJsonPath, packageJson, {
|
|
33
|
+
encoding: "utf8",
|
|
34
|
+
spaces: 2
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function _addExports(targetPath, options, current = "") {
|
|
38
|
+
const { include, exclude, dist = "dist" } = options;
|
|
39
|
+
if (!fs_extra.default.statSync(targetPath).isDirectory()) console.error(`"${targetPath}" is not directory.`);
|
|
40
|
+
const items = fs_extra.default.readdirSync(targetPath);
|
|
41
|
+
items.sort();
|
|
42
|
+
const exportsIndex = [];
|
|
43
|
+
for (const item of items) {
|
|
44
|
+
const itemPath = path.posix.join(targetPath, item);
|
|
45
|
+
const stat = fs_extra.default.statSync(itemPath);
|
|
46
|
+
const { name } = path.posix.parse(itemPath);
|
|
47
|
+
if (stat.isDirectory()) exportsIndex.push(..._addExports(itemPath, options, path.posix.join(current, item)));
|
|
48
|
+
else if (require_isTargetPath_isTargetPath(itemPath, {
|
|
49
|
+
include,
|
|
50
|
+
exclude
|
|
51
|
+
})) exportsIndex.push({
|
|
52
|
+
key: current,
|
|
53
|
+
path: path.posix.join(dist, current, name)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return exportsIndex;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
module.exports = addExports;
|
|
61
|
+
//# sourceMappingURL=addExports.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addExports.cjs","names":["fs","isTargetPath"],"sources":["../../src/addExports/addExports.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport { posix as path } from 'path';\r\nimport isTargetPath from '../isTargetPath';\r\nimport type { AddExportsOptions } from './types';\r\n\r\n/**\r\n * index.tsが配置されているモジュールをpackage.jsonのexportsに追加する\r\n * @param targetPath\r\n * @param options\r\n */\r\nexport default function addExports(\r\n targetPath: string = 'src',\r\n options: AddExportsOptions = {},\r\n) {\r\n let {\r\n packageJsonPath = 'package.json',\r\n include = [],\r\n dist = 'dist',\r\n dryRun,\r\n ...rest\r\n } = options;\r\n\r\n // 処理対象を設定\r\n include = [\r\n // indexファイルを対象\r\n {\r\n valueType: 'base',\r\n entryType: 'file',\r\n conditions: /^index.(ts|tsx)$/i,\r\n },\r\n ...include,\r\n ];\r\n\r\n // exportsをpackage.jsonに追加\r\n const exportsIndex = _addExports(targetPath, {\r\n packageJsonPath,\r\n include,\r\n dist,\r\n ...rest,\r\n });\r\n\r\n const packageJson = fs.readJsonSync(packageJsonPath, { encoding: 'utf8' });\r\n packageJson.exports = {};\r\n exportsIndex.sort((a, b) => (a.key > b.key ? 1 : -1));\r\n for (const index of exportsIndex) {\r\n packageJson.exports[index.key ? './' + index.key : '.'] =\r\n './' + index.path + '.js';\r\n }\r\n if (dryRun) {\r\n console.log(packageJson);\r\n } else {\r\n fs.writeJsonSync(packageJsonPath, packageJson, {\r\n encoding: 'utf8',\r\n spaces: 2,\r\n });\r\n }\r\n}\r\n\r\nfunction _addExports(\r\n targetPath: string,\r\n options: AddExportsOptions,\r\n current: string = '',\r\n) {\r\n const { include, exclude, dist = 'dist' } = options;\r\n\r\n const stat = fs.statSync(targetPath);\r\n if (!stat.isDirectory()) {\r\n console.error(`\"${targetPath}\" is not directory.`);\r\n }\r\n const items = fs.readdirSync(targetPath);\r\n items.sort();\r\n const exportsIndex: { key: string; path: string }[] = [];\r\n\r\n for (const item of items) {\r\n const itemPath = path.join(targetPath, item);\r\n const stat = fs.statSync(itemPath);\r\n const { name } = path.parse(itemPath);\r\n\r\n if (stat.isDirectory()) {\r\n // ディレクトリの場合は先に子要素を処理\r\n exportsIndex.push(\r\n ..._addExports(itemPath, options, path.join(current, item)),\r\n );\r\n } else if (isTargetPath(itemPath, { include, exclude })) {\r\n // exportの対象の場合\r\n exportsIndex.push({\r\n key: current,\r\n path: path.join(dist, current, name),\r\n });\r\n }\r\n }\r\n\r\n return exportsIndex;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAwB,WACtB,aAAqB,OACrB,UAA6B,EAAE,EAC/B;CACA,IAAI,EACF,kBAAkB,gBAClB,UAAU,EAAE,EACZ,OAAO,QACP,QACA,GAAG,SACD;AAGJ,WAAU,CAER;EACE,WAAW;EACX,WAAW;EACX,YAAY;EACb,EACD,GAAG,QACJ;CAGD,MAAM,eAAe,YAAY,YAAY;EAC3C;EACA;EACA;EACA,GAAG;EACJ,CAAC;CAEF,MAAM,cAAcA,iBAAG,aAAa,iBAAiB,EAAE,UAAU,QAAQ,CAAC;AAC1E,aAAY,UAAU,EAAE;AACxB,cAAa,MAAM,GAAG,MAAO,EAAE,MAAM,EAAE,MAAM,IAAI,GAAI;AACrD,MAAK,MAAM,SAAS,aAClB,aAAY,QAAQ,MAAM,MAAM,OAAO,MAAM,MAAM,OACjD,OAAO,MAAM,OAAO;AAExB,KAAI,OACF,SAAQ,IAAI,YAAY;KAExB,kBAAG,cAAc,iBAAiB,aAAa;EAC7C,UAAU;EACV,QAAQ;EACT,CAAC;;AAIN,SAAS,YACP,YACA,SACA,UAAkB,IAClB;CACA,MAAM,EAAE,SAAS,SAAS,OAAO,WAAW;AAG5C,KAAI,CADSA,iBAAG,SAAS,WAAW,CAC1B,aAAa,CACrB,SAAQ,MAAM,IAAI,WAAW,qBAAqB;CAEpD,MAAM,QAAQA,iBAAG,YAAY,WAAW;AACxC,OAAM,MAAM;CACZ,MAAM,eAAgD,EAAE;AAExD,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,WAAK,KAAK,YAAY,KAAK;EAC5C,MAAM,OAAOA,iBAAG,SAAS,SAAS;EAClC,MAAM,EAAE,SAAS,WAAK,MAAM,SAAS;AAErC,MAAI,KAAK,aAAa,CAEpB,cAAa,KACX,GAAG,YAAY,UAAU,SAAS,WAAK,KAAK,SAAS,KAAK,CAAC,CAC5D;WACQC,kCAAa,UAAU;GAAE;GAAS;GAAS,CAAC,CAErD,cAAa,KAAK;GAChB,KAAK;GACL,MAAM,WAAK,KAAK,MAAM,SAAS,KAAK;GACrC,CAAC;;AAIN,QAAO"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AddExportsOptions } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/addExports/addExports.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* index.tsが配置されているモジュールをpackage.jsonのexportsに追加する
|
|
6
|
+
* @param targetPath
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
declare function addExports(targetPath?: string, options?: AddExportsOptions): void;
|
|
10
|
+
export = addExports;
|
|
11
|
+
//# sourceMappingURL=addExports.d.cts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AddExportsOptions } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/addExports/addExports.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* index.tsが配置されているモジュールをpackage.jsonのexportsに追加する
|
|
6
|
+
* @param targetPath
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
declare function addExports(targetPath?: string, options?: AddExportsOptions): void;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { addExports as default };
|
|
12
|
+
//# sourceMappingURL=addExports.d.mts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import isTargetPath from "../isTargetPath/isTargetPath.mjs";
|
|
2
|
+
import "../isTargetPath/index.mjs";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { posix } from "path";
|
|
5
|
+
|
|
6
|
+
//#region src/addExports/addExports.ts
|
|
7
|
+
/**
|
|
8
|
+
* index.tsが配置されているモジュールをpackage.jsonのexportsに追加する
|
|
9
|
+
* @param targetPath
|
|
10
|
+
* @param options
|
|
11
|
+
*/
|
|
12
|
+
function addExports(targetPath = "src", options = {}) {
|
|
13
|
+
let { packageJsonPath = "package.json", include = [], dist = "dist", dryRun, ...rest } = options;
|
|
14
|
+
include = [{
|
|
15
|
+
valueType: "base",
|
|
16
|
+
entryType: "file",
|
|
17
|
+
conditions: /^index.(ts|tsx)$/i
|
|
18
|
+
}, ...include];
|
|
19
|
+
const exportsIndex = _addExports(targetPath, {
|
|
20
|
+
packageJsonPath,
|
|
21
|
+
include,
|
|
22
|
+
dist,
|
|
23
|
+
...rest
|
|
24
|
+
});
|
|
25
|
+
const packageJson = fs.readJsonSync(packageJsonPath, { encoding: "utf8" });
|
|
26
|
+
packageJson.exports = {};
|
|
27
|
+
exportsIndex.sort((a, b) => a.key > b.key ? 1 : -1);
|
|
28
|
+
for (const index of exportsIndex) packageJson.exports[index.key ? "./" + index.key : "."] = "./" + index.path + ".js";
|
|
29
|
+
if (dryRun) console.log(packageJson);
|
|
30
|
+
else fs.writeJsonSync(packageJsonPath, packageJson, {
|
|
31
|
+
encoding: "utf8",
|
|
32
|
+
spaces: 2
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function _addExports(targetPath, options, current = "") {
|
|
36
|
+
const { include, exclude, dist = "dist" } = options;
|
|
37
|
+
if (!fs.statSync(targetPath).isDirectory()) console.error(`"${targetPath}" is not directory.`);
|
|
38
|
+
const items = fs.readdirSync(targetPath);
|
|
39
|
+
items.sort();
|
|
40
|
+
const exportsIndex = [];
|
|
41
|
+
for (const item of items) {
|
|
42
|
+
const itemPath = posix.join(targetPath, item);
|
|
43
|
+
const stat = fs.statSync(itemPath);
|
|
44
|
+
const { name } = posix.parse(itemPath);
|
|
45
|
+
if (stat.isDirectory()) exportsIndex.push(..._addExports(itemPath, options, posix.join(current, item)));
|
|
46
|
+
else if (isTargetPath(itemPath, {
|
|
47
|
+
include,
|
|
48
|
+
exclude
|
|
49
|
+
})) exportsIndex.push({
|
|
50
|
+
key: current,
|
|
51
|
+
path: posix.join(dist, current, name)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return exportsIndex;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { addExports as default };
|
|
59
|
+
//# sourceMappingURL=addExports.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addExports.mjs","names":["path"],"sources":["../../src/addExports/addExports.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport { posix as path } from 'path';\r\nimport isTargetPath from '../isTargetPath';\r\nimport type { AddExportsOptions } from './types';\r\n\r\n/**\r\n * index.tsが配置されているモジュールをpackage.jsonのexportsに追加する\r\n * @param targetPath\r\n * @param options\r\n */\r\nexport default function addExports(\r\n targetPath: string = 'src',\r\n options: AddExportsOptions = {},\r\n) {\r\n let {\r\n packageJsonPath = 'package.json',\r\n include = [],\r\n dist = 'dist',\r\n dryRun,\r\n ...rest\r\n } = options;\r\n\r\n // 処理対象を設定\r\n include = [\r\n // indexファイルを対象\r\n {\r\n valueType: 'base',\r\n entryType: 'file',\r\n conditions: /^index.(ts|tsx)$/i,\r\n },\r\n ...include,\r\n ];\r\n\r\n // exportsをpackage.jsonに追加\r\n const exportsIndex = _addExports(targetPath, {\r\n packageJsonPath,\r\n include,\r\n dist,\r\n ...rest,\r\n });\r\n\r\n const packageJson = fs.readJsonSync(packageJsonPath, { encoding: 'utf8' });\r\n packageJson.exports = {};\r\n exportsIndex.sort((a, b) => (a.key > b.key ? 1 : -1));\r\n for (const index of exportsIndex) {\r\n packageJson.exports[index.key ? './' + index.key : '.'] =\r\n './' + index.path + '.js';\r\n }\r\n if (dryRun) {\r\n console.log(packageJson);\r\n } else {\r\n fs.writeJsonSync(packageJsonPath, packageJson, {\r\n encoding: 'utf8',\r\n spaces: 2,\r\n });\r\n }\r\n}\r\n\r\nfunction _addExports(\r\n targetPath: string,\r\n options: AddExportsOptions,\r\n current: string = '',\r\n) {\r\n const { include, exclude, dist = 'dist' } = options;\r\n\r\n const stat = fs.statSync(targetPath);\r\n if (!stat.isDirectory()) {\r\n console.error(`\"${targetPath}\" is not directory.`);\r\n }\r\n const items = fs.readdirSync(targetPath);\r\n items.sort();\r\n const exportsIndex: { key: string; path: string }[] = [];\r\n\r\n for (const item of items) {\r\n const itemPath = path.join(targetPath, item);\r\n const stat = fs.statSync(itemPath);\r\n const { name } = path.parse(itemPath);\r\n\r\n if (stat.isDirectory()) {\r\n // ディレクトリの場合は先に子要素を処理\r\n exportsIndex.push(\r\n ..._addExports(itemPath, options, path.join(current, item)),\r\n );\r\n } else if (isTargetPath(itemPath, { include, exclude })) {\r\n // exportの対象の場合\r\n exportsIndex.push({\r\n key: current,\r\n path: path.join(dist, current, name),\r\n });\r\n }\r\n }\r\n\r\n return exportsIndex;\r\n}\r\n"],"mappings":";;;;;;;;;;;AAUA,SAAwB,WACtB,aAAqB,OACrB,UAA6B,EAAE,EAC/B;CACA,IAAI,EACF,kBAAkB,gBAClB,UAAU,EAAE,EACZ,OAAO,QACP,QACA,GAAG,SACD;AAGJ,WAAU,CAER;EACE,WAAW;EACX,WAAW;EACX,YAAY;EACb,EACD,GAAG,QACJ;CAGD,MAAM,eAAe,YAAY,YAAY;EAC3C;EACA;EACA;EACA,GAAG;EACJ,CAAC;CAEF,MAAM,cAAc,GAAG,aAAa,iBAAiB,EAAE,UAAU,QAAQ,CAAC;AAC1E,aAAY,UAAU,EAAE;AACxB,cAAa,MAAM,GAAG,MAAO,EAAE,MAAM,EAAE,MAAM,IAAI,GAAI;AACrD,MAAK,MAAM,SAAS,aAClB,aAAY,QAAQ,MAAM,MAAM,OAAO,MAAM,MAAM,OACjD,OAAO,MAAM,OAAO;AAExB,KAAI,OACF,SAAQ,IAAI,YAAY;KAExB,IAAG,cAAc,iBAAiB,aAAa;EAC7C,UAAU;EACV,QAAQ;EACT,CAAC;;AAIN,SAAS,YACP,YACA,SACA,UAAkB,IAClB;CACA,MAAM,EAAE,SAAS,SAAS,OAAO,WAAW;AAG5C,KAAI,CADS,GAAG,SAAS,WAAW,CAC1B,aAAa,CACrB,SAAQ,MAAM,IAAI,WAAW,qBAAqB;CAEpD,MAAM,QAAQ,GAAG,YAAY,WAAW;AACxC,OAAM,MAAM;CACZ,MAAM,eAAgD,EAAE;AAExD,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAWA,MAAK,KAAK,YAAY,KAAK;EAC5C,MAAM,OAAO,GAAG,SAAS,SAAS;EAClC,MAAM,EAAE,SAASA,MAAK,MAAM,SAAS;AAErC,MAAI,KAAK,aAAa,CAEpB,cAAa,KACX,GAAG,YAAY,UAAU,SAASA,MAAK,KAAK,SAAS,KAAK,CAAC,CAC5D;WACQ,aAAa,UAAU;GAAE;GAAS;GAAS,CAAC,CAErD,cAAa,KAAK;GAChB,KAAK;GACL,MAAMA,MAAK,KAAK,MAAM,SAAS,KAAK;GACrC,CAAC;;AAIN,QAAO"}
|
|
File without changes
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* ビルドしたパッケージが置かれたディレクトリの名称
|
|
11
|
-
*/
|
|
12
|
-
dist?: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* -
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { IsMatchingPathCondition } from "../isMatchingPath/types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/addExports/types.d.ts
|
|
4
|
+
type AddExportsOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* package.jsonのパス
|
|
7
|
+
*/
|
|
8
|
+
packageJsonPath?: string;
|
|
9
|
+
/**
|
|
10
|
+
* ビルドしたパッケージが置かれたディレクトリの名称
|
|
11
|
+
*/
|
|
12
|
+
dist?: string;
|
|
13
|
+
/**
|
|
14
|
+
* indexファイルを作る対象
|
|
15
|
+
* 未指定の場合は下記の条件がデフォルトで適用される
|
|
16
|
+
*
|
|
17
|
+
* - ファイル名が`_`で始まらず拡張子が`.ts`,`.tsx`,`.js`,`.jsx`のもの
|
|
18
|
+
* - ディレクトリ名が`_`で始まらないもの
|
|
19
|
+
*/
|
|
20
|
+
include?: IsMatchingPathCondition[];
|
|
21
|
+
/**
|
|
22
|
+
* indexファイルを作る対象から除外するもの
|
|
23
|
+
*/
|
|
24
|
+
exclude?: IsMatchingPathCondition[];
|
|
25
|
+
/**
|
|
26
|
+
* お試し
|
|
27
|
+
* ファイルの操作は行わない
|
|
28
|
+
*/
|
|
29
|
+
dryRun?: boolean;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { AddExportsOptions };
|
|
33
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IsMatchingPathCondition } from "../isMatchingPath/types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/addExports/types.d.ts
|
|
4
|
+
type AddExportsOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* package.jsonのパス
|
|
7
|
+
*/
|
|
8
|
+
packageJsonPath?: string;
|
|
9
|
+
/**
|
|
10
|
+
* ビルドしたパッケージが置かれたディレクトリの名称
|
|
11
|
+
*/
|
|
12
|
+
dist?: string;
|
|
13
|
+
/**
|
|
14
|
+
* indexファイルを作る対象
|
|
15
|
+
* 未指定の場合は下記の条件がデフォルトで適用される
|
|
16
|
+
*
|
|
17
|
+
* - ファイル名が`_`で始まらず拡張子が`.ts`,`.tsx`,`.js`,`.jsx`のもの
|
|
18
|
+
* - ディレクトリ名が`_`で始まらないもの
|
|
19
|
+
*/
|
|
20
|
+
include?: IsMatchingPathCondition[];
|
|
21
|
+
/**
|
|
22
|
+
* indexファイルを作る対象から除外するもの
|
|
23
|
+
*/
|
|
24
|
+
exclude?: IsMatchingPathCondition[];
|
|
25
|
+
/**
|
|
26
|
+
* お試し
|
|
27
|
+
* ファイルの操作は行わない
|
|
28
|
+
*/
|
|
29
|
+
dryRun?: boolean;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { AddExportsOptions };
|
|
33
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,31 @@
|
|
|
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/addJsExtensions/addJsExtensions.ts
|
|
8
|
+
const PATTERNS = {
|
|
9
|
+
".js": /(?:from|import)\s*["'](\.\.?\/[^"']+)["']/g,
|
|
10
|
+
".cjs": /require\(["'](\.\.?\/[^"']+)["']\)/g
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* ローカルファイルのimportやrequireに拡張子を付与する
|
|
14
|
+
* @param dir
|
|
15
|
+
*/
|
|
16
|
+
async function addJsExtensions(dir) {
|
|
17
|
+
const files = await (0, fast_glob.default)(`${dir}/**/*.{js,cjs}`);
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
const content = await fs_extra.default.readFile(file, "utf-8");
|
|
20
|
+
const ext = file.endsWith(".cjs") ? ".cjs" : ".js";
|
|
21
|
+
const fixed = content.replace(PATTERNS[ext], (match, pos1) => {
|
|
22
|
+
if (pos1.endsWith(ext)) return match;
|
|
23
|
+
return match.replace(pos1, `${pos1}${ext}`);
|
|
24
|
+
});
|
|
25
|
+
if (content !== fixed) await fs_extra.default.writeFile(file, fixed);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
module.exports = addJsExtensions;
|
|
31
|
+
//# sourceMappingURL=addJsExtensions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addJsExtensions.cjs","names":["fs"],"sources":["../../src/addJsExtensions/addJsExtensions.ts"],"sourcesContent":["import fg from 'fast-glob';\r\nimport fs from 'fs-extra';\r\n\r\nconst PATTERNS = {\r\n '.js': /(?:from|import)\\s*[\"'](\\.\\.?\\/[^\"']+)[\"']/g,\r\n '.cjs': /require\\([\"'](\\.\\.?\\/[^\"']+)[\"']\\)/g,\r\n};\r\n\r\n/**\r\n * ローカルファイルのimportやrequireに拡張子を付与する\r\n * @param dir\r\n */\r\nexport default async function addJsExtensions(dir: string) {\r\n const files = await fg(`${dir}/**/*.{js,cjs}`);\r\n for (const file of files) {\r\n const content = await fs.readFile(file, 'utf-8');\r\n const ext = file.endsWith('.cjs') ? '.cjs' : '.js';\r\n const fixed = content.replace(PATTERNS[ext], (match, pos1) => {\r\n if (pos1.endsWith(ext)) {\r\n // 既に拡張子あり\r\n return match;\r\n }\r\n // 拡張子を付与\r\n return match.replace(pos1, `${pos1}${ext}`);\r\n });\r\n if (content !== fixed) {\r\n await fs.writeFile(file, fixed);\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;AAGA,MAAM,WAAW;CACf,OAAO;CACP,QAAQ;CACT;;;;;AAMD,eAA8B,gBAAgB,KAAa;CACzD,MAAM,QAAQ,6BAAS,GAAG,IAAI,gBAAgB;AAC9C,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,UAAU,MAAMA,iBAAG,SAAS,MAAM,QAAQ;EAChD,MAAM,MAAM,KAAK,SAAS,OAAO,GAAG,SAAS;EAC7C,MAAM,QAAQ,QAAQ,QAAQ,SAAS,OAAO,OAAO,SAAS;AAC5D,OAAI,KAAK,SAAS,IAAI,CAEpB,QAAO;AAGT,UAAO,MAAM,QAAQ,MAAM,GAAG,OAAO,MAAM;IAC3C;AACF,MAAI,YAAY,MACd,OAAMA,iBAAG,UAAU,MAAM,MAAM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/addJsExtensions/addJsExtensions.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ローカルファイルのimportやrequireに拡張子を付与する
|
|
4
|
+
* @param dir
|
|
5
|
+
*/
|
|
6
|
+
declare function addJsExtensions(dir: string): Promise<void>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { addJsExtensions as default };
|
|
9
|
+
//# sourceMappingURL=addJsExtensions.d.mts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import fg from "fast-glob";
|
|
3
|
+
|
|
4
|
+
//#region src/addJsExtensions/addJsExtensions.ts
|
|
5
|
+
const PATTERNS = {
|
|
6
|
+
".js": /(?:from|import)\s*["'](\.\.?\/[^"']+)["']/g,
|
|
7
|
+
".cjs": /require\(["'](\.\.?\/[^"']+)["']\)/g
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* ローカルファイルのimportやrequireに拡張子を付与する
|
|
11
|
+
* @param dir
|
|
12
|
+
*/
|
|
13
|
+
async function addJsExtensions(dir) {
|
|
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)) return match;
|
|
20
|
+
return match.replace(pos1, `${pos1}${ext}`);
|
|
21
|
+
});
|
|
22
|
+
if (content !== fixed) await fs.writeFile(file, fixed);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { addJsExtensions as default };
|
|
28
|
+
//# sourceMappingURL=addJsExtensions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addJsExtensions.mjs","names":[],"sources":["../../src/addJsExtensions/addJsExtensions.ts"],"sourcesContent":["import fg from 'fast-glob';\r\nimport fs from 'fs-extra';\r\n\r\nconst PATTERNS = {\r\n '.js': /(?:from|import)\\s*[\"'](\\.\\.?\\/[^\"']+)[\"']/g,\r\n '.cjs': /require\\([\"'](\\.\\.?\\/[^\"']+)[\"']\\)/g,\r\n};\r\n\r\n/**\r\n * ローカルファイルのimportやrequireに拡張子を付与する\r\n * @param dir\r\n */\r\nexport default async function addJsExtensions(dir: string) {\r\n const files = await fg(`${dir}/**/*.{js,cjs}`);\r\n for (const file of files) {\r\n const content = await fs.readFile(file, 'utf-8');\r\n const ext = file.endsWith('.cjs') ? '.cjs' : '.js';\r\n const fixed = content.replace(PATTERNS[ext], (match, pos1) => {\r\n if (pos1.endsWith(ext)) {\r\n // 既に拡張子あり\r\n return match;\r\n }\r\n // 拡張子を付与\r\n return match.replace(pos1, `${pos1}${ext}`);\r\n });\r\n if (content !== fixed) {\r\n await fs.writeFile(file, fixed);\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;AAGA,MAAM,WAAW;CACf,OAAO;CACP,QAAQ;CACT;;;;;AAMD,eAA8B,gBAAgB,KAAa;CACzD,MAAM,QAAQ,MAAM,GAAG,GAAG,IAAI,gBAAgB;AAC9C,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,UAAU,MAAM,GAAG,SAAS,MAAM,QAAQ;EAChD,MAAM,MAAM,KAAK,SAAS,OAAO,GAAG,SAAS;EAC7C,MAAM,QAAQ,QAAQ,QAAQ,SAAS,OAAO,OAAO,SAAS;AAC5D,OAAI,KAAK,SAAS,IAAI,CAEpB,QAAO;AAGT,UAAO,MAAM,QAAQ,MAAM,GAAG,OAAO,MAAM;IAC3C;AACF,MAAI,YAAY,MACd,OAAM,GAAG,UAAU,MAAM,MAAM"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
|
|
5
|
+
//#region src/checkExistence/checkExistence.ts
|
|
6
|
+
/**
|
|
7
|
+
* ディレクトリ、ファイルの存在チェック
|
|
8
|
+
* @param targetPaths
|
|
9
|
+
* @param options
|
|
10
|
+
*/
|
|
11
|
+
function checkExistence(...targetPaths) {
|
|
12
|
+
return targetPaths.every((targetPath) => {
|
|
13
|
+
if (!fs_extra.default.existsSync(targetPath)) {
|
|
14
|
+
console.error(`${targetPath}が存在しません。`);
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
module.exports = checkExistence;
|
|
23
|
+
//# sourceMappingURL=checkExistence.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkExistence.cjs","names":["fs"],"sources":["../../src/checkExistence/checkExistence.ts"],"sourcesContent":["import fs from 'fs-extra';\r\n\r\n/**\r\n * ディレクトリ、ファイルの存在チェック\r\n * @param targetPaths\r\n * @param options\r\n */\r\nexport default function checkExistence(...targetPaths: string[]) {\r\n return targetPaths.every((targetPath) => {\r\n if (!fs.existsSync(targetPath)) {\r\n console.error(`${targetPath}が存在しません。`);\r\n return false;\r\n }\r\n return true;\r\n });\r\n}\r\n"],"mappings":";;;;;;;;;;AAOA,SAAwB,eAAe,GAAG,aAAuB;AAC/D,QAAO,YAAY,OAAO,eAAe;AACvC,MAAI,CAACA,iBAAG,WAAW,WAAW,EAAE;AAC9B,WAAQ,MAAM,GAAG,WAAW,UAAU;AACtC,UAAO;;AAET,SAAO;GACP"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/checkExistence/checkExistence.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ディレクトリ、ファイルの存在チェック
|
|
4
|
+
* @param targetPaths
|
|
5
|
+
* @param options
|
|
6
|
+
*/
|
|
7
|
+
declare function checkExistence(...targetPaths: string[]): boolean;
|
|
8
|
+
export = checkExistence;
|
|
9
|
+
//# sourceMappingURL=checkExistence.d.cts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/checkExistence/checkExistence.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ディレクトリ、ファイルの存在チェック
|
|
4
|
+
* @param targetPaths
|
|
5
|
+
* @param options
|
|
6
|
+
*/
|
|
7
|
+
declare function checkExistence(...targetPaths: string[]): boolean;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { checkExistence as default };
|
|
10
|
+
//# sourceMappingURL=checkExistence.d.mts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
|
|
3
|
+
//#region src/checkExistence/checkExistence.ts
|
|
4
|
+
/**
|
|
5
|
+
* ディレクトリ、ファイルの存在チェック
|
|
6
|
+
* @param targetPaths
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
function checkExistence(...targetPaths) {
|
|
10
|
+
return targetPaths.every((targetPath) => {
|
|
11
|
+
if (!fs.existsSync(targetPath)) {
|
|
12
|
+
console.error(`${targetPath}が存在しません。`);
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { checkExistence as default };
|
|
21
|
+
//# sourceMappingURL=checkExistence.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkExistence.mjs","names":[],"sources":["../../src/checkExistence/checkExistence.ts"],"sourcesContent":["import fs from 'fs-extra';\r\n\r\n/**\r\n * ディレクトリ、ファイルの存在チェック\r\n * @param targetPaths\r\n * @param options\r\n */\r\nexport default function checkExistence(...targetPaths: string[]) {\r\n return targetPaths.every((targetPath) => {\r\n if (!fs.existsSync(targetPath)) {\r\n console.error(`${targetPath}が存在しません。`);\r\n return false;\r\n }\r\n return true;\r\n });\r\n}\r\n"],"mappings":";;;;;;;;AAOA,SAAwB,eAAe,GAAG,aAAuB;AAC/D,QAAO,YAAY,OAAO,eAAe;AACvC,MAAI,CAAC,GAAG,WAAW,WAAW,EAAE;AAC9B,WAAQ,MAAM,GAAG,WAAW,UAAU;AACtC,UAAO;;AAET,SAAO;GACP"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const require_isMatchingPath_isMatchingPath = require('../isMatchingPath/isMatchingPath.cjs');
|
|
2
|
+
require('../isMatchingPath/index.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/createExternalOptionFunction/createExternalOptionFunction.ts
|
|
5
|
+
/**
|
|
6
|
+
* rolldownやrollupなどで内部モジュールのimport以外をexternalとして扱うための関数を作る関数
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
function createExternalOptionFunction(options = {}) {
|
|
10
|
+
const { isExternal, isInternal } = options;
|
|
11
|
+
return (source, _importer, isResolved) => {
|
|
12
|
+
const isMatchingPathOptions = { conditionOptions: {
|
|
13
|
+
source,
|
|
14
|
+
importer: _importer,
|
|
15
|
+
isResolved
|
|
16
|
+
} };
|
|
17
|
+
if (require_isMatchingPath_isMatchingPath(source, isExternal, isMatchingPathOptions)) return true;
|
|
18
|
+
else if (require_isMatchingPath_isMatchingPath(source, isInternal, isMatchingPathOptions)) return;
|
|
19
|
+
else if (!isResolved) return !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("src/");
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
module.exports = createExternalOptionFunction;
|
|
25
|
+
//# sourceMappingURL=createExternalOptionFunction.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createExternalOptionFunction.cjs","names":["isMatchingPath"],"sources":["../../src/createExternalOptionFunction/createExternalOptionFunction.ts"],"sourcesContent":["import isMatchingPath from '../isMatchingPath';\r\nimport type {\r\n CreateExternalOptionFunctionOptions,\r\n ExternalOptionFunction,\r\n} from './types';\r\n\r\n/**\r\n * rolldownやrollupなどで内部モジュールのimport以外をexternalとして扱うための関数を作る関数\r\n * @param options\r\n */\r\nexport default function createExternalOptionFunction(\r\n options: CreateExternalOptionFunctionOptions = {},\r\n): ExternalOptionFunction {\r\n const { isExternal, isInternal } = options;\r\n return (\r\n source: string,\r\n _importer: string | undefined,\r\n isResolved: boolean,\r\n ) => {\r\n const isMatchingPathOptions = {\r\n conditionOptions: {\r\n source,\r\n importer: _importer,\r\n isResolved,\r\n },\r\n };\r\n if (isMatchingPath(source, isExternal, isMatchingPathOptions)) {\r\n // 外部モジュール扱い\r\n return true;\r\n } else if (isMatchingPath(source, isInternal, isMatchingPathOptions)) {\r\n // 内部モジュール扱い\r\n return;\r\n } else if (!isResolved) {\r\n // 相対パスでもなく、srcディレクトリ配下でもないものは外部モジュール扱い\r\n return (\r\n !source.startsWith('.') &&\r\n !source.startsWith('/') &&\r\n !source.startsWith('src/')\r\n );\r\n }\r\n return;\r\n };\r\n}\r\n"],"mappings":";;;;;;;;AAUA,SAAwB,6BACtB,UAA+C,EAAE,EACzB;CACxB,MAAM,EAAE,YAAY,eAAe;AACnC,SACE,QACA,WACA,eACG;EACH,MAAM,wBAAwB,EAC5B,kBAAkB;GAChB;GACA,UAAU;GACV;GACD,EACF;AACD,MAAIA,sCAAe,QAAQ,YAAY,sBAAsB,CAE3D,QAAO;WACEA,sCAAe,QAAQ,YAAY,sBAAsB,CAElE;WACS,CAAC,WAEV,QACE,CAAC,OAAO,WAAW,IAAI,IACvB,CAAC,OAAO,WAAW,IAAI,IACvB,CAAC,OAAO,WAAW,OAAO"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CreateExternalOptionFunctionOptions, ExternalOptionFunction } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/createExternalOptionFunction/createExternalOptionFunction.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* rolldownやrollupなどで内部モジュールのimport以外をexternalとして扱うための関数を作る関数
|
|
6
|
+
* @param options
|
|
7
|
+
*/
|
|
8
|
+
declare function createExternalOptionFunction(options?: CreateExternalOptionFunctionOptions): ExternalOptionFunction;
|
|
9
|
+
export = createExternalOptionFunction;
|
|
10
|
+
//# sourceMappingURL=createExternalOptionFunction.d.cts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CreateExternalOptionFunctionOptions, ExternalOptionFunction } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/createExternalOptionFunction/createExternalOptionFunction.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* rolldownやrollupなどで内部モジュールのimport以外をexternalとして扱うための関数を作る関数
|
|
6
|
+
* @param options
|
|
7
|
+
*/
|
|
8
|
+
declare function createExternalOptionFunction(options?: CreateExternalOptionFunctionOptions): ExternalOptionFunction;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createExternalOptionFunction as default };
|
|
11
|
+
//# sourceMappingURL=createExternalOptionFunction.d.mts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import isMatchingPath from "../isMatchingPath/isMatchingPath.mjs";
|
|
2
|
+
import "../isMatchingPath/index.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/createExternalOptionFunction/createExternalOptionFunction.ts
|
|
5
|
+
/**
|
|
6
|
+
* rolldownやrollupなどで内部モジュールのimport以外をexternalとして扱うための関数を作る関数
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
function createExternalOptionFunction(options = {}) {
|
|
10
|
+
const { isExternal, isInternal } = options;
|
|
11
|
+
return (source, _importer, isResolved) => {
|
|
12
|
+
const isMatchingPathOptions = { conditionOptions: {
|
|
13
|
+
source,
|
|
14
|
+
importer: _importer,
|
|
15
|
+
isResolved
|
|
16
|
+
} };
|
|
17
|
+
if (isMatchingPath(source, isExternal, isMatchingPathOptions)) return true;
|
|
18
|
+
else if (isMatchingPath(source, isInternal, isMatchingPathOptions)) return;
|
|
19
|
+
else if (!isResolved) return !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("src/");
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { createExternalOptionFunction as default };
|
|
25
|
+
//# sourceMappingURL=createExternalOptionFunction.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createExternalOptionFunction.mjs","names":[],"sources":["../../src/createExternalOptionFunction/createExternalOptionFunction.ts"],"sourcesContent":["import isMatchingPath from '../isMatchingPath';\r\nimport type {\r\n CreateExternalOptionFunctionOptions,\r\n ExternalOptionFunction,\r\n} from './types';\r\n\r\n/**\r\n * rolldownやrollupなどで内部モジュールのimport以外をexternalとして扱うための関数を作る関数\r\n * @param options\r\n */\r\nexport default function createExternalOptionFunction(\r\n options: CreateExternalOptionFunctionOptions = {},\r\n): ExternalOptionFunction {\r\n const { isExternal, isInternal } = options;\r\n return (\r\n source: string,\r\n _importer: string | undefined,\r\n isResolved: boolean,\r\n ) => {\r\n const isMatchingPathOptions = {\r\n conditionOptions: {\r\n source,\r\n importer: _importer,\r\n isResolved,\r\n },\r\n };\r\n if (isMatchingPath(source, isExternal, isMatchingPathOptions)) {\r\n // 外部モジュール扱い\r\n return true;\r\n } else if (isMatchingPath(source, isInternal, isMatchingPathOptions)) {\r\n // 内部モジュール扱い\r\n return;\r\n } else if (!isResolved) {\r\n // 相対パスでもなく、srcディレクトリ配下でもないものは外部モジュール扱い\r\n return (\r\n !source.startsWith('.') &&\r\n !source.startsWith('/') &&\r\n !source.startsWith('src/')\r\n );\r\n }\r\n return;\r\n };\r\n}\r\n"],"mappings":";;;;;;;;AAUA,SAAwB,6BACtB,UAA+C,EAAE,EACzB;CACxB,MAAM,EAAE,YAAY,eAAe;AACnC,SACE,QACA,WACA,eACG;EACH,MAAM,wBAAwB,EAC5B,kBAAkB;GAChB;GACA,UAAU;GACV;GACD,EACF;AACD,MAAI,eAAe,QAAQ,YAAY,sBAAsB,CAE3D,QAAO;WACE,eAAe,QAAQ,YAAY,sBAAsB,CAElE;WACS,CAAC,WAEV,QACE,CAAC,OAAO,WAAW,IAAI,IACvB,CAAC,OAAO,WAAW,IAAI,IACvB,CAAC,OAAO,WAAW,OAAO"}
|