Skip to content

Commit c99eba7

Browse files
authored
fix: Remove extraneous dependencies from node-cli, publish create-node package (no-changelog) (#18635)
1 parent d01616c commit c99eba7

File tree

10 files changed

+188
-157
lines changed

10 files changed

+188
-157
lines changed

packages/@n8n/create-node/bin/create.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
#!/usr/bin/env node
22

33
import { spawnSync } from 'node:child_process';
4-
import { createRequire } from 'node:module';
5-
import path from 'node:path';
64

7-
const require = createRequire(import.meta.url);
8-
9-
const cliBin = require.resolve('@n8n/node-cli/bin/n8n-node.js');
10-
11-
const result = spawnSync('node', [cliBin, 'create', ...process.argv.slice(2)], {
5+
const result = spawnSync('n8n-node', ['new', ...process.argv.slice(2)], {
126
stdio: 'inherit',
137
});
148

packages/@n8n/create-node/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
{
2-
"private": true,
3-
"type": "module",
42
"name": "@n8n/create-node",
53
"version": "0.1.0",
64
"description": "Official CLI to create new community nodes for n8n",
75
"bin": {
8-
"create-n8n-node": "./bin/create.js"
6+
"create-n8n-node": "bin/create.js"
97
},
108
"files": [
119
"bin",
1210
"dist"
1311
],
1412
"scripts": {
15-
"publish:dry": "pnpm run build && pnpm pub --dry-run",
1613
"start": "./bin/create.js"
1714
},
1815
"repository": {
1916
"type": "git",
20-
"url": "https://github.com/n8n-io/n8n"
17+
"url": "git+https://github.com/n8n-io/n8n.git"
2118
},
2219
"dependencies": {
2320
"@n8n/node-cli": "workspace:*"

packages/@n8n/node-cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Official CLI for developing community nodes for [n8n](https://n8n.io).
44

55
## Features
66

7-
- 🔧 Scaffold new nodes
8-
- More coming soon
7+
- 🔧 Scaffold new n8n nodes
8+
- 💻 Develop n8n nodes with live preview
99

1010
## Installation
1111

packages/@n8n/node-cli/eslint.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { nodeConfig } from '@n8n/eslint-config/node';
44
export default defineConfig(
55
globalIgnores(['src/template/templates/**/template', 'src/template/templates/shared']),
66
nodeConfig,
7+
{
8+
ignores: ['**/*.test.ts'],
9+
rules: {
10+
'import-x/no-extraneous-dependencies': ['error', { devDependencies: false }],
11+
},
12+
},
713
{
814
files: ['src/commands/**/*.ts', 'src/modules.d.ts', 'src/configs/eslint.ts'],
915
rules: { 'import-x/no-default-export': 'off', '@typescript-eslint/naming-convention': 'off' },

packages/@n8n/node-cli/package.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
2-
"private": false,
32
"name": "@n8n/node-cli",
4-
"version": "0.1.0",
3+
"version": "0.1.1",
54
"description": "Official CLI for developing community nodes for n8n",
65
"bin": {
7-
"n8n-node": "./bin/n8n-node.mjs"
6+
"n8n-node": "bin/n8n-node.mjs"
87
},
98
"exports": {
109
"./eslint": {
@@ -33,7 +32,7 @@
3332
},
3433
"repository": {
3534
"type": "git",
36-
"url": "https://github.com/n8n-io/n8n"
35+
"url": "git+https://github.com/n8n-io/n8n.git"
3736
},
3837
"oclif": {
3938
"bin": "n8n-node",
@@ -48,23 +47,28 @@
4847
"@clack/prompts": "^0.11.0",
4948
"@oclif/core": "^4.5.2",
5049
"change-case": "^5.4.4",
50+
"eslint-import-resolver-typescript": "^4.4.3",
51+
"eslint-plugin-import-x": "^4.15.2",
52+
"eslint-plugin-n8n-nodes-base": "1.16.3",
53+
"fast-glob": "catalog:",
5154
"handlebars": "4.7.8",
5255
"picocolors": "catalog:",
56+
"prettier": "3.6.2",
5357
"prompts": "^2.4.2",
54-
"ts-morph": "^26.0.0"
58+
"rimraf": "catalog:",
59+
"ts-morph": "^26.0.0",
60+
"typescript-eslint": "^8.35.0"
5561
},
5662
"devDependencies": {
5763
"@eslint/js": "^9.29.0",
5864
"@n8n/typescript-config": "workspace:*",
5965
"@n8n/vitest-config": "workspace:*",
6066
"@oclif/test": "^4.1.13",
61-
"eslint-import-resolver-typescript": "^4.4.3",
62-
"eslint-plugin-import-x": "^4.15.2",
63-
"eslint-plugin-n8n-nodes-base": "1.16.3",
64-
"n8n-workflow": "workspace:*",
65-
"rimraf": "catalog:",
67+
"eslint": "catalog:",
6668
"typescript": "catalog:",
67-
"typescript-eslint": "^8.35.0",
6869
"vitest-mock-extended": "catalog:"
70+
},
71+
"peerDependencies": {
72+
"eslint": ">= 9"
6973
}
7074
}

packages/@n8n/node-cli/src/commands/dev/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* eslint-disable no-control-regex */
22
import { type ChildProcess, spawn } from 'child_process';
3-
import { jsonParse } from 'n8n-workflow';
43
import fs from 'node:fs/promises';
54
import type { Formatter } from 'picocolors/types';
65

6+
import { jsonParse } from '../../utils/json';
7+
78
export function commands() {
89
const childProcesses: ChildProcess[] = [];
910

@@ -119,5 +120,5 @@ export function commands() {
119120
export async function readPackageName(): Promise<string> {
120121
return await fs
121122
.readFile('package.json', 'utf-8')
122-
.then((packageJson) => jsonParse<{ name: string }>(packageJson).name);
123+
.then((packageJson) => jsonParse<{ name: string }>(packageJson)?.name ?? 'unknown');
123124
}

packages/@n8n/node-cli/src/configs/eslint.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* eslint-disable @typescript-eslint/naming-convention */
1+
// Included with peer dependency eslint
2+
// eslint-disable-next-line import-x/no-extraneous-dependencies
23
import eslint from '@eslint/js';
34
import { globalIgnores } from 'eslint/config';
45
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function jsonParse<T>(data: string): T | null {
2+
try {
3+
return JSON.parse(data) as T;
4+
} catch (error) {
5+
return null;
6+
}
7+
}

packages/@n8n/node-cli/src/utils/package.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { jsonParse } from 'n8n-workflow';
21
import fs from 'node:fs/promises';
32
import path from 'node:path';
43
import prettier from 'prettier';
54

65
import { writeFileSafe } from './filesystem';
6+
import { jsonParse } from './json';
77

88
type N8nPackageJson = {
99
name: string;
@@ -13,13 +13,16 @@ type N8nPackageJson = {
1313
credentials?: string[];
1414
};
1515
};
16+
1617
export async function updatePackageJson(
1718
dirPath: string,
1819
updater: (packageJson: N8nPackageJson) => N8nPackageJson,
1920
) {
2021
const packageJsonPath = path.resolve(dirPath, 'package.json');
2122
const packageJson = jsonParse<N8nPackageJson>(await fs.readFile(packageJsonPath, 'utf-8'));
2223

24+
if (!packageJson) return;
25+
2326
const updatedPackageJson = updater(packageJson);
2427

2528
await writeFileSafe(
@@ -43,7 +46,7 @@ export async function isN8nNodePackage(dirPath = process.cwd()) {
4346

4447
export async function getPackageJsonNodes(dirPath: string) {
4548
const packageJson = await getPackageJson(dirPath);
46-
return packageJson.n8n?.nodes ?? [];
49+
return packageJson?.n8n?.nodes ?? [];
4750
}
4851

4952
export async function setNodesPackageJson(dirPath: string, nodes: string[]) {

0 commit comments

Comments
 (0)