feat: Support community nodes on Windows (#3823)

* 🐛 Account for `APPDATA` in env

* 🐛 Prevent starter installation

* 🐛 Account for Win-style path delimiter

* 👕 Fix lint
This commit is contained in:
Iván Ovejero 2022-08-03 18:10:59 +02:00 committed by GitHub
parent 74cedd94a8
commit e8eda7470a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View file

@ -89,6 +89,7 @@ export const executeCommand = async (
env: { env: {
NODE_PATH: process.env.NODE_PATH, NODE_PATH: process.env.NODE_PATH,
PATH: process.env.PATH, PATH: process.env.PATH,
APPDATA: process.env.APPDATA,
}, },
}; };

View file

@ -64,7 +64,8 @@ class LoadNodesAndCredentialsClass {
LoggerProxy.init(this.logger); LoggerProxy.init(this.logger);
// Make sure the imported modules can resolve dependencies fine. // Make sure the imported modules can resolve dependencies fine.
process.env.NODE_PATH = module.paths.join(':'); const delimiter = process.platform === 'win32' ? ';' : ':';
process.env.NODE_PATH = module.paths.join(delimiter);
// @ts-ignore // @ts-ignore
module.constructor._initPaths(); module.constructor._initPaths();

View file

@ -5,7 +5,11 @@ import { PublicInstalledPackage } from 'n8n-workflow';
import config from '../../config'; import config from '../../config';
import { ResponseHelper, LoadNodesAndCredentials, Push, InternalHooksManager } from '..'; import { ResponseHelper, LoadNodesAndCredentials, Push, InternalHooksManager } from '..';
import { RESPONSE_ERROR_MESSAGES, UNKNOWN_FAILURE_REASON } from '../constants'; import {
RESPONSE_ERROR_MESSAGES,
UNKNOWN_FAILURE_REASON,
STARTER_TEMPLATE_NAME,
} from '../constants';
import { import {
matchMissingPackages, matchMissingPackages,
matchPackagesWithUpdates, matchPackagesWithUpdates,
@ -80,6 +84,17 @@ nodesController.post(
); );
} }
if (parsed.packageName === STARTER_TEMPLATE_NAME) {
throw new ResponseHelper.ResponseError(
[
`Package "${parsed.packageName}" is only a template`,
'Please enter an actual package to install',
].join('.'),
undefined,
400,
);
}
const isInstalled = await isPackageInstalled(parsed.packageName); const isInstalled = await isPackageInstalled(parsed.packageName);
const hasLoaded = hasPackageLoaded(name); const hasLoaded = hasPackageLoaded(name);

View file

@ -6,6 +6,8 @@ import { RESPONSE_ERROR_MESSAGES as CORE_RESPONSE_ERROR_MESSAGES } from 'n8n-cor
export const NODE_PACKAGE_PREFIX = 'n8n-nodes-'; export const NODE_PACKAGE_PREFIX = 'n8n-nodes-';
export const STARTER_TEMPLATE_NAME = `${NODE_PACKAGE_PREFIX}starter`;
export const RESPONSE_ERROR_MESSAGES = { export const RESPONSE_ERROR_MESSAGES = {
NO_CREDENTIAL: 'Credential not found', NO_CREDENTIAL: 'Credential not found',
NO_ENCRYPTION_KEY: CORE_RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY, NO_ENCRYPTION_KEY: CORE_RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,