Skip to content

Commit f7cdaab

Browse files
James TsaiJames Tsai
authored andcommitted
feat: update config test and run linter
1 parent b0f580b commit f7cdaab

16 files changed

Lines changed: 91 additions & 133 deletions

File tree

package-lock.json

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
"dependencies": {
1010
"@oclif/command": "^1.5.19",
1111
"@oclif/config": "^1.13.3",
12+
"@oclif/core": "^1.3.6",
1213
"@oclif/plugin-help": "^2.2.3",
1314
"@oclif/plugin-version": "^1.0.4",
1415
"cli-ux": "^5.4.4",
1516
"fs-extra": "^8.1.0",
1617
"inquirer": "^6.5.2",
1718
"lodash": "^4.17.15",
18-
"oclif": "^2.4.5",
19+
"oclif": "^2.5.0",
1920
"tslib": "^1.10.0"
2021
},
2122
"devDependencies": {
@@ -69,7 +70,7 @@
6970
"repository": "hackmdio/hackmd-cli",
7071
"scripts": {
7172
"postpack": "rm -f oclif.manifest.json",
72-
"posttest": "tslint -p test -t stylish",
73+
"posttest": "tslint -p test -t stylish --fix",
7374
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest",
7475
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
7576
"version": "oclif-dev readme && git add README.md"

src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import API from '@hackmd/api'
22

33
import config from './config'
44

5-
export const APIClient = new API(config.accesstoken as string, config.hackmdAPIEndpointURL)
5+
export const APIClient = new API(config.accesstoken as string, config.hackmdAPIEndpointURL)

src/commands/history.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import {Command, Flags, CliUx } from '@oclif/core'
1+
import {CliUx, Command, Flags} from '@oclif/core'
2+
23
import {APIClient} from '../api'
34

45
export default class History extends Command {
56
static description = 'List user browse history'
67

78
static examples = [
89
`$ hackmd-cli history
9-
ID Title User Path Team Path
10-
────────────────────── ──────────────────────────────── ────────────────────── ────────
11-
raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q null
10+
ID Title User Path Team Path
11+
────────────────────── ──────────────────────────────── ────────────────────── ────────
12+
raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q null
1213
BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null CLI-test `,
1314
]
1415

@@ -19,7 +20,7 @@ BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null C
1920

2021
async run() {
2122
const {flags} = await this.parse(History)
22-
23+
2324
try {
2425
const history = await APIClient.getHistory()
2526

@@ -29,7 +30,7 @@ BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null C
2930
},
3031
title: {},
3132
userPath: {
32-
header:'User Path'
33+
header: 'User Path'
3334
},
3435
teamPath: {
3536
header: 'Team Path'

src/commands/notes/create.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Command, Flags, CliUx} from '@oclif/core'
1+
import {CliUx, Command, Flags} from '@oclif/core'
22

33
import {APIClient} from '../../api'
44

@@ -7,10 +7,10 @@ export default class Create extends Command {
77

88
static examples = [
99
`notes create --content='# A new note' --readPermission=owner --writePermission=owner --commentPermission=disabled
10-
ID Title User Path Team Path
11-
────────────────────── ──────────────────────────────── ────────────────────── ────────
10+
ID Title User Path Team Path
11+
────────────────────── ──────────────────────────────── ────────────────────── ────────
1212
raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q null `
13-
]
13+
]
1414

1515
static flags = {
1616
help: Flags.help({char: 'h'}),
@@ -19,26 +19,26 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q
1919
readPermission: Flags.string(),
2020
writePermission: Flags.string(),
2121
commentPermission: Flags.string(),
22-
...CliUx.ux.table.flags(),
22+
...CliUx.ux.table.flags(),
2323
}
2424

2525
async run() {
2626
const {flags} = await this.parse(Create)
2727
const options = {...flags}
28-
28+
2929
try {
30-
// TODO: create note options typing
30+
// TODO: create note options typing
3131
const note = await APIClient.createNote(options as any)
3232

33-
CliUx.ux.table([note], {
33+
CliUx.ux.table([note], {
3434
id: {
3535
header: 'ID',
3636
},
3737
title: {},
3838
userPath: {
3939
header: 'User path'
4040
},
41-
teamPath:{
41+
teamPath: {
4242
header: 'Team path'
4343
}
4444
}, {
@@ -51,4 +51,3 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q
5151
}
5252
}
5353
}
54-

src/commands/notes/delete.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default class Delete extends Command {
66
static description = 'Delete a note'
77

88
static examples = [
9-
`$ hackmd-cli notes delete --noteId=WNkLM6gkS0Cg2cQ8rv7bYA`
9+
'$ hackmd-cli notes delete --noteId=WNkLM6gkS0Cg2cQ8rv7bYA'
1010
]
1111

1212
static flags = {
@@ -18,10 +18,10 @@ export default class Delete extends Command {
1818
const {flags} = await this.parse(Delete)
1919
const {noteId} = flags
2020

21-
if(!noteId) {
21+
if (!noteId) {
2222
this.error('Flag noteId could not be empty')
2323
}
24-
24+
2525
try {
2626
await APIClient.deleteNote(noteId)
2727
} catch (e) {
@@ -30,4 +30,3 @@ export default class Delete extends Command {
3030
}
3131
}
3232
}
33-

src/commands/notes/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import {Command, Flags, CliUx } from '@oclif/core'
1+
import {CliUx, Command, Flags} from '@oclif/core'
2+
23
import {APIClient} from '../../api'
34

45
export default class IndexCommand extends Command {
56
static description = 'HackMD notes commands'
67

78
static examples = [
89
`$ hackmd-cli notes
9-
ID Title User Path Team Path
10-
────────────────────── ──────────────────────────────── ────────────────────── ────────
10+
ID Title User Path Team Path
11+
────────────────────── ──────────────────────────────── ────────────────────── ────────
1112
raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q null `,
1213
]
1314

@@ -19,17 +20,17 @@ raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q n
1920

2021
async run() {
2122
const {flags} = await this.parse(IndexCommand)
22-
23+
2324
try {
24-
const notes = flags.noteId ? [await APIClient.getNote(flags.noteId)] : await APIClient.getNoteList()
25-
25+
const notes = flags.noteId ? [await APIClient.getNote(flags.noteId)] : await APIClient.getNoteList()
26+
2627
CliUx.ux.table(notes, {
2728
id: {
2829
header: 'ID',
2930
},
3031
title: {},
3132
userPath: {
32-
header:'User Path'
33+
header: 'User Path'
3334
},
3435
teamPath: {
3536
header: 'Team Path'

src/commands/notes/update.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default class Update extends Command {
66
static description = 'Update note content'
77

88
static examples = [
9-
`$ hackmd-cli notes update --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --content='# A new title'`
9+
"$ hackmd-cli notes update --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --content='# A new title'"
1010
]
1111

1212
static flags = {
@@ -19,10 +19,10 @@ export default class Update extends Command {
1919
const {flags} = await this.parse(Update)
2020
const {noteId, content} = flags
2121

22-
if(!noteId) {
22+
if (!noteId) {
2323
this.error('Flag noteId could not be empty')
2424
}
25-
25+
2626
try {
2727
await APIClient.updateNoteContent(noteId, content)
2828
} catch (e) {

src/commands/team-notes/create.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Command, Flags, CliUx} from '@oclif/core'
1+
import {CliUx, Command, Flags} from '@oclif/core'
22

33
import {APIClient} from '../../api'
44

@@ -7,10 +7,10 @@ export default class Create extends Command {
77

88
static examples = [
99
`team-notes:create --teamPath=CLI-test --content='# A new note' --readPermission=owner --writePermission=owner --commentPermission=disabled
10-
ID Title User Path Team Path
11-
────────────────────── ──────────────────────────────── ────────────────────── ────────
10+
ID Title User Path Team Path
11+
────────────────────── ──────────────────────────────── ────────────────────── ────────
1212
raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q null `
13-
]
13+
]
1414

1515
static flags = {
1616
help: Flags.help({char: 'h'}),
@@ -20,31 +20,31 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
2020
readPermission: Flags.string(),
2121
writePermission: Flags.string(),
2222
commentPermission: Flags.string(),
23-
...CliUx.ux.table.flags(),
23+
...CliUx.ux.table.flags(),
2424
}
2525

2626
async run() {
2727
const {flags} = await this.parse(Create)
2828
const {teamPath, title, content, readPermission, writePermission, commentPermission} = flags
2929
const options = {title, content, readPermission, writePermission, commentPermission}
3030

31-
if(!teamPath) {
31+
if (!teamPath) {
3232
this.error('Flag teamPath could not be empty')
3333
}
34-
34+
3535
try {
36-
// TODO: create note options typing
36+
// TODO: create note options typing
3737
const note = await APIClient.createTeamNote(teamPath, options as any)
3838

39-
CliUx.ux.table([note], {
39+
CliUx.ux.table([note], {
4040
id: {
4141
header: 'ID',
4242
},
4343
title: {},
4444
userPath: {
4545
header: 'User path'
4646
},
47-
teamPath:{
47+
teamPath: {
4848
header: 'Team path'
4949
}
5050
}, {
@@ -57,4 +57,3 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
5757
}
5858
}
5959
}
60-

src/commands/team-notes/delete.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default class Delete extends Command {
66
static description = 'Delete a team note'
77

88
static examples = [
9-
`$ hackmd-cli team-notes delete --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA`
9+
'$ hackmd-cli team-notes delete --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA'
1010
]
1111

1212
static flags = {
@@ -19,14 +19,14 @@ export default class Delete extends Command {
1919
const {flags} = await this.parse(Delete)
2020
const {teamPath, noteId} = flags
2121

22-
if(!teamPath) {
22+
if (!teamPath) {
2323
this.error('Flag teamPath could not be empty')
2424
}
2525

26-
if(!noteId) {
26+
if (!noteId) {
2727
this.error('Flag noteId could not be empty')
2828
}
29-
29+
3030
try {
3131
await APIClient.deleteTeamNote(teamPath, noteId)
3232
} catch (e) {
@@ -35,4 +35,3 @@ export default class Delete extends Command {
3535
}
3636
}
3737
}
38-

0 commit comments

Comments
 (0)