Skip to content

Commit

Permalink
fix(create-gatsby): Disable emojis on Windows (#28039)
Browse files Browse the repository at this point in the history
* No emojis for windows 😢

* v0.0.0-9
  • Loading branch information
ascorbic committed Nov 13, 2020
1 parent d5807ac commit 5fbda3c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 38 deletions.
5 changes: 3 additions & 2 deletions packages/create-gatsby/package.json
@@ -1,6 +1,6 @@
{
"name": "create-gatsby",
"version": "0.0.0-8",
"version": "0.0.0-9",
"main": "lib/index.js",
"bin": "cli.js",
"license": "MIT",
Expand Down Expand Up @@ -36,6 +36,7 @@
"stream-filter": "^2.1.0",
"string-length": "^4.0.1",
"terminal-link": "^2.1.1",
"tiny-spin": "^1.0.2",
"typescript": "^4.0.5"
},
"repository": {
Expand All @@ -44,4 +45,4 @@
"directory": "packages/create-gatsby"
},
"author": "Matt Kane <matt@gatsbyjs.com>"
}
}
21 changes: 0 additions & 21 deletions packages/create-gatsby/src/components/spin.ts

This file was deleted.

29 changes: 21 additions & 8 deletions packages/create-gatsby/src/index.ts
Expand Up @@ -12,6 +12,11 @@ import { makePluginConfigQuestions } from "./plugin-options-form"
import { center, rule, wrap } from "./components/utils"
import { stripIndent } from "common-tags"

/**
* Hide string on windows (for emojis)
*/
const w = (input: string): string => (process.platform === `win32` ? `` : input)

