@embeddables/cli 0.8.0 → 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/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 +1 -1
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import pc from 'picocolors';
|
|
5
|
+
import { writeProjectConfig, readProjectConfig } from '../config/index.js';
|
|
6
|
+
import { isLoggedIn } from '../auth/index.js';
|
|
7
|
+
import { promptForProject } from '../prompts/index.js';
|
|
8
|
+
import * as stdout from '../stdout.js';
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
/** Recursively copy a directory, creating target dirs as needed. */
|
|
12
|
+
function copyDirSync(src, dest) {
|
|
13
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
14
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
15
|
+
const srcPath = path.join(src, entry.name);
|
|
16
|
+
const destPath = path.join(dest, entry.name);
|
|
17
|
+
if (entry.isDirectory()) {
|
|
18
|
+
copyDirSync(srcPath, destPath);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
fs.copyFileSync(srcPath, destPath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generate type declaration stubs in .types/ (project root) so the editor
|
|
27
|
+
* can resolve imports in generated TSX files without npm install.
|
|
28
|
+
*/
|
|
29
|
+
function writeTypeStubs(cwd) {
|
|
30
|
+
const typesDir = path.join(cwd, '.types');
|
|
31
|
+
fs.mkdirSync(typesDir, { recursive: true });
|
|
32
|
+
// Copy compiled types-builder.d.ts → .types/types.d.ts
|
|
33
|
+
// (named types-builder in this codebase because it's copied from another repo,
|
|
34
|
+
// but exposed as simply "types" in consumer projects)
|
|
35
|
+
// When running from compiled JS: __dirname is dist/commands/, so ../types-builder.d.ts works.
|
|
36
|
+
// When running via tsx in dev: __dirname is src/commands/, so we fall back to dist/.
|
|
37
|
+
const candidates = [
|
|
38
|
+
path.join(__dirname, '..', 'types-builder.d.ts'),
|
|
39
|
+
path.join(__dirname, '..', '..', 'dist', 'types-builder.d.ts'),
|
|
40
|
+
];
|
|
41
|
+
const typesBuilderDts = candidates.find((p) => fs.existsSync(p));
|
|
42
|
+
if (typesBuilderDts) {
|
|
43
|
+
fs.copyFileSync(typesBuilderDts, path.join(typesDir, 'types.d.ts'));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
stdout.warn('Could not find types-builder.d.ts — run `npm run build` first');
|
|
47
|
+
}
|
|
48
|
+
// React JSX runtime types (needed for "jsx": "react-jsx" in tsconfig)
|
|
49
|
+
fs.writeFileSync(path.join(typesDir, 'react-jsx-runtime.d.ts'), `export namespace JSX {
|
|
50
|
+
type Element = any
|
|
51
|
+
interface IntrinsicElements {
|
|
52
|
+
[elemName: string]: any
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function jsx(type: any, props: any, key?: string): JSX.Element
|
|
56
|
+
export function jsxs(type: any, props: any, key?: string): JSX.Element
|
|
57
|
+
export const Fragment: unique symbol
|
|
58
|
+
`, 'utf8');
|
|
59
|
+
// Component primitives — import real prop types from types-builder,
|
|
60
|
+
// omitting JSON-structural properties that aren't valid React props
|
|
61
|
+
const componentsWithOwnType = [
|
|
62
|
+
'BookMeeting',
|
|
63
|
+
'Chart',
|
|
64
|
+
'Container',
|
|
65
|
+
'CustomButton',
|
|
66
|
+
'CustomHTML',
|
|
67
|
+
'FileUpload',
|
|
68
|
+
'InputBox',
|
|
69
|
+
'Lottie',
|
|
70
|
+
'MediaEmbed',
|
|
71
|
+
'MediaImage',
|
|
72
|
+
'OptionSelector',
|
|
73
|
+
'PaypalCheckout',
|
|
74
|
+
'ProgressBar',
|
|
75
|
+
'Rive',
|
|
76
|
+
'StripeCheckout',
|
|
77
|
+
'StripeCheckout2',
|
|
78
|
+
];
|
|
79
|
+
const baseOnlyComponents = ['PlainText', 'RichText', 'RichTextMarkdown'];
|
|
80
|
+
const importAliases = componentsWithOwnType.map((name) => `${name} as ${name}JSON`).join(', ');
|
|
81
|
+
const importLine = `import type { Base, OptionSelectorButton, ${importAliases} } from './types'`;
|
|
82
|
+
// Properties from the JSON format that are structural/derived in React
|
|
83
|
+
const omitLine = `type JSONOnly = 'type' | 'parent_id' | 'parent_key' | '_location' | 'components' | '__hide_initially' | '__is_child_already_inserted' | 'clearable' | 'central_play_button'`;
|
|
84
|
+
// In React, child components are passed via JSX nesting (children), not via a components array
|
|
85
|
+
// languages is a React-only prop (JSON uses flat lang--{code}--{attr} properties instead)
|
|
86
|
+
// props is a React-only prop for non-schema properties preserved during round-trip
|
|
87
|
+
const languagesType = `type Languages = { languages?: Record<string, Record<string, any>> }`;
|
|
88
|
+
const componentPropsType = `type ComponentProps = { props?: Record<string, any> }`;
|
|
89
|
+
const propsTypeLine = `type Props<T> = Omit<T, JSONOnly> & { children?: any } & Languages & ComponentProps`;
|
|
90
|
+
// Extended button type for OptionSelector buttons with multi-language support
|
|
91
|
+
const buttonTypeLine = `export type OptionSelectorButtonWithLanguages = OptionSelectorButton & Languages`;
|
|
92
|
+
const typedExports = componentsWithOwnType
|
|
93
|
+
.map((name) => `export function ${name}(props: Props<${name}JSON>): any`)
|
|
94
|
+
.join('\n');
|
|
95
|
+
const baseExports = baseOnlyComponents
|
|
96
|
+
.map((name) => `export function ${name}(props: Props<Base>): any`)
|
|
97
|
+
.join('\n');
|
|
98
|
+
fs.writeFileSync(path.join(typesDir, 'components.d.ts'), importLine +
|
|
99
|
+
'\n\n' +
|
|
100
|
+
omitLine +
|
|
101
|
+
'\n' +
|
|
102
|
+
languagesType +
|
|
103
|
+
'\n' +
|
|
104
|
+
componentPropsType +
|
|
105
|
+
'\n' +
|
|
106
|
+
propsTypeLine +
|
|
107
|
+
'\n\n' +
|
|
108
|
+
buttonTypeLine +
|
|
109
|
+
'\n\n' +
|
|
110
|
+
typedExports +
|
|
111
|
+
'\n' +
|
|
112
|
+
baseExports +
|
|
113
|
+
'\n', 'utf8');
|
|
114
|
+
}
|
|
115
|
+
export async function runInit(opts) {
|
|
116
|
+
const cwd = process.cwd();
|
|
117
|
+
const gitignorePath = path.join(cwd, '.gitignore');
|
|
118
|
+
const embeddablesDir = path.join(cwd, 'embeddables');
|
|
119
|
+
stdout.header(`${stdout.symbols.wave} Embeddables Project Setup`);
|
|
120
|
+
const existingConfig = readProjectConfig();
|
|
121
|
+
// Step 1: Get Embeddables project
|
|
122
|
+
let projectId = opts.projectId;
|
|
123
|
+
let selectedProjectTitle;
|
|
124
|
+
let selectedOrgId;
|
|
125
|
+
let selectedOrgTitle;
|
|
126
|
+
if (!projectId && !opts.yes) {
|
|
127
|
+
if (existingConfig?.project_id) {
|
|
128
|
+
stdout.dim(` Using existing project ID: ${existingConfig.project_id}`);
|
|
129
|
+
projectId = existingConfig.project_id;
|
|
130
|
+
selectedProjectTitle = existingConfig.project_name || undefined;
|
|
131
|
+
selectedOrgId = existingConfig.org_id || undefined;
|
|
132
|
+
selectedOrgTitle = existingConfig.org_title || undefined;
|
|
133
|
+
}
|
|
134
|
+
else if (isLoggedIn()) {
|
|
135
|
+
// Fetch and show project list
|
|
136
|
+
const fetchSpinner = stdout.spinner('Fetching projects…');
|
|
137
|
+
try {
|
|
138
|
+
const selectedProject = await promptForProject({
|
|
139
|
+
allowSkip: true,
|
|
140
|
+
message: 'Select your Embeddables project:',
|
|
141
|
+
});
|
|
142
|
+
fetchSpinner.stop();
|
|
143
|
+
if (selectedProject) {
|
|
144
|
+
projectId = selectedProject.id;
|
|
145
|
+
selectedProjectTitle = selectedProject.title || undefined;
|
|
146
|
+
selectedOrgId = selectedProject.org_id || undefined;
|
|
147
|
+
selectedOrgTitle = selectedProject.org_title || undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
fetchSpinner.stop();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
// Not logged in - offer manual entry or skip
|
|
156
|
+
stdout.dim(' (Login with "embeddables login" to select from your projects)');
|
|
157
|
+
const { prompt: promptWithCancel } = await import('../helpers/prompt.js');
|
|
158
|
+
const response = await promptWithCancel({
|
|
159
|
+
type: 'text',
|
|
160
|
+
name: 'projectId',
|
|
161
|
+
message: 'Embeddables project ID (optional):',
|
|
162
|
+
hint: 'e.g., proj_abc123 - leave empty to skip',
|
|
163
|
+
});
|
|
164
|
+
projectId = response.projectId || undefined;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Write embeddables.json config
|
|
168
|
+
if (projectId) {
|
|
169
|
+
writeProjectConfig({
|
|
170
|
+
org_id: selectedOrgId,
|
|
171
|
+
org_title: selectedOrgTitle,
|
|
172
|
+
project_id: projectId,
|
|
173
|
+
project_name: selectedProjectTitle,
|
|
174
|
+
});
|
|
175
|
+
stdout.success('Created embeddables.json');
|
|
176
|
+
}
|
|
177
|
+
// Create or update .gitignore
|
|
178
|
+
const gitignoreEntries = ['**/.generated/', 'node_modules/', '.DS_Store'];
|
|
179
|
+
const embeddablesBlock = `# Embeddables\n${gitignoreEntries.join('\n')}\n`;
|
|
180
|
+
let existingGitignore = '';
|
|
181
|
+
if (fs.existsSync(gitignorePath)) {
|
|
182
|
+
existingGitignore = fs.readFileSync(gitignorePath, 'utf8');
|
|
183
|
+
}
|
|
184
|
+
const embeddablesSectionRegex = /# Embeddables\n(?:[^\n]*\n)*?(?=\n#|\n\n|$)/;
|
|
185
|
+
if (embeddablesSectionRegex.test(existingGitignore)) {
|
|
186
|
+
const updated = existingGitignore.replace(embeddablesSectionRegex, embeddablesBlock);
|
|
187
|
+
if (updated !== existingGitignore) {
|
|
188
|
+
fs.writeFileSync(gitignorePath, updated, 'utf8');
|
|
189
|
+
stdout.success('Updated .gitignore');
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
stdout.dim(' ✓ .gitignore already configured');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const separator = existingGitignore && !existingGitignore.endsWith('\n') ? '\n' : '';
|
|
197
|
+
const content = existingGitignore
|
|
198
|
+
? `${existingGitignore}${separator}\n${embeddablesBlock}`
|
|
199
|
+
: embeddablesBlock;
|
|
200
|
+
fs.writeFileSync(gitignorePath, content, 'utf8');
|
|
201
|
+
stdout.success(existingGitignore ? 'Updated .gitignore' : 'Created .gitignore');
|
|
202
|
+
}
|
|
203
|
+
// Create embeddables directory
|
|
204
|
+
if (!fs.existsSync(embeddablesDir)) {
|
|
205
|
+
fs.mkdirSync(embeddablesDir, { recursive: true });
|
|
206
|
+
stdout.success('Created embeddables/ directory');
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
stdout.dim(' ✓ embeddables/ directory exists');
|
|
210
|
+
}
|
|
211
|
+
// Remove old .claudefiles folder (replaced by .cursor/ and .claude/)
|
|
212
|
+
const claudefilesDir = path.join(cwd, '.claudefiles');
|
|
213
|
+
if (fs.existsSync(claudefilesDir)) {
|
|
214
|
+
fs.rmSync(claudefilesDir, { recursive: true });
|
|
215
|
+
stdout.success('Removed old .claudefiles/');
|
|
216
|
+
}
|
|
217
|
+
// Inject .cursor/ and .claude/ from source .prompts/embeddables-cli.md (or copy if pre-built dirs exist)
|
|
218
|
+
const packageRoot = path.resolve(__dirname, '..', '..');
|
|
219
|
+
const promptsSource = path.join(packageRoot, '.prompts', 'embeddables-cli.md');
|
|
220
|
+
const sourceCursorDir = path.join(packageRoot, '.cursor');
|
|
221
|
+
const sourceClaudeDir = path.join(packageRoot, '.claude');
|
|
222
|
+
if (fs.existsSync(promptsSource)) {
|
|
223
|
+
const content = fs.readFileSync(promptsSource, 'utf8');
|
|
224
|
+
const cursorFrontmatter = `---
|
|
225
|
+
globs:
|
|
226
|
+
alwaysApply: true
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
`;
|
|
230
|
+
const claudeIntro = `# Embeddables project (Claude Code)
|
|
231
|
+
|
|
232
|
+
This is an Embeddables project managed by the Embeddables CLI. The CLI transforms Embeddable JSON into a local file structure for development, then compiles it back to JSON for saving.
|
|
233
|
+
|
|
234
|
+
For full context when editing embeddables (pages, components, styles, actions, computed fields), see:
|
|
235
|
+
|
|
236
|
+
- **.claude/embeddables-cli.md** — Embeddables CLI structure, types, file layout, and conventions.
|
|
237
|
+
|
|
238
|
+
All TypeScript types are in \`.types/\` (generated by \`embeddables init\`). Use \`embeddables dev\` to run the dev server and \`embeddables pull\` / \`embeddables save\` to sync with the project.
|
|
239
|
+
`;
|
|
240
|
+
const codexIntro = `# Embeddables project (Codex)
|
|
241
|
+
|
|
242
|
+
This is an Embeddables project managed by the Embeddables CLI. The CLI transforms Embeddable JSON into a local file structure for development, then compiles it back to JSON for saving.
|
|
243
|
+
|
|
244
|
+
All TypeScript types are in \`.types/\` (generated by \`embeddables init\`). Use \`embeddables dev\` to run the dev server and \`embeddables pull\` / \`embeddables save\` to sync with the project.
|
|
245
|
+
|
|
246
|
+
`;
|
|
247
|
+
const cursorRulesDir = path.join(cwd, '.cursor', 'rules');
|
|
248
|
+
const claudeDir = path.join(cwd, '.claude');
|
|
249
|
+
fs.mkdirSync(cursorRulesDir, { recursive: true });
|
|
250
|
+
fs.mkdirSync(claudeDir, { recursive: true });
|
|
251
|
+
fs.writeFileSync(path.join(cursorRulesDir, 'embeddables-cli.md'), cursorFrontmatter + content, 'utf8');
|
|
252
|
+
fs.writeFileSync(path.join(claudeDir, 'CLAUDE.md'), claudeIntro, 'utf8');
|
|
253
|
+
fs.writeFileSync(path.join(claudeDir, 'embeddables-cli.md'), content, 'utf8');
|
|
254
|
+
fs.writeFileSync(path.join(cwd, 'AGENTS.md'), codexIntro + content, 'utf8');
|
|
255
|
+
stdout.success('Injected .cursor/ rules');
|
|
256
|
+
stdout.success('Injected .claude/');
|
|
257
|
+
stdout.success('Injected AGENTS.md (Codex)');
|
|
258
|
+
}
|
|
259
|
+
else if (fs.existsSync(sourceCursorDir) || fs.existsSync(sourceClaudeDir)) {
|
|
260
|
+
if (fs.existsSync(sourceCursorDir)) {
|
|
261
|
+
copyDirSync(sourceCursorDir, path.join(cwd, '.cursor'));
|
|
262
|
+
stdout.success('Injected .cursor/ rules');
|
|
263
|
+
}
|
|
264
|
+
if (fs.existsSync(sourceClaudeDir)) {
|
|
265
|
+
copyDirSync(sourceClaudeDir, path.join(cwd, '.claude'));
|
|
266
|
+
stdout.success('Injected .claude/');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// Create tsconfig.json for editor support (JSX, type checking)
|
|
270
|
+
const tsconfigPath = path.join(cwd, 'tsconfig.json');
|
|
271
|
+
if (!fs.existsSync(tsconfigPath)) {
|
|
272
|
+
const tsconfig = {
|
|
273
|
+
compilerOptions: {
|
|
274
|
+
target: 'esnext',
|
|
275
|
+
module: 'esnext',
|
|
276
|
+
moduleResolution: 'bundler',
|
|
277
|
+
jsx: 'react-jsx',
|
|
278
|
+
noEmit: true,
|
|
279
|
+
strict: false,
|
|
280
|
+
skipLibCheck: true,
|
|
281
|
+
esModuleInterop: true,
|
|
282
|
+
baseUrl: '.',
|
|
283
|
+
paths: {
|
|
284
|
+
'react/jsx-runtime': ['./.types/react-jsx-runtime.d.ts'],
|
|
285
|
+
'@embeddables/cli/components': ['./.types/components.d.ts'],
|
|
286
|
+
'@embeddables/cli/types': ['./.types/types.d.ts'],
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
include: ['embeddables'],
|
|
290
|
+
};
|
|
291
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + '\n', 'utf8');
|
|
292
|
+
stdout.success('Created tsconfig.json');
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
stdout.dim(' ✓ tsconfig.json already exists');
|
|
296
|
+
}
|
|
297
|
+
// Migrate .types from old location (embeddables/.types/) to project root (.types/)
|
|
298
|
+
const oldTypesDir = path.join(embeddablesDir, '.types');
|
|
299
|
+
if (fs.existsSync(oldTypesDir)) {
|
|
300
|
+
fs.rmSync(oldTypesDir, { recursive: true });
|
|
301
|
+
stdout.success('Removed old embeddables/.types/');
|
|
302
|
+
}
|
|
303
|
+
// Ensure tsconfig has baseUrl and paths for type resolution
|
|
304
|
+
if (fs.existsSync(tsconfigPath)) {
|
|
305
|
+
let tsconfigContent = fs.readFileSync(tsconfigPath, 'utf8');
|
|
306
|
+
let updated = false;
|
|
307
|
+
// Migrate old embeddables/.types/ location → .types/
|
|
308
|
+
if (tsconfigContent.includes('./embeddables/.types/')) {
|
|
309
|
+
tsconfigContent = tsconfigContent.replaceAll('./embeddables/.types/', './.types/');
|
|
310
|
+
updated = true;
|
|
311
|
+
}
|
|
312
|
+
// Migrate old .types/types-builder → .types/types
|
|
313
|
+
if (tsconfigContent.includes('./.types/types-builder')) {
|
|
314
|
+
tsconfigContent = tsconfigContent.replace(/\.\/\.types\/types-builder(\.d\.ts)?"/g, './.types/types.d.ts"');
|
|
315
|
+
updated = true;
|
|
316
|
+
}
|
|
317
|
+
// Migrate paths without .d.ts extension → with .d.ts
|
|
318
|
+
const extensionless = [
|
|
319
|
+
['./.types/react-jsx-runtime"', './.types/react-jsx-runtime.d.ts"'],
|
|
320
|
+
['./.types/components"', './.types/components.d.ts"'],
|
|
321
|
+
['./.types/types"', './.types/types.d.ts"'],
|
|
322
|
+
];
|
|
323
|
+
for (const [old, replacement] of extensionless) {
|
|
324
|
+
if (tsconfigContent.includes(old) && !tsconfigContent.includes(replacement)) {
|
|
325
|
+
tsconfigContent = tsconfigContent.replaceAll(old, replacement);
|
|
326
|
+
updated = true;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// Add baseUrl and paths if missing entirely
|
|
330
|
+
try {
|
|
331
|
+
const tsconfig = JSON.parse(tsconfigContent);
|
|
332
|
+
const co = tsconfig.compilerOptions ?? {};
|
|
333
|
+
let coUpdated = false;
|
|
334
|
+
if (!co.baseUrl) {
|
|
335
|
+
co.baseUrl = '.';
|
|
336
|
+
coUpdated = true;
|
|
337
|
+
}
|
|
338
|
+
const requiredPaths = {
|
|
339
|
+
'react/jsx-runtime': ['./.types/react-jsx-runtime.d.ts'],
|
|
340
|
+
'@embeddables/cli/components': ['./.types/components.d.ts'],
|
|
341
|
+
'@embeddables/cli/types': ['./.types/types.d.ts'],
|
|
342
|
+
};
|
|
343
|
+
if (!co.paths)
|
|
344
|
+
co.paths = {};
|
|
345
|
+
for (const [key, value] of Object.entries(requiredPaths)) {
|
|
346
|
+
if (!co.paths[key]) {
|
|
347
|
+
co.paths[key] = value;
|
|
348
|
+
coUpdated = true;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (coUpdated) {
|
|
352
|
+
tsconfig.compilerOptions = co;
|
|
353
|
+
tsconfigContent = JSON.stringify(tsconfig, null, 2) + '\n';
|
|
354
|
+
updated = true;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
catch {
|
|
358
|
+
// If tsconfig isn't valid JSON (e.g. has comments), fall through to string-based updates above
|
|
359
|
+
}
|
|
360
|
+
if (updated) {
|
|
361
|
+
fs.writeFileSync(tsconfigPath, tsconfigContent, 'utf8');
|
|
362
|
+
stdout.success('Updated tsconfig.json');
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// Remove old .types/types-builder.d.ts (now named .types/types.d.ts)
|
|
366
|
+
const legacyTypesBuilderDts = path.join(cwd, '.types', 'types-builder.d.ts');
|
|
367
|
+
if (fs.existsSync(legacyTypesBuilderDts)) {
|
|
368
|
+
fs.rmSync(legacyTypesBuilderDts);
|
|
369
|
+
}
|
|
370
|
+
// Generate type declaration stubs for editor support (no npm install needed)
|
|
371
|
+
writeTypeStubs(cwd);
|
|
372
|
+
stdout.success('Generated type declarations');
|
|
373
|
+
// Next steps in a compact box
|
|
374
|
+
stdout.gap();
|
|
375
|
+
const nextStepsLines = [
|
|
376
|
+
`${pc.cyan('1.')} Login: ${pc.white('embeddables login')}`,
|
|
377
|
+
projectId
|
|
378
|
+
? `${pc.cyan('2.')} Pull: ${pc.white('embeddables pull')}`
|
|
379
|
+
: `${pc.cyan('2.')} Pull: ${pc.white('embeddables pull --id <embeddable-id>')}`,
|
|
380
|
+
`${pc.cyan('3.')} Start dev: ${pc.white('embeddables dev')}`,
|
|
381
|
+
];
|
|
382
|
+
stdout.box(nextStepsLines.join('\n'), { title: 'Next steps', borderColor: 'cyan' });
|
|
383
|
+
stdout.gap();
|
|
384
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/commands/inspect.ts"],"names":[],"mappings":"AA8HA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,iBAAiB,iBAwNvD"}
|