Skip to content

Commit d55fdca

Browse files
committed
fix: update epicfail
1 parent 6fba9b9 commit d55fdca

8 files changed

Lines changed: 62 additions & 55 deletions

File tree

.release-it.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ plugins:
99
preset: angular
1010
infile: CHANGELOG.md
1111
hooks:
12-
before:init: yarn test
12+
before:init: npm test

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ node lib/cli.js test
1212
## Release Guide (Maintainers only)
1313

1414
```bash
15-
yarn release
15+
release-it
1616
```

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"version": "5.7.0",
55
"author": "Yasuaki Uechi <y@uechi.io>",
66
"scripts": {
7-
"build": "shx rm -rf lib && yarn build:ts --minify --dts",
7+
"build": "shx rm -rf lib && npm run build:ts --minify --dts",
88
"build:ts": "tsup src/index.ts src/cli.ts -d lib",
9-
"dev": "yarn build:ts --watch",
10-
"prepublishOnly": "yarn build",
9+
"dev": "npm run build:ts --watch",
10+
"prepublishOnly": "npm run build",
1111
"release": "release-it",
1212
"test": "echo notest"
1313
},
@@ -16,31 +16,31 @@
1616
"@types/yargs-interactive": "^2.1.1",
1717
"chalk": "^4.1.0",
1818
"cross-spawn": "^7.0.3",
19-
"epicfail": "^0.4.2",
19+
"epicfail": "^1.0.0",
2020
"execa": "^4.0.3",
2121
"gitconfig": "^2.0.8",
2222
"globby": "^11.0.1",
2323
"handlebars": "^4.7.6",
24-
"inquirer": "^7.3.2",
24+
"inquirer": "^7.3.3",
2525
"is-utf8": "^0.2.1",
2626
"license.js": "^3.1.2",
2727
"slash": "^3.0.0",
28-
"uuid": "^8.2.0",
28+
"uuid": "^8.3.0",
2929
"yargs-interactive": "^3.0.0"
3030
},
3131
"devDependencies": {
3232
"@release-it/conventional-changelog": "^1.1.4",
3333
"@types/cross-spawn": "^6.0.2",
34-
"@types/node": "^14.0.24",
34+
"@types/node": "^14.0.27",
3535
"@types/uuid": "^8.0.0",
36-
"doctoc": "^1.4.0",
36+
"@uetchy/doctoc": "^1.4.0",
3737
"husky": "^4.2.5",
3838
"prettier": "^2.0.5",
3939
"pretty-quick": "^2.0.1",
4040
"release-it": "^13.6.6",
4141
"shx": "^0.3.2",
4242
"ts-node": "^8.10.2",
43-
"tsup": "^3.1.1",
43+
"tsup": "^3.4.2",
4444
"typescript": "^3.9.7"
4545
},
4646
"types": "lib/index.d.ts",

src/cli.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import epicfail from 'epicfail';
55
import { resolve } from 'path';
66
import { AfterHookOptions, create } from '.';
77

8-
epicfail();
8+
epicfail({
9+
assertExpected: (err) => err.name === 'CLIError',
10+
});
911

