@embeddables/cli 0.7.19 → 0.8.1
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/.prompts/embeddables-cli.md +7 -4
- package/dist/auth/index.d.ts +43 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +102 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +210 -0
- package/dist/command-history.d.ts +13 -0
- package/dist/command-history.d.ts.map +1 -0
- package/dist/command-history.js +34 -0
- package/dist/commands/branch.d.ts +4 -0
- package/dist/commands/branch.d.ts.map +1 -0
- package/dist/commands/branch.js +67 -0
- package/dist/commands/build-workbench.d.ts +5 -0
- package/dist/commands/build-workbench.d.ts.map +1 -0
- package/dist/commands/build-workbench.js +116 -0
- package/dist/commands/build.d.ts +8 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +60 -0
- package/dist/commands/builder-open.d.ts +4 -0
- package/dist/commands/builder-open.d.ts.map +1 -0
- package/dist/commands/builder-open.js +74 -0
- package/dist/commands/dev.d.ts +12 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +226 -0
- package/dist/commands/diff.d.ts +76 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +653 -0
- package/dist/commands/experiments-connect.d.ts +6 -0
- package/dist/commands/experiments-connect.d.ts.map +1 -0
- package/dist/commands/experiments-connect.js +140 -0
- package/dist/commands/feedback.d.ts +29 -0
- package/dist/commands/feedback.d.ts.map +1 -0
- package/dist/commands/feedback.js +267 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +384 -0
- package/dist/commands/inspect.d.ts +9 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +293 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +117 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +19 -0
- package/dist/commands/pull.d.ts +16 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +395 -0
- package/dist/commands/save.d.ts +30 -0
- package/dist/commands/save.d.ts.map +1 -0
- package/dist/commands/save.js +597 -0
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +50 -0
- package/dist/compiler/errors.d.ts +20 -0
- package/dist/compiler/errors.d.ts.map +1 -0
- package/dist/compiler/errors.js +35 -0
- package/dist/compiler/evalStatic.d.ts +3 -0
- package/dist/compiler/evalStatic.d.ts.map +1 -0
- package/dist/compiler/evalStatic.js +57 -0
- package/dist/compiler/flatten.js +1 -0
- package/dist/compiler/helpers/duplicateIds.d.ts +9 -0
- package/dist/compiler/helpers/duplicateIds.d.ts.map +1 -0
- package/dist/compiler/helpers/duplicateIds.js +71 -0
- package/dist/compiler/helpers/numericLeadingKeys.d.ts +8 -0
- package/dist/compiler/helpers/numericLeadingKeys.d.ts.map +1 -0
- package/dist/compiler/helpers/numericLeadingKeys.js +17 -0
- package/dist/compiler/index.d.ts +18 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +1272 -0
- package/dist/compiler/parsePage.d.ts +15 -0
- package/dist/compiler/parsePage.d.ts.map +1 -0
- package/dist/compiler/parsePage.js +654 -0
- package/dist/compiler/registry.d.ts +4 -0
- package/dist/compiler/registry.d.ts.map +1 -0
- package/dist/compiler/registry.js +44 -0
- package/dist/compiler/reverse.d.ts +23 -0
- package/dist/compiler/reverse.d.ts.map +1 -0
- package/dist/compiler/reverse.js +1920 -0
- package/dist/compiler/types.d.ts +21 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/compiler/types.js +1 -0
- package/dist/components/index.d.ts +21 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +21 -0
- package/dist/components/primitives/BaseComponent.d.ts +33 -0
- package/dist/components/primitives/BaseComponent.d.ts.map +1 -0
- package/dist/components/primitives/BaseComponent.js +26 -0
- package/dist/components/primitives/BookMeeting.d.ts +18 -0
- package/dist/components/primitives/BookMeeting.d.ts.map +1 -0
- package/dist/components/primitives/BookMeeting.js +5 -0
- package/dist/components/primitives/Chart.d.ts +41 -0
- package/dist/components/primitives/Chart.d.ts.map +1 -0
- package/dist/components/primitives/Chart.js +5 -0
- package/dist/components/primitives/Container.d.ts +8 -0
- package/dist/components/primitives/Container.d.ts.map +1 -0
- package/dist/components/primitives/Container.js +5 -0
- package/dist/components/primitives/CustomButton.d.ts +37 -0
- package/dist/components/primitives/CustomButton.d.ts.map +1 -0
- package/dist/components/primitives/CustomButton.js +10 -0
- package/dist/components/primitives/CustomHTML.d.ts +8 -0
- package/dist/components/primitives/CustomHTML.d.ts.map +1 -0
- package/dist/components/primitives/CustomHTML.js +5 -0
- package/dist/components/primitives/FileUpload.d.ts +18 -0
- package/dist/components/primitives/FileUpload.d.ts.map +1 -0
- package/dist/components/primitives/FileUpload.js +16 -0
- package/dist/components/primitives/InputBox.d.ts +34 -0
- package/dist/components/primitives/InputBox.d.ts.map +1 -0
- package/dist/components/primitives/InputBox.js +25 -0
- package/dist/components/primitives/Lottie.d.ts +11 -0
- package/dist/components/primitives/Lottie.d.ts.map +1 -0
- package/dist/components/primitives/Lottie.js +5 -0
- package/dist/components/primitives/MediaEmbed.d.ts +13 -0
- package/dist/components/primitives/MediaEmbed.d.ts.map +1 -0
- package/dist/components/primitives/MediaEmbed.js +6 -0
- package/dist/components/primitives/MediaImage.d.ts +8 -0
- package/dist/components/primitives/MediaImage.d.ts.map +1 -0
- package/dist/components/primitives/MediaImage.js +5 -0
- package/dist/components/primitives/OptionSelector.d.ts +38 -0
- package/dist/components/primitives/OptionSelector.d.ts.map +1 -0
- package/dist/components/primitives/OptionSelector.js +8 -0
- package/dist/components/primitives/PaypalCheckout.d.ts +25 -0
- package/dist/components/primitives/PaypalCheckout.d.ts.map +1 -0
- package/dist/components/primitives/PaypalCheckout.js +5 -0
- package/dist/components/primitives/PlainText.d.ts +6 -0
- package/dist/components/primitives/PlainText.d.ts.map +1 -0
- package/dist/components/primitives/PlainText.js +5 -0
- package/dist/components/primitives/ProgressBar.d.ts +15 -0
- package/dist/components/primitives/ProgressBar.d.ts.map +1 -0
- package/dist/components/primitives/ProgressBar.js +5 -0
- package/dist/components/primitives/RichText.d.ts +6 -0
- package/dist/components/primitives/RichText.d.ts.map +1 -0
- package/dist/components/primitives/RichText.js +5 -0
- package/dist/components/primitives/RichTextMarkdown.d.ts +6 -0
- package/dist/components/primitives/RichTextMarkdown.d.ts.map +1 -0
- package/dist/components/primitives/RichTextMarkdown.js +5 -0
- package/dist/components/primitives/Rive.d.ts +16 -0
- package/dist/components/primitives/Rive.d.ts.map +1 -0
- package/dist/components/primitives/Rive.js +8 -0
- package/dist/components/primitives/StripeCheckout.d.ts +52 -0
- package/dist/components/primitives/StripeCheckout.d.ts.map +1 -0
- package/dist/components/primitives/StripeCheckout.js +5 -0
- package/dist/components/primitives/StripeCheckout2.d.ts +30 -0
- package/dist/components/primitives/StripeCheckout2.d.ts.map +1 -0
- package/dist/components/primitives/StripeCheckout2.js +7 -0
- package/dist/config/index.d.ts +23 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +42 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +9 -0
- package/dist/helpers/TEMP helpers file.d.ts +1 -0
- package/dist/helpers/TEMP helpers file.d.ts.map +1 -0
- package/dist/helpers/TEMP helpers file.js +1 -0
- package/dist/helpers/dates.d.ts +5 -0
- package/dist/helpers/dates.d.ts.map +1 -0
- package/dist/helpers/dates.js +7 -0
- package/dist/helpers/json.d.ts +47 -0
- package/dist/helpers/json.d.ts.map +1 -0
- package/dist/helpers/json.js +622 -0
- package/dist/helpers/prompt.d.ts +15 -0
- package/dist/helpers/prompt.d.ts.map +1 -0
- package/dist/helpers/prompt.js +35 -0
- package/dist/helpers/utils.d.ts +13 -0
- package/dist/helpers/utils.d.ts.map +1 -0
- package/dist/helpers/utils.js +28 -0
- package/dist/logger.d.ts +11 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +21 -0
- package/dist/patches/prompts-escape.d.ts +14 -0
- package/dist/patches/prompts-escape.d.ts.map +1 -0
- package/dist/patches/prompts-escape.js +23 -0
- package/dist/prompts/branches.d.ts +20 -0
- package/dist/prompts/branches.d.ts.map +1 -0
- package/dist/prompts/branches.js +86 -0
- package/dist/prompts/embeddables.d.ts +43 -0
- package/dist/prompts/embeddables.d.ts.map +1 -0
- package/dist/prompts/embeddables.js +200 -0
- package/dist/prompts/experiments.d.ts +28 -0
- package/dist/prompts/experiments.d.ts.map +1 -0
- package/dist/prompts/experiments.js +89 -0
- package/dist/prompts/index.d.ts +11 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +6 -0
- package/dist/prompts/projects.d.ts +22 -0
- package/dist/prompts/projects.d.ts.map +1 -0
- package/dist/prompts/projects.js +92 -0
- package/dist/prompts/versions.d.ts +18 -0
- package/dist/prompts/versions.d.ts.map +1 -0
- package/dist/prompts/versions.js +95 -0
- package/dist/proxy/injectApiInterceptor.d.ts +6 -0
- package/dist/proxy/injectApiInterceptor.d.ts.map +1 -0
- package/dist/proxy/injectApiInterceptor.js +66 -0
- package/dist/proxy/injectReload.d.ts +2 -0
- package/dist/proxy/injectReload.d.ts.map +1 -0
- package/dist/proxy/injectReload.js +14 -0
- package/dist/proxy/injectWorkbench.d.ts +5 -0
- package/dist/proxy/injectWorkbench.d.ts.map +1 -0
- package/dist/proxy/injectWorkbench.js +22 -0
- package/dist/proxy/server.d.ts +11 -0
- package/dist/proxy/server.d.ts.map +1 -0
- package/dist/proxy/server.js +304 -0
- package/dist/proxy/sse.d.ts +5 -0
- package/dist/proxy/sse.d.ts.map +1 -0
- package/dist/proxy/sse.js +17 -0
- package/dist/sentry-context.d.ts +48 -0
- package/dist/sentry-context.d.ts.map +1 -0
- package/dist/sentry-context.js +156 -0
- package/dist/stdout.d.ts +61 -0
- package/dist/stdout.d.ts.map +1 -0
- package/dist/stdout.js +163 -0
- package/dist/types-builder.d.ts +800 -0
- package/dist/types-builder.d.ts.map +1 -0
- package/dist/types-builder.js +20 -0
- package/dist/workbench/ActionsPanel.d.ts +6 -0
- package/dist/workbench/ActionsPanel.d.ts.map +1 -0
- package/dist/workbench/ActionsPanel.js +47 -0
- package/dist/workbench/AutofillPanel.d.ts +6 -0
- package/dist/workbench/AutofillPanel.d.ts.map +1 -0
- package/dist/workbench/AutofillPanel.js +543 -0
- package/dist/workbench/ComputedFieldsPanel.d.ts +6 -0
- package/dist/workbench/ComputedFieldsPanel.d.ts.map +1 -0
- package/dist/workbench/ComputedFieldsPanel.js +31 -0
- package/dist/workbench/ExperimentsPanel.d.ts +6 -0
- package/dist/workbench/ExperimentsPanel.d.ts.map +1 -0
- package/dist/workbench/ExperimentsPanel.js +182 -0
- package/dist/workbench/FieldEditorPanel.d.ts +9 -0
- package/dist/workbench/FieldEditorPanel.d.ts.map +1 -0
- package/dist/workbench/FieldEditorPanel.js +650 -0
- package/dist/workbench/InspectorPanel.d.ts +6 -0
- package/dist/workbench/InspectorPanel.d.ts.map +1 -0
- package/dist/workbench/InspectorPanel.js +341 -0
- package/dist/workbench/PageNavigator.d.ts +6 -0
- package/dist/workbench/PageNavigator.d.ts.map +1 -0
- package/dist/workbench/PageNavigator.js +123 -0
- package/dist/workbench/SchemaPanel.d.ts +6 -0
- package/dist/workbench/SchemaPanel.d.ts.map +1 -0
- package/dist/workbench/SchemaPanel.js +222 -0
- package/dist/workbench/UserDataPanel.d.ts +6 -0
- package/dist/workbench/UserDataPanel.d.ts.map +1 -0
- package/dist/workbench/UserDataPanel.js +350 -0
- package/dist/workbench/WorkbenchApp.d.ts +7 -0
- package/dist/workbench/WorkbenchApp.d.ts.map +1 -0
- package/dist/workbench/WorkbenchApp.js +193 -0
- package/dist/workbench/cloudflare-worker/README.md +31 -0
- package/dist/workbench/cloudflare-worker/public/workbench.css +1614 -0
- package/dist/workbench/cloudflare-worker/public/workbench.js +77 -0
- package/dist/workbench/cloudflare-worker/worker.js +40 -0
- package/dist/workbench/cloudflare-worker/wrangler.toml +10 -0
- package/dist/workbench/index.d.ts +10 -0
- package/dist/workbench/index.d.ts.map +1 -0
- package/dist/workbench/index.js +44 -0
- package/dist/workbench/workbench.css +1614 -0
- package/dist/workbench/workbench.js +77 -0
- package/package.json +4 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/proxy/sse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAElC,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO;;EAoB7C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function attachSse(app) {
|
|
2
|
+
const clients = new Set();
|
|
3
|
+
app.get('/__embeddables_reload', (req, res) => {
|
|
4
|
+
res.setHeader('Content-Type', 'text/event-stream');
|
|
5
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
6
|
+
res.setHeader('Connection', 'keep-alive');
|
|
7
|
+
res.flushHeaders?.();
|
|
8
|
+
clients.add(res);
|
|
9
|
+
req.on('close', () => clients.delete(res));
|
|
10
|
+
});
|
|
11
|
+
function broadcastReload() {
|
|
12
|
+
for (const res of clients) {
|
|
13
|
+
res.write(`event: reload\ndata: ${Date.now()}\n\n`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return { broadcastReload };
|
|
17
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface SentryContextUser {
|
|
2
|
+
id: string;
|
|
3
|
+
email?: string | null;
|
|
4
|
+
}
|
|
5
|
+
export interface SentryContextProject {
|
|
6
|
+
id: string;
|
|
7
|
+
title?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface SentryContextOrg {
|
|
10
|
+
id: string;
|
|
11
|
+
title?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface SentryContextEmbeddable {
|
|
14
|
+
id: string;
|
|
15
|
+
title?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface SentryContextBranch {
|
|
18
|
+
id: string;
|
|
19
|
+
name?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface SentryContextInput {
|
|
22
|
+
user?: SentryContextUser | null;
|
|
23
|
+
project?: SentryContextProject | null;
|
|
24
|
+
org?: SentryContextOrg | null;
|
|
25
|
+
embeddable?: SentryContextEmbeddable | null;
|
|
26
|
+
branch?: SentryContextBranch | null;
|
|
27
|
+
versionNumber?: number | null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Set Sentry scope with the given context. Only sets keys that are present and have valid values.
|
|
31
|
+
* Uses setUser/setContext for error events and setAttributes on the current scope so values
|
|
32
|
+
* (project, org, embeddable, branch, versionNumber) are included in log events.
|
|
33
|
+
*/
|
|
34
|
+
export declare function setSentryContext(ctx: SentryContextInput): void;
|
|
35
|
+
/**
|
|
36
|
+
* Return project and org context from embeddables.json when present.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getSentryContextFromProjectConfig(): Partial<SentryContextInput>;
|
|
39
|
+
/**
|
|
40
|
+
* Return embeddable title (from metadata.json), branch and versionNumber (from config.json)
|
|
41
|
+
* for embeddables/{embeddableId}/ when present.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getSentryContextFromEmbeddableConfig(embeddableId: string): Partial<SentryContextInput>;
|
|
44
|
+
/**
|
|
45
|
+
* Set Sentry user from auth when logged in. Call after requireLogin for commands that need user context.
|
|
46
|
+
*/
|
|
47
|
+
export declare function setSentryUserFromAuth(): Promise<void>;
|
|
48
|
+
//# sourceMappingURL=sentry-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-context.d.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AC,IAAI,CAAC,CAY3D"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import * as Sentry from '@sentry/node';
|
|
4
|
+
import { readProjectConfig } from './config/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Set Sentry scope with the given context. Only sets keys that are present and have valid values.
|
|
7
|
+
* Uses setUser/setContext for error events and setAttributes on the current scope so values
|
|
8
|
+
* (project, org, embeddable, branch, versionNumber) are included in log events.
|
|
9
|
+
*/
|
|
10
|
+
export function setSentryContext(ctx) {
|
|
11
|
+
if (ctx.user?.id) {
|
|
12
|
+
Sentry.setUser({
|
|
13
|
+
id: ctx.user.id,
|
|
14
|
+
email: ctx.user.email ?? undefined,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (ctx.project?.id) {
|
|
18
|
+
Sentry.setContext('project', {
|
|
19
|
+
id: ctx.project.id,
|
|
20
|
+
title: ctx.project.title ?? undefined,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (ctx.org?.id) {
|
|
24
|
+
Sentry.setContext('org', {
|
|
25
|
+
id: ctx.org.id,
|
|
26
|
+
title: ctx.org.title ?? undefined,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (ctx.embeddable?.id) {
|
|
30
|
+
Sentry.setContext('embeddable', {
|
|
31
|
+
id: ctx.embeddable.id,
|
|
32
|
+
title: ctx.embeddable.title ?? undefined,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (ctx.branch?.id) {
|
|
36
|
+
Sentry.setContext('branch', {
|
|
37
|
+
id: ctx.branch.id,
|
|
38
|
+
name: ctx.branch.name ?? undefined,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (ctx.versionNumber != null && !isNaN(ctx.versionNumber)) {
|
|
42
|
+
Sentry.setContext('version', { versionNumber: ctx.versionNumber });
|
|
43
|
+
}
|
|
44
|
+
// Scope attributes are included in log events; only string/number/boolean are supported
|
|
45
|
+
const scope = Sentry.getCurrentScope();
|
|
46
|
+
const attrs = {};
|
|
47
|
+
if (ctx.project?.id) {
|
|
48
|
+
attrs.projectId = ctx.project.id;
|
|
49
|
+
if (ctx.project.title != null)
|
|
50
|
+
attrs.projectTitle = String(ctx.project.title);
|
|
51
|
+
}
|
|
52
|
+
if (ctx.org?.id) {
|
|
53
|
+
attrs.orgId = ctx.org.id;
|
|
54
|
+
if (ctx.org.title != null)
|
|
55
|
+
attrs.orgTitle = String(ctx.org.title);
|
|
56
|
+
}
|
|
57
|
+
if (ctx.embeddable?.id) {
|
|
58
|
+
attrs.embeddableId = ctx.embeddable.id;
|
|
59
|
+
if (ctx.embeddable.title != null)
|
|
60
|
+
attrs.embeddableTitle = String(ctx.embeddable.title);
|
|
61
|
+
}
|
|
62
|
+
if (ctx.branch?.id) {
|
|
63
|
+
attrs.branchId = ctx.branch.id;
|
|
64
|
+
if (ctx.branch.name != null)
|
|
65
|
+
attrs.branchName = String(ctx.branch.name);
|
|
66
|
+
}
|
|
67
|
+
if (ctx.versionNumber != null && !isNaN(ctx.versionNumber)) {
|
|
68
|
+
attrs.versionNumber = ctx.versionNumber;
|
|
69
|
+
}
|
|
70
|
+
if (Object.keys(attrs).length > 0) {
|
|
71
|
+
scope.setAttributes(attrs);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Return project and org context from embeddables.json when present.
|
|
76
|
+
*/
|
|
77
|
+
export function getSentryContextFromProjectConfig() {
|
|
78
|
+
const config = readProjectConfig();
|
|
79
|
+
if (!config)
|
|
80
|
+
return {};
|
|
81
|
+
const out = {};
|
|
82
|
+
if (config.project_id) {
|
|
83
|
+
out.project = { id: config.project_id, title: config.project_name ?? null };
|
|
84
|
+
}
|
|
85
|
+
if (config.org_id) {
|
|
86
|
+
out.org = { id: config.org_id, title: config.org_title ?? null };
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Return embeddable title (from metadata.json), branch and versionNumber (from config.json)
|
|
92
|
+
* for embeddables/{embeddableId}/ when present.
|
|
93
|
+
*/
|
|
94
|
+
export function getSentryContextFromEmbeddableConfig(embeddableId) {
|
|
95
|
+
const out = {};
|
|
96
|
+
const embeddableDir = path.join('embeddables', embeddableId);
|
|
97
|
+
// Embeddable title from metadata.json (written by pull)
|
|
98
|
+
const metadataPath = path.join(embeddableDir, 'metadata.json');
|
|
99
|
+
if (fs.existsSync(metadataPath)) {
|
|
100
|
+
try {
|
|
101
|
+
const metadata = JSON.parse(fs.readFileSync(metadataPath, 'utf8'));
|
|
102
|
+
const title = metadata.title;
|
|
103
|
+
if (typeof title === 'string' && title) {
|
|
104
|
+
out.embeddable = { id: embeddableId, title };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// ignore
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (!out.embeddable) {
|
|
112
|
+
out.embeddable = { id: embeddableId };
|
|
113
|
+
}
|
|
114
|
+
const configPath = path.join(embeddableDir, 'config.json');
|
|
115
|
+
if (!fs.existsSync(configPath))
|
|
116
|
+
return out;
|
|
117
|
+
try {
|
|
118
|
+
const raw = fs.readFileSync(configPath, 'utf8');
|
|
119
|
+
const config = JSON.parse(raw);
|
|
120
|
+
const branchId = config._branch_id;
|
|
121
|
+
if (typeof branchId === 'string' && branchId) {
|
|
122
|
+
const branchName = config._branch_name;
|
|
123
|
+
out.branch = {
|
|
124
|
+
id: branchId,
|
|
125
|
+
name: typeof branchName === 'string' ? branchName : null,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
else if (config._version != null) {
|
|
129
|
+
// Config was written by pull; no _branch_id means we're on main
|
|
130
|
+
out.branch = { id: 'main', name: 'main' };
|
|
131
|
+
}
|
|
132
|
+
const ver = config._version;
|
|
133
|
+
if (typeof ver === 'number' && !isNaN(ver)) {
|
|
134
|
+
out.versionNumber = ver;
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Set Sentry user from auth when logged in. Call after requireLogin for commands that need user context.
|
|
144
|
+
*/
|
|
145
|
+
export async function setSentryUserFromAuth() {
|
|
146
|
+
const { getAuthenticatedSupabaseClient } = await import('./auth/index.js');
|
|
147
|
+
const supabase = await getAuthenticatedSupabaseClient();
|
|
148
|
+
if (!supabase)
|
|
149
|
+
return;
|
|
150
|
+
const { data: { user }, } = await supabase.auth.getUser();
|
|
151
|
+
if (user?.id) {
|
|
152
|
+
setSentryContext({
|
|
153
|
+
user: { id: user.id, email: user.email ?? null },
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
package/dist/stdout.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type Ora } from 'ora';
|
|
2
|
+
import { type Options as BoxenOptions } from 'boxen';
|
|
3
|
+
/** Suppress all print/dim/step output. Used to silence verbose compiler output. */
|
|
4
|
+
export declare function mute(): void;
|
|
5
|
+
export declare function unmute(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Write a line to stdout. Use this for all user-facing CLI terminal output.
|
|
8
|
+
* Replaces console.log so that user-facing output and observability logging
|
|
9
|
+
* (logger.info → Sentry) are clearly distinct in the code.
|
|
10
|
+
*/
|
|
11
|
+
export declare function print(message?: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Write a warning line to stdout with a yellow WARN badge.
|
|
14
|
+
* Replaces console.warn.
|
|
15
|
+
*/
|
|
16
|
+
export declare function warn(message: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Write an error line to stderr with a red ERROR badge.
|
|
19
|
+
* Replaces console.error.
|
|
20
|
+
*/
|
|
21
|
+
export declare function error(message: string): void;
|
|
22
|
+
export declare const symbols: {
|
|
23
|
+
readonly success: string;
|
|
24
|
+
readonly error: string;
|
|
25
|
+
readonly warning: string;
|
|
26
|
+
readonly info: string;
|
|
27
|
+
readonly sparkles: "✨";
|
|
28
|
+
readonly rocket: "🚀";
|
|
29
|
+
readonly bolt: "⚡";
|
|
30
|
+
readonly wave: "👋";
|
|
31
|
+
readonly branch: "🌿";
|
|
32
|
+
readonly key: "🔑";
|
|
33
|
+
readonly package: "📦";
|
|
34
|
+
readonly globe: "🌐";
|
|
35
|
+
};
|
|
36
|
+
export declare function spinner(text: string): Ora;
|
|
37
|
+
export declare function withSpinner<T>(text: string, fn: (s: Ora) => Promise<T>, opts?: {
|
|
38
|
+
successText?: string | ((result: T) => string);
|
|
39
|
+
failText?: string;
|
|
40
|
+
}): Promise<T>;
|
|
41
|
+
export declare function success(msg: string): void;
|
|
42
|
+
export declare function step(msg: string): void;
|
|
43
|
+
export declare function header(title: string, subtitle?: string): void;
|
|
44
|
+
export declare function dim(msg: string): void;
|
|
45
|
+
export declare function gap(): void;
|
|
46
|
+
export declare function box(content: string, opts?: Partial<BoxenOptions> & {
|
|
47
|
+
title?: string;
|
|
48
|
+
}): void;
|
|
49
|
+
/** Green box for final success/completion messages. */
|
|
50
|
+
export declare function successBox(content: string, opts?: {
|
|
51
|
+
title?: string;
|
|
52
|
+
}): void;
|
|
53
|
+
/** Gray/dim box for contextual info (ID, branch, version). */
|
|
54
|
+
export declare function infoBox(content: string): void;
|
|
55
|
+
export declare function separator(): void;
|
|
56
|
+
export declare function timer(): () => string;
|
|
57
|
+
export declare function fileTree(root: string, entries: string[]): void;
|
|
58
|
+
export declare function kvRow(pairs: [string, string][]): void;
|
|
59
|
+
export declare function kvBlock(pairs: [string, string][]): void;
|
|
60
|
+
export declare function randomMessage(pool: string): string;
|
|
61
|
+
//# sourceMappingURL=stdout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdout.d.ts","sourceRoot":"","sources":["../src/stdout.ts"],"names":[],"mappings":"AACA,OAAY,EAAE,KAAK,GAAG,EAAE,MA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AAC,YAAY,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAU5F;AAED,uDAAuD;AACvD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAE3E;AAED,8DAA8D;AAC9D,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAM7C;AAED,wBAAgB,SAAS,IAAI,IAAI,CAGhC;AAID,wBAAgB,KAAK,IAAI,MAAM,MAAM,CAMpC;AAID,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAO9D;AAID,wBAAgB,KAAK,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAGrD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAMvD;AAWD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlD"}
|
package/dist/stdout.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import pc from 'picocolors';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import logSymbols from 'log-symbols';
|
|
4
|
+
import boxen from 'boxen';
|
|
5
|
+
let _muted = false;
|
|
6
|
+
/** Suppress all print/dim/step output. Used to silence verbose compiler output. */
|
|
7
|
+
export function mute() {
|
|
8
|
+
_muted = true;
|
|
9
|
+
}
|
|
10
|
+
export function unmute() {
|
|
11
|
+
_muted = false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Write a line to stdout. Use this for all user-facing CLI terminal output.
|
|
15
|
+
* Replaces console.log so that user-facing output and observability logging
|
|
16
|
+
* (logger.info → Sentry) are clearly distinct in the code.
|
|
17
|
+
*/
|
|
18
|
+
export function print(message = '') {
|
|
19
|
+
if (_muted)
|
|
20
|
+
return;
|
|
21
|
+
process.stdout.write(message + '\n');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Write a warning line to stdout with a yellow WARN badge.
|
|
25
|
+
* Replaces console.warn.
|
|
26
|
+
*/
|
|
27
|
+
export function warn(message) {
|
|
28
|
+
process.stdout.write(`${logSymbols.warning} ${pc.yellow(message)}\n`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Write an error line to stderr with a red ERROR badge.
|
|
32
|
+
* Replaces console.error.
|
|
33
|
+
*/
|
|
34
|
+
export function error(message) {
|
|
35
|
+
process.stderr.write(`${logSymbols.error} ${pc.red(message)}\n`);
|
|
36
|
+
}
|
|
37
|
+
// ─── Symbols ────────────────────────────────────────────────────────────────
|
|
38
|
+
export const symbols = {
|
|
39
|
+
success: logSymbols.success,
|
|
40
|
+
error: logSymbols.error,
|
|
41
|
+
warning: logSymbols.warning,
|
|
42
|
+
info: logSymbols.info,
|
|
43
|
+
sparkles: '✨',
|
|
44
|
+
rocket: '🚀',
|
|
45
|
+
bolt: '⚡',
|
|
46
|
+
wave: '👋',
|
|
47
|
+
branch: '🌿',
|
|
48
|
+
key: '🔑',
|
|
49
|
+
package: '📦',
|
|
50
|
+
globe: '🌐',
|
|
51
|
+
};
|
|
52
|
+
// ─── Spinners ───────────────────────────────────────────────────────────────
|
|
53
|
+
export function spinner(text) {
|
|
54
|
+
return ora({ text, spinner: 'dots' }).start();
|
|
55
|
+
}
|
|
56
|
+
export async function withSpinner(text, fn, opts) {
|
|
57
|
+
const s = spinner(text);
|
|
58
|
+
try {
|
|
59
|
+
const result = await fn(s);
|
|
60
|
+
const successMsg = opts?.successText
|
|
61
|
+
? typeof opts.successText === 'function'
|
|
62
|
+
? opts.successText(result)
|
|
63
|
+
: opts.successText
|
|
64
|
+
: text;
|
|
65
|
+
s.succeed(successMsg);
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
s.fail(opts?.failText ?? (err instanceof Error ? err.message : String(err)));
|
|
70
|
+
throw err;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// ─── Output helpers ─────────────────────────────────────────────────────────
|
|
74
|
+
export function success(msg) {
|
|
75
|
+
print(`${logSymbols.success} ${msg}`);
|
|
76
|
+
}
|
|
77
|
+
export function step(msg) {
|
|
78
|
+
print(`${logSymbols.info} ${msg}`);
|
|
79
|
+
}
|
|
80
|
+
export function header(title, subtitle) {
|
|
81
|
+
print('');
|
|
82
|
+
print(` ${pc.bold(pc.cyan(title))}`);
|
|
83
|
+
if (subtitle)
|
|
84
|
+
print(` ${pc.gray(subtitle)}`);
|
|
85
|
+
print('');
|
|
86
|
+
}
|
|
87
|
+
export function dim(msg) {
|
|
88
|
+
if (_muted)
|
|
89
|
+
return;
|
|
90
|
+
print(pc.gray(msg));
|
|
91
|
+
}
|
|
92
|
+
export function gap() {
|
|
93
|
+
print('');
|
|
94
|
+
}
|
|
95
|
+
export function box(content, opts) {
|
|
96
|
+
const defaults = {
|
|
97
|
+
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
98
|
+
margin: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
99
|
+
borderStyle: 'round',
|
|
100
|
+
borderColor: 'cyan',
|
|
101
|
+
...(opts?.title ? { title: opts.title, titleAlignment: 'left' } : {}),
|
|
102
|
+
};
|
|
103
|
+
const merged = { ...defaults, ...opts };
|
|
104
|
+
print(boxen(content, merged));
|
|
105
|
+
}
|
|
106
|
+
/** Green box for final success/completion messages. */
|
|
107
|
+
export function successBox(content, opts) {
|
|
108
|
+
box(content, { borderColor: 'green', title: opts?.title, ...opts });
|
|
109
|
+
}
|
|
110
|
+
/** Gray/dim box for contextual info (ID, branch, version). */
|
|
111
|
+
export function infoBox(content) {
|
|
112
|
+
box(content, {
|
|
113
|
+
borderColor: 'gray',
|
|
114
|
+
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
115
|
+
margin: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
export function separator() {
|
|
119
|
+
const width = Math.min(process.stdout.columns || 60, 60);
|
|
120
|
+
print(pc.cyan('━'.repeat(width)));
|
|
121
|
+
}
|
|
122
|
+
// ─── Timer ──────────────────────────────────────────────────────────────────
|
|
123
|
+
export function timer() {
|
|
124
|
+
const start = performance.now();
|
|
125
|
+
return () => {
|
|
126
|
+
const ms = performance.now() - start;
|
|
127
|
+
return ms >= 1000 ? `${(ms / 1000).toFixed(1)}s` : `${Math.round(ms)}ms`;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
// ─── File tree ──────────────────────────────────────────────────────────────
|
|
131
|
+
export function fileTree(root, entries) {
|
|
132
|
+
print(pc.bold(root));
|
|
133
|
+
for (let i = 0; i < entries.length; i++) {
|
|
134
|
+
const isLast = i === entries.length - 1;
|
|
135
|
+
const prefix = isLast ? '└── ' : '├── ';
|
|
136
|
+
print(pc.gray(`${prefix}${entries[i]}`));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// ─── Key-value display ──────────────────────────────────────────────────────
|
|
140
|
+
export function kvRow(pairs) {
|
|
141
|
+
const parts = pairs.map(([k, v]) => `${pc.gray(k + ':')} ${pc.white(v)}`);
|
|
142
|
+
print(parts.join(pc.gray(' · ')));
|
|
143
|
+
}
|
|
144
|
+
export function kvBlock(pairs) {
|
|
145
|
+
const maxKeyLen = Math.max(...pairs.map(([k]) => k.length));
|
|
146
|
+
for (const [k, v] of pairs) {
|
|
147
|
+
const paddedKey = k.padStart(maxKeyLen);
|
|
148
|
+
print(` ${pc.gray(paddedKey + ':')} ${pc.white(v)}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// ─── Whimsical messages ─────────────────────────────────────────────────────
|
|
152
|
+
const MESSAGE_POOLS = {
|
|
153
|
+
build: ['Looking good!', 'Nailed it.', 'Compiled to perfection.'],
|
|
154
|
+
save: ['Saved and sealed.', 'Shipped it!', 'Up in the cloud where it belongs.'],
|
|
155
|
+
pull: ['Fresh code, who dis?', 'Hot off the server.', 'Synced up and ready.'],
|
|
156
|
+
login: ['Welcome back!', "You're in!", 'Authenticated and ready to roll.'],
|
|
157
|
+
};
|
|
158
|
+
export function randomMessage(pool) {
|
|
159
|
+
const messages = MESSAGE_POOLS[pool];
|
|
160
|
+
if (!messages || messages.length === 0)
|
|
161
|
+
return '';
|
|
162
|
+
return messages[Math.floor(Math.random() * messages.length)];
|
|
163
|
+
}
|