mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
🐛 Fix that n8n-node-dev did not build correctly
This commit is contained in:
parent
d337cbd805
commit
efc16dbc73
|
@ -46,6 +46,7 @@
|
||||||
"@oclif/dev-cli": "^1.22.2",
|
"@oclif/dev-cli": "^1.22.2",
|
||||||
"@types/inquirer": "^6.5.0",
|
"@types/inquirer": "^6.5.0",
|
||||||
"@types/node": "^10.10.1",
|
"@types/node": "^10.10.1",
|
||||||
|
"@types/tmp": "^0.1.0",
|
||||||
"@types/vorpal": "^1.11.0",
|
"@types/vorpal": "^1.11.0",
|
||||||
"tslint": "^5.17.0"
|
"tslint": "^5.17.0"
|
||||||
},
|
},
|
||||||
|
@ -58,6 +59,7 @@
|
||||||
"n8n-workflow": "^0.11.0",
|
"n8n-workflow": "^0.11.0",
|
||||||
"replace-in-file": "^4.1.0",
|
"replace-in-file": "^4.1.0",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
|
"tmp-promise": "^2.0.2",
|
||||||
"typescript": "~3.5.2"
|
"typescript": "~3.5.2"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
import { join } from 'path';
|
|
||||||
import { ChildProcess, spawn } from 'child_process';
|
import { ChildProcess, spawn } from 'child_process';
|
||||||
|
import {
|
||||||
|
readFile as fsReadFile,
|
||||||
|
write as fsWrite,
|
||||||
|
} from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { file } from 'tmp-promise';
|
||||||
|
import { promisify } from 'util';
|
||||||
|
|
||||||
|
const fsReadFileAsync = promisify(fsReadFile);
|
||||||
|
const fsWriteAsync = promisify(fsWrite);
|
||||||
|
|
||||||
import { IBuildOptions } from '.';
|
import { IBuildOptions } from '.';
|
||||||
|
|
||||||
|
@ -8,6 +17,41 @@ import {
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a custom tsconfig file as tsc currently has no way to define a base
|
||||||
|
* directory:
|
||||||
|
* https://github.com/Microsoft/TypeScript/issues/25430
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export async function createCustomTsconfig () {
|
||||||
|
|
||||||
|
// Get path to simple tsconfig file which should be used for build
|
||||||
|
const tsconfigPath = join(__dirname, '../../src/tsconfig-build.json');
|
||||||
|
|
||||||
|
// Read the tsconfi file
|
||||||
|
const tsConfigString = await fsReadFileAsync(tsconfigPath, { encoding: 'utf8'}) as string;
|
||||||
|
const tsConfig = JSON.parse(tsConfigString);
|
||||||
|
|
||||||
|
// Set absolute include paths
|
||||||
|
const newIncludeFiles = [];
|
||||||
|
for (const includeFile of tsConfig.include) {
|
||||||
|
newIncludeFiles.push(join(process.cwd(), includeFile));
|
||||||
|
}
|
||||||
|
tsConfig.include = newIncludeFiles;
|
||||||
|
|
||||||
|
// Write new custom tsconfig file
|
||||||
|
const { fd, path, cleanup } = await file();
|
||||||
|
await fsWriteAsync(fd, Buffer.from(JSON.stringify(tsConfig, null, 2), 'utf8'));
|
||||||
|
|
||||||
|
return {
|
||||||
|
path,
|
||||||
|
cleanup,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds and copies credentials and nodes
|
* Builds and copies credentials and nodes
|
||||||
*
|
*
|
||||||
|
@ -21,12 +65,11 @@ export async function buildFiles (options?: IBuildOptions): Promise<string> {
|
||||||
// Get the path of the TypeScript cli of this project
|
// Get the path of the TypeScript cli of this project
|
||||||
const tscPath = join(__dirname, '../../node_modules/typescript/bin/tsc');
|
const tscPath = join(__dirname, '../../node_modules/typescript/bin/tsc');
|
||||||
|
|
||||||
// Get path to simple tsconfig file which should be used for build
|
const tsconfigData = await createCustomTsconfig();
|
||||||
const tsconfigPath = join(__dirname, '../../src/tsconfig-build.json');
|
|
||||||
|
|
||||||
const outputDirectory = options.destinationFolder || UserSettings.getUserN8nFolderCustomExtensionPath();
|
const outputDirectory = options.destinationFolder || UserSettings.getUserN8nFolderCustomExtensionPath();
|
||||||
|
|
||||||
let buildCommand = `${tscPath} --p ${tsconfigPath} --outDir ${outputDirectory}`;
|
let buildCommand = `${tscPath} --p ${tsconfigData.path} --outDir ${outputDirectory} --rootDir ${process.cwd()}`;
|
||||||
if (options.watch === true) {
|
if (options.watch === true) {
|
||||||
buildCommand += ' --watch';
|
buildCommand += ' --watch';
|
||||||
}
|
}
|
||||||
|
@ -52,11 +95,16 @@ export async function buildFiles (options?: IBuildOptions): Promise<string> {
|
||||||
errorMessage = `${errorMessage}\nGot following output:\n${error.stdout}`;
|
errorMessage = `${errorMessage}\nGot following output:\n${error.stdout}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the tmp tsconfig file
|
||||||
|
tsconfigData.cleanup();
|
||||||
|
|
||||||
throw new Error(errorMessage);
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
buildProcess.on('exit', code => {
|
buildProcess.on('exit', code => {
|
||||||
|
// Remove the tmp tsconfig file
|
||||||
|
tsconfigData.cleanup();
|
||||||
resolve(outputDirectory);
|
resolve(outputDirectory);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2017"
|
"es2017"
|
||||||
],
|
],
|
||||||
"types": [
|
"types": [],
|
||||||
"node"
|
|
||||||
],
|
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"importHelpers": true,
|
"importHelpers": true,
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
|
@ -18,8 +16,8 @@
|
||||||
"sourceMap": true
|
"sourceMap": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"../*.credentials.ts",
|
"*.credentials.ts",
|
||||||
"../*.node.ts"
|
"*.node.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|
Loading…
Reference in a new issue