mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
🐛 Fix issue that reading version caused problems with build
This commit is contained in:
parent
291320f817
commit
52808ea460
|
@ -17,7 +17,6 @@ import {
|
||||||
ActiveWorkflows,
|
ActiveWorkflows,
|
||||||
ActiveWebhooks,
|
ActiveWebhooks,
|
||||||
NodeExecuteFunctions,
|
NodeExecuteFunctions,
|
||||||
WorkflowExecute,
|
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
import * as config from '../config';
|
import * as config from '../config';
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
|
import { join as pathJoin } from 'path';
|
||||||
import {
|
import {
|
||||||
readFile as fsReadFile,
|
readFile as fsReadFile,
|
||||||
} from 'fs';
|
} from 'fs';
|
||||||
import { promisify } from "util";
|
import { promisify } from "util";
|
||||||
import { IDataObject } from 'n8n-workflow';
|
import { IDataObject } from 'n8n-workflow';
|
||||||
|
|
||||||
|
import { IPackageVersions } from './';
|
||||||
|
|
||||||
const fsReadFileAsync = promisify(fsReadFile);
|
const fsReadFileAsync = promisify(fsReadFile);
|
||||||
|
|
||||||
|
let versionCache: IPackageVersions | undefined;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a message to the user
|
* Displays a message to the user
|
||||||
*
|
*
|
||||||
|
@ -54,6 +60,28 @@ export function getSessionId(req: express.Request): string | undefined {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information which version of the packages are installed
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @returns {Promise<IPackageVersions>}
|
||||||
|
*/
|
||||||
|
export async function getVersions(): Promise<IPackageVersions> {
|
||||||
|
if (versionCache !== undefined) {
|
||||||
|
return versionCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
const packageFile = await fsReadFileAsync(pathJoin(__dirname, '../../package.json'), 'utf8') as string;
|
||||||
|
const packageData = JSON.parse(packageFile);
|
||||||
|
|
||||||
|
versionCache = {
|
||||||
|
cli: packageData.version,
|
||||||
|
};
|
||||||
|
|
||||||
|
return versionCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets value from config with support for "_FILE" environment variables
|
* Gets value from config with support for "_FILE" environment variables
|
||||||
*
|
*
|
||||||
|
|
|
@ -259,6 +259,11 @@ export interface IN8nUISettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface IPackageVersions {
|
||||||
|
cli: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface IPushData {
|
export interface IPushData {
|
||||||
data: IPushDataExecutionFinished | IPushDataNodeExecuteAfter | IPushDataNodeExecuteBefore | IPushDataTestWebhook;
|
data: IPushDataExecutionFinished | IPushDataNodeExecuteAfter | IPushDataNodeExecuteBefore | IPushDataTestWebhook;
|
||||||
type: IPushDataType;
|
type: IPushDataType;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
import * as bodyParser from 'body-parser';
|
import * as bodyParser from 'body-parser';
|
||||||
import * as history from 'connect-history-api-fallback';
|
import * as history from 'connect-history-api-fallback';
|
||||||
import * as requestPromise from 'request-promise-native';
|
import * as requestPromise from 'request-promise-native';
|
||||||
import { version as versionCli } from '../package.json';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ActiveExecutions,
|
ActiveExecutions,
|
||||||
|
@ -28,6 +27,7 @@ import {
|
||||||
IExecutionsStopData,
|
IExecutionsStopData,
|
||||||
IExecutionsSummary,
|
IExecutionsSummary,
|
||||||
IN8nUISettings,
|
IN8nUISettings,
|
||||||
|
IPackageVersions,
|
||||||
IWorkflowBase,
|
IWorkflowBase,
|
||||||
IWorkflowShortResponse,
|
IWorkflowShortResponse,
|
||||||
IWorkflowResponse,
|
IWorkflowResponse,
|
||||||
|
@ -74,7 +74,6 @@ import * as config from '../config';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import * as timezones from 'google-timezones-json';
|
import * as timezones from 'google-timezones-json';
|
||||||
import * as parseUrl from 'parseurl';
|
import * as parseUrl from 'parseurl';
|
||||||
import { version } from '@oclif/command/lib/flags';
|
|
||||||
|
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
@ -90,6 +89,7 @@ class App {
|
||||||
timezone: string;
|
timezone: string;
|
||||||
activeExecutionsInstance: ActiveExecutions.ActiveExecutions;
|
activeExecutionsInstance: ActiveExecutions.ActiveExecutions;
|
||||||
push: Push.Push;
|
push: Push.Push;
|
||||||
|
versions: IPackageVersions | undefined;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.app = express();
|
this.app = express();
|
||||||
|
@ -122,6 +122,8 @@ class App {
|
||||||
|
|
||||||
async config(): Promise<void> {
|
async config(): Promise<void> {
|
||||||
|
|
||||||
|
this.versions = await GenericHelpers.getVersions();
|
||||||
|
|
||||||
// Check for basic auth credentials if activated
|
// Check for basic auth credentials if activated
|
||||||
const basicAuthActive = config.get('security.basicAuth.active') as boolean;
|
const basicAuthActive = config.get('security.basicAuth.active') as boolean;
|
||||||
if (basicAuthActive === true) {
|
if (basicAuthActive === true) {
|
||||||
|
@ -1005,7 +1007,7 @@ class App {
|
||||||
saveManualExecutions: this.saveManualExecutions,
|
saveManualExecutions: this.saveManualExecutions,
|
||||||
timezone: this.timezone,
|
timezone: this.timezone,
|
||||||
urlBaseWebhook: WebhookHelpers.getWebhookBaseUrl(),
|
urlBaseWebhook: WebhookHelpers.getWebhookBaseUrl(),
|
||||||
versionCli,
|
versionCli: this.versions!.cli,
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -1118,7 +1120,9 @@ export async function start(): Promise<void> {
|
||||||
|
|
||||||
await app.config();
|
await app.config();
|
||||||
|
|
||||||
app.app.listen(PORT, () => {
|
app.app.listen(PORT, async () => {
|
||||||
console.log('n8n ready on port ' + PORT);
|
const versions = await GenericHelpers.getVersions();
|
||||||
|
console.log(`n8n ready on port ${PORT}`);
|
||||||
|
console.log(`Version: ${versions.cli}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
"resolveJsonModule": true,
|
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"outDir": "./dist/",
|
"outDir": "./dist/",
|
||||||
"target": "es2017",
|
"target": "es2017",
|
||||||
|
|
Loading…
Reference in a new issue