refactor: Setup typescript project references across workflow, core, and cli (#4519)

* refactor: use consistent folder structure across workflow, core, and cli

* setup typescript project references across workflow, core, and cli
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-11-09 15:25:00 +01:00
committed by GitHub
parent de96def372
commit 698d96a617
251 changed files with 1284 additions and 1134 deletions

View File

@@ -12,15 +12,6 @@ const SPEC_THEME_FILENAME = 'swaggerTheme.css';
const userManagementEnabled = process.env.N8N_USER_MANAGEMENT_DISABLED !== 'true';
const publicApiEnabled = process.env.N8N_PUBLIC_API_DISABLED !== 'true';
shell.rm('-rf', path.resolve(ROOT_DIR, 'dist'));
const tscCompilation = shell.exec('tsc', { silent: true })
if (tscCompilation.code !== 0) {
shell.echo('Typescript Compilation failed:');
shell.echo(tscCompilation.stdout);
shell.exit(1);
}
if (userManagementEnabled) {
copyUserManagementEmailTemplates();
}
@@ -33,7 +24,7 @@ if (publicApiEnabled) {
function copyUserManagementEmailTemplates(rootDir = ROOT_DIR) {
const templates = {
source: path.resolve(rootDir, 'src', 'UserManagement', 'email', 'templates'),
destination: path.resolve(rootDir, 'dist', 'src', 'UserManagement', 'email'),
destination: path.resolve(rootDir, 'dist', 'UserManagement', 'email'),
};
shell.cp('-r', templates.source, templates.destination);
@@ -42,7 +33,7 @@ function copyUserManagementEmailTemplates(rootDir = ROOT_DIR) {
function copySwaggerTheme(rootDir = ROOT_DIR, themeFilename = SPEC_THEME_FILENAME) {
const swaggerTheme = {
source: path.resolve(rootDir, 'src', 'PublicApi', themeFilename),
destination: path.resolve(rootDir, 'dist', 'src', 'PublicApi'),
destination: path.resolve(rootDir, 'dist', 'PublicApi'),
};
shell.cp('-r', swaggerTheme.source, swaggerTheme.destination);
@@ -54,11 +45,11 @@ function bundleOpenApiSpecs(rootDir = ROOT_DIR, specFileName = SPEC_FILENAME) {
shell
.find(publicApiDir)
.reduce((acc, cur) => {
return cur.endsWith(specFileName) ? [...acc, path.relative('.', cur)] : acc;
return cur.endsWith(specFileName) ? [...acc, path.relative('./src', cur)] : acc;
}, [])
.forEach((specPath) => {
const distSpecPath = path.resolve(rootDir, 'dist', specPath);
const command = `swagger-cli bundle ${specPath} --type yaml --outfile ${distSpecPath}`;
const command = `npm run swagger -- bundle src/${specPath} --type yaml --outfile ${distSpecPath}`;
shell.exec(command, { silent: true });
});
}