SlideShare a Scribd company logo
УСТАНОВКА
npminstall-gyo
npminstall-ggrunt-cli
npminstall-gbower
sudonpminstall-gyo
sudonpminstall-ggrunt-cli
sudonpminstall-gbower
ПОИСК ГЕНЕРАТОРА
http://yeoman.io/generators/
npmsearchyeoman-generator
УСТАНОВКА
ГЕНЕРАТОРА
npminstall-ggenerator-webapp
ИСПОЛЬЗОВАНИЕ
yowebapp
app/
node_modules/
test/
.bowerrc
.editorconfig
.gitattributes
.gitignore
.jshintrc
bower.json
Gruntfile.js
package.json
СУБГЕНЕРАТОРЫ
yoangular-fullstack:controller
yoangular-fullstack:decorator
yoangular-fullstack:directive
app/
node_modules/
test/
.bowerrc
.editorconfig
.gitattributes
.gitignore
.jshintrc
bower.json
Gruntfile.js
package.json
PACKAGE.JSON
{
"name":"webapp-test",
"dependencies":{},
"devDependencies":{
"apache-server-configs":"^2.7.1",
"grunt":"^0.4.5",
"grunt-autoprefixer":"^1.0.0",
"grunt-concurrent":"^0.5.0",
"grunt-contrib-clean":"^0.6.0",
"grunt-contrib-concat":"^0.5.0",
"grunt-contrib-connect":"^0.8.0",
"grunt-contrib-copy":"^0.5.0",
},
"engines":{
"node":">=0.10.0"
}
}
BOWER.JSON
{
"name":"webapp-test",
"private":true,
"dependencies":{
"bootstrap":"~3.2.0"
}
}
ДОБАЛЕНИЕ ЗАВИСИМОСТЕЙ
npminstall
npminstalgrunt-contrib-copy--save-dev
npminstallexpress--save
bowerinstall
bowerinstalljquery--save
GRUNTFILE
module.exports=function(grunt){
grunt.initConfig({
concat:{
main:{
src:[
'js/libs/jquery.js',
'js/mylibs/**/*.js' //ВсеJS-файлывпапке
],
dest:'build/scripts.js'
}
},
uglify:{
main:{
files:{
'build/scripts.min.js':'<%=concat.main.dest%>'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default',['concat','uglify']);
};
ЗАПУСК
grunt #Задачаdefault
gruntconcat #Задачаconcat
gruntconcat:main #Подзадачаconcat:main
СВОЙ ГЕНЕРАТОР
mkdirgenerator-name
cdgenerator-name
npminit
{
"name":"generator-name",
"version":"0.1.0",
"description":"",
"keywords":["yeoman-generator"],
"dependencies":{
"yeoman-generator":"^0.17.3"
}
}
ФАЙЛОВАЯ СТРУКТУРА
├───package.json
├───app/
│ └───index.js
└───router/
└───index.js
├───package.json
└───generators/
├───app/
│ └───index.js
└───router/
└───index.js
yoname
yoname:router
GENERATOR-GENERATOR
npminstall-ggenerator-generator
yogenerator
yogenerator:subgeneratorNAME
INDEX.JS
vargenerators=require('yeoman-generator');
module.exports=generators.Base.extend();
vargenerators=require('yeoman-generator');
module.exports=generators.NamedBase.extend();
module.exports=generators.Base.extend({
method1:function(){
console.log('method1justran');
},
method2:function(){
console.log('method2justran');
}
});
ЗАПУСК
npmlink
yoname
yoname:subname
RUN LOOP
generators.Base.extend({
priorityName:function(){}
});
generators.Base.extend({
priorityName:{
method:function(){},
method2:function(){}
}
});
1. initializing 2. prompting
3. configuring 4. default
5. writing 6. conflicts
7. install 8. end
0. constructor
ВЗАИМОДЕЙСТВИЕ С
ПОЛЬЗОВАТЕЛЕМ
PROMTS
this.prompt([{
type:'input',
name:'dirname',
message:'Messagetouser',
default:'public'
},{
type:'input',
name:'name',
message:'Whatisyourname?',
default:''
}],function(answers){
this.answers=answers;
done();
}.bind(this));
ВЗАИМОДЕЙСТВИЕ С
ПОЛЬЗОВАТЕЛЕМ
ARGUMENTS
module.exports=generators.Base.extend({
constructor:function(){
generators.Base.apply(this,arguments);
this.argument('appname',{type:String,required:true});
//{type:String,required:true,optional:false,
// defaults:'myApp',desc:'',banner:''}
//this.appname;
}
});
yowebappmy-project
ВЗАИМОДЕЙСТВИЕ С
ПОЛЬЗОВАТЕЛЕМ
OPTIONS
module.exports=generators.Base.extend({
constructor:function(){
generators.Base.apply(this,arguments);
this.option('coffee',{});
// {desc:'',type:'Boolean',
// defaults:'false',hide:'false'}
//this.options.coffee
}
});
yowebapp--coffee
ВЗАИМОДЕЙСТВИЕ С
ПОЛЬЗОВАТЕЛЕМ
ВЫВОД
module.exports=generators.Base.extend({
myAction:function(){
this.log('Somethinghasgonewrong!');
}
});
РАБОТА С ФАЙЛАМИ
generators.Base.extend({
writing:function(){
this.fs.copy('package.json','package.json');
this.fs.copyTpl(
this.templatePath('index.html'),
this.destinationPath('public/index.html'),
{title:'TemplatingwithYeoman'}
);
this.write('config.json',JSON.stringify(this.answers,null,2));
}
});
<html>
<head>
<title><%=title%></title>
</head>
</html>
<html>
<head>
<title>TemplatingwithYeoman</title>
</head>
</html>
GRUNTFILE
module.exports=generators.Base.extend({
writing:function(){
this.gruntfile.insertConfig("compass","{watch:{watch:true}}");
this.gruntfile.registerTask('build','compass');
}
});
grunt.initConfig({
compass:{
watch:{watch:true}
}
});
grunt.registerTask('build',['compass']);
http://yeoman.io/generators/
https://github.com/yeoman/generator-webapp
https://github.com/yeoman/generator-angular
https://github.com/yeoman/generator-backbone
https://github.com/yeoman/generator-ember
https://github.com/yeoman/generator-mobile
https://github.com/Thomas-Lebeau/generator-
bootstrap-less
Web App
AngularJS
Backbone
Ember
Mobile App
Bootstrap LESS
http://gruntjs.com/
https://github.com/gruntjs/grunt-contrib-concat
https://github.com/gruntjs/grunt-contrib-copy
https://github.com/gruntjs/grunt-contrib-uglify
https://github.com/gruntjs/grunt-contrib-jshint
https://github.com/gruntjs/grunt-contrib-watch
https://github.com/jharding/grunt-exec
concat
copy
uglify
jshint
watch
exec
vargulp=require('gulp');
varuglify=require('gulp-uglify');
gulp.task('scripts',function(){
//МинифицируемикопируемвсеJavaScriptфайлы,
//кромескриптовпоставщика
gulp.src(['client/js/**/*.js','!client/js/vendor/**'])
.pipe(uglify())
.pipe(gulp.dest('build/js'));
//Копируемскриптыпоставщика
gulp.src('client/js/vendor/**')
.pipe(gulp.dest('build/js/vendor'));
});
//Задачапоумолчанию,вызываетсязапуском`gulp`
gulp.task('default',function(){
gulp.run('scripts');
//Отслеживаемфайлы,ипоихизменению,запускаемзадачу
gulp.watch('client/js/**',function(event){
gulp.run('scripts');
});
});

More Related Content

Viewers also liked

文學通的開發心路歷程
文學通的開發心路歷程文學通的開發心路歷程
文學通的開發心路歷程
建銘 廖
 
Fiscalidad de internet
Fiscalidad de internetFiscalidad de internet
Fiscalidad de internet
Joel Quintana
 
Textual analysis of seven
Textual analysis of sevenTextual analysis of seven
Textual analysis of seven
Abbey Cotterill
 
IR
IRIR
IR
MAK
 
«QA Community: что делать с людьми, которые хотят работать побольше» Евгений ...
«QA Community: что делать с людьми, которые хотят работать побольше» Евгений ...«QA Community: что делать с людьми, которые хотят работать побольше» Евгений ...
«QA Community: что делать с людьми, которые хотят работать побольше» Евгений ...
DataArt
 
Contratación electrónica y contratación informática
Contratación electrónica y contratación informáticaContratación electrónica y contratación informática
Contratación electrónica y contratación informática
Joel Quintana
 
Zed innovation intro
Zed innovation introZed innovation intro
Zed innovation intro
Ziv Kohav
 
Bean Plataspid
Bean PlataspidBean Plataspid
Сергей Зиновьев — Разработка веб-приложений на Rails.
Сергей Зиновьев — Разработка веб-приложений на Rails.Сергей Зиновьев — Разработка веб-приложений на Rails.
Сергей Зиновьев — Разработка веб-приложений на Rails.
DataArt
 
Яна Пролис "Создаем Dream Team"
Яна Пролис "Создаем Dream Team"Яна Пролис "Создаем Dream Team"
Яна Пролис "Создаем Dream Team"
DataArt
 
Transistores
TransistoresTransistores
Transistores
Manuel Bolivar H
 
«Прототип за 60 секунд: о вайрфреймах и прототипах»
 «Прототип за 60 секунд: о вайрфреймах и прототипах» «Прототип за 60 секунд: о вайрфреймах и прототипах»
«Прототип за 60 секунд: о вайрфреймах и прототипах»
DataArt
 
The Rental Policies You Need to Know About
The Rental Policies You Need to Know AboutThe Rental Policies You Need to Know About
The Rental Policies You Need to Know About
UrbanBound
 
Pen pc tecn
Pen pc tecnPen pc tecn
Pen pc tecn
Rajeshwar Reddy
 
Building Pennsylvania's First Detector Network Part 2
Building Pennsylvania's First Detector Network Part 2Building Pennsylvania's First Detector Network Part 2
Building Pennsylvania's First Detector Network Part 2
PlantHealthResourceCenter
 
Android wear, Alexey Rybakov DataArt Kharkov
Android wear, Alexey Rybakov DataArt KharkovAndroid wear, Alexey Rybakov DataArt Kharkov
Android wear, Alexey Rybakov DataArt Kharkov
DataArt
 
180 blue dining room training
180 blue dining room training180 blue dining room training
180 blue dining room training
Bill Buffalo
 
Reader’s theater (1)
Reader’s theater (1)Reader’s theater (1)
Reader’s theater (1)
IIPCONX
 
Testing in projects
Testing in projectsTesting in projects
Testing in projects
DataArt
 
นิทาน
นิทานนิทาน
นิทานExitOfLove
 

Viewers also liked (20)

文學通的開發心路歷程
文學通的開發心路歷程文學通的開發心路歷程
文學通的開發心路歷程
 
Fiscalidad de internet
Fiscalidad de internetFiscalidad de internet
Fiscalidad de internet
 
Textual analysis of seven
Textual analysis of sevenTextual analysis of seven
Textual analysis of seven
 
IR
IRIR
IR
 
«QA Community: что делать с людьми, которые хотят работать побольше» Евгений ...
«QA Community: что делать с людьми, которые хотят работать побольше» Евгений ...«QA Community: что делать с людьми, которые хотят работать побольше» Евгений ...
«QA Community: что делать с людьми, которые хотят работать побольше» Евгений ...
 
Contratación electrónica y contratación informática
Contratación electrónica y contratación informáticaContratación electrónica y contratación informática
Contratación electrónica y contratación informática
 
Zed innovation intro
Zed innovation introZed innovation intro
Zed innovation intro
 
Bean Plataspid
Bean PlataspidBean Plataspid
Bean Plataspid
 
Сергей Зиновьев — Разработка веб-приложений на Rails.
Сергей Зиновьев — Разработка веб-приложений на Rails.Сергей Зиновьев — Разработка веб-приложений на Rails.
Сергей Зиновьев — Разработка веб-приложений на Rails.
 
Яна Пролис "Создаем Dream Team"
Яна Пролис "Создаем Dream Team"Яна Пролис "Создаем Dream Team"
Яна Пролис "Создаем Dream Team"
 
Transistores
TransistoresTransistores
Transistores
 
«Прототип за 60 секунд: о вайрфреймах и прототипах»
 «Прототип за 60 секунд: о вайрфреймах и прототипах» «Прототип за 60 секунд: о вайрфреймах и прототипах»
«Прототип за 60 секунд: о вайрфреймах и прототипах»
 
The Rental Policies You Need to Know About
The Rental Policies You Need to Know AboutThe Rental Policies You Need to Know About
The Rental Policies You Need to Know About
 
Pen pc tecn
Pen pc tecnPen pc tecn
Pen pc tecn
 
Building Pennsylvania's First Detector Network Part 2
Building Pennsylvania's First Detector Network Part 2Building Pennsylvania's First Detector Network Part 2
Building Pennsylvania's First Detector Network Part 2
 
Android wear, Alexey Rybakov DataArt Kharkov
Android wear, Alexey Rybakov DataArt KharkovAndroid wear, Alexey Rybakov DataArt Kharkov
Android wear, Alexey Rybakov DataArt Kharkov
 
180 blue dining room training
180 blue dining room training180 blue dining room training
180 blue dining room training
 
Reader’s theater (1)
Reader’s theater (1)Reader’s theater (1)
Reader’s theater (1)
 
Testing in projects
Testing in projectsTesting in projects
Testing in projects
 
นิทาน
นิทานนิทาน
นิทาน
 

More from DataArt

DataArt Custom Software Engineering with a Human Approach
DataArt Custom Software Engineering with a Human ApproachDataArt Custom Software Engineering with a Human Approach
DataArt Custom Software Engineering with a Human Approach
DataArt
 
DataArt Healthcare & Life Sciences
DataArt Healthcare & Life SciencesDataArt Healthcare & Life Sciences
DataArt Healthcare & Life Sciences
DataArt
 
DataArt Financial Services and Capital Markets
DataArt Financial Services and Capital MarketsDataArt Financial Services and Capital Markets
DataArt Financial Services and Capital Markets
DataArt
 
About DataArt HR Partners
About DataArt HR PartnersAbout DataArt HR Partners
About DataArt HR Partners
DataArt
 
Event management в IT
Event management в ITEvent management в IT
Event management в IT
DataArt
 
Digital Marketing from inside
Digital Marketing from insideDigital Marketing from inside
Digital Marketing from inside
DataArt
 
What's new in Android, Igor Malytsky ( Google Post I|O Tour)
What's new in Android, Igor Malytsky ( Google Post I|O Tour)What's new in Android, Igor Malytsky ( Google Post I|O Tour)
What's new in Android, Igor Malytsky ( Google Post I|O Tour)
DataArt
 
DevOps Workshop:Что бывает, когда DevOps приходит на проект
DevOps Workshop:Что бывает, когда DevOps приходит на проектDevOps Workshop:Что бывает, когда DevOps приходит на проект
DevOps Workshop:Что бывает, когда DevOps приходит на проект
DataArt
 
IT Talk Kharkiv: «‎Soft skills в IT. Польза или вред? Максим Бастион, DataArt
IT Talk Kharkiv: «‎Soft skills в IT. Польза или вред? Максим Бастион, DataArtIT Talk Kharkiv: «‎Soft skills в IT. Польза или вред? Максим Бастион, DataArt
IT Talk Kharkiv: «‎Soft skills в IT. Польза или вред? Максим Бастион, DataArt
DataArt
 
«Ноль копеек. Спастись от выгорания» — Сергей Чеботарев (Head of Design, Han...
 «Ноль копеек. Спастись от выгорания» — Сергей Чеботарев (Head of Design, Han... «Ноль копеек. Спастись от выгорания» — Сергей Чеботарев (Head of Design, Han...
«Ноль копеек. Спастись от выгорания» — Сергей Чеботарев (Head of Design, Han...
DataArt
 
Communication in QA's life
Communication in QA's lifeCommunication in QA's life
Communication in QA's life
DataArt
 
Нельзя просто так взять и договориться, или как мы работали со сложными людьми
Нельзя просто так взять и договориться, или как мы работали со сложными людьмиНельзя просто так взять и договориться, или как мы работали со сложными людьми
Нельзя просто так взять и договориться, или как мы работали со сложными людьми
DataArt
 
Знакомьтесь, DevOps
Знакомьтесь, DevOpsЗнакомьтесь, DevOps
Знакомьтесь, DevOps
DataArt
 
DevOps in real life
DevOps in real lifeDevOps in real life
DevOps in real life
DataArt
 
Codeless: автоматизация тестирования
Codeless: автоматизация тестированияCodeless: автоматизация тестирования
Codeless: автоматизация тестирования
DataArt
 
Selenoid
SelenoidSelenoid
Selenoid
DataArt
 
Selenide
SelenideSelenide
Selenide
DataArt
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"
DataArt
 
Эмоциональный интеллект или как не сойти с ума в условиях сложного и динамичн...
Эмоциональный интеллект или как не сойти с ума в условиях сложного и динамичн...Эмоциональный интеллект или как не сойти с ума в условиях сложного и динамичн...
Эмоциональный интеллект или как не сойти с ума в условиях сложного и динамичн...
DataArt
 
IT talk: Как я перестал бояться и полюбил TestNG
IT talk: Как я перестал бояться и полюбил TestNGIT talk: Как я перестал бояться и полюбил TestNG
IT talk: Как я перестал бояться и полюбил TestNG
DataArt
 

More from DataArt (20)

DataArt Custom Software Engineering with a Human Approach
DataArt Custom Software Engineering with a Human ApproachDataArt Custom Software Engineering with a Human Approach
DataArt Custom Software Engineering with a Human Approach
 
DataArt Healthcare & Life Sciences
DataArt Healthcare & Life SciencesDataArt Healthcare & Life Sciences
DataArt Healthcare & Life Sciences
 
DataArt Financial Services and Capital Markets
DataArt Financial Services and Capital MarketsDataArt Financial Services and Capital Markets
DataArt Financial Services and Capital Markets
 
About DataArt HR Partners
About DataArt HR PartnersAbout DataArt HR Partners
About DataArt HR Partners
 
Event management в IT
Event management в ITEvent management в IT
Event management в IT
 
Digital Marketing from inside
Digital Marketing from insideDigital Marketing from inside
Digital Marketing from inside
 
What's new in Android, Igor Malytsky ( Google Post I|O Tour)
What's new in Android, Igor Malytsky ( Google Post I|O Tour)What's new in Android, Igor Malytsky ( Google Post I|O Tour)
What's new in Android, Igor Malytsky ( Google Post I|O Tour)
 
DevOps Workshop:Что бывает, когда DevOps приходит на проект
DevOps Workshop:Что бывает, когда DevOps приходит на проектDevOps Workshop:Что бывает, когда DevOps приходит на проект
DevOps Workshop:Что бывает, когда DevOps приходит на проект
 
IT Talk Kharkiv: «‎Soft skills в IT. Польза или вред? Максим Бастион, DataArt
IT Talk Kharkiv: «‎Soft skills в IT. Польза или вред? Максим Бастион, DataArtIT Talk Kharkiv: «‎Soft skills в IT. Польза или вред? Максим Бастион, DataArt
IT Talk Kharkiv: «‎Soft skills в IT. Польза или вред? Максим Бастион, DataArt
 
«Ноль копеек. Спастись от выгорания» — Сергей Чеботарев (Head of Design, Han...
 «Ноль копеек. Спастись от выгорания» — Сергей Чеботарев (Head of Design, Han... «Ноль копеек. Спастись от выгорания» — Сергей Чеботарев (Head of Design, Han...
«Ноль копеек. Спастись от выгорания» — Сергей Чеботарев (Head of Design, Han...
 
Communication in QA's life
Communication in QA's lifeCommunication in QA's life
Communication in QA's life
 
Нельзя просто так взять и договориться, или как мы работали со сложными людьми
Нельзя просто так взять и договориться, или как мы работали со сложными людьмиНельзя просто так взять и договориться, или как мы работали со сложными людьми
Нельзя просто так взять и договориться, или как мы работали со сложными людьми
 
Знакомьтесь, DevOps
Знакомьтесь, DevOpsЗнакомьтесь, DevOps
Знакомьтесь, DevOps
 
DevOps in real life
DevOps in real lifeDevOps in real life
DevOps in real life
 
Codeless: автоматизация тестирования
Codeless: автоматизация тестированияCodeless: автоматизация тестирования
Codeless: автоматизация тестирования
 
Selenoid
SelenoidSelenoid
Selenoid
 
Selenide
SelenideSelenide
Selenide
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"
 
Эмоциональный интеллект или как не сойти с ума в условиях сложного и динамичн...
Эмоциональный интеллект или как не сойти с ума в условиях сложного и динамичн...Эмоциональный интеллект или как не сойти с ума в условиях сложного и динамичн...
Эмоциональный интеллект или как не сойти с ума в условиях сложного и динамичн...
 
IT talk: Как я перестал бояться и полюбил TestNG
IT talk: Как я перестал бояться и полюбил TestNGIT talk: Как я перестал бояться и полюбил TestNG
IT talk: Как я перестал бояться и полюбил TestNG
 

Yeoman is awesome