Skip to content

"data init" command #63

@anuveyatsu

Description

@anuveyatsu

User stories:

  • As a publisher I want to simply and quickly build a data package for my dataset
    • so I don't need to know about data packages. [completely new to Data Packages]
    • so I don't need to build it by myself [Data Package experts]
  • As a publisher I want to add a resource to an existing data package so that it is included

Stuff to look at: https://github.com/frictionlessdata/datapackage-read-js/blob/master/datapackage-read.js#L15

Proposal
We can have a $ data init command that builds a datapackage.json file

Acceptance criteria

  • I can run $ data init and get a Data Package initialized
    • datapackage.json created with minimal properties + selected resources

Tasks

  • analyse algorithm and split into separate functions [1h]
  • promptFunction + tests [1h]
  • scanDir function + tests [1h]
  • addResource function + tests [2h]
  • init function + tests [2h]
  • binary function + help [30m]

Analysis

$ data init -h prints out nice descriptions about the command + about dp properties we are going to generate.

Algorithm:

Publisher runs data init:

  1. check if datapackage.json exists in cwd
    1. YES - ask if we should overwrite (not overwrite but extend)
    2. NO - create new one
  2. prompt for dp name, title
    1. provided
      1. valid -> proceed
      2. invalid -> warn publisher and prompt again
    2. not provided
      1. already exists -> proceed with old one
      2. does not exist -> warn publisher and prompt again
  3. starting from current directory for each file or directory ask: (for file) shall we add? For directory: shall we search?
    • Then recurse
  4. generate/update a datapackage.json file
  5. print a success message

shall we add following file "filename.ext"?
shall we scan following directory "foldername"?
shall we add ...?
...

ident = parseIdentifier(...)
// check it exists ...
dp = DataPackage.load(identifier.dataPackageJsonUrl || {})

inquirer work using the existing data for prompts
  1. Error out if exists and create from nothing
  2. Allow for existing and update appropriately
  3. Allow for explicit adding of resources

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions