Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed Apr 11, 2024
1 parent cd99c6e commit 7e35897
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 63 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"bin": "n8n"
},
"scripts": {
"benchmark": "tsc -p tsconfig.benchmark.json && tsc-alias -p tsconfig.benchmark.json && node dist/test/benchmark/main.js",
"benchmark": "tsc -p tsconfig.benchmark.json && tsc-alias -p tsconfig.benchmark.json && node dist/test/benchmarks/main.js",
"clean": "rimraf dist .turbo",
"typecheck": "tsc",
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node scripts/build.mjs",
Expand Down
58 changes: 30 additions & 28 deletions packages/cli/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,35 +289,37 @@ export class Start extends BaseCommand {
const editorUrl = Container.get(UrlService).baseUrl;
this.log(`\nEditor is now accessible via:\n${editorUrl}`);

// Allow to open n8n editor by pressing "o"
if (Boolean(process.stdout.isTTY) && process.stdin.setRawMode) {
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.setEncoding('utf8');
console.log('hello');

if (flags.open) {
this.openBrowser();
}
this.log('\nPress "o" to open in Browser.');
process.stdin.on('data', (key: string) => {
if (key === 'o') {
this.openBrowser();
} else if (key.charCodeAt(0) === 3) {
// Ctrl + c got pressed
void this.stopProcess();
} else {
// When anything else got pressed, record it and send it on enter into the child process

if (key.charCodeAt(0) === 13) {
// send to child process and print in terminal
process.stdout.write('\n');
} else {
// record it and write into terminal
process.stdout.write(key);
}
}
});
}
// Allow to open n8n editor by pressing "o"
// if (Boolean(process.stdout.isTTY) && process.stdin.setRawMode) {
// process.stdin.setRawMode(true);
// process.stdin.resume();
// process.stdin.setEncoding('utf8');

// if (flags.open) {
// this.openBrowser();
// }
// this.log('\nPress "o" to open in Browser.');
// process.stdin.on('data', (key: string) => {
// if (key === 'o') {
// this.openBrowser();
// } else if (key.charCodeAt(0) === 3) {
// // Ctrl + c got pressed
// void this.stopProcess();
// } else {
// // When anything else got pressed, record it and send it on enter into the child process

// if (key.charCodeAt(0) === 13) {
// // send to child process and print in terminal
// process.stdout.write('\n');
// } else {
// // record it and write into terminal
// process.stdout.write(key);
// }
// }
// });
// }
}

async initPruning() {
Expand Down
17 changes: 0 additions & 17 deletions packages/cli/test/benchmark/init.ts

This file was deleted.

18 changes: 18 additions & 0 deletions packages/cli/test/benchmarks/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Config } from '@oclif/core';
import { Start } from '@/commands/start';
import * as testDb from '../integration/shared/testDb';

async function mainProcess() {
const args: string[] = [];
const _config = new Config({ root: __dirname });

const main = new Start(args, _config);

await main.init();
await main.run();
}

export const init = {
database: testDb.init,
mainProcess,
};
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
/* eslint-disable import/no-extraneous-dependencies */ // @TODO: Remove

import 'reflect-metadata';

import { Bench } from 'tinybench';
import { withCodSpeed } from '@codspeed/tinybench-plugin';

import { webhook } from './webhook.bm';

function registerBenchmarks(bench: Bench) {
webhook(bench);
}
import { register } from './register';

async function main() {
const bench = withCodSpeed(
new Bench(
{ time: 0, iterations: 1 }, // @TEMP: Remove
),
);
const _bench = new Bench({ time: 0, iterations: 1 }); // @TEMP: Remove arg
const bench = withCodSpeed(_bench);

registerBenchmarks(bench);
register(bench);

// await bench.warmup(); // @TODO: Restore
await bench.run();
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/test/benchmarks/register.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type Bench from 'tinybench';
import { webhook } from './webhook.benchmark';

export function register(bench: Bench) {
webhook(bench);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ export function webhook(bench: Bench) {
bench.add(
'`start` command',
async () => {
// console.log('ended');
console.log(bench.iterations);
console.log('iteration');
},
{
beforeAll: async () => {
console.log('beforeAll start');

await init.startCommand();
// await init.database();
await init.database();
await init.mainProcess();

console.log('beforeAll end');
},
afterAll: () => {
// stop process // @TODO
},
},
);
}

0 comments on commit 7e35897

Please sign in to comment.