From 2cbcb7fd8105665a7de0d5a41cb3bf5f863dc85d Mon Sep 17 00:00:00 2001 From: Derek Rushforth Date: Tue, 21 May 2019 10:01:44 -0700 Subject: [PATCH] Use untildify package and enable esModuleInterop Also adjusts imports since esModuleInterop is enabled --- package-lock.json | 5 +++++ package.json | 1 + src/commands/email/raw.ts | 2 +- src/commands/email/template.ts | 2 +- src/commands/servers/list.ts | 2 +- src/commands/templates/pull.ts | 5 +++-- src/commands/templates/push.ts | 5 +++-- src/utils.ts | 9 --------- test/integration/email.template.test.ts | 2 +- test/integration/email.test.ts | 2 +- test/integration/general.test.ts | 2 +- test/integration/servers.test.ts | 2 +- test/integration/shared.ts | 2 +- test/integration/templates.pull.test.ts | 2 +- test/integration/templates.push.test.ts | 2 +- tsconfig.json | 3 ++- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index b090ec5..27bbc85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2153,6 +2153,11 @@ "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" }, + "untildify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", + "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==" + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", diff --git a/package.json b/package.json index f9f3c01..d92cd7e 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "postmark": "^2.2.4", "request": "^2.88.0", "table": "^5.2.0", + "untildify": "^4.0.0", "yargonaut": "^1.1.4", "yargs": "^13.2.4" }, diff --git a/src/commands/email/raw.ts b/src/commands/email/raw.ts index 9830f22..727932a 100644 --- a/src/commands/email/raw.ts +++ b/src/commands/email/raw.ts @@ -1,4 +1,4 @@ -import * as ora from 'ora' +import ora from 'ora' import { ServerClient } from 'postmark' import { log, validateToken } from '../../utils' diff --git a/src/commands/email/template.ts b/src/commands/email/template.ts index e0fe4ef..b8171bf 100644 --- a/src/commands/email/template.ts +++ b/src/commands/email/template.ts @@ -1,4 +1,4 @@ -import * as ora from 'ora' +import ora from 'ora' import { ServerClient } from 'postmark' import { log, validateToken } from '../../utils' diff --git a/src/commands/servers/list.ts b/src/commands/servers/list.ts index aedb7ce..125fd49 100644 --- a/src/commands/servers/list.ts +++ b/src/commands/servers/list.ts @@ -1,4 +1,4 @@ -import * as ora from 'ora' +import ora from 'ora' import { AccountClient } from 'postmark' import { log, validateToken } from '../../utils' diff --git a/src/commands/templates/pull.ts b/src/commands/templates/pull.ts index 2c5d14d..d7d3a81 100644 --- a/src/commands/templates/pull.ts +++ b/src/commands/templates/pull.ts @@ -1,7 +1,8 @@ import { join } from 'path' import { outputFileSync, existsSync, ensureDirSync } from 'fs-extra' import { prompt } from 'inquirer' -import * as ora from 'ora' +import ora from 'ora' +import untildify from 'untildify' import { ServerClient } from 'postmark' import { @@ -9,7 +10,7 @@ import { Template, TemplateListOptions, } from '../../types' -import { log, validateToken, pluralize, untildify } from '../../utils' +import { log, validateToken, pluralize } from '../../utils' interface Types { serverToken: string diff --git a/src/commands/templates/push.ts b/src/commands/templates/push.ts index f073c24..70d6dec 100644 --- a/src/commands/templates/push.ts +++ b/src/commands/templates/push.ts @@ -1,9 +1,10 @@ import chalk from 'chalk' -import * as ora from 'ora' +import ora from 'ora' import { join } from 'path' import { find } from 'lodash' import { prompt } from 'inquirer' import { table, getBorderCharacters } from 'table' +import untildify from 'untildify' import { readJsonSync, readFileSync, @@ -18,7 +19,7 @@ import { TemplatePushResults, TemplatePushReview, } from '../../types' -import { pluralize, untildify, log, validateToken } from '../../utils' +import { pluralize, log, validateToken } from '../../utils' interface Types { serverToken: string diff --git a/src/utils.ts b/src/utils.ts index 540c097..fa82b1d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,4 @@ import { Argv } from 'yargs' -import { homedir } from 'os' import chalk from 'chalk' import { prompt } from 'inquirer' @@ -14,14 +13,6 @@ export const cmd = (name: string, desc: string) => ({ builder: (yargs: Argv) => yargs.commandDir(`commands/${name}`), }) -/** - * Converts tildy paths to absolute paths. - * Take from https://github.com/sindresorhus/untildify - * @returns string containing resolved home directory - */ -export const untildify = (input: string) => - homedir() ? input.replace(/^~(?=$|\/|\\)/, homedir()) : input - /** * Convert a string to compatible template alias * @returns the formatted string diff --git a/test/integration/email.template.test.ts b/test/integration/email.template.test.ts index 6885132..5202209 100644 --- a/test/integration/email.template.test.ts +++ b/test/integration/email.template.test.ts @@ -1,6 +1,6 @@ import {expect} from "chai"; import "mocha"; -import * as execa from 'execa' +import execa from 'execa' import {serverToken, fromAddress, toAddress, CLICommand} from "./shared"; import * as postmark from 'postmark'; diff --git a/test/integration/email.test.ts b/test/integration/email.test.ts index e0a391a..8ed816f 100644 --- a/test/integration/email.test.ts +++ b/test/integration/email.test.ts @@ -1,6 +1,6 @@ import {expect} from "chai"; import "mocha"; -import * as execa from 'execa' +import execa from 'execa' import {serverToken, fromAddress, toAddress, CLICommand} from "./shared"; describe("Email send command", () => { diff --git a/test/integration/general.test.ts b/test/integration/general.test.ts index aa9d905..9bc3529 100644 --- a/test/integration/general.test.ts +++ b/test/integration/general.test.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; import "mocha"; -import * as execa from 'execa' +import execa from 'execa' import {CLICommand, packageJson} from "./shared"; describe("Default command", () => { diff --git a/test/integration/servers.test.ts b/test/integration/servers.test.ts index eca79f6..a009219 100644 --- a/test/integration/servers.test.ts +++ b/test/integration/servers.test.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; import "mocha"; -import * as execa from 'execa' +import execa from 'execa' import {accountToken, CLICommand} from "./shared"; diff --git a/test/integration/shared.ts b/test/integration/shared.ts index abacb3c..522db50 100644 --- a/test/integration/shared.ts +++ b/test/integration/shared.ts @@ -1,4 +1,4 @@ -import * as nconf from "nconf"; +import nconf from "nconf"; export const testingKeys = nconf.env().file({ file: __dirname + "/../config/testing_keys.json" }); export const accountToken: string = testingKeys.get("ACCOUNT_TOKEN"); diff --git a/test/integration/templates.pull.test.ts b/test/integration/templates.pull.test.ts index 893eea5..b65ad36 100644 --- a/test/integration/templates.pull.test.ts +++ b/test/integration/templates.pull.test.ts @@ -1,6 +1,6 @@ import {expect} from "chai"; import "mocha"; -import * as execa from 'execa' +import execa from 'execa' import * as fs from 'fs-extra'; const dirTree = require("directory-tree"); diff --git a/test/integration/templates.push.test.ts b/test/integration/templates.push.test.ts index 62eeeae..1ca773a 100644 --- a/test/integration/templates.push.test.ts +++ b/test/integration/templates.push.test.ts @@ -1,6 +1,6 @@ import {expect} from "chai"; import "mocha"; -import * as execa from 'execa' +import execa from 'execa' import * as fs from 'fs-extra'; import {DirectoryTree} from "directory-tree"; diff --git a/tsconfig.json b/tsconfig.json index fb0863e..5321ef3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,8 @@ "noImplicitThis": true, "lib": ["es5", "es2017", "dom"], "declaration": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "esModuleInterop": true }, "include": ["src/**/*"], "exclude": ["test/**/*"]