Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,673 changes: 1,953 additions & 720 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"bugs": "https://github.com/hackmdio/hackmd-cli/issues",
"dependencies": {
"@hackmd/api": "^2.0.0",
"@oclif/core": "^1.3.6",
"@oclif/plugin-help": "^2.2.3",
"@oclif/plugin-version": "^1.0.4",
"@oclif/core": "2.8.2",
"@oclif/plugin-help": "5.2.9",
"@oclif/plugin-version": "1.3.3",
"cli-ux": "^5.4.4",
"fs-extra": "^8.1.0",
"lodash.defaults": "^4.2.0",
"oclif": "^2.5.0",
"oclif": "3.8.1",
"tslib": "^1.10.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/command.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import API from '@hackmd/api'
import {CliUx, Command} from '@oclif/core'
import {Command, ux} from '@oclif/core'

import config from './config'
import {setAccessTokenConfig} from './utils'

export default abstract class HackMDCommand extends Command {
async getAPIClient() {
const token = config.accessToken || await CliUx.ux.prompt('Enter your access token', {
const token = config.accessToken || await ux.prompt('Enter your access token', {
type: 'hide'
})
const APIClient = new API(token, config.hackmdAPIEndpointURL)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class Export extends HackMDCommand {

static flags = {
help: Flags.help({char: 'h'}),
noteId: noteId()
noteId
}

async run() {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/history.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CliUx, Flags} from '@oclif/core'
import {Flags, ux} from '@oclif/core'

import HackMDCommand from '../command'

Expand All @@ -15,7 +15,7 @@ BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null C

static flags = {
help: Flags.help({char: 'h'}),
...CliUx.ux.table.flags(),
...ux.table.flags(),
}

async run() {
Expand All @@ -25,7 +25,7 @@ BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null C
const APIClient = await this.getAPIClient()
const history = await APIClient.getHistory()

CliUx.ux.table(history, {
ux.table(history, {
id: {
header: 'ID',
},
Expand Down
16 changes: 8 additions & 8 deletions src/commands/notes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
CreateNoteOptions,
NotePermissionRole,
} from '@hackmd/api/dist/type'
import {CliUx, Flags} from '@oclif/core'
import {Flags, ux} from '@oclif/core'
import * as fs from 'fs'

import HackMDCommand from '../../command'
Expand Down Expand Up @@ -33,13 +33,13 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q

static flags = {
help: Flags.help({char: 'h'}),
title: noteTitle(),
content: noteContent(),
readPermission: notePermission(),
writePermission: notePermission(),
commentPermission: commentPermission(),
title: noteTitle,
content: noteContent,
readPermission: notePermission,
writePermission: notePermission,
commentPermission,
editor,
...CliUx.ux.table.flags(),
...ux.table.flags(),
}

async run() {
Expand Down Expand Up @@ -69,7 +69,7 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q
const APIClient = await this.getAPIClient()
const note = await APIClient.createNote(options)

CliUx.ux.table(
ux.table(
[note],
{
id: {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/notes/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class Delete extends HackMDCommand {

static flags = {
help: Flags.help({char: 'h'}),
noteId: noteId(),
noteId,
}

async run() {
Expand Down
8 changes: 4 additions & 4 deletions src/commands/notes/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CliUx, Flags} from '@oclif/core'
import {Flags, ux} from '@oclif/core'

import HackMDCommand from '../../command'
import {noteId} from '../../flags'
Expand All @@ -15,8 +15,8 @@ raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q n

static flags = {
help: Flags.help({char: 'h'}),
noteId: noteId(),
...CliUx.ux.table.flags(),
noteId,
...ux.table.flags(),
}

async run() {
Expand All @@ -26,7 +26,7 @@ raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q n
const APIClient = await this.getAPIClient()
const notes = flags.noteId ? [await APIClient.getNote(flags.noteId)] : await APIClient.getNoteList()

CliUx.ux.table(notes, {
ux.table(notes, {
id: {
header: 'ID',
},
Expand Down
4 changes: 2 additions & 2 deletions src/commands/notes/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default class Update extends HackMDCommand {

static flags = {
help: Flags.help({char: 'h'}),
noteId: noteId(),
content: noteContent()
noteId,
content: noteContent
}

async run() {
Expand Down
18 changes: 9 additions & 9 deletions src/commands/team-notes/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {CommentPermissionType, CreateNoteOptions, NotePermissionRole} from '@hackmd/api/dist/type'
import {CliUx, Flags} from '@oclif/core'
import {Flags, ux} from '@oclif/core'
import fs from 'fs'

import HackMDCommand from '../../command'
Expand All @@ -22,14 +22,14 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n

static flags = {
help: Flags.help({char: 'h'}),
teamPath: teamPath(),
title: noteTitle(),
content: noteContent(),
readPermission: notePermission(),
writePermission: notePermission(),
commentPermission: commentPermission(),
teamPath,
title: noteTitle,
content: noteContent,
readPermission: notePermission,
writePermission: notePermission,
commentPermission,
editor,
...CliUx.ux.table.flags(),
...ux.table.flags(),
}

async run() {
Expand Down Expand Up @@ -64,7 +64,7 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
const APIClient = await this.getAPIClient()
const note = await APIClient.createTeamNote(teamPath, options)

CliUx.ux.table([note], {
ux.table([note], {
id: {
header: 'ID',
},
Expand Down
4 changes: 2 additions & 2 deletions src/commands/team-notes/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default class Delete extends HackMDCommand {

static flags = {
help: Flags.help({char: 'h'}),
teamPath: teamPath(),
noteId: noteId(),
teamPath,
noteId,
}

async run() {
Expand Down
8 changes: 4 additions & 4 deletions src/commands/team-notes/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CliUx, Flags} from '@oclif/core'
import {Flags, ux} from '@oclif/core'

import HackMDCommand from '../../command'
import {teamPath} from '../../flags'
Expand All @@ -16,8 +16,8 @@ BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null CLI-test`,

static flags = {
help: Flags.help({char: 'h'}),
teamPath: teamPath(),
...CliUx.ux.table.flags(),
teamPath,
...ux.table.flags(),
}

async run() {
Expand All @@ -31,7 +31,7 @@ BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null CLI-test`,
const APIClient = await this.getAPIClient()
const notes = await APIClient.getTeamNotes(flags.teamPath)

CliUx.ux.table(notes, {
ux.table(notes, {
id: {
header: 'ID',
},
Expand Down
6 changes: 3 additions & 3 deletions src/commands/team-notes/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class Update extends HackMDCommand {

static flags = {
help: Flags.help({char: 'h'}),
teamPath: teamPath(),
noteId: noteId(),
content: noteContent()
teamPath,
noteId,
content: noteContent,
}

async run() {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/teams.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CliUx, Flags} from '@oclif/core'
import {Flags, ux} from '@oclif/core'

import HackMDCommand from '../command'

Expand All @@ -14,7 +14,7 @@ f76308a6-d77a-41f6-86d0-8ada426a6fb4 CLI test team CLI-test 82f7f3d9-4079-4c78-8

static flags = {
help: Flags.help({char: 'h'}),
...CliUx.ux.table.flags(),
...ux.table.flags(),
}

async run() {
Expand All @@ -24,7 +24,7 @@ f76308a6-d77a-41f6-86d0-8ada426a6fb4 CLI test team CLI-test 82f7f3d9-4079-4c78-8
const APIClient = await this.getAPIClient()
const notes = await APIClient.getTeams()

CliUx.ux.table(notes, {
ux.table(notes, {
id: {
header: 'ID',
},
Expand Down
6 changes: 3 additions & 3 deletions src/commands/whoami.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CliUx, Flags} from '@oclif/core'
import {Flags, ux} from '@oclif/core'

import HackMDCommand from '../command'

Expand All @@ -14,7 +14,7 @@ ID Name Email User path

static flags = {
help: Flags.help({char: 'h'}),
...CliUx.ux.table.flags(),
...ux.table.flags(),
}

async run() {
Expand All @@ -24,7 +24,7 @@ ID Name Email User path
const APIClient = await this.getAPIClient()
const user = await APIClient.getMe()

CliUx.ux.table([user], {
ux.table([user], {
id: {
header: 'ID',
},
Expand Down
12 changes: 6 additions & 6 deletions src/flags.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {Flags} from '@oclif/core'
export const noteId = Flags.build({
export const noteId = Flags.string({
description: 'HackMD note id'
})

export const teamPath = Flags.build({
export const teamPath = Flags.string({
description: 'HackMD team path'
})

export const noteContent = Flags.build({
export const noteContent = Flags.string({
description: 'new note content'
})

export const noteTitle = Flags.build({
export const noteTitle = Flags.string({
description: 'new note title'
})

export const notePermission = Flags.build({
export const notePermission = Flags.string({
description: 'set note permission: owner, signed_in, guest'
})

export const commentPermission = Flags.build({
export const commentPermission = Flags.string({
description: 'set comment permission: disabled, forbidden, owners, signed_in_users, everyone'
})

Expand Down