@dainprotocol/cli 1.2.36 → 1.3.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.
@@ -0,0 +1,9 @@
1
+ type Runtime = 'node' | 'workers' | 'bun';
2
+ interface BuildOptions {
3
+ config?: string;
4
+ runtime?: Runtime;
5
+ watch?: boolean;
6
+ deploy?: boolean;
7
+ }
8
+ export default function build(options: BuildOptions): Promise<void>;
9
+ export {};
@@ -1,267 +1,115 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __generator = (this && this.__generator) || function (thisArg, body) {
45
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
46
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
47
- function verb(n) { return function (v) { return step([n, v]); }; }
48
- function step(op) {
49
- if (f) throw new TypeError("Generator is already executing.");
50
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
51
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
52
- if (y = 0, t) op = [op[0] & 2, t.value];
53
- switch (op[0]) {
54
- case 0: case 1: t = op; break;
55
- case 4: _.label++; return { value: op[1], done: false };
56
- case 5: _.label++; y = op[1]; op = [0]; continue;
57
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
58
- default:
59
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
60
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
61
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
62
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
63
- if (t[2]) _.ops.pop();
64
- _.trys.pop(); continue;
1
+ import * as esbuild from 'esbuild';
2
+ import { getDainConfig, logError, logInfo } from '../utils.js';
3
+ import ora from 'ora';
4
+ import fs from 'fs-extra';
5
+ import path from 'path';
6
+ async function findWasmFiles(nodeModulesPath) {
7
+ const wasmFiles = [];
8
+ async function scanDir(dir) {
9
+ try {
10
+ const entries = await fs.readdir(dir, { withFileTypes: true });
11
+ for (const entry of entries) {
12
+ const fullPath = path.join(dir, entry.name);
13
+ if (entry.isDirectory() && entry.name !== '.bin' && entry.name !== '.cache') {
14
+ await scanDir(fullPath);
15
+ }
16
+ else if (entry.name.endsWith('.wasm') && (fullPath.includes('/dist/') || fullPath.includes('/build/'))) {
17
+ wasmFiles.push(fullPath);
18
+ }
65
19
  }
66
- op = body.call(thisArg, _);
67
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
68
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
69
- }
70
- };
71
- var __importDefault = (this && this.__importDefault) || function (mod) {
72
- return (mod && mod.__esModule) ? mod : { "default": mod };
73
- };
74
- Object.defineProperty(exports, "__esModule", { value: true });
75
- exports.default = build;
76
- var esbuild = __importStar(require("esbuild"));
77
- var utils_1 = require("../utils");
78
- var ora_1 = __importDefault(require("ora"));
79
- var fs_extra_1 = __importDefault(require("fs-extra"));
80
- var path_1 = __importDefault(require("path"));
81
- function findWasmFiles(nodeModulesPath) {
82
- return __awaiter(this, void 0, void 0, function () {
83
- function scanDir(dir) {
84
- return __awaiter(this, void 0, void 0, function () {
85
- var entries, _i, entries_1, entry, fullPath, _a;
86
- return __generator(this, function (_b) {
87
- switch (_b.label) {
88
- case 0:
89
- _b.trys.push([0, 7, , 8]);
90
- return [4 /*yield*/, fs_extra_1.default.readdir(dir, { withFileTypes: true })];
91
- case 1:
92
- entries = _b.sent();
93
- _i = 0, entries_1 = entries;
94
- _b.label = 2;
95
- case 2:
96
- if (!(_i < entries_1.length)) return [3 /*break*/, 6];
97
- entry = entries_1[_i];
98
- fullPath = path_1.default.join(dir, entry.name);
99
- if (!(entry.isDirectory() && entry.name !== '.bin' && entry.name !== '.cache')) return [3 /*break*/, 4];
100
- return [4 /*yield*/, scanDir(fullPath)];
101
- case 3:
102
- _b.sent();
103
- return [3 /*break*/, 5];
104
- case 4:
105
- if (entry.name.endsWith('.wasm') && (fullPath.includes('/dist/') || fullPath.includes('/build/'))) {
106
- wasmFiles.push(fullPath);
107
- }
108
- _b.label = 5;
109
- case 5:
110
- _i++;
111
- return [3 /*break*/, 2];
112
- case 6: return [3 /*break*/, 8];
113
- case 7:
114
- _a = _b.sent();
115
- return [3 /*break*/, 8];
116
- case 8: return [2 /*return*/];
117
- }
118
- });
119
- });
120
20
  }
121
- var wasmFiles;
122
- return __generator(this, function (_a) {
123
- switch (_a.label) {
124
- case 0:
125
- wasmFiles = [];
126
- return [4 /*yield*/, scanDir(nodeModulesPath)];
127
- case 1:
128
- _a.sent();
129
- return [2 /*return*/, wasmFiles];
130
- }
131
- });
132
- });
21
+ catch { }
22
+ }
23
+ await scanDir(nodeModulesPath);
24
+ return wasmFiles;
133
25
  }
134
- function copyWasmDependencies(bundlePath, nodeModulesPath, outDir) {
135
- return __awaiter(this, void 0, void 0, function () {
136
- var copiedFiles, bundleContent, wasmFiles, _i, wasmFiles_1, wasmPath, wasmName, error_1;
137
- return __generator(this, function (_a) {
138
- switch (_a.label) {
139
- case 0:
140
- copiedFiles = [];
141
- _a.label = 1;
142
- case 1:
143
- _a.trys.push([1, 8, , 9]);
144
- return [4 /*yield*/, fs_extra_1.default.readFile(bundlePath, 'utf-8')];
145
- case 2:
146
- bundleContent = _a.sent();
147
- return [4 /*yield*/, findWasmFiles(nodeModulesPath)];
148
- case 3:
149
- wasmFiles = _a.sent();
150
- _i = 0, wasmFiles_1 = wasmFiles;
151
- _a.label = 4;
152
- case 4:
153
- if (!(_i < wasmFiles_1.length)) return [3 /*break*/, 7];
154
- wasmPath = wasmFiles_1[_i];
155
- wasmName = path_1.default.basename(wasmPath);
156
- if (!bundleContent.includes(wasmName)) return [3 /*break*/, 6];
157
- return [4 /*yield*/, fs_extra_1.default.copy(wasmPath, path_1.default.join(outDir, wasmName))];
158
- case 5:
159
- _a.sent();
160
- copiedFiles.push(wasmName);
161
- _a.label = 6;
162
- case 6:
163
- _i++;
164
- return [3 /*break*/, 4];
165
- case 7: return [3 /*break*/, 9];
166
- case 8:
167
- error_1 = _a.sent();
168
- (0, utils_1.logInfo)("Warning: Could not process WASM dependencies: ".concat(error_1));
169
- return [3 /*break*/, 9];
170
- case 9: return [2 /*return*/, copiedFiles];
26
+ async function copyWasmDependencies(bundlePath, nodeModulesPath, outDir) {
27
+ const copiedFiles = [];
28
+ try {
29
+ const bundleContent = await fs.readFile(bundlePath, 'utf-8');
30
+ const wasmFiles = await findWasmFiles(nodeModulesPath);
31
+ for (const wasmPath of wasmFiles) {
32
+ const wasmName = path.basename(wasmPath);
33
+ if (bundleContent.includes(wasmName)) {
34
+ await fs.copy(wasmPath, path.join(outDir, wasmName));
35
+ copiedFiles.push(wasmName);
171
36
  }
172
- });
173
- });
37
+ }
38
+ }
39
+ catch (error) {
40
+ logInfo(`Warning: Could not process WASM dependencies: ${error}`);
41
+ }
42
+ return copiedFiles;
174
43
  }
175
- function build(options) {
176
- return __awaiter(this, void 0, void 0, function () {
177
- var spinner, config, runtime, outDir, dainDir, nodeModulesPath, buildOptions, context, targetDir, bundlePath, copiedWasm, staticDir, error_2;
178
- return __generator(this, function (_a) {
179
- switch (_a.label) {
180
- case 0:
181
- spinner = (0, ora_1.default)('Building project...').start();
182
- config = (0, utils_1.getDainConfig)(options.config);
183
- runtime = options.runtime || config.runtime || 'node';
184
- outDir = path_1.default.join(process.cwd(), config['out-dir'] || 'build');
185
- dainDir = path_1.default.join(process.cwd(), '.dain');
186
- nodeModulesPath = path_1.default.join(process.cwd(), 'node_modules');
187
- _a.label = 1;
188
- case 1:
189
- _a.trys.push([1, 14, , 15]);
190
- return [4 /*yield*/, fs_extra_1.default.ensureDir(outDir)];
191
- case 2:
192
- _a.sent();
193
- buildOptions = {
194
- entryPoints: [config['main-file']],
195
- bundle: true,
196
- sourcemap: true,
197
- outdir: outDir,
198
- };
199
- if (runtime === 'node') {
200
- Object.assign(buildOptions, { platform: 'node', target: 'es2020', minify: !options.watch });
201
- }
202
- else if (runtime === 'workers') {
203
- Object.assign(buildOptions, {
204
- format: 'esm',
205
- target: 'esnext',
206
- conditions: ['worker', 'workerd', 'browser'],
207
- outExtension: { '.js': '.mjs' },
208
- });
209
- }
210
- else {
211
- throw new Error("Unsupported runtime: ".concat(runtime));
212
- }
213
- if (!options.watch) return [3 /*break*/, 6];
214
- return [4 /*yield*/, fs_extra_1.default.ensureDir(dainDir)];
215
- case 3:
216
- _a.sent();
217
- return [4 /*yield*/, esbuild.context(buildOptions)];
218
- case 4:
219
- context = _a.sent();
220
- return [4 /*yield*/, context.watch()];
221
- case 5:
222
- _a.sent();
223
- (0, utils_1.logInfo)('Watching for file changes...');
224
- return [3 /*break*/, 8];
225
- case 6: return [4 /*yield*/, esbuild.build(buildOptions)];
226
- case 7:
227
- _a.sent();
228
- _a.label = 8;
229
- case 8:
230
- targetDir = options.watch ? dainDir : outDir;
231
- if (!(runtime === 'node')) return [3 /*break*/, 11];
232
- bundlePath = path_1.default.join(targetDir, 'index.js');
233
- return [4 /*yield*/, fs_extra_1.default.pathExists(bundlePath)];
234
- case 9:
235
- if (!_a.sent()) return [3 /*break*/, 11];
236
- return [4 /*yield*/, copyWasmDependencies(bundlePath, nodeModulesPath, targetDir)];
237
- case 10:
238
- copiedWasm = _a.sent();
239
- if (copiedWasm.length > 0)
240
- spinner.info("WASM files copied: ".concat(copiedWasm.join(', ')));
241
- _a.label = 11;
242
- case 11:
243
- staticDir = config['static-dir']
244
- ? path_1.default.join(process.cwd(), config['static-dir'])
245
- : path_1.default.join(process.cwd(), 'static');
246
- if (!fs_extra_1.default.existsSync(staticDir)) return [3 /*break*/, 13];
247
- return [4 /*yield*/, fs_extra_1.default.copy(staticDir, path_1.default.join(targetDir, 'static'))];
248
- case 12:
249
- _a.sent();
250
- spinner.info("Static files copied to ".concat(path_1.default.join(targetDir, 'static')));
251
- _a.label = 13;
252
- case 13:
253
- spinner.succeed("Build complete: ".concat(runtime, " runtime in ").concat(targetDir));
254
- if (!options.watch && !options.deploy)
255
- process.exit(0);
256
- return [3 /*break*/, 15];
257
- case 14:
258
- error_2 = _a.sent();
259
- spinner.fail('Build failed.');
260
- (0, utils_1.logError)('Build process encountered an error', error_2);
261
- process.exit(1);
262
- return [3 /*break*/, 15];
263
- case 15: return [2 /*return*/];
44
+ export default async function build(options) {
45
+ const spinner = ora('Building project...').start();
46
+ const config = getDainConfig(options.config);
47
+ const runtime = options.runtime || config.runtime || 'node';
48
+ const outDir = path.join(process.cwd(), config['out-dir'] || 'build');
49
+ const dainDir = path.join(process.cwd(), '.dain');
50
+ const nodeModulesPath = path.join(process.cwd(), 'node_modules');
51
+ try {
52
+ await fs.ensureDir(outDir);
53
+ const buildOptions = {
54
+ entryPoints: [config['main-file']],
55
+ bundle: true,
56
+ sourcemap: true,
57
+ outdir: outDir,
58
+ };
59
+ if (runtime === 'node') {
60
+ Object.assign(buildOptions, { platform: 'node', target: 'es2020', minify: !options.watch });
61
+ }
62
+ else if (runtime === 'workers') {
63
+ Object.assign(buildOptions, {
64
+ format: 'esm',
65
+ target: 'esnext',
66
+ conditions: ['worker', 'workerd', 'browser'],
67
+ outExtension: { '.js': '.mjs' },
68
+ });
69
+ }
70
+ else if (runtime === 'bun') {
71
+ Object.assign(buildOptions, {
72
+ platform: 'node',
73
+ target: 'esnext',
74
+ format: 'esm',
75
+ minify: !options.watch,
76
+ });
77
+ }
78
+ else {
79
+ throw new Error(`Unsupported runtime: ${runtime}`);
80
+ }
81
+ if (options.watch) {
82
+ await fs.ensureDir(dainDir);
83
+ const context = await esbuild.context(buildOptions);
84
+ await context.watch();
85
+ logInfo('Watching for file changes...');
86
+ }
87
+ else {
88
+ await esbuild.build(buildOptions);
89
+ }
90
+ const targetDir = options.watch ? dainDir : outDir;
91
+ if (runtime === 'node') {
92
+ const bundlePath = path.join(targetDir, 'index.js');
93
+ if (await fs.pathExists(bundlePath)) {
94
+ const copiedWasm = await copyWasmDependencies(bundlePath, nodeModulesPath, targetDir);
95
+ if (copiedWasm.length > 0)
96
+ spinner.info(`WASM files copied: ${copiedWasm.join(', ')}`);
264
97
  }
265
- });
266
- });
98
+ }
99
+ const staticDir = config['static-dir']
100
+ ? path.join(process.cwd(), config['static-dir'])
101
+ : path.join(process.cwd(), 'static');
102
+ if (fs.existsSync(staticDir)) {
103
+ await fs.copy(staticDir, path.join(targetDir, 'static'));
104
+ spinner.info(`Static files copied to ${path.join(targetDir, 'static')}`);
105
+ }
106
+ spinner.succeed(`Build complete: ${runtime} runtime in ${targetDir}`);
107
+ if (!options.watch && !options.deploy)
108
+ process.exit(0);
109
+ }
110
+ catch (error) {
111
+ spinner.fail('Build failed.');
112
+ logError('Build process encountered an error', error);
113
+ process.exit(1);
114
+ }
267
115
  }
@@ -0,0 +1 @@
1
+ export default function config(action: 'view' | 'edit', key?: string, value?: string): Promise<void>;
@@ -1,99 +1,40 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import { logError, logSuccess, logInfo } from '../utils.js';
4
+ export default async function config(action, key, value) {
5
+ const configPath = path.join(process.cwd(), 'dain.json');
6
+ try {
7
+ const config = await fs.readJSON(configPath);
8
+ if (action === 'view') {
9
+ if (key) {
10
+ logInfo(`${key}: ${config[key]}`);
32
11
  }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.default = config;
43
- var fs_extra_1 = __importDefault(require("fs-extra"));
44
- var path_1 = __importDefault(require("path"));
45
- var utils_1 = require("../utils");
46
- function config(action, key, value) {
47
- return __awaiter(this, void 0, void 0, function () {
48
- var configPath, config_1, error_1;
49
- return __generator(this, function (_a) {
50
- switch (_a.label) {
51
- case 0:
52
- configPath = path_1.default.join(process.cwd(), 'dain.json');
53
- _a.label = 1;
54
- case 1:
55
- _a.trys.push([1, 7, , 8]);
56
- return [4 /*yield*/, fs_extra_1.default.readJSON(configPath)];
57
- case 2:
58
- config_1 = _a.sent();
59
- if (!(action === 'view')) return [3 /*break*/, 3];
60
- if (key) {
61
- (0, utils_1.logInfo)("".concat(key, ": ").concat(config_1[key]));
62
- }
63
- else {
64
- console.log(JSON.stringify(config_1, null, 2));
65
- }
66
- process.exit(0);
67
- return [3 /*break*/, 6];
68
- case 3:
69
- if (!(action === 'edit' && key && value)) return [3 /*break*/, 5];
70
- if (key === 'runtime' && !['node', 'workers'].includes(value)) {
71
- (0, utils_1.logError)('Invalid runtime. Use "node" or "workers"');
72
- process.exit(1);
73
- }
74
- if (key === 'platform-base-url' && !value.startsWith('http')) {
75
- (0, utils_1.logError)('Invalid platform-base-url. It should start with http:// or https://');
76
- process.exit(1);
77
- }
78
- config_1[key] = value;
79
- return [4 /*yield*/, fs_extra_1.default.writeJSON(configPath, config_1, { spaces: 2 })];
80
- case 4:
81
- _a.sent();
82
- (0, utils_1.logSuccess)("Updated ".concat(key, " to ").concat(value));
83
- process.exit(0);
84
- return [3 /*break*/, 6];
85
- case 5:
86
- (0, utils_1.logError)('Invalid command. Use "view" or "edit <key> <value>"');
87
- process.exit(1);
88
- _a.label = 6;
89
- case 6: return [3 /*break*/, 8];
90
- case 7:
91
- error_1 = _a.sent();
92
- (0, utils_1.logError)('Error accessing configuration', error_1);
93
- process.exit(1);
94
- return [3 /*break*/, 8];
95
- case 8: return [2 /*return*/];
12
+ else {
13
+ console.log(JSON.stringify(config, null, 2));
14
+ }
15
+ process.exit(0);
16
+ }
17
+ else if (action === 'edit' && key && value) {
18
+ if (key === 'runtime' && !['node', 'workers'].includes(value)) {
19
+ logError('Invalid runtime. Use "node" or "workers"');
20
+ process.exit(1);
21
+ }
22
+ if (key === 'platform-base-url' && !value.startsWith('http')) {
23
+ logError('Invalid platform-base-url. It should start with http:// or https://');
24
+ process.exit(1);
96
25
  }
97
- });
98
- });
26
+ config[key] = value;
27
+ await fs.writeJSON(configPath, config, { spaces: 2 });
28
+ logSuccess(`Updated ${key} to ${value}`);
29
+ process.exit(0);
30
+ }
31
+ else {
32
+ logError('Invalid command. Use "view" or "edit <key> <value>"');
33
+ process.exit(1);
34
+ }
35
+ }
36
+ catch (error) {
37
+ logError('Error accessing configuration', error);
38
+ process.exit(1);
39
+ }
99
40
  }
@@ -0,0 +1,3 @@
1
+ export default function deploy(options: {
2
+ config?: string;
3
+ }): Promise<void>;