1012
const templateRoot = resolve(__dirname, '..', 'templates');
1113
const caveat = ({ name, template }: AfterHookOptions) => {

src/index.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import chalk from 'chalk';
22
import { CommonSpawnOptions } from 'child_process';
33
import { spawn } from 'cross-spawn';
4-
import { EpicfailError } from 'epicfail';
54
import execa, { CommonOptions, ExecaChildProcess } from 'execa';
65
import fs from 'fs';
76
import gitconfig from 'gitconfig';
@@ -66,6 +65,13 @@ export interface AfterHookOptions {
6665
installNpmPackage: (packageName: string) => Promise<void>;
6766
}
6867

68+
class CLIError extends Error {
69+
constructor(message: string) {
70+
super(message);
71+
this.name = 'CLIError';
72+
}
73+
}
74+
6975
async function getGitUser(): Promise<{ name?: string; email?: string }> {
7076
try {
7177
const config = await gitconfig.get({ location: 'global' });
@@ -104,7 +110,7 @@ async function installDeps(rootDir: string, useYarn: boolean) {
104110
try {
105111
await spawnPromise(command, args, { stdio: 'inherit' });
106112
} catch (err) {
107-
error(`installDeps failed: ${err}`);
113+
throw new CLIError(`installDeps failed: ${err}`);
108114
}
109115
}
110116

@@ -189,16 +195,10 @@ async function getYargsOptions(
189195
return yargOption;
190196
}
191197

192-
function error(message: string): void {
193-
const err = new EpicfailError(message);
194-
err.epicfail = { message: false, stacktrace: false, env: false };
195-
throw err;
196-
}
197-
198198
export async function create(appName: string, options: Options) {
199199
const firstArg = process.argv[2];
200200
if (firstArg === undefined) {
201-
error(`${appName} <name>`);
201+
throw new CLIError(`${appName} <name>`);
202202
}
203203
const useCurrentDir = firstArg === '.';
204204
const name: string = useCurrentDir
@@ -210,7 +210,7 @@ export async function create(appName: string, options: Options) {
210210
const { templateRoot, promptForTemplate = false } = options;
211211

212212
if (isOccupied(packageDir)) {
213-
error(`${packageDir} is not empty directory.`);
213+
throw new CLIError(`${packageDir} is not empty directory.`);
214214
}
215215

216216
const yargsOption = await getYargsOptions(
@@ -228,7 +228,7 @@ export async function create(appName: string, options: Options) {
228228
const contact = getContact(args.author, args.email);
229229

230230
if (!fs.existsSync(templateDir)) {
231-
error('No template found');
231+
throw new CLIError('No template found');
232232
}
233233

234234
const filteredArgs = Object.entries<string>(args)

templates/default/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.0",
55
"author": "{{contact}}",
66
"dependencies": {
7-
"create-create-app": "^5.7.0"
7+
"create-create-app": "^6.0.0"
88
},
99
"bin": "src/cli.js",
1010
"files": [

templates/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"prepublishOnly": "npm run clean && npm run build"
1111
},
1212
"dependencies": {
13-
"create-create-app": "^5.7.0"
13+
"create-create-app": "^6.0.0"
1414
},
1515
"devDependencies": {
1616
"tsup": "^3.1.1",

yarn.lock

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@
251251
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
252252
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=
253253

254-
"@types/node@*", "@types/node@^14.0.24":
254+
"@types/node@*":
255255
version "14.0.24"
256256
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.24.tgz#b0f86f58564fa02a28b68f8b55d4cdec42e3b9d6"
257257
integrity sha512-btt/oNOiDWcSuI721MdL8VQGnjsKjlTMdrKyTcLCKeQp/n4AAMFJ961wMbp+09y8WuGPClDEv07RIItdXKIXAA==
258258

259-
"@types/node@>= 8":
259+
"@types/node@>= 8", "@types/node@^14.0.27":
260260
version "14.0.27"
261261
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.27.tgz#a151873af5a5e851b51b3b065c9e63390a9e0eb1"
262262
integrity sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==
@@ -309,6 +309,18 @@
309309
dependencies:
310310
"@types/yargs-parser" "*"
311311

312+
"@uetchy/doctoc@^1.4.0":
313+
version "1.5.0"
314+
resolved "https://registry.yarnpkg.com/@uetchy/doctoc/-/doctoc-1.5.0.tgz#57ce52f1f7b9567dd8d7a6e9003baa91454f68b3"
315+
integrity sha512-GJSTqqyd2jJbRHeoS4hg7E9CONQTi1HUYhHD/ZtIBG4//8cIhw7ylRrmYyeKLJxSkcNw0C8B3zL3pIACujQGgQ==
316+
dependencies:
317+
"@textlint/markdown-to-ast" "~6.0.9"
318+
anchor-markdown-header "^0.5.5"
319+
htmlparser2 "~3.9.2"
320+
minimist "~1.2.0"
321+
underscore "~1.8.3"
322+
update-section "^0.3.0"
323+
312324
JSONStream@^1.0.4:
313325
version "1.3.5"
314326
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0"
@@ -1180,18 +1192,6 @@ dir-glob@^3.0.1:
11801192
dependencies:
11811193
path-type "^4.0.0"
11821194

1183-
doctoc@^1.4.0:
1184-
version "1.4.0"
1185-
resolved "https://registry.yarnpkg.com/doctoc/-/doctoc-1.4.0.tgz#3115aa61d0a92f0abb0672036918ea904f5b9e02"
1186-
integrity sha512-8IAq3KdMkxhXCUF+xdZxdJxwuz8N2j25sMgqiu4U4JWluN9tRKMlAalxGASszQjlZaBprdD2YfXpL3VPWUD4eg==
1187-
dependencies:
1188-
"@textlint/markdown-to-ast" "~6.0.9"
1189-
anchor-markdown-header "^0.5.5"
1190-
htmlparser2 "~3.9.2"
1191-
minimist "~1.2.0"
1192-
underscore "~1.8.3"
1193-
update-section "^0.3.0"
1194-
11951195
dom-serializer@0:
11961196
version "0.2.2"
11971197
resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.2.2.tgz#1afb81f533717175d478655debc5e332d9f9bb51"
@@ -1281,10 +1281,10 @@ envinfo@^7.5.1:
12811281
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.7.0.tgz#fbfa46d739dec0554ef40220cd91fb20f64c9698"
12821282
integrity sha512-XX0+kACx7HcIFhar/JjsDtDIVcC8hnzQO1Asehq+abs+v9MtzpUuujFb6eBTT4lF9j2Bh6d2XFngbFRryjUAeQ==
12831283

1284-
epicfail@^0.4.2:
1285-
version "0.4.2"
1286-
resolved "https://registry.yarnpkg.com/epicfail/-/epicfail-0.4.2.tgz#7ce5a12784242729aa9dde1cfcafdb780eba6743"
1287-
integrity sha512-4jfd8FLydt9cCTd/ospmkow8RyFi7eX9ge46GaJ/48S/RXe/PglvGB/t+08GHhOIZ6KEE3yhVO5krL9AhHJfAA==
1284+
epicfail@^1.0.0:
1285+
version "1.0.0"
1286+
resolved "https://registry.npmjs.org/epicfail/-/epicfail-1.0.0.tgz#adcb42a61ee7b6df206e01a0287d3486baa60710"
1287+
integrity sha512-7AqQSRzwN5NA9EX9BOyGf4ZOIEuGiguFYAr4mohMDA0tJsGOCkEXHfb1c0RlYOSwHIEO+laRzkobj//lJEaYng==
12881288
dependencies:
12891289
chalk "^4.1.0"
12901290
envinfo "^7.5.1"
@@ -1341,10 +1341,10 @@ es6-weak-map@^2.0.2:
13411341
es6-iterator "^2.0.3"
13421342
es6-symbol "^3.1.1"
13431343

1344-
esbuild@^0.6.4:
1345-
version "0.6.5"
1346-
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.6.5.tgz#efbe11cf51abd0d4d489ca1bc80fd4761a35bd16"
1347-
integrity sha512-glMZd0b6W2soHuUuchM6c55e6gbdDhVpvYcmLsH3OJo87hQZcb3lFPZAJ5MbzLCJa2bChQOaoC4bqVtbqfsM/A==
1344+
esbuild@^0.6.6:
1345+
version "0.6.16"
1346+
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.6.16.tgz#a5363761dd17283e090dae398f5ff4908cad789d"
1347+
integrity sha512-Jm4aJYAk4uBP2RssDe/rvYCrpGkfOJ5tPBZUF6da62pUtyzk8/RVwXZB4q8dxjYLKZNmY4lYJRpWY+wT3kme1w==
13481348

13491349
escape-goat@^2.0.0:
13501350
version "2.1.1"
@@ -1907,7 +1907,7 @@ ini@^1.3.2, ini@^1.3.5, ini@~1.3.0:
19071907
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
19081908
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==
19091909

1910-
inquirer@7.3.3:
1910+
inquirer@7.3.3, inquirer@^7.3.3:
19111911
version "7.3.3"
19121912
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003"
19131913
integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==
@@ -1926,7 +1926,7 @@ inquirer@7.3.3:
19261926
strip-ansi "^6.0.0"
19271927
through "^2.3.6"
19281928

1929-
inquirer@^7.0.0, inquirer@^7.3.2:
1929+
inquirer@^7.0.0:
19301930
version "7.3.2"
19311931
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.2.tgz#25245d2e32dc9f33dbe26eeaada231daa66e9c7c"
19321932
integrity sha512-DF4osh1FM6l0RJc5YWYhSDB6TawiBRlbV9Cox8MWlidU218Tb7fm3lQTULyUJDfJ0tjbzl0W4q651mrCCEM55w==
@@ -3844,15 +3844,15 @@ tslib@^1.9.0:
38443844
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
38453845
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==
38463846

3847-
tsup@^3.1.1:
3848-
version "3.1.1"
3849-
resolved "https://registry.yarnpkg.com/tsup/-/tsup-3.1.1.tgz#6b433a4a4f85973707c9df7a33d8d34a5f0e81aa"
3850-
integrity sha512-pBIQn7lKa316VIYAYxOvZJIn3aj4LncE7Inkhk4tOGVqf4PTabFZx0JJxYsUta9WXm7gJvGUa8pRoWoQ9FkGjA==
3847+
tsup@^3.4.2:
3848+
version "3.4.2"
3849+
resolved "https://registry.yarnpkg.com/tsup/-/tsup-3.4.2.tgz#82a317c65e7b46f729a2c5d953dc2460e77d71bc"
3850+
integrity sha512-EQ7/tIMu66I5caj5yMdO6o3bh/NTROBrHF7PXqLZqzl2IocTP3EdohkSAk9pNdxB9XOq5GgsK8BkqvlFGD6kLQ==
38513851
dependencies:
38523852
cac "^6.6.1"
38533853
chalk "^4.1.0"
38543854
chokidar "^3.4.1"
3855-
esbuild "^0.6.4"
3855+
esbuild "^0.6.6"
38563856
joycon "^2.2.5"
38573857
rollup "^2.22.1"
38583858
rollup-plugin-dts "^1.4.8"
@@ -4019,11 +4019,16 @@ util-deprecate@^1.0.1, util-deprecate@~1.0.1:
40194019
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
40204020
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
40214021

4022-
uuid@8.2.0, uuid@^8.2.0:
4022+
uuid@8.2.0:
40234023
version "8.2.0"
40244024
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.2.0.tgz#cb10dd6b118e2dada7d0cd9730ba7417c93d920e"
40254025
integrity sha512-CYpGiFTUrmI6OBMkAdjSDM0k5h8SkkiTP4WAjQgDgNB1S3Ou9VBEvr6q0Kv2H1mMk7IWfxYGpMH5sd5AvcIV2Q==
40264026

4027+
uuid@^8.3.0:
4028+
version "8.3.0"
4029+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.0.tgz#ab738085ca22dc9a8c92725e459b1d507df5d6ea"
4030+
integrity sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==
4031+
40274032
validate-npm-package-license@^3.0.1:
40284033
version "3.0.4"
40294034
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"

0 commit comments

Comments
 (0)