mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -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: {
|
||||
type: string;
|
||||
};
|
||||
isNpmAvailable: boolean;
|
||||
allowedModules: {
|
||||
builtIn?: string[];
|
||||
external?: string[];
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import type { FrontendSettings } from '@n8n/api-types';
|
||||
import { exec as callbackExec } from 'child_process';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import express from 'express';
|
||||
import { access as fsAccess } from 'fs/promises';
|
||||
|
@ -7,7 +6,6 @@ import helmet from 'helmet';
|
|||
import { InstanceSettings } from 'n8n-core';
|
||||
import { resolve } from 'path';
|
||||
import { Container, Service } from 'typedi';
|
||||
import { promisify } from 'util';
|
||||
|
||||
import { AbstractServer } from '@/abstract-server';
|
||||
import config from '@/config';
|
||||
|
@ -67,8 +65,6 @@ import '@/workflows/workflow-history/workflow-history.controller.ee';
|
|||
import '@/workflows/workflows.controller';
|
||||
import { EventService } from './events/event.service';
|
||||
|
||||
const exec = promisify(callbackExec);
|
||||
|
||||
@Service()
|
||||
export class Server extends AbstractServer {
|
||||
private endpointPresetCredentials: string;
|
||||
|
@ -174,9 +170,6 @@ export class Server extends AbstractServer {
|
|||
const { frontendService } = this;
|
||||
if (frontendService) {
|
||||
frontendService.addToSettings({
|
||||
isNpmAvailable: await exec('npm --version')
|
||||
.then(() => true)
|
||||
.catch(() => false),
|
||||
versionCli: N8N_VERSION,
|
||||
});
|
||||
|
||||
|
|
|
@ -170,7 +170,6 @@ export class FrontendService {
|
|||
deployment: {
|
||||
type: config.getEnv('deployment.type'),
|
||||
},
|
||||
isNpmAvailable: false,
|
||||
allowedModules: {
|
||||
builtIn: process.env.NODE_FUNCTION_ALLOW_BUILTIN?.split(',') ?? undefined,
|
||||
external: process.env.NODE_FUNCTION_ALLOW_EXTERNAL?.split(',') ?? undefined,
|
||||
|
|
|
@ -887,7 +887,6 @@ export interface RootState {
|
|||
urlBaseWebhook: string;
|
||||
urlBaseEditor: string;
|
||||
instanceId: string;
|
||||
isNpmAvailable: boolean;
|
||||
binaryDataMode: 'default' | 'filesystem' | 's3';
|
||||
}
|
||||
|
||||
|
@ -935,7 +934,6 @@ export interface IRootState {
|
|||
sidebarMenuItems: IMenuItem[];
|
||||
instanceId: string;
|
||||
nodeMetadata: NodeMetadataMap;
|
||||
isNpmAvailable: boolean;
|
||||
subworkflowExecutionError: Error | null;
|
||||
binaryDataMode: string;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ export const defaultSettings: FrontendSettings = {
|
|||
hideUsagePage: false,
|
||||
hiringBannerEnabled: false,
|
||||
instanceId: '',
|
||||
isNpmAvailable: false,
|
||||
license: { environment: 'development', consumerId: 'unknown' },
|
||||
logLevel: 'info',
|
||||
maxExecutionTimeout: 0,
|
||||
|
|
|
@ -98,8 +98,6 @@ export const NPM_KEYWORD_SEARCH_URL =
|
|||
'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 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_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/`;
|
||||
|
|
|
@ -29,7 +29,6 @@ export const useRootStore = defineStore(STORES.ROOT, () => {
|
|||
pushRef: randomString(10).toLowerCase(),
|
||||
urlBaseWebhook: 'http://localhost:5678/',
|
||||
urlBaseEditor: 'http://localhost:5678',
|
||||
isNpmAvailable: false,
|
||||
instanceId: '',
|
||||
binaryDataMode: 'default',
|
||||
});
|
||||
|
@ -165,10 +164,6 @@ export const useRootStore = defineStore(STORES.ROOT, () => {
|
|||
state.value.defaultLocale = locale;
|
||||
};
|
||||
|
||||
const setIsNpmAvailable = (isNpmAvailable: boolean) => {
|
||||
state.value.isNpmAvailable = isNpmAvailable;
|
||||
};
|
||||
|
||||
const setBinaryDataMode = (binaryDataMode: string) => {
|
||||
state.value.binaryDataMode = binaryDataMode;
|
||||
};
|
||||
|
@ -213,7 +208,6 @@ export const useRootStore = defineStore(STORES.ROOT, () => {
|
|||
setOauthCallbackUrls,
|
||||
setN8nMetadata,
|
||||
setDefaultLocale,
|
||||
setIsNpmAvailable,
|
||||
setBinaryDataMode,
|
||||
};
|
||||
});
|
||||
|
|
|
@ -128,8 +128,6 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
|
|||
|
||||
const isCommunityNodesFeatureEnabled = computed(() => settings.value.communityNodesEnabled);
|
||||
|
||||
const isNpmAvailable = computed(() => settings.value.isNpmAvailable);
|
||||
|
||||
const allowedModules = computed(() => settings.value.allowedModules);
|
||||
|
||||
const isQueueModeEnabled = computed(() => settings.value.executionMode === 'queue');
|
||||
|
@ -245,7 +243,6 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
|
|||
rootStore.setOauthCallbackUrls(fetchedSettings.oauthCallbackUrls);
|
||||
rootStore.setN8nMetadata(fetchedSettings.n8nMetadata || {});
|
||||
rootStore.setDefaultLocale(fetchedSettings.defaultLocale);
|
||||
rootStore.setIsNpmAvailable(fetchedSettings.isNpmAvailable);
|
||||
rootStore.setBinaryDataMode(fetchedSettings.binaryDataMode);
|
||||
useVersionsStore().setVersionNotificationSettings(fetchedSettings.versionNotifications);
|
||||
};
|
||||
|
@ -406,7 +403,6 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
|
|||
templatesHost,
|
||||
pushBackend,
|
||||
isCommunityNodesFeatureEnabled,
|
||||
isNpmAvailable,
|
||||
allowedModules,
|
||||
isQueueModeEnabled,
|
||||
isWorkerViewAvailable,
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import {
|
||||
COMMUNITY_PACKAGE_INSTALL_MODAL_KEY,
|
||||
COMMUNITY_NODES_INSTALLATION_DOCS_URL,
|
||||
COMMUNITY_NODES_NPM_INSTALLATION_URL,
|
||||
} from '@/constants';
|
||||
import CommunityPackageCard from '@/components/CommunityPackageCard.vue';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
|
@ -10,7 +9,6 @@ import type { PublicInstalledPackage } from 'n8n-workflow';
|
|||
|
||||
import { useCommunityNodesStore } from '@/stores/communityNodes.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { onBeforeUnmount, ref } from 'vue';
|
||||
import { useExternalHooks } from '@/composables/useExternalHooks';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
@ -35,7 +33,6 @@ const telemetry = useTelemetry();
|
|||
const toast = useToast();
|
||||
|
||||
const communityNodesStore = useCommunityNodesStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const uiStore = useUIStore();
|
||||
|
||||
const getEmptyStateDescription = computed(() => {
|
||||
|
@ -55,27 +52,11 @@ const getEmptyStateDescription = computed(() => {
|
|||
});
|
||||
});
|
||||
|
||||
const shouldShowInstallButton = computed(() => {
|
||||
return settingsStore.isNpmAvailable;
|
||||
});
|
||||
|
||||
const getEmptyStateButtonText = computed(() => {
|
||||
return shouldShowInstallButton.value
|
||||
? i18n.baseText('settings.communityNodes.empty.installPackageLabel')
|
||||
: '';
|
||||
});
|
||||
const getEmptyStateButtonText = computed(() =>
|
||||
i18n.baseText('settings.communityNodes.empty.installPackageLabel'),
|
||||
);
|
||||
|
||||
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 {
|
||||
calloutText: '',
|
||||
calloutTheme: '',
|
||||
|
|
Loading…
Reference in a new issue