Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-gatsby

Package Overview
Dependencies
Maintainers
16
Versions
350
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-gatsby - npm Package Compare versions

Comparing version 0.0.0-5 to 0.0.0-6

lib/components/input.js

11

lib/cmses.json
{
"none": "No (or I'll add it later)",
"gatsby-source-wordpress-experimental": "WordPress",
"gatsby-source-contentful": "Contentful",
"gatsby-source-datocms": "DatoCMS",
"gatsby-source-sanity": "Sanity",
"gatsby-source-agility": "AgilityCMS"
"gatsby-source-wordpress-experimental": { "message": "WordPress" },
"gatsby-source-contentful": { "message": "Contentful" },
"gatsby-source-sanity": { "message": "Sanity" },
"gatsby-source-shopify": { "message": "Shopify" },
"gatsby-source-prismic-graphql": { "message": "Prismic GraphQL" }
}
{
"gatsby-plugin-google-analytics": "Add the Google Analytics tracking script",
"gatsby-plugin-sitemap": "Add an automatic sitemap",
"gatsby-plugin-mdx": "Add MDX support",
"gatsby-plugin-offline": "Enable offline functionality",
"gatsby-plugin-manifest": "Generate a manifest file"
"gatsby-plugin-google-analytics": { "message": "Add the Google Analytics tracking script" },
"gatsby-plugin-react-helmet": { "message": "Add page metadata", "dependencies": ["react-helmet"] },
"gatsby-plugin-sitemap": { "message": "Add an automatic sitemap" },
"gatsby-plugin-offline": { "message": "Enable offline functionality" },
"gatsby-plugin-manifest": { "message": "Generate a manifest file" },
"gatsby-plugin-mdx": { "message": "Add MDX support", "dependencies": ["@mdx-js/react", "@mdx-js/mdx"] }
}

@@ -16,3 +16,3 @@ "use strict";

exports.run = void 0;
const enquirer_1 = require("enquirer");
const enquirer_1 = __importDefault(require("enquirer"));
const cmses_json_1 = __importDefault(require("./cmses.json"));

@@ -26,3 +26,8 @@ const styles_json_1 = __importDefault(require("./styles.json"));

const fs_1 = __importDefault(require("fs"));
// @ts-ignore
const text_1 = require("./components/text");
// @ts-ignore
const select_1 = require("./components/select");
const plugin_options_form_1 = require("./plugin-options-form");
const utils_1 = require("./components/utils");
// eslint-disable-next-line no-control-regex

