@wix/wix-code-diagnostics-plugin 1.1.3 → 1.1.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 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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAgB5C,eAAO,MAAM,wBAAwB,QAAO,YAqB3C,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAM5C,eAAO,MAAM,wBAAwB,QAAO,YAwB3C,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
- phase,
30
- status,
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, phase, status })
61
+ body: JSON.stringify({ overrideId, metaSiteId, errorType, errors })
44
62
  });
45
63
  if (!res.ok) {
46
64
  throw new Error(
@@ -52,30 +70,32 @@ 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 MARKER = "/tmp/wcd-marker";
56
- var mark = (line) => {
57
- try {
58
- appendFileSync(MARKER, `${line}
59
- `);
60
- } catch {
61
- }
62
- };
63
73
  var wixCodeDiagnosticsPlugin = () => {
64
74
  const endpoint = process.env[ENV_ENDPOINT];
65
75
  const token = process.env[ENV_TOKEN];
66
- mark(`factory endpoint=${Boolean(endpoint)} token=${Boolean(token)}`);
67
- if (endpoint && token) {
68
- void reportDiagnostic({ endpoint, token, phase: "build", status: "success" }).then(() => mark("report: ok")).catch((error) => {
69
- mark(`report: error ${error instanceof Error ? error.message : String(error)}`);
70
- console.error("[wix-code-diagnostics] failed to report diagnostic:", error);
71
- });
72
- }
73
76
  return {
74
77
  name: "wix-code-diagnostics",
75
- hooks: {}
78
+ hooks: {
79
+ "cli:setup"({ emitter }) {
80
+ if (!endpoint || !token) {
81
+ return;
82
+ }
83
+ emitter.on("cli-error", (ctx) => {
84
+ void reportDiagnostic({
85
+ endpoint,
86
+ token,
87
+ errorType: ctx.type,
88
+ errors: cliErrorToCodeErrors(ctx)
89
+ }).catch((error) => {
90
+ console.error("[wix-code-diagnostics] failed to report diagnostic:", error);
91
+ });
92
+ });
93
+ }
94
+ }
76
95
  };
77
96
  };
78
97
  export {
98
+ cliErrorToCodeErrors,
79
99
  readAppConfig,
80
100
  reportDiagnostic,
81
101
  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
- phase: string;
5
- status: string;
5
+ errorType: string;
6
+ errors: CodeError[];
6
7
  cwd?: string;
7
8
  }
8
- export declare const reportDiagnostic: ({ endpoint, token, phase, status, cwd, }: ReportDiagnosticInput) => Promise<void>;
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":"AAEA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,gBAAgB,GAAU,0CAMpC,qBAAqB,KAAG,OAAO,CAAC,IAAI,CAoBtC,CAAC"}
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 {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,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"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC;AAGhD,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,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",
3
+ "version": "1.1.5",
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": "1d81f14e2c1e4939f4bd44e7ce9849653d340ca837b95f2c5f036443"
41
+ "falconPackageHash": "376916cfb639a4a0b35fef139e2add0a3850256e01430aecf316594b"
42
42
  }