-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(create-gatsby): Improve install (#28318) #28406
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,18 @@ import Enquirer from "enquirer" | |
import cmses from "./cmses.json" | ||
import styles from "./styles.json" | ||
import features from "./features.json" | ||
import { initStarter, getPackageManager } from "./init-starter" | ||
import { initStarter, getPackageManager, gitSetup } from "./init-starter" | ||
import { installPlugins } from "./install-plugins" | ||
import c from "ansi-colors" | ||
import path from "path" | ||
import fs from "fs" | ||
import { plugin } from "./components/plugin" | ||
import { makePluginConfigQuestions } from "./plugin-options-form" | ||
import { center, rule, wrap } from "./components/utils" | ||
import { center, wrap } from "./components/utils" | ||
import { stripIndent } from "common-tags" | ||
import { trackCli } from "./tracking" | ||
import crypto from "crypto" | ||
import { reporter } from "./reporter" | ||
|
||
const sha256 = (str: string): string => | ||
crypto.createHash(`sha256`).update(str).digest(`hex`) | ||
|
@@ -50,6 +51,7 @@ const makeChoices = ( | |
export const validateProjectName = async ( | ||
value: string | ||
): Promise<string | boolean> => { | ||
value = value.trim() | ||
if (INVALID_FILENAMES.test(value)) { | ||
return `The destination "${value}" is not a valid filename. Please try again, avoiding special characters.` | ||
} | ||
|
@@ -138,9 +140,9 @@ export async function run(): Promise<void> { | |
|
||
const { version } = require(`../package.json`) | ||
|
||
console.log(c.grey(`create-gatsby version ${version}`)) | ||
reporter.info(c.grey(`create-gatsby version ${version}`)) | ||
|
||
console.log( | ||
reporter.info( | ||
` | ||
|
||
|
||
|
@@ -150,23 +152,23 @@ ${center(c.blueBright.bold.underline(`Welcome to Gatsby!`))} | |
` | ||
) | ||
|
||
console.log( | ||
reporter.info( | ||
wrap( | ||
`This command will generate a new Gatsby site for you in ${c.bold( | ||
process.cwd() | ||
)} with the setup you select. ${c.white.bold( | ||
`Let's answer some questions:\n` | ||
`Let's answer some questions:\n\n` | ||
)}`, | ||
process.stdout.columns | ||
) | ||
) | ||
console.log(``) | ||
|
||
const enquirer = new Enquirer<IAnswers>() | ||
|
||
enquirer.use(plugin) | ||
|
||
const data = await enquirer.prompt(questions) | ||
data.project = data.project.trim() | ||
|
||
trackCli(`CREATE_GATSBY_SELECT_OPTION`, { | ||
name: `project_name`, | ||
|
@@ -259,7 +261,7 @@ ${center(c.blueBright.bold.underline(`Welcome to Gatsby!`))} | |
|
||
const config = makePluginConfigQuestions(plugins) | ||
if (config.length) { | ||
console.log( | ||
reporter.info( | ||
`\nGreat! A few of the selections you made need to be configured. Please fill in the options for each plugin now:\n` | ||
) | ||
|
||
|
@@ -273,7 +275,7 @@ ${center(c.blueBright.bold.underline(`Welcome to Gatsby!`))} | |
trackCli(`CREATE_GATSBY_SET_PLUGINS_STOP`) | ||
} | ||
|
||
console.log(` | ||
reporter.info(` | ||
|
||
${c.bold(`Thanks! Here's what we'll now do:`)} | ||
|
||
|
@@ -291,42 +293,41 @@ ${c.bold(`Thanks! Here's what we'll now do:`)} | |
if (!confirm) { | ||
trackCli(`CREATE_GATSBY_CANCEL`) | ||
|
||
console.log(`OK, bye!`) | ||
reporter.info(`OK, bye!`) | ||
return | ||
} | ||
|
||
await initStarter(DEFAULT_STARTER, data.project, packages.map(removeKey)) | ||
|
||
console.log( | ||
c.green(c.symbols.check) + ` Created site in ` + c.green(data.project) | ||
) | ||
reporter.success(`Created site in ${c.green(data.project)}`) | ||
|
||
if (plugins.length) { | ||
console.log(c.bold(`${w(`🔌 `)}Installing plugins...`)) | ||
reporter.info(`${w(`🔌 `)}Setting-up plugins...`) | ||
await installPlugins(plugins, pluginConfig, path.resolve(data.project), []) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was merge conflict here due to change from |
||
} | ||
|
||
const pm = await getPackageManager() | ||
await gitSetup(data.project) | ||
|
||
const pm = await getPackageManager() | ||
const runCommand = pm === `npm` ? `npm run` : `yarn` | ||
|
||
console.log( | ||
reporter.info( | ||
stripIndent` | ||
${w(`🎉 `)}Your new Gatsby site ${c.bold( | ||
data.project | ||
)} has been successfully bootstrapped | ||
)} has been successfully created | ||
at ${c.bold(path.resolve(data.project))}. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was merge conflict here due to change from |
||
` | ||
) | ||
console.log(`Start by going to the directory with\n | ||
reporter.info(`Start by going to the directory with\n | ||
${c.magenta(`cd ${data.project}`)} | ||
`) | ||
|
||
console.log(`Start the local development server with\n | ||
reporter.info(`Start the local development server with\n | ||
${c.magenta(`${runCommand} develop`)} | ||
`) | ||
|
||
console.log(`See all commands at\n | ||
reporter.info(`See all commands at\n | ||
${c.blueBright(`https://www.gatsbyjs.com/docs/gatsby-cli/`)} | ||
`) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was merge conflict here due to neighbouring
added by #28324 which is not backported and was merged before this PR