-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overhaul on upstream retrieval. #27
Conversation
generators/app/index.js
Outdated
var exec = require('child_process').execSync; | ||
var fs = require('fs-extra'); | ||
var path = require('path'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're cool with const
down below (node 6+) then we're cool with const
up here.
@@ -18,8 +21,7 @@ module.exports = Generator.extend({ | |||
'Welcome to the remarkable ' + chalk.red('PatternLabStarter') + ' generator! ' + this.pkg.version + '\nPlease be in the folder you want files in now.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParticleStarter
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still going to be pulling down PLS v9 for awhile.
generators/app/index.js
Outdated
}, | ||
|
||
configuring: function () { | ||
|
||
}, | ||
|
||
default: function () { | ||
var dest = options.themePath ? path.resolve(process.cwd(), options.themePath) : './'; | ||
const release = options['release'] || 'master' | ||
const release_path = release + '.tar.gz'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const release_path = `${release}.tar.gz`;
generators/app/index.js
Outdated
const release_path = release + '.tar.gz'; | ||
const compressed = _.last(_.split(release_path, '/')); | ||
const decompressed = _.replace('particle-' + release, '/', '-'); | ||
const download_url = 'https://github.com/phase2/particle/archive/' + release_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above for template literal approach to this.
generators/app/index.js
Outdated
const decompressed = _.replace('particle-' + release, '/', '-'); | ||
const download_url = 'https://github.com/phase2/particle/archive/' + release_path; | ||
const dest = options.themePath ? path.resolve(process.cwd(), options.themePath) : './'; | ||
const themeName = 'patternlab'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
particle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not trying to bring this to generator-particle just yet, simply continue to pull down the PLS 9 repo. I suppose you could have created a whole new repo... meh.
generators/app/index.js
Outdated
|
||
// @todo replace tarball retrieval & extraction with a Node library. | ||
try { | ||
this.log('Retrieving template from ' + download_url + '...'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already know that I'm going to suggest a template literal.
generators/app/index.js
Outdated
try { | ||
this.log('Retrieving template from ' + download_url + '...'); | ||
exec([ | ||
'curl --fail --silent -OL ' + download_url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template literal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one will be a literal template.
generators/app/index.js
Outdated
this.log('Retrieving template from ' + download_url + '...'); | ||
exec([ | ||
'curl --fail --silent -OL ' + download_url, | ||
'tar -xzf ' + compressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template literal.
generators/app/index.js
Outdated
} catch(error) { | ||
console.error('Could not "mkdir -p" the themePath.'); | ||
this.log.error('Could not create the theme path: ' + error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template literal.
generators/app/index.js
Outdated
fs.renameSync(decompressed, themePathFull) | ||
} catch(error) { | ||
console.error(error); | ||
this.log.error('Could not move theme into position: ' + error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template literal.
@@ -22,6 +26,10 @@ Extras can be installed with: | |||
yo pattern-lab-starter:extras |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different name here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you're getting at?
Because I addressed all understandable feedback.
A few little changes, but the heart of this is to minimize the amount of exec'd commands. I wanted to use a library such as tarball-extract (alluded to in #25) but that project depends on an ancient release of a node wget library that can't follow redirects, which immediately slams against Github's infrastructure.
This change adds a new --release flag to facilitate testing/using the generator with code other than master on the particle project.
There is also some general robustness improvements, such as failing earlier if curl asplodes, removing extra file copy and delete operations, and supporting the generator recursively creating the base directory of the theme in case someone specified a deeply nested location.
With this change I suppose I'll follow up with a v3.1.0 release.