@react-analyzer/shared 0.0.3-next.3 → 0.0.3-next.5
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/dist/index.d.ts +16 -10
- package/dist/index.js +60 -34
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
//#region src/_id.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* @internal
|
|
3
4
|
*/
|
|
4
5
|
declare const getId: () => string;
|
|
5
|
-
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/_require.d.ts
|
|
6
8
|
/**
|
|
7
9
|
* @internal
|
|
8
10
|
*/
|
|
9
11
|
declare const _require: NodeJS.Require;
|
|
10
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/constants.d.ts
|
|
11
14
|
/**
|
|
12
15
|
* The NPM scope for this project.
|
|
13
16
|
*/
|
|
@@ -20,19 +23,22 @@ declare const GITHUB_URL = "https://github.com/react-analyzer/react-analyzer";
|
|
|
20
23
|
* The URL to the project's website.
|
|
21
24
|
*/
|
|
22
25
|
declare const WEBSITE_URL = "https://react-analyzer.xyz";
|
|
23
|
-
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/get-analyzer-options.d.ts
|
|
24
28
|
interface AnalyzerOptions {
|
|
25
|
-
|
|
29
|
+
version: string;
|
|
26
30
|
}
|
|
27
31
|
declare const DEFAULT_ANALYZER_OPTIONS: {
|
|
28
|
-
|
|
32
|
+
readonly version: "19.1.0";
|
|
29
33
|
};
|
|
30
34
|
declare function getAnalyzerOptions(): AnalyzerOptions;
|
|
31
|
-
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/get-command-line-options.d.ts
|
|
32
37
|
declare function getCommandLineOptions(): {
|
|
33
|
-
|
|
38
|
+
project?: string;
|
|
34
39
|
};
|
|
35
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/get-react-version.d.ts
|
|
36
42
|
declare function getReactVersion(fallback: string): string;
|
|
37
|
-
|
|
38
|
-
export {
|
|
43
|
+
//#endregion
|
|
44
|
+
export { AnalyzerOptions, DEFAULT_ANALYZER_OPTIONS, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, getAnalyzerOptions, getCommandLineOptions, getId, getReactVersion };
|
package/dist/index.js
CHANGED
|
@@ -1,44 +1,70 @@
|
|
|
1
|
-
import module from
|
|
2
|
-
import path from
|
|
3
|
-
import { identity } from
|
|
4
|
-
import { getTsconfig } from
|
|
5
|
-
import {
|
|
6
|
-
import { parseArgs } from
|
|
1
|
+
import module from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { identity } from "@react-analyzer/eff";
|
|
4
|
+
import { getTsconfig } from "get-tsconfig";
|
|
5
|
+
import { P, match } from "ts-pattern";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
//#region src/_id.ts
|
|
9
|
+
let id = 0n;
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
const getId = () => (id++).toString();
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/_require.ts
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
const _require = module.createRequire(process.cwd() + path.sep);
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/constants.ts
|
|
24
|
+
/**
|
|
25
|
+
* The NPM scope for this project.
|
|
26
|
+
*/
|
|
27
|
+
const NPM_SCOPE = "@react-analyzer";
|
|
28
|
+
/**
|
|
29
|
+
* The GitHub repository for this project.
|
|
30
|
+
*/
|
|
31
|
+
const GITHUB_URL = "https://github.com/react-analyzer/react-analyzer";
|
|
32
|
+
/**
|
|
33
|
+
* The URL to the project's website.
|
|
34
|
+
*/
|
|
35
|
+
const WEBSITE_URL = "https://react-analyzer.xyz";
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/get-command-line-options.ts
|
|
17
39
|
function getCommandLineOptions() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
40
|
+
const { values } = parseArgs({ options: { project: {
|
|
41
|
+
type: "string",
|
|
42
|
+
short: "p"
|
|
43
|
+
} } });
|
|
44
|
+
return values;
|
|
22
45
|
}
|
|
23
46
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/get-analyzer-options.ts
|
|
49
|
+
const DEFAULT_ANALYZER_OPTIONS = { version: "19.1.0" };
|
|
28
50
|
function getAnalyzerOptions() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
51
|
+
const { project = "tsconfig.json" } = getCommandLineOptions();
|
|
52
|
+
const options = getTsconfig(project)?.config["react"];
|
|
53
|
+
return {
|
|
54
|
+
...DEFAULT_ANALYZER_OPTIONS,
|
|
55
|
+
...match(options).with({ version: P.string }, identity).otherwise(() => ({}))
|
|
56
|
+
};
|
|
35
57
|
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/get-react-version.ts
|
|
36
61
|
function getReactVersion(fallback) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
try {
|
|
63
|
+
return match(_require("react")).with({ version: P.select(P.string) }, identity).otherwise(() => fallback);
|
|
64
|
+
} catch {
|
|
65
|
+
return fallback;
|
|
66
|
+
}
|
|
42
67
|
}
|
|
43
68
|
|
|
44
|
-
|
|
69
|
+
//#endregion
|
|
70
|
+
export { DEFAULT_ANALYZER_OPTIONS, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, getAnalyzerOptions, getCommandLineOptions, getId, getReactVersion };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-analyzer/shared",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.5",
|
|
4
4
|
"description": "React Analyzer Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/react-analyzer",
|
|
6
6
|
"bugs": {
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"get-tsconfig": "^4.10.1",
|
|
31
31
|
"ts-pattern": "^5.8.0",
|
|
32
|
-
"@react-analyzer/
|
|
33
|
-
"@react-analyzer/
|
|
32
|
+
"@react-analyzer/kit": "0.0.3-next.5",
|
|
33
|
+
"@react-analyzer/eff": "0.0.3-next.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@tsconfig/node22": "^22.0.2",
|
|
37
37
|
"@types/node": "^24.3.0",
|
|
38
|
-
"
|
|
38
|
+
"tsdown": "^0.14.1",
|
|
39
39
|
"type-fest": "^4.41.0",
|
|
40
40
|
"@local/configs": "0.0.0"
|
|
41
41
|
},
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"node": ">=22.17.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "
|
|
47
|
+
"build": "tsdown --dts-resolve",
|
|
48
48
|
"build:docs": "typedoc",
|
|
49
49
|
"lint:publish": "publint",
|
|
50
50
|
"lint:ts": "tsl"
|