Commit c05124c1 authored by Steve Streza's avatar Steve Streza
Browse files

Merge branch 'lerna' into 'master'

Lerna

See merge request microjournal/cli!1
parents 085751c3 161a049e
Pipeline #707 canceled with stage
......@@ -11,3 +11,6 @@ node_modules
.cache
lib
dist
# Lerna
lerna-debug.log
......@@ -2,6 +2,7 @@ image: node:6
before_script:
- npm install
- npm run bootstrap
cache:
paths:
......
#! /usr/bin/env node
import DataStore from "./src/data/database";
import FolderAccessor from "./src/data/accessors/folder";
import { join as joinPath } from "path"
import { homedir } from "os"
import * as Yargs from 'yargs'
Yargs
.usage("$0 [opts] <command> [args]")
.env("MICROJOURNAL")
.option("path", {
alias: "p",
default: joinPath(homedir(), ".microjournal"),
type: "string",
describe: "The path to the journal (defaults to ~/.microjournal"
})
.command("create <message>", "creates a new journal entry", yargs => yargs
.positional("message", {
alias: "m",
type: "string",
describe: "The message to post"
})
.positional("journal", {
alias: "j",
type: "string",
default: "default",
describe: "The name of the journal (defaults to \"default\")"
})
.demandOption(["message"])
, (argv: { [key: string]: any }) => {
const accessor = new FolderAccessor(argv.path);
const store = new DataStore(accessor);
const message: string = argv.message
const journal: string = argv.journal
if (message && journal) {
store.accessor
.create(journal, {
date: new Date(),
data: {
message
}
})
.subscribe({
error: error => {
console.error("ERROR: ", error);
process.exit(1)
}
});
}
})
.command("journals", "lists journals", yargs => yargs, (argv: { [key: string]: any }) => {
const accessor = new FolderAccessor(argv.path);
const store = new DataStore(accessor);
store.accessor.listJournals()
.subscribe({
next: j => {
console.log("" + j.slug)
}
})
})
.command("list [journal]", "lists the contents of the journal", yargs => yargs
.positional("journal", {
type: "string",
default: "default",
describe: "The name of the journal (defaults to \"default\")"
})
, (argv: any) => {
const accessor = new FolderAccessor(argv.path);
const store = new DataStore(accessor);
const journal: string = argv.journal
if (journal) {
store.accessor.list(journal)
.subscribe({
next: entry => {
if (entry.date) {
console.log("" + entry.date.toLocaleDateString() + " " + entry.date.toLocaleTimeString() + ": " + entry.data.message)
}
else {
console.log("" + entry.data.message)
}
}
})
}
})
.command("search [journal] [term]", "searches the messages in the journal for a given term", yargs => yargs
.positional("journal", {
type: "string",
default: "default",
describe: "The name of the journal (defaults to \"default\")"
})
.positional("term", {
type: "string",
describe: "The term to search for"
})
, (argv: any) => {
const accessor = new FolderAccessor(argv.path);
const store = new DataStore(accessor);
const term: string = argv.term
const journal: string = argv.journal
if (journal) {
store.accessor.search(term, journal)
.subscribe({
next: entry => {
if (entry.date) {
console.log("" + entry.date.toLocaleDateString() + " " + entry.date.toLocaleTimeString() + ": " + entry.data.message)
}
else {
console.log("" + entry.data.message)
}
}
})
}
})
.help()
.argv
{
"packages": ["packages/*"],
"hoist": false,
"version": "0.0.0"
}
This diff is collapsed.
......@@ -4,30 +4,25 @@
"description": "",
"main": "index.ts",
"scripts": {
"build": "tsc -d -p .",
"mj": "ts-node index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
"bootstrap": "lerna bootstrap --hoist",
"build": "lerna run build",
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rm -rf packages/*/lib",
"deep-clean": "rm -rf node_modules packages/*/node_modules packages/*/lib",
"full-rebuild": "npm run deep-clean && npm install && npm run bootstrap"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/bluebird": "^3.5.25",
"@types/mkdirp": "^0.5.2",
"@types/node": "^10.12.18",
"@types/yargs": "^12.0.5",
"lerna": "^3.2.1",
"ts-node": "^7.0.1",
"tslint": "^5.12.0",
"tslint": "^5.12.1",
"typescript": "^3.2.2"
},
"dependencies": {
"bluebird": "^3.5.3",
"fuse.js": "^3.3.0",
"mkdirp": "^0.5.1",
"readdir-rx": "0.1.2",
"rxjs": "^6.3.3",
"yargs": "^12.0.5"
},
"bin": {
"mj": "build/index.js"
"rxjs": "^6.3.3"
}
}
......@@ -3,7 +3,7 @@ import { flatMap, map } from "rxjs/operators";
type Fetcher = typeof fetch;
import { Journal, Record, Accessor } from "../accessor";
import { Journal, Record, Accessor } from "@microjournal/accessor";
type Options = {
listJournalsRoute?: string;
......
{
"name": "@microjournal/accessor-api",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"rxjs": {
"version": "6.3.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz",
"integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==",
"requires": {
"tslib": "1.9.3"
}
},
"tslib": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
}
}
}
{
"name": "@microjournal/accessor-api",
"version": "1.0.0",
"description": "",
"main": "lib/index.js",
"paths": {
"@microjournal": ["packages"]
},
"scripts": {
"build": "tsc -p .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@microjournal/accessor": "1.0.0",
"rxjs": "^6.3.3"
},
"devDependencies": {
"typescript": "^3.2.2"
}
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib"
},
"include": ["./index.ts"]
}
import { Observable, empty, of } from "rxjs";
import { Journal, Record, Accessor } from "../accessor";
import { Journal, Record, Accessor } from "@microjournal/accessor";
export default class EmptyAccessor implements Accessor {
listJournals(): Observable<Journal> {
......
{
"name": "@microjournal/accessor-empty",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"rxjs": {
"version": "6.3.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz",
"integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==",
"requires": {
"tslib": "1.9.3"
}
},
"tslib": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
}
}
}
{
"name": "@microjournal/accessor-empty",
"version": "1.0.0",
"description": "",
"main": "lib/index.js",
"paths": {
"@microjournal": ["packages"]
},
"scripts": {
"build": "tsc -p .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@microjournal/accessor": "1.0.0",
"rxjs": "^6.3.3",
"typescript": "^3.2.2"
}
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib"
},
"include": ["./index.ts"]
}
......@@ -2,7 +2,7 @@ import * as Bluebird from "bluebird";
import { Observable, from, empty } from "rxjs";
import { map, flatMap, concatMap, filter } from "rxjs/operators";
import { Record, Accessor, RecordData } from "../accessor";
import { Record, Accessor, RecordData } from "@microjournal/accessor";
import { join as joinPath, basename, dirname } from "path";
......
{
"name": "@microjournal/accessor-folder",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/bluebird": {
"version": "3.5.25",
"resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.25.tgz",
"integrity": "sha512-yfhIBix+AIFTmYGtkC0Bi+XGjSkOINykqKvO/Wqdz/DuXlAKK7HmhLAXdPIGsV4xzKcL3ev/zYc4yLNo+OvGaw==",
"dev": true
},
"@types/mkdirp": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-0.5.2.tgz",
"integrity": "sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg==",
"dev": true,
"requires": {
"@types/node": "10.12.18"
}
},
"@types/node": {
"version": "10.12.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz",
"integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==",
"dev": true
},
"bluebird": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz",
"integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw=="
},
"fuse.js": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-3.3.0.tgz",
"integrity": "sha512-ESBRkGLWMuVkapqYCcNO1uqMg5qbCKkgb+VS6wsy17Rix0/cMS9kSOZoYkjH8Ko//pgJ/EEGu0GTjk2mjX2LGQ=="
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
}
},
"readdir-rx": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/readdir-rx/-/readdir-rx-0.1.2.tgz",
"integrity": "sha512-Wy6DfdQO5thuUoiVkNJj9cFvHkK6dsONgdPmzANDoaS6d5NyAlyYmsH4LTPhBRfAbwLrGtwrzkUvyZfNDtmK+w==",
"requires": {
"rxjs": "6.3.3"
}
},
"rxjs": {
"version": "6.3.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz",
"integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==",
"requires": {
"tslib": "1.9.3"
}
},
"tslib": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
}
}
}
{
"name": "@microjournal/accessor-folder",
"version": "1.0.0",
"description": "",
"main": "lib/accessor-folder/index.js",
"paths": {
"@microjournal": ["packages"]
},
"scripts": {
"build": "tsc -p .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@microjournal/accessor": "1.0.0",
"rxjs": "^6.3.3",
"bluebird": "^3.5.3",
"mkdirp": "^0.5.1",
"readdir-rx": "^0.1",
"fuse.js": "^3.3.0"
},
"devDependencies": {
"@types/bluebird": "^3.5.25",
"@types/mkdirp": "^0.5.2",
"typescript": "^3.2.2"
}
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib"
},
"include": ["./index.ts"],
"exclude": ["node_modules"]
}
{
"name": "@microjournal/accessor",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"rxjs": {
"version": "6.3.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz",
"integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==",
"requires": {
"tslib": "1.9.3"
}
},
"tslib": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment