npm

draaft
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-alpha8 • Public • Published

Draaft

Draaft is a command line tool that simply allows you to retrieve content produced on Pilot for statics sites generators. Pilot is a content production platform for marketing or communication teams.

🚨 Alpha version : This cli is absolutely not production ready and API is subject to changes 🚨

Installing

Using npm:

$ npm install -g draaft

Using yarn:

$ yarn global add draaft

Usage

$ npm install -g draaft
$ draaft COMMAND
running command...
$ draaft (-v|--version|version)
draaft/0.1.0-alpha8 darwin-x64 node-v12.18.3
$ draaft --help [COMMAND]
USAGE
  $ draaft COMMAND
...

Configuration

A configuration file with sensible defaults will be created for you in .draaft/config.json when you execute a first command. Only the API token will be prompted.

{
    // Base url of the API ( scheme + host + base path ).
    // You can change this value to force a specific version of the API.
    "apiBaseUrl": "https://app.pilot.pm/integrations/beta/",

    // The secret API token to authenticate yourself in the API
    "apiToken": "secretToken",

    // Should we make page bundles ?
    // If `true`, draaft will create a bundle for each item, containing the content and resources (images).
    // If `false`, all the resources will be created in the `/static/` directory
    "bundlePages": true,

    // The name of the field in `Item.content` that will be used for the page content.
    "contentFieldName": "body",

    // How should we serialize the frontmatter ?
    // Allowed values : "yaml" | "toml"
    "frontmatterFormat": "yaml"

    // Should we handle item translations, and if yes with which organization ?
    // Allowed values : "none" | "directory" | "filename"
    "i18nMode": "none",

    // When i18n is activated, and an item has no language defined, fallback on `i18nDefaultLanguage`
    "i18nDefaultLanguage": "en",

    // Should we create a top-directory with the channel name ?
    // If `true`, draaft will create all files into `/[destDir]/[channel.name]/`
    // If `false`, draaft will create all files into `/[destDir]/`
    "useChannelName": false,

    //Target Static Site Generator.
    // For now, only "hugo" is supported
    "ssg": "hugo"
}

Commands

draaft help [COMMAND]

display help for draaft

USAGE
  $ draaft help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

draaft layout

Create basic layout to display content

USAGE
  $ draaft layout

OPTIONS
  -f, --overwrite
  -h, --help       show CLI help
  -s, --ssg=ssg    Static site generator

See code: src/commands/layout.ts

draaft pull

Pull content and create files on disk

USAGE
  $ draaft pull

OPTIONS
  -h, --help                           show CLI help
  -o, --overwrite                      Empty destination directory before writing
  --channel=channel                    [int] [multiple] Channel to pull content from
  --dest=dest                          Destination directory where to write files
  --publicationState=publicationState  [int] [multiple] workflow state for a published content
  --ssg=hugo|gatsby                    [default: hugo] Your static site generator.

See code: src/commands/pull.ts

draaft states

List all workflow states

USAGE
  $ draaft states

OPTIONS
  -b, --backup  If file exists create backup
  -h, --help    show CLI help
  -s, --save    Save states as file for customisation

See code: src/commands/states.ts

draaft types [ID]

List all item types

USAGE
  $ draaft types [ID]

ARGUMENTS
  ID  ID of type

OPTIONS
  -b, --backup  If file exists create backup
  -h, --help    show CLI help
  -s, --save    Save content shema as file for customisation
  -w, --schema  Display content schema for each type

See code: src/commands/types.ts

Roadmap

Alpha

  • [x] Get content from channel
  • [x] hugo.io : Create _index.file for sections
  • [x] generate basic Hugo layout
  • [x] Data mapper : let user map Draaft response keys to Frontmatter (use Hugo archetype maybe)
  • [x] Generate page bundles
  • [x] Basic documentation

Beta

  • [ ] Generate data files for complex layout (eg. home page)
  • [ ] Option : Flat layout (with frontmatter menu infos + hierarchy)
  • [ ] Option : Merge frontmatter
  • [ ] hugo.io : i18n support
  • [ ] Select which pilot.pm workflow state map with the "draft" frontmatter key in Hugo

V1.0.0

  • [ ] Support Gatsby
  • [ ] Generate complete layout for Hugo and Gatsby with theme selector
  • [ ] Tests

Deploying to npm

Manually bump version number in package.json, then

[optionnal, only if a command has changed] yarn readme
yarn prepack
git add .
git commit
yarn publish

Readme

Keywords

Package Sidebar

Install

npm i draaft

Weekly Downloads

12

Version

0.1.0-alpha8

License

MIT

Unpacked Size

59.6 kB

Total Files

35

Last publish

Collaborators

  • mhby