@wix/wix-code-diagnostics-plugin 1.0.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/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @wix/wix-code-diagnostics-plugin
2
+
3
+ Wix CLI plugin that forwards CLI `build` / `preview` / `dev` diagnostics to the
4
+ code-project-orchestrator directly over HTTP, bypassing the remote-machine →
5
+ Greyhound pipeline.
6
+
7
+ ## Usage
8
+
9
+ Register it in `wix.config.mjs`:
10
+
11
+ ```js
12
+ import { defineWixConfig } from '@wix/cli/config';
13
+ import { wixCodeDiagnosticsPlugin } from '@wix/wix-code-diagnostics-plugin';
14
+
15
+ export default defineWixConfig({
16
+ config: {
17
+ /* ... */
18
+ },
19
+ plugins: [wixCodeDiagnosticsPlugin()],
20
+ });
21
+ ```
22
+
23
+ ## Activation
24
+
25
+ The plugin is **inert** unless both environment variables are present, so the
26
+ committed config is identical on every machine and activation is controlled by
27
+ the task command that runs the CLI:
28
+
29
+ | Env var | Purpose |
30
+ |---|---|
31
+ | `WIX_CODE_DIAGNOSTICS_ENDPOINT` | Full URL of the orchestrator's `ReportCodeDiagnostic` endpoint |
32
+ | `WIX_CODE_DIAGNOSTICS_TOKEN` | Authorized access token, sent as the `Authorization` header |
33
+
34
+ When active, on each diagnostic it reads `siteId` (metaSiteId) and `devArmTag`
35
+ (overrideId) from `.wix/app.config.json` and POSTs
36
+ `{ overrideId, metaSiteId, phase, status }` to the endpoint. Reporting is
37
+ best-effort and never fails the CLI run.
38
+
39
+ > Interim: until the CLI exposes `build`/`preview` error + success events, the
40
+ > plugin subscribes to the dev process's `dc-updated` event to exercise the
41
+ > transport end to end.
@@ -0,0 +1,6 @@
1
+ export interface AppConfigIdentity {
2
+ metaSiteId?: string;
3
+ overrideId?: string;
4
+ }
5
+ export declare const readAppConfig: (cwd?: string) => AppConfigIdentity;
6
+ //# sourceMappingURL=appConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appConfig.d.ts","sourceRoot":"","sources":["../src/appConfig.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID,eAAO,MAAM,aAAa,GAAI,MAAK,MAAsB,KAAG,iBAe3D,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { WixCliPlugin } from './types';
2
+ export declare const wixCodeDiagnosticsPlugin: () => WixCliPlugin;
3
+ export type { WixCliPlugin } from './types';
4
+ export { reportDiagnostic } from './reportDiagnostic';
5
+ export { readAppConfig } from './appConfig';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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,YAmB1C,CAAC;AAEH,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,68 @@
1
+ // src/appConfig.ts
2
+ import { readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ var isRecord = (value) => typeof value === "object" && value !== null;
5
+ var readAppConfig = (cwd = process.cwd()) => {
6
+ try {
7
+ const raw = readFileSync(join(cwd, ".wix", "app.config.json"), "utf8");
8
+ const parsed = JSON.parse(raw);
9
+ if (!isRecord(parsed)) {
10
+ return {};
11
+ }
12
+ const { siteId, devArmTag } = parsed;
13
+ return {
14
+ metaSiteId: typeof siteId === "string" ? siteId : void 0,
15
+ overrideId: typeof devArmTag === "string" ? devArmTag : void 0
16
+ };
17
+ } catch {
18
+ return {};
19
+ }
20
+ };
21
+
22
+ // src/reportDiagnostic.ts
23
+ var reportDiagnostic = async ({
24
+ endpoint,
25
+ token,
26
+ phase,
27
+ status,
28
+ cwd
29
+ }) => {
30
+ const { metaSiteId, overrideId } = readAppConfig(cwd);
31
+ if (!metaSiteId || !overrideId) {
32
+ return;
33
+ }
34
+ await globalThis.fetch(endpoint, {
35
+ method: "POST",
36
+ headers: {
37
+ "content-type": "application/json",
38
+ authorization: token
39
+ },
40
+ body: JSON.stringify({ overrideId, metaSiteId, phase, status })
41
+ });
42
+ };
43
+
44
+ // src/index.ts
45
+ var ENV_ENDPOINT = "WIX_CODE_DIAGNOSTICS_ENDPOINT";
46
+ var ENV_TOKEN = "WIX_CODE_DIAGNOSTICS_TOKEN";
47
+ var wixCodeDiagnosticsPlugin = () => ({
48
+ name: "wix-code-diagnostics",
49
+ hooks: {
50
+ "cli:setup"({ emitter }) {
51
+ const endpoint = process.env[ENV_ENDPOINT];
52
+ const token = process.env[ENV_TOKEN];
53
+ if (!endpoint || !token) {
54
+ return;
55
+ }
56
+ emitter.on("dc-updated", () => {
57
+ void reportDiagnostic({ endpoint, token, phase: "dev", status: "success" }).catch(
58
+ () => void 0
59
+ );
60
+ });
61
+ }
62
+ }
63
+ });
64
+ export {
65
+ readAppConfig,
66
+ reportDiagnostic,
67
+ wixCodeDiagnosticsPlugin
68
+ };
@@ -0,0 +1,9 @@
1
+ export interface ReportDiagnosticInput {
2
+ endpoint: string;
3
+ token: string;
4
+ phase: string;
5
+ status: string;
6
+ cwd?: string;
7
+ }
8
+ export declare const reportDiagnostic: ({ endpoint, token, phase, status, cwd, }: ReportDiagnosticInput) => Promise<void>;
9
+ //# sourceMappingURL=reportDiagnostic.d.ts.map
@@ -0,0 +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,CActC,CAAC"}
@@ -0,0 +1,15 @@
1
+ export interface PluginEmitter {
2
+ on(event: string, listener: (payload?: unknown) => void): void;
3
+ }
4
+ export interface CliSetupHookArgs {
5
+ cmd: string;
6
+ emitter: PluginEmitter;
7
+ }
8
+ export interface WixCliPluginHooks {
9
+ 'cli:setup'?: (args: CliSetupHookArgs) => void;
10
+ }
11
+ export interface WixCliPlugin {
12
+ name: string;
13
+ hooks: WixCliPluginHooks;
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,CAAC;CAChD;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;CAC1B"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@wix/wix-code-diagnostics-plugin",
3
+ "version": "1.0.0",
4
+ "description": "Wix CLI plugin that forwards CLI build/preview/dev diagnostics to the code-project-orchestrator over HTTP",
5
+ "type": "module",
6
+ "main": "dist/index.mjs",
7
+ "module": "dist/index.mjs",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "clean": "rm -rf dist",
17
+ "prebuild": "npm run clean",
18
+ "build": "tsc && esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.mjs",
19
+ "test": "echo \"No tests for plugin package yet\" && exit 0",
20
+ "lint": "echo \"No lint for plugin package yet\" && exit 0",
21
+ "typecheck": "tsc --noEmit"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "publishConfig": {
27
+ "registry": "https://registry.npmjs.org/",
28
+ "access": "public"
29
+ },
30
+ "wix": {
31
+ "artifact": {
32
+ "groupId": "com.wixpress",
33
+ "artifactId": "wix-code-diagnostics-plugin"
34
+ }
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^18.16.1",
38
+ "esbuild": "^0.24.0",
39
+ "typescript": "^5.9.3"
40
+ },
41
+ "falconPackageHash": "35c1871dda852f0cb3f5be465edb4df7c6096041123dda85043e8ebb"
42
+ }