@ketrics/ketrics-cli 0.1.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/README.md +326 -0
- package/dist/bin/ketrics.d.ts +8 -0
- package/dist/bin/ketrics.d.ts.map +1 -0
- package/dist/bin/ketrics.js +12 -0
- package/dist/bin/ketrics.js.map +1 -0
- package/dist/src/cli.d.ts +11 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +77 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/build.d.ts +10 -0
- package/dist/src/commands/build.d.ts.map +1 -0
- package/dist/src/commands/build.js +35 -0
- package/dist/src/commands/build.js.map +1 -0
- package/dist/src/commands/create.d.ts +11 -0
- package/dist/src/commands/create.d.ts.map +1 -0
- package/dist/src/commands/create.js +170 -0
- package/dist/src/commands/create.js.map +1 -0
- package/dist/src/commands/deploy.d.ts +11 -0
- package/dist/src/commands/deploy.d.ts.map +1 -0
- package/dist/src/commands/deploy.js +105 -0
- package/dist/src/commands/deploy.js.map +1 -0
- package/dist/src/commands/run.d.ts +11 -0
- package/dist/src/commands/run.d.ts.map +1 -0
- package/dist/src/commands/run.js +236 -0
- package/dist/src/commands/run.js.map +1 -0
- package/dist/src/commands/validate.d.ts +10 -0
- package/dist/src/commands/validate.d.ts.map +1 -0
- package/dist/src/commands/validate.js +46 -0
- package/dist/src/commands/validate.js.map +1 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +29 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/services/api-client.d.ts +14 -0
- package/dist/src/services/api-client.d.ts.map +1 -0
- package/dist/src/services/api-client.js +57 -0
- package/dist/src/services/api-client.js.map +1 -0
- package/dist/src/services/build-service.d.ts +40 -0
- package/dist/src/services/build-service.d.ts.map +1 -0
- package/dist/src/services/build-service.js +130 -0
- package/dist/src/services/build-service.js.map +1 -0
- package/dist/src/services/config-service.d.ts +35 -0
- package/dist/src/services/config-service.d.ts.map +1 -0
- package/dist/src/services/config-service.js +204 -0
- package/dist/src/services/config-service.js.map +1 -0
- package/dist/src/services/template-service.d.ts +51 -0
- package/dist/src/services/template-service.d.ts.map +1 -0
- package/dist/src/services/template-service.js +214 -0
- package/dist/src/services/template-service.js.map +1 -0
- package/dist/src/services/upload-service.d.ts +13 -0
- package/dist/src/services/upload-service.d.ts.map +1 -0
- package/dist/src/services/upload-service.js +54 -0
- package/dist/src/services/upload-service.js.map +1 -0
- package/dist/src/services/zip-service.d.ts +55 -0
- package/dist/src/services/zip-service.d.ts.map +1 -0
- package/dist/src/services/zip-service.js +219 -0
- package/dist/src/services/zip-service.js.map +1 -0
- package/dist/src/types/index.d.ts +188 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +50 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/logger.d.ts +52 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +95 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/dist/src/utils/spinner.d.ts +15 -0
- package/dist/src/utils/spinner.d.ts.map +1 -0
- package/dist/src/utils/spinner.js +38 -0
- package/dist/src/utils/spinner.js.map +1 -0
- package/package.json +47 -0
- package/templates/ketrics-app-v1/.env.example +17 -0
- package/templates/ketrics-app-v1/README.md +134 -0
- package/templates/ketrics-app-v1/backend/package-lock.json +716 -0
- package/templates/ketrics-app-v1/backend/package.json +18 -0
- package/templates/ketrics-app-v1/backend/src/index.ts +41 -0
- package/templates/ketrics-app-v1/backend/src/volume.ts +48 -0
- package/templates/ketrics-app-v1/backend/tsconfig.json +16 -0
- package/templates/ketrics-app-v1/frontend/index.html +13 -0
- package/templates/ketrics-app-v1/frontend/package-lock.json +1981 -0
- package/templates/ketrics-app-v1/frontend/package.json +24 -0
- package/templates/ketrics-app-v1/frontend/src/App.css +121 -0
- package/templates/ketrics-app-v1/frontend/src/App.tsx +109 -0
- package/templates/ketrics-app-v1/frontend/src/main.tsx +10 -0
- package/templates/ketrics-app-v1/frontend/src/services/index.ts +55 -0
- package/templates/ketrics-app-v1/frontend/tsconfig.json +21 -0
- package/templates/ketrics-app-v1/frontend/tsconfig.node.json +11 -0
- package/templates/ketrics-app-v1/frontend/vite.config.ts +11 -0
- package/templates/ketrics-app-v1/ketrics.config.json +10 -0
- package/templates/ketrics-app-v1/tests/test.echo.json +13 -0
- package/templates/ketrics-app-v1/tests/test.greet.json +11 -0
- package/templates/ketrics-app-v1/tests/test.info.json +9 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload Service
|
|
3
|
+
*
|
|
4
|
+
* Handles file uploads to S3 using presigned URLs.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Upload ZIP buffer to S3 presigned URL
|
|
8
|
+
*
|
|
9
|
+
* @param presignedUrl - S3 presigned URL for upload
|
|
10
|
+
* @param zipBuffer - ZIP file buffer
|
|
11
|
+
*/
|
|
12
|
+
export declare function uploadToS3(presignedUrl: string, zipBuffer: Buffer): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=upload-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-service.d.ts","sourceRoot":"","sources":["../../../src/services/upload-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCvF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Upload Service
|
|
4
|
+
*
|
|
5
|
+
* Handles file uploads to S3 using presigned URLs.
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.uploadToS3 = uploadToS3;
|
|
12
|
+
const axios_1 = __importDefault(require("axios"));
|
|
13
|
+
/**
|
|
14
|
+
* Upload ZIP buffer to S3 presigned URL
|
|
15
|
+
*
|
|
16
|
+
* @param presignedUrl - S3 presigned URL for upload
|
|
17
|
+
* @param zipBuffer - ZIP file buffer
|
|
18
|
+
*/
|
|
19
|
+
async function uploadToS3(presignedUrl, zipBuffer) {
|
|
20
|
+
try {
|
|
21
|
+
await axios_1.default.put(presignedUrl, zipBuffer, {
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/zip",
|
|
24
|
+
"Content-Length": zipBuffer.length,
|
|
25
|
+
},
|
|
26
|
+
maxContentLength: Infinity,
|
|
27
|
+
maxBodyLength: Infinity,
|
|
28
|
+
timeout: 300000, // 5 minute timeout for large uploads
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
33
|
+
const axiosError = error;
|
|
34
|
+
if (axiosError.response) {
|
|
35
|
+
const status = axiosError.response.status;
|
|
36
|
+
switch (status) {
|
|
37
|
+
case 400:
|
|
38
|
+
throw new Error("Upload failed: Invalid request. The presigned URL may have expired.");
|
|
39
|
+
case 403:
|
|
40
|
+
throw new Error("Upload failed: Access denied. The presigned URL may have expired or been used.");
|
|
41
|
+
case 413:
|
|
42
|
+
throw new Error("Upload failed: File too large. Maximum upload size exceeded.");
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(`Upload failed with status ${status}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (axiosError.request) {
|
|
48
|
+
throw new Error("Upload failed: Network error. Please check your internet connection.");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=upload-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP Service
|
|
3
|
+
*
|
|
4
|
+
* Creates ZIP archives from source files based on include/exclude patterns.
|
|
5
|
+
*/
|
|
6
|
+
import type { KetricsConfig, FileInfo } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Format file size for display
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatSize(bytes: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* Collect files based on include/exclude patterns
|
|
13
|
+
*
|
|
14
|
+
* @param config - Ketrics configuration
|
|
15
|
+
* @returns Array of file information
|
|
16
|
+
*/
|
|
17
|
+
export declare function collectFiles(config: KetricsConfig): Promise<FileInfo[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Create ZIP archive from collected files
|
|
20
|
+
*
|
|
21
|
+
* @param files - Array of files to include
|
|
22
|
+
* @returns ZIP buffer
|
|
23
|
+
*/
|
|
24
|
+
export declare function createZipBuffer(files: FileInfo[]): Promise<Buffer>;
|
|
25
|
+
/**
|
|
26
|
+
* Get total size of files
|
|
27
|
+
*/
|
|
28
|
+
export declare function getTotalSize(files: FileInfo[]): number;
|
|
29
|
+
/**
|
|
30
|
+
* Create ZIP bundle from configuration
|
|
31
|
+
*
|
|
32
|
+
* @param config - Ketrics configuration
|
|
33
|
+
* @returns Object with buffer, files, and sizes
|
|
34
|
+
*/
|
|
35
|
+
export declare function createZipBundle(config: KetricsConfig): Promise<{
|
|
36
|
+
buffer: Buffer;
|
|
37
|
+
files: FileInfo[];
|
|
38
|
+
totalSourceSize: number;
|
|
39
|
+
zipSize: number;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Create ZIP bundle from frontend and backend dist directories
|
|
43
|
+
* Creates flat structure: frontend/ and backend/ folders at ZIP root
|
|
44
|
+
*
|
|
45
|
+
* @param frontendDistPath - Path to frontend dist directory
|
|
46
|
+
* @param backendDistPath - Path to backend dist directory
|
|
47
|
+
* @returns Object with buffer, files, and sizes
|
|
48
|
+
*/
|
|
49
|
+
export declare function createDeploymentZipBundle(frontendDistPath: string, backendDistPath: string): Promise<{
|
|
50
|
+
buffer: Buffer;
|
|
51
|
+
files: FileInfo[];
|
|
52
|
+
totalSourceSize: number;
|
|
53
|
+
zipSize: number;
|
|
54
|
+
}>;
|
|
55
|
+
//# sourceMappingURL=zip-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip-service.d.ts","sourceRoot":"","sources":["../../../src/services/zip-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExD;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAoC7E;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA2BxE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAEtD;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAyBD;AAgCD;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAC7C,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CA0BD"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ZIP Service
|
|
4
|
+
*
|
|
5
|
+
* Creates ZIP archives from source files based on include/exclude patterns.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.formatSize = formatSize;
|
|
45
|
+
exports.collectFiles = collectFiles;
|
|
46
|
+
exports.createZipBuffer = createZipBuffer;
|
|
47
|
+
exports.getTotalSize = getTotalSize;
|
|
48
|
+
exports.createZipBundle = createZipBundle;
|
|
49
|
+
exports.createDeploymentZipBundle = createDeploymentZipBundle;
|
|
50
|
+
const fs = __importStar(require("fs"));
|
|
51
|
+
const path = __importStar(require("path"));
|
|
52
|
+
const archiver_1 = __importDefault(require("archiver"));
|
|
53
|
+
const glob_1 = require("glob");
|
|
54
|
+
/**
|
|
55
|
+
* Format file size for display
|
|
56
|
+
*/
|
|
57
|
+
function formatSize(bytes) {
|
|
58
|
+
if (bytes === 0)
|
|
59
|
+
return '0 B';
|
|
60
|
+
const k = 1024;
|
|
61
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
62
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
63
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Collect files based on include/exclude patterns
|
|
67
|
+
*
|
|
68
|
+
* @param config - Ketrics configuration
|
|
69
|
+
* @returns Array of file information
|
|
70
|
+
*/
|
|
71
|
+
async function collectFiles(config) {
|
|
72
|
+
const cwd = process.cwd();
|
|
73
|
+
const files = [];
|
|
74
|
+
// Process each include pattern
|
|
75
|
+
for (const pattern of config.include) {
|
|
76
|
+
const matches = await (0, glob_1.glob)(pattern, {
|
|
77
|
+
cwd,
|
|
78
|
+
ignore: config.exclude,
|
|
79
|
+
nodir: true,
|
|
80
|
+
dot: false,
|
|
81
|
+
});
|
|
82
|
+
for (const match of matches) {
|
|
83
|
+
const fullPath = path.join(cwd, match);
|
|
84
|
+
// Skip if already added
|
|
85
|
+
if (files.some((f) => f.path === fullPath)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
// Get file stats
|
|
89
|
+
try {
|
|
90
|
+
const stats = fs.statSync(fullPath);
|
|
91
|
+
files.push({
|
|
92
|
+
path: fullPath,
|
|
93
|
+
relativePath: match,
|
|
94
|
+
size: stats.size,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Skip files that can't be read
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return files;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create ZIP archive from collected files
|
|
106
|
+
*
|
|
107
|
+
* @param files - Array of files to include
|
|
108
|
+
* @returns ZIP buffer
|
|
109
|
+
*/
|
|
110
|
+
async function createZipBuffer(files) {
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
const chunks = [];
|
|
113
|
+
const archive = (0, archiver_1.default)('zip', {
|
|
114
|
+
zlib: { level: 9 }, // Maximum compression
|
|
115
|
+
});
|
|
116
|
+
archive.on('data', (chunk) => {
|
|
117
|
+
chunks.push(chunk);
|
|
118
|
+
});
|
|
119
|
+
archive.on('end', () => {
|
|
120
|
+
resolve(Buffer.concat(chunks));
|
|
121
|
+
});
|
|
122
|
+
archive.on('error', (err) => {
|
|
123
|
+
reject(err);
|
|
124
|
+
});
|
|
125
|
+
// Add files to archive
|
|
126
|
+
for (const file of files) {
|
|
127
|
+
archive.file(file.path, { name: file.relativePath });
|
|
128
|
+
}
|
|
129
|
+
// Finalize archive
|
|
130
|
+
archive.finalize();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get total size of files
|
|
135
|
+
*/
|
|
136
|
+
function getTotalSize(files) {
|
|
137
|
+
return files.reduce((sum, file) => sum + file.size, 0);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Create ZIP bundle from configuration
|
|
141
|
+
*
|
|
142
|
+
* @param config - Ketrics configuration
|
|
143
|
+
* @returns Object with buffer, files, and sizes
|
|
144
|
+
*/
|
|
145
|
+
async function createZipBundle(config) {
|
|
146
|
+
// Collect files
|
|
147
|
+
const files = await collectFiles(config);
|
|
148
|
+
if (files.length === 0) {
|
|
149
|
+
throw new Error('No files found matching include patterns.\n' +
|
|
150
|
+
`Include: ${config.include.join(', ')}\n` +
|
|
151
|
+
`Exclude: ${config.exclude.join(', ')}\n` +
|
|
152
|
+
'Make sure you have built your application before deploying.');
|
|
153
|
+
}
|
|
154
|
+
// Get total source size
|
|
155
|
+
const totalSourceSize = getTotalSize(files);
|
|
156
|
+
// Create ZIP buffer
|
|
157
|
+
const buffer = await createZipBuffer(files);
|
|
158
|
+
return {
|
|
159
|
+
buffer,
|
|
160
|
+
files,
|
|
161
|
+
totalSourceSize,
|
|
162
|
+
zipSize: buffer.length,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Collect files from a directory recursively
|
|
167
|
+
*/
|
|
168
|
+
function collectFilesFromDir(dir, prefix) {
|
|
169
|
+
const files = [];
|
|
170
|
+
function walk(currentDir, relativePath) {
|
|
171
|
+
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
172
|
+
for (const entry of entries) {
|
|
173
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
174
|
+
const relPath = relativePath ? path.join(relativePath, entry.name) : entry.name;
|
|
175
|
+
if (entry.isDirectory()) {
|
|
176
|
+
walk(fullPath, relPath);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
const stats = fs.statSync(fullPath);
|
|
180
|
+
files.push({
|
|
181
|
+
path: fullPath,
|
|
182
|
+
relativePath: path.join(prefix, relPath),
|
|
183
|
+
size: stats.size,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
walk(dir, '');
|
|
189
|
+
return files;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Create ZIP bundle from frontend and backend dist directories
|
|
193
|
+
* Creates flat structure: frontend/ and backend/ folders at ZIP root
|
|
194
|
+
*
|
|
195
|
+
* @param frontendDistPath - Path to frontend dist directory
|
|
196
|
+
* @param backendDistPath - Path to backend dist directory
|
|
197
|
+
* @returns Object with buffer, files, and sizes
|
|
198
|
+
*/
|
|
199
|
+
async function createDeploymentZipBundle(frontendDistPath, backendDistPath) {
|
|
200
|
+
// Collect files from both dist directories
|
|
201
|
+
const frontendFiles = collectFilesFromDir(frontendDistPath, 'frontend');
|
|
202
|
+
const backendFiles = collectFilesFromDir(backendDistPath, 'backend');
|
|
203
|
+
const files = [...frontendFiles, ...backendFiles];
|
|
204
|
+
if (files.length === 0) {
|
|
205
|
+
throw new Error('No files found in dist directories.\n' +
|
|
206
|
+
'Make sure both frontend and backend have been built.');
|
|
207
|
+
}
|
|
208
|
+
// Get total source size
|
|
209
|
+
const totalSourceSize = getTotalSize(files);
|
|
210
|
+
// Create ZIP buffer
|
|
211
|
+
const buffer = await createZipBuffer(files);
|
|
212
|
+
return {
|
|
213
|
+
buffer,
|
|
214
|
+
files,
|
|
215
|
+
totalSourceSize,
|
|
216
|
+
zipSize: buffer.length,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=zip-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip-service.js","sourceRoot":"","sources":["../../../src/services/zip-service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWH,gCAMC;AAQD,oCAoCC;AAQD,0CA2BC;AAKD,oCAEC;AAQD,0CA8BC;AAwCD,8DAkCC;AArND,uCAAyB;AACzB,2CAA6B;AAC7B,wDAAgC;AAChC,+BAA4B;AAG5B;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAa;IACtC,IAAI,KAAK,KAAK,C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KAAK;QACL,eAAe;QACf,OAAO,EAAE,MAAM,CAAC,MAAM;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ketrics CLI Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for CLI configuration, API responses, and deployment operations.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Zod schema for ketrics.config.json validation
|
|
9
|
+
*/
|
|
10
|
+
export declare const ketricsConfigSchema: z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
version: z.ZodString;
|
|
13
|
+
description: z.ZodOptional<z.ZodString>;
|
|
14
|
+
runtime: z.ZodDefault<z.ZodEnum<["nodejs18", "nodejs20", "static"]>>;
|
|
15
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
16
|
+
entry: z.ZodString;
|
|
17
|
+
include: z.ZodArray<z.ZodString, "many">;
|
|
18
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
name: string;
|
|
21
|
+
version: string;
|
|
22
|
+
runtime: "nodejs18" | "nodejs20" | "static";
|
|
23
|
+
actions: string[];
|
|
24
|
+
entry: string;
|
|
25
|
+
include: string[];
|
|
26
|
+
exclude: string[];
|
|
27
|
+
description?: string | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
name: string;
|
|
30
|
+
version: string;
|
|
31
|
+
actions: string[];
|
|
32
|
+
entry: string;
|
|
33
|
+
include: string[];
|
|
34
|
+
description?: string | undefined;
|
|
35
|
+
runtime?: "nodejs18" | "nodejs20" | "static" | undefined;
|
|
36
|
+
exclude?: string[] | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
export type KetricsConfig = z.infer<typeof ketricsConfigSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* Zod schema for environment variables validation
|
|
41
|
+
*/
|
|
42
|
+
export declare const envConfigSchema: z.ZodObject<{
|
|
43
|
+
KETRICS_TOKEN: z.ZodString;
|
|
44
|
+
KETRICS_API_URL: z.ZodString;
|
|
45
|
+
KETRICS_TENANT_ID: z.ZodString;
|
|
46
|
+
KETRICS_APPLICATION_ID: z.ZodString;
|
|
47
|
+
KETRICS_AUTH_TOKEN: z.ZodOptional<z.ZodString>;
|
|
48
|
+
KETRICS_RUNTIME_URL: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
KETRICS_TOKEN: string;
|
|
51
|
+
KETRICS_API_URL: string;
|
|
52
|
+
KETRICS_TENANT_ID: string;
|
|
53
|
+
KETRICS_APPLICATION_ID: string;
|
|
54
|
+
KETRICS_AUTH_TOKEN?: string | undefined;
|
|
55
|
+
KETRICS_RUNTIME_URL?: string | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
KETRICS_TOKEN: string;
|
|
58
|
+
KETRICS_API_URL: string;
|
|
59
|
+
KETRICS_TENANT_ID: string;
|
|
60
|
+
KETRICS_APPLICATION_ID: string;
|
|
61
|
+
KETRICS_AUTH_TOKEN?: string | undefined;
|
|
62
|
+
KETRICS_RUNTIME_URL?: string | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
export type EnvConfig = z.infer<typeof envConfigSchema>;
|
|
65
|
+
/**
|
|
66
|
+
* Combined configuration from ketrics.config.json and .env
|
|
67
|
+
*/
|
|
68
|
+
export interface FullConfig {
|
|
69
|
+
ketrics: KetricsConfig;
|
|
70
|
+
env: EnvConfig;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* API response from deploy endpoint
|
|
74
|
+
*/
|
|
75
|
+
export interface DeployResponse {
|
|
76
|
+
success: boolean;
|
|
77
|
+
data: {
|
|
78
|
+
uploadUrl: string;
|
|
79
|
+
deploymentId: string;
|
|
80
|
+
s3Key: string;
|
|
81
|
+
expiresAt: string;
|
|
82
|
+
expiresInSeconds: number;
|
|
83
|
+
};
|
|
84
|
+
message: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* File information for deployment
|
|
88
|
+
*/
|
|
89
|
+
export interface FileInfo {
|
|
90
|
+
path: string;
|
|
91
|
+
relativePath: string;
|
|
92
|
+
size: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Deployment result
|
|
96
|
+
*/
|
|
97
|
+
export interface DeploymentResult {
|
|
98
|
+
success: boolean;
|
|
99
|
+
deploymentId: string;
|
|
100
|
+
filesDeployed: number;
|
|
101
|
+
totalSize: number;
|
|
102
|
+
s3Key: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Validation result
|
|
106
|
+
*/
|
|
107
|
+
export interface ValidationResult {
|
|
108
|
+
valid: boolean;
|
|
109
|
+
errors: string[];
|
|
110
|
+
warnings: string[];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* CLI options for deploy command
|
|
114
|
+
*/
|
|
115
|
+
export interface DeployOptions {
|
|
116
|
+
config?: string;
|
|
117
|
+
env?: string;
|
|
118
|
+
dryRun?: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* CLI options for create command
|
|
122
|
+
*/
|
|
123
|
+
export interface CreateOptions {
|
|
124
|
+
template?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Template information
|
|
128
|
+
*/
|
|
129
|
+
export interface TemplateInfo {
|
|
130
|
+
name: string;
|
|
131
|
+
path: string;
|
|
132
|
+
description: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Zod schema for run file validation (*.info.json)
|
|
136
|
+
*/
|
|
137
|
+
export declare const runFileSchema: z.ZodObject<{
|
|
138
|
+
endpoint: z.ZodString;
|
|
139
|
+
method: z.ZodDefault<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>>;
|
|
140
|
+
headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
141
|
+
body: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
endpoint: string;
|
|
144
|
+
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
145
|
+
headers: Record<string, string>;
|
|
146
|
+
body?: any;
|
|
147
|
+
}, {
|
|
148
|
+
endpoint: string;
|
|
149
|
+
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | undefined;
|
|
150
|
+
headers?: Record<string, string> | undefined;
|
|
151
|
+
body?: any;
|
|
152
|
+
}>;
|
|
153
|
+
export type RunFileConfig = z.infer<typeof runFileSchema>;
|
|
154
|
+
/**
|
|
155
|
+
* Extended env config schema for run command (requires KETRICS_AUTH_TOKEN and KETRICS_RUNTIME_URL)
|
|
156
|
+
*/
|
|
157
|
+
export declare const runEnvConfigSchema: z.ZodObject<{
|
|
158
|
+
KETRICS_TOKEN: z.ZodString;
|
|
159
|
+
KETRICS_API_URL: z.ZodString;
|
|
160
|
+
KETRICS_TENANT_ID: z.ZodString;
|
|
161
|
+
KETRICS_APPLICATION_ID: z.ZodString;
|
|
162
|
+
} & {
|
|
163
|
+
KETRICS_AUTH_TOKEN: z.ZodString;
|
|
164
|
+
KETRICS_RUNTIME_URL: z.ZodString;
|
|
165
|
+
}, "strip", z.ZodTypeAny, {
|
|
166
|
+
KETRICS_TOKEN: string;
|
|
167
|
+
KETRICS_API_URL: string;
|
|
168
|
+
KETRICS_TENANT_ID: string;
|
|
169
|
+
KETRICS_APPLICATION_ID: string;
|
|
170
|
+
KETRICS_AUTH_TOKEN: string;
|
|
171
|
+
KETRICS_RUNTIME_URL: string;
|
|
172
|
+
}, {
|
|
173
|
+
KETRICS_TOKEN: string;
|
|
174
|
+
KETRICS_API_URL: string;
|
|
175
|
+
KETRICS_TENANT_ID: string;
|
|
176
|
+
KETRICS_APPLICATION_ID: string;
|
|
177
|
+
KETRICS_AUTH_TOKEN: string;
|
|
178
|
+
KETRICS_RUNTIME_URL: string;
|
|
179
|
+
}>;
|
|
180
|
+
export type RunEnvConfig = z.infer<typeof runEnvConfigSchema>;
|
|
181
|
+
/**
|
|
182
|
+
* CLI options for run command
|
|
183
|
+
*/
|
|
184
|
+
export interface RunOptions {
|
|
185
|
+
env?: string;
|
|
186
|
+
verbose?: boolean;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;EAO1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,SAAS,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,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
|
5
|
+
* Type definitions for CLI configuration, API responses, and deployment operations.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.runEnvConfigSchema = exports.runFileSchema = exports.envConfigSchema = exports.ketricsConfigSchema = void 0;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
/**
|
|
11
|
+
* Zod schema for ketrics.config.json validation
|
|
12
|
+
*/
|
|
13
|
+
exports.ketricsConfigSchema = zod_1.z.object({
|
|
14
|
+
name: zod_1.z.string().min(1, 'Application name is required'),
|
|
15
|
+
version: zod_1.z.string().regex(/^\d+\.\d+\.\d+$/, 'Version must be in semver format (e.g., 1.0.0)'),
|
|
16
|
+
description: zod_1.z.string().optional(),
|
|
17
|
+
runtime: zod_1.z.enum(['nodejs18', 'nodejs20', 'static']).default('nodejs18'),
|
|
18
|
+
actions: zod_1.z.array(zod_1.z.string()).min(1, 'At least one action is required'),
|
|
19
|
+
entry: zod_1.z.string().min(1, 'Entry point is required'),
|
|
20
|
+
include: zod_1.z.array(zod_1.z.string()).min(1, 'At least one include pattern is required'),
|
|
21
|
+
exclude: zod_1.z.array(zod_1.z.string()).default([]),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Zod schema for environment variables validation
|
|
25
|
+
*/
|
|
26
|
+
exports.envConfigSchema = zod_1.z.object({
|
|
27
|
+
KETRICS_TOKEN: zod_1.z.string().min(1, 'KETRICS_TOKEN is required'),
|
|
28
|
+
KETRICS_API_URL: zod_1.z.string().url('KETRICS_API_URL must be a valid URL'),
|
|
29
|
+
KETRICS_TENANT_ID: zod_1.z.string().uuid('KETRICS_TENANT_ID must be a valid UUID'),
|
|
30
|
+
KETRICS_APPLICATION_ID: zod_1.z.string().uuid('KETRICS_APPLICATION_ID must be a valid UUID'),
|
|
31
|
+
KETRICS_AUTH_TOKEN: zod_1.z.string().optional(),
|
|
32
|
+
KETRICS_RUNTIME_URL: zod_1.z.string().url('KETRICS_RUNTIME_URL must be a valid URL').optional(),
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Zod schema for run file validation (*.info.json)
|
|
36
|
+
*/
|
|
37
|
+
exports.runFileSchema = zod_1.z.object({
|
|
38
|
+
endpoint: zod_1.z.string().min(1, 'Endpoint is required'),
|
|
39
|
+
method: zod_1.z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).default('POST'),
|
|
40
|
+
headers: zod_1.z.record(zod_1.z.string()).optional().default({}),
|
|
41
|
+
body: zod_1.z.any().optional().default({}),
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Extended env config schema for run command (requires KETRICS_AUTH_TOKEN and KETRICS_RUNTIME_URL)
|
|
45
|
+
*/
|
|
46
|
+
exports.runEnvConfigSchema = exports.envConfigSchema.extend({
|
|
47
|
+
KETRICS_AUTH_TOKEN: zod_1.z.string().min(1, 'KETRICS_AUTH_TOKEN is required for ketrics run'),
|
|
48
|
+
KETRICS_RUNTIME_URL: zod_1.z.string().url('KETRICS_RUNTIME_URL is required for ketrics run'),
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,6BAAwB;AAExB;;GAEG;AACU,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,8BAA8B,CAAC;IACvD,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,gDAAgD,CAAC;IAC9F,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,OAAO,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CA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AE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACzE,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACpD,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CACrC,CAAC,CAAC;AAIH;;GAEG;AACU,QAAA,kBAAkB,GAAG,uBAAe,CAAC,MAAM,CAAC;IACvD,kBAAkB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,gDAAgD,CAAC;IACvF,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,iDAAiD,CAAC;CACvF,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides colored console output for CLI messages.
|
|
5
|
+
*/
|
|
6
|
+
export declare const logger: {
|
|
7
|
+
/**
|
|
8
|
+
* Log info message (blue)
|
|
9
|
+
*/
|
|
10
|
+
info: (message: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Log success message (green)
|
|
13
|
+
*/
|
|
14
|
+
success: (message: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Log warning message (yellow)
|
|
17
|
+
*/
|
|
18
|
+
warn: (message: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Log error message (red)
|
|
21
|
+
*/
|
|
22
|
+
error: (message: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Log plain message
|
|
25
|
+
*/
|
|
26
|
+
log: (message: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Log newline
|
|
29
|
+
*/
|
|
30
|
+
newline: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Log header (bold)
|
|
33
|
+
*/
|
|
34
|
+
header: (message: string) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Log key-value pair
|
|
37
|
+
*/
|
|
38
|
+
keyValue: (key: string, value: string) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Log indented message
|
|
41
|
+
*/
|
|
42
|
+
indent: (message: string, level?: number) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Log file info
|
|
45
|
+
*/
|
|
46
|
+
file: (path: string, size?: string) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Log box with title
|
|
49
|
+
*/
|
|
50
|
+
box: (title: string, content: string[]) => void;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,MAAM;IACjB;;OAEG;oBACa,MAAM,KAAG,IAAI;IAI7B;;OAEG;uBACgB,MAAM,KAAG,IAAI;IAIhC;;OAEG;oBACa,MAAM,KAAG,IAAI;IAI7B;;OAEG;qBACc,MAAM,KAAG,IAAI;IAI9B;;OAEG;mBACY,MAAM,KAAG,IAAI;IAI5B;;OAEG;mBACU,IAAI;IAIjB;;OAEG;sBACe,MAAM,KAAG,IAAI;IAM/B;;OAEG;oBACa,MAAM,SAAS,MAAM,KAAG,IAAI;IAI5C;;OAEG;sBACe,MAAM,qBAAc,IAAI;IAK1C;;OAEG;iBACU,MAAM,SAAS,MAAM,KAAG,IAAI;IAQzC;;OAEG;iBACU,MAAM,WAAW,MAAM,EAAE,KAAG,IAAI;CAS9C,CAAC"}
|