Repository navigation
Export solid-permissions constants - #129
Conversation
dan-f
left a comment
There was a problem hiding this comment.
I'm stoked about adding a lib directory for transpiled JS, 👍 to that!
That said I'm a bit skeptical about the practice of re-exporting other libraries. At the very least, I'll request that we don't mutate those libraries' APIs before re-exporting because it seems a bit subversive to me.
I also am curious about the testing situation. It looks like we now point our tests at the lib directory, which requires the build to be run. This definitely works, but a lot of test tools offer a hook for running the test (and source) code through babel in-memory when running the suite which seems a bit nicer.
| "lib", | ||
| "dist" | ||
| "dist", | ||
| "src" |
There was a problem hiding this comment.
This means that src will be distributed as part of the node package. I don't see any reason for this. People use npm to install JS which they can bundle into their apps, or run on Node, not to browse and edit source code.
If people want to see the source for a given release of solid-client they can browse on github for the tag of that release.
There was a problem hiding this comment.
No prob with removing it. I saw that we included the src dir in other libs, but maybe the thing to do is to not include it anywhere.
There was a problem hiding this comment.
That's my opinion, at least. It's not a big deal, but it avoids confusion, because sometimes the library consumer want's do do something like require('solid-client/lib/path/to/module'), and if there's a lib and a src, the choice could be ambiguous to that library consumer.
There was a problem hiding this comment.
Yeah, agreed. Will remove src/ from the npm files.
| "src" | ||
| ], | ||
| "scripts": { | ||
| "babel": "babel src -d lib", |
There was a problem hiding this comment.
Just a nitpick, but I'd prefer if this was called something like build-lib to indicate that it's the build scrip for the lib directory, rather than being named after the tool it uses.
There was a problem hiding this comment.
Also, a general question: were we not using es2015 previously?
We'll have to make the webpack builds use babel as well. I can point you to examples if you like.
There was a problem hiding this comment.
Sure, I can change it from babel to build-lib.
There was a problem hiding this comment.
Re 'not using es2015 previously' - I think previously it was in the dev dependencies, this PR moves it to regular dependencies.
There was a problem hiding this comment.
Oooh. It should definitely be in the devDependencies. The build system is only ever run in the dev environment.
| "preversion": "npm test", | ||
| "postversion": "git push --follow-tags", | ||
| "prepublish": "npm run build" | ||
| "postpublish": "git push --follow-tags", |
There was a problem hiding this comment.
Why did you change this from postversion to postpublish?
It's my opinion that you'd want to push the git tags whenever bumping the package version, whether or not you subsequently publish the package to npm.
There was a problem hiding this comment.
My logic here was -- the tags only make sense in the context of publishing.
If the push is done post-publish, it means that if publish fails, a developer can roll back the versioning slightly easier (locally, without having to change history on the remote repo).
There was a problem hiding this comment.
Good point, it's definitely important to make sure that a release works before pushing tags. But I'm pretty sure that's why we have that preversion hook to run the tests.
I don't feel strongly about this one, so I'm fine with this.
There was a problem hiding this comment.
On second pass, I actually think it's very important that we push tags whenever versioning, especially for a library that multiple folks work on. If we only ever push tags when publishing it's possible that two different developers bump the version at the same time independently and create a weird state of affairs in our git tree.
There was a problem hiding this comment.
That's fine. I'll change the script back to postversion
| const ns = require('solid-namespace')(rdf) | ||
| const acl = require('solid-permissions') | ||
| Object.assign(acl, acl.Authorization.acl) | ||
| acl.ALL_MODES = acl.Authorization.ALL_MODES |
There was a problem hiding this comment.
I'm of the opinion that it's not really solid-client's responsibility to re-export the libraries it uses, and especially that it shouldn't mutate the APIs of the libraries which it uses.
So in this example, if solid-permissions should export an ALL_MODES constant at the top level, then it's the responsibility of solid-permissions to do so. Though I think that namespacing within acl.Authorization makes sense.
There was a problem hiding this comment.
No prob. I can undo this part, and export the constants in solid-permissions.
| @@ -1,31 +0,0 @@ | |||
| module.exports = `@prefix acl: <http://www.w3.org/ns/auth/acl#>. | |||
There was a problem hiding this comment.
This acl-container-ttl.js test resource was left over from when we extracted the ACL code (and its tests + test resources) to its own solid-permission. Just forgot to delete this one.
| loaders: [ | ||
| { | ||
| test: /\.js$/, | ||
| // exclude: /(node_modules)/, |
There was a problem hiding this comment.
Oh, I made a comment above about how we should be using babel in the webpack build, not realizing that we already did. We definitely should not be deleting this, otherwise solid-client won't work in browsers.
There was a problem hiding this comment.
I removed it from the webpack config because it's made redundant -- the webpack entry point now points to lib/, which is already pre-transpiled.
There was a problem hiding this comment.
I see. I'd still recommend keeping this, and pointing webpack at the src directory because
- It removes a dependency on the state of the dev environment
- Everyone does it this way (I know, I know...)
| "postversion": "git push --follow-tags", | ||
| "prepublish": "npm run build" | ||
| "postpublish": "git push --follow-tags", | ||
| "prepublish": "npm run build && npm run test" |
There was a problem hiding this comment.
As a nitpick I'd rather see tests fail before attempting to run the build.
There was a problem hiding this comment.
No prob. I switched the order.
91529f9 to
5f6027b
Compare
solid.acl.*various constants,Authorization,PermissionSet, access modesbabel-cli, point tests tolib/instead ofsrc/, update configstest/resources/acl-container-ttl.jsfile (was moved tosolid-permissionspreviously)Closes issue #125.