@codenotch/codenotch.cli 1.0.33 → 1.0.35
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/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/project/new.js +227 -1
- package/dist/commands/project/new.js.map +1 -1
- package/dist/commands/validation/ValidationUtils.d.ts +28 -0
- package/dist/commands/validation/ValidationUtils.js +182 -0
- package/dist/commands/validation/ValidationUtils.js.map +1 -0
- package/dist/commands/validation/files/AppManifestValidator.d.ts +6 -0
- package/dist/commands/validation/files/AppManifestValidator.js +93 -0
- package/dist/commands/validation/files/AppManifestValidator.js.map +1 -0
- package/dist/commands/validation/files/BpmnValidator.d.ts +5 -0
- package/dist/commands/validation/files/BpmnValidator.js +32 -0
- package/dist/commands/validation/files/BpmnValidator.js.map +1 -0
- package/dist/commands/validation/files/DbSchemaValidator.d.ts +5 -0
- package/dist/commands/validation/files/DbSchemaValidator.js +16 -0
- package/dist/commands/validation/files/DbSchemaValidator.js.map +1 -0
- package/dist/commands/validation/files/DocumentValidator.d.ts +5 -0
- package/dist/commands/validation/files/DocumentValidator.js +12 -0
- package/dist/commands/validation/files/DocumentValidator.js.map +1 -0
- package/dist/commands/validation/files/I18nValidator.d.ts +5 -0
- package/dist/commands/validation/files/I18nValidator.js +13 -0
- package/dist/commands/validation/files/I18nValidator.js.map +1 -0
- package/dist/commands/validation/files/JsonValidator.d.ts +5 -0
- package/dist/commands/validation/files/JsonValidator.js +13 -0
- package/dist/commands/validation/files/JsonValidator.js.map +1 -0
- package/dist/commands/validation/files/ManifestCacheValidator.d.ts +5 -0
- package/dist/commands/validation/files/ManifestCacheValidator.js +121 -0
- package/dist/commands/validation/files/ManifestCacheValidator.js.map +1 -0
- package/dist/commands/validation/files/ManifestValidator.d.ts +5 -0
- package/dist/commands/validation/files/ManifestValidator.js +14 -0
- package/dist/commands/validation/files/ManifestValidator.js.map +1 -0
- package/dist/commands/validation/files/ScriptValidator.d.ts +12 -0
- package/dist/commands/validation/files/ScriptValidator.js +128 -0
- package/dist/commands/validation/files/ScriptValidator.js.map +1 -0
- package/dist/commands/validation/files/TableValidator.d.ts +5 -0
- package/dist/commands/validation/files/TableValidator.js +19 -0
- package/dist/commands/validation/files/TableValidator.js.map +1 -0
- package/dist/commands/validation/validate.d.ts +2 -0
- package/dist/commands/validation/validate.js +245 -0
- package/dist/commands/validation/validate.js.map +1 -0
- package/dist/utils/BuildUtils.d.ts +23 -4
- package/dist/utils/BuildUtils.js +46 -16
- package/dist/utils/BuildUtils.js.map +1 -1
- package/dist/utils/FileUtils.d.ts +13 -0
- package/dist/utils/FileUtils.js +30 -0
- package/dist/utils/FileUtils.js.map +1 -1
- package/dist/utils/I18nUtils.js +0 -2
- package/dist/utils/I18nUtils.js.map +1 -1
- package/package.json +14 -6
- package/.github/copilot-instructions.md +0 -3
- package/bin/cli.js +0 -3
- package/docs/ARCHITECTURE.md +0 -179
- package/docs/TODO.md +0 -18
- package/src/bin/cli.ts +0 -4
- package/src/commands/index.ts +0 -13
- package/src/commands/project/compile.ts +0 -20
- package/src/commands/project/deploy.ts +0 -11
- package/src/commands/project/index.ts +0 -28
- package/src/commands/project/inspect.ts +0 -12
- package/src/commands/project/new.ts +0 -11
- package/src/commands/project/open.ts +0 -21
- package/src/commands/project/package.ts +0 -20
- package/src/commands/project/refresh.ts +0 -13
- package/src/commands/project/remove.ts +0 -12
- package/src/commands/project/shared.ts +0 -9
- package/src/commands/project/start.ts +0 -24
- package/src/commands/project/test.ts +0 -15
- package/src/commands/react/build.ts +0 -12
- package/src/commands/react/index.ts +0 -12
- package/src/commands/react/serve.ts +0 -13
- package/src/commands/runtime/clear.ts +0 -11
- package/src/commands/runtime/index.ts +0 -24
- package/src/commands/runtime/info.ts +0 -47
- package/src/commands/runtime/latest.ts +0 -18
- package/src/commands/runtime/portal.ts +0 -20
- package/src/commands/runtime/start.ts +0 -16
- package/src/commands/runtime/stop.ts +0 -13
- package/src/commands/runtime/update.ts +0 -12
- package/src/commands/system/index.ts +0 -9
- package/src/commands/system/info.ts +0 -23
- package/src/commands/system/read.ts +0 -25
- package/src/index.ts +0 -22
- package/src/models/Codenotch.ts +0 -361
- package/src/models/DbModels.ts +0 -428
- package/src/models/OpenApiModels.ts +0 -145
- package/src/utils/BuildUtils.ts +0 -739
- package/src/utils/ConsoleUtils.ts +0 -22
- package/src/utils/FileUtils.ts +0 -266
- package/src/utils/GitHubAuthUtils.ts +0 -83
- package/src/utils/I18nUtils.ts +0 -58
- package/src/utils/OpenAPIUtils.ts +0 -285
- package/src/utils/OsUtils.ts +0 -32
- package/src/utils/ProjectCompilationUtils.ts +0 -1002
- package/src/utils/ProjectUtils.ts +0 -151
- package/src/utils/RuntimeUtils.ts +0 -743
- package/src/utils/ServeUtils.ts +0 -175
- package/src/utils/ShellUtils.ts +0 -26
- package/src/utils/StringUtils.ts +0 -80
- package/tsconfig.json +0 -35
package/src/utils/ServeUtils.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { existsSync, readFileSync } from 'fs';
|
|
3
|
-
import { join, resolve } from 'path';
|
|
4
|
-
import ConsoleUtils from './ConsoleUtils';
|
|
5
|
-
|
|
6
|
-
export interface IServeOptions {
|
|
7
|
-
port?: number;
|
|
8
|
-
index?: string;
|
|
9
|
-
}
|
|
10
|
-
export default abstract class ServeUtils {
|
|
11
|
-
static async serveApp(directory: string, options: IServeOptions) {
|
|
12
|
-
const port = options.port || 5000;
|
|
13
|
-
const isAbsolutePath = directory && (directory.startsWith('/') || directory.match(/^[a-zA-Z]:\\/));
|
|
14
|
-
const targetDir = resolve(isAbsolutePath ? directory : join(process.cwd(), directory));
|
|
15
|
-
const indexPath = resolve(targetDir, options.index || 'index.html');
|
|
16
|
-
|
|
17
|
-
if (!existsSync(targetDir)) {
|
|
18
|
-
console.log(chalk.red(`Error: Target directory not found (${targetDir})`));
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (!existsSync(indexPath)) {
|
|
23
|
-
console.log(chalk.red(`Error: Index file not found (${indexPath})`));
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const envVariables = this.getEnvVariables(resolve(targetDir, '.env'));
|
|
28
|
-
const aumlObject = this.getAumlVariables(resolve(targetDir, 'auml.json'));
|
|
29
|
-
console.log(chalk.green('Starting production server...'));
|
|
30
|
-
console.log(chalk.blue(`Server: http://localhost:${port}`));
|
|
31
|
-
console.log(chalk.yellow('Using built-in static file server with custom endpoint\n'));
|
|
32
|
-
|
|
33
|
-
await this.startExpressServer(targetDir, indexPath, {
|
|
34
|
-
port: port,
|
|
35
|
-
envVariables: envVariables,
|
|
36
|
-
auml: aumlObject
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private static getAumlVariables(aumlPath: string): any {
|
|
41
|
-
if (existsSync(aumlPath)) {
|
|
42
|
-
console.log(chalk.green(`Loaded auml variables from "${aumlPath}":`));
|
|
43
|
-
try{
|
|
44
|
-
let json = readFileSync(aumlPath, 'utf8');
|
|
45
|
-
return JSON.parse(json);
|
|
46
|
-
}
|
|
47
|
-
catch(error){
|
|
48
|
-
console.log(chalk.red(`Error parsing auml file: ${error}`));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
console.log(chalk.yellow(`Warning: No .auml file found. Auml variables will not be loaded.`));
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
private static getEnvVariables(envPath: string): { name: string, value: string }[] {
|
|
57
|
-
let envVariables: { name: string, value: string }[] = [];
|
|
58
|
-
if (existsSync(envPath)) {
|
|
59
|
-
let envContent = readFileSync(envPath, 'utf8');
|
|
60
|
-
envContent.split('\n').forEach(line => {
|
|
61
|
-
let [key, value] = line.split('=');
|
|
62
|
-
if (key && value) {
|
|
63
|
-
envVariables.push({ name: key.trim(), value: value.trim() });
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
console.log(chalk.green(`Loaded environment variables from "${envPath}":`));
|
|
67
|
-
envVariables.forEach(env => {
|
|
68
|
-
console.log(chalk.blue(`- ${env.name}=${env.value}`));
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
console.log(chalk.yellow(`Warning: No .env file found. Environment variables will not be loaded.`));
|
|
73
|
-
}
|
|
74
|
-
return envVariables;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private static async startExpressServer(targetDir: string, indexPath: string, options: {
|
|
78
|
-
port: number;
|
|
79
|
-
envVariables: { name: string, value: string }[];
|
|
80
|
-
auml: any;
|
|
81
|
-
}){
|
|
82
|
-
|
|
83
|
-
// Express server
|
|
84
|
-
try {
|
|
85
|
-
const express = await import('express');
|
|
86
|
-
const app = express.default();
|
|
87
|
-
|
|
88
|
-
// Serve static files
|
|
89
|
-
app.use(express.static(targetDir));
|
|
90
|
-
|
|
91
|
-
app.get('/api/env', (req, res) => {
|
|
92
|
-
let envData: { [key: string]: string } = {};
|
|
93
|
-
options.envVariables.forEach(env => {
|
|
94
|
-
envData[env.name] = env.value;
|
|
95
|
-
});
|
|
96
|
-
if(options.auml && Object.keys(options.auml).length > 0){
|
|
97
|
-
for(let key of Object.keys(options.auml)){
|
|
98
|
-
envData[`GLOBAL.${key}`] = JSON.stringify(options.auml[key]);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
res.json(envData);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Fallback to index.html for SPA - handle all unmatched routes
|
|
105
|
-
app.use((req, res, next) => {
|
|
106
|
-
// Skip fallback for static files (images, favicons, etc.)
|
|
107
|
-
const staticFileExtensions = ['.ico', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.css', '.js', '.map', '.txt', '.xml', '.json'];
|
|
108
|
-
const hasStaticExtension = staticFileExtensions.some(ext => req.path.toLowerCase().endsWith(ext));
|
|
109
|
-
|
|
110
|
-
// Only serve index.html for GET requests that aren't API calls or static files
|
|
111
|
-
if (req.method === 'GET' && !req.path.startsWith('/api/') && !hasStaticExtension) {
|
|
112
|
-
console.log(chalk.gray(`Serving fallback for: ${req.path}`));
|
|
113
|
-
|
|
114
|
-
// Use a more robust approach for sending files with special characters
|
|
115
|
-
try {
|
|
116
|
-
res.sendFile(indexPath, {
|
|
117
|
-
maxAge: 0,
|
|
118
|
-
etag: false
|
|
119
|
-
}, (err) => {
|
|
120
|
-
if (err) {
|
|
121
|
-
console.error(chalk.red(`Error serving ${indexPath}: ${err.message}`));
|
|
122
|
-
if (!res.headersSent) {
|
|
123
|
-
res.status(404).send('Page not found');
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
} catch (error) {
|
|
128
|
-
console.error(chalk.red(`Catch error: ${error}`));
|
|
129
|
-
if (!res.headersSent) {
|
|
130
|
-
res.status(500).send('Internal Server Error');
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
// For static files that don't exist, return 404 directly
|
|
135
|
-
if (hasStaticExtension) {
|
|
136
|
-
res.status(404).send('File not found');
|
|
137
|
-
} else {
|
|
138
|
-
next();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const server = app.listen(options.port, () => {
|
|
144
|
-
console.log(chalk.green(`Server running on http://localhost:${options.port}`) + ConsoleUtils.proposeOpenUri('Open in browser?', `http://localhost:${options.port}`));
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const killServer = () => {
|
|
148
|
-
console.log(chalk.yellow('\nStopping server...'));
|
|
149
|
-
|
|
150
|
-
// Force exit graceful shutdown takes too long
|
|
151
|
-
const forceExit = setTimeout(() => {
|
|
152
|
-
console.log(chalk.red('Force stopping server...'));
|
|
153
|
-
process.exit(0);
|
|
154
|
-
}, 500);
|
|
155
|
-
|
|
156
|
-
server.close(() => {
|
|
157
|
-
clearTimeout(forceExit);
|
|
158
|
-
process.exit(0);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// For Node.js 18.02+ - close all connections immediately
|
|
162
|
-
if (typeof server.closeAllConnections === 'function') {
|
|
163
|
-
server.closeAllConnections();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
process.on('SIGINT', () => killServer());
|
|
168
|
-
process.on('SIGTERM', () => killServer());
|
|
169
|
-
|
|
170
|
-
} catch (error) {
|
|
171
|
-
console.log(chalk.red(`Error starting server: ${error}`));
|
|
172
|
-
process.exit(1);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
package/src/utils/ShellUtils.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { exec } from 'child_process';
|
|
3
|
-
|
|
4
|
-
export default abstract class ShellUtils{
|
|
5
|
-
public static async exec(location: string, command: string, info?: string, silent: boolean = false): Promise<void> {
|
|
6
|
-
|
|
7
|
-
if(info)
|
|
8
|
-
console.log(info + "...");
|
|
9
|
-
await new Promise((resolve, reject) => {
|
|
10
|
-
exec(command, { cwd: location }, (error: any, stdout: any, stderr: any) => {
|
|
11
|
-
if (error) {
|
|
12
|
-
if (!silent) {
|
|
13
|
-
console.error(`Error while ${info}: ${error}`);
|
|
14
|
-
}
|
|
15
|
-
reject(error);
|
|
16
|
-
} else {
|
|
17
|
-
if (!silent) {
|
|
18
|
-
console.log(stdout);
|
|
19
|
-
console.error(stderr);
|
|
20
|
-
}
|
|
21
|
-
resolve(null);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
package/src/utils/StringUtils.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { platform } from 'os';
|
|
3
|
-
|
|
4
|
-
export default abstract class StringUtils {
|
|
5
|
-
|
|
6
|
-
static firstUpper(str: string): string {
|
|
7
|
-
if (str.trim() === '')
|
|
8
|
-
return str;
|
|
9
|
-
|
|
10
|
-
return `${str[0].toUpperCase()}${str.substring(1)}`;
|
|
11
|
-
}
|
|
12
|
-
public static toRelativePath(path: string, parentPath: string): string {
|
|
13
|
-
path = path.replaceAll("\\", "/");
|
|
14
|
-
parentPath = parentPath.replaceAll("\\", "/");
|
|
15
|
-
|
|
16
|
-
path = path.replace(parentPath, '');
|
|
17
|
-
|
|
18
|
-
if (path.startsWith("/")) {
|
|
19
|
-
path = path.substring(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return path;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static getNameWithoutExtention(filename: string): string {
|
|
26
|
-
filename = this.getFilenameFromUri(filename);
|
|
27
|
-
|
|
28
|
-
if (!filename.includes('.')) {
|
|
29
|
-
return filename;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let ind = filename.lastIndexOf('.');
|
|
33
|
-
return filename.substring(0, ind);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static getFilenameFromUri(uri: string): string {
|
|
37
|
-
uri = uri.replaceAll('\\', '/');
|
|
38
|
-
return uri.includes('/') ? uri.split('/').pop()! : uri;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static getFolder(path: string): string {
|
|
42
|
-
path = path.replaceAll("/", "\\");
|
|
43
|
-
if (path.includes('\\') === false) {
|
|
44
|
-
return '';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
path = path.substring(0, path.lastIndexOf("\\"));
|
|
48
|
-
path = this.normalizePath(path);
|
|
49
|
-
return path;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static normalizePath(path: string): string {
|
|
53
|
-
if (typeof path !== 'string' || path.trim() === '') {
|
|
54
|
-
return '';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (platform() === 'win32') {
|
|
58
|
-
path = path.replaceAll("/", '\\');
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
path = path.replaceAll('\\', '/');
|
|
62
|
-
}
|
|
63
|
-
return path;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
static async sha256(message: string): Promise<string> {
|
|
67
|
-
// encode as UTF-8
|
|
68
|
-
const msgBuffer = new TextEncoder().encode(message);
|
|
69
|
-
|
|
70
|
-
// hash the message
|
|
71
|
-
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
|
|
72
|
-
|
|
73
|
-
// convert ArrayBuffer to Array
|
|
74
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
75
|
-
|
|
76
|
-
// convert bytes to hex string
|
|
77
|
-
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
78
|
-
return hashHex;
|
|
79
|
-
}
|
|
80
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"allowSyntheticDefaultImports": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"outDir": "./dist",
|
|
13
|
-
"rootDir": "./src",
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"allowImportingTsExtensions": false,
|
|
17
|
-
"noEmitOnError": true,
|
|
18
|
-
"pretty": true,
|
|
19
|
-
"lib": ["ES2022"],
|
|
20
|
-
"types": ["node"]
|
|
21
|
-
},
|
|
22
|
-
"include": [
|
|
23
|
-
"src/**/*"
|
|
24
|
-
],
|
|
25
|
-
"exclude": [
|
|
26
|
-
"node_modules",
|
|
27
|
-
"dist",
|
|
28
|
-
"**/*.test.ts",
|
|
29
|
-
"**/*.spec.ts"
|
|
30
|
-
],
|
|
31
|
-
"ts-node": {
|
|
32
|
-
"esm": true,
|
|
33
|
-
"experimentalSpecifierResolution": "node"
|
|
34
|
-
}
|
|
35
|
-
}
|