Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
joeworkman committed Nov 2, 2021
2 parents 5df601f + efd225e commit b2620b3
Show file tree
Hide file tree
Showing 14 changed files with 3,339 additions and 115 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
test
npm-debug.log
*.swp
package-lock.json
5 changes: 1 addition & 4 deletions bin/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ if (typeof cmd.args[0] === 'undefined') {
else {
foundation.help();
}
}

// Arguments given
else {
} else {
// If the command typed in doesn't exist, show the help screen
if (typeof foundation[cmd.args[0]] == 'undefined') {
foundation.help();
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var helpText = {
'',
'To learn more about a specific command, type ' + 'foundation help <command>'.cyan,
'',
'Need more help? Ask a question on the Foundation Forum: ' + 'foundation.discourse.group'.cyan
'Need more help? Ask a question on the Foundation Forum: ' + 'https://github.com/foundation/foundation-sites/discussions'.cyan
],
'new': [
'Usage:',
Expand All @@ -29,7 +29,7 @@ var helpText = {
'Creates a new Foundation project.',
'Run the command without any flags to get an interactive setup prompt.',
'You can also manually supply the framework and folder name using the ' + '--framework'.cyan + ' and ' + '--directory'.cyan + ' flags.',
' If creating a ' + 'sites'.cyan + ' project, add the ' + '--template'.cyan + ' flag as well. The value can be ' + 'basic'.cyan + ' or ' + 'zurb'.cyan + '.'
' If creating a ' + 'sites'.cyan + ' project, add the ' + '--template'.cyan + ' flag as well. The value can be ' + 'basic'.cyan + ' or ' + 'panini'.cyan + '.'
],
'update': [
'Usage:',
Expand Down
54 changes: 9 additions & 45 deletions lib/commands/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
var async = require('async');
var bower = require('bower');
var colors = require('colors');
var exec = require('child_process').exec;
var fs = require('fs');
var inquirer = require('inquirer');
Expand All @@ -10,22 +8,21 @@ var path = require('path');
var rimraf = require('rimraf');
var which = require('which');
var util = require('../util');
var EventEmitter = require("events").EventEmitter;
var format = require('util').format;
// var EventEmitter = require("events").EventEmitter;

var repositories = {
sites: {
basic: 'https://github.com/foundation/foundation-sites-template.git',
zurb: 'https://github.com/foundation/foundation-zurb-template.git'
panini: 'https://github.com/foundation/foundation-zurb-template.git'
},
apps: 'https://github.com/zurb/foundation-apps-template.git',
emails: 'https://github.com/foundation/foundation-emails-template.git'
}

module.exports = function(args, options, callback, ee) {
var projectName, projectFolder, framework, template, messages, directory;
var tasks = [
preflight, prompt, gitClone, folderSetup, npmInstall, bowerInstall
preflight, prompt, gitClone, folderSetup, npmInstall
];

// Each function below is executed in order
Expand All @@ -49,7 +46,7 @@ module.exports = function(args, options, callback, ee) {

// 2. Find out what the user wants to do
function prompt(cb) {
inquirer.prompt(util.questions(options), function(answers) {
inquirer.prompt(util.questions(options)).then(function(answers) {
// The variables we need either came from the prompts, or the console arguments
projectName = answers.directory || options.directory;
framework = answers.framework || options.framework;
Expand All @@ -75,18 +72,16 @@ module.exports = function(args, options, callback, ee) {

// [TODO] Change to spawn and check for errors on stderr
if (repositories[framework] === undefined) {
console.log("error!".red + "\nFramework " + framework.cyan + " unknown.");
process.exit(1);
console.log("error!".red + "\nFramework " + framework.cyan + " unknown.");
process.exit(1);
}

exec(cmd, function(err) {
if (err instanceof Error) {
console.log(messages.gitCloneError);
process.exit(1);
}

process.chdir(projectFolder);

cb();
});

Expand All @@ -100,53 +95,22 @@ module.exports = function(args, options, callback, ee) {
rimraf('.git', function() {});
console.log(messages.installingDependencies);
cb();

// if (options.edge) {
// util.changeVersion(directory, 'foundation-'+framework, 'master', cb);
// }
// else if (options.version) {
// util.changeVersion(directory, 'foundation-'+framework, options.version, cb);
// }
// else {
// cb();
// }
}

// 5. Install Node dependencies
function npmInstall(cb) {
npm.load({ prefix: projectFolder, loglevel: 'error', loaded: false }, function(err) {
npm.load(function(err) {
npm.commands.install([], function(err, data) {
if (options.debug && err) console.log(err);
var success = err === null;
console.log(ee);
if(success && typeof(ee) !== 'undefined') ee.emit("npmInstallSuccess", projectName);
else if(typeof(ee) !== 'undefined') ee.emit("npmInstallFailure", projectName);
cb(null, success);
});
});
}

// 6. Install Bower dependencies
function bowerInstall(cb) {
// Only run "bower install" if a bower.json is present
if (!fs.existsSync('bower.json')) {
cb(null, true)
}
else {
bower.commands.install(undefined, undefined, {
cwd: process.cwd(), silent: true, quiet: true, production: true })
.on('err', function(err) {
if (typeof ee !== 'undefined')
ee.emit("bowerInstallFailure", projectName);
cb(null, false);
})
.on('end', function(data) {
if (typeof ee !== 'undefined')
ee.emit("bowerInstallSuccess", projectName);
cb(null, true);
});
}
}

// 7. Finish the process with a status report
function finish(err, results) {
// Indexes 4 and 5 of results are the npm/Bower statuses
Expand Down Expand Up @@ -175,7 +139,7 @@ module.exports = function(args, options, callback, ee) {
else
console.log(messages.installFailFinal);

if (typeof(callback)!=='undefined') callback();
if (typeof callback === 'function') callback();
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function(args, options) {
process.exit(0);
}

npm.load({ prefix: process.cwd(), loaded: false }, function(err) {
npm.load(function(err) {
npm.commands.start.apply(this, []);
});
}
4 changes: 2 additions & 2 deletions lib/util/assert-installable-repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module.exports = function assertInstallableRepo(callback) {
choices: [{name: 'Yes', value: 'y'}, {name: 'No', value: 'n'}]};
for(var i = 0; i < paths.length; i++) {
if(!fs.existsSync(paths[i])) {
console.log("You don't appear to be in a ZURB stack project, so we can't automatically install building blocks");
inquirer.prompt(question, function(answer) {
console.log("You don't appear to be in a Foundation project, so we can't automatically install building blocks");
inquirer.prompt(question).then(function(answer) {
if(answer.zip === 'y') {
callback('zip');
} else {
Expand Down
21 changes: 0 additions & 21 deletions lib/util/changeVersion.js

This file was deleted.

10 changes: 0 additions & 10 deletions lib/util/copySettings.js

This file was deleted.

2 changes: 0 additions & 2 deletions lib/util/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module.exports = {
changeVersion: require('./changeVersion'),
copySettings: require('./copySettings'),
mascot: require('./mascot'),
messages: require('./messages'),
questions: require('./questions')
Expand Down
4 changes: 2 additions & 2 deletions lib/util/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var colors = require('colors');
module.exports = function(projectName,messageFramework,messageTemplate) {
return {
helloYeti: [
'Thanks for using ZURB Foundation for %s!',
'Thanks for using Foundation for %s!',
'-------------------------------------------',
'Let\'s set up a new project.',
'It shouldn\'t take more than a minute.'
Expand All @@ -16,7 +16,7 @@ module.exports = function(projectName,messageFramework,messageTemplate) {
installSuccess: "\nYou're all set!\n".cyan,
installFail: "\nThere were some problems during the installation.\n".cyan,
npmSuccess: " \u2713 Node modules installed.".green,
npmFail: " \u2717 Node modules not installed.".red + " Try running " + "npm install".cyan + " manually.",
npmFail: " \u2717 Node modules not installed.".red + " Try running " + "yarn install".cyan + " manually.",
bowerSuccess: " \u2713 Bower components installed.".green,
bowerFail: " \u2717 Bower components not installed.".red + " Try running " + "bower install".cyan + " manually.",
installSuccessFinal: "\nNow run " + "foundation watch ".cyan + "while inside the " + projectName.cyan + " folder.\n",
Expand Down
7 changes: 2 additions & 5 deletions lib/util/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ module.exports = function(options) {
choices: [{
name: 'A website (Foundation for Sites)',
value: 'sites'
}, {
name: 'A web app (Foundation for Apps) (deprecated - use Sites instead)',
value: 'apps'
}, {
name: 'An email (Foundation for Emails)',
value: 'emails'
Expand Down Expand Up @@ -55,8 +52,8 @@ module.exports = function(options) {
name: 'Basic Template: includes a Sass compiler',
value: 'basic'
}, {
name: 'ZURB Template: includes Handlebars templates and Sass/JS compilers',
value: 'zurb'
name: 'Panini Template: includes Handlebars templates and Sass/JS compilers',
value: 'panini'
}],
when: function(answers) {
if (!options.template && (answers.framework === 'sites' || options.framework === 'sites'))
Expand Down
39 changes: 19 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foundation-cli",
"version": "2.2.6",
"version": "2.3.0",
"description": "Command-line interface for the Foundation family of frameworks.",
"keywords": [
"foundation",
Expand All @@ -13,23 +13,22 @@
"foundation": "./bin/foundation.js"
},
"dependencies": {
"async": "^2.3.0",
"bower": "^1.6.8",
"colors": "^1.0.3",
"inquirer": "^0.8.3",
"is-root": "^1.0.0",
"js-yaml": "^3.8.2",
"lodash": "^4.17.4",
"async": "^3.2.1",
"colors": "^1.4.0",
"inquirer": "^8.1.5",
"is-root": "^2.1.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"multiline": "^1.0.2",
"nopt": "^3.0.1",
"npm": "^2.1.12",
"paint-by-number": "1.0.0",
"rimraf": "^2.2.8",
"semver": "^4.3.0",
"string-length": "^1.0.0",
"terminal-kit": "^1.8.7",
"update-notifier": "^0.2.2",
"which": "^1.0.8"
"nopt": "^5.0.0",
"npm": "^7.24.0",
"paint-by-number": "2.0.0",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"string-length": "^4.0.2",
"terminal-kit": "^2.1.6",
"update-notifier": "^5.1.0",
"which": "^2.0.2"
},
"homepage": "https://get.foundation",
"repository": {
Expand All @@ -44,11 +43,11 @@
},
"preferGlobal": true,
"engines": {
"node": ">=4.0"
"node": ">=12.0"
},
"license": "MIT",
"devDependencies": {
"editorconfig": "^0.13.2",
"eslint": "^3.19.0"
"editorconfig": "^0.15.3",
"eslint": "^8.1.0"
}
}
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
This is the command-line interface for [Foundation](https://get.foundation) family of frameworks. It downloads and installs blank templates in any of the three Foundation frameworks:

- [Foundation for Sites](https://get.foundation/sites), a framework for responsive websites
- [Foundation for Apps](https://get.foundation/apps), a framework for responsive web apps ([deprecated](https://github.com/zurb/foundation-apps#deprecation-notice))
- [Foundation for Emails](https://get.foundation/emails), a framework for responsive email

## Requirements
Expand Down
Loading

0 comments on commit b2620b3

Please sign in to comment.