mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
feat: Add @n8n/node-cli package with an empty create command (#17620)
This commit is contained in:
13
packages/@n8n/create-node/README.md
Normal file
13
packages/@n8n/create-node/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# @n8n/create-node
|
||||
|
||||
Scaffold a new community n8n node
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
npm create @n8n/node
|
||||
# or
|
||||
pnpm create @n8n/node
|
||||
# or
|
||||
yarn create @n8n/node
|
||||
```
|
||||
15
packages/@n8n/create-node/bin/create.js
Executable file
15
packages/@n8n/create-node/bin/create.js
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/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)], {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
process.exit(result.status ?? 1);
|
||||
25
packages/@n8n/create-node/package.json
Normal file
25
packages/@n8n/create-node/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"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"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@n8n/node-cli": "workspace:*"
|
||||
}
|
||||
}
|
||||
11
packages/@n8n/create-node/tsconfig.json
Normal file
11
packages/@n8n/create-node/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "@n8n/typescript-config/modern/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"types": ["vite/client", "vitest/globals"],
|
||||
"isolatedModules": true
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
35
packages/@n8n/node-cli/README.md
Normal file
35
packages/@n8n/node-cli/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# @n8n/node-cli
|
||||
|
||||
Official CLI for developing community nodes for [n8n](https://n8n.io).
|
||||
|
||||
## Features
|
||||
|
||||
- 🔧 Scaffold new nodes
|
||||
- More coming soon
|
||||
|
||||
## Installation
|
||||
|
||||
Run directly via `npx`:
|
||||
|
||||
```bash
|
||||
npx n8n-node create
|
||||
```
|
||||
|
||||
Or install globally:
|
||||
|
||||
```bash
|
||||
npm install -g @n8n/node-cli
|
||||
n8n-node create
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
## Create a node
|
||||
|
||||
```bash
|
||||
n8n-node create # Scaffold a new node
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
`@n8n/create-node`: Lightweight wrapper to support `npm create @n8n/node`
|
||||
5
packages/@n8n/node-cli/bin/n8n-node.js
Executable file
5
packages/@n8n/node-cli/bin/n8n-node.js
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { execute } from '@oclif/core';
|
||||
|
||||
await execute({ dir: import.meta.url });
|
||||
7
packages/@n8n/node-cli/eslint.config.mjs
Normal file
7
packages/@n8n/node-cli/eslint.config.mjs
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'eslint/config';
|
||||
import { nodeConfig } from '@n8n/eslint-config/node';
|
||||
|
||||
export default defineConfig(nodeConfig, {
|
||||
files: ['./src/commands/*.ts'],
|
||||
rules: { 'import-x/no-default-export': 'off' },
|
||||
});
|
||||
46
packages/@n8n/node-cli/package.json
Normal file
46
packages/@n8n/node-cli/package.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"name": "@n8n/node-cli",
|
||||
"version": "0.1.0",
|
||||
"description": "Official CLI for developing community nodes for n8n",
|
||||
"bin": {
|
||||
"n8n-node": "./bin/n8n-node.js"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf dist .turbo",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"dev": "tsc -w",
|
||||
"format": "biome format --write src",
|
||||
"format:check": "biome ci src",
|
||||
"lint": "eslint src --quiet",
|
||||
"lintfix": "eslint src --fix",
|
||||
"build": "tsc",
|
||||
"publish:dry": "pnpm run build && pnpm pub --dry-run",
|
||||
"test": "vitest run",
|
||||
"test:dev": "vitest --silent=false",
|
||||
"start": "./bin/n8n-node.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/n8n-io/n8n"
|
||||
},
|
||||
"oclif": {
|
||||
"bin": "n8n-node",
|
||||
"commands": "./dist/commands",
|
||||
"topicSeparator": " "
|
||||
},
|
||||
"dependencies": {
|
||||
"@oclif/core": "^4.5.2",
|
||||
"prompts": "^2.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@n8n/typescript-config": "workspace:*",
|
||||
"@n8n/vitest-config": "workspace:*",
|
||||
"@oclif/test": "^4.1.13"
|
||||
}
|
||||
}
|
||||
8
packages/@n8n/node-cli/src/commands/create.test.ts
Normal file
8
packages/@n8n/node-cli/src/commands/create.test.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { runCommand } from '@oclif/test';
|
||||
|
||||
describe('n8n-node create', () => {
|
||||
it('should print correct output', async () => {
|
||||
const { stdout } = await runCommand('create -f', { root: import.meta.dirname });
|
||||
expect(stdout).toEqual('hello from commands/create.ts (force=true)\n');
|
||||
});
|
||||
});
|
||||
17
packages/@n8n/node-cli/src/commands/create.ts
Normal file
17
packages/@n8n/node-cli/src/commands/create.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Command, Flags } from '@oclif/core';
|
||||
|
||||
export default class Create extends Command {
|
||||
static override description = 'Create a new n8n community node';
|
||||
static override examples = ['<%= config.bin %> <%= command.id %>'];
|
||||
static override flags = {
|
||||
// flag with no value (-f, --force)
|
||||
force: Flags.boolean({ char: 'f' }),
|
||||
};
|
||||
|
||||
async run(): Promise<void> {
|
||||
const { flags } = await this.parse(Create);
|
||||
|
||||
const force = flags.force;
|
||||
this.log(`hello from commands/create.ts (force=${force})`);
|
||||
}
|
||||
}
|
||||
12
packages/@n8n/node-cli/tsconfig.json
Normal file
12
packages/@n8n/node-cli/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "@n8n/typescript-config/modern/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"types": ["vite/client", "vitest/globals"],
|
||||
"isolatedModules": true
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["src/**/*.test.ts"]
|
||||
}
|
||||
4
packages/@n8n/node-cli/vite.config.ts
Normal file
4
packages/@n8n/node-cli/vite.config.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { vitestConfig } from '@n8n/vitest-config/node';
|
||||
import { defineConfig, mergeConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({ test: { globals: true, disableConsoleIntercept: true } });
|
||||
Reference in New Issue
Block a user