@embeddables/cli 0.7.13 → 0.7.14
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/custom/build-funnel.md +1 -1
- package/.prompts/embeddables-cli.md +9 -2
- package/package.json +1 -1
- package/dist/auth/index.d.ts +0 -43
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -102
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -174
- package/dist/commands/branch.d.ts +0 -4
- package/dist/commands/branch.d.ts.map +0 -1
- package/dist/commands/branch.js +0 -68
- package/dist/commands/build-workbench.d.ts +0 -5
- package/dist/commands/build-workbench.d.ts.map +0 -1
- package/dist/commands/build-workbench.js +0 -128
- package/dist/commands/build.d.ts +0 -8
- package/dist/commands/build.d.ts.map +0 -1
- package/dist/commands/build.js +0 -55
- package/dist/commands/dev.d.ts +0 -12
- package/dist/commands/dev.d.ts.map +0 -1
- package/dist/commands/dev.js +0 -221
- package/dist/commands/experiments-connect.d.ts +0 -6
- package/dist/commands/experiments-connect.d.ts.map +0 -1
- package/dist/commands/experiments-connect.js +0 -140
- package/dist/commands/init.d.ts +0 -5
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -327
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -122
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js +0 -22
- package/dist/commands/pull.d.ts +0 -14
- package/dist/commands/pull.d.ts.map +0 -1
- package/dist/commands/pull.js +0 -383
- package/dist/commands/save.d.ts +0 -30
- package/dist/commands/save.d.ts.map +0 -1
- package/dist/commands/save.js +0 -591
- package/dist/commands/upgrade.d.ts +0 -2
- package/dist/commands/upgrade.d.ts.map +0 -1
- package/dist/commands/upgrade.js +0 -51
- package/dist/compiler/errors.d.ts +0 -20
- package/dist/compiler/errors.d.ts.map +0 -1
- package/dist/compiler/errors.js +0 -35
- package/dist/compiler/evalStatic.d.ts +0 -3
- package/dist/compiler/evalStatic.d.ts.map +0 -1
- package/dist/compiler/evalStatic.js +0 -57
- package/dist/compiler/flatten.js +0 -1
- package/dist/compiler/helpers/duplicateIds.d.ts +0 -9
- package/dist/compiler/helpers/duplicateIds.d.ts.map +0 -1
- package/dist/compiler/helpers/duplicateIds.js +0 -71
- package/dist/compiler/helpers/numericLeadingKeys.d.ts +0 -8
- package/dist/compiler/helpers/numericLeadingKeys.d.ts.map +0 -1
- package/dist/compiler/helpers/numericLeadingKeys.js +0 -17
- package/dist/compiler/index.d.ts +0 -18
- package/dist/compiler/index.d.ts.map +0 -1
- package/dist/compiler/index.js +0 -1245
- package/dist/compiler/parsePage.d.ts +0 -15
- package/dist/compiler/parsePage.d.ts.map +0 -1
- package/dist/compiler/parsePage.js +0 -631
- package/dist/compiler/registry.d.ts +0 -4
- package/dist/compiler/registry.d.ts.map +0 -1
- package/dist/compiler/registry.js +0 -44
- package/dist/compiler/reverse.d.ts +0 -23
- package/dist/compiler/reverse.d.ts.map +0 -1
- package/dist/compiler/reverse.js +0 -1875
- package/dist/compiler/types.d.ts +0 -21
- package/dist/compiler/types.d.ts.map +0 -1
- package/dist/compiler/types.js +0 -1
- package/dist/components/index.d.ts +0 -21
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/index.js +0 -21
- package/dist/components/primitives/BaseComponent.d.ts +0 -32
- package/dist/components/primitives/BaseComponent.d.ts.map +0 -1
- package/dist/components/primitives/BaseComponent.js +0 -26
- package/dist/components/primitives/BookMeeting.d.ts +0 -18
- package/dist/components/primitives/BookMeeting.d.ts.map +0 -1
- package/dist/components/primitives/BookMeeting.js +0 -5
- package/dist/components/primitives/Chart.d.ts +0 -41
- package/dist/components/primitives/Chart.d.ts.map +0 -1
- package/dist/components/primitives/Chart.js +0 -5
- package/dist/components/primitives/Container.d.ts +0 -8
- package/dist/components/primitives/Container.d.ts.map +0 -1
- package/dist/components/primitives/Container.js +0 -5
- package/dist/components/primitives/CustomButton.d.ts +0 -37
- package/dist/components/primitives/CustomButton.d.ts.map +0 -1
- package/dist/components/primitives/CustomButton.js +0 -10
- package/dist/components/primitives/CustomHTML.d.ts +0 -8
- package/dist/components/primitives/CustomHTML.d.ts.map +0 -1
- package/dist/components/primitives/CustomHTML.js +0 -5
- package/dist/components/primitives/FileUpload.d.ts +0 -18
- package/dist/components/primitives/FileUpload.d.ts.map +0 -1
- package/dist/components/primitives/FileUpload.js +0 -16
- package/dist/components/primitives/InputBox.d.ts +0 -34
- package/dist/components/primitives/InputBox.d.ts.map +0 -1
- package/dist/components/primitives/InputBox.js +0 -25
- package/dist/components/primitives/Lottie.d.ts +0 -11
- package/dist/components/primitives/Lottie.d.ts.map +0 -1
- package/dist/components/primitives/Lottie.js +0 -5
- package/dist/components/primitives/MediaEmbed.d.ts +0 -13
- package/dist/components/primitives/MediaEmbed.d.ts.map +0 -1
- package/dist/components/primitives/MediaEmbed.js +0 -6
- package/dist/components/primitives/MediaImage.d.ts +0 -8
- package/dist/components/primitives/MediaImage.d.ts.map +0 -1
- package/dist/components/primitives/MediaImage.js +0 -5
- package/dist/components/primitives/OptionSelector.d.ts +0 -35
- package/dist/components/primitives/OptionSelector.d.ts.map +0 -1
- package/dist/components/primitives/OptionSelector.js +0 -8
- package/dist/components/primitives/PaypalCheckout.d.ts +0 -25
- package/dist/components/primitives/PaypalCheckout.d.ts.map +0 -1
- package/dist/components/primitives/PaypalCheckout.js +0 -5
- package/dist/components/primitives/PlainText.d.ts +0 -6
- package/dist/components/primitives/PlainText.d.ts.map +0 -1
- package/dist/components/primitives/PlainText.js +0 -5
- package/dist/components/primitives/ProgressBar.d.ts +0 -15
- package/dist/components/primitives/ProgressBar.d.ts.map +0 -1
- package/dist/components/primitives/ProgressBar.js +0 -5
- package/dist/components/primitives/RichText.d.ts +0 -6
- package/dist/components/primitives/RichText.d.ts.map +0 -1
- package/dist/components/primitives/RichText.js +0 -5
- package/dist/components/primitives/RichTextMarkdown.d.ts +0 -6
- package/dist/components/primitives/RichTextMarkdown.d.ts.map +0 -1
- package/dist/components/primitives/RichTextMarkdown.js +0 -5
- package/dist/components/primitives/Rive.d.ts +0 -16
- package/dist/components/primitives/Rive.d.ts.map +0 -1
- package/dist/components/primitives/Rive.js +0 -8
- package/dist/components/primitives/StripeCheckout.d.ts +0 -52
- package/dist/components/primitives/StripeCheckout.d.ts.map +0 -1
- package/dist/components/primitives/StripeCheckout.js +0 -5
- package/dist/components/primitives/StripeCheckout2.d.ts +0 -30
- package/dist/components/primitives/StripeCheckout2.d.ts.map +0 -1
- package/dist/components/primitives/StripeCheckout2.js +0 -7
- package/dist/config/index.d.ts +0 -23
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -42
- package/dist/constants.d.ts +0 -9
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -9
- package/dist/helpers/TEMP helpers file.d.ts +0 -1
- package/dist/helpers/TEMP helpers file.d.ts.map +0 -1
- package/dist/helpers/TEMP helpers file.js +0 -1
- package/dist/helpers/dates.d.ts +0 -5
- package/dist/helpers/dates.d.ts.map +0 -1
- package/dist/helpers/dates.js +0 -7
- package/dist/helpers/json.d.ts +0 -47
- package/dist/helpers/json.d.ts.map +0 -1
- package/dist/helpers/json.js +0 -622
- package/dist/helpers/utils.d.ts +0 -13
- package/dist/helpers/utils.d.ts.map +0 -1
- package/dist/helpers/utils.js +0 -28
- package/dist/logger.d.ts +0 -11
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -21
- package/dist/prompts/branches.d.ts +0 -20
- package/dist/prompts/branches.d.ts.map +0 -1
- package/dist/prompts/branches.js +0 -90
- package/dist/prompts/embeddables.d.ts +0 -43
- package/dist/prompts/embeddables.d.ts.map +0 -1
- package/dist/prompts/embeddables.js +0 -198
- package/dist/prompts/experiments.d.ts +0 -28
- package/dist/prompts/experiments.d.ts.map +0 -1
- package/dist/prompts/experiments.js +0 -87
- package/dist/prompts/index.d.ts +0 -11
- package/dist/prompts/index.d.ts.map +0 -1
- package/dist/prompts/index.js +0 -6
- package/dist/prompts/projects.d.ts +0 -22
- package/dist/prompts/projects.d.ts.map +0 -1
- package/dist/prompts/projects.js +0 -86
- package/dist/prompts/versions.d.ts +0 -18
- package/dist/prompts/versions.d.ts.map +0 -1
- package/dist/prompts/versions.js +0 -99
- package/dist/proxy/injectApiInterceptor.d.ts +0 -6
- package/dist/proxy/injectApiInterceptor.d.ts.map +0 -1
- package/dist/proxy/injectApiInterceptor.js +0 -66
- package/dist/proxy/injectReload.d.ts +0 -2
- package/dist/proxy/injectReload.d.ts.map +0 -1
- package/dist/proxy/injectReload.js +0 -14
- package/dist/proxy/injectWorkbench.d.ts +0 -5
- package/dist/proxy/injectWorkbench.d.ts.map +0 -1
- package/dist/proxy/injectWorkbench.js +0 -22
- package/dist/proxy/server.d.ts +0 -11
- package/dist/proxy/server.d.ts.map +0 -1
- package/dist/proxy/server.js +0 -316
- package/dist/proxy/sse.d.ts +0 -5
- package/dist/proxy/sse.d.ts.map +0 -1
- package/dist/proxy/sse.js +0 -17
- package/dist/sentry-context.d.ts +0 -48
- package/dist/sentry-context.d.ts.map +0 -1
- package/dist/sentry-context.js +0 -156
- package/dist/stdout.d.ts +0 -17
- package/dist/stdout.d.ts.map +0 -1
- package/dist/stdout.js +0 -23
- package/dist/types-builder.d.ts +0 -800
- package/dist/types-builder.d.ts.map +0 -1
- package/dist/types-builder.js +0 -20
- package/dist/workbench/ActionsPanel.d.ts +0 -6
- package/dist/workbench/ActionsPanel.d.ts.map +0 -1
- package/dist/workbench/ActionsPanel.js +0 -47
- package/dist/workbench/AutofillPanel.d.ts +0 -6
- package/dist/workbench/AutofillPanel.d.ts.map +0 -1
- package/dist/workbench/AutofillPanel.js +0 -543
- package/dist/workbench/ComputedFieldsPanel.d.ts +0 -6
- package/dist/workbench/ComputedFieldsPanel.d.ts.map +0 -1
- package/dist/workbench/ComputedFieldsPanel.js +0 -31
- package/dist/workbench/ExperimentsPanel.d.ts +0 -6
- package/dist/workbench/ExperimentsPanel.d.ts.map +0 -1
- package/dist/workbench/ExperimentsPanel.js +0 -182
- package/dist/workbench/FieldEditorPanel.d.ts +0 -9
- package/dist/workbench/FieldEditorPanel.d.ts.map +0 -1
- package/dist/workbench/FieldEditorPanel.js +0 -650
- package/dist/workbench/InspectorPanel.d.ts +0 -6
- package/dist/workbench/InspectorPanel.d.ts.map +0 -1
- package/dist/workbench/InspectorPanel.js +0 -341
- package/dist/workbench/PageNavigator.d.ts +0 -6
- package/dist/workbench/PageNavigator.d.ts.map +0 -1
- package/dist/workbench/PageNavigator.js +0 -123
- package/dist/workbench/SchemaPanel.d.ts +0 -6
- package/dist/workbench/SchemaPanel.d.ts.map +0 -1
- package/dist/workbench/SchemaPanel.js +0 -222
- package/dist/workbench/UserDataPanel.d.ts +0 -6
- package/dist/workbench/UserDataPanel.d.ts.map +0 -1
- package/dist/workbench/UserDataPanel.js +0 -350
- package/dist/workbench/WorkbenchApp.d.ts +0 -7
- package/dist/workbench/WorkbenchApp.d.ts.map +0 -1
- package/dist/workbench/WorkbenchApp.js +0 -193
- package/dist/workbench/cloudflare-worker/README.md +0 -31
- package/dist/workbench/cloudflare-worker/public/workbench.css +0 -1614
- package/dist/workbench/cloudflare-worker/public/workbench.js +0 -77
- package/dist/workbench/cloudflare-worker/worker.js +0 -40
- package/dist/workbench/cloudflare-worker/wrangler.toml +0 -10
- package/dist/workbench/index.d.ts +0 -10
- package/dist/workbench/index.d.ts.map +0 -1
- package/dist/workbench/index.js +0 -44
- package/dist/workbench/workbench.css +0 -1614
- package/dist/workbench/workbench.js +0 -77
|
@@ -2,7 +2,7 @@ We need to build the pages from the attached images. Please create a plan and hi
|
|
|
2
2
|
|
|
3
3
|
Embeddable ID: <EMBEDDABLE_ID>
|
|
4
4
|
|
|
5
|
-
Important: Always read the Embeddables CLI context before starting (e.g. @.cursor/rules/embeddables-cli.md
|
|
5
|
+
Important: Always read the Embeddables CLI context before starting (e.g. @.cursor/rules/embeddables-cli.md, @.claude/embeddables-cli.md, or @AGENTS.md depending on your editor).
|
|
6
6
|
|
|
7
7
|
[KEEP / REMOVE]
|
|
8
8
|
Use the designs from the images but use the content from the attached document instead, and build out the pages based on that content. Therefore, when using the designs from the images, for each page just find the most relevant design for the page's content and design it based on that. However, don't be confined to the provided designs - just find the closest design and modify it to fit the content required.
|
|
@@ -498,6 +498,13 @@ function output() {
|
|
|
498
498
|
|
|
499
499
|
Conditions control visibility of components and pages based on User Data. The `Condition`, `ConditionOperator`, `ConditionValue`, and `ConditionalTag` types are defined in `src/types-builder.ts`.
|
|
500
500
|
|
|
501
|
+
**Key Properties**:
|
|
502
|
+
|
|
503
|
+
- `id: string` - Required unique identifier. Use the `cond_` prefix + 10 digits (e.g. `cond_1234567890`). Must be unique across the flow.
|
|
504
|
+
- `key: string` - The User Data key to evaluate
|
|
505
|
+
- `operator: ConditionOperator` - The comparison operator
|
|
506
|
+
- `values: ConditionValue[]` - The values to compare against
|
|
507
|
+
|
|
501
508
|
**Valid Operators** (`ConditionOperator`):
|
|
502
509
|
|
|
503
510
|
- `==` - equals (with multiple values = OR)
|
|
@@ -525,7 +532,7 @@ When visibility is gated by an experiment (a key in `connected_experiments`, oth
|
|
|
525
532
|
|
|
526
533
|
#1 and #2 should be on the same conditions as each other, whereas all other variants (#3) can be on other conditions.
|
|
527
534
|
|
|
528
|
-
Example: for experiment key `hero_test` with variants `control` and `variant_b`, the control experience might use a condition like `key: "hero_test", operator: "==", values: ["control", "_no_value"]` so both control users and users with no assignment see the control. The variant experience would use `values: ["variant_b"]`.
|
|
535
|
+
Example: for experiment key `hero_test` with variants `control` and `variant_b`, the control experience might use a condition like `id: "cond_0000000001", key: "hero_test", operator: "==", values: ["control", "_no_value"]` so both control users and users with no assignment see the control. The variant experience would use `id: "cond_0000000002", values: ["variant_b"]`.
|
|
529
536
|
|
|
530
537
|
## Config.json Structure
|
|
531
538
|
|
|
@@ -687,7 +694,7 @@ The `config.json` file contains the reduced Embeddable JSON with:
|
|
|
687
694
|
|
|
688
695
|
## Important Notes
|
|
689
696
|
|
|
690
|
-
- **IDs**: All components, pages, computed fields, actions, and buttons inside OptionSelectors have unique `id` properties. These are preserved in config.json and used for internal references, except for component and button ids which should always be written in React. **ID format**: Use a prefix plus 10 digits so generated IDs don't collide with real ones: pages → `page_` + 10 digits (e.g. `page_1234567890`); components → `comp_` + 10 digits; option buttons → `button_` prefix (e.g. `button_plan_basic`). Must be unique across the flow.
|
|
697
|
+
- **IDs**: All components, pages, computed fields, actions, conditions, and buttons inside OptionSelectors have unique `id` properties. These are preserved in config.json and used for internal references, except for component and button ids which should always be written in React. **ID format**: Use a prefix plus 10 digits so generated IDs don't collide with real ones: pages → `page_` + 10 digits (e.g. `page_1234567890`); components → `comp_` + 10 digits; conditions → `cond_` + 10 digits (e.g. `cond_1234567890`); option buttons → `button_` prefix (e.g. `button_plan_basic`). Must be unique across the flow.
|
|
691
698
|
|
|
692
699
|
- **Keys**: Component and page `key` properties are used for file naming and must be valid file names (no special characters, use underscores).
|
|
693
700
|
|
package/package.json
CHANGED
package/dist/auth/index.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
-
export declare const SUPABASE_URL = "https://ierxexdtyashuotcsjyo.supabase.co";
|
|
3
|
-
export declare const SUPABASE_ANON_KEY = "sb_publishable_Vt8-msWNtn2hhOY3AA6RsQ_ueTx79Vo";
|
|
4
|
-
export interface AuthConfig {
|
|
5
|
-
access_token: string;
|
|
6
|
-
refresh_token: string;
|
|
7
|
-
expires_at: number;
|
|
8
|
-
supabase_url: string;
|
|
9
|
-
supabase_anon_key: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Get the path to the auth config file
|
|
13
|
-
*/
|
|
14
|
-
export declare function getAuthFilePath(): string;
|
|
15
|
-
/**
|
|
16
|
-
* Read auth config from file
|
|
17
|
-
*/
|
|
18
|
-
export declare function readAuthConfig(): AuthConfig | null;
|
|
19
|
-
/**
|
|
20
|
-
* Write auth config to file
|
|
21
|
-
*/
|
|
22
|
-
export declare function writeAuthConfig(config: AuthConfig): void;
|
|
23
|
-
/**
|
|
24
|
-
* Delete auth config file (logout)
|
|
25
|
-
*/
|
|
26
|
-
export declare function deleteAuthConfig(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Check if user is logged in (has valid auth config)
|
|
29
|
-
*/
|
|
30
|
-
export declare function isLoggedIn(): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Get Supabase client instance
|
|
33
|
-
*/
|
|
34
|
-
export declare function getSupabaseClient(): SupabaseClient;
|
|
35
|
-
/**
|
|
36
|
-
* Get authenticated Supabase client (with stored session)
|
|
37
|
-
*/
|
|
38
|
-
export declare function getAuthenticatedSupabaseClient(): Promise<SupabaseClient | null>;
|
|
39
|
-
/**
|
|
40
|
-
* Get access token for authenticated requests
|
|
41
|
-
*/
|
|
42
|
-
export declare function getAccessToken(): string | null;
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/auth/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAGpE,eAAO,MAAM,YAAY,6CAA6C,CAAA;AACtE,eAAO,MAAM,iBAAiB,mDAAmD,CAAA;AAEjF,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,iBAAiB,EAAE,MAAM,CAAA;CAC1B;AAMD;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,UAAU,GAAG,IAAI,CAUlD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAGxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAIvC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAcpC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAWlD;AAED;;GAEG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAcrF;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAM9C"}
|
package/dist/auth/index.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { createClient } from '@supabase/supabase-js';
|
|
5
|
-
// TODO: Move to environment variables
|
|
6
|
-
export const SUPABASE_URL = 'https://ierxexdtyashuotcsjyo.supabase.co'; // Replace with actual Supabase URL
|
|
7
|
-
export const SUPABASE_ANON_KEY = 'sb_publishable_Vt8-msWNtn2hhOY3AA6RsQ_ueTx79Vo'; // Replace with actual Supabase anon key
|
|
8
|
-
// Store auth globally in user's home directory
|
|
9
|
-
const AUTH_DIR = path.join(os.homedir(), '.embeddables');
|
|
10
|
-
const AUTH_FILE = path.join(AUTH_DIR, 'auth.json');
|
|
11
|
-
/**
|
|
12
|
-
* Get the path to the auth config file
|
|
13
|
-
*/
|
|
14
|
-
export function getAuthFilePath() {
|
|
15
|
-
return AUTH_FILE;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Read auth config from file
|
|
19
|
-
*/
|
|
20
|
-
export function readAuthConfig() {
|
|
21
|
-
try {
|
|
22
|
-
if (!fs.existsSync(AUTH_FILE)) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
const content = fs.readFileSync(AUTH_FILE, 'utf8');
|
|
26
|
-
return JSON.parse(content);
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Write auth config to file
|
|
34
|
-
*/
|
|
35
|
-
export function writeAuthConfig(config) {
|
|
36
|
-
fs.mkdirSync(AUTH_DIR, { recursive: true });
|
|
37
|
-
fs.writeFileSync(AUTH_FILE, JSON.stringify(config, null, 2), 'utf8');
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Delete auth config file (logout)
|
|
41
|
-
*/
|
|
42
|
-
export function deleteAuthConfig() {
|
|
43
|
-
if (fs.existsSync(AUTH_FILE)) {
|
|
44
|
-
fs.unlinkSync(AUTH_FILE);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Check if user is logged in (has valid auth config)
|
|
49
|
-
*/
|
|
50
|
-
export function isLoggedIn() {
|
|
51
|
-
const config = readAuthConfig();
|
|
52
|
-
if (!config) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
// Check if token is expired (with 5 minute buffer)
|
|
56
|
-
const now = Math.floor(Date.now() / 1000);
|
|
57
|
-
const expiresAt = config.expires_at;
|
|
58
|
-
if (expiresAt && expiresAt < now + 300) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
return !!config.access_token;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Get Supabase client instance
|
|
65
|
-
*/
|
|
66
|
-
export function getSupabaseClient() {
|
|
67
|
-
const config = readAuthConfig();
|
|
68
|
-
const url = config?.supabase_url || SUPABASE_URL;
|
|
69
|
-
const anonKey = config?.supabase_anon_key || SUPABASE_ANON_KEY;
|
|
70
|
-
return createClient(url, anonKey, {
|
|
71
|
-
auth: {
|
|
72
|
-
persistSession: false, // We handle session persistence ourselves
|
|
73
|
-
autoRefreshToken: false, // No auto refresh for now
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Get authenticated Supabase client (with stored session)
|
|
79
|
-
*/
|
|
80
|
-
export async function getAuthenticatedSupabaseClient() {
|
|
81
|
-
const config = readAuthConfig();
|
|
82
|
-
if (!config || !isLoggedIn()) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
const client = getSupabaseClient();
|
|
86
|
-
// Set the session manually
|
|
87
|
-
await client.auth.setSession({
|
|
88
|
-
access_token: config.access_token,
|
|
89
|
-
refresh_token: config.refresh_token,
|
|
90
|
-
});
|
|
91
|
-
return client;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get access token for authenticated requests
|
|
95
|
-
*/
|
|
96
|
-
export function getAccessToken() {
|
|
97
|
-
const config = readAuthConfig();
|
|
98
|
-
if (!config || !isLoggedIn()) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
return config.access_token;
|
|
102
|
-
}
|
package/dist/cli.d.ts
DELETED
package/dist/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import * as Sentry from '@sentry/node';
|
|
2
|
-
Sentry.init({
|
|
3
|
-
dsn: 'https://1660165be6d73c50814963e5c6bbd5dc@o4510046767742976.ingest.us.sentry.io/4510908525379584',
|
|
4
|
-
tracesSampleRate: 1.0,
|
|
5
|
-
enableLogs: true,
|
|
6
|
-
// debug: true,
|
|
7
|
-
});
|
|
8
|
-
import { createRequire } from 'node:module';
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import { fileURLToPath } from 'node:url';
|
|
11
|
-
import { Command } from 'commander';
|
|
12
|
-
import pc from 'picocolors';
|
|
13
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
|
-
const require = createRequire(import.meta.url);
|
|
15
|
-
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
|
16
|
-
Sentry.getCurrentScope().setAttributes({ cliVersion: pkg.version });
|
|
17
|
-
import { isLoggedIn } from './auth/index.js';
|
|
18
|
-
import { getSentryContextFromProjectConfig, setSentryContext, setSentryUserFromAuth, } from './sentry-context.js';
|
|
19
|
-
import { runBranch } from './commands/branch.js';
|
|
20
|
-
import { runBuild } from './commands/build.js';
|
|
21
|
-
import { runDev } from './commands/dev.js';
|
|
22
|
-
import { runExperimentsConnect } from './commands/experiments-connect.js';
|
|
23
|
-
import { runInit } from './commands/init.js';
|
|
24
|
-
import { runLogin } from './commands/login.js';
|
|
25
|
-
import { runLogout } from './commands/logout.js';
|
|
26
|
-
import { runPull } from './commands/pull.js';
|
|
27
|
-
import { runSave } from './commands/save.js';
|
|
28
|
-
import { runUpgrade } from './commands/upgrade.js';
|
|
29
|
-
import { exit } from './logger.js';
|
|
30
|
-
import * as stdout from './stdout.js';
|
|
31
|
-
/** Only these commands may run without being logged in. All others require login. */
|
|
32
|
-
const COMMANDS_ALLOWED_WITHOUT_LOGIN = new Set(['login', 'logout', 'upgrade']);
|
|
33
|
-
async function requireLogin(commandName) {
|
|
34
|
-
const baseCommand = commandName.split(' ')[0];
|
|
35
|
-
if (COMMANDS_ALLOWED_WITHOUT_LOGIN.has(baseCommand))
|
|
36
|
-
return;
|
|
37
|
-
if (isLoggedIn())
|
|
38
|
-
return;
|
|
39
|
-
stdout.error(pc.red('Not logged in.'));
|
|
40
|
-
stdout.print(pc.gray('Run "embeddables login" first.'));
|
|
41
|
-
await exit(1);
|
|
42
|
-
}
|
|
43
|
-
/** Set Sentry context from config and auth for the current command. Config is set immediately; user is set in background so we don't block on auth. */
|
|
44
|
-
function setSentryContextForCommand() {
|
|
45
|
-
setSentryContext(getSentryContextFromProjectConfig());
|
|
46
|
-
void setSentryUserFromAuth();
|
|
47
|
-
}
|
|
48
|
-
const program = new Command();
|
|
49
|
-
program
|
|
50
|
-
.name('embeddables')
|
|
51
|
-
.description('Embeddables CLI')
|
|
52
|
-
.version(pkg.version, '-v, --version', 'Show CLI version');
|
|
53
|
-
program
|
|
54
|
-
.command('init')
|
|
55
|
-
.description('Initialize a new Embeddables project')
|
|
56
|
-
.option('-p, --project-id <id>', 'Embeddables project ID')
|
|
57
|
-
.option('-y, --yes', 'Skip prompts and use defaults')
|
|
58
|
-
.action(async (opts) => {
|
|
59
|
-
await requireLogin('init');
|
|
60
|
-
setSentryContextForCommand();
|
|
61
|
-
await runInit({ projectId: opts.projectId, yes: opts.yes });
|
|
62
|
-
});
|
|
63
|
-
program
|
|
64
|
-
.command('build')
|
|
65
|
-
.option('-i, --id <id>', 'Embeddable ID (will prompt if not provided)')
|
|
66
|
-
.option('-p, --pages <glob>', 'Pages glob')
|
|
67
|
-
.option('-o, --out <path>', 'Output json path')
|
|
68
|
-
.option('--fix', 'Apply lint fixes (duplicate IDs, keys/IDs starting with a number)')
|
|
69
|
-
.option('--pageKeyFrom <mode>', 'filename|export', 'filename')
|
|
70
|
-
.action(async (opts) => {
|
|
71
|
-
await requireLogin('build');
|
|
72
|
-
setSentryContextForCommand();
|
|
73
|
-
await runBuild(opts);
|
|
74
|
-
});
|
|
75
|
-
program
|
|
76
|
-
.command('dev')
|
|
77
|
-
.option('-i, --id <id>', 'Embeddable ID (will prompt if not provided)')
|
|
78
|
-
.option('-p, --pages <glob>', 'Pages glob')
|
|
79
|
-
.option('-o, --out <path>', 'Output json path')
|
|
80
|
-
.option('--fix', 'Apply lint fixes (duplicate IDs, keys/IDs starting with a number)')
|
|
81
|
-
.option('-L, --local', 'Use local engine (http://localhost:8787)')
|
|
82
|
-
.option('-e, --engine <url>', 'Engine origin', 'https://engine.embeddables.com')
|
|
83
|
-
.option('--port <n>', 'Dev proxy port', '3000')
|
|
84
|
-
.option('--overrideRoute <path>', 'Route to override in proxy (exact match, no wildcards yet)', '/init')
|
|
85
|
-
.option('--pageKeyFrom <mode>', 'filename|export', 'filename')
|
|
86
|
-
.action(async (opts) => {
|
|
87
|
-
await requireLogin('dev');
|
|
88
|
-
setSentryContextForCommand();
|
|
89
|
-
// --local flag overrides --engine to use local engine
|
|
90
|
-
if (opts.local) {
|
|
91
|
-
opts.engine = 'http://localhost:8787';
|
|
92
|
-
}
|
|
93
|
-
await runDev(opts);
|
|
94
|
-
});
|
|
95
|
-
program
|
|
96
|
-
.command('login')
|
|
97
|
-
.description('Login to Embeddables')
|
|
98
|
-
.action(async () => {
|
|
99
|
-
await runLogin();
|
|
100
|
-
});
|
|
101
|
-
program
|
|
102
|
-
.command('logout')
|
|
103
|
-
.description('Logout from Embeddables')
|
|
104
|
-
.action(async () => {
|
|
105
|
-
await runLogout();
|
|
106
|
-
});
|
|
107
|
-
program
|
|
108
|
-
.command('pull')
|
|
109
|
-
.description('Pull an embeddable from the cloud')
|
|
110
|
-
.option('-i, --id <id>', 'Embeddable ID to pull (interactive selection if not provided)')
|
|
111
|
-
.option('-o, --out <path>', 'Output json path')
|
|
112
|
-
.option('--version <version>', 'Version to pull (number or "latest"); if omitted, choose from 100 most recent')
|
|
113
|
-
.option('-b, --branch <branch_id>', 'Embeddable branch ID')
|
|
114
|
-
.option('-f, --fix', 'Fix by removing components missing required props (warn instead of error)')
|
|
115
|
-
.option('-p, --preserve', 'Preserve component order in config for forward compile')
|
|
116
|
-
.action(async (opts) => {
|
|
117
|
-
await requireLogin('pull');
|
|
118
|
-
setSentryContextForCommand();
|
|
119
|
-
await runPull({
|
|
120
|
-
...opts,
|
|
121
|
-
version: opts.version,
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
program
|
|
125
|
-
.command('save')
|
|
126
|
-
.description('Build and save an embeddable to the cloud')
|
|
127
|
-
.option('-i, --id <id>', 'Embeddable ID (will prompt if not provided)')
|
|
128
|
-
.option('-l, --label <label>', 'Human-readable label for this version')
|
|
129
|
-
.option('-b, --branch <branch_id>', 'Branch ID to save to')
|
|
130
|
-
.option('-s, --skip-build', 'Skip the build step and use existing compiled JSON')
|
|
131
|
-
.option('--from-version <number>', 'Base version number (auto-detected from local files if not provided)')
|
|
132
|
-
.action(async (opts) => {
|
|
133
|
-
await requireLogin('save');
|
|
134
|
-
setSentryContextForCommand();
|
|
135
|
-
await runSave({
|
|
136
|
-
id: opts.id,
|
|
137
|
-
label: opts.label,
|
|
138
|
-
branch: opts.branch,
|
|
139
|
-
skipBuild: opts.skipBuild,
|
|
140
|
-
fromVersion: opts.fromVersion,
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
program
|
|
144
|
-
.command('upgrade')
|
|
145
|
-
.description('Update the CLI to the latest stable version')
|
|
146
|
-
.action(async () => {
|
|
147
|
-
await runUpgrade();
|
|
148
|
-
});
|
|
149
|
-
program
|
|
150
|
-
.command('branch')
|
|
151
|
-
.description('Switch to a different branch of an embeddable')
|
|
152
|
-
.option('-i, --id <id>', 'Embeddable ID (will prompt if not provided)')
|
|
153
|
-
.action(async (opts) => {
|
|
154
|
-
await requireLogin('branch');
|
|
155
|
-
setSentryContextForCommand();
|
|
156
|
-
await runBranch(opts);
|
|
157
|
-
});
|
|
158
|
-
const experiments = program.command('experiments').description('Manage embeddable experiments');
|
|
159
|
-
experiments
|
|
160
|
-
.command('connect')
|
|
161
|
-
.description('Connect an experiment to an embeddable')
|
|
162
|
-
.option('-i, --id <id>', 'Embeddable ID (will prompt if not provided)')
|
|
163
|
-
.option('--experiment-id <id>', 'Experiment ID (will prompt to choose from project if not provided)')
|
|
164
|
-
.option('--experiment-key <key>', 'Experiment key (required if --experiment-id is set)')
|
|
165
|
-
.action(async (opts) => {
|
|
166
|
-
await requireLogin('experiments connect');
|
|
167
|
-
setSentryContextForCommand();
|
|
168
|
-
await runExperimentsConnect({
|
|
169
|
-
id: opts.id,
|
|
170
|
-
experimentId: opts.experimentId,
|
|
171
|
-
experimentKey: opts.experimentKey,
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
await program.parseAsync(process.argv);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/commands/branch.ts"],"names":[],"mappings":"AAYA,wBAAsB,SAAS,CAAC,IAAI,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,iBAoEpD"}
|
package/dist/commands/branch.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import pc from 'picocolors';
|
|
2
|
-
import { isLoggedIn } from '../auth/index.js';
|
|
3
|
-
import { runPull } from './pull.js';
|
|
4
|
-
import { promptForLocalEmbeddable, fetchBranches, promptForBranch } from '../prompts/index.js';
|
|
5
|
-
import { createLogger, exit } from '../logger.js';
|
|
6
|
-
import { getSentryContextFromProjectConfig, setSentryContext, } from '../sentry-context.js';
|
|
7
|
-
import * as stdout from '../stdout.js';
|
|
8
|
-
import { inferEmbeddableFromCwd } from '../helpers/utils.js';
|
|
9
|
-
export async function runBranch(opts) {
|
|
10
|
-
const logger = createLogger('runBranch');
|
|
11
|
-
// Check login status
|
|
12
|
-
if (!isLoggedIn()) {
|
|
13
|
-
stdout.error(pc.red('Not logged in.'));
|
|
14
|
-
stdout.print(pc.gray('Run "embeddables login" first.'));
|
|
15
|
-
logger.error('not logged in');
|
|
16
|
-
await exit(1);
|
|
17
|
-
}
|
|
18
|
-
// Get embeddable ID
|
|
19
|
-
const inferred = inferEmbeddableFromCwd();
|
|
20
|
-
let embeddableId = opts.id ?? inferred?.embeddableId;
|
|
21
|
-
if (inferred && !opts.id && embeddableId) {
|
|
22
|
-
process.chdir(inferred.projectRoot);
|
|
23
|
-
}
|
|
24
|
-
setSentryContext(getSentryContextFromProjectConfig());
|
|
25
|
-
if (!embeddableId) {
|
|
26
|
-
const selected = await promptForLocalEmbeddable();
|
|
27
|
-
if (!selected) {
|
|
28
|
-
await exit(1);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
embeddableId = selected;
|
|
32
|
-
}
|
|
33
|
-
if (embeddableId) {
|
|
34
|
-
setSentryContext({ embeddable: { id: embeddableId } });
|
|
35
|
-
}
|
|
36
|
-
stdout.print('');
|
|
37
|
-
stdout.print(pc.cyan('Fetching branches...'));
|
|
38
|
-
// Fetch branches for this embeddable
|
|
39
|
-
const branches = await fetchBranches(embeddableId);
|
|
40
|
-
if (branches.length === 0) {
|
|
41
|
-
stdout.print(pc.yellow('No branches found for this embeddable.'));
|
|
42
|
-
stdout.print(pc.gray('Branches are created in the Embeddables Builder.'));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
stdout.print('');
|
|
46
|
-
// Prompt for branch selection
|
|
47
|
-
const selectedBranch = await promptForBranch(branches);
|
|
48
|
-
stdout.print('');
|
|
49
|
-
// Pull the selected branch
|
|
50
|
-
if (selectedBranch === null) {
|
|
51
|
-
// User selected "main" - pull without branch
|
|
52
|
-
stdout.print(pc.cyan('Switching to main (latest published version)...'));
|
|
53
|
-
stdout.print('');
|
|
54
|
-
await runPull({ id: embeddableId, useMain: true });
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
setSentryContext({
|
|
58
|
-
branch: { id: selectedBranch.id, name: selectedBranch.name },
|
|
59
|
-
});
|
|
60
|
-
stdout.print(pc.cyan(`Switching to branch: ${selectedBranch.name}...`));
|
|
61
|
-
stdout.print('');
|
|
62
|
-
await runPull({
|
|
63
|
-
id: embeddableId,
|
|
64
|
-
branch: selectedBranch.id,
|
|
65
|
-
branchName: selectedBranch.name,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-workbench.d.ts","sourceRoot":"","sources":["../../src/commands/build-workbench.ts"],"names":[],"mappings":"AAUA,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,iBA+H/E"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import * as esbuild from 'esbuild';
|
|
4
|
-
import postcss from 'postcss';
|
|
5
|
-
import tailwindcss from '@tailwindcss/postcss';
|
|
6
|
-
import autoprefixer from 'autoprefixer';
|
|
7
|
-
import pc from 'picocolors';
|
|
8
|
-
import { createLogger, exit } from '../logger.js';
|
|
9
|
-
import * as stdout from '../stdout.js';
|
|
10
|
-
export async function runBuildWorkbench(opts) {
|
|
11
|
-
const logger = createLogger('runBuildWorkbench');
|
|
12
|
-
const outDir = opts.out || 'dist/workbench';
|
|
13
|
-
const shouldMinify = opts.minify ?? true;
|
|
14
|
-
// Check if wrangler config exists in outDir (native Cloudflare Git integration mode)
|
|
15
|
-
const hasWranglerConfig = fs.existsSync(path.join(outDir, 'wrangler.jsonc')) ||
|
|
16
|
-
fs.existsSync(path.join(outDir, 'wrangler.toml'));
|
|
17
|
-
stdout.print(pc.cyan('Building Workbench for CDN deployment...'));
|
|
18
|
-
stdout.print();
|
|
19
|
-
// Ensure output directory exists
|
|
20
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
21
|
-
const workbenchEntry = path.join(process.cwd(), 'src', 'workbench', 'index.tsx');
|
|
22
|
-
const workbenchCssEntry = path.join(process.cwd(), 'src', 'workbench', 'workbench.css');
|
|
23
|
-
// Check that source files exist
|
|
24
|
-
if (!fs.existsSync(workbenchEntry)) {
|
|
25
|
-
stdout.error(`Workbench entry not found: ${workbenchEntry}`);
|
|
26
|
-
logger.error('workbench entry not found', { path: workbenchEntry });
|
|
27
|
-
await exit(1);
|
|
28
|
-
}
|
|
29
|
-
if (!fs.existsSync(workbenchCssEntry)) {
|
|
30
|
-
stdout.error(`Workbench CSS not found: ${workbenchCssEntry}`);
|
|
31
|
-
logger.error('workbench css not found', { path: workbenchCssEntry });
|
|
32
|
-
await exit(1);
|
|
33
|
-
}
|
|
34
|
-
// Build JavaScript bundle
|
|
35
|
-
stdout.print(pc.dim(' Building JavaScript bundle...'));
|
|
36
|
-
const jsResult = await esbuild.build({
|
|
37
|
-
entryPoints: [workbenchEntry],
|
|
38
|
-
bundle: true,
|
|
39
|
-
format: 'iife',
|
|
40
|
-
globalName: '__EmbeddablesWorkbenchBundle',
|
|
41
|
-
platform: 'browser',
|
|
42
|
-
minify: shouldMinify,
|
|
43
|
-
sourcemap: shouldMinify ? false : 'inline',
|
|
44
|
-
write: false,
|
|
45
|
-
target: ['es2020', 'chrome80', 'firefox78', 'safari14'],
|
|
46
|
-
});
|
|
47
|
-
const jsOutput = jsResult.outputFiles?.[0];
|
|
48
|
-
if (!jsOutput) {
|
|
49
|
-
stdout.error('Failed to build JavaScript bundle');
|
|
50
|
-
logger.error('workbench js bundle build failed');
|
|
51
|
-
await exit(1);
|
|
52
|
-
}
|
|
53
|
-
// Build CSS
|
|
54
|
-
stdout.print(pc.dim(' Building CSS...'));
|
|
55
|
-
const rawCss = fs.readFileSync(workbenchCssEntry, 'utf8');
|
|
56
|
-
const cssResult = await postcss([tailwindcss(), autoprefixer]).process(rawCss, {
|
|
57
|
-
from: workbenchCssEntry,
|
|
58
|
-
});
|
|
59
|
-
// CORS headers file for Cloudflare static assets
|
|
60
|
-
const headersContent = `/*
|
|
61
|
-
Access-Control-Allow-Origin: *
|
|
62
|
-
Access-Control-Allow-Methods: GET, OPTIONS
|
|
63
|
-
Access-Control-Allow-Headers: Content-Type
|
|
64
|
-
`;
|
|
65
|
-
if (hasWranglerConfig) {
|
|
66
|
-
// Native Cloudflare Git integration mode:
|
|
67
|
-
// Output directly to outDir/public
|
|
68
|
-
const publicDir = path.join(outDir, 'public');
|
|
69
|
-
fs.mkdirSync(publicDir, { recursive: true });
|
|
70
|
-
fs.writeFileSync(path.join(publicDir, 'workbench.js'), jsOutput.contents);
|
|
71
|
-
const jsSize = (jsOutput.contents.length / 1024).toFixed(1);
|
|
72
|
-
stdout.print(pc.green(` ✓ ${publicDir}/workbench.js (${jsSize} KB)`));
|
|
73
|
-
fs.writeFileSync(path.join(publicDir, 'workbench.css'), cssResult.css);
|
|
74
|
-
const cssSize = (cssResult.css.length / 1024).toFixed(1);
|
|
75
|
-
stdout.print(pc.green(` ✓ ${publicDir}/workbench.css (${cssSize} KB)`));
|
|
76
|
-
fs.writeFileSync(path.join(publicDir, '_headers'), headersContent);
|
|
77
|
-
stdout.print(pc.green(` ✓ ${publicDir}/_headers`));
|
|
78
|
-
stdout.print();
|
|
79
|
-
stdout.print(pc.bold(pc.green('Build complete!')));
|
|
80
|
-
stdout.print();
|
|
81
|
-
stdout.print(pc.dim('Using existing wrangler.toml for Cloudflare Git integration'));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
// Standalone mode: output to outDir with nested cloudflare-worker folder
|
|
85
|
-
const jsPath = path.join(outDir, 'workbench.js');
|
|
86
|
-
fs.writeFileSync(jsPath, jsOutput.contents);
|
|
87
|
-
const jsSize = (jsOutput.contents.length / 1024).toFixed(1);
|
|
88
|
-
stdout.print(pc.green(` ✓ ${jsPath} (${jsSize} KB)`));
|
|
89
|
-
const cssPath = path.join(outDir, 'workbench.css');
|
|
90
|
-
fs.writeFileSync(cssPath, cssResult.css);
|
|
91
|
-
const cssSize = (cssResult.css.length / 1024).toFixed(1);
|
|
92
|
-
stdout.print(pc.green(` ✓ ${cssPath} (${cssSize} KB)`));
|
|
93
|
-
// Generate Cloudflare static site files
|
|
94
|
-
stdout.print(pc.dim(' Generating Cloudflare deployment files...'));
|
|
95
|
-
const workerDir = path.join(outDir, 'cloudflare');
|
|
96
|
-
fs.mkdirSync(workerDir, { recursive: true });
|
|
97
|
-
const wranglerConfig = generateWranglerConfig();
|
|
98
|
-
fs.writeFileSync(path.join(workerDir, 'wrangler.jsonc'), wranglerConfig);
|
|
99
|
-
stdout.print(pc.green(` ✓ ${workerDir}/wrangler.jsonc`));
|
|
100
|
-
const publicDir = path.join(workerDir, 'public');
|
|
101
|
-
fs.mkdirSync(publicDir, { recursive: true });
|
|
102
|
-
fs.copyFileSync(jsPath, path.join(publicDir, 'workbench.js'));
|
|
103
|
-
fs.copyFileSync(cssPath, path.join(publicDir, 'workbench.css'));
|
|
104
|
-
fs.writeFileSync(path.join(publicDir, '_headers'), headersContent);
|
|
105
|
-
stdout.print(pc.green(` ✓ ${publicDir}/ (assets + _headers)`));
|
|
106
|
-
stdout.print();
|
|
107
|
-
stdout.print(pc.bold(pc.green('Build complete!')));
|
|
108
|
-
stdout.print();
|
|
109
|
-
stdout.print(pc.cyan('Deploy to Cloudflare:'));
|
|
110
|
-
stdout.print(pc.dim(` cd ${workerDir} && npx wrangler deploy`));
|
|
111
|
-
}
|
|
112
|
-
stdout.print();
|
|
113
|
-
stdout.print(pc.cyan('Usage:'));
|
|
114
|
-
stdout.print(pc.dim(' Add ?workbench=true to any engine preview URL'));
|
|
115
|
-
stdout.print();
|
|
116
|
-
}
|
|
117
|
-
function generateWranglerConfig() {
|
|
118
|
-
return `{
|
|
119
|
-
// Embeddables Workbench - Static Assets
|
|
120
|
-
// Deploy: npx wrangler deploy
|
|
121
|
-
"name": "embeddables-workbench",
|
|
122
|
-
"compatibility_date": "2024-01-01",
|
|
123
|
-
"assets": {
|
|
124
|
-
"directory": "./public"
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
`;
|
|
128
|
-
}
|
package/dist/commands/build.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAaA,wBAAsB,QAAQ,CAAC,IAAI,EAAE;IACnC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,UAAU,GAAG,QAAQ,CAAA;CACnC,iBAoDA"}
|