@niche-works/dev 0.2.0 → 0.4.1
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/package.json +30 -23
- package/src/addExports/addExports.ts +94 -0
- package/src/addExports/index.ts +2 -0
- package/src/addExports/types.ts +33 -0
- package/src/addJsExtensions/addJsExtensions.ts +30 -0
- package/src/addJsExtensions/index.ts +1 -0
- package/src/checkExistence/checkExistence.ts +16 -0
- package/src/checkExistence/index.ts +1 -0
- package/src/createExternalOptionFunction/createExternalOptionFunction.ts +43 -0
- package/src/createExternalOptionFunction/index.ts +1 -0
- package/src/createExternalOptionFunction/types.ts +34 -0
- package/src/editJsonFile/editJsonFile.ts +30 -0
- package/src/editJsonFile/index.ts +1 -0
- package/src/generatePublishPackageJson/generatePublishPackageJson.ts +55 -0
- package/src/generatePublishPackageJson/index.ts +2 -0
- package/src/generatePublishPackageJson/types.ts +61 -0
- package/src/index.ts +11 -0
- package/src/indexes/constants.ts +135 -0
- package/src/indexes/index.ts +2 -0
- package/src/indexes/indexes.ts +194 -0
- package/src/indexes/types.ts +87 -0
- package/src/installFromLocal/index.ts +2 -0
- package/{installFromLocal/installFromLocal.js → src/installFromLocal/installFromLocal.ts} +63 -48
- package/src/installFromLocal/types.ts +19 -0
- package/src/isMatchingPath/index.ts +2 -0
- package/src/isMatchingPath/isMatchingPath.ts +94 -0
- package/src/isMatchingPath/types.ts +95 -0
- package/src/isTargetPath/index.ts +2 -0
- package/src/isTargetPath/isTargetPath.ts +30 -0
- package/src/isTargetPath/types.ts +38 -0
- package/src/moveFilesToSubdir/index.ts +2 -0
- package/src/moveFilesToSubdir/moveFilesToSubdir.ts +40 -0
- package/src/moveFilesToSubdir/types.ts +15 -0
- package/src/removeFiles/index.ts +1 -0
- package/src/removeFiles/removeFiles.ts +11 -0
- package/src/removeFiles/types.ts +5 -0
- package/src/ver/index.ts +2 -0
- package/src/ver/types.ts +13 -0
- package/src/ver/ver.ts +38 -0
- package/tsconfig.json +46 -0
- package/tsdown.config.ts +41 -0
- package/addExports/addExports.cjs +0 -71
- package/addExports/addExports.cjs.map +0 -1
- package/addExports/addExports.d.cts +0 -13
- package/addExports/addExports.d.ts +0 -13
- package/addExports/addExports.js +0 -71
- package/addExports/addExports.js.map +0 -1
- package/addExports/index.cjs +0 -5
- package/addExports/index.cjs.map +0 -1
- package/addExports/index.d.cts +0 -5
- package/addExports/index.d.ts +0 -5
- package/addExports/index.js +0 -5
- package/addExports/index.js.map +0 -1
- package/addExports/types.cjs +0 -1
- package/addExports/types.cjs.map +0 -1
- package/addExports/types.d.cts +0 -33
- package/addExports/types.d.ts +0 -33
- package/addExports/types.js +0 -1
- package/addExports/types.js.map +0 -1
- package/checkExistence/checkExistence.cjs +0 -15
- package/checkExistence/checkExistence.cjs.map +0 -1
- package/checkExistence/checkExistence.d.cts +0 -8
- package/checkExistence/checkExistence.d.ts +0 -8
- package/checkExistence/checkExistence.js +0 -15
- package/checkExistence/checkExistence.js.map +0 -1
- package/checkExistence/index.cjs +0 -5
- package/checkExistence/index.cjs.map +0 -1
- package/checkExistence/index.d.cts +0 -1
- package/checkExistence/index.d.ts +0 -1
- package/checkExistence/index.js +0 -5
- package/checkExistence/index.js.map +0 -1
- package/editJsonFile/editJsonFile.cjs +0 -22
- package/editJsonFile/editJsonFile.cjs.map +0 -1
- package/editJsonFile/editJsonFile.d.cts +0 -8
- package/editJsonFile/editJsonFile.d.ts +0 -8
- package/editJsonFile/editJsonFile.js +0 -22
- package/editJsonFile/editJsonFile.js.map +0 -1
- package/editJsonFile/index.cjs +0 -5
- package/editJsonFile/index.cjs.map +0 -1
- package/editJsonFile/index.d.cts +0 -1
- package/editJsonFile/index.d.ts +0 -1
- package/editJsonFile/index.js +0 -5
- package/editJsonFile/index.js.map +0 -1
- package/generatePublishPackageJson/generatePublishPackageJson.cjs +0 -54
- package/generatePublishPackageJson/generatePublishPackageJson.cjs.map +0 -1
- package/generatePublishPackageJson/generatePublishPackageJson.d.cts +0 -7
- package/generatePublishPackageJson/generatePublishPackageJson.d.ts +0 -7
- package/generatePublishPackageJson/generatePublishPackageJson.js +0 -54
- package/generatePublishPackageJson/generatePublishPackageJson.js.map +0 -1
- package/generatePublishPackageJson/index.cjs +0 -5
- package/generatePublishPackageJson/index.cjs.map +0 -1
- package/generatePublishPackageJson/index.d.cts +0 -4
- package/generatePublishPackageJson/index.d.ts +0 -4
- package/generatePublishPackageJson/index.js +0 -5
- package/generatePublishPackageJson/index.js.map +0 -1
- package/generatePublishPackageJson/types.cjs +0 -1
- package/generatePublishPackageJson/types.cjs.map +0 -1
- package/generatePublishPackageJson/types.d.cts +0 -58
- package/generatePublishPackageJson/types.d.ts +0 -58
- package/generatePublishPackageJson/types.js +0 -1
- package/generatePublishPackageJson/types.js.map +0 -1
- package/index.cjs +0 -21
- package/index.cjs.map +0 -1
- package/index.d.cts +0 -19
- package/index.d.ts +0 -19
- package/index.js +0 -21
- package/index.js.map +0 -1
- package/indexes/constants.cjs +0 -91
- package/indexes/constants.cjs.map +0 -1
- package/indexes/constants.d.cts +0 -66
- package/indexes/constants.d.ts +0 -66
- package/indexes/constants.js +0 -91
- package/indexes/constants.js.map +0 -1
- package/indexes/index.cjs +0 -5
- package/indexes/index.cjs.map +0 -1
- package/indexes/index.d.cts +0 -5
- package/indexes/index.d.ts +0 -5
- package/indexes/index.js +0 -5
- package/indexes/index.js.map +0 -1
- package/indexes/indexes.cjs +0 -161
- package/indexes/indexes.cjs.map +0 -1
- package/indexes/indexes.d.cts +0 -13
- package/indexes/indexes.d.ts +0 -13
- package/indexes/indexes.js +0 -161
- package/indexes/indexes.js.map +0 -1
- package/indexes/types.cjs +0 -1
- package/indexes/types.cjs.map +0 -1
- package/indexes/types.d.cts +0 -81
- package/indexes/types.d.ts +0 -81
- package/indexes/types.js +0 -1
- package/indexes/types.js.map +0 -1
- package/installFromLocal/index.cjs +0 -5
- package/installFromLocal/index.cjs.map +0 -1
- package/installFromLocal/index.d.cts +0 -2
- package/installFromLocal/index.d.ts +0 -2
- package/installFromLocal/index.js +0 -5
- package/installFromLocal/index.js.map +0 -1
- package/installFromLocal/installFromLocal.cjs +0 -48
- package/installFromLocal/installFromLocal.cjs.map +0 -1
- package/installFromLocal/installFromLocal.d.cts +0 -10
- package/installFromLocal/installFromLocal.d.ts +0 -10
- package/installFromLocal/installFromLocal.js.map +0 -1
- package/installFromLocal/types.cjs +0 -1
- package/installFromLocal/types.cjs.map +0 -1
- package/installFromLocal/types.d.cts +0 -19
- package/installFromLocal/types.d.ts +0 -19
- package/installFromLocal/types.js +0 -1
- package/installFromLocal/types.js.map +0 -1
- package/isMatchingPath/_types.cjs +0 -1
- package/isMatchingPath/_types.cjs.map +0 -1
- package/isMatchingPath/_types.d.cts +0 -52
- package/isMatchingPath/_types.d.ts +0 -52
- package/isMatchingPath/_types.js +0 -1
- package/isMatchingPath/_types.js.map +0 -1
- package/isMatchingPath/index.cjs +0 -5
- package/isMatchingPath/index.cjs.map +0 -1
- package/isMatchingPath/index.d.cts +0 -4
- package/isMatchingPath/index.d.ts +0 -4
- package/isMatchingPath/index.js +0 -5
- package/isMatchingPath/index.js.map +0 -1
- package/isMatchingPath/isMatchingPath.cjs +0 -57
- package/isMatchingPath/isMatchingPath.cjs.map +0 -1
- package/isMatchingPath/isMatchingPath.d.cts +0 -14
- package/isMatchingPath/isMatchingPath.d.ts +0 -14
- package/isMatchingPath/isMatchingPath.js +0 -57
- package/isMatchingPath/isMatchingPath.js.map +0 -1
- package/isMatchingPath/types.cjs +0 -1
- package/isMatchingPath/types.cjs.map +0 -1
- package/isMatchingPath/types.d.cts +0 -19
- package/isMatchingPath/types.d.ts +0 -19
- package/isMatchingPath/types.js +0 -1
- package/isMatchingPath/types.js.map +0 -1
- package/moveFilesToSubdir/index.cjs +0 -5
- package/moveFilesToSubdir/index.cjs.map +0 -1
- package/moveFilesToSubdir/index.d.cts +0 -1
- package/moveFilesToSubdir/index.d.ts +0 -1
- package/moveFilesToSubdir/index.js +0 -5
- package/moveFilesToSubdir/index.js.map +0 -1
- package/moveFilesToSubdir/moveFilesToSubdir.cjs +0 -19
- package/moveFilesToSubdir/moveFilesToSubdir.cjs.map +0 -1
- package/moveFilesToSubdir/moveFilesToSubdir.d.cts +0 -7
- package/moveFilesToSubdir/moveFilesToSubdir.d.ts +0 -7
- package/moveFilesToSubdir/moveFilesToSubdir.js +0 -19
- package/moveFilesToSubdir/moveFilesToSubdir.js.map +0 -1
- package/ver/index.cjs +0 -5
- package/ver/index.cjs.map +0 -1
- package/ver/index.d.cts +0 -2
- package/ver/index.d.ts +0 -2
- package/ver/index.js +0 -5
- package/ver/index.js.map +0 -1
- package/ver/types.cjs +0 -1
- package/ver/types.cjs.map +0 -1
- package/ver/types.d.cts +0 -14
- package/ver/types.d.ts +0 -14
- package/ver/types.js +0 -1
- package/ver/types.js.map +0 -1
- package/ver/ver.cjs +0 -31
- package/ver/ver.cjs.map +0 -1
- package/ver/ver.d.cts +0 -10
- package/ver/ver.d.ts +0 -10
- package/ver/ver.js +0 -31
- package/ver/ver.js.map +0 -1
package/indexes/types.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { IsMatchingPathCondition } from '../isMatchingPath/types.js';
|
|
2
|
-
import '../isMatchingPath/_types.js';
|
|
3
|
-
import 'path';
|
|
4
|
-
|
|
5
|
-
type IndexesOptions = {
|
|
6
|
-
/**
|
|
7
|
-
* 処理対象のパス\
|
|
8
|
-
* @default `src`
|
|
9
|
-
*/
|
|
10
|
-
srcPath?: string;
|
|
11
|
-
/**
|
|
12
|
-
* indexのファイル名\
|
|
13
|
-
* @default `index.ts`
|
|
14
|
-
*/
|
|
15
|
-
indexFileName?: string;
|
|
16
|
-
/**
|
|
17
|
-
* indexファイルを作る対象\
|
|
18
|
-
* 未指定の場合は下記の条件がデフォルトで適用される
|
|
19
|
-
*
|
|
20
|
-
* - ファイル名が`_`で始まらず拡張子が`.ts`,`.tsx`,`.js`,`.jsx`のもの
|
|
21
|
-
* - ディレクトリ名が`_`で始まらないもの
|
|
22
|
-
*/
|
|
23
|
-
include?: IsMatchingPathCondition[];
|
|
24
|
-
/**
|
|
25
|
-
* indexファイルを作る対象から除外するもの
|
|
26
|
-
*/
|
|
27
|
-
exclude?: IsMatchingPathCondition[];
|
|
28
|
-
/**
|
|
29
|
-
* 同じindexファイル内にデフォルトエクスポートがある場合でも名前付きエクスポートをする\
|
|
30
|
-
* デフォルトエクスポートしたモジュールをcjsへ変換したものへアクセスする際に、\
|
|
31
|
-
* defaultという名前付きでアクセスしても問題ない場合はtrue
|
|
32
|
-
*/
|
|
33
|
-
includeNamedWithDefault?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* exportの形式を下記にしたいもの
|
|
36
|
-
*
|
|
37
|
-
* ```
|
|
38
|
-
* export * from './abc';
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
exportAll?: IsMatchingPathCondition[];
|
|
42
|
-
/**
|
|
43
|
-
* exportの形式を下記にしたいもの
|
|
44
|
-
*
|
|
45
|
-
* ```
|
|
46
|
-
* export * as abc from './abc';
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
exportAllAs?: IsMatchingPathCondition[];
|
|
50
|
-
/**
|
|
51
|
-
* exportの形式を下記にしたいもの
|
|
52
|
-
*
|
|
53
|
-
* ```
|
|
54
|
-
* export { default } from './abc';
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
exportDefault?: IsMatchingPathCondition[];
|
|
58
|
-
/**
|
|
59
|
-
* exportの形式を下記にしたいもの
|
|
60
|
-
*
|
|
61
|
-
* ```
|
|
62
|
-
* export { default as abc } from './abc';
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
exportDefaultAs?: IsMatchingPathCondition[];
|
|
66
|
-
/**
|
|
67
|
-
* exportの形式を下記にしたいもの
|
|
68
|
-
*
|
|
69
|
-
* ```
|
|
70
|
-
* export type * from './abc';
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
exportTypeAll?: IsMatchingPathCondition[];
|
|
74
|
-
/**
|
|
75
|
-
* お試し\
|
|
76
|
-
* ファイルの操作は行わない
|
|
77
|
-
*/
|
|
78
|
-
dryRun?: boolean;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export type { IndexesOptions };
|
package/indexes/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
package/indexes/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _installFromLocal = require('./installFromLocal'); var _installFromLocal2 = _interopRequireDefault(_installFromLocal);
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.default = _installFromLocal2.default;
|
|
5
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\installFromLocal\\index.cjs"],"names":[],"mappings":"AAAA,mSAAwD;AACxD;AACE;AACF,6CAAC","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\installFromLocal\\index.cjs","sourcesContent":[null]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/installFromLocal/index.ts"],"sourcesContent":["export { default } from './installFromLocal';\r\nexport type * from './types';\r\n"],"mappings":"AAAA,SAAS,WAAAA,gBAAe;","names":["default"]}
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
var _remeda = require('remeda');
|
|
4
|
-
var _checkExistence = require('../checkExistence'); var _checkExistence2 = _interopRequireDefault(_checkExistence);
|
|
5
|
-
function installFromLocal(localNodeModulesPath, options = {}) {
|
|
6
|
-
const {
|
|
7
|
-
packageJsonPath = "./package.json",
|
|
8
|
-
nodeModulesPath = "./node_modules",
|
|
9
|
-
dryRun
|
|
10
|
-
} = options;
|
|
11
|
-
const resolvedLocalNodeModulesPath = _path2.default.resolve(localNodeModulesPath);
|
|
12
|
-
const resolvedPackageJsonPath = _path2.default.resolve(packageJsonPath);
|
|
13
|
-
if (!_checkExistence2.default.call(void 0, resolvedLocalNodeModulesPath, resolvedPackageJsonPath)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
console.info(`${localNodeModulesPath} -> ${nodeModulesPath}`);
|
|
17
|
-
const packageJson = _fsextra2.default.readJSONSync(resolvedPackageJsonPath);
|
|
18
|
-
const localPackages = _remeda.reduce.call(void 0,
|
|
19
|
-
{ ...packageJson.dependencies, ...packageJson.devDependencies },
|
|
20
|
-
(result, value, key) => {
|
|
21
|
-
if (value.startsWith(localNodeModulesPath)) {
|
|
22
|
-
result[key] = value;
|
|
23
|
-
} else if (value.startsWith(`file:${localNodeModulesPath}`)) {
|
|
24
|
-
result[key] = value.substring(5);
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
},
|
|
28
|
-
{}
|
|
29
|
-
);
|
|
30
|
-
for (const packageName in localPackages) {
|
|
31
|
-
const localPackagePath = _path2.default.resolve(localPackages[packageName]);
|
|
32
|
-
if (_fsextra2.default.existsSync(localPackagePath)) {
|
|
33
|
-
const installedPackagePath = _path2.default.resolve(nodeModulesPath, packageName);
|
|
34
|
-
if (!dryRun) {
|
|
35
|
-
if (_fsextra2.default.existsSync(installedPackagePath)) {
|
|
36
|
-
_fsextra2.default.removeSync(installedPackagePath);
|
|
37
|
-
}
|
|
38
|
-
_fsextra2.default.copySync(localPackagePath, installedPackagePath);
|
|
39
|
-
}
|
|
40
|
-
console.info(`${packageName} is being copied...`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
var installFromLocal_default = installFromLocal;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
exports.default = installFromLocal_default;
|
|
48
|
-
//# sourceMappingURL=installFromLocal.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\installFromLocal\\installFromLocal.cjs"],"names":[],"mappings":"AAAA,8PAAyB;AACzB,wEAAuB;AACvB,gCAA+B;AAC/B,mHAA8C;AAC9C,SAAS,gBAAgB,CAAC,oBAAoB,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;AAC9D,EAAE,MAAM;AACR,IAAI,gBAAgB,EAAE,gBAAgB;AACtC,IAAI,gBAAgB,EAAE,gBAAgB;AACtC,IAAI;AACJ,EAAE,EAAE,EAAE,OAAO;AACb,EAAE,MAAM,6BAA6B,EAAE,cAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;AACzE,EAAE,MAAM,wBAAwB,EAAE,cAAI,CAAC,OAAO,CAAC,eAAe,CAAC;AAC/D,EAAE,GAAG,CAAC,CAAC,sCAAc,4BAA6B,EAAE,uBAAuB,CAAC,EAAE;AAC9E,IAAI,MAAM;AACV,EAAE;AACF,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,UAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\installFromLocal\\installFromLocal.cjs","sourcesContent":[null]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { InstallFromLocalOptions } from './types.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ローカルに配置されたパッケージを差し替える
|
|
5
|
-
* @param localNodeModulesPath ローカルのnode_modulesディレクトリのパス
|
|
6
|
-
* @param options オプション
|
|
7
|
-
*/
|
|
8
|
-
declare function installFromLocal(localNodeModulesPath: string, options?: InstallFromLocalOptions): void;
|
|
9
|
-
|
|
10
|
-
export { installFromLocal as default };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { InstallFromLocalOptions } from './types.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ローカルに配置されたパッケージを差し替える
|
|
5
|
-
* @param localNodeModulesPath ローカルのnode_modulesディレクトリのパス
|
|
6
|
-
* @param options オプション
|
|
7
|
-
*/
|
|
8
|
-
declare function installFromLocal(localNodeModulesPath: string, options?: InstallFromLocalOptions): void;
|
|
9
|
-
|
|
10
|
-
export { installFromLocal as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/installFromLocal/installFromLocal.ts"],"sourcesContent":["import fs from 'fs-extra';\r\nimport path from 'path';\r\nimport { reduce } from 'remeda';\r\nimport checkExistence from '../checkExistence';\r\nimport type { InstallFromLocalOptions } from './types';\r\n\r\n/**\r\n * ローカルに配置されたパッケージを差し替える\r\n * @param localNodeModulesPath ローカルのnode_modulesディレクトリのパス\r\n * @param options オプション\r\n */\r\nfunction installFromLocal(\r\n localNodeModulesPath: string,\r\n options: InstallFromLocalOptions = {},\r\n) {\r\n const {\r\n packageJsonPath = './package.json',\r\n nodeModulesPath = './node_modules',\r\n dryRun,\r\n } = options;\r\n const resolvedLocalNodeModulesPath = path.resolve(localNodeModulesPath);\r\n const resolvedPackageJsonPath = path.resolve(packageJsonPath);\r\n\r\n if (!checkExistence(resolvedLocalNodeModulesPath, resolvedPackageJsonPath)) {\r\n return;\r\n }\r\n\r\n console.info(`${localNodeModulesPath} -> ${nodeModulesPath}`);\r\n\r\n // package.jsonからローカルのnode_modulesにあるパッケージを取得\r\n const packageJson = fs.readJSONSync(resolvedPackageJsonPath);\r\n const localPackages = reduce(\r\n { ...packageJson.dependencies, ...packageJson.devDependencies },\r\n (result: Record<string, string>, value: string, key) => {\r\n if (value.startsWith(localNodeModulesPath)) {\r\n result[key] = value;\r\n } else if (value.startsWith(`file:${localNodeModulesPath}`)) {\r\n result[key] = value.substring(5);\r\n }\r\n return result;\r\n },\r\n {},\r\n );\r\n\r\n for (const packageName in localPackages) {\r\n // ローカルパッケージの確認\r\n const localPackagePath = path.resolve(localPackages[packageName]);\r\n if (fs.existsSync(localPackagePath)) {\r\n // ローカルパッケージがある場合のみ処理\r\n const installedPackagePath = path.resolve(nodeModulesPath, packageName);\r\n if (!dryRun) {\r\n // コピーを行う\r\n if (fs.existsSync(installedPackagePath)) {\r\n // 古いパッケージは削除\r\n fs.removeSync(installedPackagePath);\r\n }\r\n // パッケージをコピー\r\n fs.copySync(localPackagePath, installedPackagePath);\r\n }\r\n console.info(`${packageName} is being copied...`);\r\n }\r\n }\r\n}\r\n\r\nexport default installFromLocal;\r\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,OAAO,oBAAoB;AAQ3B,SAAS,iBACP,sBACA,UAAmC,CAAC,GACpC;AACA,QAAM;AAAA,IACJ,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB;AAAA,EACF,IAAI;AACJ,QAAM,+BAA+B,KAAK,QAAQ,oBAAoB;AACtE,QAAM,0BAA0B,KAAK,QAAQ,eAAe;AAE5D,MAAI,CAAC,eAAe,8BAA8B,uBAAuB,GAAG;AAC1E;AAAA,EACF;AAEA,UAAQ,KAAK,GAAG,oBAAoB,OAAO,eAAe,EAAE;AAG5D,QAAM,cAAc,GAAG,aAAa,uBAAuB;AAC3D,QAAM,gBAAgB;AAAA,IACpB,EAAE,GAAG,YAAY,cAAc,GAAG,YAAY,gBAAgB;AAAA,IAC9D,CAAC,QAAgC,OAAe,QAAQ;AACtD,UAAI,MAAM,WAAW,oBAAoB,GAAG;AAC1C,eAAO,GAAG,IAAI;AAAA,MAChB,WAAW,MAAM,WAAW,QAAQ,oBAAoB,EAAE,GAAG;AAC3D,eAAO,GAAG,IAAI,MAAM,UAAU,CAAC;AAAA,MACjC;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AAEA,aAAW,eAAe,eAAe;AAEvC,UAAM,mBAAmB,KAAK,QAAQ,cAAc,WAAW,CAAC;AAChE,QAAI,GAAG,WAAW,gBAAgB,GAAG;AAEnC,YAAM,uBAAuB,KAAK,QAAQ,iBAAiB,WAAW;AACtE,UAAI,CAAC,QAAQ;AAEX,YAAI,GAAG,WAAW,oBAAoB,GAAG;AAEvC,aAAG,WAAW,oBAAoB;AAAA,QACpC;AAEA,WAAG,SAAS,kBAAkB,oBAAoB;AAAA,MACpD;AACA,cAAQ,KAAK,GAAG,WAAW,qBAAqB;AAAA,IAClD;AAAA,EACF;AACF;AAEA,IAAO,2BAAQ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";//# sourceMappingURL=types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\installFromLocal\\types.cjs"],"names":[],"mappings":"AAAA","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\installFromLocal\\types.cjs"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
type InstallFromLocalOptions = {
|
|
2
|
-
/**
|
|
3
|
-
* package.jsonのパス
|
|
4
|
-
* @default './package.json'
|
|
5
|
-
*/
|
|
6
|
-
packageJsonPath?: string;
|
|
7
|
-
/**
|
|
8
|
-
* node_modulesのパス
|
|
9
|
-
* @default './node_modules'
|
|
10
|
-
*/
|
|
11
|
-
nodeModulesPath?: string;
|
|
12
|
-
/**
|
|
13
|
-
* お試し
|
|
14
|
-
* ファイルの操作は行わない
|
|
15
|
-
*/
|
|
16
|
-
dryRun?: boolean;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type { InstallFromLocalOptions };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
type InstallFromLocalOptions = {
|
|
2
|
-
/**
|
|
3
|
-
* package.jsonのパス
|
|
4
|
-
* @default './package.json'
|
|
5
|
-
*/
|
|
6
|
-
packageJsonPath?: string;
|
|
7
|
-
/**
|
|
8
|
-
* node_modulesのパス
|
|
9
|
-
* @default './node_modules'
|
|
10
|
-
*/
|
|
11
|
-
nodeModulesPath?: string;
|
|
12
|
-
/**
|
|
13
|
-
* お試し
|
|
14
|
-
* ファイルの操作は行わない
|
|
15
|
-
*/
|
|
16
|
-
dryRun?: boolean;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type { InstallFromLocalOptions };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";//# sourceMappingURL=_types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,52 +0,0 @@
|
|
|
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 };
|
|
@@ -1,52 +0,0 @@
|
|
|
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 };
|
package/isMatchingPath/_types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=_types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/isMatchingPath/index.cjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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]}
|
package/isMatchingPath/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["c:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\isMatchingPath\\isMatchingPath.cjs"],"names":[],"mappings":"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","file":"C:\\Users\\mitsu\\Documents\\git\\@niche-works\\packages\\dev\\dist\\isMatchingPath\\isMatchingPath.cjs","sourcesContent":[null]}
|
|
@@ -1,14 +0,0 @@
|
|
|
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[] | null | undefined, options?: IsMatchingPathOptions): boolean;
|
|
13
|
-
|
|
14
|
-
export { isMatchingPath as default };
|
|
@@ -1,14 +0,0 @@
|
|
|
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[] | null | undefined, options?: IsMatchingPathOptions): boolean;
|
|
13
|
-
|
|
14
|
-
export { isMatchingPath as default };
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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:\r\n | IsMatchingPathCondition\r\n | IsMatchingPathCondition[]\r\n | null\r\n | undefined,\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,YAKA,UAAiC,CAAC,GAClC;AACA,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AACA,QAAM,gBAAgB,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,UAAU;AAE1E,QAAM,YAAY,KAAK,UAAU,UAAU;AAC3C,QAAM,aAAa,KAAK,MAAM,SAAS;AACvC,QAAM,YAAY,KAAK,MAAM,WAAW,GAAG;AAC3C,QAAM,SAAS;AAAA,IACb,MAAM;AAAA,IACN,GAAG;AAAA,IACH,SAAS,WAAW;AAAA,IACpB,SAAS,UAAU;AAAA,IACnB,SAAS,UAAU;AAAA,IACnB,QAAQ,UAAU;AAAA,EACpB;AACA,SAAO,OAAO;AAEd,aAAW,aAAa,eAAe;AACrC,QAAI,YAAY,OAAO,MAAM,QAAQ,WAAW,OAAO,GAAG;AAExD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,YACP,OACA,QACA,WACA,SACS;AACT,MAAI,SAAS,SAAS,GAAG;AAEvB,QAAI,MAAM,SAAS,SAAS,GAAG;AAC7B,aAAO;AAAA,IACT;AAAA,EACF,WAAW,qBAAqB,QAAQ;AAEtC,QAAI,UAAU,KAAK,KAAK,GAAG;AACzB,aAAO;AAAA,IACT;AAAA,EACF,WAAW,WAAW,SAAS,GAAG;AAEhC,WAAO,UAAU,QAAQ,QAAQ,oBAAoB,CAAC,CAAC;AAAA,EACzD,OAAO;AAEL,UAAM,EAAE,YAAY,QAAQ,YAAY,QAAQ,WAAW,IAAI;AAC/D,QAAI,cAAc,QAAQ;AACxB,YAAM,OAAO,GAAG,SAAS,OAAO,IAAI;AACpC,UACG,KAAK,YAAY,KAAK,cAAc,SACpC,KAAK,OAAO,KAAK,cAAc,QAChC;AACA,eAAO;AAAA,MACT;AAAA,IACF;AACA,UAAM,gBAAgB,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,UAAU;AAE1E,WAAO,cAAc;AAAA,MAAM,CAAC,SAC1B,YAAY,OAAO,SAAS,GAAG,QAAQ,MAAM,OAAO;AAAA,IACtD;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/isMatchingPath/types.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";//# sourceMappingURL=types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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 };
|
|
@@ -1,19 +0,0 @@
|
|
|
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 };
|
package/isMatchingPath/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,5 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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]}
|