Skip to content

Commit

Permalink
perf: upgrade dependencies and fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
Val-istar-Guo committed Mar 23, 2022
1 parent 2b87306 commit d72cdc6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"prewatch": "npm run copyfile:lib"
},
"devDependencies": {
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.15.2",
Expand Down Expand Up @@ -84,9 +84,9 @@
"@types/node": "^14.14.31",
"@types/ramda": "^0.27.11",
"@types/semver": "^7.3.1",
"ajv8": "npm:ajv@^8.1.0",
"ajv-formats": "^2.1.0",
"ajv-keywords": "^5.0.0",
"ajv8": "npm:ajv@^8.1.0",
"chalk": "^4.1.0",
"commander": "^7.2.0",
"cosmiconfig": "^7.0.0",
Expand All @@ -102,9 +102,10 @@
"json5": "^2.2.0",
"micromatch": "^4.0.2",
"ora": "^5.4.0",
"pretty-error": "^4.0.0",
"ramda": "^0.27.0",
"semver": "^7.3.2",
"simple-git": "^2.39.0",
"simple-git": "^3.4.0",
"temp-dir": "^2.0.0",
"uuid": "^3.4.0",
"validate-npm-package-name": "^3.0.0"
Expand Down
7 changes: 3 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { program } from 'commander'
import * as path from 'path'
import * as fs from 'fs-extra'
import * as milircSchema from './schema/milirc.json'
import * as chalk from 'chalk'
import { cosmiconfig } from 'cosmiconfig'
import { version } from '../package.json'
import { init } from './init'
Expand All @@ -14,6 +13,7 @@ import { Milirc } from './interface/milirc'
import { clean } from './clean'
import { check } from './check'
import * as logger from '@/util/logger'
import { prettyError } from '@/util/pretty-error'


const ajv = new Ajv()
Expand All @@ -27,7 +27,7 @@ async function getConfig(cwd: string = process.cwd()): Promise<Milirc> {
const config = result.config
const valid = validate(config)
if (!valid) throw new Error(ajv.errorsText(validate.errors, { dataVar: 'milirc' }))
return config as Milirc
return config as unknown as Milirc
}

async function main(): Promise<void> {
Expand Down Expand Up @@ -143,8 +143,7 @@ async function main(): Promise<void> {
try {
await program.parseAsync(process.argv)
} catch (e) {
logger.error(chalk.red(e.message))
console.log(e.stack)
logger.error(prettyError(e))
process.exitCode = 1
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/render/exec-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ export async function execHandler(dist: Path, src: Path, filepath: Path, resourc
if (!valid) throw new Error(ajv.errorsText(validate.errors, { dataVar: 'loader' }))

// TODO: Check Hanlder engines
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return await pkg.compile(dist, src, filepath, resource, handler.options)
}
3 changes: 3 additions & 0 deletions src/render/exec-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ export async function execLoader(cwd: string, loader: Loader): Promise<Record<st
const valid = validate(pkg)
if (!valid) throw new Error(ajv.errorsText(validate.errors, { dataVar: 'loader' }))

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return pkg.exec(cwd, loader.options)
}
6 changes: 6 additions & 0 deletions src/util/pretty-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as PrettyError from 'pretty-error'

export const pe = new PrettyError()
export function prettyError(e: unknown): string {
return pe.render(e instanceof Error ? e : new Error(String(e)))
}

0 comments on commit d72cdc6

Please sign in to comment.