@holdyapp/install 0.1.0 → 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/README.md +1 -1
- package/dist/cli.js +16 -16
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Re-rodar o CLI no mesmo projeto = no-op. Os patches detectam o marker `holdy-ins
|
|
|
64
64
|
|
|
65
65
|
npm install @holdyapp/sdk
|
|
66
66
|
|
|
67
|
-
[4] Pronto! Inicie o app e abra o widget de status em
|
|
67
|
+
[4] Pronto! Inicie o app e abra o widget de status em holdy.chat
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
## Licença
|
package/dist/cli.js
CHANGED
|
@@ -82,7 +82,7 @@ function pick(cwd, candidates) {
|
|
|
82
82
|
var import_node_fs2 = require("node:fs");
|
|
83
83
|
var import_node_path2 = require("node:path");
|
|
84
84
|
var HOLDY_MARKER = "holdy-installed-by-cli";
|
|
85
|
-
var CDN_URL = "https://
|
|
85
|
+
var CDN_URL = "https://holdy.chat/sdk/v1/holdy.js";
|
|
86
86
|
function inject(detection, opts) {
|
|
87
87
|
switch (detection.framework) {
|
|
88
88
|
case "next-app":
|
|
@@ -189,7 +189,7 @@ export function HoldyScript() {
|
|
|
189
189
|
s.onload = () => {
|
|
190
190
|
window.Holdy?.init({
|
|
191
191
|
apiKey: '${opts.apiKey}',
|
|
192
|
-
${opts.accountId ? `
|
|
192
|
+
${opts.accountId ? `accountKey: '${opts.accountId}',
|
|
193
193
|
` : ""}autoCapture: ${opts.autoCapture},
|
|
194
194
|
})
|
|
195
195
|
}
|
|
@@ -228,11 +228,11 @@ function injectNextPages(file, opts) {
|
|
|
228
228
|
if (original.includes(HOLDY_MARKER) || original.includes("@holdyapp/sdk")) {
|
|
229
229
|
return { ok: true, modified: false, file, message: "Holdy j\xE1 presente no _app \xB7 skip" };
|
|
230
230
|
}
|
|
231
|
-
let patched = addImport(original, `import {
|
|
231
|
+
let patched = addImport(original, `import { initHoldy } from '@holdyapp/sdk/web' // ${HOLDY_MARKER}`);
|
|
232
232
|
patched = patched.replace(
|
|
233
233
|
/export default function (\w+)\([^)]*\)\s*\{/,
|
|
234
234
|
(match) => `${match}
|
|
235
|
-
if (typeof window !== 'undefined' && !window.__holdyInit) {
|
|
235
|
+
if (typeof window !== 'undefined' && !window.__holdyInit) { initHoldy({ apiKey: '${opts.apiKey}', ${opts.accountId ? `accountKey: '${opts.accountId}', ` : ""}autoCapture: ${opts.autoCapture} }); (window as unknown as { __holdyInit?: boolean }).__holdyInit = true }`
|
|
236
236
|
);
|
|
237
237
|
(0, import_node_fs2.writeFileSync)(file, patched);
|
|
238
238
|
return { ok: true, modified: true, file, message: `Patched ${displayPath(file)} \xB7 rode npm install @holdyapp/sdk` };
|
|
@@ -251,8 +251,8 @@ function injectViteReact(file, opts) {
|
|
|
251
251
|
if (original.includes(HOLDY_MARKER) || original.includes("@holdyapp/sdk")) {
|
|
252
252
|
return { ok: true, modified: false, file, message: "Holdy j\xE1 presente no entry \xB7 skip" };
|
|
253
253
|
}
|
|
254
|
-
const patched = `import {
|
|
255
|
-
|
|
254
|
+
const patched = `import { initHoldy } from '@holdyapp/sdk/web' // ${HOLDY_MARKER}
|
|
255
|
+
initHoldy({ apiKey: '${opts.apiKey}', ${opts.accountId ? `accountKey: '${opts.accountId}', ` : ""}autoCapture: ${opts.autoCapture} })
|
|
256
256
|
|
|
257
257
|
${original}`;
|
|
258
258
|
(0, import_node_fs2.writeFileSync)(file, patched);
|
|
@@ -267,12 +267,12 @@ function injectNuxt(file, opts) {
|
|
|
267
267
|
}
|
|
268
268
|
ensureDir(file);
|
|
269
269
|
const content = `// ${HOLDY_MARKER}
|
|
270
|
-
import {
|
|
270
|
+
import { initHoldy } from '@holdyapp/sdk/web'
|
|
271
271
|
|
|
272
272
|
export default defineNuxtPlugin(() => {
|
|
273
|
-
|
|
273
|
+
initHoldy({
|
|
274
274
|
apiKey: '${opts.apiKey}',
|
|
275
|
-
${opts.accountId ? `
|
|
275
|
+
${opts.accountId ? `accountKey: '${opts.accountId}',
|
|
276
276
|
` : ""}autoCapture: ${opts.autoCapture},
|
|
277
277
|
})
|
|
278
278
|
})
|
|
@@ -341,7 +341,7 @@ function injectHtmlOrAstro(file, opts) {
|
|
|
341
341
|
}
|
|
342
342
|
function buildScriptSnippet(opts) {
|
|
343
343
|
const accountLine = opts.accountId ? `
|
|
344
|
-
|
|
344
|
+
accountKey: '${opts.accountId}',` : "";
|
|
345
345
|
return `<script src="${CDN_URL}"></script>
|
|
346
346
|
<script>
|
|
347
347
|
Holdy.init({
|
|
@@ -352,10 +352,10 @@ function buildScriptSnippet(opts) {
|
|
|
352
352
|
}
|
|
353
353
|
function buildEsImportSnippet(opts) {
|
|
354
354
|
const accountLine = opts.accountId ? `
|
|
355
|
-
|
|
356
|
-
return `import {
|
|
355
|
+
accountKey: '${opts.accountId}',` : "";
|
|
356
|
+
return `import { initHoldy } from '@holdyapp/sdk/web'
|
|
357
357
|
|
|
358
|
-
|
|
358
|
+
initHoldy({
|
|
359
359
|
apiKey: '${opts.apiKey}',${accountLine}
|
|
360
360
|
autoCapture: ${opts.autoCapture},
|
|
361
361
|
})`;
|
|
@@ -407,7 +407,7 @@ async function main() {
|
|
|
407
407
|
apiKey = await promptApiKey();
|
|
408
408
|
}
|
|
409
409
|
if (!apiKey || !apiKey.startsWith("hol_")) {
|
|
410
|
-
log.error("API key inv\xE1lida. Use formato hol_live_\u2026 ou hol_test_\u2026 \xB7 gere em
|
|
410
|
+
log.error("API key inv\xE1lida. Use formato hol_live_\u2026 ou hol_test_\u2026 \xB7 gere em holdy.chat/settings.");
|
|
411
411
|
process.exit(1);
|
|
412
412
|
}
|
|
413
413
|
log.step("2", "Aplicando snippet no(s) arquivo(s)\u2026");
|
|
@@ -439,7 +439,7 @@ async function main() {
|
|
|
439
439
|
} else {
|
|
440
440
|
log.step("3", "Sem npm install necess\xE1rio \xB7 script tag via CDN.");
|
|
441
441
|
}
|
|
442
|
-
log.step("4", 'Pronto! Inicie o app e abra o widget de status em
|
|
442
|
+
log.step("4", 'Pronto! Inicie o app e abra o widget de status em holdy.chat \xB7 voc\xEA deve ver "conectado" em segundos.');
|
|
443
443
|
process.exit(0);
|
|
444
444
|
}
|
|
445
445
|
function parseArgs(argv) {
|
|
@@ -484,7 +484,7 @@ ${bold("Argumentos:")}
|
|
|
484
484
|
apiKey Token Holdy (hol_live_\u2026 ou hol_test_\u2026)
|
|
485
485
|
|
|
486
486
|
${bold("Op\xE7\xF5es:")}
|
|
487
|
-
--account <id>
|
|
487
|
+
--account <id> Chave da account padr\xE3o (vira context.account_external_id)
|
|
488
488
|
--no-auto-capture Desabilita captura autom\xE1tica de page views
|
|
489
489
|
--version, -v Mostra vers\xE3o
|
|
490
490
|
--help, -h Mostra esta mensagem
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holdyapp/install",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Holdy install CLI
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Holdy install CLI \u00b7 detects your framework and wires the SDK in 1 step",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://
|
|
6
|
+
"homepage": "https://holdy.chat",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/augustoperolligaedke/
|
|
9
|
+
"url": "git+https://github.com/augustoperolligaedke/holdy.git",
|
|
10
10
|
"directory": "packages/install-cli"
|
|
11
11
|
},
|
|
12
12
|
"bin": {
|