Best JavaScript code snippet using storybook-root
index.js
Source:index.js
...219 this._buildTemplateData();220 }221 },222 writing: function() {223 this.sourceRoot(path.join(__dirname, './templates/projects'));224 switch (this.type) {225 case 'web':226 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));227 this.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');228 this.template(this.sourceRoot() + '/Program.cs', this.applicationName + '/Program.cs', this.templatedata);229 this.template(this.sourceRoot() + '/Startup.cs', this.applicationName + '/Startup.cs', this.templatedata);230 this.template(this.sourceRoot() + '/Company.WebApplication1.csproj', this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata);231 this.copy(this.sourceRoot() + '/web.config', this.applicationName + '/web.config');232 /// Properties233 this.fs.copyTpl(this.templatePath('Properties/**/*'), this.applicationName + '/Properties', this.templatedata);234 this.copy(this.sourceRoot() + '/runtimeconfig.template.json', this.applicationName + '/runtimeconfig.template.json');235 this.fs.copy(this.sourceRoot() + '/README.md', this.applicationName + '/README.md');236 mkdirp.sync(this.applicationName + '/wwwroot');237 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);238 break;239 case 'webapi':240 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));241 this.fs.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');242 this.copy(this.sourceRoot() + '/appsettings.json', this.applicationName + '/appsettings.json');243 this.copy(this.sourceRoot() + '/appsettings.Development.json', this.applicationName + '/appsettings.Development.json');244 this.fs.copyTpl(this.sourceRoot() + '/Startup.cs', this.applicationName + '/Startup.cs', this.templatedata);245 this.fs.copyTpl(this.sourceRoot() + '/Program.cs', this.applicationName + '/Program.cs', this.templatedata);246 this.fs.copyTpl(this.sourceRoot() + '/Company.WebApplication1.csproj', this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata);247 this.fs.copyTpl(this.templatePath('Properties/**/*'), this.applicationName + '/Properties', this.templatedata);248 this.fs.copyTpl(this.sourceRoot() + '/Controllers/ValuesController.cs', this.applicationName + '/Controllers/ValuesController.cs', this.templatedata);249 this.fs.copy(this.sourceRoot() + '/web.config', this.applicationName + '/web.config');250 this.fs.copy(this.sourceRoot() + '/README.md', this.applicationName + '/README.md');251 mkdirp.sync(this.applicationName + '/wwwroot');252 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);253 break;254 case 'mvc':255 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));256 // individual files (configs, etc)257 this.fs.copy(this.templatePath('.bowerrc'), this.applicationName + '/.bowerrc');258 this.fs.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');259 this.fs.copyTpl(this.templatePath('appsettings.json'), this.applicationName + '/appsettings.json', this.templatedata);260 this.fs.copyTpl(this.templatePath('appsettings.Development.json'), this.applicationName + '/appsettings.Development.json', this.templatedata);261 this.fs.copyTpl(this.templatePath('bower.json'), this.applicationName + '/bower.json', this.templatedata);262 this.fs.copy(this.templatePath('bundleconfig.json'), this.applicationName + '/bundleconfig.json');263 this.fs.copy(this.templatePath('Company.WebApplication1.db'), this.applicationName + '/' + this.applicationName + '.db');264 this.fs.copyTpl(this.templatePath('Company.WebApplication1.csproj'), this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata);265 this.fs.copyTpl(this.templatePath('Program.cs'), this.applicationName + '/Program.cs', this.templatedata);266 this.fs.copy(this.templatePath('README.md'), this.applicationName + '/README.md');267 this.fs.copyTpl(this.templatePath('Startup.cs'), this.applicationName + '/Startup.cs', this.templatedata);268 // Controllers269 this.fs.copyTpl(this.templatePath('Controllers/AccountController.cs'), this.applicationName + '/Controllers/AccountController.cs', this.templatedata);270 this.fs.copyTpl(this.templatePath('Controllers/HomeController.cs'), this.applicationName + '/Controllers/HomeController.cs', this.templatedata);271 this.fs.copyTpl(this.templatePath('Controllers/ManageController.cs'), this.applicationName + '/Controllers/ManageController.cs', this.templatedata);272 // Migrations273 this.fs.copyTpl(this.templatePath('Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs'), this.applicationName + '/Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs', this.templatedata);274 this.fs.copyTpl(this.templatePath('Data/Migrations/00000000000000_CreateIdentitySchema.cs'), this.applicationName + '/Data/Migrations/00000000000000_CreateIdentitySchema.cs', this.templatedata);275 this.fs.copyTpl(this.templatePath('Data/Migrations/ApplicationDbContextModelSnapshot.cs'), this.applicationName + '/Data/Migrations/ApplicationDbContextModelSnapshot.cs', this.templatedata);276 this.fs.copyTpl(this.templatePath('Data/ApplicationDbContext.cs'), this.applicationName + '/Data/ApplicationDbContext.cs', this.templatedata);277 // Models278 this.fs.copyTpl(this.templatePath('Models/ApplicationUser.cs'), this.applicationName + '/Models/ApplicationUser.cs', this.templatedata);279 this.fs.copyTpl(this.templatePath('Models/AccountViewModels/**/*'), this.applicationName + '/Models/AccountViewModels', this.templatedata);280 this.fs.copyTpl(this.templatePath('Models/ManageViewModels/**/*'), this.applicationName + '/Models/ManageViewModels', this.templatedata);281 // Properties282 this.fs.copyTpl(this.templatePath('Properties/**/*'), this.applicationName + '/Properties', this.templatedata);283 // Services284 this.fs.copyTpl(this.templatePath('Services/IEmailSender.cs'), this.applicationName + '/Services/IEmailSender.cs', this.templatedata);285 this.fs.copyTpl(this.templatePath('Services/ISmsSender.cs'), this.applicationName + '/Services/ISmsSender.cs', this.templatedata);286 this.fs.copyTpl(this.templatePath('Services/MessageServices.cs'), this.applicationName + '/Services/MessageServices.cs', this.templatedata);287 // Views288 this.fs.copyTpl(this.templatePath('Views/**/*'), this.applicationName + '/Views', this.templatedata);289 // wwwroot290 // wwwroot - the content in the wwwroot does not include any direct references or imports291 // So again it is copied 1-to-1 - but tests cover list of all files292 this.fs.copy(this.templatePath('wwwroot/**/*'), this.applicationName + '/wwwroot');293 this.fs.copy(this.templatePath('web.config'), this.applicationName + '/web.config');294 // UI Component Overrides295 // If the developer has placed anything in overrides/ui-module/project-type/**/* then use it296 this.fs.copyTpl(this.templatePath('/../../overrides/' + this.ui + '/' + this.type + '/**/*'), this.applicationName + '/', this.templatedata);297 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);298 break;299 case 'mvcbasic':300 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));301 // individual files (configs, etc)302 this.fs.copy(this.templatePath('.bowerrc'), this.applicationName + '/.bowerrc');303 this.fs.copy(this.templatePath('bundleconfig.json'), this.applicationName + '/bundleconfig.json');304 this.fs.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');305 this.fs.copyTpl(this.templatePath('bower.json'), this.applicationName + '/bower.json', this.templatedata);306 this.fs.copyTpl(this.templatePath('appsettings.json'), this.applicationName + '/appsettings.json', this.templatedata);307 this.fs.copyTpl(this.templatePath('appsettings.Development.json'), this.applicationName + '/appsettings.Development.json', this.templatedata);308 this.fs.copyTpl(this.templatePath('Company.WebApplication1.csproj'), this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata);309 this.fs.copyTpl(this.templatePath('Program.cs'), this.applicationName + '/Program.cs', this.templatedata);310 // Properties311 this.fs.copyTpl(this.templatePath('Properties/**/*'), this.applicationName + '/Properties', this.templatedata);312 this.fs.copy(this.templatePath('README.md'), this.applicationName + '/README.md');313 this.fs.copyTpl(this.templatePath('Startup.cs'), this.applicationName + '/Startup.cs', this.templatedata);314 this.fs.copyTpl(this.templatePath('web.config'), this.applicationName + '/web.config', this.templatedata);315 // Controllers316 this.fs.copyTpl(this.templatePath('Controllers/HomeController.cs'), this.applicationName + '/Controllers/HomeController.cs', this.templatedata);317 // Views318 this.fs.copyTpl(this.templatePath('Views/**/*'), this.applicationName + '/Views', this.templatedata);319 // wwwroot - the content in the wwwroot does not include any direct references or imports320 // So again it is copied 1-to-1 - but tests cover list of all files321 this.fs.copy(this.templatePath('wwwroot/**/*'), this.applicationName + '/wwwroot');322 // UI Component Overrides323 // If the developer has placed anything in overrides/ui-module/project-type/**/* then use it324 this.fs.copyTpl(this.templatePath('/../../overrides/' + this.ui + '/' + this.type + '/**/*'), this.applicationName + '/', this.templatedata);325 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);326 break;327 case 'nancy':328 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));329 this.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');330 this.template(this.sourceRoot() + '/Startup.cs', this.applicationName + '/Startup.cs', this.templatedata);331 this.fs.copyTpl(this.templatePath('NancyTemplate.csproj'), this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata);332 this.template(this.sourceRoot() + '/HomeModule.cs', this.applicationName + '/HomeModule.cs', this.templatedata);333 this.template(this.sourceRoot() + '/Program.cs', this.applicationName + '/Program.cs', this.templatedata);334 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);335 break;336 case 'console':337 this.sourceRoot(path.join(__dirname, '../templates/projects/console'));338 this.fs.copy(path.join(__dirname, '../templates/gitignore.txt'), this.applicationName + '/.gitignore');339 this.fs.copyTpl(this.templatePath('Program.cs'), this.applicationName + '/Program.cs', this.templatedata);340 this.fs.copyTpl(this.templatePath('Company.ConsoleApplication1.csproj'), this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata);341 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);342 break;343 case 'classlib':344 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));345 this.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');346 this.template(this.sourceRoot() + '/Class1.cs', this.applicationName + '/Class1.cs', this.templatedata);347 this.fs.copyTpl(this.sourceRoot() + '/Company.ClassLibrary1.csproj', this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata);348 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);349 break;350 case 'xunit':351 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));352 this.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');353 this.template(this.sourceRoot() + '/UnitTest1.cs', this.applicationName + '/UnitTest1.cs', this.templatedata);354 this.template(this.sourceRoot() + '/Company.TestProject1.csproj', this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata);355 this.copy(this.sourceRoot() + '/xunit.runner.json', this.applicationName + '/xunit.runner.json');356 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);357 break;358 case 'mstest':359 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));360 this.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');361 this.template(this.sourceRoot() + '/UnitTest1.cs', this.applicationName + '/UnitTest1.cs', this.templatedata);362 this.template(this.sourceRoot() + '/Company.TestProject1.csproj', this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata);363 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);364 break;365 //F# Cases366 case 'fsharp_classlib':367 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));368 this.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');369 this.template(this.sourceRoot() + '/Library.fs', this.applicationName + '/Library.fs', this.templatedata);370 this.fs.copyTpl(this.sourceRoot() + '/Company.ClassLibrary1.fsproj', this.applicationName + '/' + this.applicationName + '.fsproj', this.templatedata);371 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);372 break;373 case 'fsharp_console':374 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));375 this.fs.copy(path.join(__dirname, '../templates/gitignore.txt'), this.applicationName + '/.gitignore');376 this.fs.copyTpl(this.templatePath('Program.fs'), this.applicationName + '/Program.fs', this.templatedata);377 this.fs.copyTpl(this.templatePath('Company.ConsoleApplication1.fsproj'), this.applicationName + '/' + this.applicationName + '.fsproj', this.templatedata);378 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);379 break;380 case 'fsharp_web':381 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));382 this.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');383 this.template(this.sourceRoot() + '/Program.fs', this.applicationName + '/Program.fs', this.templatedata);384 this.template(this.sourceRoot() + '/Startup.fs', this.applicationName + '/Startup.fs', this.templatedata);385 this.template(this.sourceRoot() + '/Company.WebApplication1.fsproj', this.applicationName + '/' + this.applicationName + '.fsproj', this.templatedata);386 this.copy(this.sourceRoot() + '/web.config', this.applicationName + '/web.config');387 /// Properties388 this.fs.copyTpl(this.templatePath('Properties/**/*'), this.applicationName + '/Properties', this.templatedata);389 this.fs.copy(this.sourceRoot() + '/README.md', this.applicationName + '/README.md');390 this.fs.copyTpl(this.templatePath('/runtimeconfig.template.json'), this.applicationName + '/runtimeconfig.template.json', this.templatedata);391 mkdirp.sync(this.applicationName + '/wwwroot');392 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);393 break;394 case 'fsharp_webapi':395 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));396 this.fs.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');397 this.copy(this.sourceRoot() + '/appsettings.json', this.applicationName + '/appsettings.json');398 this.copy(this.sourceRoot() + '/appsettings.Development.json', this.applicationName + '/appsettings.Development.json');399 this.fs.copyTpl(this.sourceRoot() + '/Startup.fs', this.applicationName + '/Startup.fs', this.templatedata);400 this.fs.copyTpl(this.sourceRoot() + '/Program.fs', this.applicationName + '/Program.fs', this.templatedata);401 this.fs.copyTpl(this.sourceRoot() + '/Company.WebApplication1.fsproj', this.applicationName + '/' + this.applicationName + '.fsproj', this.templatedata);402 this.fs.copyTpl(this.templatePath('Properties/**/*'), this.applicationName + '/Properties', this.templatedata);403 this.fs.copyTpl(this.templatePath() + '/Controllers/**/*', this.applicationName + '/Controllers', this.templatedata);404 this.fs.copy(this.sourceRoot() + '/web.config', this.applicationName + '/web.config');405 this.fs.copy(this.sourceRoot() + '/README.md', this.applicationName + '/README.md');406 this.fs.copy(this.sourceRoot() + '/runtimeconfig.template.json', this.applicationName + '/runtimeconfig.template.json');407 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);408 break;409 case 'fsharp_mvcbasic':410 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));411 // individual files (configs, etc)412 this.fs.copy(this.templatePath('.bowerrc'), this.applicationName + '/.bowerrc');413 this.fs.copy(this.templatePath('bundleconfig.json'), this.applicationName + '/bundleconfig.json');414 this.fs.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');415 this.fs.copyTpl(this.templatePath('bower.json'), this.applicationName + '/bower.json', this.templatedata);416 this.fs.copyTpl(this.templatePath('appsettings.json'), this.applicationName + '/appsettings.json', this.templatedata);417 this.fs.copyTpl(this.templatePath('appsettings.Development.json'), this.applicationName + '/appsettings.Development.json', this.templatedata);418 this.fs.copyTpl(this.templatePath('Company.WebApplication1.fsproj'), this.applicationName + '/' + this.applicationName + '.fsproj', this.templatedata);419 this.fs.copyTpl(this.templatePath('Program.fs'), this.applicationName + '/Program.fs', this.templatedata);420 // Properties421 this.fs.copyTpl(this.templatePath('Properties/**/*'), this.applicationName + '/Properties', this.templatedata);422 this.fs.copy(this.templatePath('README.md'), this.applicationName + '/README.md');423 this.fs.copyTpl(this.templatePath('Startup.fs'), this.applicationName + '/Startup.fs', this.templatedata);424 this.fs.copyTpl(this.templatePath('web.config'), this.applicationName + '/web.config', this.templatedata);425 // Controllers426 this.fs.copyTpl(this.templatePath('Controllers/**/*'), this.applicationName + '/Controllers', this.templatedata);427 // Views428 this.fs.copyTpl(this.templatePath('Views/**/*'), this.applicationName + '/Views', this.templatedata);429 // wwwroot - the content in the wwwroot does not include any direct references or imports430 // So again it is copied 1-to-1 - but tests cover list of all files431 this.fs.copy(this.templatePath('wwwroot/**/*'), this.applicationName + '/wwwroot');432 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);433 break;434 case 'fsharp_xunit':435 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));436 this.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');437 this.fs.copyTpl(this.templatePath('Company.TestProject1.fsproj'), this.applicationName + '/' + this.applicationName + '.fsproj', this.templatedata);438 this.fs.copyTpl(this.templatePath('Tests.fs'), this.applicationName + '/Tests.fs', this.templatedata);439 this.fs.copy(this.sourceRoot() + '/xunit.runner.json', this.applicationName + '/xunit.runner.json');440 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);441 break;442 case 'fsharp_mstest':443 this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type));444 this.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore');445 this.fs.copyTpl(this.templatePath('Company.TestProject1.fsproj'), this.applicationName + '/' + this.applicationName + '.fsproj', this.templatedata);446 this.fs.copyTpl(this.templatePath('Tests.fs'), this.applicationName + '/Tests.fs', this.templatedata);447 this.fs.copy(this.sourceRoot() + '/xunit.runner.json', this.applicationName + '/xunit.runner.json');448 this.template(this.sourceRoot() + '/../../global.json', this.applicationName + '/global.json', this.templatedata);449 break;450 default:451 this.log('Unknown project type');452 }453 },454 /**455 * Called on the very end of Yo execution456 * Dependencies are installed only for web type457 * of projects that depends on client side libraries458 * and tools like Gulp or Grunt459 * Uses can skip installing dependencies using built-in yo460 * --skip-install option461 */462 end: function() {...
copyFiles.js
Source:copyFiles.js
1'use strict';2var fs = require('fs'),3 path = require('path'),4 jsonfile = require('jsonfile'),5 mkdirp = require('mkdirp'),6 printTitle = require('../helpers/printTitle');7function copyProjectFiles(self, destRoot, sourceRoot, cb){8 mkdirp(path.join(destRoot, 'src', 'bower_components'));9 mkdirp(path.join(destRoot, self.templateDest, self.jsDirPath));10 mkdirp(path.join(destRoot, self.templateDest, self.jsLibDirPath));11 mkdirp(path.join(destRoot, self.templateDest, self.imgDirPath));12 mkdirp(path.join(destRoot, self.templateDest, self.cssDirPath));13 mkdirp(path.join(destRoot, self.templateDest, self.cssLibDirPath));14 mkdirp(path.join(destRoot, self.templateDest, self.fontDirPath));15 self.fs.copy(16 path.join(sourceRoot, 'project/_editorconfig'),17 path.join(destRoot, '.editorconfig')18 );19 self.fs.copy(20 path.join(sourceRoot, 'project/_gitignore'),21 path.join(destRoot, '.gitignore')22 );23 self.fs.copy(24 path.join(sourceRoot, 'project/_gitattributes'),25 path.join(destRoot, '.gitattributes')26 );27 // self.fs.copyTpl(28 // path.join(sourceRoot, 'project/README.md'),29 // path.join(destRoot, 'README.md'),30 // templateContext31 // );32 cb();33}34function copyExpressFiles(self, destRoot, sourceRoot, cb){35 if(self.environmentOption === 'express'){36 self.fs.copy(37 path.join(sourceRoot, 'bin'),38 path.join(destRoot, self.mainDir, 'bin')39 );40 self.fs.copy(41 path.join(sourceRoot, 'routes'),42 path.join(destRoot, self.mainDir, 'routes')43 );44 self.fs.copy(45 path.join(sourceRoot, 'views'),46 path.join(destRoot, self.mainDir, 'views')47 );48 self.fs.copy(49 path.join(sourceRoot, 'app.js'),50 path.join(destRoot, self.mainDir, 'app.js')51 );52 self.fs.copy(53 path.join(sourceRoot, 'package.json'),54 path.join(destRoot, self.mainDir, 'package.json')55 );56 }57 cb();58}59function copyWordpressFiles(self, destRoot, sourceRoot, cb) {60 var wpRoot = path.join(sourceRoot, 'wordpress/blank-theme'),61 wpDest = path.join(destRoot, self.templateDest),62 templateContext = {63 themeAuthor: self.themeAuthor,64 themeAuthorEmail: self.themeAuthorEmail,65 themeName: self.themeName,66 themeNameSpace: self.themeNameSpace,67 jsDirPath: self.jsDirPath,68 jsLibDirPath: self.jsLibDirPath,69 cssDirPath: self.cssDirPath,70 cssLibDirPath: self.cssLibDirPath71 }72 if(self.environmentOption === 'wordpress' && self.wpBlankTheme === true) {73 self.fs.copy(74 path.join(wpRoot, '_inc'),75 path.join(wpDest, '_inc')76 );77 self.fs.copy(78 path.join(wpRoot, 'screenshot.png'),79 path.join(wpDest, 'screenshot.png')80 );81 self.fs.copyTpl(82 path.join(wpRoot, '404.php'),83 path.join(wpDest, '404.php'),84 templateContext85 );86 self.fs.copyTpl(87 path.join(wpRoot, 'archive.php'),88 path.join(wpDest, 'archive.php'),89 templateContext90 );91 self.fs.copyTpl(92 path.join(wpRoot, 'comments.php'),93 path.join(wpDest, 'comments.php'),94 templateContext95 );96 self.fs.copyTpl(97 path.join(wpRoot, 'footer.php'),98 path.join(wpDest, 'footer.php'),99 templateContext100 );101 self.fs.copyTpl(102 path.join(wpRoot, 'functions.php'),103 path.join(wpDest, 'functions.php'),104 templateContext105 );106 self.fs.copyTpl(107 path.join(wpRoot, 'header.php'),108 path.join(wpDest, 'header.php'),109 templateContext110 );111 self.fs.copyTpl(112 path.join(wpRoot, 'index.php'),113 path.join(wpDest, 'index.php'),114 templateContext115 );116 self.fs.copyTpl(117 path.join(wpRoot, 'options.php'),118 path.join(wpDest, 'options.php'),119 templateContext120 );121 self.fs.copyTpl(122 path.join(wpRoot, 'page.php'),123 path.join(wpDest, 'page.php'),124 templateContext125 );126 self.fs.copyTpl(127 path.join(wpRoot, 'search.php'),128 path.join(wpDest, 'search.php'),129 templateContext130 );131 self.fs.copyTpl(132 path.join(wpRoot, 'searchform.php'),133 path.join(wpDest, 'searchform.php'),134 templateContext135 );136 self.fs.copyTpl(137 path.join(wpRoot, 'sidebar.php'),138 path.join(wpDest, 'sidebar.php'),139 templateContext140 );141 self.fs.copyTpl(142 path.join(wpRoot, 'single.php'),143 path.join(wpDest, 'single.php'),144 templateContext145 );146 self.fs.copyTpl(147 path.join(wpRoot, 'style.css'),148 path.join(wpDest, 'style.css'),149 templateContext150 );151 }152 cb();153}154function copyH5bpFiles(self, destRoot, sourceRoot, cb) {155 var templateContext = {156 imgDirPath: self.imgDirPath157 }158 if(self.environmentOption === 'static') {159 self.fs.copyTpl(160 path.join(sourceRoot, 'website/browserconfig.xml'),161 path.join(destRoot, self.mainDir, 'browserconfig.xml'),162 templateContext163 );164 self.fs.copy(165 path.join(sourceRoot, 'website/htaccess.txt'),166 path.join(destRoot, self.mainDir, '.htaccess')167 );168 self.fs.copy(169 path.join(sourceRoot, 'website/crossdomain.xml'),170 path.join(destRoot, self.mainDir, 'crossdomain.xml')171 );172 self.fs.copy(173 path.join(sourceRoot, 'website/robots.txt'),174 path.join(destRoot, self.mainDir, 'robots.txt')175 );176 }177 cb();178}179function copyHtmlFiles(self, destRoot, sourceRoot, cb) {180 var templateContext = {181 environmentOption: self.environmentOption,182 imgDirPath: self.imgDirPath,183 cssDirPath: self.cssDirPath,184 jsDirPath: self.jsDirPath,185 jsLibDirPath: self.jsLibDirPath,186 modernizrOption: self.modernizrOption,187 analyticsOption: self.analyticsOption,188 jsScripts: self.jsScripts189 }190 if(self.environmentOption === 'static' || self.environmentOption === 'express') {191 switch (self.templateOption){192 case 'jade':193 if(self.environmentOption === 'express') {194 destRoot = path.join(destRoot, self.mainDir, 'views');195 } else {196 destRoot = path.join(destRoot, 'src/jade');197 }198 self.fs.copy(199 path.join(sourceRoot, 'jade'),200 destRoot201 );202 self.fs.copyTpl(203 path.join(sourceRoot, 'tpl/jade/index.jade'),204 path.join(destRoot, 'index.jade'),205 templateContext206 );207 self.fs.copyTpl(208 path.join(sourceRoot, 'tpl/jade/templates/layout.jade'),209 path.join(destRoot,'templates/layout.jade'),210 templateContext211 );212 break;213 case 'pug':214 if(self.environmentOption === 'express') {215 destRoot = path.join(destRoot, self.mainDir, 'views');216 } else {217 destRoot = path.join(destRoot, 'src/pug');218 }219 self.fs.copy(220 path.join(sourceRoot, 'pug'),221 destRoot);222 self.fs.copyTpl(223 path.join(sourceRoot, 'tpl/pug/index.pug'),224 path.join(destRoot, 'index.pug'),225 templateContext226 );227 self.fs.copyTpl(228 path.join(sourceRoot, 'tpl/pug/templates/layout.pug'),229 path.join(destRoot,'templates/layout.pug'),230 templateContext231 );232 break;233 case 'nunjucks':234 if(self.environmentOption === 'express') {235 destRoot = path.join(destRoot, self.mainDir, 'views');236 } else {237 destRoot = path.join(destRoot, 'src/nunjucks');238 }239 self.fs.copy(240 path.join(sourceRoot, 'nunjucks'),241 destRoot242 );243 self.fs.copyTpl(244 path.join(sourceRoot, 'tpl/nunjucks/base/layout.html'),245 path.join(destRoot,'base/layout.html'),246 templateContext247 );248 self.fs.copy(249 path.join(sourceRoot, 'nunjucks'),250 destRoot251 );252 break;253 default:254 self.fs.copyTpl(255 path.join(sourceRoot, 'website/index.html'),256 path.join(destRoot, self.mainDir, 'index.html'),257 templateContext258 );259 }260 }261 cb();262}263function copyJsFiles(self, destRoot, gulpRoot, sourceRoot, cb){264 var templateContext = {265 requireOption: self.requireOption,266 jqueryOption: self.jqueryOption,267 jsLibDirPath: self.jsLibDirPath,268 jsScriptsBower: self.jsScriptsBower,269 rootFolder: self.rootFolder,270 javascriptOption: self.javascriptOption,271 modernizrOption: self.modernizrOption,272 scriptsOption: self.scriptsOption273 }274 var ext = '.js';275 if(self.gulpTypeOption === 'coffee') ext = '.coffee';276 self.fs.copyTpl(277 path.join(sourceRoot, 'gulp-tasks/bower' + ext),278 path.join(gulpRoot, 'gulp-tasks/bower' + ext),279 templateContext280 );281 self.fs.copyTpl(282 path.join(sourceRoot, 'gulp-tasks/scripts' + ext),283 path.join(gulpRoot, 'gulp-tasks/scripts' + ext),284 templateContext285 );286 switch (self.javascriptOption){287 case 'coffee':288 self.fs.copyTpl(289 path.join(sourceRoot, 'coffee/main.coffee'),290 path.join(destRoot, 'src/coffee/main.coffee'),291 templateContext292 );293 break;294 default:295 self.fs.copyTpl(296 path.join(sourceRoot, 'js/main.js'),297 path.join(destRoot, 'src/js/main.js'),298 templateContext299 );300 }301 if(self.modernizrOption) {302 self.fs.copy(303 path.join(sourceRoot, 'modernizr'),304 path.join(destRoot, 'src/modernizr')305 );306 var ext = '.js';307 if(self.gulpTypeOption === 'coffee') {308 ext = '.coffee';309 }310 self.fs.copy(311 path.join(sourceRoot, 'gulp-tasks/modernizr' + ext),312 path.join(gulpRoot, 'gulp-tasks/modernizr' + ext),313 templateContext314 );315 }316 cb();317}318function copyImageFiles(self, destRoot, sourceRoot, cb) {319 self.fs.copy(320 path.join(sourceRoot, 'img'),321 path.join(destRoot, 'src/img')322 );323 cb();324};325function copyGulpFiles(self, destRoot, gulpRoot, sourceRoot, cb) {326 var templateContext = {327 environmentOption: self.environmentOption,328 templateOption: self.templateOption,329 jsDirPath: self.jsDirPath,330 cssDirPath: self.cssDirPath,331 mainDir: self.mainDir332 }333 var ext = '.js';334 if(self.gulpTypeOption === 'coffee') {335 ext = '.coffee';336 self.fs.copyTpl(337 path.join(sourceRoot, 'gulp/coffee_gulpfile.js'),338 path.join(gulpRoot, 'gulpfile.js'),339 templateContext340 );341 }342 self.fs.copy(343 path.join(sourceRoot, 'gulp/gulp-tasks/clean' + ext),344 path.join(gulpRoot, 'gulp-tasks/clean' + ext)345 );346 self.fs.copy(347 path.join(sourceRoot, 'gulp/gulp-tasks/images' + ext),348 path.join(gulpRoot, 'gulp-tasks/images' + ext)349 );350 self.fs.copyTpl(351 path.join(sourceRoot, 'gulp/gulpfile' + ext),352 path.join(gulpRoot, 'gulpfile' + ext),353 templateContext354 );355 self.fs.copyTpl(356 path.join(sourceRoot, 'gulp/gulp-tasks/browsersync' + ext),357 path.join(gulpRoot, 'gulp-tasks/browsersync' + ext),358 templateContext359 );360 switch (self.templateOption){361 case 'html':362 self.fs.copyTpl(363 path.join(sourceRoot, 'gulp/gulp-tasks/html' + ext),364 path.join(gulpRoot, 'gulp-tasks/html' + ext),365 templateContext366 );367 break;368 case 'jade':369 self.fs.copyTpl(370 path.join(sourceRoot, 'gulp/gulp-tasks/jade' + ext),371 path.join(gulpRoot, 'gulp-tasks/html' + ext),372 templateContext373 );374 break;375 case 'pug':376 self.fs.copyTpl(377 path.join(sourceRoot, 'gulp/gulp-tasks/pug' + ext),378 path.join(gulpRoot, 'gulp-tasks/html' + ext),379 templateContext380 );381 break;382 case 'nunjucks':383 self.fs.copyTpl(384 path.join(sourceRoot, 'gulp/gulp-tasks/nunjucks' + ext),385 path.join(gulpRoot, 'gulp-tasks/html' + ext),386 templateContext387 );388 break;389 }390 cb();391};392function copySvgIconsFiles(self, destRoot, gulpRoot, sourceRoot, cb) {393 if(self.svgiconsOption){394 self.fs.copy(395 path.join(sourceRoot, 'illustrator'),396 path.join(destRoot, 'src/icons/illustrator')397 );398 self.fs.copy(399 path.join(sourceRoot, 'svg'),400 path.join(destRoot, 'src/icons', self.svgIconSpriteName)401 );402 var ext = '.js';403 if(self.gulpTypeOption === 'coffee') {404 ext = '.coffee';405 }406 self.fs.copy(407 path.join(sourceRoot, 'gulp-tasks/svg' + ext),408 path.join(gulpRoot, 'gulp-tasks/svg' + ext)409 );410 }411 cb();412}413function copyIconFontFiles(self, destRoot, gulpRoot, sourceRoot, cb) {414 var templateContext = {415 customIconfontName: self.customIconfontName416 }417 if(self.customIconfontOption){418 self.fs.copy(419 path.join(sourceRoot, 'illustrator'),420 path.join(destRoot, 'src/iconfont/illustrator')421 );422 self.fs.copy(423 path.join(sourceRoot, 'svg'),424 path.join(destRoot, 'src/iconfont/svg')425 );426 // Template file427 switch(self.preproOption) {428 case 'scss':429 self.fs.copy(430 path.join(sourceRoot, 'template/_icons.scss'),431 path.join(destRoot, 'src/iconfont/template/_icons.scss')432 );433 self.fs.copy(434 path.join(sourceRoot, 'scss/_icons.scss'),435 path.join(destRoot, 'src/scss/modules/_icons.scss')436 );437 self.fs.copyTpl(438 path.join(sourceRoot, 'scss/_font-icn.scss'),439 path.join(destRoot, 'src/scss/base/fonts/_font-icn.scss'),440 templateContext441 );442 break;443 case 'stylus':444 self.fs.copy(445 path.join(sourceRoot, 'template/icons.styl'),446 path.join(destRoot, 'src/iconfont/template/icons.styl')447 );448 self.fs.copy(449 path.join(sourceRoot, 'stylus/icons.styl'),450 path.join(destRoot, 'src/stylus/modules/icons.styl')451 );452 self.fs.copyTpl(453 path.join(sourceRoot, 'stylus/font-icn.styl'),454 path.join(destRoot, 'src/stylus/base/fonts/font-icn.styl'),455 templateContext456 );457 break;458 case 'less':459 self.fs.copy(460 path.join(sourceRoot, 'template/icons.less'),461 path.join(destRoot, 'src/iconfont/template/icons.less')462 );463 self.fs.copy(464 path.join(sourceRoot, 'less/icons.less'),465 path.join(destRoot, 'src/less/modules/icons.less')466 );467 self.fs.copyTpl(468 path.join(sourceRoot, 'less/font-icn.less'),469 path.join(destRoot, 'src/less/base/fonts/font-icn.less'),470 templateContext471 );472 break;473 }474 var ext = '.js';475 if(self.gulpTypeOption === 'coffee') {476 ext = '.coffee';477 }478 self.fs.copy(479 path.join(sourceRoot, 'gulp-tasks/iconfont' + ext),480 path.join(gulpRoot, 'gulp-tasks/iconfont' + ext)481 );482 }483 cb();484}485function copyStyleFiles(self, destRoot, gulpRoot, sourceRoot, cb) {486 var wpRoot = path.join(sourceRoot, 'wordpress/blank-theme'),487 templateContext = {488 preproOption: self.preproOption,489 baseStyleOption: self.baseStyleOption,490 mqOption: self.mqOption,491 gridOption: self.gridOption,492 mixinOption: self.mixinOption,493 nodeModules: self.nodeModules,494 imgDir: self.imgDir,495 fontDir: self.fontDir,496 assetsDir: self.assetsDir,497 wpBlankTheme: self.wpBlankTheme,498 postcssOption: self.postcssOption,499 postcssPlugins: self.postcssPlugins,500 postcssCssNanoOption: self.postcssCssNanoOption501 }502 var ext = '.js';503 if(self.gulpTypeOption === 'coffee') {504 ext = '.coffee';505 }506 self.fs.copyTpl(507 path.join(sourceRoot, 'gulp-tasks/styles' + ext),508 path.join(gulpRoot, 'gulp-tasks/styles' + ext),509 templateContext510 );511 if(self.preproOption === 'scss') {512 self.fs.copy(513 path.join(sourceRoot, 'scss/base'),514 path.join(destRoot, 'src/scss/base')515 );516 self.fs.copy(517 path.join(sourceRoot, 'scss/modules'),518 path.join(destRoot, 'src/scss/modules')519 );520 self.fs.copy(521 path.join(sourceRoot, 'scss/pages'),522 path.join(destRoot, 'src/scss/pages')523 );524 self.fs.copy(525 path.join(sourceRoot, 'scss/playground'),526 path.join(destRoot, 'src/scss/playground')527 );528 self.fs.copy(529 path.join(sourceRoot, 'scss/themes'),530 path.join(destRoot, 'src/scss/themes')531 );532 self.fs.copy(533 path.join(sourceRoot, 'scss/views'),534 path.join(destRoot, 'src/scss/views')535 );536 self.fs.copy(537 path.join(sourceRoot, 'scss/tpl/base/_variables.scss'),538 path.join(destRoot, 'src/scss/base/_variables.scss')539 );540 self.fs.copyTpl(541 path.join(sourceRoot, 'scss/tpl/style.scss'),542 path.join(destRoot, 'src/scss/style.scss'),543 templateContext544 );545 switch (self.gridOption){546 case 'semantic':547 self.fs.copy(548 path.join(sourceRoot, 'scss/tpl/base/_semantic-grid.scss'),549 path.join(destRoot, 'src/scss/base/_grid.scss')550 );551 break;552 case 'jeet':553 self.fs.copy(554 path.join(sourceRoot, 'scss/tpl/base/jeet/'),555 path.join(destRoot, 'src/scss/base/jeet/')556 );557 self.fs.copyTpl(558 path.join(sourceRoot, 'scss/tpl/base/_grid.scss'),559 path.join(destRoot, 'src/scss/base/_grid.scss'),560 templateContext561 );562 break;563 default:564 self.fs.copyTpl(565 path.join(sourceRoot, 'scss/tpl/base/_grid.scss'),566 path.join(destRoot, 'src/scss/base/_grid.scss'),567 templateContext568 );569 }570 switch (self.baseStyleOption){571 case 'reset':572 self.fs.copy(573 path.join(sourceRoot, 'scss/tpl/reset/_reset.scss'),574 path.join(destRoot, 'src/scss/base/_reset.scss')575 );576 break;577 case 'normalize':578 self.fs.copy(579 path.join(sourceRoot, 'scss/tpl/reset/_normalize.scss'),580 path.join(destRoot, 'src/scss/base/_normalize.scss')581 );582 break;583 case 'sanitize':584 self.fs.copy(585 path.join(sourceRoot, 'scss/tpl/reset/_sanitize.scss'),586 path.join(destRoot, 'src/scss/base/_sanitize.scss')587 );588 break;589 }590 }591 if(self.preproOption === 'stylus') {592 self.fs.copy(593 path.join(sourceRoot, 'stylus/base'),594 path.join(destRoot, 'src/stylus/base')595 );596 self.fs.copy(597 path.join(sourceRoot, 'stylus/modules'),598 path.join(destRoot, 'src/stylus/modules')599 );600 self.fs.copy(601 path.join(sourceRoot, 'stylus/pages'),602 path.join(destRoot, 'src/stylus/pages')603 );604 self.fs.copy(605 path.join(sourceRoot, 'stylus/playground'),606 path.join(destRoot, 'src/stylus/playground')607 );608 self.fs.copy(609 path.join(sourceRoot, 'stylus/themes'),610 path.join(destRoot, 'src/stylus/themes')611 );612 self.fs.copy(613 path.join(sourceRoot, 'stylus/views'),614 path.join(destRoot, 'src/stylus/views')615 );616 self.fs.copy(617 path.join(sourceRoot, 'stylus/tpl/base/variables.styl'),618 path.join(destRoot, 'src/stylus/base/variables.styl')619 );620 self.fs.copyTpl(621 path.join(sourceRoot, 'stylus/tpl/style.styl'),622 path.join(destRoot, 'src/stylus/style.styl'),623 templateContext624 );625 switch (self.gridOption){626 case 'semantic':627 self.fs.copy(628 path.join(sourceRoot, 'stylus/tpl/base/semantic-grid.styl'),629 path.join(destRoot, 'src/stylus/base/grid.styl')630 );631 break;632 case 'jeet':633 self.fs.copy(634 path.join(sourceRoot, 'stylus/tpl/base/jeet/'),635 path.join(destRoot, 'src/stylus/base/jeet/')636 );637 break;638 default:639 self.fs.copyTpl(640 path.join(sourceRoot, 'stylus/tpl/base/grid.styl'),641 path.join(destRoot, 'src/stylus/base/grid.styl'),642 templateContext643 );644 }645 switch (self.baseStyleOption){646 case 'reset':647 self.fs.copy(648 path.join(sourceRoot, 'stylus/tpl/reset/reset.styl'),649 path.join(destRoot, 'src/stylus/base/reset.styl')650 );651 break;652 case 'normalize':653 self.fs.copy(654 path.join(sourceRoot, 'stylus/tpl/reset/normalize.styl'),655 path.join(destRoot, 'src/stylus/base/normalize.styl')656 );657 break;658 case 'sanitize':659 self.fs.copy(660 path.join(sourceRoot, 'stylus/tpl/reset/sanitize.styl'),661 path.join(destRoot, 'src/stylus/base/sanitize.styl')662 );663 break;664 }665 }666 if(self.preproOption === 'less') {667 self.fs.copy(668 path.join(sourceRoot, 'less/base'),669 path.join(destRoot, 'src/less/base')670 );671 self.fs.copy(672 path.join(sourceRoot, 'less/modules'),673 path.join(destRoot, 'src/less/modules')674 );675 self.fs.copy(676 path.join(sourceRoot, 'less/pages'),677 path.join(destRoot, 'src/less/pages')678 );679 self.fs.copy(680 path.join(sourceRoot, 'less/playground'),681 path.join(destRoot, 'src/less/playground')682 );683 self.fs.copy(684 path.join(sourceRoot, 'less/themes'),685 path.join(destRoot, 'src/less/themes')686 );687 self.fs.copy(688 path.join(sourceRoot, 'less/views'),689 path.join(destRoot, 'src/less/views')690 );691 self.fs.copy(692 path.join(sourceRoot, 'less/tpl/base/variables.less'),693 path.join(destRoot, 'src/less/base/variables.less')694 );695 self.fs.copyTpl(696 path.join(sourceRoot, 'less/tpl/style.less'),697 path.join(destRoot, 'src/less/style.less'),698 templateContext699 );700 switch (self.gridOption){701 case 'semantic':702 self.fs.copy(703 path.join(sourceRoot, 'less/tpl/base/semantic-grid.less'),704 path.join(destRoot, 'src/less/base/grid.less')705 );706 break;707 default:708 self.fs.copyTpl(709 path.join(sourceRoot, 'less/tpl/base/grid.less'),710 path.join(destRoot, 'src/less/base/grid.less'),711 templateContext712 );713 }714 switch (self.mixinOption){715 case 'lesshat':716 self.fs.copy(717 path.join(sourceRoot, 'less/tpl/mixins/lesshat.less'),718 path.join(destRoot, 'src/less/base/mixins/lesshat.less')719 );720 self.fs.copy(721 path.join(sourceRoot, 'less/tpl/mixins/lesshat-prefixed.less'),722 path.join(destRoot, 'src/less/base/mixins/lesshat-prefixed.less')723 );724 break;725 }726 switch (self.mqOption){727 case 'lessmq':728 self.fs.copy(729 path.join(sourceRoot, 'less/tpl/mixins/mq.less'),730 path.join(destRoot, 'src/less/base/mixins/mq.less')731 );732 self.fs.copy(733 path.join(sourceRoot, 'less/tpl/mixins/mq-prefixed.less'),734 path.join(destRoot, 'src/less/base/mixins/mq-prefixed.less')735 );736 break;737 }738 switch (self.baseStyleOption){739 case 'reset':740 self.fs.copy(741 path.join(sourceRoot, 'less/tpl/reset/reset.less'),742 path.join(destRoot, 'src/less/base/reset.less')743 );744 break;745 case 'normalize':746 self.fs.copy(747 path.join(sourceRoot, 'less/tpl/reset/normalize.less'),748 path.join(destRoot, 'src/less/base/normalize.less')749 );750 break;751 case 'sanitize':752 self.fs.copy(753 path.join(sourceRoot, 'less/tpl/reset/sanitize.less'),754 path.join(destRoot, 'src/less/base/sanitize.less')755 );756 break;757 }758 }759 if(self.wpBlankTheme){760 switch(self.preproOption) {761 case 'scss':762 self.fs.copy(763 path.join(wpRoot, 'wp-core.css'),764 path.join(destRoot, 'src/scss/base/_wp-core.scss')765 );766 break;767 case 'stylus':768 self.fs.copy(769 path.join(wpRoot, 'wp-core.css'),770 path.join(destRoot, 'src/stylus/base/wp-core.styl')771 );772 break;773 case 'less':774 self.fs.copy(775 path.join(wpRoot, 'wp-core.css'),776 path.join(destRoot, 'src/less/base/wp-core.less')777 );778 break;779 }780 }781 cb();782}783module.exports = {784 copyProjectFiles: copyProjectFiles,785 copyWordpressFiles: copyWordpressFiles,786 copyExpressFiles: copyExpressFiles,787 copyH5bpFiles: copyH5bpFiles,788 copyHtmlFiles: copyHtmlFiles,789 copyImageFiles: copyImageFiles,790 copySvgIconsFiles: copySvgIconsFiles,791 copyIconFontFiles: copyIconFontFiles,792 copyJsFiles: copyJsFiles,793 copyStyleFiles: copyStyleFiles,794 copyGulpFiles: copyGulpFiles...
Gruntfile.js
Source:Gruntfile.js
1module.exports = function(grunt) {2 var autoprefixer = require('autoprefixer');3 // Project configuration.4 grunt.initConfig({5 pkg: grunt.file.readJSON('package.json'),6 sourceRoot: 'assets',7 // use this one for wordpress builds 8 buildRoot: '../build/wp-content/themes/landmark/assets',9 // and target css in the root of the theme10 cssDest: '../build/wp-content/themes/landmark',11 jshint: {12 options: {13 force: true14 },15 all: ['<%= sourceRoot %>/js/script.js']16 },17 uglify: {18 dev: {19 options: {20 beautify: false,21 mangle: false22 },23 files: {24 '<%= buildRoot %>/js/script.min.js': [25 '<%= sourceRoot %>/js/jquery.bxslider.js',26 '<%= sourceRoot %>/js/script.js'27 ],28 '<%= buildRoot %>/js/ie-polys.js': [29 '<%= sourceRoot %>/js/pointer-events-polyfill.js',30 '<%= sourceRoot %>/js/html5shiv.min.js',31 '<%= sourceRoot %>/js/respond.min.js',32 ],33 '<%= buildRoot %>/js/picturefill.min.js' : '<%= sourceRoot %>/js/picturefill-3.0.1.js',34 '<%= buildRoot %>/js/justice.mapped.min.js' : '<%= sourceRoot %>/js/justice.mapped.min.js'35 }36 },37 dist: {38 files: {39 '<%= buildRoot %>/js/script.min.js': [40 '<%= sourceRoot %>/js/jquery.bxslider.js',41 '<%= sourceRoot %>/js/script.js'42 ],43 '<%= buildRoot %>/js/ie-polys.js': [44 '<%= sourceRoot %>/js/pointer-events-polyfill.js',45 '<%= sourceRoot %>/js/html5shiv.min.js',46 '<%= sourceRoot %>/js/respond.min.js',47 ],48 '<%= buildRoot %>/js/picturefill.min.js' : '<%= sourceRoot %>/js/picturefill-3.0.1.js'49 }50 }51 },52 sass: {53 dist: {54 files: {55 '<%= cssDest %>/style.css' : '<%= sourceRoot %>/sass/style.scss',56 '<%= cssDest %>/assets/css/fancybox.min.css' : '<%= sourceRoot %>/sass/fancybox.scss'57 }58 }59 },60 postcss: {61 options: {62 map: false, // inline sourcemaps63 unused: false,64 zindex: false,65 idents: false,66 processors: [67 require('pixrem')(), // add fallbacks for rem units68 require('autoprefixer')({browsers: 'last 2 versions'}), // add vendor prefixes69 require('cssnano')() // minify the result70 ]71 },72 dist: {73 src: '<%= cssDest %>/*.css'74 }75 },76 svg2png: {77 all: {78 files: [79 {80 src: ['<%= buildRoot %>/svg/*.svg'],81 dest: '<%= buildRoot %>/svg/png'82 }83 ]84 }85 },86 watch : {87 scripts: {88 files: ['<%= sourceRoot %>/js/**/*.js'],89 tasks: ['jshint', 'uglify:dev', 'watch']90 },91 stylesheets: {92 files: ['<%= sourceRoot %>/sass/**/*.scss'],93 tasks: ['sass', 'postcss', 'watch']94 },95 svg2png: {96 files: ['<%= buildRoot %>/svg/*.svg'],97 tasks: ['newer:svg2png']98 }99 }100 });101 // Load the plugins.102 grunt.loadNpmTasks('grunt-sass');103 grunt.loadNpmTasks('grunt-postcss');104 grunt.loadNpmTasks('grunt-contrib-jshint');105 grunt.loadNpmTasks('grunt-contrib-uglify');106 grunt.loadNpmTasks('grunt-contrib-watch');107 grunt.loadNpmTasks('grunt-newer');108 grunt.loadNpmTasks('grunt-svg2png');109 // Default task(s).110 grunt.registerTask('default', ['sass', 'postcss', 'jshint', 'uglify:dev', 'svg2png', 'watch']);// $ grunt111 grunt.registerTask('dist', ['sass', 'postcss', 'jshint', 'uglify:dist', 'svg2png']);// $ grunt dist...
Using AI Code Generation
1import { sourceRoot } from 'storybook-root-decorator';2sourceRoot(__dirname);3import { withRoot } from 'storybook-root-decorator';4import { storiesOf } from '@storybook/react';5storiesOf('Button', module)6 .addDecorator(withRoot(__dirname))7 .add('with text', () => (8 .add('with some emoji', () => (9 ));10import { sourceRoot } from 'storybook-root-decorator';11sourceRoot(__dirname);12import { withRoot } from 'storybook-root-decorator';13import { storiesOf } from '@storybook/react';14storiesOf('Button', module)15 .addDecorator(withRoot(__dirname))16 .add('with text', () => (17 .add('with some emoji', () => (18 ));19import { sourceRoot } from 'storybook-root-decorator';20sourceRoot(__dirname);21import { withRoot } from 'storybook-root-decorator';22import { storiesOf } from '@storybook/react';23storiesOf('Button', module)24 .addDecorator(withRoot(__dirname))25 .add('with text', () => (26 .add('with some emoji', () => (27 ));28import { sourceRoot } from 'storybook-root-decorator';29sourceRoot(__dirname);30import { withRoot } from 'storybook-root-decorator';31import { storiesOf } from '@storybook/react';32storiesOf('Button', module)33 .addDecorator(withRoot(__dirname))34 .add('
Using AI Code Generation
1import { configure } from '@storybook/react';2import { sourceRoot } from 'storybook-root-decorator';3sourceRoot(__dirname);4const req = require.context('../src', true, /.stories.tsx$/);5function loadStories() {6 req.keys().forEach(filename => req(filename));7}8configure(loadStories, module);9const path = require('path');10module.exports = ({ config }) => {11 config.resolve.alias['@'] = path.resolve(__dirname, '../src');12 return config;13};14import 'storybook-root-decorator/register';15import React from 'react';16import { storiesOf } from '@storybook/react';17import { withInfo } from '@storybook/addon-info';18import { withKnobs, text } from '@storybook/addon-knobs';19import { withRoot } from 'storybook-root-decorator';20import { Button } from '@/components';21storiesOf('Button', module)22 .addDecorator(withRoot)23 .addDecorator(withInfo)24 .addDecorator(withKnobs)25 .add('with text', () => (26 <Button>{text('label', 'Hello Button')}</Button>27 ));
Using AI Code Generation
1const path = require('path');2const root = require('storybook-root-require');3module.exports = {4 webpackFinal: async config => {5 config.module.rules.push({6 include: path.resolve(__dirname, root('../'))7 });8 return config;9 }10};11const path = require('path');12const root = require('storybook-root-require');13module.exports = async ({ config, mode }) => {14 config.module.rules.push({15 include: path.resolve(__dirname, root('../'))16 });17 return config;18};19ERROR in ./src/components/atoms/Link/Link.scss (./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js!./src/components/atoms/Link/Link.scss)20Module build failed (from ./node_modules/sass-loader/lib/loader.js):21@import "variables";22 in /var/lib/jenkins/workspace/MyApp/src/components/atoms/Link/Link.scss (line 1, column 1)23ERROR in ./src/components/atoms/Link/Link.scss (./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js!./src/components/atoms/Link/Link.scss)24Module build failed (from ./node_modules/sass-loader/lib/loader.js):25@import "variables";
Using AI Code Generation
1import { addDecorator } from '@storybook/react';2import { withSourceRoot } from 'storybook-source-root-decorator';3addDecorator(withSourceRoot(__dirname));4import { addDecorator } from '@storybook/react';5import { withSourceRoot } from 'storybook-addon-react-docgen';6addDecorator(withSourceRoot(__dirname));7import { addDecorator } from '@storybook/react';8import { withSourceRoot } from 'storybook-addon-react-docgen';9addDecorator(withSourceRoot(__dirname));10import { addDecorator } from '@storybook/react';11import { withSourceRoot } from 'storybook-addon-react-docgen';12addDecorator(withSourceRoot(__dirname));13import { addDecorator } from '@storybook/react';14import { withSourceRoot } from 'storybook-addon-react-docgen';15addDecorator(withSourceRoot(__dirname));16import { addDecorator } from '@storybook/react';17import { withSourceRoot } from 'storybook-addon-react-docgen';18addDecorator(withSourceRoot(__dirname));19import { addDecorator } from '@storybook/react';20import { withSourceRoot } from 'storybook-addon-react-docgen';21addDecorator(withSourceRoot(__dirname));22import { addDecorator } from '@storybook/react';23import { withSourceRoot } from 'storybook-addon-react-docgen';24addDecorator(withSourceRoot(__dirname));25import { addDecorator } from '@storybook/react';26import { withSourceRoot } from 'storybook-addon-react-docgen';27addDecorator(withSourceRoot(__dirname));28import { addDecorator } from '@storybook/react';29import { withSourceRoot } from 'storybook-addon-react-docgen';30addDecorator(withSourceRoot(__dirname));31import { addDecorator } from '@storybook/react';32import { withSourceRoot } from 'storybook-addon-react-docgen';
Using AI Code Generation
1import { addDecorator } from '@storybook/react';2import sourceRoot from 'storybook-root-decorator';3addDecorator(sourceRoot(__dirname));4import { setAddon, addDecorator } from '@storybook/react';5import { withInfo } from 'storybook-addon-react-docgen';6import sourceRoot from 'storybook-root-decorator';7setAddon(withInfo);8addDecorator(sourceRoot(__dirname));9import { setAddon, addDecorator } from '@storybook/react';10import { withInfo } from 'storybook-addon-jsx';11import sourceRoot from 'storybook-root-decorator';12setAddon(withInfo);13addDecorator(sourceRoot(__dirname));14import { setAddon, addDecorator } from '@storybook/react';15import { withInfo } from 'storybook-addon-react-docgen';16import sourceRoot from 'storybook-root-decorator';17setAddon(withInfo);18addDecorator(sourceRoot(__dirname));19import { setAddon, addDecorator } from '@storybook/react';20import { withInfo } from 'storybook-addon-jsx';21import sourceRoot from 'storybook-root-decorator';22setAddon(withInfo);23addDecorator(sourceRoot(__dirname));24import './test.js';25import sourceRoot from 'storybook-root-decorator';26addDecorator(sourceRoot(__dirname));
Using AI Code Generation
1import { addParameters } from '@storybook/react';2import { sourceRoot } from 'storybook-root-sourcemaps';3addParameters({4 sourceRoot: sourceRoot(__dirname)5});6const { sourceRoot } = require('storybook-root-sourcemaps');7module.exports = async ({ config }) => {8 config.module.rules.push({9 {10 options: {11 {12 }13 }14 }15 include: [sourceRoot(__dirname)]16 });17 return config;18};19module.exports = {20};21import { addParameters } from '@storybook/react';22import { sourceRoot } from 'storybook-root-sourcemaps';23addParameters({24 sourceRoot: sourceRoot(__dirname)25});26import '@storybook/addon-actions/register';27import '@storybook/addon-links/register';28{29}30{31 "compilerOptions": {
Using AI Code Generation
1import { sourceRoot } from 'storybook-root';2console.log(sourceRoot);3import { sourceRoot } from 'storybook-root';4console.log(sourceRoot);5import { sourceRoot } from 'storybook-root';6console.log(sourceRoot);7import { sourceRoot } from 'storybook-root';8console.log(sourceRoot);9import { sourceRoot } from 'storybook-root';10console.log(sourceRoot);11import { sourceRoot } from 'storybook-root';12console.log(sourceRoot);13import { sourceRoot } from 'storybook-root';14console.log(sourceRoot);15import { sourceRoot } from 'storybook-root';16console.log(sourceRoot);17import { sourceRoot } from 'storybook-root';18console.log(sourceRoot);19import { sourceRoot } from 'storybook-root';20console.log(sourceRoot);21import { sourceRoot } from 'storybook-root';22console.log(sourceRoot);23import { sourceRoot } from 'storybook-root';24console.log(sourceRoot);
Using AI Code Generation
1import { addDecorator } from "@storybook/react";2import { withSourceRoot } from "storybook-root-decorator";3addDecorator(withSourceRoot(__dirname));4import { addDecorator } from "@storybook/react";5import { withSourceRoot } from "storybook-root-decorator";6addDecorator(withSourceRoot(__dirname));7import { addDecorator } from "@storybook/react";8import { withSourceRoot } from "storybook-root-decorator";9addDecorator(withSourceRoot(__dirname));
Using AI Code Generation
1const sourceRoot = require('storybook-root').sourceRoot;2const path = require('path');3const srcPath = sourceRoot(path.join('src', 'test.js'));4console.log(srcPath);5const sourceRoot = require('storybook-root').sourceRoot;6const path = require('path');7const srcPath = sourceRoot(path.join('src', 'test.js'));8console.log(srcPath);9const sourceRoot = require('storybook-root').sourceRoot;10const path = require('path');11const srcPath = sourceRoot(path.join('src', 'test.js'));12console.log(srcPath);13const sourceRoot = require('storybook-root').sourceRoot;14const path = require('path');15const srcPath = sourceRoot(path.join('src', 'test.js'));16console.log(srcPath);17const sourceRoot = require('storybook-root').sourceRoot;18const path = require('path');19const srcPath = sourceRoot(path.join('src', 'test.js'));20console.log(srcPath);21const sourceRoot = require('storybook-root').sourceRoot;22const path = require('path');23const srcPath = sourceRoot(path.join('src', 'test.js'));24console.log(srcPath);25const sourceRoot = require('storybook-root').sourceRoot;26const path = require('path');27const srcPath = sourceRoot(path.join('src', 'test.js'));28console.log(srcPath);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!