@codenotch/codenotch.cli 1.0.35 → 1.0.37
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 +2 -2
- package/dist/commands/generate/app.d.ts +2 -0
- package/dist/commands/generate/app.js +45 -0
- package/dist/commands/generate/app.js.map +1 -0
- package/dist/commands/generate/appmanifest.d.ts +2 -0
- package/dist/commands/generate/appmanifest.js +34 -0
- package/dist/commands/generate/appmanifest.js.map +1 -0
- package/dist/commands/generate/dbcontext.d.ts +2 -0
- package/dist/commands/generate/dbcontext.js +32 -0
- package/dist/commands/generate/dbcontext.js.map +1 -0
- package/dist/commands/generate/i18n.d.ts +2 -0
- package/dist/commands/generate/i18n.js +29 -0
- package/dist/commands/generate/i18n.js.map +1 -0
- package/dist/commands/generate/index.d.ts +2 -0
- package/dist/commands/generate/index.js +23 -0
- package/dist/commands/generate/index.js.map +1 -0
- package/dist/commands/generate/manifest.d.ts +2 -0
- package/dist/commands/generate/manifest.js +29 -0
- package/dist/commands/generate/manifest.js.map +1 -0
- package/dist/commands/generate/openapi.d.ts +2 -0
- package/dist/commands/generate/openapi.js +32 -0
- package/dist/commands/generate/openapi.js.map +1 -0
- package/dist/commands/generate/pkg.d.ts +2 -0
- package/dist/commands/generate/pkg.js +34 -0
- package/dist/commands/generate/pkg.js.map +1 -0
- package/dist/commands/generate/shared.d.ts +17 -0
- package/dist/commands/generate/shared.js +70 -0
- package/dist/commands/generate/shared.js.map +1 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/project/new.js +107 -187
- package/dist/commands/project/new.js.map +1 -1
- package/dist/commands/react/build.js +11 -5
- package/dist/commands/react/build.js.map +1 -1
- package/dist/commands/react/clean.d.ts +2 -0
- package/dist/commands/react/clean.js +46 -0
- package/dist/commands/react/clean.js.map +1 -0
- package/dist/commands/react/dev.d.ts +2 -0
- package/dist/commands/react/dev.js +27 -0
- package/dist/commands/react/dev.js.map +1 -0
- package/dist/commands/react/index.js +5 -1
- package/dist/commands/react/index.js.map +1 -1
- package/dist/commands/react/serve.js +33 -4
- package/dist/commands/react/serve.js.map +1 -1
- package/dist/commands/react/shared.d.ts +21 -0
- package/dist/commands/react/shared.js +80 -0
- package/dist/commands/react/shared.js.map +1 -0
- package/dist/commands/system/info.js +0 -7
- package/dist/commands/system/info.js.map +1 -1
- package/dist/commands/validation/ValidationUtils.d.ts +3 -13
- package/dist/commands/validation/ValidationUtils.js +5 -58
- package/dist/commands/validation/ValidationUtils.js.map +1 -1
- package/dist/commands/validation/files/AppManifestValidator.js +5 -20
- package/dist/commands/validation/files/AppManifestValidator.js.map +1 -1
- package/dist/commands/validation/files/I18nValidator.d.ts +24 -0
- package/dist/commands/validation/files/I18nValidator.js +190 -5
- package/dist/commands/validation/files/I18nValidator.js.map +1 -1
- package/dist/commands/validation/files/{BpmnValidator.d.ts → ProjectManifestValidator.d.ts} +1 -1
- package/dist/commands/validation/files/ProjectManifestValidator.js +31 -0
- package/dist/commands/validation/files/ProjectManifestValidator.js.map +1 -0
- package/dist/commands/validation/files/ScriptValidator.d.ts +6 -2
- package/dist/commands/validation/files/ScriptValidator.js +1 -1
- package/dist/commands/validation/files/ScriptValidator.js.map +1 -1
- package/dist/commands/validation/validate.js +15 -46
- package/dist/commands/validation/validate.js.map +1 -1
- package/dist/models/Codenotch.d.ts +0 -205
- package/dist/models/Codenotch.js +0 -211
- package/dist/models/Codenotch.js.map +1 -1
- package/dist/utils/BuildUtils.d.ts +66 -28
- package/dist/utils/BuildUtils.js +292 -330
- package/dist/utils/BuildUtils.js.map +1 -1
- package/dist/utils/ConsoleUtils.d.ts +13 -0
- package/dist/utils/ConsoleUtils.js +50 -0
- package/dist/utils/ConsoleUtils.js.map +1 -1
- package/dist/utils/DbSchemaUtils.d.ts +49 -0
- package/dist/utils/DbSchemaUtils.js +246 -0
- package/dist/utils/DbSchemaUtils.js.map +1 -0
- package/dist/utils/FileUtils.d.ts +104 -15
- package/dist/utils/FileUtils.js +285 -100
- package/dist/utils/FileUtils.js.map +1 -1
- package/dist/utils/GitHubAuthUtils.js.map +1 -1
- package/dist/utils/I18nTsUtils.d.ts +66 -0
- package/dist/utils/I18nTsUtils.js +221 -0
- package/dist/utils/I18nTsUtils.js.map +1 -0
- package/dist/utils/ManifestUtils.d.ts +24 -0
- package/dist/utils/ManifestUtils.js +53 -0
- package/dist/utils/ManifestUtils.js.map +1 -0
- package/dist/utils/OpenApiUtils.d.ts +81 -0
- package/dist/utils/OpenApiUtils.js +123 -0
- package/dist/utils/OpenApiUtils.js.map +1 -0
- package/dist/utils/ProjectCompilationUtils.d.ts +3 -30
- package/dist/utils/ProjectCompilationUtils.js +26 -760
- package/dist/utils/ProjectCompilationUtils.js.map +1 -1
- package/dist/utils/ProjectGeneratorUtils.d.ts +35 -0
- package/dist/utils/ProjectGeneratorUtils.js +119 -0
- package/dist/utils/ProjectGeneratorUtils.js.map +1 -0
- package/dist/utils/ProjectTemplates.d.ts +102 -0
- package/dist/utils/ProjectTemplates.js +284 -0
- package/dist/utils/ProjectTemplates.js.map +1 -0
- package/dist/utils/ProjectUtils.d.ts +217 -4
- package/dist/utils/ProjectUtils.js +386 -50
- package/dist/utils/ProjectUtils.js.map +1 -1
- package/dist/utils/RuntimeUtils.js +14 -8
- package/dist/utils/RuntimeUtils.js.map +1 -1
- package/dist/utils/ScriptDeclarationUtils.d.ts +169 -0
- package/dist/utils/ScriptDeclarationUtils.js +398 -0
- package/dist/utils/ScriptDeclarationUtils.js.map +1 -0
- package/dist/utils/ServeUtils.d.ts +0 -1
- package/dist/utils/ServeUtils.js +11 -29
- package/dist/utils/ServeUtils.js.map +1 -1
- package/dist/utils/ShellUtils.d.ts +6 -0
- package/dist/utils/ShellUtils.js +13 -0
- package/dist/utils/ShellUtils.js.map +1 -1
- package/dist/utils/TemplateUtils.d.ts +62 -0
- package/dist/utils/TemplateUtils.js +218 -0
- package/dist/utils/TemplateUtils.js.map +1 -0
- package/dist/utils/TypeSchemaUtils.d.ts +42 -0
- package/dist/utils/TypeSchemaUtils.js +171 -0
- package/dist/utils/TypeSchemaUtils.js.map +1 -0
- package/package.json +3 -3
- package/dist/commands/validation/files/BpmnValidator.js +0 -32
- package/dist/commands/validation/files/BpmnValidator.js.map +0 -1
- package/dist/commands/validation/files/DbSchemaValidator.d.ts +0 -5
- package/dist/commands/validation/files/DbSchemaValidator.js +0 -16
- package/dist/commands/validation/files/DbSchemaValidator.js.map +0 -1
- package/dist/commands/validation/files/DocumentValidator.d.ts +0 -5
- package/dist/commands/validation/files/DocumentValidator.js +0 -12
- package/dist/commands/validation/files/DocumentValidator.js.map +0 -1
- package/dist/commands/validation/files/ManifestCacheValidator.d.ts +0 -5
- package/dist/commands/validation/files/ManifestCacheValidator.js +0 -121
- package/dist/commands/validation/files/ManifestCacheValidator.js.map +0 -1
- package/dist/commands/validation/files/ManifestValidator.d.ts +0 -5
- package/dist/commands/validation/files/ManifestValidator.js +0 -14
- package/dist/commands/validation/files/ManifestValidator.js.map +0 -1
- package/dist/commands/validation/files/TableValidator.d.ts +0 -5
- package/dist/commands/validation/files/TableValidator.js +0 -19
- package/dist/commands/validation/files/TableValidator.js.map +0 -1
- package/dist/models/DbModels.d.ts +0 -221
- package/dist/models/DbModels.js +0 -130
- package/dist/models/DbModels.js.map +0 -1
- package/dist/models/OpenApiModels.d.ts +0 -115
- package/dist/models/OpenApiModels.js +0 -103
- package/dist/models/OpenApiModels.js.map +0 -1
- package/dist/utils/I18nUtils.d.ts +0 -9
- package/dist/utils/I18nUtils.js +0 -54
- package/dist/utils/I18nUtils.js.map +0 -1
- package/dist/utils/OpenAPIUtils.d.ts +0 -33
- package/dist/utils/OpenAPIUtils.js +0 -279
- package/dist/utils/OpenAPIUtils.js.map +0 -1
|
@@ -1,4 +1,37 @@
|
|
|
1
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
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -6,23 +39,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
39
|
exports.registerNew = registerNew;
|
|
7
40
|
const shared_1 = require("./shared");
|
|
8
41
|
const FileUtils_1 = __importDefault(require("../../utils/FileUtils"));
|
|
42
|
+
const ConsoleUtils_1 = __importDefault(require("../../utils/ConsoleUtils"));
|
|
43
|
+
const ManifestUtils_1 = __importStar(require("../../utils/ManifestUtils"));
|
|
44
|
+
const ProjectTemplates_1 = __importStar(require("../../utils/ProjectTemplates"));
|
|
45
|
+
const ProjectGeneratorUtils_1 = __importDefault(require("../../utils/ProjectGeneratorUtils"));
|
|
46
|
+
const ShellUtils_1 = __importDefault(require("../../utils/ShellUtils"));
|
|
9
47
|
const fs_extra_1 = require("fs-extra");
|
|
10
48
|
const path_1 = require("path");
|
|
11
|
-
const BuildUtils_1 = __importDefault(require("../../utils/BuildUtils"));
|
|
12
|
-
const os_1 = require("os");
|
|
13
49
|
const chalk_1 = __importDefault(require("chalk"));
|
|
14
50
|
function registerNew(project) {
|
|
15
51
|
(0, shared_1.withProjectPathOption)(project
|
|
16
52
|
.command('new')
|
|
17
|
-
.description('Create a new project')
|
|
53
|
+
.description('Create a new project')
|
|
54
|
+
.option('-t, --template <name>', `template to start from: ${ProjectTemplates_1.default.TEMPLATES.map(t => t.name).join(', ')} (asked when omitted)`)
|
|
55
|
+
.option('--list-templates', 'list the available templates and exit')
|
|
56
|
+
.option('--no-install', 'do not run npm install in the new project'))
|
|
18
57
|
.action(async (options) => {
|
|
58
|
+
if (options.listTemplates) {
|
|
59
|
+
for (const template of ProjectTemplates_1.default.TEMPLATES) {
|
|
60
|
+
console.log(`${chalk_1.default.cyan(template.name.padEnd(12))} ${template.description}`);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const templateName = await pickTemplate(options.template);
|
|
65
|
+
if (templateName === undefined) {
|
|
66
|
+
process.exitCode = 1;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
19
69
|
if (options.projectPath === process.cwd()) {
|
|
20
70
|
options.projectPath = '';
|
|
21
71
|
}
|
|
22
72
|
// Create project folder
|
|
23
73
|
let finalFolder = '';
|
|
24
74
|
if (options.projectPath && options.projectPath.trim() !== '') {
|
|
25
|
-
|
|
75
|
+
// resolve() already turns a relative path into an absolute one, based on the current directory
|
|
76
|
+
options.projectPath = (0, path_1.resolve)(options.projectPath);
|
|
26
77
|
if (await FileUtils_1.default.exists(options.projectPath)) {
|
|
27
78
|
console.error(`Path '${options.projectPath}' already exists.`);
|
|
28
79
|
process.exitCode = 1;
|
|
@@ -40,200 +91,69 @@ function registerNew(project) {
|
|
|
40
91
|
}
|
|
41
92
|
(0, fs_extra_1.ensureDirSync)(finalFolder);
|
|
42
93
|
const projectName = FileUtils_1.default.getNameFromPath(finalFolder);
|
|
43
|
-
const serviceName =
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
(0, path_1.join)(finalFolder,
|
|
47
|
-
(0, path_1.join)(finalFolder, 'documents'),
|
|
48
|
-
(0, path_1.join)(finalFolder, 'typings'),
|
|
49
|
-
(0, path_1.join)(finalFolder, 'tables'),
|
|
50
|
-
];
|
|
51
|
-
const files = [
|
|
52
|
-
{ path: (0, path_1.join)(finalFolder, 'manifest.json'), content: JSON.stringify(getDefaultCodenotchManifest(projectName, serviceName), null, 4) },
|
|
53
|
-
{ path: (0, path_1.join)(finalFolder, 'readme.md'), content: getReadmeMd(projectName, serviceName) },
|
|
54
|
-
{ path: (0, path_1.join)(finalFolder, '.gitignore'), content: ['manifest.cache.json', 'package-lock.json', '/.codenotch', '/node_modules', '/typings'].join('\n') },
|
|
55
|
-
{ path: (0, path_1.join)(finalFolder, 'package.json'), content: JSON.stringify(getDefaultPkgJson(serviceName), null, 4) },
|
|
56
|
-
{ path: (0, path_1.join)(finalFolder, 'apps/index.manifest.json'), content: JSON.stringify(getDefaultAppManifest(), null, 4) },
|
|
57
|
-
{ path: (0, path_1.join)(finalFolder, 'apps/index.tsx'), content: getDefaultApp() },
|
|
58
|
-
];
|
|
59
|
-
for (const folder of folders) {
|
|
60
|
-
(0, fs_extra_1.ensureDirSync)(folder);
|
|
94
|
+
const serviceName = ManifestUtils_1.default.toServiceName(projectName);
|
|
95
|
+
const scaffold = ProjectTemplates_1.default.build(templateName, { projectName, serviceName, languages: [...ManifestUtils_1.DEFAULT_LANGUAGES] });
|
|
96
|
+
for (const folder of scaffold.folders) {
|
|
97
|
+
(0, fs_extra_1.ensureDirSync)((0, path_1.join)(finalFolder, folder));
|
|
61
98
|
}
|
|
62
|
-
for (const file of files) {
|
|
63
|
-
FileUtils_1.default.writeFileSync(file.path, file.content)
|
|
99
|
+
for (const file of scaffold.files) {
|
|
100
|
+
if (!FileUtils_1.default.writeFileSync((0, path_1.join)(finalFolder, file.path), file.content)) {
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
ConsoleUtils_1.default.check(`${scaffold.files.length} file(s) written from the '${templateName}' template`);
|
|
106
|
+
// The schema, the translation classes and the api document come from the files just written
|
|
107
|
+
const generated = await ProjectGeneratorUtils_1.default.generateAll(finalFolder);
|
|
108
|
+
for (const warning of generated.warnings) {
|
|
109
|
+
ConsoleUtils_1.default.checkWarning(warning);
|
|
110
|
+
}
|
|
111
|
+
if (generated.error !== undefined) {
|
|
112
|
+
console.error(chalk_1.default.red(generated.error));
|
|
113
|
+
process.exitCode = 1;
|
|
114
|
+
return;
|
|
64
115
|
}
|
|
116
|
+
if (generated.written.length > 0) {
|
|
117
|
+
ConsoleUtils_1.default.check(`${generated.written.length} file(s) generated: ${generated.written.map(f => FileUtils_1.default.getNameFromPath(f)).join(', ')}`);
|
|
118
|
+
}
|
|
119
|
+
// The project is complete at this point: a failed install leaves it usable, with the step to redo by hand
|
|
120
|
+
let nextSteps = scaffold.nextSteps;
|
|
121
|
+
if (options.install) {
|
|
122
|
+
console.log(``);
|
|
123
|
+
console.log(`Installing dependencies...`);
|
|
124
|
+
const exitCode = await ShellUtils_1.default.run(finalFolder, 'npm install --no-audit --no-fund');
|
|
125
|
+
if (exitCode === 0) {
|
|
126
|
+
ConsoleUtils_1.default.check(`Dependencies installed`);
|
|
127
|
+
nextSteps = nextSteps.filter(step => step !== ProjectTemplates_1.NPM_INSTALL_STEP);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
ConsoleUtils_1.default.checkWarning(`npm install failed (exit code ${exitCode}), run it again once the cause is fixed.`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
console.log(``);
|
|
65
134
|
console.log(`Your new Codenotch project is ready at:`);
|
|
66
135
|
console.log(chalk_1.default.green(finalFolder));
|
|
67
136
|
console.log(``);
|
|
68
137
|
console.log(`You can now execute:`);
|
|
69
138
|
console.log(chalk_1.default.green(`cd '${finalFolder}'`));
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const downloads = {
|
|
73
|
-
"win": "https://codenotchide.blob.core.windows.net/release-desktop-win/Codenotch%20Latest.exe?sv=2023-01-03&ss=btqf&srt=sco&spr=https%2Chttp&st=2025-08-28T12%3A46%3A05Z&se=2039-06-23T15%3A46%3A00Z&sp=rlp&sig=7ivKIFM4nANK4VzdKp20bzaNZhaZZ51YIvzriUacxBw%3D",
|
|
74
|
-
"linux": "https://codenotchide.blob.core.windows.net/release-desktop-linux/codenotch-ide_latest_amd64.deb?sv=2023-01-03&ss=btqf&srt=sco&spr=https%2Chttp&st=2025-08-28T12%3A46%3A05Z&se=2039-06-23T15%3A46%3A00Z&sp=rlp&sig=7ivKIFM4nANK4VzdKp20bzaNZhaZZ51YIvzriUacxBw%3D",
|
|
75
|
-
};
|
|
76
|
-
const url = downloads[(0, os_1.platform)()];
|
|
77
|
-
if (url) {
|
|
78
|
-
console.log(`Download link:`);
|
|
79
|
-
console.log(chalk_1.default.green(url));
|
|
139
|
+
for (const step of nextSteps) {
|
|
140
|
+
console.log(chalk_1.default.green(step));
|
|
80
141
|
}
|
|
81
142
|
});
|
|
82
143
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"pwa": {
|
|
92
|
-
"name": "index",
|
|
93
|
-
"display": "standalone",
|
|
94
|
-
"display_override": [
|
|
95
|
-
"window-controls-overlay"
|
|
96
|
-
],
|
|
97
|
-
"start_url": "./",
|
|
98
|
-
"icons": [
|
|
99
|
-
{
|
|
100
|
-
"src": "logo512.png",
|
|
101
|
-
"sizes": "512x512",
|
|
102
|
-
"type": "image/png"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"src": "logo192.png",
|
|
106
|
-
"sizes": "192x192",
|
|
107
|
-
"type": "image/png"
|
|
108
|
-
}
|
|
109
|
-
]
|
|
144
|
+
/**
|
|
145
|
+
* The template to use: the one given on the command line when valid, otherwise the one picked
|
|
146
|
+
* on the terminal ('default' when nobody can answer). Undefined when the given name is unknown.
|
|
147
|
+
*/
|
|
148
|
+
async function pickTemplate(requested) {
|
|
149
|
+
if (requested !== undefined) {
|
|
150
|
+
if (ProjectTemplates_1.default.isTemplateName(requested)) {
|
|
151
|
+
return requested;
|
|
110
152
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
function getDefaultApp() {
|
|
115
|
-
return `import React from 'react';
|
|
116
|
-
import { useCodenotch } from '@codenotch/codenotch.react';
|
|
117
|
-
|
|
118
|
-
const index: React.FC<{}> = () => {
|
|
119
|
-
const cn = useCodenotch();
|
|
120
|
-
|
|
121
|
-
return <div>
|
|
122
|
-
<h1>My new Codenotch App</h1>
|
|
123
|
-
<pre>{JSON.stringify(cn.env, null, 4)}</pre>
|
|
124
|
-
</div>
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export default index;`;
|
|
128
|
-
}
|
|
129
|
-
function getReadmeMd(projectName, serviceName) {
|
|
130
|
-
return `
|
|
131
|
-
# ${projectName}
|
|
132
|
-
|
|
133
|
-
A [Codenotch](https://codenotch.com/) project. Codenotch is a full-stack platform for building and deploying business applications: the backend is made of BPMN workflows, data is stored in SQL tables and NoSQL documents, and the (optional) UI is written in React/TypeScript.
|
|
134
|
-
|
|
135
|
-
## Project structure
|
|
136
|
-
|
|
137
|
-
| Path | Purpose |
|
|
138
|
-
| --- | --- |
|
|
139
|
-
| \`manifest.json\` | Project metadata (name, service name, languages, roles…). |
|
|
140
|
-
| \`processes/\` | \`.bpmn\` workflows: server-side logic, API endpoints, data persistence. |
|
|
141
|
-
| \`tables/\` | \`.table\` SQL table definitions. |
|
|
142
|
-
| \`documents/\` | \`.jschema\` NoSQL document schemas. |
|
|
143
|
-
| \`apps/\` | \`.tsx\` React apps and components. |
|
|
144
|
-
| \`typings/\` | Auto-generated TypeScript typings (never edit by hand). |
|
|
145
|
-
| \`*.i18n.csv\` | Translations. |
|
|
146
|
-
|
|
147
|
-
The service name of this project is \`${serviceName}\`. It is part of the project URL and referenced throughout the project files, so avoid changing it afterwards.
|
|
148
|
-
|
|
149
|
-
## Getting started
|
|
150
|
-
|
|
151
|
-
1. Install the dependencies (required before building any React app):
|
|
152
|
-
|
|
153
|
-
\`\`\`sh
|
|
154
|
-
npm install
|
|
155
|
-
\`\`\`
|
|
156
|
-
|
|
157
|
-
2. Make sure the Codenotch CLI and runtime are available:
|
|
158
|
-
|
|
159
|
-
\`\`\`sh
|
|
160
|
-
npm install -g @codenotch/codenotch.cli
|
|
161
|
-
cn runtime update
|
|
162
|
-
cn runtime start
|
|
163
|
-
\`\`\`
|
|
164
|
-
|
|
165
|
-
3. Build, deploy and open the project on the local runtime:
|
|
166
|
-
|
|
167
|
-
\`\`\`sh
|
|
168
|
-
cn project start
|
|
169
|
-
\`\`\`
|
|
170
|
-
|
|
171
|
-
## Useful commands
|
|
172
|
-
|
|
173
|
-
| Command | Description |
|
|
174
|
-
| --- | --- |
|
|
175
|
-
| \`cn project start\` | Build, deploy and start the project locally. |
|
|
176
|
-
| \`cn project refresh\` | Re-sync the running project after changes. |
|
|
177
|
-
| \`cn project inspect\` | Validate the project and print diagnostics. |
|
|
178
|
-
| \`cn project test\` | Run the project tests. |
|
|
179
|
-
| \`cn project package\` | Build a deployable zip. |
|
|
180
|
-
| \`cn project deploy <service> <zip>\` | Deploy a packaged zip to a service. |
|
|
181
|
-
| \`cn runtime portal\` | Open the local runtime portal. |
|
|
182
|
-
|
|
183
|
-
Run \`cn --help\` for the full list of commands. You can also open this project in the Codenotch IDE.
|
|
184
|
-
`.trim() + '\n';
|
|
185
|
-
}
|
|
186
|
-
function getServiceName(projectName) {
|
|
187
|
-
let serviceName = projectName
|
|
188
|
-
// 1. Normalise et supprime les accents (ex: "é" -> "e", "ç" -> "c")
|
|
189
|
-
.normalize("NFD")
|
|
190
|
-
.replace(/[\u0300-\u036f]/g, "")
|
|
191
|
-
// 2. Remplace les espaces, tabulations et tirets (-) par des tirets bas (_)
|
|
192
|
-
.replace(/[-\s]+/g, '_')
|
|
193
|
-
// 3. Supprime les caractères spéciaux restants qui ne correspondent pas à [\w.]
|
|
194
|
-
.replace(/[^\w.]/g, '')
|
|
195
|
-
// 4. Nettoie les éventuels tirets bas ou points consécutifs (ex: "__" ou ".." -> "_")
|
|
196
|
-
.replace(/__+/g, '_')
|
|
197
|
-
.replace(/\.\.+/g, '.');
|
|
198
|
-
// Validation finale de sécurité
|
|
199
|
-
if (!serviceName || !/[\w.]+/.test(serviceName)) {
|
|
200
|
-
serviceName = '';
|
|
153
|
+
console.error(chalk_1.default.yellow(`Unknown template '${requested}', expected one of: ${ProjectTemplates_1.default.TEMPLATES.map(t => t.name).join(', ')}.`));
|
|
154
|
+
return undefined;
|
|
201
155
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
function getDefaultPkgJson(serviceName) {
|
|
205
|
-
return {
|
|
206
|
-
"name": serviceName,
|
|
207
|
-
"version": "0.0.0",
|
|
208
|
-
"description": "New Codenotch Project",
|
|
209
|
-
"main": "index.js",
|
|
210
|
-
"scripts": {},
|
|
211
|
-
"keywords": [],
|
|
212
|
-
"author": "",
|
|
213
|
-
"license": "MIT",
|
|
214
|
-
"dependencies": {
|
|
215
|
-
"react": "^19.2.8",
|
|
216
|
-
"react-dom": "^19.2.8",
|
|
217
|
-
"@codenotch/codenotch.react": BuildUtils_1.default.CN_REACT_VERSION
|
|
218
|
-
},
|
|
219
|
-
"devDependencies": {
|
|
220
|
-
"@types/react": "^19.2.18",
|
|
221
|
-
"@types/react-dom": "^19.2.4",
|
|
222
|
-
"@vitejs/plugin-react": "^6.0.5",
|
|
223
|
-
"typescript": "^5.9.3"
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function getDefaultCodenotchManifest(projectName, serviceName) {
|
|
228
|
-
return {
|
|
229
|
-
packages: {},
|
|
230
|
-
projectName: projectName,
|
|
231
|
-
serviceName: serviceName,
|
|
232
|
-
languages: ['en', 'de', 'fr'],
|
|
233
|
-
roles: [],
|
|
234
|
-
version: '0.0.0',
|
|
235
|
-
dependencies: [],
|
|
236
|
-
postInstallationProcesses: []
|
|
237
|
-
};
|
|
156
|
+
const index = await ConsoleUtils_1.default.select('Which template do you want to start from?', ProjectTemplates_1.default.TEMPLATES, 0);
|
|
157
|
+
return ProjectTemplates_1.default.TEMPLATES[index].name;
|
|
238
158
|
}
|
|
239
159
|
//# sourceMappingURL=new.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/commands/project/new.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/commands/project/new.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,kCAwGC;AAnHD,qCAAyE;AACzE,sEAA8C;AAC9C,4EAAoD;AACpD,2EAA6E;AAC7E,iFAAgG;AAChG,8FAAsE;AACtE,wEAAgD;AAChD,uCAAyC;AACzC,+BAAqC;AACrC,kDAA0B;AAE1B,SAAgB,WAAW,CAAC,OAAgB;IACxC,IAAA,8BAAqB,EAAC,OAAO;SACxB,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,sBAAsB,CAAC;SACnC,M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CAAC,CAAC;QAC5I,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,sBAAY,CAAC,MAAM,CAAC,2CAA2C,EAAE,0BAAgB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACpH,OAAO,0BAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC"}
|
|
@@ -5,13 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerBuild = registerBuild;
|
|
7
7
|
const BuildUtils_1 = __importDefault(require("../../utils/BuildUtils"));
|
|
8
|
+
const shared_1 = require("./shared");
|
|
8
9
|
function registerBuild(react) {
|
|
9
10
|
react
|
|
10
|
-
.command('build [
|
|
11
|
-
.description('Build a React
|
|
12
|
-
.option('-c, --cluster <url>', '
|
|
13
|
-
.action(async (
|
|
14
|
-
await
|
|
11
|
+
.command('build [app]')
|
|
12
|
+
.description('Build a React app of the project into a ready-to-serve bundle. By its name, or the path of its component; the only app when omitted.')
|
|
13
|
+
.option('-c, --cluster <url>', 'cluster the app will talk to, written into the .env of the bundle')
|
|
14
|
+
.action(async (target, options) => {
|
|
15
|
+
const app = await (0, shared_1.resolveAppTarget)(target);
|
|
16
|
+
if (app === null) {
|
|
17
|
+
process.exitCode = 1;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
await BuildUtils_1.default.buildReactApp(app.scriptPath, options.cluster);
|
|
15
21
|
});
|
|
16
22
|
}
|
|
17
23
|
//# sourceMappingURL=build.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/commands/react/build.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/commands/react/build.ts"],"names":[],"mappings":";;;;;AAIA,sCAeC;AAlBD,wEAAmE;AACnE,qCAA4C;AAE5C,SAAgB,aAAa,CAAC,KAAc;IACxC,KAAK;SACA,OAAO,CAAC,aAAa,CAAC;SACtB,WAAW,CAAC,sIAAsI,CAAC;SACnJ,MAAM,CAAC,qBAAqB,EAAE,mEAAmE,CAAC;SAClG,MAAM,CAAC,KAAK,EAAE,MAA0B,EAAE,OAAsB,EAAE,EAAE;QAEjE,MAAM,GAAG,GAAG,MAAM,IAAA,yBAAgB,EAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACX,CAAC;QAED,MAAM,oBAAU,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerClean = registerClean;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const ConsoleUtils_1 = __importDefault(require("../../utils/ConsoleUtils"));
|
|
11
|
+
const FileUtils_1 = __importDefault(require("../../utils/FileUtils"));
|
|
12
|
+
const shared_1 = require("./shared");
|
|
13
|
+
/** The folders 'cn react build' and 'cn react dev' stage under .codenotch */
|
|
14
|
+
const STAGING_SUFFIXES = ['-source', '-dist', '-dev'];
|
|
15
|
+
function registerClean(react) {
|
|
16
|
+
react
|
|
17
|
+
.command('clean [app]')
|
|
18
|
+
.description('Delete the staging and bundle folders a build or a dev server left under .codenotch, for one app or for all')
|
|
19
|
+
.action(async (target) => {
|
|
20
|
+
const workspacePath = (0, shared_1.findWorkspace)();
|
|
21
|
+
if (workspacePath === undefined) {
|
|
22
|
+
console.error(chalk_1.default.yellow(`Aborted: no Codenotch project found from '${process.cwd()}' (no manifest.json in the parent folders).`));
|
|
23
|
+
process.exitCode = 1;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const codenotchPath = (0, path_1.join)(workspacePath, '.codenotch');
|
|
27
|
+
if (!(0, fs_1.existsSync)(codenotchPath)) {
|
|
28
|
+
ConsoleUtils_1.default.check(`Nothing to clean, '${codenotchPath}' does not exist.`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const folders = (0, fs_1.readdirSync)(codenotchPath, { withFileTypes: true })
|
|
32
|
+
.filter(entry => entry.isDirectory())
|
|
33
|
+
.map(entry => entry.name)
|
|
34
|
+
.filter(name => STAGING_SUFFIXES.some(suffix => name.toLowerCase().endsWith(suffix)))
|
|
35
|
+
.filter(name => target === undefined || STAGING_SUFFIXES.some(suffix => name.toLowerCase() === `${target.toLowerCase()}${suffix}`));
|
|
36
|
+
if (folders.length === 0) {
|
|
37
|
+
ConsoleUtils_1.default.check(`Nothing to clean${target === undefined ? '' : ` for '${target}'`} in '${codenotchPath}'.`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
for (const folder of folders) {
|
|
41
|
+
FileUtils_1.default.deleteRecursively((0, path_1.join)(codenotchPath, folder));
|
|
42
|
+
}
|
|
43
|
+
ConsoleUtils_1.default.check(`${folders.length} folder(s) deleted: ${folders.join(', ')}`);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=clean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../../src/commands/react/clean.ts"],"names":[],"mappings":";;;;;AAWA,sCAoCC;AA9CD,kDAA0B;AAC1B,2BAA6C;AAC7C,+BAA4B;AAC5B,4EAAoD;AACpD,sEAA8C;AAC9C,qCAAyC;AAEzC,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AAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;QAExI,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,sBAAY,CAAC,KAAK,CAAC,mBAAmB,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,QAAQ,aAAa,IAAI,CAAC,CAAC;YAC/G,OAAO;QACX,CAAC;QAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC3B,mBAAS,CAAC,iBAAiB,CAAC,IAAA,WAAI,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7D,CAAC;QAED,sBAAY,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,uBAAuB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerDev = registerDev;
|
|
7
|
+
const BuildUtils_1 = __importDefault(require("../../utils/BuildUtils"));
|
|
8
|
+
const shared_1 = require("./shared");
|
|
9
|
+
function registerDev(react) {
|
|
10
|
+
react
|
|
11
|
+
.command('dev [app]')
|
|
12
|
+
.description('Start the Vite dev server of an app, with hot reload on the project sources. By name; the only app when omitted.')
|
|
13
|
+
.option('-p, --port <port>', 'port of the dev server (default 5173)', (value) => parseInt(value, 10), 5173)
|
|
14
|
+
.option('-c, --cluster <url>', 'cluster the app will talk to, exposed to the page through /api/env')
|
|
15
|
+
.action(async (target, options) => {
|
|
16
|
+
const app = await (0, shared_1.resolveAppTarget)(target);
|
|
17
|
+
if (app === null) {
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const exitCode = await BuildUtils_1.default.devReactApp(app.scriptPath, { port: options.port, clusterUrl: options.cluster });
|
|
22
|
+
if (exitCode !== 0) {
|
|
23
|
+
process.exitCode = exitCode;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/commands/react/dev.ts"],"names":[],"mappings":";;;;;AAIA,kCAmBC;AAtBD,wEAAgD;AAChD,qCAA4C;AAE5C,SAAgB,WAAW,CAAC,KAAc;IACtC,KAAK;SACA,OAAO,CAAC,WAAW,CAAC;SACpB,WAAW,CAAC,kHAAkH,CAAC;SAC/H,MAAM,CAAC,mBAAmB,EAAE,uCAAuC,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC;SAClH,MAAM,CAAC,qBAAqB,EAAE,oEAAoE,CAAC;SACnG,MAAM,CAAC,KAAK,EAAE,MAA0B,EAAE,OAA2C,EAAE,EAAE;QAEtF,MAAM,GAAG,GAAG,MAAM,IAAA,yBAAgB,EAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,oBAAU,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACnH,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;YACjB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAChC,CAAC;IACL,CAAC,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -3,11 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.registerReactCommands = registerReactCommands;
|
|
4
4
|
const serve_1 = require("./serve");
|
|
5
5
|
const build_1 = require("./build");
|
|
6
|
+
const dev_1 = require("./dev");
|
|
7
|
+
const clean_1 = require("./clean");
|
|
6
8
|
function registerReactCommands(program) {
|
|
7
9
|
const react = program
|
|
8
10
|
.command('react')
|
|
9
11
|
.description('React application management commands');
|
|
10
|
-
(0,
|
|
12
|
+
(0, dev_1.registerDev)(react);
|
|
11
13
|
(0, build_1.registerBuild)(react);
|
|
14
|
+
(0, serve_1.registerServe)(react);
|
|
15
|
+
(0, clean_1.registerClean)(react);
|
|
12
16
|
}
|
|
13
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/react/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/react/index.ts"],"names":[],"mappings":";;AAMA,sDASC;AAdD,mCAAwC;AACxC,mCAAwC;AACxC,+BAAoC;AACpC,mCAAwC;AAExC,SAAgB,qBAAqB,CAAC,OAAgB;IAClD,MAAM,KAAK,GAAG,OAAO;SAChB,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAE1D,IAAA,iBAAW,EAAC,KAAK,CAAC,CAAC;IACnB,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;IACrB,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;IACrB,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -4,15 +4,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerServe = registerServe;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
7
10
|
const ServeUtils_1 = __importDefault(require("../../utils/ServeUtils"));
|
|
11
|
+
const shared_1 = require("./shared");
|
|
8
12
|
function registerServe(react) {
|
|
9
13
|
react
|
|
10
|
-
.command('serve [
|
|
11
|
-
.
|
|
14
|
+
.command('serve [target]')
|
|
15
|
+
.alias('preview')
|
|
16
|
+
.description('Serve the built bundle of an app (by name, the only app when omitted), or any folder holding an index.html')
|
|
12
17
|
.option('-p, --port <port>', 'port to serve the application on (default 5000)', (value) => parseInt(value, 10), 5000)
|
|
13
18
|
.option('-i, --index <name>', 'index file name (default index.html)', 'index.html')
|
|
14
|
-
.action(async (
|
|
15
|
-
|
|
19
|
+
.action(async (target, options) => {
|
|
20
|
+
// An explicit folder is served as it is, whatever it holds
|
|
21
|
+
if (target !== undefined) {
|
|
22
|
+
const asPath = (0, path_1.resolve)(target);
|
|
23
|
+
if ((0, fs_1.existsSync)(asPath) && (0, fs_1.lstatSync)(asPath).isDirectory()) {
|
|
24
|
+
await ServeUtils_1.default.serveApp(asPath, options);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Outside a project and without target, keep serving the current folder as before
|
|
29
|
+
if (target === undefined && (0, shared_1.findWorkspace)() === undefined) {
|
|
30
|
+
await ServeUtils_1.default.serveApp(process.cwd(), options);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const app = await (0, shared_1.resolveAppTarget)(target);
|
|
34
|
+
if (app === null) {
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const distPath = (0, path_1.join)(app.workspacePath, '.codenotch', `${app.name}-dist`);
|
|
39
|
+
if (!(0, fs_1.existsSync)(distPath)) {
|
|
40
|
+
console.error(chalk_1.default.yellow(`Aborted: no build found for '${app.name}' (${distPath}). Build it first with 'cn react build ${app.name}'.`));
|
|
41
|
+
process.exitCode = 1;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
await ServeUtils_1.default.serveApp(distPath, options);
|
|
16
45
|
});
|
|
17
46
|
}
|
|
18
47
|
//# sourceMappingURL=serve.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/react/serve.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/react/serve.ts"],"names":[],"mappings":";;;;;AAOA,sCAuCC;AA7CD,kDAA0B;AAC1B,2BAA2C;AAC3C,+BAAqC;AACrC,wEAAmE;AACnE,qCAA2D;AAE3D,SAAgB,aAAa,CAAC,KAAc;IACxC,KAAK;SACA,OAAO,CAAC,gBAAgB,CAAC;SACzB,KAAK,CAAC,SAAS,CAAC;SAChB,WAAW,CAAC,4GAA4G,CAAC;SACzH,MAAM,CAAC,mBAAmB,EAAE,iDAAiD,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC;SAC5H,MAAM,CAAC,oBAAoB,EAAE,sCAAsC,EAAE,YAAY,CAAC;SAClF,MAAM,CAAC,KAAK,EAAE,MAA0B,EAAE,OAAsB,EAAE,EAAE;QAEjE,2DAA2D;QAC3D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,MAAM,GAAG,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC;YAC/B,IAAI,IAAA,eAAU,EAAC,MAAM,CAAC,IAAI,IAAA,cAAS,EAAC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxD,MAAM,oBAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC3C,OAAO;YACX,CAAC;QACL,CAAC;QAED,kFAAkF;QAClF,IAAI,MAAM,KAAK,SAAS,IAAI,IAAA,sBAAa,GAAE,KAAK,SAAS,EAAE,CAAC;YACxD,MAAM,oBAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;YAClD,OAAO;QACX,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,IAAA,yBAAgB,EAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,GAAG,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,MAAM,CAAC,gCAAgC,GAAG,CAAC,IAAI,MAAM,QAAQ,0CAA0C,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;YAC1I,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACX,CAAC;QAED,MAAM,oBAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** An app a 'cn react ...' command will work on */
|
|
2
|
+
export interface IResolvedApp {
|
|
3
|
+
/** Name of the app as the build knows it: 'app.name' of its manifest, that names the .codenotch folders */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Absolute path of the *.tsx/*.jsx component */
|
|
6
|
+
scriptPath: string;
|
|
7
|
+
/** Absolute path of the project root */
|
|
8
|
+
workspacePath: string;
|
|
9
|
+
}
|
|
10
|
+
/** Root of the Codenotch project a folder belongs to, walking up to the closest manifest.json */
|
|
11
|
+
export declare function findWorkspace(fromDir?: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The app targeted by a 'cn react ...' command.
|
|
14
|
+
*
|
|
15
|
+
* `target` may be the name of an app of the surrounding project, or directly the path of its
|
|
16
|
+
* component. Without a target, the only app of the project is taken, and when there are several
|
|
17
|
+
* the choice is asked on the terminal (first one when nobody can answer).
|
|
18
|
+
*
|
|
19
|
+
* Returns null after printing the reason when no app can be resolved.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveAppTarget(target?: string): Promise<IResolvedApp | null>;
|