Skip to content
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

Return error if deploying Meteor runtime to node.js runtime #118

Merged
merged 5 commits into from Jul 5, 2016

Conversation

theworkflow
Copy link
Contributor

  • Return error if deploying to the wrong runtime
  • Return error if deploying an outdated version of Meteor to the Meteor runtime

Closes #117

var errMessage = 'You are deploying a %s project to a %s runtime. Please select the correct runtime.';
var minMeteorVersion = parseVersion(Project.supportedVersions.Meteor);

function parseVersion (str) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be above where it's being called (line 221)

@theworkflow
Copy link
Contributor Author

@franvarney updated

Return error if deploying an an outdated version of Meteor to the
Meteor runtime
*/
//-----------------------------------------------------------------------------
Project.prototype.detectProjectType = function (path, callback) {
async.waterfall([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this a waterfall?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For when we check all other project types. I did this for future reference

@theworkflow
Copy link
Contributor Author

updated

@theworkflow
Copy link
Contributor Author

I was thinking of moving all the code from line 236 to line 251 to a separate function that would check the version of whatever project type the user is deploying. What do you all think?

* @param {Boolean} Returns boolean
*/
//-----------------------------------------------------------------------------
Project.prototype.isSupported = function (srcVersion, runtime) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some tests for this? I think I see logic that won't work, would like to confirm:

isSupported('2.0.0', 'Meteor')
// return majorPass && minorPass && patchPass;
return true && false && true; // false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use a module like semver?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add some tests, but Meteor doesn't follow semver. This was discussed when testing the meteor version in the build image.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documenting comments IRL:

even if Meteor is not semver, this function is and should probably be replaced with semver.gte(srcVersion, minVersion)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced custom compatibility check with semver

expect(supported).to.equal(true);
done();
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test for 'badly' formatted versions (eg: 1.3.2.4)

@@ -761,8 +760,31 @@ Project.prototype.detectProjectType = function (path, callback) {
*/
//-----------------------------------------------------------------------------
Project.prototype.isSupported = function (srcVersion, runtime) {
var imageVersion, majorPass, minorPass, patchPass;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not rewrite semver, you can use that tested code by just handling the weird edge case for Meteor:

var input = 'METEOR@1.3.2.4'

var srcVersion = input.replace('METEOR@', '')
  .split('.')
  .slice(0, 3)
  .join('.')

// srcVersion === '1.3.2', ready for `semver.gte()`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be risky because of the way Meteor does versioning.. it's not semver. :/ I tried doing this in Demeteorizer for a while and had to make changes to the parsing logic to use semver every other Meteor release or so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is risky, what's the best way to do this? Or is this goal not accomplished?

function (files, next) {
if (files.indexOf('.meteor') !== -1) {
fs.readdir(path.join(dir, '.meteor'), next);
} else next('ok', false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you passing 'ok' then at line 794 setting err = null?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short circuit the waterfall without passing an actual error. i.e.: stop running but don't fail

}
], function (err, result) {
if (err === 'ok') err = null;
callback(err, result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you just pass null and ignore err?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing null means the waterfall calls the next function, this is an escape hatch

@franvarney
Copy link
Contributor

👍

@musgravejw
Copy link

PR looks ok to me. Maybe @jackboberg could confirm that issues have been addressed.

@jackboberg
Copy link
Contributor

👍 all my local tests performed as expected

@theworkflow theworkflow changed the title Return error if deploying to the wrong runtime. Return error if deploying Meteor runtime to node.js runtime Jul 5, 2016
@theworkflow theworkflow merged commit 4d3e76c into master Jul 5, 2016
@theworkflow theworkflow deleted the enhancement/check-runtime branch July 5, 2016 20:25
@dsjoerg
Copy link

dsjoerg commented Aug 12, 2016

I have a meteor 1.2 project that was happily running on modulus as a node.js runtime. Now when I go to deploy it, it's yelling at me about "You are deploying a Meteor project to a Node.js runtime". Is there a way around this?

@theworkflow
Copy link
Contributor Author

@dsjoerg Unfortunately you will have to downgrade your CLI. If you have a Meteor runtime option available, we recommend creating a new project under the Meteor runtime and deploying your source. If you prefer to not go this route, you will need to downgrade your CLI so the demeteorizer process happens locally.

@dsjoerg
Copy link

dsjoerg commented Aug 12, 2016

Thanks @HarlanJ that worked (after I found out how to downgrade CLI, Googling for downgrade meteor CLI gets you nowhere :\ )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants