From b1bf44e64724b9c596606365ab5a4fadd276b00d Mon Sep 17 00:00:00 2001 From: mottox2 Date: Mon, 9 Mar 2020 16:34:34 +0900 Subject: [PATCH 1/5] chore(gatsby-cli): Convert init-starter to typescript --- packages/gatsby-cli/src/init-starter.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/gatsby-cli/src/init-starter.ts b/packages/gatsby-cli/src/init-starter.ts index d2004675caa4c..778a9faf9707d 100644 --- a/packages/gatsby-cli/src/init-starter.ts +++ b/packages/gatsby-cli/src/init-starter.ts @@ -1,16 +1,16 @@ -import opn from "better-opn" import { execSync } from "child_process" import execa from "execa" -import { sync as existsSync } from "fs-exists-cached" -import fs from "fs-extra" -import { trackCli, trackError } from "gatsby-telemetry" import hostedGitInfo from "hosted-git-info" -import isValid from "is-valid-path" +import fs from "fs-extra" import sysPath from "path" -import prompts from "prompts" +import report from "./reporter" import url from "url" +import isValid from "is-valid-path" +import { sync as existsSync } from "fs-exists-cached" +import { trackCli, trackError } from "gatsby-telemetry" +import prompts from "prompts" +import opn from "better-opn" -import report from "./reporter" import { getPackageManager, promptPackageManager } from "./util/package-manager" import isTTY from "./util/is-tty" From 5ed9a64606dcc5be9b27aaec866fddc0061dc068 Mon Sep 17 00:00:00 2001 From: Yuki Takemoto Date: Tue, 10 Mar 2020 02:39:39 +0900 Subject: [PATCH 2/5] Update packages/gatsby-cli/src/init-starter.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Michaƫl De Boey --- packages/gatsby-cli/src/init-starter.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/gatsby-cli/src/init-starter.ts b/packages/gatsby-cli/src/init-starter.ts index 778a9faf9707d..c7b9df983d8a5 100644 --- a/packages/gatsby-cli/src/init-starter.ts +++ b/packages/gatsby-cli/src/init-starter.ts @@ -1,17 +1,21 @@ +import opn from "better-opn" import { execSync } from "child_process" import execa from "execa" -import hostedGitInfo from "hosted-git-info" -import fs from "fs-extra" -import sysPath from "path" -import report from "./reporter" -import url from "url" -import isValid from "is-valid-path" import { sync as existsSync } from "fs-exists-cached" +import fs from "fs-extra" import { trackCli, trackError } from "gatsby-telemetry" +import hostedGitInfo from "hosted-git-info" +import isValid from "is-valid-path" +import sysPath from "path" import prompts from "prompts" -import opn from "better-opn" +import url from "url" +<<<<<<< HEAD import { getPackageManager, promptPackageManager } from "./util/package-manager" +======= +import report from "./reporter" +import { getPackageManager, promptPackageManager } from "./util/configstore" +>>>>>>> Update packages/gatsby-cli/src/init-starter.ts import isTTY from "./util/is-tty" const spawnWithArgs = ( From b14fb63b973a793c2ae39bfdefd8a495d799c4ec Mon Sep 17 00:00:00 2001 From: mottox2 Date: Tue, 10 Mar 2020 20:25:43 +0900 Subject: [PATCH 3/5] chore(gatsby-cli): Convert is-tty to typescript --- packages/gatsby-cli/src/init-starter.ts | 6 +----- packages/gatsby-cli/src/util/{is-tty.js => is-tty.ts} | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) rename packages/gatsby-cli/src/util/{is-tty.js => is-tty.ts} (70%) diff --git a/packages/gatsby-cli/src/init-starter.ts b/packages/gatsby-cli/src/init-starter.ts index c7b9df983d8a5..2c332dbcf9d32 100644 --- a/packages/gatsby-cli/src/init-starter.ts +++ b/packages/gatsby-cli/src/init-starter.ts @@ -10,13 +10,9 @@ import sysPath from "path" import prompts from "prompts" import url from "url" -<<<<<<< HEAD import { getPackageManager, promptPackageManager } from "./util/package-manager" -======= import report from "./reporter" -import { getPackageManager, promptPackageManager } from "./util/configstore" ->>>>>>> Update packages/gatsby-cli/src/init-starter.ts -import isTTY from "./util/is-tty" +import { isTTY } from "./util/is-tty" const spawnWithArgs = ( file: string, diff --git a/packages/gatsby-cli/src/util/is-tty.js b/packages/gatsby-cli/src/util/is-tty.ts similarity index 70% rename from packages/gatsby-cli/src/util/is-tty.js rename to packages/gatsby-cli/src/util/is-tty.ts index 48f8aaa3c0dc9..ba94ff581e3e6 100644 --- a/packages/gatsby-cli/src/util/is-tty.js +++ b/packages/gatsby-cli/src/util/is-tty.ts @@ -1,6 +1,6 @@ -const { isCI } = require(`gatsby-core-utils`) +import { isCI } from "gatsby-core-utils" // Some CI pipelines incorrectly report process.stdout.isTTY status, // which causes unwanted lines in the output. An additional check for isCI helps. // @see https://github.com/prettier/prettier/blob/36aeb4ce4f620023c8174e826d7208c0c64f1a0b/src/utils/is-tty.js -module.exports = () => process.stdout.isTTY && !isCI() +export const isTTY = (): boolean => process.stdout.isTTY && !isCI() From 78a7f6efd816188fc19e35a961835559331e8a91 Mon Sep 17 00:00:00 2001 From: mottox2 Date: Wed, 11 Mar 2020 00:47:31 +0900 Subject: [PATCH 4/5] Migrate is-tty test to typescript --- packages/gatsby-cli/src/init-starter.ts | 2 +- .../src/util/__tests__/{is-tty.js => is-tty.ts} | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) rename packages/gatsby-cli/src/util/__tests__/{is-tty.js => is-tty.ts} (83%) diff --git a/packages/gatsby-cli/src/init-starter.ts b/packages/gatsby-cli/src/init-starter.ts index 2c332dbcf9d32..8ed209a001734 100644 --- a/packages/gatsby-cli/src/init-starter.ts +++ b/packages/gatsby-cli/src/init-starter.ts @@ -10,8 +10,8 @@ import sysPath from "path" import prompts from "prompts" import url from "url" -import { getPackageManager, promptPackageManager } from "./util/package-manager" import report from "./reporter" +import { getPackageManager, promptPackageManager } from "./util/package-manager" import { isTTY } from "./util/is-tty" const spawnWithArgs = ( diff --git a/packages/gatsby-cli/src/util/__tests__/is-tty.js b/packages/gatsby-cli/src/util/__tests__/is-tty.ts similarity index 83% rename from packages/gatsby-cli/src/util/__tests__/is-tty.js rename to packages/gatsby-cli/src/util/__tests__/is-tty.ts index 7ea4dfe57710c..a6327a8a61f7b 100644 --- a/packages/gatsby-cli/src/util/__tests__/is-tty.js +++ b/packages/gatsby-cli/src/util/__tests__/is-tty.ts @@ -1,5 +1,5 @@ describe(`isTTY`, () => { - let originalTTY + let originalTTY: boolean beforeEach(() => { jest.resetModules() @@ -14,7 +14,7 @@ describe(`isTTY`, () => { jest.mock(`gatsby-core-utils`, () => { return { isCI: () => false } }) - const isTTY = require(`../is-tty`) + const { isTTY } = require(`../is-tty`) expect(isTTY()).toBe(true) }) @@ -23,7 +23,7 @@ describe(`isTTY`, () => { jest.mock(`gatsby-core-utils`, () => { return { isCI: () => false } }) - const isTTY = require(`../is-tty`) + const { isTTY } = require(`../is-tty`) expect(isTTY()).toBe(false) }) @@ -32,7 +32,7 @@ describe(`isTTY`, () => { jest.mock(`gatsby-core-utils`, () => { return { isCI: () => true } }) - const isTTY = require(`../is-tty`) + const { isTTY } = require(`../is-tty`) expect(isTTY()).toBe(false) }) @@ -41,7 +41,7 @@ describe(`isTTY`, () => { jest.mock(`gatsby-core-utils`, () => { return { isCI: () => true } }) - const isTTY = require(`../is-tty`) + const { isTTY } = require(`../is-tty`) expect(isTTY()).toBe(false) }) }) From 2c356092ce2016560b6aef4b3167bad1c503823e Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Tue, 17 Mar 2020 15:53:22 +0100 Subject: [PATCH 5/5] type some mocks --- packages/gatsby-cli/src/util/__tests__/is-tty.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/gatsby-cli/src/util/__tests__/is-tty.ts b/packages/gatsby-cli/src/util/__tests__/is-tty.ts index a6327a8a61f7b..1cc49180bef78 100644 --- a/packages/gatsby-cli/src/util/__tests__/is-tty.ts +++ b/packages/gatsby-cli/src/util/__tests__/is-tty.ts @@ -12,7 +12,7 @@ describe(`isTTY`, () => { it(`returns true if not on ci & TTY is enabled`, () => { process.stdout.isTTY = true jest.mock(`gatsby-core-utils`, () => { - return { isCI: () => false } + return { isCI: (): boolean => false } }) const { isTTY } = require(`../is-tty`) expect(isTTY()).toBe(true) @@ -21,7 +21,7 @@ describe(`isTTY`, () => { it(`returns false if not on ci & TTY is disabled`, () => { process.stdout.isTTY = false jest.mock(`gatsby-core-utils`, () => { - return { isCI: () => false } + return { isCI: (): boolean => false } }) const { isTTY } = require(`../is-tty`) expect(isTTY()).toBe(false) @@ -30,7 +30,7 @@ describe(`isTTY`, () => { it(`returns false if on ci & TTY is enabled`, () => { process.stdout.isTTY = true jest.mock(`gatsby-core-utils`, () => { - return { isCI: () => true } + return { isCI: (): boolean => true } }) const { isTTY } = require(`../is-tty`) expect(isTTY()).toBe(false) @@ -39,7 +39,7 @@ describe(`isTTY`, () => { it(`returns false if on ci & TTY is disabled`, () => { process.stdout.isTTY = false jest.mock(`gatsby-core-utils`, () => { - return { isCI: () => true } + return { isCI: (): boolean => true } }) const { isTTY } = require(`../is-tty`) expect(isTTY()).toBe(false)