bannertime / generator-bannertime

Yeoman generator to help build and manage HTML5 banner campaigns.
https://bannertime.github.io/
58 stars 35 forks source link

feat: copy format sub-generator #4

Closed pyramidium closed 8 years ago

pyramidium commented 8 years ago

Provide a method to generate a copy of a format using yo bannertime:copy. When called, the user will be prompted with the following questions:

joemidi commented 8 years ago

Played around with this feature on branch sub-generator-copy at: c12c8ce.

$ yo bannertime:copy
  _____             _   _
 |     |___ ___ _ _| |_|_|_____ ___
 |   --| . | . | | |  _| |     | -_|
 |_____|___|  _|_  |_| |_|_|_|_|___|
           |_| |___|

? Which banner do you want to copy? 
  bannertime-test-230x500 
  bannertime-test-300x250 
❯ bannertime-test-600x500
? Set the width of the banner: (300) 400
? Set the height of the banner: (250) 375
? What is the name of the new format?: bannertime-test-400x375
? What type of banner is it? DoubleClick
? Include vendor scripts for offline use? (y/N) n
 conflict src/index.html
? Overwrite src/index.html? (Ynaxdh) Y
    force src/index.html
   create src/bannertime-test-400x375/index.html
   create src/bannertime-test-400x375/styles/style.scss
   create src/bannertime-test-400x375/styles/base/_banner.scss
   create src/bannertime-test-400x375/styles/base/_preloader.scss
   create src/bannertime-test-400x375/js/banner.js
   create src/bannertime-test-400x375/js/banner.loader.js
   create src/bannertime-test-400x375/js/banner.animation.js
   create src/bannertime-test-400x375/images/logo.png
New banner format copied from: bannertime-test-600x500

This gets all the folders within the ./src folder and lists them as options to copy from, the files that it copies from are all images, js/banner.animation.js, styles/base/style.scss, styles/base/_banner.scss and styles/base/_preloader.scss, with a RegEx being performing on _banner.scss to update the $banner-width and $banner-height with the new dimensions.

The remaining files, index.html, js/banner.js, js/banner.animation.js are taken from the original templates, to allow the user to change the Ad platform at this stage.

    ├── bannertime-test-600x500
    │   ├── images
    │   ├── index.html
    │   ├── js
    │   │   ├── banner.animation.js
    │   │   ├── banner.js
    │   │   └── banner.loader.js
    │   └── styles
    │       ├── base
    │       │   ├── _banner.scss
    │       │   └── _preloader.scss
    │       └── style.scss