Skip to content

Commit

Permalink
feat(scripts): handle init termination (#155)
Browse files Browse the repository at this point in the history
* chore(scripts): handle init termination

also bump deps to latest

* chore(scripts): revert to only terminate

* chore(config): reorganize global defs

Closes #153
  • Loading branch information
Hotell committed Dec 24, 2018
1 parent e07e8fb commit 614d7a8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 29 deletions.
14 changes: 8 additions & 6 deletions config/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// ============================
// ts-jest types require 'babel__core'
// extend existing types
// ============================
declare module 'babel__core' {
interface TransformOptions {}
}

// ============================
// Rollup plugins without types
Expand Down Expand Up @@ -58,9 +55,15 @@ declare module 'rollup-plugin-terser' {
export { terser }
}

// =====================
// =====================
// missing library types
// =====================

// ts-jest types require 'babel__core'
declare module 'babel__core' {
interface TransformOptions {}
}

declare module '@commitlint/core' {
interface Config {
extends: string[]
Expand All @@ -74,7 +77,6 @@ declare module 'sort-object-keys' {
export = sortPackageJson
}

declare module 'prompt'
declare module 'replace-in-file' {
interface Options {
files: string | string[]
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@types/json5": "0.0.30",
"@types/node": "8.10.*",
"@types/prettier": "1.15.2",
"@types/prompts": "1.1.1",
"@types/prompts": "1.2.0",
"@types/webpack-config-utils": "2.3.0",
"commitizen": "3.0.5",
"cross-var": "1.1.0",
Expand All @@ -101,7 +101,7 @@
"prettier": "1.15.3",
"prompts": "2.0.0",
"replace-in-file": "3.4.2",
"rollup": "0.67.4",
"rollup": "0.68.2",
"rollup-plugin-commonjs": "9.2.0",
"rollup-plugin-json": "3.1.0",
"rollup-plugin-node-resolve": "4.0.0",
Expand All @@ -116,10 +116,10 @@
"strip-json-comments-cli": "1.0.1",
"ts-jest": "23.10.5",
"tslib": "1.9.3",
"tslint": "5.11.0",
"tslint": "5.12.0",
"tslint-config-prettier": "1.17.0",
"tslint-config-standard": "8.0.1",
"tslint-etc": "1.2.8",
"tslint-etc": "1.2.12",
"tslint-react": "3.6.0",
"typedoc": "0.13.0",
"typescript": "3.2.2",
Expand Down
25 changes: 22 additions & 3 deletions scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,9 @@ function createQuestions(config) {
initial: /**@type any */ (false)
},
{
type: /** @type {import('prompts').ValueOrFunc<string>} */ ((prev) =>
prev === true ? 'text' : null),
type: /** @type {import('prompts').ValueOrFunc<import('prompts').PromptType>} */ ((
prev
) => (prev === true ? 'text' : null)),
name: 'scope',
message: 'Scope/namespace (needs to start with @)',
validate: (value) =>
Expand Down Expand Up @@ -383,6 +384,23 @@ function createQuestions(config) {
]
}

/**
*
* @param {import('prompts').PromptObject} prompt
* @param {any} answers
* @returns {void | boolean}
*/
function handlePromptExit(prompt, answers) {
error(
kleur
.bold()
.white()
.bgRed('Terminating library init')
)

process.exit(1)
}

/**
*
* @param {import('./types').PromptAnswers} promptAnswers
Expand Down Expand Up @@ -428,7 +446,8 @@ async function main() {
const userInfo = getUserInfo()
const questions = createQuestions(userInfo)
const response = /** @type {import('./types').PromptAnswers} */ (await prompts(
questions
questions,
{ onCancel: handlePromptExit }
))
const config = getLibConfig(response)

Expand Down
32 changes: 16 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.15.2.tgz#91594ea7cb6f3b1f7ea69f32621246654c7cc231"
integrity sha512-XIB0ZCaFZmWUHAa9dBqP5UKXXHwuukmVlP+XcyU94dui2k+l2lG+CHAbt2ffenHPUqoIs5Beh8Pdf2YEq/CZ7A==

"@types/prompts@1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/prompts/-/prompts-1.1.1.tgz#5688abfa6a95ddfe808f8ae5337e86e5cf8f3147"
integrity sha512-iqE02VXr48Dw//ZBTU0wiL1gbBn3sclnAuTztMLjd2L3bKgq2Qcn0d6ezIXFMaaAl2382g99CUp/p3scU/JCpQ==
"@types/prompts@1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/prompts/-/prompts-1.2.0.tgz#891e73f735ad5e82e8adae3a99424128e105fb62"
integrity sha512-7JXpT2rSd4hqd2oBWU1wfEW6x6gX+qPH+gLzGEx+My3wcb67K9Rc02xNQRVn67phusmXm5Yqn4oTP2OW1G5zdQ==

"@types/shelljs@^0.8.0":
version "0.8.1"
Expand Down Expand Up @@ -5530,10 +5530,10 @@ rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.3.3:
estree-walker "^0.5.2"
micromatch "^2.3.11"

rollup@0.67.4:
version "0.67.4"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.67.4.tgz#8ed6b0993337f84ec8a0387f824fa6c197e833ec"
integrity sha512-AVuP73mkb4BBMUmksQ3Jw0jTrBTU1i7rLiUYjFxLZGb3xiFmtVEg40oByphkZAsiL0bJC3hRAJUQos/e5EBd+w==
rollup@0.68.2:
version "0.68.2"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.68.2.tgz#c26afb5d981ca7a1a32f76087dbde9dad4fcc653"
integrity sha512-WgjNCXYv7ZbtStIap1+tz4pd2zwz0XYN//OILwEY6dINIFLVizK1iWdu+ZtUURL/OKnp8Lv2w8FBds8YihzX7Q==
dependencies:
"@types/estree" "0.0.39"
"@types/node" "*"
Expand Down Expand Up @@ -6225,10 +6225,10 @@ tslint-eslint-rules@^5.3.1:
tslib "1.9.0"
tsutils "^3.0.0"

tslint-etc@1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/tslint-etc/-/tslint-etc-1.2.8.tgz#4a1a65c6bea96237168a0b4a2d0d1e0ced0e73fd"
integrity sha512-nQ+Y+nYMhPgUNCE2L6qDAI6Z26qUASiFrLIhSdZWAXiHRiiMUzIK7jMEL7ZFDE8rFWo7mv6jgFkJWUZ3pFwN7A==
tslint-etc@1.2.12:
version "1.2.12"
resolved "https://registry.yarnpkg.com/tslint-etc/-/tslint-etc-1.2.12.tgz#f42895a9808a80ce3f2c21cbd2cd6c415630c699"
integrity sha512-3msQCFNSvfPN1TaowrF+JesUUPJOlbqmo8OhChQGL/H0GddppGSsbYYx6fsq+npGBYLY9OLCHMVQu324DR1axg==
dependencies:
"@phenomnomnominal/tsquery" "^3.0.0"
tslib "^1.8.0"
Expand All @@ -6241,10 +6241,10 @@ tslint-react@3.6.0:
dependencies:
tsutils "^2.13.1"

tslint@5.11.0:
version "5.11.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.11.0.tgz#98f30c02eae3cde7006201e4c33cb08b48581eed"
integrity sha1-mPMMAurjzecAYgHkwzywi0hYHu0=
tslint@5.12.0:
version "5.12.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.12.0.tgz#47f2dba291ed3d580752d109866fb640768fca36"
integrity sha512-CKEcH1MHUBhoV43SA/Jmy1l24HJJgI0eyLbBNSRyFlsQvb9v6Zdq+Nz2vEOH00nC5SUx4SneJ59PZUS/ARcokQ==
dependencies:
babel-code-frame "^6.22.0"
builtin-modules "^1.1.1"
Expand Down

0 comments on commit 614d7a8

Please sign in to comment.