mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Feature/add typings for feflow cli (#43565)
* feat: Add typings for feflow * feat: update comment * feat: fix new line warn * fix: package name error * fix: package name error * feat: change test name * fix: fix lint error * fix: blank error for lint * feat: support npm path * feat: change namespace and tests Co-authored-by: yanzhanghu <yanzhanghu@tencent.com>
This commit is contained in:
20
types/feflow__cli/feflow__cli-tests.ts
Normal file
20
types/feflow__cli/feflow__cli-tests.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
module.exports = (ctx: Feflow.ctx) => {
|
||||
const {
|
||||
commander,
|
||||
hook,
|
||||
logger,
|
||||
} = ctx;
|
||||
const [ action ] = ctx.args['_'];
|
||||
logger.debug(String(action));
|
||||
commander.register('devtool', 'Feflow devtool for better develop a devkit or plugin', async () => {
|
||||
logger.trace('Start dev');
|
||||
logger.debug('Start test');
|
||||
logger.info('Start info');
|
||||
});
|
||||
|
||||
hook.hook('devtool', async () => {
|
||||
logger.warn('Start warn');
|
||||
logger.error('Start error');
|
||||
logger.fatal('Start fatal');
|
||||
});
|
||||
};
|
||||
120
types/feflow__cli/index.d.ts
vendored
Normal file
120
types/feflow__cli/index.d.ts
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
// Type definitions for @feflow/cli 0.18
|
||||
// Project: https://github.com/Tencent/feflow/releases
|
||||
// Definitions by: nikewu <https://github.com/nikewu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
/**
|
||||
* feflow namespace
|
||||
*/
|
||||
declare namespace Feflow {
|
||||
/**
|
||||
* feflow context
|
||||
*/
|
||||
interface ctx {
|
||||
/**
|
||||
* Feflow context params
|
||||
*/
|
||||
args: {
|
||||
_: Array<number | string>
|
||||
};
|
||||
/**
|
||||
* Feflow configuration file in the current directory
|
||||
* ( .feflowrc.json/.feflowrc.js/.feflowrc.yml )
|
||||
*/
|
||||
projectConfig: string;
|
||||
/**
|
||||
* Current project path
|
||||
*/
|
||||
projectPath: string;
|
||||
/**
|
||||
* Feflow version
|
||||
*/
|
||||
version: string;
|
||||
/**
|
||||
* Feflow logger includes: (trace、debug、info、warn、error、fatal)
|
||||
*/
|
||||
logger: Logger;
|
||||
/**
|
||||
* Feflow command includes: (register)
|
||||
*/
|
||||
commander: Command;
|
||||
/**
|
||||
* Feflow hook includes: (hook)
|
||||
*/
|
||||
hook: Hook;
|
||||
/**
|
||||
* Feflow home directory path
|
||||
*/
|
||||
root: string;
|
||||
/**
|
||||
* Feflow home directory package.json path
|
||||
*/
|
||||
rootPkg: string;
|
||||
/**
|
||||
* feflow config
|
||||
*/
|
||||
config: string;
|
||||
/**
|
||||
* feflow config path
|
||||
*/
|
||||
configPath: string;
|
||||
}
|
||||
}
|
||||
|
||||
interface Command {
|
||||
/**
|
||||
* Plugin registration command method parameter description
|
||||
* @param cmd Plugin command name eg:devtool
|
||||
* @param desc Plugin command description eg: Feflow devtool for better develop a devkit or plugin
|
||||
* @param fn Plugin callback function
|
||||
*/
|
||||
register(cmd: string, desc: string, fn: () => void): void;
|
||||
}
|
||||
|
||||
interface Hook {
|
||||
/**
|
||||
* Hook will execute befor any command
|
||||
* Hook registration command method parameter description
|
||||
* @param type Hook name eg:report
|
||||
* @param fn Hook callback function eg:report
|
||||
*/
|
||||
hook(type: string, fn: () => void): void;
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
/**
|
||||
* Print trace level log, The Color is gray
|
||||
* @param desc log detail
|
||||
*/
|
||||
trace(desc: string): void;
|
||||
/**
|
||||
* Print trace level log, The Color is gray
|
||||
* @param desc log detail
|
||||
*/
|
||||
debug(desc: string): void;
|
||||
|
||||
/**
|
||||
* Print trace level log, The Color is green
|
||||
* @param desc log detail
|
||||
*/
|
||||
info(desc: string): void;
|
||||
|
||||
/**
|
||||
* Print trace level log, The Color is yellow
|
||||
* @param desc log detail
|
||||
*/
|
||||
warn(desc: string): void;
|
||||
|
||||
/**
|
||||
* Print trace level log, The Color is red
|
||||
* @param desc log detail
|
||||
*/
|
||||
error(desc: string): void;
|
||||
|
||||
/**
|
||||
* Print trace level log, The Color is red
|
||||
* @param desc log detail
|
||||
*/
|
||||
fatal(desc: string): void;
|
||||
}
|
||||
28
types/feflow__cli/tsconfig.json
Normal file
28
types/feflow__cli/tsconfig.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@feflow/cli": [
|
||||
"feflow__cli"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"feflow__cli-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/feflow__cli/tslint.json
Normal file
1
types/feflow__cli/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user