Closed tomgp closed 3 years ago
I was on Node 12 without realising and got
> supply
(node:4709) ExperimentalWarning: The ESM module loader is experimental.
file:///home/marcel/projects/datasupply/src/supply-cmd.js:8
import { Command } from 'commander';
^^^^^^^
SyntaxError: The requested module 'commander' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'commander';
const { Command } = pkg;
at ModuleJob._instantiate (internal/modules/esm/module_job.js:97:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:136:20)
at async Loader.import (internal/modules/esm/loader.js:179:24)```
Firstly, with now I'm running v14, it seems to work really nicely. Could we please find a way to test for the v12 error I found so we don't get passing tests for that situation?
I've got a few syntactical / naming type thoughts... :)
supply-config.json
- it feels more idiomatic to either use .datasupplyrc
(my preference) or datasupply.config.json
. Maybe we could allow a couple of different onestargetDirectories
config key the relative location of the source data files? If so it feels misnamed from the point of view of the userexcludeDirectories
would be better served with a distinct .datasupplyignore
file (again idiomatically), perhaps optionallypolling-data.metadata.json
fields
object, with the title on a higher level object.Firstly, with now I'm running v14, it seems to work really nicely. Could we please find a way to test for the v12 error I found so we don't get passing tests for that situation?
Think I should be able to fix that (I thought I had )
I've got a few syntactical / naming type thoughts... :)
- I'm not a huge fan of
supply-config.json
- it feels more idiomatic to either use.datasupplyrc
(my preference) ordatasupply.config.json
. Maybe we could allow a couple of different ones
Agree .datasupplyrc
as the default is nice
- is the
targetDirectories
config key the relative location of the source data files? If so it feels misnamed from the point of view of the user
relative to the the location of the configuration file or in absence of that relative to the place where the command is invoked (I think, though let me check :) )
- IMO
excludeDirectories
would be better served with a distinct.datasupplyignore
file (again idiomatically), perhaps optionally
I'm not sure about this, I like the idea of being able to have 2 different configs and of having as much config as possible in one place. we could also have an ignore file but then we'd need to to think about which took precedence
- Although I understand the reasoning, I personally find YAML very easy to make errors in, and I wonder if we ought not to start with all config in JSON rather than using different formats for different types of config? I suggest it's called e.g.
polling-data.metadata.json
Agree, I've done it with YAML in the past because it works well when using things like Jekyll, with our typical stack json makes more sense
- I think the data-specific config could do with a little more structure - it would be more flexible and future-proof if e.g. the fields were inside a
fields
object, with the title on a higher level object.
this should be easier to do with JSON, I think there's a discussion to be had here about how prescriptive we want to be
- Specifically for that Date format in the data config, the way it's a second leaf on the branch for that field looks odd to my structural eye :)
Think I should be able to fix that (I thought I had )
I'm surprised the tests passed though - do you think they are missing something or was my setup at fault?
Based on feedback
Revisions:
Deferred:
cosmiconfig
Headlines
To see it working
npm link
to "install" the modulesupply
this should run the script using thesupply-config.json
file at the root. output appears in./example-output
. Note the slightly different structure for output JSON and that the 'polling-data' example now includes metadatasupply --config ./test/example-data/config-fixture.json
to try a different configuration fileBecause of the change to the JSON output format this PR is a breaking change
The detail
This PR has a number of changes from the current version. Mostly under the hood to do with refactoring but also adding the
supply
command and adding a means to add metadatacsv-parser
withd3-dsv
reasoning: we don't need to use streams 99% of the time and they make the code more involved/ difficult to reason with than just loading the hole file into memory in one gulp.commander
for passing in configuration