mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix: Fix issue with some community nodes not displaying correctly (#17866)
This commit is contained in:
@@ -57,7 +57,7 @@ const {
|
|||||||
|
|
||||||
const asyncExec = promisify(exec);
|
const asyncExec = promisify(exec);
|
||||||
|
|
||||||
const INVALID_OR_SUSPICIOUS_PACKAGE_NAME = /[^0-9a-z@\-./]/;
|
const INVALID_OR_SUSPICIOUS_PACKAGE_NAME = /[^0-9a-z@\-._/]/;
|
||||||
|
|
||||||
type PackageJson = {
|
type PackageJson = {
|
||||||
name: 'installed-nodes';
|
name: 'installed-nodes';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { ResourceMapperField } from 'n8n-workflow';
|
import type { ResourceMapperField } from 'n8n-workflow';
|
||||||
import { isResourceMapperFieldListStale } from './nodeTypesUtils';
|
import { isCommunityPackageName, isResourceMapperFieldListStale } from './nodeTypesUtils';
|
||||||
|
|
||||||
describe('isResourceMapperFieldListStale', () => {
|
describe('isResourceMapperFieldListStale', () => {
|
||||||
const baseField: ResourceMapperField = {
|
const baseField: ResourceMapperField = {
|
||||||
@@ -73,3 +73,57 @@ describe('isResourceMapperFieldListStale', () => {
|
|||||||
expect(isResourceMapperFieldListStale(oldFields, newFields)).toBe(true);
|
expect(isResourceMapperFieldListStale(oldFields, newFields)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isCommunityPackageName', () => {
|
||||||
|
// Standard community package names
|
||||||
|
it('should identify standard community node package names', () => {
|
||||||
|
expect(isCommunityPackageName('n8n-nodes-example')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('n8n-nodes-custom')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('n8n-nodes-test')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Scoped package names
|
||||||
|
it('should identify scoped community node package names', () => {
|
||||||
|
expect(isCommunityPackageName('@username/n8n-nodes-example')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('@org/n8n-nodes-custom')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('@test-scope/n8n-nodes-test-name')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should identify scoped packages with other characters', () => {
|
||||||
|
expect(isCommunityPackageName('n8n-nodes-my_package')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('@user/n8n-nodes-with_underscore')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('@user_name/n8n-nodes-example')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('@n8n-io/n8n-nodes-test')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('@n8n.io/n8n-nodes-test')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle mixed cases', () => {
|
||||||
|
expect(isCommunityPackageName('@user-name_org/n8n-nodes-mixed-case_example')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('@mixed_style-org/n8n-nodes-complex_name-format')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('@my.mixed_style-org/n8n-nodes-complex_name-format')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Official n8n packages that should not be identified as community packages
|
||||||
|
it('should not identify official n8n packages as community nodes', () => {
|
||||||
|
expect(isCommunityPackageName('@n8n/n8n-nodes-example')).toBe(false);
|
||||||
|
expect(isCommunityPackageName('n8n-nodes-base')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Additional edge cases
|
||||||
|
it('should handle edge cases correctly', () => {
|
||||||
|
// Non-matching patterns
|
||||||
|
expect(isCommunityPackageName('not-n8n-nodes')).toBe(false);
|
||||||
|
expect(isCommunityPackageName('n8n-core')).toBe(false);
|
||||||
|
|
||||||
|
// With node name after package
|
||||||
|
expect(isCommunityPackageName('n8n-nodes-example.NodeName')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('@user/n8n-nodes-example.NodeName')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Multiple executions to test regex state
|
||||||
|
it('should work correctly with multiple consecutive calls', () => {
|
||||||
|
expect(isCommunityPackageName('@user/n8n-nodes-example')).toBe(true);
|
||||||
|
expect(isCommunityPackageName('n8n-nodes-base')).toBe(false);
|
||||||
|
expect(isCommunityPackageName('@test-scope/n8n-nodes-test')).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import {
|
|||||||
|
|
||||||
const CRED_KEYWORDS_TO_FILTER = ['API', 'OAuth1', 'OAuth2'];
|
const CRED_KEYWORDS_TO_FILTER = ['API', 'OAuth1', 'OAuth2'];
|
||||||
const NODE_KEYWORDS_TO_FILTER = ['Trigger'];
|
const NODE_KEYWORDS_TO_FILTER = ['Trigger'];
|
||||||
const COMMUNITY_PACKAGE_NAME_REGEX = /^(?!@n8n\/)(@\w+\/)?n8n-nodes-(?!base\b)\b\w+/g;
|
const COMMUNITY_PACKAGE_NAME_REGEX = /^(?!@n8n\/)(@[\w.-]+\/)?n8n-nodes-(?!base\b)\b\w+/g;
|
||||||
const RESOURCE_MAPPER_FIELD_NAME_REGEX = /value\[\"(.+)\"\]/;
|
const RESOURCE_MAPPER_FIELD_NAME_REGEX = /value\[\"(.+)\"\]/;
|
||||||
|
|
||||||
export function getAppNameFromCredType(name: string) {
|
export function getAppNameFromCredType(name: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user