// eslint-disable-next-line no-control-regex
const INVALID_FILENAMES = /[<>:"/\\|?*\u0000-\u001F]/g
const INVALID_WINDOWS = /^(con|prn|aux|nul|com\d|lpt\d)$/i
Expand Down Expand Up @@ -137,7 +142,11 @@ ${center(c.blueBright.bold.underline(`Welcome to Gatsby!`))}
`
)
console.log(c.red(rule()))
console.log(center(c.red(`⚠️ This is currently for testing purposes only`)))
console.log(
center(
c.red(`${c.symbols.warning} This is currently for testing purposes only`)
)
)
console.log(c.red(rule()))

console.log(
Expand All @@ -159,7 +168,9 @@ ${center(c.blueBright.bold.underline(`Welcome to Gatsby!`))}
const data = await enquirer.prompt(questions)

const messages: Array<string> = [
`🛠 Create a new Gatsby site in the folder ${c.magenta(data.project)}`,
`${w(`🛠 `)}Create a new Gatsby site in the folder ${c.magenta(
data.project
)}`,
]

const plugins: Array<string> = []
Expand All @@ -168,7 +179,7 @@ ${center(c.blueBright.bold.underline(`Welcome to Gatsby!`))}

if (data.cms && data.cms !== `none`) {
messages.push(
`📚 Install and configure the plugin for ${c.magenta(
`${w(`📚 `)}Install and configure the plugin for ${c.magenta(
cmses[data.cms].message
)}`
)
Expand All @@ -184,7 +195,7 @@ ${center(c.blueBright.bold.underline(`Welcome to Gatsby!`))}

if (data.styling && data.styling !== `none`) {
messages.push(
`🎨 Get you set up to use ${c.magenta(
`${w(`🎨 `)}Get you set up to use ${c.magenta(
styles[data.styling].message
)} for styling your site`
)
Expand All @@ -201,7 +212,7 @@ ${center(c.blueBright.bold.underline(`Welcome to Gatsby!`))}

if (data.features?.length) {
messages.push(
`🔌 Install ${data.features
`${w(`🔌 `)}Install ${data.features
?.map((feat: string) => c.magenta(feat))
.join(`, `)}`
)
Expand Down Expand Up @@ -261,10 +272,12 @@ ${c.bold(`Thanks! Here's what we'll now do:`)}

await initStarter(DEFAULT_STARTER, data.project, packages.map(removeKey))

console.log(c.green(`✔ `) + `Created site in ` + c.green(data.project))
console.log(
c.green(c.symbols.check) + ` Created site in ` + c.green(data.project)
)

if (plugins.length) {
console.log(c.bold(`🔌 Installing plugins...`))
console.log(c.bold(`${w(`🔌 `)}Installing plugins...`))
await installPlugins(plugins, pluginConfig, path.resolve(data.project), [])
}

Expand All @@ -274,7 +287,7 @@ ${c.bold(`Thanks! Here's what we'll now do:`)}

console.log(
stripIndent`
🎉 Your new Gatsby site ${c.bold(
${w(`🎉 `)}Your new Gatsby site ${c.bold(
data.project
)} has been successfully bootstrapped
at ${c.bold(path.resolve(data.project))}.
Expand Down
2 changes: 1 addition & 1 deletion packages/create-gatsby/src/init-starter.ts
Expand Up @@ -4,7 +4,7 @@ import fs from "fs-extra"
import path from "path"
import { reporter } from "./reporter"
import filterStream from "stream-filter"
import { spin } from "./components/spin"
import { spin } from "tiny-spin"
import { getConfigStore } from "./get-config-store"
type PackageManager = "yarn" | "npm"

Expand Down
6 changes: 4 additions & 2 deletions packages/create-gatsby/src/reporter.ts
Expand Up @@ -4,8 +4,10 @@ export const reporter = {
info: (message: string): void => console.log(message),
verbose: (message: string): void => console.log(message),
log: (message: string): void => console.log(message),
success: (message: string): void => console.log(c.green(`✔ `) + message),
error: (message: string): void => console.error(c.red(`✘ `) + message),
success: (message: string): void =>
console.log(c.green(c.symbols.check + ` `) + message),
error: (message: string): void =>
console.error(c.red(c.symbols.cross + ` `) + message),
panic: (message: string): void => {
console.error(message)
process.exit(1)
Expand Down
15 changes: 11 additions & 4 deletions yarn.lock
Expand Up @@ -974,6 +974,8 @@
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.10.4.tgz#8f2682bcdcef9ed327e1b0861585d7013f8a54dd"
integrity sha512-hGsw1O6Rew1fkFbDImZIEqA8GoidwTAilwCyWqLBM9f+e/u/sQMQu7uX6dyokfOayRuuVfKOW4O7HvaBWM+JlQ==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-transform-runtime@^7.11.5":
version "7.11.5"
Expand Down Expand Up @@ -11197,10 +11199,10 @@ gatsby-design-tokens@^2.0.2:
dependencies:
hex2rgba "^0.0.1"

gatsby-interface@^0.0.231:
version "0.0.231"
resolved "https://registry.yarnpkg.com/gatsby-interface/-/gatsby-interface-0.0.231.tgz#26f22c52423aee85641923e966e786dbacc17508"
integrity sha512-PCIfWVl8QfNuvcYYzNy1ZZGpK3oFn7QQlcCpoB/sjCciYxWRv7PEvjyGUD3Hiv1lZxJPCDjHY6TSIG8xTaVacQ==
gatsby-interface@^0.0.225:
version "0.0.225"
resolved "https://registry.yarnpkg.com/gatsby-interface/-/gatsby-interface-0.0.225.tgz#f2962d8f2e40163ff1bf908f3083ef634a3f4730"
integrity sha512-pJtp9uRSQL8OQCIQeADLOhVqMi2zRSHV6cwo3DwlVvwV264LffCirk1oYoJxldMbIyf0TEx3ouvoRWSIeq/8zw==
dependencies:
"@mdx-js/react" "^1.5.2"
"@reach/alert" "0.10.3"
Expand Down Expand Up @@ -24145,6 +24147,11 @@ tiny-lr@^1.1.0:
object-assign "^4.1.0"
qs "^6.4.0"

tiny-spin@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/tiny-spin/-/tiny-spin-1.0.2.tgz#a30ab6ef3b0b534fef9becc99874b49fb4115d23"
integrity sha512-w+LQXNFIrts+pOjuf1/UivYCd4znPiH/c5X8500Qv6n7FpUDaaB5Q1JSuZN3MIj65qQHzoXcKT9QAz3Tg/djFQ==

tiny-warning@^1.0.0, tiny-warning@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
Expand Down

0 comments on commit 5fbda3c

Please sign in to comment.