npm-package-json-loader 2.0.6 → 2.0.7
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/CHANGELOG.md +23 -0
- package/index.d.ts +3 -3
- package/jest.config.js +115 -4
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.7](https://github.com/bluelovers/ws-yarn-workspaces/compare/npm-package-json-loader@2.0.6...npm-package-json-loader@2.0.7) (2022-08-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### 🚨 Tests
|
|
10
|
+
|
|
11
|
+
* update jest.config.js and deps ([d1d501b](https://github.com/bluelovers/ws-yarn-workspaces/commit/d1d501ba059130bd8f90e6eaa266084110698011))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### 🛠 Build System
|
|
15
|
+
|
|
16
|
+
* update typescript ([b69b593](https://github.com/bluelovers/ws-yarn-workspaces/commit/b69b593d511d9d4e246513dc1d69721150b9cfe8))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### 📌 Dependencies
|
|
20
|
+
|
|
21
|
+
* update deps ([58501f9](https://github.com/bluelovers/ws-yarn-workspaces/commit/58501f97494eb624779dffea7ac9d68e45e5e978))
|
|
22
|
+
* update deps ([c968045](https://github.com/bluelovers/ws-yarn-workspaces/commit/c96804598f63a5cd06507e3eaaa2e8b569b14b65))
|
|
23
|
+
* update deps ([a0b8755](https://github.com/bluelovers/ws-yarn-workspaces/commit/a0b875582efdc9829b0cdb6c9c819cace8b76e90))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
## [2.0.6](https://github.com/bluelovers/ws-yarn-workspaces/compare/npm-package-json-loader@2.0.5...npm-package-json-loader@2.0.6) (2022-07-31)
|
|
7
30
|
|
|
8
31
|
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IPackageJson } from '@ts-type/package-dts';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type IFileOrJson = Buffer | string | object | IPackageJson;
|
|
4
|
+
type IPackageJsonLike<T> = Partial<T> | Record<string, any>;
|
|
5
|
+
type IItemOrItemArray<T> = T | T[];
|
|
6
6
|
export declare class PackageJsonLoader<T extends IPackageJsonLike<IPackageJson> = IPackageJson> {
|
|
7
7
|
readonly file: string;
|
|
8
8
|
protected json: T;
|
package/jest.config.js
CHANGED
|
@@ -1,5 +1,116 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const { basename, extname, dirname } = require('path');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* // @type { import('@jest/types').Config.InitialOptions }
|
|
7
|
+
* @type { import('ts-jest').InitialOptionsTsJest }
|
|
8
|
+
*/
|
|
9
|
+
let jestConfig = {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} name
|
|
15
|
+
* @returns {string}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
function _requireResolve(name)
|
|
19
|
+
{
|
|
20
|
+
let result;
|
|
21
|
+
|
|
22
|
+
try
|
|
23
|
+
{
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const { requireResolveExtra, requireResolveCore } = require('@yarn-tool/require-resolve');
|
|
26
|
+
|
|
27
|
+
const paths = [
|
|
28
|
+
requireResolveExtra('@bluelovers/tsdx').result,
|
|
29
|
+
requireResolveExtra('tsdx').result,
|
|
30
|
+
].filter(Boolean);
|
|
31
|
+
|
|
32
|
+
result = requireResolveCore(name, {
|
|
33
|
+
includeGlobal: true,
|
|
34
|
+
includeCurrentDirectory: true,
|
|
35
|
+
paths,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
catch (e)
|
|
39
|
+
{
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
result = result || require.resolve(name);
|
|
44
|
+
|
|
45
|
+
console.info('[require.resolve]', name, '=>', result)
|
|
46
|
+
|
|
47
|
+
return result
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let _ok = true;
|
|
51
|
+
|
|
52
|
+
try
|
|
53
|
+
{
|
|
54
|
+
if (!jestConfig.preset)
|
|
55
|
+
{
|
|
56
|
+
|
|
57
|
+
let result = require('@yarn-tool/ws-find-up-paths').findUpPathsWorkspaces([
|
|
58
|
+
'jest-preset.js',
|
|
59
|
+
'jest.config.js',
|
|
60
|
+
], {
|
|
61
|
+
ignoreCurrentPackage: true,
|
|
62
|
+
onlyFiles: true,
|
|
63
|
+
}).result;
|
|
64
|
+
|
|
65
|
+
if (result)
|
|
66
|
+
{
|
|
67
|
+
let name = basename(result, extname(result))
|
|
68
|
+
|
|
69
|
+
switch (name)
|
|
70
|
+
{
|
|
71
|
+
case 'jest-preset':
|
|
72
|
+
jestConfig.preset = dirname(result);
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
jestConfig = {
|
|
76
|
+
...require(result),
|
|
77
|
+
jestConfig,
|
|
78
|
+
};
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_ok = false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e)
|
|
87
|
+
{
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
try
|
|
92
|
+
{
|
|
93
|
+
if (_ok && !jestConfig.preset)
|
|
94
|
+
{
|
|
95
|
+
let result = _requireResolve('@bluelovers/jest-config/package.json');
|
|
96
|
+
if (result)
|
|
97
|
+
{
|
|
98
|
+
jestConfig.preset = dirname(result);
|
|
99
|
+
_ok = false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (e)
|
|
104
|
+
{
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (_ok && !jestConfig.preset)
|
|
109
|
+
{
|
|
110
|
+
jestConfig.preset = '@bluelovers/jest-config';
|
|
111
|
+
_ok = false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.info(`jest.config.preset: ${jestConfig.preset}`);
|
|
115
|
+
|
|
116
|
+
module.exports = jestConfig
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-package-json-loader",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Find and load configuration from a package.json",
|
|
6
6
|
"keywords": [
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
"config": {},
|
|
45
45
|
"resolutions": {},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@bluelovers/fs-json": "^1.0.
|
|
48
|
-
"@ts-type/package-dts": "^2.0.
|
|
49
|
-
"@yarn-tool/pkg-entry-util": "^2.0.
|
|
50
|
-
"@yarn-tool/resolve-package": "^2.0.
|
|
47
|
+
"@bluelovers/fs-json": "^1.0.9",
|
|
48
|
+
"@ts-type/package-dts": "^2.0.5",
|
|
49
|
+
"@yarn-tool/pkg-entry-util": "^2.0.7",
|
|
50
|
+
"@yarn-tool/resolve-package": "^2.0.1",
|
|
51
51
|
"bind-decorator": "^1.0.11",
|
|
52
52
|
"fs-extra": "^10.1.0",
|
|
53
53
|
"sort-package-json": "^1.57.0",
|
|
54
|
-
"sort-package-json3": "^2.0.
|
|
55
|
-
"ts-type": "^2.1.
|
|
54
|
+
"sort-package-json3": "^2.0.2",
|
|
55
|
+
"ts-type": "^2.1.10",
|
|
56
56
|
"tslib": "^2"
|
|
57
57
|
},
|
|
58
58
|
"bundleDependencies": [],
|
|
59
59
|
"preferGlobal": true,
|
|
60
60
|
"publishConfig": {},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "e34c95f09bf1ad26e3a721028a28f6b8bfb44510",
|
|
62
62
|
"licenses": []
|
|
63
63
|
}
|