Skip to content

Commit

Permalink
feat(cli): add initial cli file
Browse files Browse the repository at this point in the history
  • Loading branch information
nampdn committed Jan 25, 2018
1 parent aa8a2c7 commit a83a57a
Show file tree
Hide file tree
Showing 6 changed files with 965 additions and 57 deletions.
18 changes: 16 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"main": "dist/mosia.umd.js",
"module": "dist/mosia.es5.js",
"typings": "dist/types/mosia.d.ts",
"bin": {
"mosia": "dist/cli.umd.js"
},
"files": [
"dist"
],
Expand Down Expand Up @@ -87,6 +90,7 @@
},
"devDependencies": {
"@types/jest": "^22.0.0",
"@types/meow": "^3.6.2",
"@types/node": "^9.3.0",
"all-contributors-cli": "^4.10.1",
"colors": "^1.1.2",
Expand All @@ -104,18 +108,28 @@
"rimraf": "^2.6.1",
"rollup": "^0.55.0",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-copy": "^0.2.3",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.10.0",
"semantic-release": "^12.2.4",
"travis-deploy-once": "^4.3.3",
"ts-jest": "^22.0.0",
"ts-node": "^4.1.0",
"tslint": "^5.8.0",
"tslint-config-prettier": "^1.1.0",
"tslint-config-standard": "^7.0.0",
"typedoc": "^0.9.0",
"typescript": "^2.6.2",
"validate-commit-msg": "^2.12.2",
"travis-deploy-once": "^4.3.3"
"validate-commit-msg": "^2.12.2"
},
"dependencies": {
"chalk": "^2.3.0",
"conf": "^1.4.0",
"core-js": "^2.5.3",
"get-stdin": "^5.0.1",
"meow": "^4.0.0",
"ora": "^1.3.0",
"update-notifier": "^2.3.0"
}
}
68 changes: 37 additions & 31 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import sourceMaps from 'rollup-plugin-sourcemaps'
import camelCase from 'lodash.camelcase'
import typescript from 'rollup-plugin-typescript2'
import resolve from "rollup-plugin-node-resolve"
import commonjs from "rollup-plugin-commonjs"
import sourceMaps from "rollup-plugin-sourcemaps"
import camelCase from "lodash.camelcase"
import typescript from "rollup-plugin-typescript2"

const pkg = require('./package.json')
const pkg = require("./package.json")

const libraryName = 'mosia'
const libraryName = "mosia"

export default {
input: `src/${libraryName}.ts`,
output: [
{ file: pkg.main, name: camelCase(libraryName), format: 'umd' },
{ file: pkg.module, format: 'es' },
],
sourcemap: true,
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: 'src/**',
export default [
{
input: `src/cli.js`,
output: { file: "dist/cli.umd.js", format: "umd" },
},
plugins: [
// Compile TypeScript files
typescript(),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),
{
input: `src/${libraryName}.ts`,
output: [
{ file: pkg.main, name: camelCase(libraryName), format: "umd" },
{ file: pkg.module, format: "es" }
],
sourcemap: true,
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: "src/**"
},
plugins: [
// Compile TypeScript files
typescript(),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),

// Resolve source maps to the original source
sourceMaps(),
],
}
// Resolve source maps to the original source
sourceMaps()
]
}
]
14 changes: 14 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const meow = require('meow')
const Mosia = require('./mosia.umd')

const cli = () => {
return meow(`
Usage
$ mosia <command>
mosia
`)
}

const mosia = new Mosia()
mosia.cmd(cli())
11 changes: 7 additions & 4 deletions src/mosia.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Import here Polyfills if needed. Recommended core-js (npm i -D core-js)
// import "core-js/fn/array.find"
// ...
export default class DummyClass {}
import meow from 'meow'

export default class Mosia {
cmd(input: meow.Result) {
console.log(input)
}
}
6 changes: 3 additions & 3 deletions test/mosia.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import DummyClass from '../src/mosia'
import Mosia from '../src/mosia'

/**
* Dummy test
*/
describe('Dummy test', () => {
describe('Mosia test', () => {
it('works if true is truthy', () => {
expect(true).toBeTruthy()
})

it('DummyClass is instantiable', () => {
expect(new DummyClass()).toBeInstanceOf(DummyClass)
expect(new Mosia()).toBeInstanceOf(Mosia)
})
})
Loading

0 comments on commit a83a57a

Please sign in to comment.