1
1
mirror of https://github.com/jxnblk/mdx-deck.git synced 2024-11-29 13:58:02 +03:00

Add init cli

This commit is contained in:
Brent Jackson 2018-08-25 16:40:44 -04:00
parent a881996ce0
commit 0d44a7d33d
8 changed files with 173 additions and 0 deletions

View File

@ -7,3 +7,5 @@ test
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
templates
create-deck

8
create-deck/README.md Normal file
View File

@ -0,0 +1,8 @@
# npm init deck
Create mdx-deck presentations
```sh
npm init deck my-presentation
```

55
create-deck/cli.js Executable file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const meow = require('meow')
const chalk = require('chalk')
const initit = require('initit')
const logo = chalk.magenta('[mdx-deck]')
const log = (...args) => {
console.log(logo, ...args)
}
log.error = (...args) => {
console.log(chalk.red('[ERROR]'), ...args)
}
const template = 'jxnblk/mdx-deck/templates/basic'
const cli = meow(`
Usage
$ npm init deck my-presentation
$ npx create-deck my-presentation
`, {
booleanDefault: undefined,
flags: {
help: {
type: 'boolean',
alias: 'h'
},
version: {
type: 'boolean',
alias: 'v'
}
}
})
const [ name ] = cli.input
if (!name) {
cli.showHelp(0)
}
// todo: ensure directory doesn't exist
initit({ name, template })
.then(res => {
log('created mdx-deck')
process.exit(0)
})
.catch(err => {
log.error('failed to create mdx-deck')
log.error(err)
process.exit(1)
})

15
create-deck/package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "create-deck",
"version": "1.0.0",
"description": "Create mdx-deck presentations",
"bin": {
"create-deck": "cli.js"
},
"author": "Brent Jackson",
"license": "MIT",
"dependencies": {
"chalk": "^2.4.1",
"initit": "^1.0.0-2",
"meow": "^5.0.0"
}
}

40
templates/basic/README.md Normal file
View File

@ -0,0 +1,40 @@
# mdx-deck basic template
![screenshot](dist/card.png)
This was generated with [mdx-deck][]'s `npm init deck` command.
## Development
To run the presentation deck in development mode:
```sh
npm start
```
Edit the [`deck.mdx`](deck.mdx) file to get started.
## Exporting
To build the presentation deck as static HTML:
```sh
npm run build
```
To export a PDF:
```sh
npm run pdf
```
To export an image of the title slide:
```sh
npm run image
```
For more documentation see the [mdx-deck][] repo.
[mdx-deck]: https://github.com/jxnblk/mdx-deck

23
templates/basic/deck.mdx Normal file
View File

@ -0,0 +1,23 @@
import { Head } from 'mdx-deck'
export { default as theme } from './theme'
<Head>
<title>Presentation Title</title>
</Head>
# Hello
---
## Edit this file
To create your presentation
```notes
- Create speaker notes in fenced code blocks
```
---
<https://github.com/jxnblk/mdx-deck>

View File

@ -0,0 +1,18 @@
{
"private": true,
"version": "1.0.0",
"description": "Deck created with mdx-deck",
"scripts": {
"start": "mdx-deck deck.mdx",
"build": "mdx-deck build deck.mdx",
"pdf": "mdx-deck pdf deck.mdx",
"image": "mdx-deck screenshot deck.mdx",
"help": "mdx-deck"
},
"keywords": [],
"author": "Brent Jackson",
"license": "MIT",
"devDependencies": {
"mdx-deck": "^1.6.7"
}
}

12
templates/basic/theme.js Normal file
View File

@ -0,0 +1,12 @@
import theme from 'mdx-deck/themes'
export default {
...theme,
// Customize your presentation theme here.
//
// Read the docs for more info:
// https://github.com/jxnblk/mdx-deck/blob/master/docs/theming.md
// https://github.com/jxnblk/mdx-deck/blob/master/docs/themes.md
}