mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
refactor: Clean all instances of isNpmAvailable
(#10891)
This commit is contained in:
parent
30261bdc91
commit
583d3a7acb
|
@ -109,7 +109,6 @@ export interface FrontendSettings {
|
||||||
deployment: {
|
deployment: {
|
||||||
type: string;
|
type: string;
|
||||||
};
|
};
|
||||||
isNpmAvailable: boolean;
|
|
||||||
allowedModules: {
|
allowedModules: {
|
||||||
builtIn?: string[];
|
builtIn?: string[];
|
||||||
external?: string[];
|
external?: string[];
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import type { FrontendSettings } from '@n8n/api-types';
|
import type { FrontendSettings } from '@n8n/api-types';
|
||||||
import { exec as callbackExec } from 'child_process';
|
|
||||||
import cookieParser from 'cookie-parser';
|
import cookieParser from 'cookie-parser';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { access as fsAccess } from 'fs/promises';
|
import { access as fsAccess } from 'fs/promises';
|
||||||
|
@ -7,7 +6,6 @@ import helmet from 'helmet';
|
||||||
import { InstanceSettings } from 'n8n-core';
|
import { InstanceSettings } from 'n8n-core';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { Container, Service } from 'typedi';
|
import { Container, Service } from 'typedi';
|
||||||
import { promisify } from 'util';
|
|
||||||
|
|
||||||
import { AbstractServer } from '@/abstract-server';
|
import { AbstractServer } from '@/abstract-server';
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
|
@ -67,8 +65,6 @@ import '@/workflows/workflow-history/workflow-history.controller.ee';
|
||||||
import '@/workflows/workflows.controller';
|
import '@/workflows/workflows.controller';
|
||||||
import { EventService } from './events/event.service';
|
import { EventService } from './events/event.service';
|
||||||
|
|
||||||
const exec = promisify(callbackExec);
|
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class Server extends AbstractServer {
|
export class Server extends AbstractServer {
|
||||||
private endpointPresetCredentials: string;
|
private endpointPresetCredentials: string;
|
||||||
|
@ -174,9 +170,6 @@ export class Server extends AbstractServer {
|
||||||
const { frontendService } = this;
|
const { frontendService } = this;
|
||||||
if (frontendService) {
|
if (frontendService) {
|
||||||
frontendService.addToSettings({
|
frontendService.addToSettings({
|
||||||
isNpmAvailable: await exec('npm --version')
|
|
||||||
.then(() => true)
|
|
||||||
.catch(() => false),
|
|
||||||
versionCli: N8N_VERSION,
|
versionCli: N8N_VERSION,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,6 @@ export class FrontendService {
|
||||||
deployment: {
|
deployment: {
|
||||||
type: config.getEnv('deployment.type'),
|
type: config.getEnv('deployment.type'),
|
||||||
},
|
},
|
||||||
isNpmAvailable: false,
|
|
||||||
allowedModules: {
|
allowedModules: {
|
||||||
builtIn: process.env.NODE_FUNCTION_ALLOW_BUILTIN?.split(',') ?? undefined,
|
builtIn: process.env.NODE_FUNCTION_ALLOW_BUILTIN?.split(',') ?? undefined,
|
||||||
external: process.env.NODE_FUNCTION_ALLOW_EXTERNAL?.split(',') ?? undefined,
|
external: process.env.NODE_FUNCTION_ALLOW_EXTERNAL?.split(',') ?? undefined,
|
||||||
|
|
|
@ -887,7 +887,6 @@ export interface RootState {
|
||||||
urlBaseWebhook: string;
|
urlBaseWebhook: string;
|
||||||
urlBaseEditor: string;
|
urlBaseEditor: string;
|
||||||
instanceId: string;
|
instanceId: string;
|
||||||
isNpmAvailable: boolean;
|
|
||||||
binaryDataMode: 'default' | 'filesystem' | 's3';
|
binaryDataMode: 'default' | 'filesystem' | 's3';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,7 +934,6 @@ export interface IRootState {
|
||||||
sidebarMenuItems: IMenuItem[];
|
sidebarMenuItems: IMenuItem[];
|
||||||
instanceId: string;
|
instanceId: string;
|
||||||
nodeMetadata: NodeMetadataMap;
|
nodeMetadata: NodeMetadataMap;
|
||||||
isNpmAvailable: boolean;
|
|
||||||
subworkflowExecutionError: Error | null;
|
subworkflowExecutionError: Error | null;
|
||||||
binaryDataMode: string;
|
binaryDataMode: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ export const defaultSettings: FrontendSettings = {
|
||||||
hideUsagePage: false,
|
hideUsagePage: false,
|
||||||
hiringBannerEnabled: false,
|
hiringBannerEnabled: false,
|
||||||
instanceId: '',
|
instanceId: '',
|
||||||
isNpmAvailable: false,
|
|
||||||
license: { environment: 'development', consumerId: 'unknown' },
|
license: { environment: 'development', consumerId: 'unknown' },
|
||||||
logLevel: 'info',
|
logLevel: 'info',
|
||||||
maxExecutionTimeout: 0,
|
maxExecutionTimeout: 0,
|
||||||
|
|
|
@ -98,8 +98,6 @@ export const NPM_KEYWORD_SEARCH_URL =
|
||||||
'https://www.npmjs.com/search?q=keywords%3An8n-community-node-package';
|
'https://www.npmjs.com/search?q=keywords%3An8n-community-node-package';
|
||||||
export const N8N_QUEUE_MODE_DOCS_URL = `https://${DOCS_DOMAIN}/hosting/scaling/queue-mode/`;
|
export const N8N_QUEUE_MODE_DOCS_URL = `https://${DOCS_DOMAIN}/hosting/scaling/queue-mode/`;
|
||||||
export const COMMUNITY_NODES_INSTALLATION_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/community-nodes/installation/gui-install/`;
|
export const COMMUNITY_NODES_INSTALLATION_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/community-nodes/installation/gui-install/`;
|
||||||
export const COMMUNITY_NODES_NPM_INSTALLATION_URL =
|
|
||||||
'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm';
|
|
||||||
export const COMMUNITY_NODES_RISKS_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/community-nodes/risks/`;
|
export const COMMUNITY_NODES_RISKS_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/community-nodes/risks/`;
|
||||||
export const COMMUNITY_NODES_BLOCKLIST_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/community-nodes/blocklist/`;
|
export const COMMUNITY_NODES_BLOCKLIST_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/community-nodes/blocklist/`;
|
||||||
export const CUSTOM_NODES_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/creating-nodes/code/create-n8n-nodes-module/`;
|
export const CUSTOM_NODES_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/creating-nodes/code/create-n8n-nodes-module/`;
|
||||||
|
|
|
@ -29,7 +29,6 @@ export const useRootStore = defineStore(STORES.ROOT, () => {
|
||||||
pushRef: randomString(10).toLowerCase(),
|
pushRef: randomString(10).toLowerCase(),
|
||||||
urlBaseWebhook: 'http://localhost:5678/',
|
urlBaseWebhook: 'http://localhost:5678/',
|
||||||
urlBaseEditor: 'http://localhost:5678',
|
urlBaseEditor: 'http://localhost:5678',
|
||||||
isNpmAvailable: false,
|
|
||||||
instanceId: '',
|
instanceId: '',
|
||||||
binaryDataMode: 'default',
|
binaryDataMode: 'default',
|
||||||
});
|
});
|
||||||
|
@ -165,10 +164,6 @@ export const useRootStore = defineStore(STORES.ROOT, () => {
|
||||||
state.value.defaultLocale = locale;
|
state.value.defaultLocale = locale;
|
||||||
};
|
};
|
||||||
|
|
||||||
const setIsNpmAvailable = (isNpmAvailable: boolean) => {
|
|
||||||
state.value.isNpmAvailable = isNpmAvailable;
|
|
||||||
};
|
|
||||||
|
|
||||||
const setBinaryDataMode = (binaryDataMode: string) => {
|
const setBinaryDataMode = (binaryDataMode: string) => {
|
||||||
state.value.binaryDataMode = binaryDataMode;
|
state.value.binaryDataMode = binaryDataMode;
|
||||||
};
|
};
|
||||||
|
@ -213,7 +208,6 @@ export const useRootStore = defineStore(STORES.ROOT, () => {
|
||||||
setOauthCallbackUrls,
|
setOauthCallbackUrls,
|
||||||
setN8nMetadata,
|
setN8nMetadata,
|
||||||
setDefaultLocale,
|
setDefaultLocale,
|
||||||
setIsNpmAvailable,
|
|
||||||
setBinaryDataMode,
|
setBinaryDataMode,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -128,8 +128,6 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
|
||||||
|
|
||||||
const isCommunityNodesFeatureEnabled = computed(() => settings.value.communityNodesEnabled);
|
const isCommunityNodesFeatureEnabled = computed(() => settings.value.communityNodesEnabled);
|
||||||
|
|
||||||
const isNpmAvailable = computed(() => settings.value.isNpmAvailable);
|
|
||||||
|
|
||||||
const allowedModules = computed(() => settings.value.allowedModules);
|
const allowedModules = computed(() => settings.value.allowedModules);
|
||||||
|
|
||||||
const isQueueModeEnabled = computed(() => settings.value.executionMode === 'queue');
|
const isQueueModeEnabled = computed(() => settings.value.executionMode === 'queue');
|
||||||
|
@ -245,7 +243,6 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
|
||||||
rootStore.setOauthCallbackUrls(fetchedSettings.oauthCallbackUrls);
|
rootStore.setOauthCallbackUrls(fetchedSettings.oauthCallbackUrls);
|
||||||
rootStore.setN8nMetadata(fetchedSettings.n8nMetadata || {});
|
rootStore.setN8nMetadata(fetchedSettings.n8nMetadata || {});
|
||||||
rootStore.setDefaultLocale(fetchedSettings.defaultLocale);
|
rootStore.setDefaultLocale(fetchedSettings.defaultLocale);
|
||||||
rootStore.setIsNpmAvailable(fetchedSettings.isNpmAvailable);
|
|
||||||
rootStore.setBinaryDataMode(fetchedSettings.binaryDataMode);
|
rootStore.setBinaryDataMode(fetchedSettings.binaryDataMode);
|
||||||
useVersionsStore().setVersionNotificationSettings(fetchedSettings.versionNotifications);
|
useVersionsStore().setVersionNotificationSettings(fetchedSettings.versionNotifications);
|
||||||
};
|
};
|
||||||
|
@ -406,7 +403,6 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
|
||||||
templatesHost,
|
templatesHost,
|
||||||
pushBackend,
|
pushBackend,
|
||||||
isCommunityNodesFeatureEnabled,
|
isCommunityNodesFeatureEnabled,
|
||||||
isNpmAvailable,
|
|
||||||
allowedModules,
|
allowedModules,
|
||||||
isQueueModeEnabled,
|
isQueueModeEnabled,
|
||||||
isWorkerViewAvailable,
|
isWorkerViewAvailable,
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import {
|
import {
|
||||||
COMMUNITY_PACKAGE_INSTALL_MODAL_KEY,
|
COMMUNITY_PACKAGE_INSTALL_MODAL_KEY,
|
||||||
COMMUNITY_NODES_INSTALLATION_DOCS_URL,
|
COMMUNITY_NODES_INSTALLATION_DOCS_URL,
|
||||||
COMMUNITY_NODES_NPM_INSTALLATION_URL,
|
|
||||||
} from '@/constants';
|
} from '@/constants';
|
||||||
import CommunityPackageCard from '@/components/CommunityPackageCard.vue';
|
import CommunityPackageCard from '@/components/CommunityPackageCard.vue';
|
||||||
import { useToast } from '@/composables/useToast';
|
import { useToast } from '@/composables/useToast';
|
||||||
|
@ -10,7 +9,6 @@ import type { PublicInstalledPackage } from 'n8n-workflow';
|
||||||
|
|
||||||
import { useCommunityNodesStore } from '@/stores/communityNodes.store';
|
import { useCommunityNodesStore } from '@/stores/communityNodes.store';
|
||||||
import { useUIStore } from '@/stores/ui.store';
|
import { useUIStore } from '@/stores/ui.store';
|
||||||
import { useSettingsStore } from '@/stores/settings.store';
|
|
||||||
import { onBeforeUnmount, ref } from 'vue';
|
import { onBeforeUnmount, ref } from 'vue';
|
||||||
import { useExternalHooks } from '@/composables/useExternalHooks';
|
import { useExternalHooks } from '@/composables/useExternalHooks';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
@ -35,7 +33,6 @@ const telemetry = useTelemetry();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
const communityNodesStore = useCommunityNodesStore();
|
const communityNodesStore = useCommunityNodesStore();
|
||||||
const settingsStore = useSettingsStore();
|
|
||||||
const uiStore = useUIStore();
|
const uiStore = useUIStore();
|
||||||
|
|
||||||
const getEmptyStateDescription = computed(() => {
|
const getEmptyStateDescription = computed(() => {
|
||||||
|
@ -55,27 +52,11 @@ const getEmptyStateDescription = computed(() => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const shouldShowInstallButton = computed(() => {
|
const getEmptyStateButtonText = computed(() =>
|
||||||
return settingsStore.isNpmAvailable;
|
i18n.baseText('settings.communityNodes.empty.installPackageLabel'),
|
||||||
});
|
);
|
||||||
|
|
||||||
const getEmptyStateButtonText = computed(() => {
|
|
||||||
return shouldShowInstallButton.value
|
|
||||||
? i18n.baseText('settings.communityNodes.empty.installPackageLabel')
|
|
||||||
: '';
|
|
||||||
});
|
|
||||||
|
|
||||||
const actionBoxConfig = computed(() => {
|
const actionBoxConfig = computed(() => {
|
||||||
if (!settingsStore.isNpmAvailable) {
|
|
||||||
return {
|
|
||||||
calloutText: i18n.baseText('settings.communityNodes.npmUnavailable.warning', {
|
|
||||||
interpolate: { npmUrl: COMMUNITY_NODES_NPM_INSTALLATION_URL },
|
|
||||||
}),
|
|
||||||
calloutTheme: 'warning',
|
|
||||||
hideButton: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
calloutText: '',
|
calloutText: '',
|
||||||
calloutTheme: '',
|
calloutTheme: '',
|
||||||
|
|
Loading…
Reference in a new issue