sealmetrics 0.1.3 → 0.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/api/client.d.ts +0 -3
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +51 -109
- package/dist/api/client.js.map +1 -1
- package/dist/detect/cms.d.ts +6 -4
- package/dist/detect/cms.d.ts.map +1 -1
- package/dist/detect/cms.js +4 -49
- package/dist/detect/cms.js.map +1 -1
- package/dist/detect/index.d.ts +7 -4
- package/dist/detect/index.d.ts.map +1 -1
- package/dist/detect/index.js +5 -152
- package/dist/detect/index.js.map +1 -1
- package/dist/handoff/install.d.ts.map +1 -1
- package/dist/handoff/install.js +9 -2
- package/dist/handoff/install.js.map +1 -1
- package/dist/index.js +2061 -66
- package/dist/instrument/guide.d.ts +1 -2
- package/dist/instrument/guide.d.ts.map +1 -1
- package/dist/instrument/guide.js +9 -24
- package/dist/instrument/guide.js.map +1 -1
- package/dist/mcp/configure.js +2 -2
- package/dist/mcp/configure.js.map +1 -1
- package/dist/types.d.ts +11 -40
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/dist/verify/pixel.d.ts +5 -12
- package/dist/verify/pixel.d.ts.map +1 -1
- package/dist/verify/pixel.js +17 -33
- package/dist/verify/pixel.js.map +1 -1
- package/package.json +6 -3
package/dist/api/client.d.ts
CHANGED
|
@@ -21,8 +21,5 @@ export declare class ApiClient {
|
|
|
21
21
|
provision(input: ProvisionInput): Promise<ProvisionResult>;
|
|
22
22
|
/** GET /sites/{id}/pixel/status. Throws CliError(4) on network/backend errors. */
|
|
23
23
|
pixelStatus(accountId: string, apiKey: string): Promise<PixelStatus>;
|
|
24
|
-
private fetchWithTimeout;
|
|
25
|
-
private json;
|
|
26
|
-
private safeText;
|
|
27
24
|
}
|
|
28
25
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEhE,8FAA8F;AAC9F,qBAAa,gBAAiB,SAAQ,KAAK;;CAK1C;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAE1B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAKjD,yFAAyF;IACnF,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAqBhE,kFAAkF;IAC5E,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAS3E"}
|
package/dist/api/client.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP client for the Fase 1 backend (Bloque 4).
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* HTTP client for the Fase 1 backend (Bloque 4). The transport now lives in
|
|
3
|
+
* `@sealmetrics/setup-core` (`provision`, `fetchPixelStatus`), shared with the MCP
|
|
4
|
+
* write-path (RF-3102). This adapter keeps the CLI's surface identical: it maps
|
|
5
|
+
* setup-core's presentation-agnostic `ProvisionError` codes to the CLI's exit
|
|
6
|
+
* codes / `CliError` (RF-402) and re-exposes `EmailExistsError` + `ProvisionInput`.
|
|
6
7
|
*/
|
|
8
|
+
import { provision as coreProvision, fetchPixelStatus as coreFetchPixelStatus, ProvisionError, } from "@sealmetrics/setup-core";
|
|
7
9
|
import { CliError, ExitCode } from "../exit-codes.js";
|
|
8
|
-
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
9
10
|
/** Raised on 409 (email already exists) — init handles it as informative, exit 0 (RF-402). */
|
|
10
11
|
export class EmailExistsError extends Error {
|
|
11
12
|
constructor() {
|
|
@@ -22,126 +23,67 @@ export class ApiClient {
|
|
|
22
23
|
}
|
|
23
24
|
/** POST /provision. Throws CliError (3/4) or EmailExistsError on the mapped statuses. */
|
|
24
25
|
async provision(input) {
|
|
25
|
-
const body = {
|
|
26
|
-
site_name: input.siteName,
|
|
27
|
-
domain: input.domain,
|
|
28
|
-
email: input.email,
|
|
29
|
-
name: input.name,
|
|
30
|
-
accept_terms: true,
|
|
31
|
-
install_source: input.installSource,
|
|
32
|
-
timezone: input.timezone,
|
|
33
|
-
};
|
|
34
|
-
let res;
|
|
35
26
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
27
|
+
return await coreProvision({
|
|
28
|
+
siteName: input.siteName,
|
|
29
|
+
domain: input.domain,
|
|
30
|
+
email: input.email,
|
|
31
|
+
name: input.name,
|
|
32
|
+
installSource: input.installSource,
|
|
33
|
+
timezone: input.timezone,
|
|
34
|
+
}, { baseUrl: this.baseUrl, provisionKey: this.provisionKey });
|
|
45
35
|
}
|
|
46
36
|
catch (e) {
|
|
47
|
-
|
|
37
|
+
if (e instanceof ProvisionError) {
|
|
38
|
+
throw mapProvisionError(e, input, this.baseUrl);
|
|
39
|
+
}
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** GET /sites/{id}/pixel/status. Throws CliError(4) on network/backend errors. */
|
|
44
|
+
async pixelStatus(accountId, apiKey) {
|
|
45
|
+
try {
|
|
46
|
+
return await coreFetchPixelStatus(accountId, { baseUrl: this.baseUrl, apiKey });
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
throw new CliError(ExitCode.NETWORK, "pixel_status_error", "Pixel status check failed.", {
|
|
48
50
|
hint: e instanceof Error ? e.message : undefined,
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
throw new CliError(ExitCode.AUTH_REQUIRED, "AUTH_REQUIRED", "The provision key was rejected (invalid or revoked).", {
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Map setup-core's transport-level error to the CLI's exit-coded CliError (RF-402). */
|
|
56
|
+
function mapProvisionError(e, input, baseUrl) {
|
|
57
|
+
switch (e.code) {
|
|
58
|
+
case "EMAIL_EXISTS":
|
|
59
|
+
return new EmailExistsError();
|
|
60
|
+
case "AUTH_REQUIRED":
|
|
61
|
+
return new CliError(ExitCode.AUTH_REQUIRED, "AUTH_REQUIRED", e.message, {
|
|
61
62
|
hint: "Re-run with a valid publishable provision key.",
|
|
62
63
|
extra: {
|
|
63
64
|
command: input.reinvokeCommand ??
|
|
64
65
|
"npx sealmetrics init --provision-key <YOUR_KEY> --email <email> --accept-tos",
|
|
65
66
|
},
|
|
66
67
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
if (res.status === 429) {
|
|
72
|
-
const retryAfter = parseRetryAfter(res.headers.get("Retry-After"));
|
|
73
|
-
throw new CliError(ExitCode.NETWORK, "rate_limited", "Provisioning is rate-limited. Please wait and retry.", {
|
|
74
|
-
extra: retryAfter ? { retry_after: retryAfter } : undefined,
|
|
68
|
+
case "RATE_LIMITED":
|
|
69
|
+
return new CliError(ExitCode.NETWORK, "rate_limited", e.message, {
|
|
70
|
+
extra: e.retryAfter ? { retry_after: e.retryAfter } : undefined,
|
|
75
71
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
const detail = await this.safeText(res);
|
|
81
|
-
throw new CliError(ExitCode.NETWORK, "backend_error", `Provisioning failed (HTTP ${res.status}).`, {
|
|
82
|
-
hint: detail.slice(0, 200) || undefined,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/** GET /sites/{id}/pixel/status. Throws CliError(4) on network/backend errors. */
|
|
86
|
-
async pixelStatus(accountId, apiKey) {
|
|
87
|
-
const url = `${this.baseUrl}/sites/${encodeURIComponent(accountId)}/pixel/status`;
|
|
88
|
-
let res;
|
|
89
|
-
try {
|
|
90
|
-
res = await this.fetchWithTimeout(url, {
|
|
91
|
-
method: "GET",
|
|
92
|
-
headers: { "X-API-Key": apiKey, Accept: "application/json" },
|
|
72
|
+
case "PROVISIONING_DISABLED":
|
|
73
|
+
return new CliError(ExitCode.NETWORK, "provisioning_disabled", e.message, {
|
|
74
|
+
hint: "The free-tier channel is not enabled yet. Try again later.",
|
|
93
75
|
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
76
|
+
case "BAD_RESPONSE":
|
|
77
|
+
return new CliError(ExitCode.NETWORK, "bad_response", e.message);
|
|
78
|
+
case "NETWORK":
|
|
79
|
+
return new CliError(ExitCode.NETWORK, "network_error", `Could not reach the SealMetrics API at ${baseUrl}.`, {
|
|
80
|
+
hint: e.detail,
|
|
98
81
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
hint: detail.slice(0, 200) || undefined,
|
|
82
|
+
case "BACKEND_ERROR":
|
|
83
|
+
default:
|
|
84
|
+
return new CliError(ExitCode.NETWORK, "backend_error", e.message, {
|
|
85
|
+
hint: e.detail,
|
|
104
86
|
});
|
|
105
|
-
}
|
|
106
|
-
const json = (await this.json(res));
|
|
107
|
-
const data = json.data;
|
|
108
|
-
if (!data || typeof data.installed !== "boolean") {
|
|
109
|
-
throw new CliError(ExitCode.NETWORK, "bad_response", "Pixel status returned an unexpected response.");
|
|
110
|
-
}
|
|
111
|
-
return data;
|
|
112
|
-
}
|
|
113
|
-
async fetchWithTimeout(url, init) {
|
|
114
|
-
const controller = new AbortController();
|
|
115
|
-
const timeout = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT_MS);
|
|
116
|
-
try {
|
|
117
|
-
return await fetch(url, { ...init, signal: controller.signal });
|
|
118
|
-
}
|
|
119
|
-
finally {
|
|
120
|
-
clearTimeout(timeout);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
async json(res) {
|
|
124
|
-
const text = await res.text();
|
|
125
|
-
try {
|
|
126
|
-
return JSON.parse(text);
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
throw new CliError(ExitCode.NETWORK, "bad_response", "The API returned invalid JSON.");
|
|
130
|
-
}
|
|
131
87
|
}
|
|
132
|
-
async safeText(res) {
|
|
133
|
-
try {
|
|
134
|
-
return await res.text();
|
|
135
|
-
}
|
|
136
|
-
catch {
|
|
137
|
-
return "";
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
function parseRetryAfter(header) {
|
|
142
|
-
if (!header)
|
|
143
|
-
return undefined;
|
|
144
|
-
const n = parseInt(header, 10);
|
|
145
|
-
return Number.isFinite(n) && n > 0 ? n : undefined;
|
|
146
88
|
}
|
|
147
89
|
//# sourceMappingURL=client.js.map
|
package/dist/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["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CAAC,OAAO,EAAE;gBACxE,IAAI,EAAE,4DAA4D;aACnE,CAAC,CAAC;QACL,KAAK,cAAc;YACjB,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;QACnE,KAAK,SAAS;YACZ,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,0CAA0C,OAAO,GAAG,EAAE;gBAC3G,IAAI,EAAE,CAAC,CAAC,MAAM;aACf,CAAC,CAAC;QACL,KAAK,eAAe,CAAC;QACrB;YACE,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE;gBAChE,IAAI,EAAE,CAAC,CAAC,MAAM;aACf,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
|
package/dist/detect/cms.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CMS / ecommerce platform detection (RF-305). The logic now lives in
|
|
3
|
+
* `@sealmetrics/setup-core` (shared with the MCP write-path, RF-3102); this module
|
|
4
|
+
* re-exports it so the rest of the CLI keeps importing from `./cms.js` unchanged.
|
|
5
|
+
*/
|
|
6
|
+
export { detectPlatform, PLATFORM_PLUGIN_HINT } from "@sealmetrics/setup-core";
|
|
5
7
|
//# sourceMappingURL=cms.d.ts.map
|
package/dist/detect/cms.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms.d.ts","sourceRoot":"","sources":["../../src/detect/cms.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cms.d.ts","sourceRoot":"","sources":["../../src/detect/cms.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/detect/cms.js
CHANGED
|
@@ -1,52 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CMS / ecommerce platform detection (RF-305).
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* only; conservative (VAL-305).
|
|
2
|
+
* CMS / ecommerce platform detection (RF-305). The logic now lives in
|
|
3
|
+
* `@sealmetrics/setup-core` (shared with the MCP write-path, RF-3102); this module
|
|
4
|
+
* re-exports it so the rest of the CLI keeps importing from `./cms.js` unchanged.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
/** Official plugin/module install hint per platform, surfaced in next_steps (RF-306). */
|
|
10
|
-
export const PLATFORM_PLUGIN_HINT = {
|
|
11
|
-
woocommerce: "Install the official SealMetrics for WooCommerce plugin and paste your account_id in its settings.",
|
|
12
|
-
wordpress: "Install the official SealMetrics for WordPress plugin and paste your account_id in its settings.",
|
|
13
|
-
prestashop: "Install the official SealMetrics PrestaShop module and paste your account_id in its settings.",
|
|
14
|
-
magento2: "Install the official SealMetrics Magento 2 extension and paste your account_id in its settings.",
|
|
15
|
-
drupal: "Install the official SealMetrics Drupal module and paste your account_id in its settings.",
|
|
16
|
-
joomla: "Install the official SealMetrics Joomla plugin and paste your account_id in its settings.",
|
|
17
|
-
opencart: "Install the official SealMetrics OpenCart extension and paste your account_id in its settings.",
|
|
18
|
-
};
|
|
19
|
-
export function detectPlatform(cwd) {
|
|
20
|
-
const has = (...rel) => rel.some((r) => existsSync(join(cwd, r)));
|
|
21
|
-
// WordPress family (Woo is WordPress + the plugin dir).
|
|
22
|
-
if (has("wp-config.php", "wp-content")) {
|
|
23
|
-
if (has("wp-content/plugins/woocommerce", "wp-content/plugins/woocommerce/woocommerce.php")) {
|
|
24
|
-
return "woocommerce";
|
|
25
|
-
}
|
|
26
|
-
return "wordpress";
|
|
27
|
-
}
|
|
28
|
-
// PrestaShop
|
|
29
|
-
if (has("config/settings.inc.php", "app/config/parameters.php") && has("prestashop", "classes/PrestaShopAutoload.php")) {
|
|
30
|
-
return "prestashop";
|
|
31
|
-
}
|
|
32
|
-
if (has("classes/PrestaShopAutoload.php"))
|
|
33
|
-
return "prestashop";
|
|
34
|
-
// Magento 2
|
|
35
|
-
if (has("bin/magento", "app/etc/env.php") && has("app/etc/di.xml", "vendor/magento")) {
|
|
36
|
-
return "magento2";
|
|
37
|
-
}
|
|
38
|
-
if (has("bin/magento"))
|
|
39
|
-
return "magento2";
|
|
40
|
-
// Drupal
|
|
41
|
-
if (has("core/lib/Drupal.php"))
|
|
42
|
-
return "drupal";
|
|
43
|
-
// Joomla
|
|
44
|
-
if (has("configuration.php") && has("libraries/joomla", "administrator/manifests")) {
|
|
45
|
-
return "joomla";
|
|
46
|
-
}
|
|
47
|
-
// OpenCart
|
|
48
|
-
if (has("system/startup.php") && has("catalog/controller"))
|
|
49
|
-
return "opencart";
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
6
|
+
export { detectPlatform, PLATFORM_PLUGIN_HINT } from "@sealmetrics/setup-core";
|
|
52
7
|
//# sourceMappingURL=cms.js.map
|
package/dist/detect/cms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms.js","sourceRoot":"","sources":["../../src/detect/cms.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cms.js","sourceRoot":"","sources":["../../src/detect/cms.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/detect/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Project detection (Bloque 3). The detection logic now lives in
|
|
3
|
+
* `@sealmetrics/setup-core` (shared with the MCP write-path, RF-3102) and is
|
|
4
|
+
* re-exported here so the rest of the CLI keeps importing `detect` from
|
|
5
|
+
* `./index.js` unchanged. Read-only, best-effort, conservative — see setup-core.
|
|
6
|
+
*/
|
|
7
|
+
export { detect, detectFramework } from "@sealmetrics/setup-core";
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/detect/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/detect/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/detect/index.js
CHANGED
|
@@ -1,155 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Project detection (Bloque 3).
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Best-effort and conservative (VAL-301): when in doubt it returns `unknown`
|
|
8
|
-
* and falls back to the manual path rather than guessing wrong.
|
|
2
|
+
* Project detection (Bloque 3). The detection logic now lives in
|
|
3
|
+
* `@sealmetrics/setup-core` (shared with the MCP write-path, RF-3102) and is
|
|
4
|
+
* re-exported here so the rest of the CLI keeps importing `detect` from
|
|
5
|
+
* `./index.js` unchanged. Read-only, best-effort, conservative — see setup-core.
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { detectPlatform } from "./cms.js";
|
|
13
|
-
const LOCATIONS = {
|
|
14
|
-
"next-app": {
|
|
15
|
-
location: "app/layout.tsx",
|
|
16
|
-
hint: "inside <head>, or via a next/script <Script> component",
|
|
17
|
-
strategy: "next-app-router-layout",
|
|
18
|
-
},
|
|
19
|
-
"next-pages": {
|
|
20
|
-
location: "pages/_document.tsx",
|
|
21
|
-
hint: "inside <Head> in _document (or pages/_app.tsx)",
|
|
22
|
-
strategy: "next-pages-document",
|
|
23
|
-
},
|
|
24
|
-
astro: {
|
|
25
|
-
location: "src/layouts/Layout.astro",
|
|
26
|
-
hint: "inside <head> of your root layout",
|
|
27
|
-
strategy: "astro-layout-head",
|
|
28
|
-
},
|
|
29
|
-
remix: {
|
|
30
|
-
location: "app/root.tsx",
|
|
31
|
-
hint: "inside the <head> region of the root route",
|
|
32
|
-
strategy: "remix-root-head",
|
|
33
|
-
},
|
|
34
|
-
nuxt: {
|
|
35
|
-
location: "nuxt.config.ts",
|
|
36
|
-
hint: "in app.head.script (or app.vue <head>)",
|
|
37
|
-
strategy: "nuxt-config-head",
|
|
38
|
-
},
|
|
39
|
-
sveltekit: {
|
|
40
|
-
location: "src/app.html",
|
|
41
|
-
hint: "inside <head>, above %sveltekit.head%",
|
|
42
|
-
strategy: "sveltekit-app-html",
|
|
43
|
-
},
|
|
44
|
-
vite: {
|
|
45
|
-
location: "index.html",
|
|
46
|
-
hint: "just before </head>",
|
|
47
|
-
strategy: "vite-index-html",
|
|
48
|
-
},
|
|
49
|
-
html: {
|
|
50
|
-
location: "index.html",
|
|
51
|
-
hint: "just before </head>",
|
|
52
|
-
strategy: "static-html-head",
|
|
53
|
-
},
|
|
54
|
-
unknown: {
|
|
55
|
-
location: "your site's root HTML / <head>",
|
|
56
|
-
hint: "just before the closing </head> tag on every page",
|
|
57
|
-
strategy: "manual",
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
export function detect(cwd, opts) {
|
|
61
|
-
// RF-304: provision-only when forced or when there's nothing to place into.
|
|
62
|
-
if (opts?.noInject) {
|
|
63
|
-
return makeDetection("unknown", { provisionOnly: true });
|
|
64
|
-
}
|
|
65
|
-
const platform = detectPlatform(cwd);
|
|
66
|
-
if (platform) {
|
|
67
|
-
// RF-305/306: CMS with an official plugin — do NOT edit PHP/theme files.
|
|
68
|
-
return makeDetection("unknown", { platform, provisionOnly: false });
|
|
69
|
-
}
|
|
70
|
-
const pkg = readPackageJson(cwd);
|
|
71
|
-
if (pkg) {
|
|
72
|
-
const fw = detectFromPackageJson(cwd, pkg);
|
|
73
|
-
return makeDetection(fw, { provisionOnly: false });
|
|
74
|
-
}
|
|
75
|
-
// No package.json — a static site if there's an index.html, else nothing to place into.
|
|
76
|
-
if (findIndexHtml(cwd)) {
|
|
77
|
-
return makeDetection("html", { provisionOnly: false });
|
|
78
|
-
}
|
|
79
|
-
if (isEmptyish(cwd)) {
|
|
80
|
-
return makeDetection("unknown", { provisionOnly: true });
|
|
81
|
-
}
|
|
82
|
-
// There IS a repo but we don't recognise it (RF-303): manual, not provision-only.
|
|
83
|
-
return makeDetection("unknown", { provisionOnly: false });
|
|
84
|
-
}
|
|
85
|
-
function detectFromPackageJson(cwd, pkg) {
|
|
86
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
87
|
-
const has = (name) => Object.prototype.hasOwnProperty.call(deps, name);
|
|
88
|
-
if (has("next")) {
|
|
89
|
-
return hasAppRouter(cwd) ? "next-app" : "next-pages";
|
|
90
|
-
}
|
|
91
|
-
if (has("astro"))
|
|
92
|
-
return "astro";
|
|
93
|
-
if (has("@remix-run/react") || has("@remix-run/node") || has("@remix-run/serve"))
|
|
94
|
-
return "remix";
|
|
95
|
-
if (has("nuxt") || has("nuxt3") || has("nuxt-edge"))
|
|
96
|
-
return "nuxt";
|
|
97
|
-
if (has("@sveltejs/kit"))
|
|
98
|
-
return "sveltekit";
|
|
99
|
-
if (has("vite"))
|
|
100
|
-
return "vite";
|
|
101
|
-
// A package.json with none of the markers but an index.html → treat as static.
|
|
102
|
-
if (findIndexHtml(cwd))
|
|
103
|
-
return "html";
|
|
104
|
-
return "unknown";
|
|
105
|
-
}
|
|
106
|
-
function hasAppRouter(cwd) {
|
|
107
|
-
// App router if app/ exists (and is preferred); fall back to pages/.
|
|
108
|
-
const appDirs = ["app", "src/app"];
|
|
109
|
-
const pagesDirs = ["pages", "src/pages"];
|
|
110
|
-
const hasApp = appDirs.some((d) => existsSync(join(cwd, d)));
|
|
111
|
-
const hasPages = pagesDirs.some((d) => existsSync(join(cwd, d)));
|
|
112
|
-
if (hasApp)
|
|
113
|
-
return true;
|
|
114
|
-
if (hasPages)
|
|
115
|
-
return false;
|
|
116
|
-
// Default for modern Next.js is the app router.
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
function readPackageJson(cwd) {
|
|
120
|
-
const p = join(cwd, "package.json");
|
|
121
|
-
if (!existsSync(p))
|
|
122
|
-
return null;
|
|
123
|
-
try {
|
|
124
|
-
return JSON.parse(readFileSync(p, "utf8"));
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function findIndexHtml(cwd) {
|
|
131
|
-
return ["index.html", "public/index.html", "src/index.html"].some((f) => existsSync(join(cwd, f)));
|
|
132
|
-
}
|
|
133
|
-
function isEmptyish(cwd) {
|
|
134
|
-
try {
|
|
135
|
-
const entries = readdirSync(cwd).filter((e) => !e.startsWith(".") && e !== "seal.config.json");
|
|
136
|
-
return entries.length === 0;
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function makeDetection(framework, extra) {
|
|
143
|
-
const loc = LOCATIONS[framework];
|
|
144
|
-
const detection = {
|
|
145
|
-
framework,
|
|
146
|
-
strategy: extra.platform ? `cms-plugin-${extra.platform}` : loc.strategy,
|
|
147
|
-
recommendedLocation: loc.location,
|
|
148
|
-
placementHint: loc.hint,
|
|
149
|
-
provisionOnly: extra.provisionOnly,
|
|
150
|
-
};
|
|
151
|
-
if (extra.platform)
|
|
152
|
-
detection.platform = extra.platform;
|
|
153
|
-
return detection;
|
|
154
|
-
}
|
|
7
|
+
export { detect, detectFramework } from "@sealmetrics/setup-core";
|
|
155
8
|
//# sourceMappingURL=index.js.map
|
package/dist/detect/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/detect/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/detect/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/handoff/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/handoff/install.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgC7C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CA+CxE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAmET"}
|
package/dist/handoff/install.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
9
9
|
import { join } from "node:path";
|
|
10
|
+
import { getStackGuide, PLATFORM_PLUGIN_HINT } from "@sealmetrics/setup-core";
|
|
10
11
|
import { SNIPPET_MARKER } from "../embedded.js";
|
|
11
|
-
import { PLATFORM_PLUGIN_HINT } from "../detect/cms.js";
|
|
12
12
|
const SKIP_DIRS = new Set([
|
|
13
13
|
"node_modules",
|
|
14
14
|
".git",
|
|
@@ -105,11 +105,18 @@ export function isSnippetPresent(cwd, accountId) {
|
|
|
105
105
|
*/
|
|
106
106
|
export function buildInstallMarkdown(args) {
|
|
107
107
|
const { snippet, accountId, detection, dashboardUrl } = args;
|
|
108
|
+
// Framework-specific loading knowledge (RF-3501) — single source: setup-core.
|
|
109
|
+
const stackNotes = detection.platform
|
|
110
|
+
? ""
|
|
111
|
+
: `\n\n**${detection.framework} — how to load it correctly:**\n` +
|
|
112
|
+
getStackGuide(detection.framework)
|
|
113
|
+
.notes.map((n) => `- ${n}`)
|
|
114
|
+
.join("\n");
|
|
108
115
|
const placement = detection.platform
|
|
109
116
|
? `**Platform detected: ${detection.platform}.** ${PLATFORM_PLUGIN_HINT[detection.platform]}\n\n` +
|
|
110
117
|
`Do **not** paste the snippet into theme files by hand — the official plugin is the supported path.`
|
|
111
118
|
: `**Recommended location:** \`${detection.recommendedLocation}\` — ${detection.placementHint}.\n\n` +
|
|
112
|
-
`Place the snippet there so it loads on **every** page. The CLI did not edit any source file; you (or your agent) place it
|
|
119
|
+
`Place the snippet there so it loads on **every** page. The CLI did not edit any source file; you (or your agent) place it.${stackNotes}`;
|
|
113
120
|
return `${SNIPPET_MARKER}
|
|
114
121
|
# Install SealMetrics tracking
|
|
115
122
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/handoff/install.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/handoff/install.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,SAAS,GAAG,IAA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