@@ -33,11 +38,22 @@ const INVALID_FILENAMES = /[<>:"/\\|?*\u0000-\u001F]/g;

const DEFAULT_STARTER = `https://github.com/ascorbic/gatsby-starter-hello-world.git`;
const makeChoices = (options) => Object.entries(options).map(([name, message]) => {
return { name, message };
});
const makeChoices = (options, multi = false) => {
const entries = Object.entries(options).map(([name, message]) => {
return { name, message: message.message };
});
if (multi) {
return entries;
}
const none = { name: `none`, message: `No (or I'll add it later)` };
const divider = { name: `–`, role: `separator`, message: `–` };
return [none, divider, ...entries];
};
const questions = [
{
type: `input`,
type: `textinput`,
name: `project`,
message: `What would you like to name the folder where your site will be created?`,
hint: path_1.default.basename(process.cwd()),
separator: `/`,
initial: `my-gatsby-site`,
format: (value) => ansi_colors_1.default.cyan(value),
validate: (value) => {

@@ -57,56 +73,66 @@ if (INVALID_FILENAMES.test(value)) {

{
type: `select`,
type: `selectinput`,
name: `cms`,
message: `Will you be using a CMS?`,
hint: `Use arrow keys to move, and enter to select`,
hint: `(Single choice) Arrow keys to move, enter to confirm`,
choices: makeChoices(cmses_json_1.default),
},
{
type: `select`,
type: `selectinput`,
name: `styling`,
message: `Would you like to install a styling system?`,
hint: `Use arrow keys to move, and enter to select`,
hint: `(Single choice) Arrow keys to move, enter to confirm`,
choices: makeChoices(styles_json_1.default),
},
{
type: `multiselect`,
type: `multiselectinput`,
name: `features`,
message: `Would you like to install additional features with other plugins?`,
hint: `Use arrow keys to move, spacebar to select, and enter to confirm your choices`,
choices: makeChoices(features_json_1.default),
hint: `(Multiple choice) Use arrow keys to move, spacebar to select, and enter to confirm your choices`,
choices: makeChoices(features_json_1.default, true),
},
];
function run() {
var _a;
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
const { version } = require(`../package.json`);
console.log(ansi_colors_1.default.grey.italic(`create-gatsby version ${version}`));
console.log(ansi_colors_1.default.grey(`create-gatsby version ${version}`));
console.log(`
${ansi_colors_1.default.blueBright.bold.underline(`Welcome to Gatsby!`)}
${utils_1.center(ansi_colors_1.default.blueBright.bold.underline(`Welcome to Gatsby!`))}
`);
console.log(ansi_colors_1.default.red.italic(`Important: This is currently for testing purposes only`));
console.log(`This command will generate a new Gatsby site for you with the setup you select.`);
console.log(`Let's answer some questions:\n`);
const data = yield enquirer_1.prompt(questions);
console.log(ansi_colors_1.default.red(utils_1.rule()));
console.log(utils_1.center(ansi_colors_1.default.red(`⚠️ This is currently for testing purposes only`)));
console.log(ansi_colors_1.default.red(utils_1.rule()));
console.log(utils_1.wrap(`This command will generate a new Gatsby site for you in ${ansi_colors_1.default.bold(process.cwd())} with the setup you select. ${ansi_colors_1.default.white.bold(`Let's answer some questions:\n`)}`, process.stdout.columns));
console.log(``);
const enquirer = new enquirer_1.default();
enquirer.register(`textinput`, text_1.TextInput);
enquirer.register(`selectinput`, select_1.SelectInput);
enquirer.register(`multiselectinput`, select_1.MultiSelectInput);
const data = yield enquirer.prompt(questions);
const messages = [
`🛠 Create a new Gatsby site in the folder ${ansi_colors_1.default.blueBright(data.project)}`,
`🛠 Create a new Gatsby site in the folder ${ansi_colors_1.default.magenta(data.project)}`,
];
const plugins = [];
const packages = [];
if (data.cms && data.cms !== `none`) {
messages.push(`📚 Install and configure the plugin for ${ansi_colors_1.default.red(cmses_json_1.default[data.cms])}`);
messages.push(`📚 Install and configure the plugin for ${ansi_colors_1.default.magenta(cmses_json_1.default[data.cms].message)}`);
plugins.push(data.cms);
packages.push(data.cms, ...(cmses_json_1.default[data.cms].dependencies || []));
}
if (data.styling && data.styling !== `none`) {
messages.push(`🎨 Get you set up to use ${ansi_colors_1.default.green(styles_json_1.default[data.styling])} for styling your site`);
messages.push(`🎨 Get you set up to use ${ansi_colors_1.default.magenta(styles_json_1.default[data.styling].message)} for styling your site`);
plugins.push(data.styling);
packages.push(data.styling, ...(styles_json_1.default[data.styling].dependencies || []));
}
if ((_a = data.features) === null || _a === void 0 ? void 0 : _a.length) {
messages.push(`🔌 Install ${data.features
.map((feat) => ansi_colors_1.default.magenta(feat))
.join(`, `)}`);
messages.push(`🔌 Install ${(_b = data.features) === null || _b === void 0 ? void 0 : _b.map((feat) => ansi_colors_1.default.magenta(feat)).join(`, `)}`);
plugins.push(...data.features);
const featureDependencies = (_c = data.features) === null || _c === void 0 ? void 0 : _c.map(featureKey => features_json_1.default[featureKey].dependencies || []);
const flattenedDependencies = [].concat.apply([], featureDependencies); // here until we upgrade to node 11 and can use flatMap
packages.push(...data.features, ...flattenedDependencies);
}

@@ -117,3 +143,3 @@ const config = plugin_options_form_1.makePluginConfigQuestions(plugins);

console.log(`\nGreat! A few of the selections you made need to be configured. Please fill in the options for each plugin now:\n`);
pluginConfig = yield enquirer_1.prompt(config);
pluginConfig = yield new enquirer_1.default().prompt(config);
}

@@ -126,3 +152,3 @@ console.log(`

`);
const { confirm } = yield enquirer_1.prompt({
const { confirm } = yield new enquirer_1.default().prompt({
type: `confirm`,

@@ -139,14 +165,22 @@ name: `confirm`,

yield init_starter_1.initStarter(DEFAULT_STARTER, data.project);
console.log(ansi_colors_1.default.green(`✔ `) + ansi_colors_1.default.bold(`Created site in `) + ansi_colors_1.default.green.bold(data.project));
console.log(ansi_colors_1.default.green(`✔ `) + `Created site in ` + ansi_colors_1.default.green(data.project));
if (plugins.length) {
console.log(ansi_colors_1.default.bold(`🔌 Installing plugins...`));
yield install_plugins_1.installPlugins(plugins, pluginConfig, path_1.default.resolve(data.project));
yield install_plugins_1.installPlugins(plugins, pluginConfig, path_1.default.resolve(data.project), packages);
}
console.log(ansi_colors_1.default.bold(`✨ Your new Gatsby site is ready! Start developing it by running:`));
console.log(`✨ Your new Gatsby site ${ansi_colors_1.default.bold(path_1.default.resolve(data.project))} has been successfully bootstrapped at ${ansi_colors_1.default.bold(data.project)}. There you can:\n`);
console.log(`
cd ${data.project}
gatsby develop
Start developing with\n
${ansi_colors_1.default.magenta(`gatsby develop`)}\n
`);
console.log(`
Create a production build with\n
${ansi_colors_1.default.magenta(`gatsby build`)}\n
`);
console.log(`
Head to your new project with\n
${ansi_colors_1.default.magenta(`cd ${data.project}`)}\n
`);
});
}
exports.run = run;

@@ -24,3 +24,3 @@ "use strict";

const stream_filter_1 = __importDefault(require("stream-filter"));
const spin_1 = require("./spin");
const spin_1 = require("./components/spin");
const packageMangerConfigKey = `cli.packageManager`;

@@ -27,0 +27,0 @@ exports.getPackageManager = () => gatsby_core_utils_2.getConfigStore().get(packageMangerConfigKey);

@@ -14,3 +14,3 @@ "use strict";

const reporter_1 = require("./reporter");
function installPlugins(plugins, pluginOptions = {}, rootPath) {
function installPlugins(plugins, pluginOptions = {}, rootPath, packages) {
return __awaiter(this, void 0, void 0, function* () {

@@ -31,5 +31,5 @@ let installPluginCommand;

const { addPlugins } = require(installPluginCommand);
return addPlugins(plugins, pluginOptions, rootPath);
return addPlugins(plugins, pluginOptions, rootPath, packages);
});
}
exports.installPlugins = installPlugins;

@@ -18,3 +18,3 @@ "use strict";

if (key in types) {
return types[key];
return types[key].message;
}

@@ -36,2 +36,5 @@ }

const choices = [];
if (!options) {
return;
}
Object.entries(options).forEach(([name, option]) => {

@@ -38,0 +41,0 @@ var _a, _b, _c, _d;

{
"none": "No (or I'll add it later)",
"gatsby-plugin-postcss": "CSS Modules/PostCSS",
"gatsby-plugin-styled-components": "styled-components",
"gatsby-plugin-emotion": "Emotion",
"gatsby-plugin-sass": "Sass",
"gatsby-plugin-theme-ui": "Theme-UI"
"gatsby-plugin-postcss": { "message": "CSS Modules/PostCSS", "dependencies": ["postcss"] },
"gatsby-plugin-styled-components": { "message": "styled-components", "dependencies": ["styled-components", "babel-plugin-styled-components"] },
"gatsby-plugin-emotion": { "message": "Emotion", "dependencies": ["@emotion/core", "@emotion/styled"] },
"gatsby-plugin-sass": { "message": "Sass", "dependencies": ["node-sass"] },
"gatsby-plugin-theme-ui": {
"message": "Theme-UI",
"dependencies": ["theme-ui"]
}
}
{
"name": "create-gatsby",
"version": "0.0.0-5",
"version": "0.0.0-6",
"main": "lib/index.js",

@@ -16,2 +16,3 @@ "bin": "lib/cli.js",

"@babel/runtime": "^7.12.1",
"ansi-wordwrap": "^1.0.2",
"common-tags": "^1.8.0",

@@ -21,4 +22,5 @@ "enquirer": "^2.3.6",

"fs-extra": "^9.0.1",
"gatsby-core-utils": "^1.3.23",
"gatsby-core-utils": "^1.4.0-next.0",
"stream-filter": "^2.1.0",
"string-length": "^4.0.1",
"terminal-link": "^2.1.1"

@@ -25,0 +27,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc