npm-package-json-loader 2.0.5 → 2.0.8

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 CHANGED
@@ -3,6 +3,48 @@
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.8](https://github.com/bluelovers/ws-yarn-workspaces/compare/npm-package-json-loader@2.0.7...npm-package-json-loader@2.0.8) (2022-08-13)
7
+
8
+ **Note:** Version bump only for package npm-package-json-loader
9
+
10
+
11
+
12
+
13
+
14
+ ## [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)
15
+
16
+
17
+ ### 🚨 Tests
18
+
19
+ * update jest.config.js and deps ([d1d501b](https://github.com/bluelovers/ws-yarn-workspaces/commit/d1d501ba059130bd8f90e6eaa266084110698011))
20
+
21
+
22
+ ### 🛠 Build System
23
+
24
+ * update typescript ([b69b593](https://github.com/bluelovers/ws-yarn-workspaces/commit/b69b593d511d9d4e246513dc1d69721150b9cfe8))
25
+
26
+
27
+ ### 📌 Dependencies
28
+
29
+ * update deps ([58501f9](https://github.com/bluelovers/ws-yarn-workspaces/commit/58501f97494eb624779dffea7ac9d68e45e5e978))
30
+ * update deps ([c968045](https://github.com/bluelovers/ws-yarn-workspaces/commit/c96804598f63a5cd06507e3eaaa2e8b569b14b65))
31
+ * update deps ([a0b8755](https://github.com/bluelovers/ws-yarn-workspaces/commit/a0b875582efdc9829b0cdb6c9c819cace8b76e90))
32
+
33
+
34
+
35
+
36
+
37
+ ## [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)
38
+
39
+
40
+ ### 🚨 Tests
41
+
42
+ * **preset:** use `@bluelovers/jest-config` ([e239ecf](https://github.com/bluelovers/ws-yarn-workspaces/commit/e239ecf606d82930c6036ec1241bf3b4a1095423))
43
+
44
+
45
+
46
+
47
+
6
48
  ## [2.0.5](https://github.com/bluelovers/ws-yarn-workspaces/compare/npm-package-json-loader@2.0.4...npm-package-json-loader@2.0.5) (2022-07-29)
7
49
 
8
50
  **Note:** Version bump only for package npm-package-json-loader
package/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import { IPackageJson } from '@ts-type/package-dts';
3
- declare type IFileOrJson = Buffer | string | object | IPackageJson;
4
- declare type IPackageJsonLike<T> = Partial<T> | Record<string, any>;
5
- declare type IItemOrItemArray<T> = T | T[];
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,12 +1,116 @@
1
- module.exports = {
2
- clearMocks: true,
3
- moduleFileExtensions: ['ts', 'js'],
4
- testEnvironment: 'node',
5
- //testMatch: ['**/*.test.ts', '**/*.spec.ts'],
6
- testRegex: ['\\.(test|spec)\\.(ts|tsx)$'],
7
- //testRunner: 'jest-circus/runner',
8
- transform: {
9
- '^.+\\.ts$': 'ts-jest',
10
- },
11
- verbose: true,
1
+ // @ts-check
2
+
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
+
12
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.5",
3
+ "version": "2.0.8",
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.7",
48
- "@ts-type/package-dts": "^2.0.2",
49
- "@yarn-tool/pkg-entry-util": "^2.0.5",
50
- "@yarn-tool/resolve-package": "^2.0.0",
47
+ "@bluelovers/fs-json": "^1.0.9",
48
+ "@ts-type/package-dts": "^2.0.5",
49
+ "@yarn-tool/pkg-entry-util": "^2.0.8",
50
+ "@yarn-tool/resolve-package": "^2.0.2",
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.0",
55
- "ts-type": "^2.1.8",
54
+ "sort-package-json3": "^2.0.3",
55
+ "ts-type": "^2.1.10",
56
56
  "tslib": "^2"
57
57
  },
58
58
  "bundleDependencies": [],
59
59
  "preferGlobal": true,
60
60
  "publishConfig": {},
61
- "gitHead": "8deef4eaac947ec4f4c76660380bf70e285f51bd",
61
+ "gitHead": "1e294e0d844e53ead65f2cd9a501229de44d4bb5",
62
62
  "licenses": []
63
63
  }