I'm creating my first Yeoman Generator. I want to download an external zip containing a CMS and unzip it in the root. According to this thread this should be possible. Has this not been implemented yet? What do i need to copy over to my generator if not?
I have run generator generator and got my basic generator up. This is my code so far.
Generator.prototype.getVersion = function getVersion() {
  var cb   = this.async()
    , self = this
  this.log.writeln('Downloading Umbraco version 6.1.6')
  this.download('http://our.umbraco.org/ReleaseDownload?id=92348', '.');
}
This generates an error telling me that it "cannot find module 'download'". What is the correct syntax?
I did a little investigation for you.
There are two methods to download something with yeoman...
/**
 * Download a string or an array of files to a given destination.
 *
 * @param {String|Array} url
 * @param {String} destination
 * @param {Function} cb
 */
this.fetch(url, destination, cb)
/**
 * Fetch a string or an array of archives and extract it/them to a given
 * destination.
 *
 * @param {String|Array} archive
 * @param {String} destination
 * @param {Function} cb
 */
this.extract(archive, destination, cb)
The callback will pass an error if something went wrong.
There's also a method to download packages from Github.
/**
 * Remotely fetch a package from github (or an archive), store this into a _cache
 * folder, and provide a "remote" object as a facade API to ourself (part of
 * generator API, copy, template, directory). It's possible to remove local cache,
 * and force a new remote fetch of the package.
 *
 * ### Examples:
 *
 *     this.remote('user', 'repo', function(err, remote) {
 *       remote.copy('.', 'vendors/user-repo');
 *     });
 *
 *     this.remote('user', 'repo', 'branch', function(err, remote) {
 *       remote.copy('.', 'vendors/user-repo');
 *     });
 *
 *     this.remote('http://foo.com/bar.zip', function(err, remote) {
 *       remote.copy('.', 'vendors/user-repo');
 *     });
 *
 * When fetching from Github
 * @param {String} username
 * @param {String} repo
 * @param {String} branch
 * @param {Function} cb
 * @param {Boolean} refresh
 *
 * @also
 * When fetching an archive
 * @param {String} url
 * @param {Function} cb
 * @param {Boolean} refresh
 */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With