rsbuild-plugin-arethetypeswrong 0.0.0 → 0.1.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.
@@ -0,0 +1,14 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation. All rights reserved.
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
+ this file except in compliance with the License. You may obtain a copy of the
5
+ License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
+ MERCHANTABLITY OR NON-INFRINGEMENT.
11
+
12
+ See the Apache Version 2.0 License for specific language governing permissions
13
+ and limitations under the License.
14
+ ***************************************************************************** */
package/dist/737.js ADDED
@@ -0,0 +1,144 @@
1
+ /*! For license information please see 737.js.LICENSE.txt */
2
+ export const __webpack_ids__ = [
3
+ "737"
4
+ ];
5
+ export const __webpack_modules__ = {
6
+ "./src/problemUtils.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
7
+ __webpack_require__.d(__webpack_exports__, {
8
+ SG: ()=>moduleKinds,
9
+ jo: ()=>resolutionKinds,
10
+ zc: ()=>problemFlags
11
+ });
12
+ const problemFlags = {
13
+ NoResolution: "no-resolution",
14
+ UntypedResolution: "untyped-resolution",
15
+ FalseCJS: "false-cjs",
16
+ FalseESM: "false-esm",
17
+ CJSResolvesToESM: "cjs-resolves-to-esm",
18
+ FallbackCondition: "fallback-condition",
19
+ CJSOnlyExportsDefault: "cjs-only-exports-default",
20
+ NamedExports: "named-exports",
21
+ FalseExportDefault: "false-export-default",
22
+ MissingExportEquals: "missing-export-equals",
23
+ UnexpectedModuleSyntax: "unexpected-module-syntax",
24
+ InternalResolutionError: "internal-resolution-error"
25
+ };
26
+ const resolutionKinds = {
27
+ node10: "node10",
28
+ "node16-cjs": "node16 (from CJS)",
29
+ "node16-esm": "node16 (from ESM)",
30
+ bundler: "bundler"
31
+ };
32
+ const moduleKinds = {
33
+ 1: "(CJS)",
34
+ 99: "(ESM)",
35
+ "": ""
36
+ };
37
+ },
38
+ "./src/render/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ render: ()=>render
41
+ });
42
+ var dist_problems = __webpack_require__("./node_modules/.pnpm/@arethetypeswrong+core@0.18.2/node_modules/@arethetypeswrong/core/dist/problems.js");
43
+ var utils = __webpack_require__("./node_modules/.pnpm/@arethetypeswrong+core@0.18.2/node_modules/@arethetypeswrong/core/dist/utils.js");
44
+ var cli_table3 = __webpack_require__("./node_modules/.pnpm/cli-table3@0.6.5/node_modules/cli-table3/index.js");
45
+ var cli_table3_default = /*#__PURE__*/ __webpack_require__.n(cli_table3);
46
+ var marked_esm = __webpack_require__("./node_modules/.pnpm/marked@11.2.0/node_modules/marked/lib/marked.esm.js");
47
+ var marked_terminal = __webpack_require__("./node_modules/.pnpm/marked-terminal@7.3.0_marked@11.2.0/node_modules/marked-terminal/index.js");
48
+ var picocolors = __webpack_require__("./node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
49
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
50
+ var problemUtils = __webpack_require__("./src/problemUtils.ts");
51
+ /**
52
+ * @license
53
+ Copyright 2023 Andrew Branch
54
+
55
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
60
+ */ async function renderTyped(analysis, { emoji = true, summary = true, ignoreRules = [], ignoreResolutions = [] }) {
61
+ let output = "";
62
+ const problems = analysis.problems.filter((problem)=>!ignoreRules || !ignoreRules.includes(problemUtils.zc[problem.kind]));
63
+ const requiredResolutions = utils.Kx.filter((kind)=>!ignoreResolutions.includes(kind));
64
+ const ignoredResolutions = utils.Kx.filter((kind)=>ignoreResolutions.includes(kind));
65
+ const resolutions = requiredResolutions.concat(ignoredResolutions);
66
+ const entrypoints = Object.keys(analysis.entrypoints);
67
+ marked_esm.TU.setOptions({
68
+ renderer: new marked_terminal.Z()
69
+ });
70
+ out(`[arethetypeswrong] ${analysis.packageName} v${analysis.packageVersion}`);
71
+ out();
72
+ if (Object.keys(analysis.buildTools).length) {
73
+ out("Build tools:");
74
+ out(Object.entries(analysis.buildTools).map(([tool, version])=>`- ${tool}@${version}`).join("\n"));
75
+ out();
76
+ }
77
+ if (ignoreRules && ignoreRules.length) out(picocolors_default().gray(` (ignoring rules: ${ignoreRules.map((rule)=>`'${rule}'`).join(", ")})\n`));
78
+ if (ignoreResolutions && ignoreResolutions.length) out(picocolors_default().gray(` (ignoring resolutions: ${ignoreResolutions.map((resolution)=>`'${resolution}'`).join(", ")})\n`));
79
+ if (summary) {
80
+ const defaultSummary = emoji ? " No problems found \uD83C\uDF1F" : " No problems found";
81
+ const grouped = (0, utils.$y)(problems);
82
+ const summaryTexts = await Promise.all(Object.entries(grouped).map(async ([kind, kindProblems])=>{
83
+ const info = dist_problems.I[kind];
84
+ const affectsRequiredResolution = kindProblems.some((p)=>requiredResolutions.some((r)=>(0, dist_problems.Kh)(p, r, analysis)));
85
+ const description = await (0, marked_esm.TU)(`${info.description}${info.details ? ` Use \`-f json\` to see ${info.details}.` : ""} ${info.docsUrl}`);
86
+ return `${affectsRequiredResolution ? "" : "(ignored per resolution) "}${emoji ? `${info.emoji} ` : ""}${description}`;
87
+ }));
88
+ out(summaryTexts.join("") || defaultSummary);
89
+ }
90
+ const entrypointNames = entrypoints.map((s)=>`"${"." === s ? analysis.packageName : `${analysis.packageName}/${s.substring(2)}`}"`);
91
+ const entrypointHeaders = entrypoints.map((s, i)=>{
92
+ const hasProblems = problems.some((p)=>(0, dist_problems.On)(p, s, analysis));
93
+ return picocolors_default().bold((hasProblems ? picocolors_default().redBright : picocolors_default().greenBright)(entrypointNames[i]));
94
+ });
95
+ const getCellContents = (subpath, resolutionKind)=>{
96
+ const ignoredPrefix = ignoreResolutions.includes(resolutionKind) ? "(ignored) " : "";
97
+ const problemsForCell = (0, utils.$y)((0, dist_problems.jR)(problems, analysis, {
98
+ entrypoint: subpath,
99
+ resolutionKind
100
+ }));
101
+ const entrypoint = analysis.entrypoints[subpath].resolutions[resolutionKind];
102
+ const resolution = entrypoint.resolution;
103
+ const kinds = Object.keys(problemsForCell);
104
+ if (kinds.length) return kinds.map((kind)=>ignoredPrefix + (emoji ? `${dist_problems.I[kind].emoji} ` : "") + dist_problems.I[kind].shortDescription).join("\n");
105
+ const jsonResult = emoji ? "\uD83D\uDFE2 (JSON)" : "OK (JSON)";
106
+ const moduleResult = entrypoint.isWildcard ? "(wildcard)" : (emoji ? "\uD83D\uDFE2 " : "OK ") + problemUtils.SG[analysis.programInfo[(0, utils.Nt)(resolutionKind)].moduleKinds?.[resolution?.fileName ?? ""]?.detectedKind || ""];
107
+ return ignoredPrefix + (resolution?.isJson ? jsonResult : moduleResult);
108
+ };
109
+ const table = new (cli_table3_default())({
110
+ head: [
111
+ "",
112
+ ...entrypointHeaders
113
+ ]
114
+ });
115
+ resolutions.forEach((kind)=>{
116
+ table.push([
117
+ problemUtils.jo[kind],
118
+ ...entrypoints.map((entrypoint)=>getCellContents(entrypoint, kind))
119
+ ]);
120
+ });
121
+ out(table.toString());
122
+ return output.trimEnd();
123
+ function out(s = "") {
124
+ output += s + "\n";
125
+ }
126
+ }
127
+ /**
128
+ * @license
129
+ Copyright 2023 Andrew Branch
130
+
131
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
132
+
133
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
134
+
135
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
136
+ */ function renderUntyped(analysis) {
137
+ return `[arethetypeswrong] Package ${analysis.packageName}@${analysis.packageVersion} does not contain types.`;
138
+ }
139
+ async function render(analysis, options) {
140
+ if (analysis.types) return renderTyped(analysis, options);
141
+ return renderUntyped(analysis);
142
+ }
143
+ }
144
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ Copyright 2023 Andrew Branch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+ */