mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-16 01:24:05 -08:00
1e551a202f
* Added flag to simplify output to execute command and created executeAll Also created a command that lists workflows so it can be used by other applications that wish to interact with n8n via CLI. * Added compare funcionality that helps us identify possible breaking changes * ⚡ Add JSON flag to output execution result in json format * Add execution time to execution result * Add --output flag to save JSON formated results * Fix typos * Adding usage examples and warning message * Changing command to always output JSON information * ⚡ Add concurrency to executeAll command * ✨ Add IDs filter to executeAll command * ✏️ Fix typos * Fix lint issues * Improvements to execute all * Added colors and beautified execute all command output * Improving premature termination of execute all command * Refactored output * Added detection for warnings instead of errors for a few cases * Fixed linting * Improved process finishing * Added encryption key init, removed messages from non-debug run and created sample github actions file * Updated test command to use correct encryption key * Correcting paths * Changed command name and changed concurrency to be slot based * Added the retry functionality * Improved typing and fixed executions filtering * Updated test description * Added concurrency * Added skip list and concurrency * Fixed termination behavior, removed unnecessary code and added main mode to executions * Added special edge cases handling * Added safe debug flag for non tty terminals * Removed comparison and retries for testing * Changed the way we run commands to add more debug info * Test adding concurrency * Testing with regular testing procedure without comparison * Adding compare flag * Fixing short output command * Upgraded concurrency to 16, fixed short output and covered nodes count * Fixed short output condition * Correcting short output information * Correcting the output for short output * Added a string to possible warnings list * Added example usages with more arguments * Improvements to code made by Ivan * Removed colorize output setting (always use colors), moved execution timeout to become static and removed node list from executions * Moving types to a separate file on execute batch command * Changed interfaces file extension to prevent oclif warnings * Updated workflow pdf files * ⚡ Change rule when tests run + minor formatting fixes Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
68 lines
1.4 KiB
TypeScript
68 lines
1.4 KiB
TypeScript
import {
|
|
Command,
|
|
flags,
|
|
} from '@oclif/command';
|
|
|
|
import {
|
|
IDataObject
|
|
} from 'n8n-workflow';
|
|
|
|
import {
|
|
Db,
|
|
} from "../../src";
|
|
|
|
|
|
export class ListWorkflowCommand extends Command {
|
|
static description = '\nList workflows';
|
|
|
|
static examples = [
|
|
'$ n8n list:workflow',
|
|
'$ n8n list:workflow --active=true --onlyId',
|
|
'$ n8n list:workflow --active=false',
|
|
];
|
|
|
|
static flags = {
|
|
help: flags.help({ char: 'h' }),
|
|
active: flags.string({
|
|
description: 'Filters workflows by active status. Can be true or false',
|
|
}),
|
|
onlyId: flags.boolean({
|
|
description: 'Outputs workflow IDs only, one per line.',
|
|
}),
|
|
};
|
|
|
|
async run() {
|
|
const { flags } = this.parse(ListWorkflowCommand);
|
|
|
|
if (flags.active !== undefined && !['true', 'false'].includes(flags.active)) {
|
|
this.error('The --active flag has to be passed using true or false');
|
|
}
|
|
|
|
try {
|
|
await Db.init();
|
|
|
|
const findQuery: IDataObject = {};
|
|
if (flags.active !== undefined) {
|
|
findQuery.active = flags.active === 'true';
|
|
}
|
|
|
|
const workflows = await Db.collections.Workflow!.find(findQuery);
|
|
if (flags.onlyId) {
|
|
workflows.forEach(workflow => console.log(workflow.id));
|
|
} else {
|
|
workflows.forEach(workflow => console.log(workflow.id + "|" + workflow.name));
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
console.error('\nGOT ERROR');
|
|
console.log('====================================');
|
|
console.error(e.message);
|
|
console.error(e.stack);
|
|
this.exit(1);
|
|
}
|
|
|
|
this.exit();
|
|
}
|
|
}
|