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

Commit

Permalink
Merge pull request #48 from tomwayson/latest-yeoman-generator
Browse files Browse the repository at this point in the history
updated to latest yeoman-generator (0.22)
  • Loading branch information
tomwayson committed Feb 12, 2016
2 parents bb3b68d + d6c3faa commit 3c3aa9a
Show file tree
Hide file tree
Showing 8 changed files with 283 additions and 378 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
sudo: false
language: node_js
node_js:
- "stable"
- 'stable'
- 'v4'
- '0.12'
- '0.10'
before_install:
- currentfolder=${PWD##*/}
- if [ "$currentfolder" != 'generator-esri-appbuilder-js' ]; then cd .. && eval "mv $currentfolder generator-esri-appbuilder-js" && cd generator-esri-appbuilder-js; fi

7 changes: 4 additions & 3 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
'use strict';
var path = require('path');
var yeoman = require('yeoman-generator');
var Base = require('yeoman-generator').Base;
var yosay = require('yosay');
var chalk = require('chalk');
var isWin = process.platform === 'win32';
var homedir = (isWin) ? process.env.HOMEPATH : process.env.HOME;
var fs = require('fs');
var mkdirp = require('mkdirp');

function getDirectories(srcpath) {
return fs.readdirSync(srcpath).filter(function(file) {
return fs.statSync(path.join(srcpath, file)).isDirectory();
});
}

module.exports = yeoman.generators.Base.extend({
module.exports = Base.extend({
initializing: function () {
// check for existence of package.json
try {
Expand Down Expand Up @@ -134,7 +135,7 @@ module.exports = yeoman.generators.Base.extend({
if (this.abort) {
return;
}
this.mkdir('widgets');
mkdirp('widgets');
},

gruntConfig: function() {
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "generator-esri-appbuilder-js",
"version": "1.2.0",
"version": "2.0.0",
"description": "Yeoman generator to help customize the ArcGIS Web AppBuilder",
"license": "Apache",
"license": "Apache-2.0",
"main": "app/index.js",
"repository": "Esri/generator-esri-appbuilder-js",
"author": {
Expand All @@ -14,7 +14,7 @@
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
"test": "mocha --timeout 10000"
},
"files": [
"app",
Expand All @@ -28,15 +28,15 @@
"AppBuilder"
],
"dependencies": {
"chalk": "~0.4.0",
"yeoman-generator": "^0.17.0",
"yosay": "^0.1.0"
"chalk": "^1.0.0",
"underscore.string": "^3.2.3",
"yeoman-generator": "^0.22.5",
"yosay": "^1.0.2"
},
"devDependencies": {
"mkdirp": "^0.5.1",
"mocha": "*"
},
"peerDependencies": {
"yo": ">=1.0.0"
"mocha": "*",
"yeoman-assert": "^2.0.0",
"yeoman-test": "^1.0.0"
}
}
151 changes: 52 additions & 99 deletions test/test-creation.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,34 @@
/*global describe, before, it */
'use strict';
var path = require('path');
var helpers = require('yeoman-generator').test;
var assert = require('yeoman-assert');
var helpers = require('yeoman-test');
var mkdirp = require('mkdirp');
var fs = require('fs');

var wabRoot = path.join(__dirname, 'temp');
var wabRoot = 'wab_root';
var appDirId = '5'; // arbitrary number since we're creating everything anyway.
var appTitle = 'TestTitle'; // arbitrary title
var appDirPath = path.join('server', 'apps', appDirId);
var filePath = path.join(appDirPath, 'config.json');
var appDirPath = path.join(wabRoot, 'server', 'apps', appDirId);
var configFilePath = path.join(appDirPath, 'config.json');
var configFileContents = '{title:"' + appTitle + '"}';

describe('esri-appbuilder-js generator', function () {
describe('esri-appbuilder-js:app', function () {
before(function (done) {
helpers.testDirectory(wabRoot, function (err) {
if (err) {
return done(err);
}

// Write the config file to the "filePath", so it's available to
// read when the generator goes to lookup the possible values
// for the apps.
mkdirp(appDirPath, function (err) {
if (err) {
console.error(err);
} else {
fs.writeFileSync(filePath, configFileContents);

this.app = helpers.createGenerator('esri-appbuilder-js:app', [
'../../app'
]);

helpers.mockPrompt(this.app, {
'abort': false,
'wabRoot': wabRoot,
'appDirId': appDirId
});
this.app.options['skip-install'] = true;
this.app.run({}, function () {
done();
});
}
}.bind(this));
}.bind(this));
helpers.run(path.join(__dirname, '../app'))
.withOptions({ skipInstall: true })
.withPrompts({
'abort': false,
'wabRoot': wabRoot,
'appDirId': appDirId
}).inTmpDir(function(/*dir*/) {
var done = this.async();
mkdirp(appDirPath, function () {
fs.writeFileSync(configFilePath, configFileContents);
done();
});
})
.on('end', done);
});

// TODO: test for existence of widgets folder?
Expand All @@ -53,68 +38,55 @@ describe('esri-appbuilder-js generator', function () {
'.jshintrc',
'.editorconfig'
];
helpers.assertFile(expected);
assert.file(expected);
});

describe('when creating gruntfile', function() {
it('sets stemappDir variable', function() {
helpers.assertFileContent('Gruntfile.js', new RegExp('var stemappDir = \'' + path.join(wabRoot, 'client', 'stemapp').replace(/\\/g, '/')));
assert.fileContent('Gruntfile.js', new RegExp('var stemappDir = \'' + path.join(wabRoot, 'client', 'stemapp').replace(/\\/g, '/')));
});
it('sets appDir variable', function() {
helpers.assertFileContent('Gruntfile.js', new RegExp('var appDir = \'' + path.join(wabRoot, 'server', 'apps', appDirId).replace(/\\/g, '/')));
assert.fileContent('Gruntfile.js', new RegExp('var appDir = \'' + path.join(wabRoot, 'server', 'apps', appDirId).replace(/\\/g, '/')));
});
it('sets watch config', function() {
helpers.assertFileContent('Gruntfile.js', new RegExp('watch:'));
assert.fileContent('Gruntfile.js', new RegExp('watch:'));
});
it('loads watch task', function() {
helpers.assertFileContent('Gruntfile.js', /grunt.loadNpmTasks\('grunt-contrib-watch'\);/);
assert.fileContent('Gruntfile.js', /grunt.loadNpmTasks\('grunt-contrib-watch'\);/);
});
it('sets sync config', function() {
helpers.assertFileContent('Gruntfile.js', new RegExp('sync:'));
assert.fileContent('Gruntfile.js', new RegExp('sync:'));
});
it('loads sync task', function() {
helpers.assertFileContent('Gruntfile.js', /grunt.loadNpmTasks\('grunt-sync'\);/);
assert.fileContent('Gruntfile.js', /grunt.loadNpmTasks\('grunt-sync'\);/);
});
it('registers default task', function() {
helpers.assertFileContent('Gruntfile.js', /grunt.registerTask\('default',/);
assert.fileContent('Gruntfile.js', /grunt.registerTask\('default',/);
});
});
});

describe('esri-appbuilder-js generator - no app', function () {
before(function (done) {
helpers.testDirectory(wabRoot, function (err) {
if (err) {
return done(err);
}

mkdirp(appDirPath, function (err) {
if (err) {
console.error(err);
} else {
fs.writeFileSync(filePath, configFileContents);

this.app = helpers.createGenerator('esri-appbuilder-js:app', [
'../../app'
]);

helpers.mockPrompt(this.app, {
'abort': false,
'wabRoot': wabRoot,
'appDirId': 'None'
});
this.app.options['skip-install'] = true;
this.app.run({}, function () {
done();
});
}
}.bind(this));
}.bind(this));
helpers.run(path.join(__dirname, '../app'))
.withOptions({ skipInstall: true })
.withPrompts({
'abort': false,
'wabRoot': wabRoot,
'appDirId': 'None'
}).inTmpDir(function(/*dir*/) {
var done = this.async();
mkdirp(appDirPath, function () {
fs.writeFileSync(configFilePath, configFileContents);
done();
});
})
.on('end', done);
});

describe('when creating gruntfile', function() {
it('appDir set to "todo"', function() {
helpers.assertFileContent('Gruntfile.js', new RegExp('var appDir = \'TODO(.*)'));
assert.fileContent('Gruntfile.js', new RegExp('var appDir = \'TODO(.*)'));
});
// TODO - not testing the other parts of the gruntfile here since it's the same as the previous
// case. That common code should be pulled out in the future.
Expand All @@ -123,33 +95,14 @@ describe('esri-appbuilder-js generator - no app', function () {

describe('esri-appbuilder-js abort', function () {
before(function (done) {
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
if (err) {
return done(err);
}

mkdirp(appDirPath, function (err) {
if (err) {
console.error(err);
} else {
fs.writeFileSync(filePath, configFileContents);

this.app = helpers.createGenerator('esri-appbuilder-js:app', [
'../../app'
]);

helpers.mockPrompt(this.app, {
'abort': true,
'wabRoot': wabRoot,
'appDirId': appDirId
});
this.app.options['skip-install'] = true;
this.app.run({}, function () {
done();
});
}
}.bind(this));
}.bind(this));
helpers.run(path.join(__dirname, '../app'))
.withOptions({ skipInstall: true })
.withPrompts({
'abort': true,
'wabRoot': wabRoot,
'appDirId': appDirId
})
.on('end', done);
});

it('does not create dotfiles or Gruntfile', function () {
Expand All @@ -158,6 +111,6 @@ describe('esri-appbuilder-js abort', function () {
'.editorconfig',
'Gruntfile.js'
];
helpers.assertNoFile(expected);
assert.noFile(expected);
});
});
10 changes: 0 additions & 10 deletions test/test-load.js

This file was deleted.

Loading

0 comments on commit 3c3aa9a

Please sign in to comment.