@curenorway/kode-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js ADDED
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deployCommand,
4
+ htmlCommand,
5
+ initCommand,
6
+ pullCommand,
7
+ pushCommand,
8
+ statusCommand,
9
+ watchCommand
10
+ } from "./chunk-NWXEBN2N.js";
11
+
12
+ // src/cli.ts
13
+ import { Command } from "commander";
14
+ import chalk from "chalk";
15
+ var program = new Command();
16
+ program.name("kode").description("CLI for Cure Kode - manage JS/CSS scripts for Webflow sites").version("1.0.0");
17
+ program.command("init").description("Initialize Cure Kode in current directory").option("-k, --api-key <key>", "API key").option("-s, --site-slug <slug>", "Site slug").option("-f, --force", "Reinitialize even if already configured").action((options) => {
18
+ initCommand(options);
19
+ });
20
+ program.command("pull").description("Download scripts from Cure to local files").argument("[script]", "Specific script slug to pull").option("-f, --force", "Overwrite local changes").action((script, options) => {
21
+ pullCommand({ script, ...options });
22
+ });
23
+ program.command("push").description("Upload local scripts to Cure").argument("[script]", "Specific script file or slug to push").option("-m, --message <message>", "Change summary").option("-a, --all", "Push all scripts even if unchanged").action((script, options) => {
24
+ pushCommand({ script, ...options });
25
+ });
26
+ program.command("watch").description("Watch for changes and auto-push").option("-d, --deploy", "Auto-deploy after each push").action((options) => {
27
+ watchCommand(options);
28
+ });
29
+ program.command("deploy [environment]").description("Deploy to staging or production").option("-p, --promote", "Promote staging to production").action((environment, options) => {
30
+ deployCommand(environment, options);
31
+ });
32
+ program.command("html <url>").description("Fetch and analyze HTML from a URL").option("-j, --json", "Output as JSON").option("--scripts", "Show only scripts").option("--styles", "Show only styles").action((url, options) => {
33
+ htmlCommand(url, options);
34
+ });
35
+ program.command("status").description("Show current status of scripts and deployments").option("-v, --verbose", "Show more details").action((options) => {
36
+ statusCommand(options);
37
+ });
38
+ program.showHelpAfterError();
39
+ console.log();
40
+ console.log(chalk.bold(" Cure Kode CLI"));
41
+ console.log(chalk.dim(" Manage JS/CSS for Webflow sites"));
42
+ console.log();
43
+ program.parse();
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Project-level configuration (.cure-kode/config.json)
3
+ */
4
+ interface ProjectConfig {
5
+ siteId: string;
6
+ siteSlug: string;
7
+ siteName: string;
8
+ apiKey: string;
9
+ apiUrl?: string;
10
+ scriptsDir?: string;
11
+ environment?: 'staging' | 'production';
12
+ }
13
+ /**
14
+ * Find project config by walking up directory tree
15
+ */
16
+ declare function findProjectRoot(startDir?: string): string | null;
17
+ /**
18
+ * Get project config
19
+ */
20
+ declare function getProjectConfig(projectRoot?: string): ProjectConfig | null;
21
+ /**
22
+ * Save project config
23
+ */
24
+ declare function saveProjectConfig(config: ProjectConfig, projectRoot?: string): void;
25
+ /**
26
+ * Get API URL (project config overrides global)
27
+ */
28
+ declare function getApiUrl(projectConfig?: ProjectConfig | null): string;
29
+ /**
30
+ * Get API key (project config required)
31
+ */
32
+ declare function getApiKey(projectConfig?: ProjectConfig | null): string | null;
33
+ /**
34
+ * Set global config
35
+ */
36
+ declare function setGlobalConfig(key: 'apiUrl' | 'defaultApiKey', value: string): void;
37
+ /**
38
+ * Get scripts directory path
39
+ */
40
+ declare function getScriptsDir(projectRoot: string, projectConfig?: ProjectConfig | null): string;
41
+
42
+ /**
43
+ * Cure Kode API Client
44
+ */
45
+ interface CdnSite {
46
+ id: string;
47
+ slug: string;
48
+ name: string;
49
+ domain: string | null;
50
+ staging_domain: string | null;
51
+ production_domain: string | null;
52
+ client_id: string | null;
53
+ }
54
+ interface CdnScript {
55
+ id: string;
56
+ site_id: string;
57
+ name: string;
58
+ slug: string;
59
+ type: 'javascript' | 'css';
60
+ scope: 'global' | 'page-specific';
61
+ content: string;
62
+ current_version: number;
63
+ is_active: boolean;
64
+ load_order: number;
65
+ }
66
+ interface CdnPage {
67
+ id: string;
68
+ site_id: string;
69
+ name: string;
70
+ slug: string;
71
+ url_patterns: string[];
72
+ pattern_type: 'exact' | 'prefix' | 'wildcard' | 'regex';
73
+ priority: number;
74
+ is_active: boolean;
75
+ }
76
+ interface CdnDeployment {
77
+ id: string;
78
+ site_id: string;
79
+ version: string;
80
+ environment: 'staging' | 'production';
81
+ status: 'pending' | 'deploying' | 'success' | 'failed';
82
+ started_at: string;
83
+ completed_at: string | null;
84
+ }
85
+ interface ParsedHtmlResult {
86
+ url: string;
87
+ title: string | null;
88
+ domain: string;
89
+ htmlPreview: string;
90
+ scripts: {
91
+ webflow: any[];
92
+ cureKode: any[];
93
+ thirdParty: any[];
94
+ custom: any[];
95
+ };
96
+ styles: any[];
97
+ detectedComponents: string[];
98
+ stats: {
99
+ totalScripts: number;
100
+ totalStyles: number;
101
+ inlineScripts: number;
102
+ externalScripts: number;
103
+ };
104
+ }
105
+ declare class KodeApiError extends Error {
106
+ statusCode: number;
107
+ response?: any | undefined;
108
+ constructor(message: string, statusCode: number, response?: any | undefined);
109
+ }
110
+ declare class KodeApiClient {
111
+ private baseUrl;
112
+ private apiKey;
113
+ constructor(config: ProjectConfig);
114
+ private request;
115
+ getSite(siteId: string): Promise<CdnSite>;
116
+ listSites(): Promise<CdnSite[]>;
117
+ listScripts(siteId: string): Promise<CdnScript[]>;
118
+ getScript(scriptId: string): Promise<CdnScript>;
119
+ createScript(siteId: string, data: {
120
+ name: string;
121
+ slug: string;
122
+ type: 'javascript' | 'css';
123
+ scope?: 'global' | 'page-specific';
124
+ content?: string;
125
+ }): Promise<CdnScript>;
126
+ updateScript(scriptId: string, data: {
127
+ content?: string;
128
+ name?: string;
129
+ scope?: 'global' | 'page-specific';
130
+ changeSummary?: string;
131
+ }): Promise<CdnScript>;
132
+ deleteScript(scriptId: string): Promise<void>;
133
+ uploadScript(data: {
134
+ siteSlug: string;
135
+ scriptSlug: string;
136
+ content: string;
137
+ type: 'javascript' | 'css';
138
+ scope?: 'global' | 'page-specific';
139
+ changeSummary?: string;
140
+ }): Promise<CdnScript>;
141
+ listPages(siteId: string): Promise<CdnPage[]>;
142
+ deploy(siteId: string, environment?: 'staging' | 'production'): Promise<CdnDeployment>;
143
+ promoteToProduction(siteId: string, stagingDeploymentId?: string): Promise<CdnDeployment>;
144
+ getDeploymentStatus(siteId: string): Promise<{
145
+ staging: {
146
+ latest: CdnDeployment | null;
147
+ lastSuccessful: any;
148
+ };
149
+ production: {
150
+ latest: CdnDeployment | null;
151
+ lastSuccessful: any;
152
+ };
153
+ canPromote: boolean;
154
+ }>;
155
+ fetchHtml(url: string): Promise<ParsedHtmlResult>;
156
+ }
157
+ /**
158
+ * Create API client from project config
159
+ */
160
+ declare function createApiClient(config: ProjectConfig): KodeApiClient;
161
+
162
+ /**
163
+ * Initialize Cure Kode in current directory
164
+ */
165
+ declare function initCommand(options: {
166
+ apiKey?: string;
167
+ siteSlug?: string;
168
+ force?: boolean;
169
+ }): Promise<void>;
170
+
171
+ /**
172
+ * Pull scripts from remote to local
173
+ */
174
+ declare function pullCommand(options: {
175
+ script?: string;
176
+ force?: boolean;
177
+ }): Promise<void>;
178
+
179
+ /**
180
+ * Push local scripts to remote
181
+ */
182
+ declare function pushCommand(options: {
183
+ script?: string;
184
+ message?: string;
185
+ all?: boolean;
186
+ }): Promise<void>;
187
+
188
+ /**
189
+ * Watch for local changes and auto-push
190
+ */
191
+ declare function watchCommand(options: {
192
+ deploy?: boolean;
193
+ }): Promise<void>;
194
+
195
+ /**
196
+ * Deploy to staging or production
197
+ */
198
+ declare function deployCommand(environment?: 'staging' | 'production', options?: {
199
+ promote?: boolean;
200
+ }): Promise<void>;
201
+
202
+ /**
203
+ * Fetch and display HTML from a URL
204
+ */
205
+ declare function htmlCommand(url: string, options?: {
206
+ json?: boolean;
207
+ scripts?: boolean;
208
+ styles?: boolean;
209
+ }): Promise<void>;
210
+
211
+ /**
212
+ * Show current status of scripts and deployments
213
+ */
214
+ declare function statusCommand(options?: {
215
+ verbose?: boolean;
216
+ }): Promise<void>;
217
+
218
+ export { type CdnDeployment, type CdnPage, type CdnScript, type CdnSite, KodeApiClient, KodeApiError, type ParsedHtmlResult, type ProjectConfig, createApiClient, deployCommand, findProjectRoot, getApiKey, getApiUrl, getProjectConfig, getScriptsDir, htmlCommand, initCommand, pullCommand, pushCommand, saveProjectConfig, setGlobalConfig, statusCommand, watchCommand };
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ import {
2
+ KodeApiClient,
3
+ KodeApiError,
4
+ createApiClient,
5
+ deployCommand,
6
+ findProjectRoot,
7
+ getApiKey,
8
+ getApiUrl,
9
+ getProjectConfig,
10
+ getScriptsDir,
11
+ htmlCommand,
12
+ initCommand,
13
+ pullCommand,
14
+ pushCommand,
15
+ saveProjectConfig,
16
+ setGlobalConfig,
17
+ statusCommand,
18
+ watchCommand
19
+ } from "./chunk-NWXEBN2N.js";
20
+ export {
21
+ KodeApiClient,
22
+ KodeApiError,
23
+ createApiClient,
24
+ deployCommand,
25
+ findProjectRoot,
26
+ getApiKey,
27
+ getApiUrl,
28
+ getProjectConfig,
29
+ getScriptsDir,
30
+ htmlCommand,
31
+ initCommand,
32
+ pullCommand,
33
+ pushCommand,
34
+ saveProjectConfig,
35
+ setGlobalConfig,
36
+ statusCommand,
37
+ watchCommand
38
+ };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@curenorway/kode-cli",
3
+ "version": "1.0.0",
4
+ "description": "CLI tool for Cure Kode - manage JS/CSS scripts for Webflow sites",
5
+ "type": "module",
6
+ "bin": {
7
+ "cure-kode": "./dist/cli.js",
8
+ "kode": "./dist/cli.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsup src/cli.ts src/index.ts --format esm --dts --clean",
17
+ "dev": "tsup src/cli.ts src/index.ts --format esm --dts --watch",
18
+ "typecheck": "tsc --noEmit",
19
+ "prepublishOnly": "pnpm build"
20
+ },
21
+ "dependencies": {
22
+ "chalk": "^5.3.0",
23
+ "chokidar": "^3.5.3",
24
+ "commander": "^11.1.0",
25
+ "conf": "^12.0.0",
26
+ "enquirer": "^2.4.1",
27
+ "ora": "^8.0.1"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^20.10.0",
31
+ "tsup": "^8.0.1",
32
+ "typescript": "^5.3.2"
33
+ },
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "keywords": [
38
+ "cure",
39
+ "kode",
40
+ "webflow",
41
+ "cdn",
42
+ "cli"
43
+ ],
44
+ "author": "Cure Norway",
45
+ "license": "MIT",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/curenorway/cure-app-v2",
49
+ "directory": "packages/kode-cli"
50
+ }
51
+ }