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

Update TBG fork from Foundation CLI Master #1

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a807f6c
test for user operating platform
paxperscientiam May 12, 2017
6a9e962
node version req is >=4.0
paxperscientiam Jun 6, 2017
10a33bf
Merge pull request #72 from paxperscientiam/update-engine-req
kball Jun 29, 2017
4143fe1
Merge pull request #66 from paxperscientiam/os-test
kball Aug 15, 2017
52b67b8
Update http to https for foundation properties & cli fetch
kball Sep 28, 2017
3cdf7ff
Merge pull request #91 from zurb/update-cli-to-https
kball Sep 28, 2017
5f79d78
Bump version
kball Sep 28, 2017
3337438
Fix accidental premature exit in watch introduced in #66
kball Sep 29, 2017
1a1c584
Bump version
kball Sep 29, 2017
dedd02a
Merge pull request #94 from zurb/fix-broken-watch
kball Sep 29, 2017
da04c40
Update documentation about Foundation for Apps and Bower
joshkel Oct 20, 2019
22154f3
Merge pull request #117 from joshkel/deprecation-updates
DanielRuf Nov 23, 2019
0cd91f0
Use new domain - closes #122
DanielRuf Feb 19, 2020
9afb15c
Update org name
DanielRuf Jul 23, 2020
99b1bcf
Merge pull request #130 from foundation/chore/update-org
DanielRuf Jul 23, 2020
b8d1804
Update package for release
joeworkman Jul 30, 2020
5df601f
Merge branch 'release/v2.2.6' into master
joeworkman Jul 30, 2020
cfb3d4a
Merge tag 'v2.2.6' into develop
joeworkman Jul 30, 2020
d619c4f
Updated package.json dependencies
caraya Sep 20, 2021
3302253
switching to develop branch
caraya Oct 29, 2021
a5cd123
Merge pull request #145 from caraya/chore/143-update-dependencies
joeworkman Nov 2, 2021
baaeb28
remove obsolete copySetting and changeVersion
joeworkman Nov 2, 2021
f1c0d55
bad code formatting
joeworkman Nov 2, 2021
fe93ae6
remove bower
joeworkman Nov 2, 2021
148bebb
update verbiage
joeworkman Nov 2, 2021
d5535d6
yarn
joeworkman Nov 2, 2021
5e8cf51
put back for clue for missing ee
joeworkman Nov 2, 2021
738a137
yarn > npm
joeworkman Nov 2, 2021
50b50c2
remove zurb brand
joeworkman Nov 2, 2021
68eec2a
update deps
joeworkman Nov 2, 2021
5990e08
npm load only wants function passed
joeworkman Nov 2, 2021
efd225e
Update version for release
joeworkman Nov 2, 2021
b2620b3
Merge branch 'release/v2.3.0'
joeworkman Nov 2, 2021
f61e0f8
Merge tag 'v2.3.0' into develop
joeworkman Nov 2, 2021
fc5278b
Fix color.js liberty issue
joeworkman Jan 10, 2022
9c677fc
Merge branch 'release/v2.3.1'
joeworkman Jan 10, 2022
4851f4c
Merge tag 'v2.3.1' into develop
joeworkman Jan 10, 2022
1471346
Update package for release this time
joeworkman Jan 10, 2022
2d78093
Merge branch 'release/v2.3.2'
joeworkman Jan 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions lib/commands/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function(args, options, callback) {
}

function listBuildingBlocks(args, options, callback) {
fetchUrl('foundation.zurb.com', '/building-blocks/data/building-blocks.json', function(blocksJson) {
fetchUrl('get.foundation', '/building-blocks/data/building-blocks.json', function(blocksJson) {
var i = 0;
var index = "";
var blocks = JSON.parse(blocksJson);
Expand Down Expand Up @@ -131,7 +131,7 @@ function installFiles(name, callback) {
var filename = name + filetype.name;
var path = '/building-blocks/files/building-blocks/' + name + '/' + filename;
fs.mkdir(filetype.directory, function() {
fetchUrl('foundation.zurb.com', path, function(file) {
fetchUrl('get.foundation', path, function(file) {
if(file.length > 0) {
fs.writeFile(filetype.directory + filetype.prefix + filename, file, cb);
} else {
Expand All @@ -145,7 +145,7 @@ function installFiles(name, callback) {
function downloadZipFile(name, callback) {
var filename = name + '.zip';
var path = '/building-blocks/files/building-blocks/' + filename;
fetchUrl('foundation.zurb.com', path, function(file) {
fetchUrl('get.foundation', path, function(file) {
if(file.length > 0) {
fs.writeFile(filename, file, callback);
} else {
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.zurb.com/forum'.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
4 changes: 2 additions & 2 deletions lib/commands/kits.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function listKits(args, options, callback) {

function getKitList(callback) {
// For now until kits are implemented, use categories to test out build
fetchUrl('foundation.zurb.com', '/building-blocks/data/kits.json', function(kitJson) {
fetchUrl('get.foundation', '/building-blocks/data/kits.json', function(kitJson) {
var kits = JSON.parse(kitJson);
callback(kits);
});
Expand Down Expand Up @@ -72,7 +72,7 @@ function installKit(args, options, callback) {
function downloadZipFile(name, callback) {
var filename = name + '.zip';
var path = '/building-blocks/files/kits/' + filename;
fetchUrl('foundation.zurb.com', path, function(file) {
fetchUrl('get.foundation', path, function(file) {
if(file.length > 0) {
fs.writeFile(filename, file, callback);
} else {
Expand Down
58 changes: 11 additions & 47 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/zurb/foundation-sites-template.git',
zurb: 'https://github.com/zurb/foundation-zurb-template.git'
basic: 'https://github.com/foundation/foundation-sites-template.git',
panini: 'https://github.com/foundation/foundation-zurb-template.git'
},
apps: 'https://github.com/zurb/foundation-apps-template.git',
emails: 'https://github.com/zurb/foundation-emails-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
17 changes: 15 additions & 2 deletions lib/commands/watch.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
var fs = require('fs');
var npm = require('npm');
var path = require('path');
var os = require('os');
//
var platform = os.platform();
var platformResponse = function() {
var r = "";
if (["darwin","freebsd","linux","openbsd","sunos"].indexOf(platform) > -1)
r = "pwd";
if (["win32"].indexOf(platform) > -1)
r = "chdir";
if (r === "")
r = "the appropriate command";
return "\nYou don't appear to be in a Foundation project folder.\n\nUse " + r.cyan + " to see what folder you're in.\n";
}

module.exports = function(args, options) {
// Check if the user is inside a project folder, by looking for a package.json
if (!fs.existsSync(path.join(process.cwd(), 'package.json'))) {
console.log("\nYou don't appear to be in a Foundation project folder.\n\nUse " + "pwd".cyan + " (or " + "chdir".cyan + " on Windows) to see what folder you're in.\n");
console.log(platformResponse());
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.

4 changes: 2 additions & 2 deletions lib/util/fetch-url.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var http = require('http');
var https = require('https');

module.exports = function fetchUrl(host, path, done) {
var options = {
Expand All @@ -22,5 +22,5 @@ module.exports = function fetchUrl(host, path, done) {
}
});
};
http.request(options, callback).end();
https.request(options, callback).end();
}
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)',
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
Loading