From 4b511c47f0654b85fc54812ee5e2b8696119b0df Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Tue, 19 Dec 2017 18:00:31 +0100 Subject: [PATCH] Start on some easy TS conversion --- lib/config.ts | 2 +- lib/utils/messages.coffee | 22 ------------ lib/utils/messages.ts | 22 ++++++++++++ .../{validation.coffee => validation.ts} | 36 +++++++++++-------- tsconfig.json | 1 + typings/@resin-valid-email.d.ts | 1 + typings/resin-cli-errors.d.ts | 1 + typings/resin-cli-form.d.ts | 1 + typings/resin-cli-visuals.d.ts | 1 + 9 files changed, 49 insertions(+), 38 deletions(-) delete mode 100644 lib/utils/messages.coffee create mode 100644 lib/utils/messages.ts rename lib/utils/{validation.coffee => validation.ts} (52%) create mode 100644 typings/@resin-valid-email.d.ts create mode 100644 typings/resin-cli-errors.d.ts create mode 100644 typings/resin-cli-form.d.ts create mode 100644 typings/resin-cli-visuals.d.ts diff --git a/lib/config.ts b/lib/config.ts index 83351520..e2ae8f2d 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -1 +1 @@ -exports.sentryDsn = 'https://56d2a46124614b01b0f4086897e96110:6e175465accc41b595a96947155f61fb@sentry.io/149239' +exports.sentryDsn = 'https://56d2a46124614b01b0f4086897e96110:6e175465accc41b595a96947155f61fb@sentry.io/149239'; diff --git a/lib/utils/messages.coffee b/lib/utils/messages.coffee deleted file mode 100644 index ef0b1785..00000000 --- a/lib/utils/messages.coffee +++ /dev/null @@ -1,22 +0,0 @@ -exports.reachingOut = ''' - If you need help, or just want to say hi, don't hesitate in reaching out at: - - GitHub: https://github.com/resin-io/resin-cli/issues/new - Forums: https://forums.resin.io -''' - -exports.getHelp = ''' - If you need help, don't hesitate in contacting us at: - - GitHub: https://github.com/resin-io/resin-cli/issues/new - Forums: https://forums.resin.io -''' - -exports.resinAsciiArt = ''' - ______ _ _ - | ___ \\ (_) (_) - | |_/ /___ ___ _ _ __ _ ___ - | // _ \\/ __| | '_ \\ | |/ _ \\ - | |\\ \\ __/\\__ \\ | | | |_| | (_) | - \\_| \\_\\___||___/_|_| |_(_)_|\\___/ -''' diff --git a/lib/utils/messages.ts b/lib/utils/messages.ts new file mode 100644 index 00000000..113fd7ae --- /dev/null +++ b/lib/utils/messages.ts @@ -0,0 +1,22 @@ +export const reachingOut = `\ +If you need help, or just want to say hi, don't hesitate in reaching out at: + + GitHub: https://github.com/resin-io/resin-cli/issues/new + Forums: https://forums.resin.io\ +`; + +export const getHelp = `\ +If you need help, don't hesitate in contacting us at: + + GitHub: https://github.com/resin-io/resin-cli/issues/new + Forums: https://forums.resin.io\ +`; + +export const resinAsciiArt = `\ +______ _ _ +| ___ \\ (_) (_) +| |_/ /___ ___ _ _ __ _ ___ +| // _ \\/ __| | '_ \\ | |/ _ \\ +| |\\ \\ __/\\__ \\ | | | |_| | (_) | +\\_| \\_\\___||___/_|_| |_(_)_|\\___/\ +`; diff --git a/lib/utils/validation.coffee b/lib/utils/validation.ts similarity index 52% rename from lib/utils/validation.coffee rename to lib/utils/validation.ts index 2901a982..a16db94e 100644 --- a/lib/utils/validation.coffee +++ b/lib/utils/validation.ts @@ -1,4 +1,4 @@ -### +/* Copyright 2016-2017 Resin.io Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,24 +12,30 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -### +*/ -validEmail = require('@resin.io/valid-email') +import validEmail = require('@resin.io/valid-email'); -exports.validateEmail = (input) -> - if not validEmail(input) - return 'Email is not valid' +exports.validateEmail = function(input: string) { + if (!validEmail(input)) { + return 'Email is not valid'; + } - return true + return true; +}; -exports.validatePassword = (input) -> - if input.length < 8 - return 'Password should be 8 characters long' +exports.validatePassword = function(input: string) { + if (input.length < 8) { + return 'Password should be 8 characters long'; + } - return true + return true; +}; -exports.validateApplicationName = (input) -> - if input.length < 4 - return 'The application name should be at least 4 characters' +exports.validateApplicationName = function(input: string) { + if (input.length < 4) { + return 'The application name should be at least 4 characters'; + } - return true + return true; +}; diff --git a/tsconfig.json b/tsconfig.json index fc436833..bb840ae9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "sourceMap": true }, "include": [ + "./typings/*.d.ts", "./lib/**/*.ts" ] } diff --git a/typings/@resin-valid-email.d.ts b/typings/@resin-valid-email.d.ts new file mode 100644 index 00000000..7d9183ee --- /dev/null +++ b/typings/@resin-valid-email.d.ts @@ -0,0 +1 @@ +declare module '@resin.io/valid-email'; diff --git a/typings/resin-cli-errors.d.ts b/typings/resin-cli-errors.d.ts new file mode 100644 index 00000000..b62af69f --- /dev/null +++ b/typings/resin-cli-errors.d.ts @@ -0,0 +1 @@ +declare module 'resin-cli-errors'; diff --git a/typings/resin-cli-form.d.ts b/typings/resin-cli-form.d.ts new file mode 100644 index 00000000..073592bd --- /dev/null +++ b/typings/resin-cli-form.d.ts @@ -0,0 +1 @@ +declare module 'resin-cli-form'; diff --git a/typings/resin-cli-visuals.d.ts b/typings/resin-cli-visuals.d.ts new file mode 100644 index 00000000..f1b2e48f --- /dev/null +++ b/typings/resin-cli-visuals.d.ts @@ -0,0 +1 @@ +declare module 'resin-cli-visuals';