mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix: Remove extraneous dependencies from node-cli, publish create-node package (no-changelog) (#18635)
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { createRequire } from 'node:module';
|
||||
import path from 'node:path';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const cliBin = require.resolve('@n8n/node-cli/bin/n8n-node.js');
|
||||
|
||||
const result = spawnSync('node', [cliBin, 'create', ...process.argv.slice(2)], {
|
||||
const result = spawnSync('n8n-node', ['new', ...process.argv.slice(2)], {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"name": "@n8n/create-node",
|
||||
"version": "0.1.0",
|
||||
"description": "Official CLI to create new community nodes for n8n",
|
||||
"bin": {
|
||||
"create-n8n-node": "./bin/create.js"
|
||||
"create-n8n-node": "bin/create.js"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"publish:dry": "pnpm run build && pnpm pub --dry-run",
|
||||
"start": "./bin/create.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/n8n-io/n8n"
|
||||
"url": "git+https://github.com/n8n-io/n8n.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@n8n/node-cli": "workspace:*"
|
||||
|
||||
@@ -4,8 +4,8 @@ Official CLI for developing community nodes for [n8n](https://n8n.io).
|
||||
|
||||
## Features
|
||||
|
||||
- 🔧 Scaffold new nodes
|
||||
- More coming soon
|
||||
- 🔧 Scaffold new n8n nodes
|
||||
- 💻 Develop n8n nodes with live preview
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
@@ -4,6 +4,12 @@ import { nodeConfig } from '@n8n/eslint-config/node';
|
||||
export default defineConfig(
|
||||
globalIgnores(['src/template/templates/**/template', 'src/template/templates/shared']),
|
||||
nodeConfig,
|
||||
{
|
||||
ignores: ['**/*.test.ts'],
|
||||
rules: {
|
||||
'import-x/no-extraneous-dependencies': ['error', { devDependencies: false }],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['src/commands/**/*.ts', 'src/modules.d.ts', 'src/configs/eslint.ts'],
|
||||
rules: { 'import-x/no-default-export': 'off', '@typescript-eslint/naming-convention': 'off' },
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
{
|
||||
"private": false,
|
||||
"name": "@n8n/node-cli",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"description": "Official CLI for developing community nodes for n8n",
|
||||
"bin": {
|
||||
"n8n-node": "./bin/n8n-node.mjs"
|
||||
"n8n-node": "bin/n8n-node.mjs"
|
||||
},
|
||||
"exports": {
|
||||
"./eslint": {
|
||||
@@ -33,7 +32,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/n8n-io/n8n"
|
||||
"url": "git+https://github.com/n8n-io/n8n.git"
|
||||
},
|
||||
"oclif": {
|
||||
"bin": "n8n-node",
|
||||
@@ -48,23 +47,28 @@
|
||||
"@clack/prompts": "^0.11.0",
|
||||
"@oclif/core": "^4.5.2",
|
||||
"change-case": "^5.4.4",
|
||||
"eslint-import-resolver-typescript": "^4.4.3",
|
||||
"eslint-plugin-import-x": "^4.15.2",
|
||||
"eslint-plugin-n8n-nodes-base": "1.16.3",
|
||||
"fast-glob": "catalog:",
|
||||
"handlebars": "4.7.8",
|
||||
"picocolors": "catalog:",
|
||||
"prettier": "3.6.2",
|
||||
"prompts": "^2.4.2",
|
||||
"ts-morph": "^26.0.0"
|
||||
"rimraf": "catalog:",
|
||||
"ts-morph": "^26.0.0",
|
||||
"typescript-eslint": "^8.35.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.29.0",
|
||||
"@n8n/typescript-config": "workspace:*",
|
||||
"@n8n/vitest-config": "workspace:*",
|
||||
"@oclif/test": "^4.1.13",
|
||||
"eslint-import-resolver-typescript": "^4.4.3",
|
||||
"eslint-plugin-import-x": "^4.15.2",
|
||||
"eslint-plugin-n8n-nodes-base": "1.16.3",
|
||||
"n8n-workflow": "workspace:*",
|
||||
"rimraf": "catalog:",
|
||||
"eslint": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"typescript-eslint": "^8.35.0",
|
||||
"vitest-mock-extended": "catalog:"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">= 9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* eslint-disable no-control-regex */
|
||||
import { type ChildProcess, spawn } from 'child_process';
|
||||
import { jsonParse } from 'n8n-workflow';
|
||||
import fs from 'node:fs/promises';
|
||||
import type { Formatter } from 'picocolors/types';
|
||||
|
||||
import { jsonParse } from '../../utils/json';
|
||||
|
||||
export function commands() {
|
||||
const childProcesses: ChildProcess[] = [];
|
||||
|
||||
@@ -119,5 +120,5 @@ export function commands() {
|
||||
export async function readPackageName(): Promise<string> {
|
||||
return await fs
|
||||
.readFile('package.json', 'utf-8')
|
||||
.then((packageJson) => jsonParse<{ name: string }>(packageJson).name);
|
||||
.then((packageJson) => jsonParse<{ name: string }>(packageJson)?.name ?? 'unknown');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
// Included with peer dependency eslint
|
||||
// eslint-disable-next-line import-x/no-extraneous-dependencies
|
||||
import eslint from '@eslint/js';
|
||||
import { globalIgnores } from 'eslint/config';
|
||||
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
|
||||
|
||||
7
packages/@n8n/node-cli/src/utils/json.ts
Normal file
7
packages/@n8n/node-cli/src/utils/json.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function jsonParse<T>(data: string): T | null {
|
||||
try {
|
||||
return JSON.parse(data) as T;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { jsonParse } from 'n8n-workflow';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import prettier from 'prettier';
|
||||
|
||||
import { writeFileSafe } from './filesystem';
|
||||
import { jsonParse } from './json';
|
||||
|
||||
type N8nPackageJson = {
|
||||
name: string;
|
||||
@@ -13,6 +13,7 @@ type N8nPackageJson = {
|
||||
credentials?: string[];
|
||||
};
|
||||
};
|
||||
|
||||
export async function updatePackageJson(
|
||||
dirPath: string,
|
||||
updater: (packageJson: N8nPackageJson) => N8nPackageJson,
|
||||
@@ -20,6 +21,8 @@ export async function updatePackageJson(
|
||||
const packageJsonPath = path.resolve(dirPath, 'package.json');
|
||||
const packageJson = jsonParse<N8nPackageJson>(await fs.readFile(packageJsonPath, 'utf-8'));
|
||||
|
||||
if (!packageJson) return;
|
||||
|
||||
const updatedPackageJson = updater(packageJson);
|
||||
|
||||
await writeFileSafe(
|
||||
@@ -43,7 +46,7 @@ export async function isN8nNodePackage(dirPath = process.cwd()) {
|
||||
|
||||
export async function getPackageJsonNodes(dirPath: string) {
|
||||
const packageJson = await getPackageJson(dirPath);
|
||||
return packageJson.n8n?.nodes ?? [];
|
||||
return packageJson?.n8n?.nodes ?? [];
|
||||
}
|
||||
|
||||
export async function setNodesPackageJson(dirPath: string, nodes: string[]) {
|
||||
|
||||
Reference in New Issue
Block a user