gatsby-cli
Advanced tools
Comparing version 1.2.0-alpha.22c8a6f1 to 1.2.0-alpha.2e1e7782
168
index.js
@@ -8,14 +8,104 @@ #!/usr/bin/env node | ||
require("core-js/modules/es6.typed.array-buffer"); | ||
require("core-js/modules/es6.typed.int8-array"); | ||
require("core-js/modules/es6.typed.uint8-array"); | ||
require("core-js/modules/es6.typed.uint8-clamped-array"); | ||
require("core-js/modules/es6.typed.int16-array"); | ||
require("core-js/modules/es6.typed.uint16-array"); | ||
require("core-js/modules/es6.typed.int32-array"); | ||
require("core-js/modules/es6.typed.uint32-array"); | ||
require("core-js/modules/es6.typed.float32-array"); | ||
require("core-js/modules/es6.typed.float64-array"); | ||
require("core-js/modules/es6.map"); | ||
require("core-js/modules/es6.set"); | ||
require("core-js/modules/es6.weak-map"); | ||
require("core-js/modules/es6.weak-set"); | ||
require("core-js/modules/es6.reflect.apply"); | ||
require("core-js/modules/es6.reflect.construct"); | ||
require("core-js/modules/es6.reflect.define-property"); | ||
require("core-js/modules/es6.reflect.delete-property"); | ||
require("core-js/modules/es6.reflect.get"); | ||
require("core-js/modules/es6.reflect.get-own-property-descriptor"); | ||
require("core-js/modules/es6.reflect.get-prototype-of"); | ||
require("core-js/modules/es6.reflect.has"); | ||
require("core-js/modules/es6.reflect.is-extensible"); | ||
require("core-js/modules/es6.reflect.own-keys"); | ||
require("core-js/modules/es6.reflect.prevent-extensions"); | ||
require("core-js/modules/es6.reflect.set"); | ||
require("core-js/modules/es6.reflect.set-prototype-of"); | ||
require("core-js/modules/es6.promise"); | ||
require("core-js/modules/es6.symbol"); | ||
require("core-js/modules/es6.function.name"); | ||
require("core-js/modules/es6.regexp.flags"); | ||
require("core-js/modules/es6.regexp.match"); | ||
require("core-js/modules/es6.regexp.replace"); | ||
require("core-js/modules/es6.regexp.split"); | ||
require("core-js/modules/es6.regexp.search"); | ||
require("core-js/modules/es6.array.from"); | ||
require("core-js/modules/es7.array.includes"); | ||
require("core-js/modules/es7.object.values"); | ||
require("core-js/modules/es7.object.entries"); | ||
require("core-js/modules/es7.object.get-own-property-descriptors"); | ||
require("core-js/modules/es7.string.pad-start"); | ||
require("core-js/modules/es7.string.pad-end"); | ||
require("regenerator-runtime/runtime"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const program = require(`commander`); | ||
const packageJson = require(`./package.json`); | ||
const path = require(`path`); | ||
const _ = require(`lodash`); | ||
const resolveCwd = require(`resolve-cwd`); | ||
var program = require(`commander`); | ||
// babel-preset-env doesn't find this import if you | ||
// use require() with backtick strings so use the es6 syntax | ||
var packageJson = require(`./package.json`); | ||
var path = require(`path`); | ||
var _ = require(`lodash`); | ||
var resolveCwd = require(`resolve-cwd`); | ||
program.version(packageJson.version).usage(`[command] [options]`); | ||
let inGatsbySite = false; | ||
let localPackageJSON; | ||
var inGatsbySite = false; | ||
var localPackageJSON = void 0; | ||
try { | ||
@@ -32,8 +122,8 @@ localPackageJSON = require(path.resolve(`./package.json`)); | ||
const defaultHost = `localhost`; | ||
var defaultHost = `localhost`; | ||
const directory = path.resolve(`.`); | ||
const getSiteInfo = () => { | ||
const sitePackageJson = require(path.join(directory, `package.json`)); | ||
const browserslist = sitePackageJson.browserslist || [`> 1%`, `last 2 versions`, `IE >= 9`]; | ||
var directory = path.resolve(`.`); | ||
var getSiteInfo = function getSiteInfo() { | ||
var sitePackageJson = require(path.join(directory, `package.json`)); | ||
var browserslist = sitePackageJson.browserslist || [`> 1%`, `last 2 versions`, `IE >= 9`]; | ||
return { sitePackageJson, browserslist }; | ||
@@ -46,7 +136,11 @@ }; | ||
program.command(`develop`).description(`Start development server. Watches files and rebuilds and hot reloads ` + `if something changes`) // eslint-disable-line max-len | ||
.option(`-H, --host <url>`, `Set host. Defaults to ${defaultHost}`, defaultHost).option(`-p, --port <port>`, `Set port. Defaults to 8000`, `8000`).option(`-o, --open`, `Open the site in your browser for you.`).action(command => { | ||
const developPath = resolveCwd(`gatsby/dist/utils/develop`); | ||
const develop = require(developPath); | ||
const { sitePackageJson, browserslist } = getSiteInfo(); | ||
const p = (0, _extends3.default)({}, command, { | ||
.option(`-H, --host <url>`, `Set host. Defaults to ${defaultHost}`, defaultHost).option(`-p, --port <port>`, `Set port. Defaults to 8000`, `8000`).option(`-o, --open`, `Open the site in your browser for you.`).action(function (command) { | ||
var developPath = resolveCwd(`gatsby/dist/utils/develop`); | ||
var develop = require(developPath); | ||
var _getSiteInfo = getSiteInfo(), | ||
sitePackageJson = _getSiteInfo.sitePackageJson, | ||
browserslist = _getSiteInfo.browserslist; | ||
var p = (0, _extends3.default)({}, command, { | ||
directory, | ||
@@ -59,10 +153,14 @@ sitePackageJson, | ||
program.command(`build`).description(`Build a Gatsby project.`).option(`--prefix-paths`, `Build site with link paths prefixed (set prefix in your config).`).action(command => { | ||
program.command(`build`).description(`Build a Gatsby project.`).option(`--prefix-paths`, `Build site with link paths prefixed (set prefix in your config).`).action(function (command) { | ||
// Set NODE_ENV to 'production' | ||
process.env.NODE_ENV = `production`; | ||
const buildPath = resolveCwd(`gatsby/dist/utils/build`); | ||
const build = require(buildPath); | ||
const { sitePackageJson, browserslist } = getSiteInfo(); | ||
const p = (0, _extends3.default)({}, command, { | ||
var buildPath = resolveCwd(`gatsby/dist/utils/build`); | ||
var build = require(buildPath); | ||
var _getSiteInfo2 = getSiteInfo(), | ||
sitePackageJson = _getSiteInfo2.sitePackageJson, | ||
browserslist = _getSiteInfo2.browserslist; | ||
var p = (0, _extends3.default)({}, command, { | ||
directory, | ||
@@ -72,3 +170,3 @@ sitePackageJson, | ||
}); | ||
build(p).then(() => { | ||
build(p).then(function () { | ||
console.log(`Done building in`, process.uptime(), `seconds`); | ||
@@ -79,7 +177,11 @@ process.exit(); | ||
program.command(`serve`).description(`Serve built site.`).option(`-H, --host <url>`, `Set host. Defaults to ${defaultHost}`, defaultHost).option(`-p, --port <port>`, `Set port. Defaults to 9000`, `9000`).option(`-o, --open`, `Open the site in your browser for you.`).action(command => { | ||
const servePath = resolveCwd(`gatsby/dist/utils/serve`); | ||
const serve = require(servePath); | ||
const { sitePackageJson, browserslist } = getSiteInfo(); | ||
const p = (0, _extends3.default)({}, command, { | ||
program.command(`serve`).description(`Serve built site.`).option(`-H, --host <url>`, `Set host. Defaults to ${defaultHost}`, defaultHost).option(`-p, --port <port>`, `Set port. Defaults to 9000`, `9000`).option(`-o, --open`, `Open the site in your browser for you.`).action(function (command) { | ||
var servePath = resolveCwd(`gatsby/dist/utils/serve`); | ||
var serve = require(servePath); | ||
var _getSiteInfo3 = getSiteInfo(), | ||
sitePackageJson = _getSiteInfo3.sitePackageJson, | ||
browserslist = _getSiteInfo3.browserslist; | ||
var p = (0, _extends3.default)({}, command, { | ||
directory, | ||
@@ -93,8 +195,8 @@ sitePackageJson, | ||
program.command(`new [rootPath] [starter]`).description(`Create new Gatsby project.`).action((rootPath, starter) => { | ||
const newCommand = require(`./new`); | ||
program.command(`new [rootPath] [starter]`).description(`Create new Gatsby project.`).action(function (rootPath, starter) { | ||
var newCommand = require(`./new`); | ||
newCommand(rootPath, starter); | ||
}); | ||
program.on(`--help`, () => { | ||
program.on(`--help`, function () { | ||
console.log(`To show subcommand help: | ||
@@ -107,4 +209,4 @@ | ||
// If the user types an unknown sub-command, just display the help. | ||
const subCmd = process.argv.slice(2, 3)[0]; | ||
let cmds = _.map(program.commands, `_name`); | ||
var subCmd = process.argv.slice(2, 3)[0]; | ||
var cmds = _.map(program.commands, `_name`); | ||
cmds = cmds.concat([`--version`, `-V`]); | ||
@@ -111,0 +213,0 @@ |
@@ -20,3 +20,3 @@ "use strict"; | ||
/* weak */ | ||
let logger = console; | ||
var logger = console; | ||
@@ -28,3 +28,3 @@ // Checks the existence of yarn package | ||
// Returns true if yarn exists, false otherwise | ||
const shouldUseYarn = () => { | ||
var shouldUseYarn = function shouldUseYarn() { | ||
try { | ||
@@ -44,12 +44,12 @@ (0, _child_process.execSync)(`yarnpkg --version`, { stdio: `ignore` }); | ||
// Returns nothing. | ||
const install = (rootPath, callback) => { | ||
const prevDir = process.cwd(); | ||
var install = function install(rootPath, callback) { | ||
var prevDir = process.cwd(); | ||
logger.log(`Installing packages...`); | ||
process.chdir(rootPath); | ||
const installCmd = shouldUseYarn() ? `yarnpkg` : `npm install`; | ||
(0, _child_process.exec)(installCmd, (error, stdout, stderr) => { | ||
var installCmd = shouldUseYarn() ? `yarnpkg` : `npm install`; | ||
(0, _child_process.exec)(installCmd, function (error, stdout, stderr) { | ||
process.chdir(prevDir); | ||
if (stdout) console.log(stdout.toString()); | ||
if (error !== null) { | ||
const msg = stderr.toString(); | ||
var msg = stderr.toString(); | ||
callback(new Error(msg)); | ||
@@ -61,3 +61,5 @@ } | ||
const ignored = path => !/^\.(git|hg)$/.test(_path2.default.basename(path)); | ||
var ignored = function ignored(path) { | ||
return !/^\.(git|hg)$/.test(_path2.default.basename(path)); | ||
}; | ||
@@ -71,5 +73,5 @@ // Copy starter from file system. | ||
// Returns nothing. | ||
const copy = (starterPath, rootPath, callback) => { | ||
const copyDirectory = () => { | ||
_fsExtra2.default.copy(starterPath, rootPath, { filter: ignored }, error => { | ||
var copy = function copy(starterPath, rootPath, callback) { | ||
var copyDirectory = function copyDirectory() { | ||
_fsExtra2.default.copy(starterPath, rootPath, { filter: ignored }, function (error) { | ||
if (error !== null) return callback(new Error(error)); | ||
@@ -84,7 +86,7 @@ logger.log(`Created starter directory layout`); | ||
// 493 = parseInt('755', 8) | ||
_fsExtra2.default.mkdirp(rootPath, { mode: 493 }, error => { | ||
_fsExtra2.default.mkdirp(rootPath, { mode: 493 }, function (error) { | ||
if (error !== null) callback(new Error(error)); | ||
return _fsExtra2.default.exists(starterPath, exists => { | ||
return _fsExtra2.default.exists(starterPath, function (exists) { | ||
if (!exists) { | ||
const chmodError = `starter ${starterPath} doesn't exist`; | ||
var chmodError = `starter ${starterPath} doesn't exist`; | ||
return callback(new Error(chmodError)); | ||
@@ -107,10 +109,10 @@ } | ||
// Returns nothing. | ||
const clone = (hostInfo, rootPath, callback) => { | ||
const url = hostInfo.git({ noCommittish: true }); | ||
const branch = hostInfo.committish ? `-b ${hostInfo.committish}` : ``; | ||
var clone = function clone(hostInfo, rootPath, callback) { | ||
var url = hostInfo.git({ noCommittish: true }); | ||
var branch = hostInfo.committish ? `-b ${hostInfo.committish}` : ``; | ||
logger.log(`Cloning git repo ${url} to ${rootPath}...`); | ||
const cmd = `git clone ${branch} ${url} ${rootPath} --single-branch`; | ||
var cmd = `git clone ${branch} ${url} ${rootPath} --single-branch`; | ||
(0, _child_process.exec)(cmd, (error, stdout, stderr) => { | ||
(0, _child_process.exec)(cmd, function (error, stdout, stderr) { | ||
if (error !== null) { | ||
@@ -120,3 +122,3 @@ return callback(new Error(`Git clone error: ${stderr.toString()}`)); | ||
logger.log(`Created starter directory layout`); | ||
return _fsExtra2.default.remove(_path2.default.join(rootPath, `.git`), removeError => { | ||
return _fsExtra2.default.remove(_path2.default.join(rootPath, `.git`), function (removeError) { | ||
if (error !== null) return callback(new Error(removeError)); | ||
@@ -136,16 +138,21 @@ install(rootPath, callback); | ||
// Returns nothing. | ||
const initStarter = (starter, options = {}) => new Promise((resolve, reject) => { | ||
const callback = (err, value) => err ? reject(err) : resolve(value); | ||
var initStarter = function initStarter(starter) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return new Promise(function (resolve, reject) { | ||
var callback = function callback(err, value) { | ||
return err ? reject(err) : resolve(value); | ||
}; | ||
const cwd = process.cwd(); | ||
const rootPath = options.rootPath || cwd; | ||
if (options.logger) logger = options.logger; | ||
var cwd = process.cwd(); | ||
var rootPath = options.rootPath || cwd; | ||
if (options.logger) logger = options.logger; | ||
if (_fsExtra2.default.existsSync(_path2.default.join(rootPath, `package.json`))) throw new Error(`Directory ${rootPath} is already an npm project`); | ||
if (_fsExtra2.default.existsSync(_path2.default.join(rootPath, `package.json`))) throw new Error(`Directory ${rootPath} is already an npm project`); | ||
const hostedInfo = _hostedGitInfo2.default.fromUrl(starter); | ||
var hostedInfo = _hostedGitInfo2.default.fromUrl(starter); | ||
if (hostedInfo) clone(hostedInfo, rootPath, callback);else copy(starter, rootPath, callback); | ||
}); | ||
if (hostedInfo) clone(hostedInfo, rootPath, callback);else copy(starter, rootPath, callback); | ||
}); | ||
}; | ||
module.exports = initStarter; |
12
new.js
"use strict"; | ||
/* weak */ | ||
const logger = require(`tracer`).colorConsole(); | ||
var logger = require(`tracer`).colorConsole(); | ||
const initStarter = require(`./init-starter`); | ||
var initStarter = require(`./init-starter`); | ||
module.exports = (rootPath, starter = `gatsbyjs/gatsby-starter-default`) => { | ||
initStarter(starter, { rootPath, logger }).catch(error => logger.error(error)); | ||
module.exports = function (rootPath) { | ||
var starter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : `gatsbyjs/gatsby-starter-default`; | ||
initStarter(starter, { rootPath, logger }).catch(function (error) { | ||
return logger.error(error); | ||
}); | ||
}; |
{ | ||
"name": "gatsby-cli", | ||
"description": "Gatsby command-line interface for creating new sites and running Gatsby commands", | ||
"version": "1.2.0-alpha.22c8a6f1", | ||
"version": "1.2.0-alpha.2e1e7782", | ||
"author": "Kyle Mathews <mathews.kyle@gmail.com>", | ||
@@ -10,3 +10,3 @@ "bin": { | ||
"dependencies": { | ||
"babel-runtime": "^6.25.0", | ||
"babel-runtime": "^6.26.0", | ||
"commander": "^2.11.0", | ||
@@ -21,3 +21,4 @@ "core-js": "^2.5.0", | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1" | ||
"babel-cli": "^6.26.0", | ||
"cross-env": "^5.0.5" | ||
}, | ||
@@ -31,4 +32,5 @@ "keywords": [ | ||
"build": "babel src --out-dir . --ignore __tests__", | ||
"watch": "babel -w src --out-dir . --ignore __tests__" | ||
"watch": "babel -w src --out-dir . --ignore __tests__", | ||
"prepublish": "cross-env NODE_ENV=production npm run build" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
25
18593
2
7
403
2
Updatedbabel-runtime@^6.26.0