rsbuild-plugin-arethetypeswrong 0.1.1 → 0.2.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.
- package/dist/131.js +124 -0
- package/dist/218.js +1 -0
- package/dist/{223.js → 356.js} +3212 -3132
- package/dist/363.js +7 -0
- package/dist/408.js +22 -0
- package/dist/45.js +879 -0
- package/dist/453.js +26 -0
- package/dist/{806.js → 520.js} +134 -145
- package/dist/727.js +3413 -0
- package/dist/index.js +1 -279
- package/dist/rslib-runtime.js +48 -0
- package/package.json +17 -17
- package/dist/237.js +0 -63
- package/dist/395.js +0 -686
- package/dist/698.js +0 -74
- package/dist/723.js +0 -3419
- package/dist/737.js +0 -144
- /package/dist/{index.js.LICENSE.txt → 131.js.LICENSE.txt} +0 -0
- /package/dist/{237.js.LICENSE.txt → 356.js.LICENSE.txt} +0 -0
- /package/dist/{737.js.LICENSE.txt → 408.js.LICENSE.txt} +0 -0
- /package/dist/{723.js.LICENSE.txt → 727.js.LICENSE.txt} +0 -0
package/dist/131.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*! For license information please see 131.js.LICENSE.txt */
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
import node_path, { delimiter, dirname, normalize, resolve } from "node:path";
|
|
4
|
+
function _ts_add_disposable_resource(env, value, async) {
|
|
5
|
+
if (null != value) {
|
|
6
|
+
if ("object" != typeof value && "function" != typeof value) throw new TypeError("Object expected.");
|
|
7
|
+
var dispose, inner;
|
|
8
|
+
if (async) {
|
|
9
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
10
|
+
dispose = value[Symbol.asyncDispose];
|
|
11
|
+
}
|
|
12
|
+
if (void 0 === dispose) {
|
|
13
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
14
|
+
dispose = value[Symbol.dispose];
|
|
15
|
+
if (async) inner = dispose;
|
|
16
|
+
}
|
|
17
|
+
if ("function" != typeof dispose) throw new TypeError("Object not disposable.");
|
|
18
|
+
if (inner) dispose = function() {
|
|
19
|
+
try {
|
|
20
|
+
inner.call(this);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return Promise.reject(e);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
env.stack.push({
|
|
26
|
+
value: value,
|
|
27
|
+
dispose: dispose,
|
|
28
|
+
async: async
|
|
29
|
+
});
|
|
30
|
+
} else if (async) env.stack.push({
|
|
31
|
+
async: true
|
|
32
|
+
});
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
function src_ts_dispose_resources(env) {
|
|
36
|
+
var _SuppressedError = "function" == typeof SuppressedError ? SuppressedError : function(error, suppressed, message) {
|
|
37
|
+
var e = new Error(message);
|
|
38
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
39
|
+
};
|
|
40
|
+
return (src_ts_dispose_resources = function(env) {
|
|
41
|
+
function fail(e) {
|
|
42
|
+
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
43
|
+
env.hasError = true;
|
|
44
|
+
}
|
|
45
|
+
var r, s = 0;
|
|
46
|
+
function next() {
|
|
47
|
+
while(r = env.stack.pop())try {
|
|
48
|
+
if (!r.async && 1 === s) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
49
|
+
if (r.dispose) {
|
|
50
|
+
var result = r.dispose.call(r.value);
|
|
51
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
|
|
52
|
+
fail(e);
|
|
53
|
+
return next();
|
|
54
|
+
});
|
|
55
|
+
} else s |= 1;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
fail(e);
|
|
58
|
+
}
|
|
59
|
+
if (1 === s) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
60
|
+
if (env.hasError) throw env.error;
|
|
61
|
+
}
|
|
62
|
+
return next();
|
|
63
|
+
})(env);
|
|
64
|
+
}
|
|
65
|
+
const pluginAreTheTypesWrong = (options = {})=>({
|
|
66
|
+
name: "plugin-arethetypeswrong",
|
|
67
|
+
setup (api) {
|
|
68
|
+
if (false === options.enable) return;
|
|
69
|
+
const logger = api.logger;
|
|
70
|
+
api.onAfterBuild({
|
|
71
|
+
handler: async ({ isFirstCompile, isWatch })=>{
|
|
72
|
+
const env = {
|
|
73
|
+
stack: [],
|
|
74
|
+
error: void 0,
|
|
75
|
+
hasError: false
|
|
76
|
+
};
|
|
77
|
+
try {
|
|
78
|
+
/* node:coverage ignore if -- @preserve */ if (!isFirstCompile) return;
|
|
79
|
+
const { rootPath } = api.context;
|
|
80
|
+
const packageJson = JSON.parse(node_fs.readFileSync(node_path.join(rootPath, "package.json"), "utf-8"));
|
|
81
|
+
const packageName = packageJson.name;
|
|
82
|
+
const packageVersion = packageJson.version;
|
|
83
|
+
logger.start(`[arethetypeswrong] Checking ${packageName}@${packageVersion}...`);
|
|
84
|
+
console.info();
|
|
85
|
+
logger.debug(`[arethetypeswrong] Running npm pack from ${rootPath}`);
|
|
86
|
+
const { createTarball } = await import("./45.js").then((mod)=>({
|
|
87
|
+
createTarball: mod.createTarball
|
|
88
|
+
}));
|
|
89
|
+
const tarball = _ts_add_disposable_resource(env, await createTarball(rootPath, packageJson), true);
|
|
90
|
+
logger.debug("[arethetypeswrong] npm pack success");
|
|
91
|
+
const { checkPackage, createPackageFromTarballData } = await import("./727.js").then((mod)=>({
|
|
92
|
+
checkPackage: mod.checkPackage,
|
|
93
|
+
createPackageFromTarballData: mod.createPackageFromTarballData
|
|
94
|
+
}));
|
|
95
|
+
const pkg = createPackageFromTarballData(node_fs.readFileSync(tarball.path));
|
|
96
|
+
const result = await checkPackage(pkg);
|
|
97
|
+
const { render } = await import("./356.js").then((mod)=>({
|
|
98
|
+
render: mod.render
|
|
99
|
+
}));
|
|
100
|
+
const message = await render(result, options.areTheTypesWrongOptions ?? {});
|
|
101
|
+
const { getExitCode } = await import("./408.js").then((mod)=>({
|
|
102
|
+
getExitCode: mod.getExitCode
|
|
103
|
+
}));
|
|
104
|
+
const exitCode = getExitCode(result, options.areTheTypesWrongOptions);
|
|
105
|
+
const hasErrors = 0 !== exitCode;
|
|
106
|
+
if (hasErrors) {
|
|
107
|
+
logger.error(message);
|
|
108
|
+
/* node:coverage ignore next -- @preserve */ if (!isWatch) throw new Error("arethetypeswrong failed!");
|
|
109
|
+
/* node:coverage ignore next -- @preserve */ return;
|
|
110
|
+
}
|
|
111
|
+
logger.success(message);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
env.error = e;
|
|
114
|
+
env.hasError = true;
|
|
115
|
+
} finally{
|
|
116
|
+
const result = src_ts_dispose_resources(env);
|
|
117
|
+
if (result) await result;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
order: "post"
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
export { delimiter, dirname, node_path, normalize, pluginAreTheTypesWrong, resolve };
|
package/dist/218.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cwd, default as node_process } from "node:process";
|