@gurulu/cli 0.4.7 → 1.0.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/LICENSE +92 -0
- package/README.md +35 -106
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +25751 -0
- package/dist/commands/auth.d.ts +23 -20
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/doctor.d.ts +20 -6
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/init.d.ts +33 -11
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/pull.d.ts +13 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/push.d.ts +40 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/validate.d.ts +36 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25326 -876
- package/dist/lib/api.d.ts +139 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/codegen.d.ts +4 -0
- package/dist/lib/codegen.d.ts.map +1 -0
- package/dist/lib/config.d.ts +43 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/detect.d.ts +27 -0
- package/dist/lib/detect.d.ts.map +1 -0
- package/dist/lib/detect.js +106 -0
- package/dist/lib/exec-install.d.ts +21 -0
- package/dist/lib/exec-install.d.ts.map +1 -0
- package/dist/lib/install-plan.d.ts +25 -0
- package/dist/lib/install-plan.d.ts.map +1 -0
- package/dist/lib/install-plan.js +161 -0
- package/package.json +51 -20
- package/bin/gurulu.js +0 -2
- package/dist/api-client.d.ts +0 -33
- package/dist/api-client.js +0 -175
- package/dist/commands/add-server.d.ts +0 -9
- package/dist/commands/add-server.js +0 -162
- package/dist/commands/alerts.d.ts +0 -27
- package/dist/commands/alerts.js +0 -309
- package/dist/commands/api-keys.d.ts +0 -20
- package/dist/commands/api-keys.js +0 -130
- package/dist/commands/attribution.d.ts +0 -22
- package/dist/commands/attribution.js +0 -111
- package/dist/commands/audiences.d.ts +0 -23
- package/dist/commands/audiences.js +0 -243
- package/dist/commands/audit.d.ts +0 -20
- package/dist/commands/audit.js +0 -130
- package/dist/commands/auth.js +0 -249
- package/dist/commands/chat.d.ts +0 -19
- package/dist/commands/chat.js +0 -118
- package/dist/commands/config.d.ts +0 -10
- package/dist/commands/config.js +0 -92
- package/dist/commands/consent.d.ts +0 -27
- package/dist/commands/consent.js +0 -233
- package/dist/commands/conversion-paths.d.ts +0 -19
- package/dist/commands/conversion-paths.js +0 -55
- package/dist/commands/db.d.ts +0 -25
- package/dist/commands/db.js +0 -330
- package/dist/commands/destinations.d.ts +0 -20
- package/dist/commands/destinations.js +0 -191
- package/dist/commands/doctor.js +0 -360
- package/dist/commands/errors.d.ts +0 -27
- package/dist/commands/errors.js +0 -121
- package/dist/commands/events.d.ts +0 -33
- package/dist/commands/events.js +0 -371
- package/dist/commands/experiments.d.ts +0 -22
- package/dist/commands/experiments.js +0 -264
- package/dist/commands/funnels.d.ts +0 -17
- package/dist/commands/funnels.js +0 -203
- package/dist/commands/goals.d.ts +0 -18
- package/dist/commands/goals.js +0 -214
- package/dist/commands/heatmap.d.ts +0 -27
- package/dist/commands/heatmap.js +0 -112
- package/dist/commands/identity.d.ts +0 -29
- package/dist/commands/identity.js +0 -328
- package/dist/commands/init.js +0 -215
- package/dist/commands/insights.d.ts +0 -10
- package/dist/commands/insights.js +0 -77
- package/dist/commands/install.d.ts +0 -259
- package/dist/commands/install.js +0 -1590
- package/dist/commands/login.d.ts +0 -20
- package/dist/commands/login.js +0 -170
- package/dist/commands/logout.d.ts +0 -10
- package/dist/commands/logout.js +0 -41
- package/dist/commands/playground.d.ts +0 -11
- package/dist/commands/playground.js +0 -47
- package/dist/commands/releases.d.ts +0 -17
- package/dist/commands/releases.js +0 -54
- package/dist/commands/replay.d.ts +0 -18
- package/dist/commands/replay.js +0 -64
- package/dist/commands/secrets.d.ts +0 -19
- package/dist/commands/secrets.js +0 -145
- package/dist/commands/setup.d.ts +0 -21
- package/dist/commands/setup.js +0 -67
- package/dist/commands/sites.d.ts +0 -18
- package/dist/commands/sites.js +0 -139
- package/dist/commands/skad.d.ts +0 -18
- package/dist/commands/skad.js +0 -53
- package/dist/commands/sourcemap.d.ts +0 -33
- package/dist/commands/sourcemap.js +0 -204
- package/dist/commands/status.d.ts +0 -7
- package/dist/commands/status.js +0 -136
- package/dist/commands/upgrade.d.ts +0 -21
- package/dist/commands/upgrade.js +0 -183
- package/dist/commands/warehouse.d.ts +0 -20
- package/dist/commands/warehouse.js +0 -65
- package/dist/commands/warehouses.d.ts +0 -17
- package/dist/commands/warehouses.js +0 -182
- package/dist/commands/watch.d.ts +0 -45
- package/dist/commands/watch.js +0 -258
- package/dist/commands/whoami.d.ts +0 -9
- package/dist/commands/whoami.js +0 -50
- package/dist/config.d.ts +0 -75
- package/dist/config.js +0 -329
- package/dist/frameworks/detect.d.ts +0 -8
- package/dist/frameworks/detect.js +0 -458
- package/dist/install-intent-proposal.d.ts +0 -99
- package/dist/install-intent-proposal.js +0 -202
- package/dist/utils/api.d.ts +0 -20
- package/dist/utils/api.js +0 -47
- package/dist/utils/config.d.ts +0 -13
- package/dist/utils/config.js +0 -30
- package/dist/utils/confirm.d.ts +0 -17
- package/dist/utils/confirm.js +0 -40
- package/dist/utils/dry-run.d.ts +0 -20
- package/dist/utils/dry-run.js +0 -67
- package/dist/utils/from-file.d.ts +0 -9
- package/dist/utils/from-file.js +0 -72
- package/dist/utils/redact.d.ts +0 -14
- package/dist/utils/redact.js +0 -48
- package/dist/utils/ui.d.ts +0 -14
- package/dist/utils/ui.js +0 -59
- package/scripts/.gitkeep +0 -0
- package/scripts/README-gurulu-agentic-install.md +0 -114
- package/scripts/README-gurulu-scan.md +0 -98
- package/scripts/audit-cli-scopes.mjs +0 -204
- package/scripts/backfill-tenant-id.mjs +0 -172
- package/scripts/backfill-tenant-links.ts +0 -252
- package/scripts/backup-clickhouse.sh +0 -27
- package/scripts/backup-postgres.sh +0 -19
- package/scripts/bootstrap-runtime-schema.mjs +0 -87
- package/scripts/bootstrap-stripe.mjs +0 -158
- package/scripts/gurulu-agentic-install.lib.cjs +0 -762
- package/scripts/gurulu-agentic-install.mjs +0 -623
- package/scripts/gurulu-scan.lib.cjs +0 -1509
- package/scripts/gurulu-scan.mjs +0 -91
- package/scripts/gurulu-verify-install.lib.cjs +0 -334
- package/scripts/gurulu-verify-install.mjs +0 -59
- package/scripts/init-ssl.sh +0 -26
- package/scripts/migrate-flow-graph-enums.sh +0 -86
- package/scripts/monitor-disk.sh +0 -24
- package/scripts/patches/astro.patch.cjs +0 -74
- package/scripts/patches/auto-instrument/ast-helper.cjs +0 -480
- package/scripts/patches/auto-instrument/astro.cjs +0 -273
- package/scripts/patches/auto-instrument/express.cjs +0 -383
- package/scripts/patches/auto-instrument/fastify.cjs +0 -262
- package/scripts/patches/auto-instrument/hono.cjs +0 -392
- package/scripts/patches/auto-instrument/index.cjs +0 -80
- package/scripts/patches/auto-instrument/nestjs.cjs +0 -286
- package/scripts/patches/auto-instrument/nextjs-app-router.cjs +0 -345
- package/scripts/patches/auto-instrument/nextjs-pages.cjs +0 -361
- package/scripts/patches/auto-instrument/remix.cjs +0 -168
- package/scripts/patches/auto-instrument/sdk-helper-map.cjs +0 -241
- package/scripts/patches/auto-instrument/singleton-helper.cjs +0 -193
- package/scripts/patches/auto-instrument/sveltekit.cjs +0 -161
- package/scripts/patches/auto-instrument/vite-react.cjs +0 -37
- package/scripts/patches/auto-instrument/vue.cjs +0 -196
- package/scripts/patches/express.patch.cjs +0 -99
- package/scripts/patches/fastify.patch.cjs +0 -108
- package/scripts/patches/index.cjs +0 -300
- package/scripts/patches/nestjs.patch.cjs +0 -112
- package/scripts/patches/nextjs-app-router.patch.cjs +0 -97
- package/scripts/patches/nextjs-pages.patch.cjs +0 -97
- package/scripts/patches/remix.patch.cjs +0 -75
- package/scripts/patches/sveltekit.patch.cjs +0 -72
- package/scripts/patches/vite-react.patch.cjs +0 -73
- package/scripts/patches/vue.patch.cjs +0 -82
- package/scripts/renew-ssl.sh +0 -14
- package/scripts/resolve-migration.sh +0 -23
- package/scripts/seed-cli-dev-keys.mjs +0 -130
- package/scripts/seed-test-data.mjs +0 -391
- package/scripts/spike-browserless.ts +0 -65
- package/scripts/tenant-pivot-consistency-check.mjs +0 -205
- package/scripts/tenant-pivot-phase-3-cleanup.lib.cjs +0 -258
- package/scripts/tenant-pivot-phase-3-cleanup.mjs +0 -98
- package/scripts/test-identity-resolution.ts +0 -804
- package/scripts/validate-gurulu-schemas.mjs +0 -79
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export interface ApiClientOptions {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ApiError {
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
status: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class ApiHttpError extends Error {
|
|
11
|
+
status: number;
|
|
12
|
+
code: string;
|
|
13
|
+
constructor(opts: {
|
|
14
|
+
status: number;
|
|
15
|
+
code: string;
|
|
16
|
+
message: string;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export declare class ApiClient {
|
|
20
|
+
private opts;
|
|
21
|
+
constructor(opts: ApiClientOptions);
|
|
22
|
+
private headers;
|
|
23
|
+
get<T>(path: string, query?: Record<string, string | number>): Promise<T>;
|
|
24
|
+
post<T>(path: string, body: unknown): Promise<T>;
|
|
25
|
+
private handle;
|
|
26
|
+
}
|
|
27
|
+
export interface RegistryPullResponse {
|
|
28
|
+
manifest_version: string;
|
|
29
|
+
schema_version: number;
|
|
30
|
+
workspace_id: string;
|
|
31
|
+
exported_at: string;
|
|
32
|
+
events: ManifestEvent[];
|
|
33
|
+
}
|
|
34
|
+
export interface ManifestEvent {
|
|
35
|
+
key: string;
|
|
36
|
+
name: string;
|
|
37
|
+
meaning: string;
|
|
38
|
+
type: 'interaction' | 'intent' | 'outcome';
|
|
39
|
+
lifecycle: 'draft' | 'active' | 'deprecated' | 'archived';
|
|
40
|
+
producerPrimary: string;
|
|
41
|
+
producerAllowed: string[];
|
|
42
|
+
producerForbidden: string[];
|
|
43
|
+
schemaVersion: number;
|
|
44
|
+
properties: ManifestProperty[];
|
|
45
|
+
}
|
|
46
|
+
export interface ManifestProperty {
|
|
47
|
+
name: string;
|
|
48
|
+
type: 'string' | 'number' | 'boolean' | 'date' | 'json' | 'array';
|
|
49
|
+
required: boolean;
|
|
50
|
+
format?: string;
|
|
51
|
+
position?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface RegistryPushBody {
|
|
54
|
+
action: 'add_event' | 'add_property' | 'modify_event';
|
|
55
|
+
source: 'cli' | 'mcp:cursor' | 'mcp:claude_code' | 'mcp:codex' | 'mcp:lovable' | 'mcp:generic';
|
|
56
|
+
payload: {
|
|
57
|
+
event_key: string;
|
|
58
|
+
name?: string;
|
|
59
|
+
meaning: string;
|
|
60
|
+
event_type: 'interaction' | 'intent' | 'outcome';
|
|
61
|
+
primary_producer?: 'script' | 'sdk_web' | 'sdk_server' | 'webhook' | 'playground' | 'agent' | 'cli';
|
|
62
|
+
required_properties?: Array<{
|
|
63
|
+
name: string;
|
|
64
|
+
type: string;
|
|
65
|
+
format?: string;
|
|
66
|
+
}>;
|
|
67
|
+
optional_properties?: Array<{
|
|
68
|
+
name: string;
|
|
69
|
+
type: string;
|
|
70
|
+
}>;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export interface RegistryPushResponse {
|
|
74
|
+
verification_id: string;
|
|
75
|
+
status: 'pending_approval';
|
|
76
|
+
event_key: string;
|
|
77
|
+
lifecycle: string;
|
|
78
|
+
message: string;
|
|
79
|
+
}
|
|
80
|
+
export interface RecentEventsResponse {
|
|
81
|
+
workspace_id: string;
|
|
82
|
+
count: number;
|
|
83
|
+
events: Array<{
|
|
84
|
+
event_id: string;
|
|
85
|
+
event_key: string;
|
|
86
|
+
event_type: 'interaction' | 'intent' | 'outcome';
|
|
87
|
+
occurred_at: string;
|
|
88
|
+
anonymous_id: string | null;
|
|
89
|
+
person_id: string | null;
|
|
90
|
+
properties: Record<string, unknown>;
|
|
91
|
+
}>;
|
|
92
|
+
note?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface HealthOverviewResponse {
|
|
95
|
+
workspace_id: string;
|
|
96
|
+
registry: {
|
|
97
|
+
total_events: number;
|
|
98
|
+
by_type: {
|
|
99
|
+
interaction: number;
|
|
100
|
+
intent: number;
|
|
101
|
+
outcome: number;
|
|
102
|
+
};
|
|
103
|
+
by_lifecycle: {
|
|
104
|
+
draft: number;
|
|
105
|
+
active: number;
|
|
106
|
+
deprecated: number;
|
|
107
|
+
archived: number;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
alarms: {
|
|
111
|
+
total: number;
|
|
112
|
+
active: number;
|
|
113
|
+
by_severity: {
|
|
114
|
+
critical: number;
|
|
115
|
+
warn: number;
|
|
116
|
+
info: number;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
traffic: {
|
|
120
|
+
recent_events_24h: number;
|
|
121
|
+
clickhouse_available: boolean;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export interface DeviceStartResponse {
|
|
125
|
+
device_code: string;
|
|
126
|
+
user_code: string;
|
|
127
|
+
verification_url: string;
|
|
128
|
+
verification_url_complete: string;
|
|
129
|
+
expires_in: number;
|
|
130
|
+
interval: number;
|
|
131
|
+
}
|
|
132
|
+
export interface DeviceTokenResponse {
|
|
133
|
+
access_token: string;
|
|
134
|
+
token_type: 'Bearer';
|
|
135
|
+
workspace_id: string;
|
|
136
|
+
tenant_id: string;
|
|
137
|
+
expires_in: number | null;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/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iB,EAAE,MAAM,CAAC;QAC1B,oBAAoB,EAAE,OAAO,CAAC;KAC/B,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,yBAAyB,EAAE,MAAM,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,QAAQ,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/lib/codegen.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAmC,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA8BtF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAwDzE;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAE3E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface ProjectConfig {
|
|
2
|
+
workspace_id: string;
|
|
3
|
+
endpoint: string;
|
|
4
|
+
sdk_preference: 'web' | 'node' | 'react';
|
|
5
|
+
registry_path: string;
|
|
6
|
+
generated_path: string;
|
|
7
|
+
manifest_lock_path: string;
|
|
8
|
+
auto_pull_on_init: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface GlobalCredentialEntry {
|
|
11
|
+
workspace_id: string;
|
|
12
|
+
api_key: string;
|
|
13
|
+
endpoint: string;
|
|
14
|
+
last_used: string;
|
|
15
|
+
}
|
|
16
|
+
export interface GlobalCredentials {
|
|
17
|
+
workspaces: GlobalCredentialEntry[];
|
|
18
|
+
default_workspace_id?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const DEFAULT_ENDPOINT: string;
|
|
21
|
+
export declare function projectRoot(cwd?: string): string;
|
|
22
|
+
export declare function projectConfigPath(cwd?: string): string;
|
|
23
|
+
export declare function projectRegistryPath(cwd?: string): string;
|
|
24
|
+
export declare function projectGeneratedPath(cwd?: string): string;
|
|
25
|
+
export declare function projectManifestLockPath(cwd?: string): string;
|
|
26
|
+
export declare function globalCredentialsPath(): string;
|
|
27
|
+
export declare function ensureDir(path: string): void;
|
|
28
|
+
export declare function readProjectConfig(cwd?: string): ProjectConfig | null;
|
|
29
|
+
export declare function writeProjectConfig(cfg: ProjectConfig, cwd?: string): void;
|
|
30
|
+
export declare function readGlobalCredentials(): GlobalCredentials;
|
|
31
|
+
export declare function writeGlobalCredentials(creds: GlobalCredentials): void;
|
|
32
|
+
export declare function findCredentialForWorkspace(workspaceId: string): GlobalCredentialEntry | null;
|
|
33
|
+
export declare function upsertCredential(entry: GlobalCredentialEntry): void;
|
|
34
|
+
export declare function removeCredential(workspaceId: string): boolean;
|
|
35
|
+
export declare function resolveActiveCredential(opts: {
|
|
36
|
+
workspaceId?: string;
|
|
37
|
+
cwd?: string;
|
|
38
|
+
}): {
|
|
39
|
+
workspaceId: string;
|
|
40
|
+
apiKey: string;
|
|
41
|
+
endpoint: string;
|
|
42
|
+
} | null;
|
|
43
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MA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AAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAO7D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAmBnE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type Framework = 'next' | 'react' | 'vue' | 'nuxt' | 'svelte' | 'astro' | 'vite' | 'express' | 'fastify' | 'hono' | 'koa' | 'node-server' | 'unknown';
|
|
2
|
+
export type Runtime = 'browser' | 'node' | 'unknown';
|
|
3
|
+
export type PackageManager = 'bun' | 'pnpm' | 'yarn' | 'npm';
|
|
4
|
+
export interface DetectedProject {
|
|
5
|
+
dir: string;
|
|
6
|
+
hasPackageJson: boolean;
|
|
7
|
+
framework: Framework;
|
|
8
|
+
runtime: Runtime;
|
|
9
|
+
packageManager: PackageManager;
|
|
10
|
+
packageJson: PackageJsonShape | null;
|
|
11
|
+
}
|
|
12
|
+
interface PackageJsonShape {
|
|
13
|
+
name?: string;
|
|
14
|
+
type?: 'module' | 'commonjs';
|
|
15
|
+
dependencies?: Record<string, string>;
|
|
16
|
+
devDependencies?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Walk up the directory tree (max 6 levels) looking for a lockfile.
|
|
20
|
+
* Monorepo workspaces typically have the lockfile at the repo root.
|
|
21
|
+
*/
|
|
22
|
+
export declare function detectPackageManager(dir: string): PackageManager;
|
|
23
|
+
export declare function detectFramework(pkg: PackageJsonShape | null, dir: string): Framework;
|
|
24
|
+
export declare function frameworkRuntime(fw: Framework): Runtime;
|
|
25
|
+
export declare function detectProject(dir: string): DetectedProject;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,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
// src/lib/detect.ts
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join, parse } from "node:path";
|
|
4
|
+
function readPackageJson(dir) {
|
|
5
|
+
const p = join(dir, "package.json");
|
|
6
|
+
if (!existsSync(p))
|
|
7
|
+
return null;
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(readFileSync(p, "utf8"));
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function hasDep(pkg, name) {
|
|
15
|
+
if (!pkg)
|
|
16
|
+
return false;
|
|
17
|
+
return Boolean(pkg.dependencies?.[name] ?? pkg.devDependencies?.[name]);
|
|
18
|
+
}
|
|
19
|
+
function detectPackageManager(dir) {
|
|
20
|
+
const root = parse(dir).root;
|
|
21
|
+
let cur = dir;
|
|
22
|
+
for (let i = 0;i < 6; i++) {
|
|
23
|
+
if (existsSync(join(cur, "bun.lock")) || existsSync(join(cur, "bun.lockb")))
|
|
24
|
+
return "bun";
|
|
25
|
+
if (existsSync(join(cur, "pnpm-lock.yaml")))
|
|
26
|
+
return "pnpm";
|
|
27
|
+
if (existsSync(join(cur, "yarn.lock")))
|
|
28
|
+
return "yarn";
|
|
29
|
+
if (existsSync(join(cur, "package-lock.json")))
|
|
30
|
+
return "npm";
|
|
31
|
+
if (cur === root)
|
|
32
|
+
break;
|
|
33
|
+
const parent = dirname(cur);
|
|
34
|
+
if (parent === cur)
|
|
35
|
+
break;
|
|
36
|
+
cur = parent;
|
|
37
|
+
}
|
|
38
|
+
return "npm";
|
|
39
|
+
}
|
|
40
|
+
function detectFramework(pkg, dir) {
|
|
41
|
+
if (!pkg)
|
|
42
|
+
return "unknown";
|
|
43
|
+
if (hasDep(pkg, "next"))
|
|
44
|
+
return "next";
|
|
45
|
+
if (hasDep(pkg, "nuxt"))
|
|
46
|
+
return "nuxt";
|
|
47
|
+
if (hasDep(pkg, "@sveltejs/kit") || hasDep(pkg, "svelte"))
|
|
48
|
+
return "svelte";
|
|
49
|
+
if (hasDep(pkg, "astro"))
|
|
50
|
+
return "astro";
|
|
51
|
+
if (hasDep(pkg, "vite") && (hasDep(pkg, "vue") || hasDep(pkg, "react")))
|
|
52
|
+
return "vite";
|
|
53
|
+
if (hasDep(pkg, "vue"))
|
|
54
|
+
return "vue";
|
|
55
|
+
if (hasDep(pkg, "react"))
|
|
56
|
+
return "react";
|
|
57
|
+
if (hasDep(pkg, "hono"))
|
|
58
|
+
return "hono";
|
|
59
|
+
if (hasDep(pkg, "fastify"))
|
|
60
|
+
return "fastify";
|
|
61
|
+
if (hasDep(pkg, "express"))
|
|
62
|
+
return "express";
|
|
63
|
+
if (hasDep(pkg, "koa"))
|
|
64
|
+
return "koa";
|
|
65
|
+
if (existsSync(join(dir, "server.js")) || existsSync(join(dir, "server.ts")))
|
|
66
|
+
return "node-server";
|
|
67
|
+
return "unknown";
|
|
68
|
+
}
|
|
69
|
+
function frameworkRuntime(fw) {
|
|
70
|
+
switch (fw) {
|
|
71
|
+
case "next":
|
|
72
|
+
case "react":
|
|
73
|
+
case "vue":
|
|
74
|
+
case "nuxt":
|
|
75
|
+
case "svelte":
|
|
76
|
+
case "astro":
|
|
77
|
+
case "vite":
|
|
78
|
+
return "browser";
|
|
79
|
+
case "express":
|
|
80
|
+
case "fastify":
|
|
81
|
+
case "hono":
|
|
82
|
+
case "koa":
|
|
83
|
+
case "node-server":
|
|
84
|
+
return "node";
|
|
85
|
+
default:
|
|
86
|
+
return "unknown";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function detectProject(dir) {
|
|
90
|
+
const pkg = readPackageJson(dir);
|
|
91
|
+
const framework = detectFramework(pkg, dir);
|
|
92
|
+
return {
|
|
93
|
+
dir,
|
|
94
|
+
hasPackageJson: pkg !== null,
|
|
95
|
+
framework,
|
|
96
|
+
runtime: frameworkRuntime(framework),
|
|
97
|
+
packageManager: detectPackageManager(dir),
|
|
98
|
+
packageJson: pkg
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
frameworkRuntime,
|
|
103
|
+
detectProject,
|
|
104
|
+
detectPackageManager,
|
|
105
|
+
detectFramework
|
|
106
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InstallPlan } from './install-plan.ts';
|
|
2
|
+
export interface ExecInstallOptions {
|
|
3
|
+
cwd: string;
|
|
4
|
+
/** Suppress stdout/stderr forwarding (still captured in result). */
|
|
5
|
+
silent?: boolean;
|
|
6
|
+
/** Hard timeout in ms (default 120s). */
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ExecInstallResult {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
exitCode: number | null;
|
|
12
|
+
durationMs: number;
|
|
13
|
+
command: string;
|
|
14
|
+
stderr?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Spawn the package manager install command for the planned SDK.
|
|
18
|
+
* Streams output to the parent process (unless `silent: true`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function execInstall(plan: InstallPlan, opts: ExecInstallOptions): Promise<ExecInstallResult>;
|
|
21
|
+
//# sourceMappingURL=exec-install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-install.d.ts","sourceRoot":"","sources":["../../src/lib/exec-install.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CA6D5B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DetectedProject, Framework, PackageManager } from './detect.ts';
|
|
2
|
+
export type SdkPackage = '@gurulu/web' | '@gurulu/node';
|
|
3
|
+
export interface InstallPlanContext {
|
|
4
|
+
/** Workspace key (pk_xxx) — script tag + init() içine inject. */
|
|
5
|
+
writeKey?: string;
|
|
6
|
+
/** Workspace UUID — CLI/MCP referansı. */
|
|
7
|
+
workspaceId?: string;
|
|
8
|
+
/** Server-side projeler için API key (sk_xxx). */
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface InstallPlan {
|
|
12
|
+
sdk: SdkPackage;
|
|
13
|
+
packageManager: PackageManager;
|
|
14
|
+
installCommand: string;
|
|
15
|
+
initSnippet: string;
|
|
16
|
+
envKeys: Array<{
|
|
17
|
+
key: string;
|
|
18
|
+
example: string;
|
|
19
|
+
required: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
placementHint: string;
|
|
22
|
+
framework: Framework;
|
|
23
|
+
}
|
|
24
|
+
export declare function buildInstallPlan(detected: DetectedProject, ctx?: InstallPlanContext): InstallPlan;
|
|
25
|
+
//# sourceMappingURL=install-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-plan.d.ts","sourceRoot":"","sources":["../../src/lib/install-plan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE9E,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,cAAc,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,UAAU,CAAC;IAChB,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACpE,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;CACtB;AA2JD,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,eAAe,EACzB,GAAG,GAAE,kBAAuB,GAC3B,WAAW,CAYb"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// src/lib/install-plan.ts
|
|
2
|
+
function installCmdFor(pm, pkg) {
|
|
3
|
+
switch (pm) {
|
|
4
|
+
case "bun":
|
|
5
|
+
return `bun add ${pkg}`;
|
|
6
|
+
case "pnpm":
|
|
7
|
+
return `pnpm add ${pkg}`;
|
|
8
|
+
case "yarn":
|
|
9
|
+
return `yarn add ${pkg}`;
|
|
10
|
+
default:
|
|
11
|
+
return `npm install ${pkg}`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function sdkFor(framework) {
|
|
15
|
+
switch (framework) {
|
|
16
|
+
case "express":
|
|
17
|
+
case "fastify":
|
|
18
|
+
case "hono":
|
|
19
|
+
case "koa":
|
|
20
|
+
case "node-server":
|
|
21
|
+
return "@gurulu/node";
|
|
22
|
+
default:
|
|
23
|
+
return "@gurulu/web";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function snippetWeb(workspaceKey) {
|
|
27
|
+
return `import { createGurulu } from '@gurulu/web';
|
|
28
|
+
|
|
29
|
+
const gurulu = createGurulu();
|
|
30
|
+
gurulu.init({ workspace: '${workspaceKey}' });`;
|
|
31
|
+
}
|
|
32
|
+
function snippetNext(workspaceKey) {
|
|
33
|
+
return `// app/layout.tsx (or pages/_app.tsx)
|
|
34
|
+
'use client';
|
|
35
|
+
import { useEffect } from 'react';
|
|
36
|
+
import { createGurulu } from '@gurulu/web';
|
|
37
|
+
|
|
38
|
+
const gurulu = createGurulu();
|
|
39
|
+
|
|
40
|
+
export function GuruluProvider({ children }: { children: React.ReactNode }) {
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
gurulu.init({ workspace: '${workspaceKey}' });
|
|
43
|
+
}, []);
|
|
44
|
+
return <>{children}</>;
|
|
45
|
+
}`;
|
|
46
|
+
}
|
|
47
|
+
function snippetNode(workspaceKey) {
|
|
48
|
+
return `import { createGurulu } from '@gurulu/node';
|
|
49
|
+
|
|
50
|
+
const gurulu = createGurulu({
|
|
51
|
+
workspace: '${workspaceKey}',
|
|
52
|
+
apiKey: process.env.GURULU_API_KEY,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// In your handler:
|
|
56
|
+
await gurulu.track('purchase.completed', {
|
|
57
|
+
user_id: 'u_42',
|
|
58
|
+
order_id: 'o_123',
|
|
59
|
+
total: 49.99,
|
|
60
|
+
});`;
|
|
61
|
+
}
|
|
62
|
+
function snippetExpress(workspaceKey) {
|
|
63
|
+
return `import express from 'express';
|
|
64
|
+
import { guruluMiddleware } from '@gurulu/node/middleware/express';
|
|
65
|
+
|
|
66
|
+
const app = express();
|
|
67
|
+
app.use(guruluMiddleware({
|
|
68
|
+
workspace: '${workspaceKey}',
|
|
69
|
+
apiKey: process.env.GURULU_API_KEY,
|
|
70
|
+
}));`;
|
|
71
|
+
}
|
|
72
|
+
function snippetHono(workspaceKey) {
|
|
73
|
+
return `import { Hono } from 'hono';
|
|
74
|
+
import { createGurulu } from '@gurulu/node';
|
|
75
|
+
|
|
76
|
+
const gurulu = createGurulu({
|
|
77
|
+
workspace: '${workspaceKey}',
|
|
78
|
+
apiKey: process.env.GURULU_API_KEY,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const app = new Hono();
|
|
82
|
+
app.post('/checkout/complete', async (c) => {
|
|
83
|
+
await gurulu.track('purchase.completed', await c.req.json());
|
|
84
|
+
return c.json({ ok: true });
|
|
85
|
+
});`;
|
|
86
|
+
}
|
|
87
|
+
function placementHintFor(framework) {
|
|
88
|
+
switch (framework) {
|
|
89
|
+
case "next":
|
|
90
|
+
return "Add the GuruluProvider to app/layout.tsx (App Router) or pages/_app.tsx (Pages Router) and wrap children.";
|
|
91
|
+
case "nuxt":
|
|
92
|
+
return "Add to plugins/gurulu.client.ts and register in nuxt.config.ts.";
|
|
93
|
+
case "svelte":
|
|
94
|
+
return "Add to src/routes/+layout.svelte inside onMount().";
|
|
95
|
+
case "astro":
|
|
96
|
+
return "Add to src/layouts/Base.astro inside a <script> tag (or use a hydrated component).";
|
|
97
|
+
case "vite":
|
|
98
|
+
case "react":
|
|
99
|
+
case "vue":
|
|
100
|
+
return "Add to src/main.ts (or your entry file) before mounting the app.";
|
|
101
|
+
case "express":
|
|
102
|
+
return "Register guruluMiddleware before your route handlers in your app entry file.";
|
|
103
|
+
case "fastify":
|
|
104
|
+
return "Register the Gurulu plugin via fastify.register() before route definitions.";
|
|
105
|
+
case "hono":
|
|
106
|
+
return "Initialize the SDK at the top of your app file; call track() inside route handlers.";
|
|
107
|
+
case "koa":
|
|
108
|
+
return "Add as Koa middleware (app.use) before your routes.";
|
|
109
|
+
case "node-server":
|
|
110
|
+
return "Initialize the SDK at startup; call track() from your handlers.";
|
|
111
|
+
default:
|
|
112
|
+
return "Initialize the SDK at your app entry point.";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function initSnippetFor(framework, sdk, workspaceKey) {
|
|
116
|
+
if (sdk === "@gurulu/node") {
|
|
117
|
+
if (framework === "express")
|
|
118
|
+
return snippetExpress(workspaceKey);
|
|
119
|
+
if (framework === "hono")
|
|
120
|
+
return snippetHono(workspaceKey);
|
|
121
|
+
return snippetNode(workspaceKey);
|
|
122
|
+
}
|
|
123
|
+
if (framework === "next")
|
|
124
|
+
return snippetNext(workspaceKey);
|
|
125
|
+
return snippetWeb(workspaceKey);
|
|
126
|
+
}
|
|
127
|
+
function envKeysFor(sdk, framework) {
|
|
128
|
+
if (sdk === "@gurulu/node") {
|
|
129
|
+
return [
|
|
130
|
+
{
|
|
131
|
+
key: "GURULU_API_KEY",
|
|
132
|
+
example: "sk_live_xxxxxxxxxxxx",
|
|
133
|
+
required: true
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
const envKey = framework === "next" ? "NEXT_PUBLIC_GURULU_WORKSPACE" : "VITE_GURULU_WORKSPACE";
|
|
138
|
+
return [
|
|
139
|
+
{
|
|
140
|
+
key: envKey,
|
|
141
|
+
example: "pk_live_xxxxxxxxxxxx",
|
|
142
|
+
required: false
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
function buildInstallPlan(detected, ctx = {}) {
|
|
147
|
+
const sdk = sdkFor(detected.framework);
|
|
148
|
+
const workspaceKey = ctx.writeKey ?? "pk_xxxxxxxxxxxx";
|
|
149
|
+
return {
|
|
150
|
+
sdk,
|
|
151
|
+
packageManager: detected.packageManager,
|
|
152
|
+
installCommand: installCmdFor(detected.packageManager, sdk),
|
|
153
|
+
initSnippet: initSnippetFor(detected.framework, sdk, workspaceKey),
|
|
154
|
+
envKeys: envKeysFor(sdk, detected.framework),
|
|
155
|
+
placementHint: placementHintFor(detected.framework),
|
|
156
|
+
framework: detected.framework
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
buildInstallPlan
|
|
161
|
+
};
|
package/package.json
CHANGED
|
@@ -1,33 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gurulu/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "BUSL-1.1",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"description": "Gurulu CLI. init / pull / push / validate / doctor — registry as code, local schema sync.",
|
|
11
|
+
"homepage": "https://gurulu.io",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/Preatan/gurulu.io.git",
|
|
15
|
+
"directory": "packages/cli"
|
|
16
|
+
},
|
|
5
17
|
"bin": {
|
|
6
|
-
"gurulu": "bin
|
|
18
|
+
"gurulu": "./dist/bin.js"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./detect": {
|
|
30
|
+
"types": "./dist/lib/detect.d.ts",
|
|
31
|
+
"import": "./dist/lib/detect.js",
|
|
32
|
+
"default": "./dist/lib/detect.js"
|
|
33
|
+
},
|
|
34
|
+
"./install-plan": {
|
|
35
|
+
"types": "./dist/lib/install-plan.d.ts",
|
|
36
|
+
"import": "./dist/lib/install-plan.js",
|
|
37
|
+
"default": "./dist/lib/install-plan.js"
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
7
40
|
},
|
|
8
|
-
"main": "dist/index.js",
|
|
9
41
|
"files": [
|
|
10
42
|
"dist",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
13
45
|
],
|
|
14
46
|
"scripts": {
|
|
15
|
-
"build": "
|
|
16
|
-
"
|
|
47
|
+
"build": "rm -rf dist && bun run build:js && bun run build:lib && bun run build:types && bun run build:bin",
|
|
48
|
+
"build:js": "bun build ./src/index.ts --outdir ./dist --target node --format=esm",
|
|
49
|
+
"build:lib": "bun build ./src/lib/detect.ts ./src/lib/install-plan.ts --outdir ./dist/lib --target node --format=esm",
|
|
50
|
+
"build:bin": "bun build ./src/bin.ts --outdir ./dist --target node --format=esm && chmod +x dist/bin.js",
|
|
51
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
52
|
+
"typecheck": "tsc --noEmit",
|
|
53
|
+
"test": "echo no-tests-yet",
|
|
54
|
+
"prepublishOnly": "bun run build",
|
|
55
|
+
"clean": "rm -rf dist .turbo"
|
|
17
56
|
},
|
|
18
57
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"@babel/traverse": "^7.24.0",
|
|
22
|
-
"@babel/generator": "^7.24.0"
|
|
58
|
+
"citty": "^0.1.6",
|
|
59
|
+
"undici": "^7.0.0"
|
|
23
60
|
},
|
|
24
61
|
"devDependencies": {
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
"@types/node": "^20.0.0"
|
|
28
|
-
},
|
|
29
|
-
"engines": {
|
|
30
|
-
"node": ">=18.0.0"
|
|
31
|
-
},
|
|
32
|
-
"license": "MIT"
|
|
62
|
+
"typescript": "^5.6.0"
|
|
63
|
+
}
|
|
33
64
|
}
|
package/bin/gurulu.js
DELETED