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

feat: add support for node 12 #5

Merged
merged 27 commits into from
Jun 1, 2020

Conversation

owenniblock
Copy link
Contributor

Motivation

We need to build things which are written with node 12. This breaking change will add node 12 support to this module.

Notes

I've updated all dependencies to the very latest versions (explicitly where not already handled by the package.json versioning). Tests are green but it you feel test coverage isn't sufficient to feel comfortable releasing this - let me know and we can discuss adding further tests.

c: [, , '3'],
d: [, , '4', '5'],
e: [, , '6', , 'hello'],
g: [, ,] // eslint-disable-line comma-spacing
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Latest standard complains about spaces after , and also having a space before ].

@coveralls
Copy link

coveralls commented May 20, 2020

Coverage Status

Coverage increased (+5.8%) to 100.0% when pulling da1a8e8 on owenniblock:fix/update-for-node12 into 1f6e032 on npm-wharf:master.

@owenniblock
Copy link
Contributor Author

Build broken on node 6 - I'm going to remove support for node 6 (let me know if you disagree with this decision and we can discuss what to do here) :)

@andrialexandrou
Copy link

having no context, i just might request that coverage go to 100% here to have an added assurance

src/writer.js Outdated Show resolved Hide resolved
@wraithgar
Copy link

If getting the test coverage up to 100% is prohibitive, I think at the very least what we should do is audit the lines that the coverage report say are missing and make sure we don't have another instance like with mkdirp where the function signature changed.

src/writer.js Outdated
}
})
mkdirp(dir).then(
() => { resolve() },
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 just pass the resolve function itself here? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lumaxis - I'm not sure - can you elaborate? (Sorry - my foo.js is weak 😂 )

Choose a reason for hiding this comment

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

mkdirp(dir).then(resolve, (err) => {})

Choose a reason for hiding this comment

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

I.e. instead of calling resolve() you can just pass a reference to resolve function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool - thanks! I'll try this (after I've got the tests working at all locally again :/ )

Choose a reason for hiding this comment

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

@owenniblock interrupting just for the js syntax -- is there a test that will ensure that we get into that error block? the syntax in this file doesn't look like js promises, but i don't want to suggest a change from that perspective, just from "is there a test that ensures we get to this block, and is it passing" and let the code be what it needs to.

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 believe I have all the lines covered by tests now so hopefully we've covered all eventualities.

@@ -114,4 +116,63 @@ describe('Config Mapper', function () {
writer.hasFiles(hashFive).should.equal(false)
writer.hasFiles(hashSix).should.equal(true)
})

it('should handle missing packagePath by not adding start', function () {
sinon.stub(fs, 'existsSync').returns(false)

Choose a reason for hiding this comment

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

Do we have to stub this if the file really doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From memory - this was the simplest way to trigger the code - logic is as follows:

  • Find the current project's package.json
  • Check that the path exists
  • If it does - perform the logic to get the start element
  • If it doesn't - don't add start element

Because the logic picks up the package.json from the kickerd project it was much simpler to stub the call to get this file so we could pretend it doesn't exist.

const stubPathResolve = sinon.stub(path, 'resolve')
stubPathResolve.onCall(0).returns(replacementPackagePath).callThrough()

const noPackagePath = configMapper.load('./spec/.kickerd.toml.one')

Choose a reason for hiding this comment

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

I'm a little confused as to why we pass in a fake name here and then try to stub the calls that the code uses to return the real file. Why not pass the actual filename here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're bypassing the call which would normally pick up the package.json from the root of kickerd - we point it to a test .json file which includes a start element in scripts and then check that we're including the custom start element.

src/config-mapper.js Outdated Show resolved Hide resolved
src/etcd.js Outdated Show resolved Hide resolved
Copy link
Contributor

@lumaxis lumaxis left a comment

Choose a reason for hiding this comment

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

Had a few ideas/comments/questions, nothing big though 🙂

Loving all these tests! 💯

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
@@ -33,10 +33,16 @@ function initConfig (hash) {
return hash
}

// NOTE: These tests cannot be run in isolation
Copy link
Contributor

Choose a reason for hiding this comment

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

😢

Out of curiosity, what's causing this limitation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests call out to an external etcd service which keeps state. We should probably look at mocking out these requests and responses at some point but it felt like I'd already spent long enough adding the tests to get the coverage up so I think that's a task for another day!

spec/etcd.spec.js Show resolved Hide resolved
spec/etcd.spec.js Outdated Show resolved Hide resolved
spec/kicker.spec.js Outdated Show resolved Hide resolved
spec/kicker.spec.js Outdated Show resolved Hide resolved
@wraithgar wraithgar self-requested a review June 1, 2020 14:10
Copy link

@wraithgar wraithgar left a comment

Choose a reason for hiding this comment

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

Next time we iterate on this code we should see about removing the magic that the sinon.stub is doing. Not this time though, this works for today.

@owenniblock owenniblock changed the title Update dependencies for node 12 support BREAKING CHANGE: add support for node 12 Jun 1, 2020
@owenniblock owenniblock changed the title BREAKING CHANGE: add support for node 12 feat: add support for node 12 Jun 1, 2020
@wraithgar wraithgar merged commit e9312a8 into npm-wharf:master Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants