@codenotch/codenotch.cli 1.0.33 → 1.0.34
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/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 +22 -4
- package/dist/utils/BuildUtils.js +45 -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
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { IScenarioProjectManifest } from '../models/Codenotch';
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import os from "node:os";
|
|
6
|
-
import fs from "node:fs/promises";
|
|
7
|
-
import FileUtils from './FileUtils';
|
|
8
|
-
import ProjectCompilationUtils, { CompilationResult } from './ProjectCompilationUtils';
|
|
9
|
-
|
|
10
|
-
type IExtendedScenarioProjectManifest = IScenarioProjectManifest & {
|
|
11
|
-
apis?: unknown[];
|
|
12
|
-
applications?: unknown[];
|
|
13
|
-
reactApplications?: unknown[];
|
|
14
|
-
expressComponents?: unknown[];
|
|
15
|
-
scripts?: unknown[];
|
|
16
|
-
pdfs?: unknown[];
|
|
17
|
-
emails?: unknown[];
|
|
18
|
-
htmls?: unknown[];
|
|
19
|
-
processes?: unknown[];
|
|
20
|
-
tableDataSources?: unknown[];
|
|
21
|
-
documentDataSources?: unknown[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default abstract class ProjectUtils {
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Compile and package the project to prepare it for deployment
|
|
28
|
-
* Work on a copy of the project in a temp folder to avoid modifying the original source files
|
|
29
|
-
* Output a zip file that can be deployed to Codenotch
|
|
30
|
-
*/
|
|
31
|
-
public static async packageProject(sourcePath: string, outputPath: string, ignoreErrors: boolean = false): Promise<CompilationResult> {
|
|
32
|
-
|
|
33
|
-
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "codenotch-"));
|
|
34
|
-
|
|
35
|
-
try
|
|
36
|
-
{
|
|
37
|
-
// Copy project
|
|
38
|
-
await FileUtils.copyFolder(sourcePath, tempRoot, ['.git', 'node_modules', 'dist', 'build', 'out']);
|
|
39
|
-
|
|
40
|
-
// Compile project
|
|
41
|
-
// Some files need to be modified a bit in order to work when deployed
|
|
42
|
-
// For example auml files have to include their i18n data
|
|
43
|
-
const compilation = await ProjectCompilationUtils.compileProject(tempRoot);
|
|
44
|
-
|
|
45
|
-
if(compilation.errors.length > 0) {
|
|
46
|
-
console.error(chalk.red("Compilation failed with errors:"));
|
|
47
|
-
compilation.errors.forEach(err => console.error(chalk.red(`- ${err}`)));
|
|
48
|
-
if (!ignoreErrors) {
|
|
49
|
-
throw new Error("Compilation failed");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
console.warn(chalk.yellow("Ignoring compilation errors and proceeding with packaging..."));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Zip the project folder
|
|
56
|
-
await FileUtils.zipFolder(tempRoot, outputPath);
|
|
57
|
-
|
|
58
|
-
return compilation;
|
|
59
|
-
}
|
|
60
|
-
catch (e)
|
|
61
|
-
{
|
|
62
|
-
throw new Error(`Failed to compile and package the project: ${e instanceof Error ? e.message : String(e)}`);
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
// Clean up temp folder
|
|
66
|
-
await FileUtils.delete(tempRoot);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Check if the manifest is full (meaning with process, apps, etc...) or if it's a minimal manifest that only contains metadata, this can be used to determine if the project has been compiled or not
|
|
71
|
-
static async isManifestCompiled(projectPath: string): Promise<boolean> {
|
|
72
|
-
const manifest = await ProjectUtils.getManifest(projectPath) as IExtendedScenarioProjectManifest;
|
|
73
|
-
return !!(manifest.processes);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private static getCollectionCount(value: unknown): number {
|
|
77
|
-
return Array.isArray(value) ? value.length : 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static async getManifest(projectPath: string): Promise<IScenarioProjectManifest> {
|
|
81
|
-
|
|
82
|
-
const manifestPath = path.join(projectPath, "manifest.json");
|
|
83
|
-
const manifestContent = await fs.readFile(manifestPath, "utf8");
|
|
84
|
-
const manifest = JSON.parse(manifestContent) as IScenarioProjectManifest
|
|
85
|
-
return manifest;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
static async getProjectServiceName(projectPath: string): Promise<string> {
|
|
89
|
-
const manifest = await ProjectUtils.getManifest(projectPath);
|
|
90
|
-
return manifest.serviceName ?? manifest.projectName.toLowerCase();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
static async inspectProject(projectPath: string): Promise<void> {
|
|
94
|
-
|
|
95
|
-
//TODO will only work on a compiler project since we rely on the full manifest
|
|
96
|
-
|
|
97
|
-
const manifest = await ProjectUtils.getManifest(projectPath) as IExtendedScenarioProjectManifest;
|
|
98
|
-
|
|
99
|
-
const projectName = manifest.projectName || "(unknown)";
|
|
100
|
-
const serviceName = manifest.serviceName || projectName.toLowerCase();
|
|
101
|
-
const version = manifest.version || "(unknown)";
|
|
102
|
-
const index = manifest.index || "(not set)";
|
|
103
|
-
|
|
104
|
-
const languages = ProjectUtils.getCollectionCount(manifest.languages);
|
|
105
|
-
const packages = manifest.packages ? Object.keys(manifest.packages).length : 0;
|
|
106
|
-
const dependencies = ProjectUtils.getCollectionCount(manifest.dependencies);
|
|
107
|
-
const roles = ProjectUtils.getCollectionCount(manifest.roles);
|
|
108
|
-
const postInstallProcesses = ProjectUtils.getCollectionCount(manifest.postInstallationProcesses);
|
|
109
|
-
const bpmnActivities = ProjectUtils.getCollectionCount(manifest.bpmnActivities);
|
|
110
|
-
|
|
111
|
-
const counters: Array<{ label: string; count: number }> = [
|
|
112
|
-
{ label: "apis", count: ProjectUtils.getCollectionCount(manifest.apis) },
|
|
113
|
-
{ label: "applications", count: ProjectUtils.getCollectionCount(manifest.applications) },
|
|
114
|
-
{ label: "reactApplications", count: ProjectUtils.getCollectionCount(manifest.reactApplications) },
|
|
115
|
-
{ label: "expressComponents", count: ProjectUtils.getCollectionCount(manifest.expressComponents) },
|
|
116
|
-
{ label: "scripts", count: ProjectUtils.getCollectionCount(manifest.scripts) },
|
|
117
|
-
{ label: "pdfs", count: ProjectUtils.getCollectionCount(manifest.pdfs) },
|
|
118
|
-
{ label: "emails", count: ProjectUtils.getCollectionCount(manifest.emails) },
|
|
119
|
-
{ label: "htmls", count: ProjectUtils.getCollectionCount(manifest.htmls) },
|
|
120
|
-
{ label: "processes", count: ProjectUtils.getCollectionCount(manifest.processes) },
|
|
121
|
-
{ label: "tableDataSources", count: ProjectUtils.getCollectionCount(manifest.tableDataSources) },
|
|
122
|
-
{ label: "documentDataSources", count: ProjectUtils.getCollectionCount(manifest.documentDataSources) },
|
|
123
|
-
];
|
|
124
|
-
|
|
125
|
-
const maxLabelLength = counters.reduce((max, c) => Math.max(max, c.label.length), 0);
|
|
126
|
-
|
|
127
|
-
console.log(chalk.blue("Project inspection"));
|
|
128
|
-
console.log(`${chalk.gray("Path:")} ${path.resolve(projectPath)}`);
|
|
129
|
-
console.log(`${chalk.gray("Project:")} ${chalk.cyan(projectName)}`);
|
|
130
|
-
console.log(`${chalk.gray("Service:")} ${chalk.cyan(serviceName)}`);
|
|
131
|
-
console.log(`${chalk.gray("Version:")} ${chalk.cyan(version)}`);
|
|
132
|
-
console.log(`${chalk.gray("Index:")} ${chalk.cyan(index)}`);
|
|
133
|
-
|
|
134
|
-
console.log("");
|
|
135
|
-
console.log(chalk.blue("Manifest metadata"));
|
|
136
|
-
console.log(`- languages: ${chalk.yellow(languages.toString())}`);
|
|
137
|
-
console.log(`- packages: ${chalk.yellow(packages.toString())}`);
|
|
138
|
-
console.log(`- dependencies: ${chalk.yellow(dependencies.toString())}`);
|
|
139
|
-
console.log(`- roles: ${chalk.yellow(roles.toString())}`);
|
|
140
|
-
console.log(`- postInstallationProcesses: ${chalk.yellow(postInstallProcesses.toString())}`);
|
|
141
|
-
console.log(`- bpmnActivities: ${chalk.yellow(bpmnActivities.toString())}`);
|
|
142
|
-
|
|
143
|
-
console.log("");
|
|
144
|
-
console.log(chalk.blue("Project elements"));
|
|
145
|
-
for (const counter of counters) {
|
|
146
|
-
const label = counter.label.padEnd(maxLabelLength, " ");
|
|
147
|
-
console.log(`- ${label}: ${chalk.green(counter.count.toString())}`);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
}
|