@aomex/console
Advanced tools
Comparing version 0.0.5 to 0.0.6
# @aomex/console | ||
## 0.0.5 | ||
## 0.0.6 | ||
### Patch Changes | ||
- [`13033a9`](https://github.com/aomex/aomex/commit/13033a924a2fbfc4c8360bb198f4aa66fa8e4e04) Thanks [@geekact](https://github.com/geekact)! - feat(console): 挂载中间件时检测到链条自动创建分割点 | ||
- [`bbc8dda`](https://github.com/aomex/aomex/commit/bbc8dda9f0876c3402608133085350cc693def6f) Thanks [@geekact](https://github.com/geekact)! - refactor: rename package helper to utility | ||
- [`146b6b5`](https://github.com/aomex/aomex/commit/146b6b5f09d4b9f557c1771686f3585bebf4cfc9) Thanks [@geekact](https://github.com/geekact)! - refactor(helper): 重命名 color 为 chalk | ||
- [`9866b9e`](https://github.com/aomex/aomex/commit/9866b9e63abb71e1197ff8002c38bac04a36dd62) Thanks [@geekact](https://github.com/geekact)! - feat(console): run command parallel is supported | ||
- Updated dependencies [[`146b6b5`](https://github.com/aomex/aomex/commit/146b6b5f09d4b9f557c1771686f3585bebf4cfc9), [`e8dee7c`](https://github.com/aomex/aomex/commit/e8dee7c3f064587cd2afb9cb95ab3341f63ccd27)]: | ||
- @aomex/helper@0.0.3 | ||
- @aomex/core@0.0.5 | ||
## 0.0.4 | ||
### Patch Changes | ||
- [`1a2800d`](https://github.com/aomex/aomex/commit/1a2800d3a27f2b45fd5db314c1ca81295831b77d) Thanks [@geekact](https://github.com/geekact)! - feat(console): help 类型的中间件需判断是否存在 cli 属性 | ||
- [`cd9369f`](https://github.com/aomex/aomex/commit/cd9369f585053b0003a121fe5fee71c44d78587e) Thanks [@geekact](https://github.com/geekact)! - feat(console): 导出 scriptName 变量 | ||
- [`6a57463`](https://github.com/aomex/aomex/commit/6a57463c1107c38a8b8cf5fa00ff3289bf629c0a) Thanks [@geekact](https://github.com/geekact)! - refactor(middleware): 类型 MiddlewareFn 和 GetMiddlewareProps 迁移到命名空间 | ||
- [`f6bbf24`](https://github.com/aomex/aomex/commit/f6bbf247a81d20c14598c1046169c2e6e1e48fec) Thanks [@geekact](https://github.com/geekact)! - fix(console): 从错误的字段中过滤中间件 | ||
- [`6849b03`](https://github.com/aomex/aomex/commit/6849b03dc1e0dc9b707d89dfe98327c9f120dc7f) Thanks [@geekact](https://github.com/geekact)! - feat(middleware): chain.flatten 支持传入数组 | ||
- [`56a5e1f`](https://github.com/aomex/aomex/commit/56a5e1fffe3e1cec863e52c21d122979d121c630) Thanks [@geekact](https://github.com/geekact)! - fix(console): description 赋值错误 | ||
- Updated dependencies [[`956bba9`](https://github.com/aomex/aomex/commit/956bba9e5b954f34486ad5f2b45a5277c1f980c9), [`ee021e3`](https://github.com/aomex/aomex/commit/ee021e342814f12777e538c06a19971e1020f201)]: | ||
- @aomex/helper@0.0.2 | ||
- @aomex/core@0.0.4 | ||
## 0.0.3 | ||
### Patch Changes | ||
- [`ee5f8ca`](https://github.com/aomex/aomex/commit/ee5f8ca34df085ab9b5ef2a3525cf361ac46440a) Thanks [@geekact](https://github.com/geekact)! - request.query 重命名为 request.options | ||
- [`d06c1c1`](https://github.com/aomex/aomex/commit/d06c1c1bdfee8657a74bbcbb06a2880263e85529) Thanks [@geekact](https://github.com/geekact)! - middleware 增加构造函数 | ||
- Updated dependencies []: | ||
- @aomex/core@0.0.3 | ||
## 0.0.2 | ||
### Patch Changes | ||
- [`f0b7c9a`](https://github.com/aomex/aomex/commit/f0b7c9a7ce70774080b645c4952ad9b1d0948cf5) Thanks [@geekact](https://github.com/geekact)! - 增加前置全局中间件概念 | ||
- Updated dependencies [[`d1ce4e2`](https://github.com/aomex/aomex/commit/d1ce4e2276f93c44e67ea06666d048917fa94e53)]: | ||
- @aomex/core@0.0.2 | ||
## 0.0.1 | ||
### Patch Changes | ||
- Updated dependencies [[`be095e9`](https://github.com/aomex/aomex/commit/be095e964ec136982581f4ea09024f716ff93a3d)]: | ||
- @aomex/helper@0.0.1 | ||
- @aomex/core@0.0.1 | ||
- Updated dependencies [[`589243d`](https://github.com/aomex/aomex/commit/589243da955f3e4296d30fdfe05eac0c45714281), [`24d45f0`](https://github.com/aomex/aomex/commit/24d45f02966cfd936d493de5844bcae73caa6d10), [`cab01c6`](https://github.com/aomex/aomex/commit/cab01c63d60e73a7e24018e6872080d5656c29e2), [`bbc8dda`](https://github.com/aomex/aomex/commit/bbc8dda9f0876c3402608133085350cc693def6f)]: | ||
- @aomex/file-parser@0.0.3 | ||
- @aomex/utility@0.0.4 | ||
- @aomex/core@0.0.6 |
import { Chain, PureMiddlewareToken, Next, Middleware, Validator } from '@aomex/core'; | ||
import { NonReadonly } from '@aomex/helper'; | ||
import { NonReadonly } from '@aomex/utility'; | ||
import { Argv } from 'yargs'; | ||
@@ -20,14 +20,17 @@ import EventEmitter from 'node:events'; | ||
interface ConsoleAppOption { | ||
silent?: boolean; | ||
} | ||
declare class ConsoleApp extends EventEmitter { | ||
protected readonly options: ConsoleAppOption; | ||
readonly chainPoints: string[]; | ||
protected running: boolean; | ||
protected level: number; | ||
protected readonly tokenList: ConsoleMiddlewareToken[]; | ||
constructor(_options?: ConsoleAppOption); | ||
constructor(options?: ConsoleAppOption); | ||
/** | ||
* 执行命令。如果不传参数,则自动从`process.argv`中获取 | ||
* Run command. Builtin `process.argv` will be used by default until you input one or more arguments. | ||
* @see process.argv | ||
*/ | ||
run(...commands: string[]): Promise<void>; | ||
log(err: Error): void; | ||
mount(middleware: ConsoleMiddlewareToken): void; | ||
mount(middleware: ConsoleMiddlewareToken | null): void; | ||
} | ||
@@ -101,3 +104,3 @@ | ||
/** | ||
* 验证控制台命令的传入参数,同时可以设置参数别名 | ||
* Validate command-line options, and make type safe. | ||
* | ||
@@ -113,3 +116,3 @@ * ```typescript | ||
* }, { | ||
* date: ['d'], // 传参形式: --date=xxx 或者 -d=xxx | ||
* date: ['d'], // alias --date or -d | ||
* }); | ||
@@ -128,2 +131,18 @@ * ], | ||
export { ConsoleApp, ConsoleAppOption, ConsoleChain, ConsoleContext, ConsoleMiddleware, ConsoleMiddlewareToken, ConsoleOptionMiddleware, ConsoleRequest, ConsoleResponse, HelpMiddleware, YargsInstance, options, scriptName, version }; | ||
interface Config { | ||
cliEntry: { | ||
/** | ||
* Entry file by each environment | ||
* @see process.env.NODE_ENV | ||
*/ | ||
[NODE_ENV: string]: string | undefined; | ||
/** | ||
* Fallback to `default` if NODE_ENV doesn't match specific file. | ||
* @see process.env.NODE_ENV | ||
*/ | ||
default?: string; | ||
}; | ||
} | ||
declare const defineConfig: (config: Config) => Config; | ||
export { Config, ConsoleApp, ConsoleAppOption, ConsoleChain, ConsoleContext, ConsoleMiddleware, ConsoleMiddlewareToken, ConsoleOptionMiddleware, ConsoleRequest, ConsoleResponse, HelpMiddleware, YargsInstance, defineConfig, options, scriptName, version }; |
@@ -9,4 +9,4 @@ // src/override/middleware.ts | ||
// src/info.ts | ||
var version = "0.0.5"; | ||
// src/meta.ts | ||
var version = "0.0.6"; | ||
var scriptName = "aomex"; | ||
@@ -117,18 +117,17 @@ | ||
// src/app/app.ts | ||
import { chalk } from "@aomex/helper"; | ||
import { chalk } from "@aomex/utility"; | ||
var ConsoleApp = class extends EventEmitter { | ||
constructor(options2 = {}) { | ||
super(); | ||
this.options = options2; | ||
} | ||
chainPoints = []; | ||
running = false; | ||
level = 0; | ||
tokenList = []; | ||
constructor(_options = {}) { | ||
super(); | ||
} | ||
/** | ||
* 执行命令。如果不传参数,则自动从`process.argv`中获取 | ||
* Run command. Builtin `process.argv` will be used by default until you input one or more arguments. | ||
* @see process.argv | ||
*/ | ||
async run(...commands) { | ||
if (this.running) { | ||
throw new Error('Call "app.run()" multiple times at same time'); | ||
} | ||
this.running = true; | ||
const currentLevel = this.level++; | ||
const request = new ConsoleRequest( | ||
@@ -141,3 +140,3 @@ this, | ||
if (!this.listenerCount("error")) { | ||
this.on("error", this.log); | ||
this.on("error", this.log.bind(this)); | ||
} | ||
@@ -157,9 +156,11 @@ try { | ||
} catch (e) { | ||
this.emit("error", e); | ||
currentLevel === 0 && this.emit("error", e); | ||
throw e; | ||
} finally { | ||
this.running = false; | ||
--this.level; | ||
} | ||
} | ||
log(err) { | ||
if (this.options.silent) | ||
return; | ||
const stack = (err.stack || err.toString()).split(EOL).map((item) => " " + item); | ||
@@ -171,4 +172,6 @@ console.error( | ||
mount(middleware2) { | ||
if (middleware2 === null) | ||
return; | ||
if (middleware2 instanceof Chain2) { | ||
this.chainPoints.push(Chain2.createPoint(middleware2)); | ||
this.chainPoints.push(Chain2.createSplitPoint(middleware2)); | ||
} | ||
@@ -232,2 +235,5 @@ this.tokenList.push(middleware2); | ||
var options = (fields, alias) => new ConsoleOptionMiddleware(fields, alias); | ||
// src/define-config.ts | ||
var defineConfig = (config) => config; | ||
export { | ||
@@ -242,2 +248,3 @@ ConsoleApp, | ||
HelpMiddleware, | ||
defineConfig, | ||
options, | ||
@@ -244,0 +251,0 @@ scriptName, |
{ | ||
"name": "@aomex/console", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "", | ||
@@ -12,10 +12,6 @@ "type": "module", | ||
}, | ||
"./config": { | ||
"types": "./dist/cli/define-config.d.ts", | ||
"import": "./dist/cli/define-config.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"bin": { | ||
"aomex": "dist/cli/bin.js" | ||
"aomex": "dist/bin.js" | ||
}, | ||
@@ -37,7 +33,8 @@ "publishConfig": { | ||
"peerDependencies": { | ||
"@aomex/core": "^0.0.5" | ||
"@aomex/core": "^0.0.6" | ||
}, | ||
"dependencies": { | ||
"@aomex/helper": "^0.0.3", | ||
"cosmiconfig": "^8.0.0", | ||
"@aomex/utility": "^0.0.4", | ||
"@aomex/file-parser": "^0.0.3", | ||
"ts-node": "^10.9.1", | ||
"yargs": "^17.6.2", | ||
@@ -47,3 +44,3 @@ "yargs-parser": "^21.1.1" | ||
"devDependencies": { | ||
"@aomex/core": "^0.0.5", | ||
"@aomex/core": "^0.0.6", | ||
"@types/yargs": "^17.0.22", | ||
@@ -50,0 +47,0 @@ "@types/yargs-parser": "^21.0.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38625
518
6
10
+ Added@aomex/file-parser@^0.0.3
+ Added@aomex/utility@^0.0.4
+ Addedts-node@^10.9.1
+ Added@aomex/cache@0.0.3(transitive)
+ Added@aomex/core@0.0.6(transitive)
+ Added@aomex/file-parser@0.0.3(transitive)
+ Added@aomex/middleware@0.0.4(transitive)
+ Added@aomex/utility@0.0.4(transitive)
+ Added@aomex/validator@0.0.5(transitive)
+ Added@cspotcode/source-map-support@0.8.1(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.9(transitive)
+ Added@tsconfig/node10@1.0.11(transitive)
+ Added@tsconfig/node12@1.0.11(transitive)
+ Added@tsconfig/node14@1.0.3(transitive)
+ Added@tsconfig/node16@1.0.4(transitive)
+ Added@types/bytes@3.1.4(transitive)
+ Addedacorn@8.14.0(transitive)
+ Addedacorn-walk@8.3.4(transitive)
+ Addedarg@4.1.3(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcreate-require@1.1.1(transitive)
+ Addeddiff@4.0.2(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@9.3.5(transitive)
+ Addedlru-cache@10.4.3(transitive)
+ Addedmake-error@1.3.6(transitive)
+ Addedminimatch@8.0.4(transitive)
+ Addedminipass@4.2.87.1.2(transitive)
+ Addedpath-scurry@1.11.1(transitive)
+ Addedts-node@10.9.2(transitive)
+ Addedv8-compile-cache-lib@3.0.1(transitive)
+ Addedyn@3.1.1(transitive)
- Removed@aomex/helper@^0.0.3
- Removedcosmiconfig@^8.0.0
- Removed@aomex/cache@0.0.2(transitive)
- Removed@aomex/core@0.0.5(transitive)
- Removed@aomex/helper@0.0.3(transitive)
- Removed@aomex/middleware@0.0.3(transitive)
- Removed@aomex/validator@0.0.4(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removedargparse@2.0.1(transitive)
- Removedcallsites@3.1.0(transitive)
- Removedcosmiconfig@8.3.6(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedimport-fresh@3.3.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjs-yaml@4.1.0(transitive)
- Removedjson-parse-even-better-errors@2.3.1(transitive)
- Removedlines-and-columns@1.2.4(transitive)
- Removedparent-module@1.0.1(transitive)
- Removedparse-json@5.2.0(transitive)
- Removedpath-type@4.0.0(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedresolve-from@4.0.0(transitive)