From 21b09ddc1d3f6849714af63484167cd4af1b876f Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Sat, 14 Dec 2013 16:58:11 -0500 Subject: [PATCH 1/4] compile to js on publish --- Gulpfile.js | 6 ++++++ lib/commands/index.coffee | 1 + lib/commands/index.js | 1 - package.json | 8 +++++++- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Gulpfile.js create mode 100644 lib/commands/index.coffee delete mode 100644 lib/commands/index.js diff --git a/Gulpfile.js b/Gulpfile.js new file mode 100644 index 0000000..69d2a59 --- /dev/null +++ b/Gulpfile.js @@ -0,0 +1,6 @@ +var g = require('gulp'), + coffee = require('gulp-coffee'); + +g.task('build', function(){ + g.src('src/**/*.coffee').pipe(coffee({ bare: true })).pipe(g.dest('lib')) +}); diff --git a/lib/commands/index.coffee b/lib/commands/index.coffee new file mode 100644 index 0000000..b56e9ac --- /dev/null +++ b/lib/commands/index.coffee @@ -0,0 +1 @@ +module.exports = require('indx')(__dirname) diff --git a/lib/commands/index.js b/lib/commands/index.js deleted file mode 100644 index b20ab4d..0000000 --- a/lib/commands/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('indx')(__dirname); diff --git a/package.json b/package.json index 418d960..4942366 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,12 @@ }, "devDependencies": { "mocha": "*", - "should": "*" + "should": "*", + "gulp": "3.x.x", + "gulp-coffee": "1.x.x" + }, + "scripts": { + "prepublish": "mv lib/ src; gulp build", + "postpublish": "rm -rf lib; mv src/ lib" } } From 61e6da0f8f6994971256664acf55a2cafd2043a2 Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Sat, 14 Dec 2013 17:07:04 -0500 Subject: [PATCH 2/4] add npm test command --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 4942366..6d9ede1 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "gulp-coffee": "1.x.x" }, "scripts": { + "test": "mocha", "prepublish": "mv lib/ src; gulp build", "postpublish": "rm -rf lib; mv src/ lib" } From a9b6ae240e180aef05669605397ebf7e28fb96ef Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Sat, 14 Dec 2013 17:11:33 -0500 Subject: [PATCH 3/4] fix directory creation bug --- lib/base.coffee | 11 ++++++----- package.json | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/base.coffee b/lib/base.coffee index b77b19a..e00db8f 100644 --- a/lib/base.coffee +++ b/lib/base.coffee @@ -3,6 +3,7 @@ fs = require 'fs' crypto = require 'crypto' os = require 'os' osenv = require 'osenv' +mkdirp = require 'mkdirp' class Base @@ -10,15 +11,15 @@ class Base user = (osenv.user() || generate_fake_user()).replace(/\\/g, '-') tmp_dir = path.join((if os.tmpdir then os.tmpdir() else os.tmpDir()), user) @config_dir = process.env.XDG_CONFIG_HOME || path.join((osenv.home() || tmp_dir), '.config/sprout') - if not fs.existsSync(@config_dir) then fs.mkdirSync(@config_dir) + if not fs.existsSync(@config_dir) then mkdirp.sync(@config_dir) path: (name='') -> path.join(@config_dir, name) - - # + + # # @api private - # - + # + generate_fake_user: -> # h/t to configstore for this logic uid = [process.pid, Date.now(), Math.floor(Math.random() * 1000000)].join('-') diff --git a/package.json b/package.json index 6d9ede1..4fcf92a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "readdirp": "0.3.x", "event-stream": "3.x.x", "when": "2.x.x", - "sugar": "1.x.x" + "sugar": "1.x.x", + "mkdirp": "0.3.x" }, "devDependencies": { "mocha": "*", From a0a21504177edbbd5cdfe44897847e5148bc9e7d Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Sat, 14 Dec 2013 17:14:10 -0500 Subject: [PATCH 4/4] fix up tests to work much better - pull from real github repo - fix strange bug in prepublish task - remove unneeded deps - eliminate any extra console logs when overriding prompt --- .gitignore | 2 +- .travis.yml | 1 - Gulpfile.js | 2 +- lib/commands/add.coffee | 4 ++-- lib/commands/init.coffee | 6 ++++-- package.json | 8 ++++---- test/fixtures/basic | 1 - test/test.coffee | 5 ++--- 8 files changed, 14 insertions(+), 15 deletions(-) delete mode 160000 test/fixtures/basic diff --git a/.gitignore b/.gitignore index 91dfed8..9daa824 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .DS_Store -node_modules \ No newline at end of file +node_modules diff --git a/.travis.yml b/.travis.yml index b9207e5..244b7e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ language: node_js node_js: - - '0.8' - '0.10' diff --git a/Gulpfile.js b/Gulpfile.js index 69d2a59..d8f0f9c 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -2,5 +2,5 @@ var g = require('gulp'), coffee = require('gulp-coffee'); g.task('build', function(){ - g.src('src/**/*.coffee').pipe(coffee({ bare: true })).pipe(g.dest('lib')) + g.src('src/**/*.coffee').pipe(coffee()).pipe(g.dest('lib')) }); diff --git a/lib/commands/add.coffee b/lib/commands/add.coffee index d74b921..6a896bb 100644 --- a/lib/commands/add.coffee +++ b/lib/commands/add.coffee @@ -1,4 +1,4 @@ -require 'shelljs/global' +which = require 'which' exec = require('child_process').exec Base = require '../base' accord = require '../utils/accord' @@ -10,7 +10,7 @@ class Add extends Base accord.call(@, { name: name, url: url, options: opts, cb: cb }) if not @name then return @cb('your template needs a name!') - if not which('git') then return @cb('you need to have git installed') + if not which.sync('git') then return @cb('you need to have git installed') if @name and not @url @url = @name diff --git a/lib/commands/init.coffee b/lib/commands/init.coffee index 7a90319..40f6ad0 100644 --- a/lib/commands/init.coffee +++ b/lib/commands/init.coffee @@ -53,14 +53,16 @@ class Init extends Base @config_values = @options return W.resolve() - console.log '\nplease enter the following information:'.yellow prompt.override = @options prompt.message = '' prompt.delimiter = '' + + if not prompt.override then console.log '\nplease enter the following information:'.yellow + prompt.start() nodefn.call(prompt.get, @config.configure).tap (res) => @config_values = res - console.log('') + if not prompt.override then console.log('') user_after_fn = -> if not @config.before then return W.resolve() diff --git a/package.json b/package.json index 4fcf92a..6814ec1 100644 --- a/package.json +++ b/package.json @@ -15,23 +15,23 @@ "colors": "0.6.x", "optimist": "0.6.x", "indx": "0.0.x", - "shelljs": "0.2.x", "osenv": "0.0.x", "rimraf": "2.x.x", "ncp": "0.4.x", "ejs": "0.8.x", "prompt": "0.2.x", "readdirp": "0.3.x", - "event-stream": "3.x.x", "when": "2.x.x", "sugar": "1.x.x", - "mkdirp": "0.3.x" + "mkdirp": "0.3.x", + "which": "1.0.x" }, "devDependencies": { "mocha": "*", "should": "*", "gulp": "3.x.x", - "gulp-coffee": "1.x.x" + "gulp-coffee": "1.x.x", + "shelljs": "0.2.x" }, "scripts": { "test": "mocha", diff --git a/test/fixtures/basic b/test/fixtures/basic deleted file mode 160000 index 7f01f01..0000000 --- a/test/fixtures/basic +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7f01f0119d3b55c258fc031870a8a9d94c90780a diff --git a/test/test.coffee b/test/test.coffee index fdf6e98..b5afd47 100644 --- a/test/test.coffee +++ b/test/test.coffee @@ -9,7 +9,6 @@ before -> @exec = (cmd) -> exec(cmd, {silent: true}) @$ = path.join(__dirname, '../bin/sprout') - describe 'accord', -> beforeEach -> @@ -72,7 +71,7 @@ describe 'js api', -> it '[init] creates a project template correctly', (done) -> basic_path = path.join(__dirname, 'fixtures/basic') - sprout.add 'foobar', "file:////#{basic_path}", (err, res) -> + sprout.add 'foobar', "https://github.com/jenius/sprout-test-template.git", (err, res) -> should.not.exist(err) testpath = path.join(__dirname, 'testproj') sprout.init 'foobar', testpath, { foo: 'bar' }, (err, res) => @@ -124,7 +123,7 @@ describe 'cli', -> cmd.code.should.be.above(0) it '[init] creates a project template correctly', -> - cmd = @exec("#{@$} add foobar file:////#{path.join(__dirname, 'fixtures/basic')}") + cmd = @exec("#{@$} add foobar https://github.com/jenius/sprout-test-template.git") cmd.code.should.eql(0) testpath = path.join(__dirname, 'testproj') cmd = @exec("#{@$} init foobar #{testpath} --foo bar")