@wix/wix-code-diagnostics-plugin 1.1.2 → 1.1.4
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 +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +63 -37
- package/dist/reportDiagnostic.d.ts +5 -3
- package/dist/reportDiagnostic.d.ts.map +1 -1
- package/dist/types.d.ts +32 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WixCliPlugin } from './types';
|
|
2
2
|
export declare const wixCodeDiagnosticsPlugin: () => WixCliPlugin;
|
|
3
|
-
export type { WixCliPlugin } from './types';
|
|
4
|
-
export { reportDiagnostic } from './reportDiagnostic';
|
|
3
|
+
export type { WixCliPlugin, CliErrorCtx } from './types';
|
|
4
|
+
export { reportDiagnostic, cliErrorToCodeErrors } from './reportDiagnostic';
|
|
5
5
|
export { readAppConfig } from './appConfig';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,YAAY,EAAE,MAAM,SAAS,CAAC;AAevD,eAAO,MAAM,wBAAwB,QAAO,YAsC3C,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import { appendFileSync } from "node:fs";
|
|
3
|
-
|
|
4
1
|
// src/appConfig.ts
|
|
5
2
|
import { readFileSync } from "node:fs";
|
|
6
3
|
import { join } from "node:path";
|
|
@@ -23,11 +20,32 @@ var readAppConfig = (cwd = process.cwd()) => {
|
|
|
23
20
|
};
|
|
24
21
|
|
|
25
22
|
// src/reportDiagnostic.ts
|
|
23
|
+
var cliErrorToCodeErrors = (ctx) => {
|
|
24
|
+
if (ctx.type === "project") {
|
|
25
|
+
return (ctx.errors ?? []).map((error2) => ({
|
|
26
|
+
raw: error2.raw,
|
|
27
|
+
message: error2.message,
|
|
28
|
+
file: error2.location?.file,
|
|
29
|
+
line: error2.location?.line,
|
|
30
|
+
column: error2.location?.column,
|
|
31
|
+
stack: error2.stack
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
const { error } = ctx;
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
name: error.name,
|
|
38
|
+
message: error.message,
|
|
39
|
+
stack: error.stack,
|
|
40
|
+
cause: error.cause === void 0 ? void 0 : String(error.cause)
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
};
|
|
26
44
|
var reportDiagnostic = async ({
|
|
27
45
|
endpoint,
|
|
28
46
|
token,
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
errorType,
|
|
48
|
+
errors,
|
|
31
49
|
cwd
|
|
32
50
|
}) => {
|
|
33
51
|
const { metaSiteId, overrideId } = readAppConfig(cwd);
|
|
@@ -40,7 +58,7 @@ var reportDiagnostic = async ({
|
|
|
40
58
|
"content-type": "application/json",
|
|
41
59
|
authorization: token
|
|
42
60
|
},
|
|
43
|
-
body: JSON.stringify({ overrideId, metaSiteId,
|
|
61
|
+
body: JSON.stringify({ overrideId, metaSiteId, errorType, errors })
|
|
44
62
|
});
|
|
45
63
|
if (!res.ok) {
|
|
46
64
|
throw new Error(
|
|
@@ -52,41 +70,49 @@ var reportDiagnostic = async ({
|
|
|
52
70
|
// src/index.ts
|
|
53
71
|
var ENV_ENDPOINT = "WIX_CODE_DIAGNOSTICS_ENDPOINT";
|
|
54
72
|
var ENV_TOKEN = "WIX_CODE_DIAGNOSTICS_TOKEN";
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
73
|
+
var SAMPLE_PROJECT_ERROR = {
|
|
74
|
+
message: "Example build error (wix-code-diagnostics e2e test)",
|
|
75
|
+
raw: "[vite] Internal server error: Example build error (e2e test)",
|
|
76
|
+
file: "src/pages/index.astro",
|
|
77
|
+
line: 1,
|
|
78
|
+
column: 1
|
|
62
79
|
};
|
|
63
|
-
var wixCodeDiagnosticsPlugin = () =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
var wixCodeDiagnosticsPlugin = () => {
|
|
81
|
+
const endpoint = process.env[ENV_ENDPOINT];
|
|
82
|
+
const token = process.env[ENV_TOKEN];
|
|
83
|
+
if (endpoint && token) {
|
|
84
|
+
void reportDiagnostic({
|
|
85
|
+
endpoint,
|
|
86
|
+
token,
|
|
87
|
+
errorType: "project",
|
|
88
|
+
errors: [SAMPLE_PROJECT_ERROR]
|
|
89
|
+
}).catch((error) => {
|
|
90
|
+
console.error("[wix-code-diagnostics] failed to report diagnostic:", error);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
name: "wix-code-diagnostics",
|
|
95
|
+
hooks: {
|
|
96
|
+
"cli:setup"({ emitter }) {
|
|
97
|
+
if (!endpoint || !token) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
emitter.on("cli-error", (ctx) => {
|
|
101
|
+
void reportDiagnostic({
|
|
102
|
+
endpoint,
|
|
103
|
+
token,
|
|
104
|
+
errorType: ctx.type,
|
|
105
|
+
errors: cliErrorToCodeErrors(ctx)
|
|
106
|
+
}).catch((error) => {
|
|
107
|
+
console.error("[wix-code-diagnostics] failed to report diagnostic:", error);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
85
110
|
}
|
|
86
111
|
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
112
|
+
};
|
|
113
|
+
};
|
|
89
114
|
export {
|
|
115
|
+
cliErrorToCodeErrors,
|
|
90
116
|
readAppConfig,
|
|
91
117
|
reportDiagnostic,
|
|
92
118
|
wixCodeDiagnosticsPlugin
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { CliErrorCtx, CodeError } from './types';
|
|
1
2
|
export interface ReportDiagnosticInput {
|
|
2
3
|
endpoint: string;
|
|
3
4
|
token: string;
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
errorType: string;
|
|
6
|
+
errors: CodeError[];
|
|
6
7
|
cwd?: string;
|
|
7
8
|
}
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const cliErrorToCodeErrors: (ctx: CliErrorCtx) => CodeError[];
|
|
10
|
+
export declare const reportDiagnostic: ({ endpoint, token, errorType, errors, cwd, }: ReportDiagnosticInput) => Promise<void>;
|
|
9
11
|
//# sourceMappingURL=reportDiagnostic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportDiagnostic.d.ts","sourceRoot":"","sources":["../src/reportDiagnostic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reportDiagnostic.d.ts","sourceRoot":"","sources":["../src/reportDiagnostic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID,eAAO,MAAM,oBAAoB,GAAI,KAAK,WAAW,KAAG,SAAS,EAqBhE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,8CAMpC,qBAAqB,KAAG,OAAO,CAAC,IAAI,CAoBtC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
|
+
export interface ProjectErrorLocation {
|
|
2
|
+
file: string;
|
|
3
|
+
line?: number;
|
|
4
|
+
column?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ProjectError {
|
|
7
|
+
raw?: string;
|
|
8
|
+
message?: string;
|
|
9
|
+
location?: ProjectErrorLocation;
|
|
10
|
+
stack?: string;
|
|
11
|
+
}
|
|
12
|
+
export type CliErrorCtx = {
|
|
13
|
+
type: 'cli-system';
|
|
14
|
+
error: Error;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'cli-user';
|
|
17
|
+
error: Error;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'project';
|
|
20
|
+
errors: ProjectError[];
|
|
21
|
+
};
|
|
22
|
+
export interface CodeError {
|
|
23
|
+
name?: string;
|
|
24
|
+
message?: string;
|
|
25
|
+
raw?: string;
|
|
26
|
+
file?: string;
|
|
27
|
+
line?: number;
|
|
28
|
+
column?: number;
|
|
29
|
+
stack?: string;
|
|
30
|
+
cause?: string;
|
|
31
|
+
}
|
|
1
32
|
export interface PluginEmitter {
|
|
33
|
+
on(event: 'cli-error', listener: (ctx: CliErrorCtx) => void): void;
|
|
2
34
|
on(event: string, listener: (payload?: unknown) => void): void;
|
|
3
35
|
}
|
|
4
36
|
export interface CliSetupHookArgs {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"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,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAC;IACnE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;CAChE;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;CAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/wix-code-diagnostics-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Wix CLI plugin that forwards CLI build/preview/dev diagnostics to the code-project-orchestrator over HTTP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"esbuild": "^0.24.0",
|
|
39
39
|
"typescript": "^5.9.3"
|
|
40
40
|
},
|
|
41
|
-
"falconPackageHash": "
|
|
41
|
+
"falconPackageHash": "273b25b5f89269fbb7f683ef03c33d2ce22260c5a928765d21a41c87"
|
|
42
42
|
}
|