Add node-engine to snapcraft.yaml #509

Merged
merged 16 commits into from May 26, 2016

Conversation

Projects
None yet
4 participants
Contributor

earnubs commented May 23, 2016

Allow the developer to set the version of node they want, the current plugin uses 4.2.2, LTS is 4.4.4 and higher versions enable more of ES2015 http://node.green/

snapcraft/plugins/nodejs.py
@@ -64,6 +63,9 @@ def schema(cls):
},
'default': [],
}
+ schema['properties']['node-engine'] = {
+ 'type': 'string'
@sergiusens

sergiusens May 23, 2016

Collaborator

maybe add a default to 4.4.4 here?

@earnubs

earnubs May 23, 2016

Contributor

Originally I did have the default, but I'm not sure it's exactly what you want because you're almost always going to have a default that is out of date, as such I thought it better to make the developer take full control of this, and no default...

@sergiusens

sergiusens May 24, 2016

Collaborator

Yes, but this breaks backwards compatibility so we now are stuck with it. We update snapcraft often enough that we can always keep it using the best choice available

snapcraft/plugins/nodejs.py
+ self._nodejs_tar = sources.Tar(
+ _get_nodejs_release(self.options.node_engine),
+ os.path.join(self.partdir, 'npm'))
+ except AttributeError:
@sergiusens

sergiusens May 23, 2016

Collaborator

by adding a default there is no need for this exception dance ;-)

@earnubs

earnubs May 23, 2016

Contributor

agreed

snapcraft/plugins/nodejs.py
+ _get_nodejs_release(self.options.node_engine),
+ os.path.join(self.partdir, 'npm'))
+ except AttributeError:
+ raise AttributeError('node-engine not defined in snapcraft.yaml')
@kyrofa

kyrofa May 23, 2016

Member

This probably means it needs to be required in the schema instead of deleting the required key on line 71.

@kyrofa

kyrofa May 23, 2016

Member

Not you, but the plugin currently deletes it on line 71. If you add the node-engine option to the required key, snapcraft will catch it when validating the YAML instead of your needing to do it here. See the copy plugin for an example of what you'll probably need to do.

@earnubs

earnubs May 23, 2016

Contributor

Thanks!

snapcraft/plugins/nodejs.py
@@ -64,6 +63,9 @@ def schema(cls):
},
'default': [],
}
+ schema['properties']['node-engine'] = {
@sergiusens

sergiusens May 23, 2016

Collaborator

this needs to be explained in the docstring above

@earnubs

earnubs May 23, 2016

Contributor

Done.

snapcraft/plugins/nodejs.py
+ # `node-engine` keyword is required, but `node-packages` is not.
+ schema['required'].append('node-engine')
+ schema['required'].remove('source')
+ schema['properties']['source']['default'] = '.'
@sergiusens

sergiusens May 24, 2016

Collaborator

Can we leave this one for later? default is a contentious topic and would be better applied across the board

Collaborator

sergiusens commented May 24, 2016

Thanks for this, looks good. Mind rebasing or mergin master in to get rid of whatever the conflict github mentions is?

Can one of the admins verify this patch?

snapcraft/plugins/nodejs.py
+ # `node-engine` keyword is required, but `node-packages` is not.
+ schema['required'].append('node-engine')
+ schema['required'].remove('source')
+ schema['properties']['source']['default'] = '.'
@kyrofa

kyrofa May 24, 2016

Member

I doubt you want this line here (defaulting the source to '.'). Also, the comment doesn't seem quite right. Perhaps:

# `node-engine` keyword is required, but `source` is not.
schema['required'].append('node-engine')
schema['required'].remove('source')

Stephen Stewart and others added some commits May 25, 2016

Collaborator

sergiusens commented May 26, 2016

OK, I am 👍 with this but the diff looks super weird

Member

kyrofa commented May 26, 2016

@earnubs mind rebasing please? I think that's why the diff looks odd, and that was our mistake, not yours-- sorry about that 😒 .

Merge branch 'master' of github.com:ubuntu-core/snapcraft into node-e…
…ngine

* 'master' of github.com:ubuntu-core/snapcraft:
  Run the integration tests against a local fake server when the user password is not in the environment. (#511)
  Correct autotools tests to use configflags (#521)
Contributor

earnubs commented May 26, 2016

@kyrofa for reasons I don't understand I cannot rebase this without getting stuck in an endless merge conflict loop :)

I've merged master and that seems to have cleared up the PR diff, but if you're not happy I'll submit a new PR (rather than figure out what's going on with this rebase).

Member

kyrofa commented May 26, 2016

@earnubs ah! That works just fine, thank you 😄 .

Collaborator

sergiusens commented May 26, 2016

ok to test

Collaborator

sergiusens commented May 26, 2016

ok to test

@kyrofa kyrofa merged commit d579b55 into snapcore:master May 26, 2016

4 checks passed

Examples tests Success
Details
autopkgtest Success
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.003%) to 95.66%
Details

josepht added a commit to josepht/snapcraft that referenced this pull request May 31, 2016

nodejs plugin: Support configurable node version (#509)
Currently the nodejs plugin is hard-coded to use version 4.2.2. This
commit adds a `node-engine` parameter to its schema to make that version
configurable.

LP: #1586104

kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017

nodejs plugin: Support configurable node version (#509)
Currently the nodejs plugin is hard-coded to use version 4.2.2. This
commit adds a `node-engine` parameter to its schema to make that version
configurable.

LP: #1586104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment