Notes /
NPMThis page contains discussion and notes about using the Node Package Manager (npm) with Accessors. See npm for links to other pages about npm. Current DesignThe idea is to use the Node Package Manager ( If we don't use npm, then we will end up creating something very similar to npm. The Node community is very large and is where our work could likely have the most impact. The more we follow the Node/npm way, the more likely it is that people will use our work. For smaller platforms, we want to be able to easily deploy swarmlets that include the required accessors, which would be a subset of all the accessors and all the hosts.
We should have the following scopes:
Currently, we are optionally downloading accessor definitions from the accessors website. In practice, we almost never do this because we are running accessors in a development environment. Also, versioning of the accessors is not supported. Dependency management is hacked in, for example under Node, the serial accessor will attempt to npm install the serialport module if it is not present. This does not work very well. We could define a npm module that defines a swarmlet. The package.json would list which accessors and which versions of the accessors are required. The accessor in the @accessors npm scope would in turn define which modules in the @accessors-modules scope are required and which versions. The package.json file would also refer to the .js file that defines the accessor itself. Open questions:
We don't have to implement the npm accessors feature now, but if we keep the @accessors-modules scope, then we can implement the @accessors scope in the future. (Details below here are somewhat obsolete) IssuesModule NamingNPM requires that package names be lower case:
Outcome:
How much of the npm module system should we use?We have two npm packages
For the Node accessor host, we have these modules
We also have
One idea would be to break up the current accessor modules in the repository into separate modules. Below are some upsides:
Moving the accessorsCurrently, the Accessor_1.dtd gdp package.json README.md geodesy reports accessors-license.htm hosts robotics audio image services audioIo index.html signals build.xml index.json styles cameras jjsModules.nyc svn.html contextAware jsdoc test copyright.txt library toc.htm coverage localization trusted demo mutable tutorial deterministicTemporalSemantics net updateIndex devices node_modules utilities doc obsolete wiki Perhaps the directories that define accessors should be moved in to a lib subdirectory? This would take some work, but now is better than later. Another idea is to create to separate node organizations:
Restructuring ProposalTo check out the work in progress: svn co https://repo.eecs.berkeley.edu/svn/projects/icyphy/accessors/branches/npm-0-1/accessors accessors-npm The npm system includes support for dependencies and versioning, so we will use it. We can use npm for the accessors definitions themselves and the modules required by the accessors. First, we will try it with the Node host, then try other hosts. One point of discussion is that accessors are not modules. However accessors require a bunch of features that modules have such as versioning, dependency management, being downloaded from a central location. We can either use this nice, somewhat sane npm module system to support these features for accessors, or we can spend time reimplementing it all. I say that we should use npm. Scopingnpm supports scoping (https://docs.npmjs.com/misc/scope). I'd like to create two scopes: @accessors and @accessors-impl 1) @accessors would define the accessors definitions, for example, we would have @accessors/net/TCPSocketClient which would define the TCPSocketClient accessor as a npm module. (I'm not sure if we can have three deep directories like @accessors/net/TCPSocket. If we can't then we could go with @accessors-net/TCPSocket or some other idea) @accessors/common would define the common host module. 2) @accessors-modules (not sure about the name) would include the implementations of the modules required by the accessors. For example the TCPSocketClient accessor currently requires a socket module, which would be renamed to @accessors-impl/socket. Accessor hosts would provide host-specific implementations of these modules. For Cape Code, we could consider moving actor/lib/jjs/modules to actor/lib/jjs/@accessor-impl, or we could just have the Cape Code-specific require() function map @accessor-impl to modules. So require('@accessor-impl/') would find actor/lib/jjs/modules/socket/package.json, which already exists. One open question is: what would the development tree look like? Probably we would have directories that would contain the definitions of the modules. So, we would have
which would describe the TCPSocketClient accessor and include dependency and version information. The code itself would be in
The node host would have:
which would describe the socket implementation (including version info). An alternative would be to create separate repos for each module. This would make configuration and set up more difficult, but would be more in the npm spirit. We might as well bite the bullet and create git repos. In the near term, I'm proposing that not go with separate repos, but consider the possibility of supporting that in the future. Design Decisions
Cape Code Host NPM Design Decisions
moduleName = moduleName.replace(/@accessors-modules/, 'modules'); npm5npm 5 it not backward compatibile, so it gets its open npm5 page. See Also
|