Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function buildFiles (options?: IBuildOptions): Promise {
options = options || {};
// Get the path of the TypeScript cli of this project
const tscPath = join(__dirname, '../../node_modules/typescript/bin/tsc');
const tsconfigData = await createCustomTsconfig();
const outputDirectory = options.destinationFolder || UserSettings.getUserN8nFolderCustomExtensionPath();
// Supply a node base path so that it finds n8n-core and n8n-workflow
const nodeModulesPath = join(__dirname, '../../node_modules/');
let buildCommand = `${tscPath} --p ${tsconfigData.path} --outDir ${outputDirectory} --rootDir ${process.cwd()} --baseUrl ${nodeModulesPath}`;
if (options.watch === true) {
buildCommand += ' --watch';
}
let buildProcess: ChildProcess;
try {
buildProcess = spawn('node', buildCommand.split(' '), { windowsVerbatimArguments: true, cwd: process.cwd() });
// Forward the output of the child process to the main one
// that the user can see what is happening
buildProcess.stdout.pipe(process.stdout);
buildProcess.stderr.pipe(process.stderr);
}
this.excludeNodes = config.get('nodes.exclude');
// Get all the installed packages which contain n8n nodes
const packages = await this.getN8nNodePackages();
for (const packageName of packages) {
await this.loadDataFromPackage(packageName);
}
// Read nodes and credentials from custom directories
const customDirectories = [];
// Add "custom" folder in user-n8n folder
customDirectories.push(UserSettings.getUserN8nFolderCustomExtensionPath());
// Add folders from special environment variable
if (process.env[CUSTOM_EXTENSION_ENV] !== undefined) {
const customExtensionFolders = process.env[CUSTOM_EXTENSION_ENV]!.split(';');
customDirectories.push.apply(customDirectories, customExtensionFolders);
}
for (const directory of customDirectories) {
await this.loadDataFromDirectory('CUSTOM', directory);
}
}
} from '../src';
export class Build extends Command {
static description = 'Builds credentials and nodes and copies it to n8n custom extension folder';
static examples = [
`$ n8n-node-dev build`,
`$ n8n-node-dev build --destination ~/n8n-nodes`,
`$ n8n-node-dev build --watch`,
];
static flags = {
help: flags.help({ char: 'h' }),
destination: flags.string({
char: 'd',
description: `The path to copy the compiles files to [default: ${UserSettings.getUserN8nFolderCustomExtensionPath()}]`,
}),
watch: flags.boolean({
description: 'Starts in watch mode and automatically builds and copies file whenever they change',
}),
};
async run() {
const { flags } = this.parse(Build);
this.log('\nBuild credentials and nodes');
this.log('=========================');
try {
const options: IBuildOptions = {};
if (flags.destination) {