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 #19 from spohner/master
Browse files Browse the repository at this point in the history
Finally got around to testing this. Works perfect. Long over due merge.

Nice work @spohner!
  • Loading branch information
tomwayson committed Nov 21, 2014
2 parents 25f2763 + 748cb1e commit dac73d4
Show file tree
Hide file tree
Showing 99 changed files with 3,937 additions and 2 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## About

This generator scaffolds out the boilerplate files that are needed when you are customizing the Web AppBuilder. This includes [generators](#running-the-generators) to creates project files (`package.json`, `.jshintrc`, etc) and scaffold out the files needed to create a new custom widget
This generator scaffolds out the boilerplate files that are needed when you are customizing the Web AppBuilder. This includes [generators](#running-the-generators) to creates project files (`package.json`, `.jshintrc`, etc) and scaffold out the files needed to create a new custom widget and custom theme.

![Screenshot](https://raw.githubusercontent.com/Esri/generator-esri-appbuilder-js/master/docs/images/running-the-generators.png)

Expand Down Expand Up @@ -83,6 +83,20 @@ The next time you run the Web AppBuilder, you will see something like the follow

![Widget in the Builder](https://raw.githubusercontent.com/Esri/generator-esri-appbuilder-js/master/docs/images/widget-in-builder.png)

### Theme Generator

Scaffolds out the files needed to create a new custom theme based on the default Foldable Theme by Esri.

1. Navigate into either `stemapp` or `builder/apps/[appId]` under your local Web AppBuilder installation
2. Run the generator with `yo esri-appbuilder-js:theme`
3. Answer the man's questions!

|Prompt|Description|Default|
|------|-----------|-------|
|Theme Name|Folder name for output files and theme identifier|DefaultThemeName|
|Description|Give a description of your custom theme|A good description of my theme...|
|Author|Your name or organization to be associated with the theme|My organization|

## Issues

Find a bug or want to request a new feature? Please let us know by [submitting an issue](https://github.com/Esri/generator-esri-appbuilder-js/issues).
Expand Down
1 change: 1 addition & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = yeoman.generators.Base.extend({

app: function () {
this.mkdir('widgets');
this.mkdir('themes');

this.template('_package.json', 'package.json');
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"files": [
"app",
"widget"
"widget",
"theme"
],
"keywords": [
"yeoman-generator", "Esri", "ArcGIS", "Web", "AppBuilder"
Expand Down
222 changes: 222 additions & 0 deletions test/test-theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
/*global describe, beforeEach, it */
'use strict';
var path = require('path');
var helpers = require('yeoman-generator').test;

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

this.theme = helpers.createGenerator('esri-appbuilder-js:theme', [
'../../theme'
]);
console.log('cleared folder and created theme generator');
done();
}.bind(this));
});

describe('when scaffolding theme', function() {

beforeEach(function(done) {
helpers.mockPrompt(this.theme, {
themeName: 'TestTheme',
desc: 'A test theme.',
author: 'Test Authorsen'
});
this.theme.run({}, function() {
done();
});
});

it('it creates expected files', function( /*done*/ ) {
var expected = [
// add files you expect to exist here.'
'themes/Testtheme/common.css',
'themes/Testtheme/layouts/default/config.json',
'themes/Testtheme/images',
'themes/Testtheme/layouts',
'themes/Testtheme/manifest.json',
'themes/Testtheme/panels',
'themes/Testtheme/styles',
'themes/Testtheme/widgets',
'themes/Testtheme/images/cancel.png',
'themes/Testtheme/images/close.png',
'themes/Testtheme/images/double_arrow.png',
'themes/Testtheme/images/icon.png',
'themes/Testtheme/layouts/default',
'themes/Testtheme/layouts/default/icon.png',
'themes/Testtheme/panels/DockablePanel',
'themes/Testtheme/panels/FoldablePanel',
'themes/Testtheme/panels/SimpleBorderPanel',
'themes/Testtheme/panels/TitlePanel',
'themes/Testtheme/panels/DockablePanel/images',
'themes/Testtheme/panels/DockablePanel/Panel.html',
'themes/Testtheme/panels/DockablePanel/Panel.js',
'themes/Testtheme/panels/DockablePanel/images/bar_down.png',
'themes/Testtheme/panels/DockablePanel/images/bar_left.png',
'themes/Testtheme/panels/DockablePanel/images/bar_right.png',
'themes/Testtheme/panels/DockablePanel/images/bar_up.png',
'themes/Testtheme/panels/DockablePanel/images/nav_down.png',
'themes/Testtheme/panels/DockablePanel/images/nav_left.png',
'themes/Testtheme/panels/DockablePanel/images/nav_right.png',
'themes/Testtheme/panels/DockablePanel/images/nav_up.png',
'themes/Testtheme/panels/FoldablePanel/FoldableDijit.js',
'themes/Testtheme/panels/FoldablePanel/FoldableWidgetFrame.js',
'themes/Testtheme/panels/FoldablePanel/Panel.js',
'themes/Testtheme/panels/SimpleBorderPanel/Panel.js',
'themes/Testtheme/panels/TitlePanel/Panel.js',
'themes/Testtheme/styles/black',
'themes/Testtheme/styles/cyan',
'themes/Testtheme/styles/default',
'themes/Testtheme/styles/green',
'themes/Testtheme/styles/black/style.css',
'themes/Testtheme/styles/cyan/style.css',
'themes/Testtheme/styles/default/style.css',
'themes/Testtheme/styles/green/style.css',
'themes/Testtheme/widgets/HeaderController',
'themes/Testtheme/widgets/HeaderController/config.json',
'themes/Testtheme/widgets/HeaderController/css',
'themes/Testtheme/widgets/HeaderController/images',
'themes/Testtheme/widgets/HeaderController/manifest.json',
'themes/Testtheme/widgets/HeaderController/nls',
'themes/Testtheme/widgets/HeaderController/PopupTileNodes.js',
'themes/Testtheme/widgets/HeaderController/setting',
'themes/Testtheme/widgets/HeaderController/Widget.html',
'themes/Testtheme/widgets/HeaderController/Widget.js',
'themes/Testtheme/widgets/HeaderController/css/images',
'themes/Testtheme/widgets/HeaderController/css/style.css',
'themes/Testtheme/widgets/HeaderController/css/images/arrow.png',
'themes/Testtheme/widgets/HeaderController/css/images/close.png',
'themes/Testtheme/widgets/HeaderController/images/app-logo.png',
'themes/Testtheme/widgets/HeaderController/images/group_icon.png',
'themes/Testtheme/widgets/HeaderController/images/icon.png',
'themes/Testtheme/widgets/HeaderController/images/more_icon.png',
'themes/Testtheme/widgets/HeaderController/nls/ar',
'themes/Testtheme/widgets/HeaderController/nls/cs',
'themes/Testtheme/widgets/HeaderController/nls/da',
'themes/Testtheme/widgets/HeaderController/nls/de',
'themes/Testtheme/widgets/HeaderController/nls/es',
'themes/Testtheme/widgets/HeaderController/nls/et',
'themes/Testtheme/widgets/HeaderController/nls/fi',
'themes/Testtheme/widgets/HeaderController/nls/fr',
'themes/Testtheme/widgets/HeaderController/nls/he',
'themes/Testtheme/widgets/HeaderController/nls/it',
'themes/Testtheme/widgets/HeaderController/nls/ja',
'themes/Testtheme/widgets/HeaderController/nls/ko',
'themes/Testtheme/widgets/HeaderController/nls/lt',
'themes/Testtheme/widgets/HeaderController/nls/lv',
'themes/Testtheme/widgets/HeaderController/nls/nb',
'themes/Testtheme/widgets/HeaderController/nls/nl',
'themes/Testtheme/widgets/HeaderController/nls/pl',
'themes/Testtheme/widgets/HeaderController/nls/pt-BR',
'themes/Testtheme/widgets/HeaderController/nls/pt-PT',
'themes/Testtheme/widgets/HeaderController/nls/ro',
'themes/Testtheme/widgets/HeaderController/nls/ru',
'themes/Testtheme/widgets/HeaderController/nls/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/sv',
'themes/Testtheme/widgets/HeaderController/nls/th',
'themes/Testtheme/widgets/HeaderController/nls/tr',
'themes/Testtheme/widgets/HeaderController/nls/zh-cn',
'themes/Testtheme/widgets/HeaderController/nls/ar/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/cs/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/da/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/de/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/es/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/et/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/fi/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/fr/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/he/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/it/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/ja/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/ko/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/lt/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/lv/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/nb/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/nl/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/pl/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/pt-BR/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/pt-PT/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/ro/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/ru/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/sv/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/th/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/tr/strings.js',
'themes/Testtheme/widgets/HeaderController/nls/zh-cn/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/css',
'themes/Testtheme/widgets/HeaderController/setting/nls',
'themes/Testtheme/widgets/HeaderController/setting/Setting.html',
'themes/Testtheme/widgets/HeaderController/setting/Setting.js',
'themes/Testtheme/widgets/HeaderController/setting/css/style.css',
'themes/Testtheme/widgets/HeaderController/setting/nls/ar',
'themes/Testtheme/widgets/HeaderController/setting/nls/cs',
'themes/Testtheme/widgets/HeaderController/setting/nls/da',
'themes/Testtheme/widgets/HeaderController/setting/nls/de',
'themes/Testtheme/widgets/HeaderController/setting/nls/es',
'themes/Testtheme/widgets/HeaderController/setting/nls/et',
'themes/Testtheme/widgets/HeaderController/setting/nls/fi',
'themes/Testtheme/widgets/HeaderController/setting/nls/fr',
'themes/Testtheme/widgets/HeaderController/setting/nls/he',
'themes/Testtheme/widgets/HeaderController/setting/nls/it',
'themes/Testtheme/widgets/HeaderController/setting/nls/ja',
'themes/Testtheme/widgets/HeaderController/setting/nls/ko',
'themes/Testtheme/widgets/HeaderController/setting/nls/lt',
'themes/Testtheme/widgets/HeaderController/setting/nls/lv',
'themes/Testtheme/widgets/HeaderController/setting/nls/nb',
'themes/Testtheme/widgets/HeaderController/setting/nls/nl',
'themes/Testtheme/widgets/HeaderController/setting/nls/pl',
'themes/Testtheme/widgets/HeaderController/setting/nls/pt-BR',
'themes/Testtheme/widgets/HeaderController/setting/nls/pt-PT',
'themes/Testtheme/widgets/HeaderController/setting/nls/ro',
'themes/Testtheme/widgets/HeaderController/setting/nls/ru',
'themes/Testtheme/widgets/HeaderController/setting/nls/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/sv',
'themes/Testtheme/widgets/HeaderController/setting/nls/th',
'themes/Testtheme/widgets/HeaderController/setting/nls/tr',
'themes/Testtheme/widgets/HeaderController/setting/nls/zh-cn',
'themes/Testtheme/widgets/HeaderController/setting/nls/ar/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/cs/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/da/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/de/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/es/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/et/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/fi/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/fr/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/he/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/it/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/ja/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/ko/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/lt/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/lv/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/nb/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/nl/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/pl/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/pt-BR/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/pt-PT/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/ro/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/ru/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/sv/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/th/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/tr/strings.js',
'themes/Testtheme/widgets/HeaderController/setting/nls/zh-cn/strings.js'
];
helpers.assertFile(expected);
});

it('should set author in manifest.json ', function() {
helpers.assertFileContent('themes/Testtheme/manifest.json', /"author": "Test Authorsen"/g);
});

it('should set themeName in manifest.json ', function() {
helpers.assertFileContent('themes/Testtheme/manifest.json', /"name": "Testtheme"/g);
});

it('should set description in manifest.json ', function() {
helpers.assertFileContent('themes/Testtheme/manifest.json', /"description": "A test theme."/g);
});

});

});
76 changes: 76 additions & 0 deletions theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');

var ThemeGenerator = yeoman.generators.Base.extend({
prompting: function () {
var done = this.async();
var dasherize = this._.dasherize;

this.log(yosay(
'Welcome to the ArcGIS Web AppBuilder theme generator!'
));

var prompts = [{
name: 'themeName',
message: 'What would you like to call your theme?',
'default': "DefaultThemeName",
// test for valid folder name
validate: function(answer) {
var validFolderNameRegExp = /^[^\\/?%*"":|<>\.\s]+$/;
return validFolderNameRegExp.test(answer);
}
},
{
name: 'author',
message: 'What is your name or the name of your organization?',
'default': "My organization"
},
{
name : 'desc',
message: 'Would you like to add a description for your theme?',
'default': "A good description of my theme..."
}
];

this.prompt(prompts, function (props) {
this.themeNameClean = this._.classify(props.themeName);
this.themeName = props.themeName.match(/([A-Z]?[^A-Z]*)/g).slice(0,-1).join(' ');
this.author = props.author;
this.description = props.desc;
done();
}.bind(this));
},

projectfiles: function () {
// NOTE: this is needed b/c _Widget.html has ES6 style interpolation delimiters
// see: https://github.com/lodash/lodash/issues/399
this._.templateSettings.interpolate = /<%=([\s\S]+?)%>/g;

var basePath = path.join('themes', this.themeNameClean);
//css
this.src.copy('_common.css', path.join(basePath, 'common.css'));
//folders
this.directory('_images', path.join(basePath, 'images'));
this.directory('_layouts', path.join(basePath, 'layouts'));
this.directory('_panels', path.join(basePath, 'panels'));
this.directory('_styles', path.join(basePath, 'styles'));
this.directory('_widgets', path.join(basePath, 'widgets'));

var context = {
themeName: this.themeName,
themeNameClean: this.themeNameClean,
author: this.author,
desc: this.description
};

this.template('_manifest.json', path.join(basePath, 'manifest.json'), context);
this.template('_config.json',path.join(basePath,'layouts/default/config.json'),context);

}
});

module.exports = ThemeGenerator;
Loading

0 comments on commit dac73d4

Please sign in to comment.