Skip to content

Commit

Permalink
Apply prettier to .ts
Browse files Browse the repository at this point in the history
  • Loading branch information
litencatt committed Jan 1, 2024
1 parent 4720b06 commit 7b51c18
Show file tree
Hide file tree
Showing 37 changed files with 948 additions and 1,053 deletions.
23 changes: 10 additions & 13 deletions src/commands/block/append.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {Args, Command, Flags, ux} from '@oclif/core'
import { Args, Command, Flags, ux } from '@oclif/core'
import * as notion from '../../notion'
import {
AppendBlockChildrenParameters,
BlockObjectResponse
BlockObjectResponse,
} from '@notionhq/client/build/src/api-endpoints'
import {
getBlockPlainText,
outputRawJson
} from '../../helper'
import { getBlockPlainText, outputRawJson } from '../../helper'

export default class BlockAppend extends Command {
static description = 'Append block children'
Expand All @@ -30,9 +27,9 @@ export default class BlockAppend extends Command {
]

static args = {
block_id: Args.string({required: true}),
children: Args.string({required: true}),
after: Args.string({required: false}),
block_id: Args.string({ required: true }),
children: Args.string({ required: true }),
after: Args.string({ required: false }),
}

static flags = {
Expand All @@ -45,7 +42,7 @@ export default class BlockAppend extends Command {

// TODO: Add support children params building prompt
public async run(): Promise<void> {
const {args, flags} = await this.parse(BlockAppend)
const { args, flags } = await this.parse(BlockAppend)
const params: AppendBlockChildrenParameters = {
block_id: args.block_id,
children: JSON.parse(args.children),
Expand All @@ -67,12 +64,12 @@ export default class BlockAppend extends Command {
content: {
get: (row: BlockObjectResponse) => {
return getBlockPlainText(row)
}
}
},
},
}
const options = {
printLine: this.log.bind(this),
...flags
...flags,
}
ux.table(res.results, columns, options)
}
Expand Down
21 changes: 8 additions & 13 deletions src/commands/block/delete.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import {Args, Command, Flags, ux} from '@oclif/core'
import { Args, Command, Flags, ux } from '@oclif/core'
import * as notion from '../../notion'
import {
BlockObjectResponse
} from '@notionhq/client/build/src/api-endpoints'
import {
getBlockPlainText,
outputRawJson
} from '../../helper'
import { BlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'
import { getBlockPlainText, outputRawJson } from '../../helper'

export default class BlockDelete extends Command {
static description = 'Delete a block'
Expand All @@ -25,7 +20,7 @@ export default class BlockDelete extends Command {
]

static args = {
block_id: Args.string({required: true}),
block_id: Args.string({ required: true }),
}

static flags = {
Expand All @@ -37,7 +32,7 @@ export default class BlockDelete extends Command {
}

public async run(): Promise<void> {
const {args, flags} = await this.parse(BlockDelete)
const { args, flags } = await this.parse(BlockDelete)

const res = await notion.deleteBlock(args.block_id)
if (flags.raw) {
Expand All @@ -53,12 +48,12 @@ export default class BlockDelete extends Command {
content: {
get: (row: BlockObjectResponse) => {
return getBlockPlainText(row)
}
}
},
},
}
const options = {
printLine: this.log.bind(this),
...flags
...flags,
}
ux.table([res], columns, options)
}
Expand Down
23 changes: 9 additions & 14 deletions src/commands/block/retrieve.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import {Args, Command, Flags, ux} from '@oclif/core'
import { Args, Command, Flags, ux } from '@oclif/core'
import * as notion from '../../notion'
import {
BlockObjectResponse
} from '@notionhq/client/build/src/api-endpoints'
import {
getBlockPlainText,
outputRawJson,
} from '../../helper'
import { BlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'
import { getBlockPlainText, outputRawJson } from '../../helper'

export default class BlockRetrieve extends Command {
static description = 'Retrieve a block'
Expand All @@ -21,11 +16,11 @@ export default class BlockRetrieve extends Command {
{
description: 'Retrieve a block and output raw json',
command: `$ notion-cli block retrieve BLOCK_ID -r`,
}
},
]

static args = {
block_id: Args.string({required: true}),
block_id: Args.string({ required: true }),
}

static flags = {
Expand All @@ -37,7 +32,7 @@ export default class BlockRetrieve extends Command {
}

public async run(): Promise<void> {
const {args, flags} = await this.parse(BlockRetrieve)
const { args, flags } = await this.parse(BlockRetrieve)

const res = await notion.retrieveBlock(args.block_id)
if (flags.raw) {
Expand All @@ -53,12 +48,12 @@ export default class BlockRetrieve extends Command {
content: {
get: (row: BlockObjectResponse) => {
return getBlockPlainText(row)
}
}
},
},
}
const options = {
printLine: this.log.bind(this),
...flags
...flags,
}
ux.table([res], columns, options)
}
Expand Down
21 changes: 8 additions & 13 deletions src/commands/block/retrieve/children.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import {Args, Command, Flags, ux} from '@oclif/core'
import { Args, Command, Flags, ux } from '@oclif/core'
import * as notion from '../../../notion'
import {
BlockObjectResponse
} from '@notionhq/client/build/src/api-endpoints'
import {
getBlockPlainText,
outputRawJson,
} from '../../../helper'
import { BlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'
import { getBlockPlainText, outputRawJson } from '../../../helper'

export default class BlockRetrieveChildren extends Command {
static description = 'Retrieve block children'
Expand All @@ -21,13 +16,13 @@ export default class BlockRetrieveChildren extends Command {
{
description: 'Retrieve block children and output raw json',
command: `$ notion-cli block retrieve:children BLOCK_ID -r`,
}
},
]

static args = {
block_id: Args.string({
description: 'block_id or page_id',
required: true
required: true,
}),
}

Expand All @@ -40,7 +35,7 @@ export default class BlockRetrieveChildren extends Command {
}

public async run(): Promise<void> {
const {args, flags} = await this.parse(BlockRetrieveChildren)
const { args, flags } = await this.parse(BlockRetrieveChildren)

// TODO: Add support start_cursor, page_size
const res = await notion.retrieveBlockChildren(args.block_id)
Expand All @@ -56,12 +51,12 @@ export default class BlockRetrieveChildren extends Command {
content: {
get: (row: BlockObjectResponse) => {
return getBlockPlainText(row)
}
},
},
}
const options = {
printLine: this.log.bind(this),
...flags
...flags,
}
ux.table(res.results, columns, options)
}
Expand Down
21 changes: 9 additions & 12 deletions src/commands/block/update.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {Args, Command, Flags, ux} from '@oclif/core'
import { Args, Command, Flags, ux } from '@oclif/core'
import * as notion from '../../notion'
import {
UpdateBlockParameters,
BlockObjectResponse,
} from '@notionhq/client/build/src/api-endpoints'
import {
outputRawJson,
getBlockPlainText,
} from '../../helper'
import { outputRawJson, getBlockPlainText } from '../../helper'

export default class BlockUpdate extends Command {
static description = 'Update a block'
Expand All @@ -22,15 +19,15 @@ export default class BlockUpdate extends Command {
{
description: 'Update a block and output raw json',
command: `$ notion-cli block update BLOCK_ID -r`,
}
},
]

static args = {
block_id: Args.string({descriptin: 'block_id', required: true}),
block_id: Args.string({ descriptin: 'block_id', required: true }),
}

static flags = {
archived: Flags.boolean({ char: 'a'}),
archived: Flags.boolean({ char: 'a' }),
raw: Flags.boolean({
char: 'r',
description: 'output raw json',
Expand All @@ -40,7 +37,7 @@ export default class BlockUpdate extends Command {

// TODO: Add support for updating block type objects
public async run(): Promise<void> {
const {args, flags} = await this.parse(BlockUpdate)
const { args, flags } = await this.parse(BlockUpdate)
// Support only archived for now
const params: UpdateBlockParameters = {
block_id: args.block_id,
Expand All @@ -60,12 +57,12 @@ export default class BlockUpdate extends Command {
content: {
get: (row: BlockObjectResponse) => {
return getBlockPlainText(row)
}
}
},
},
}
const options = {
printLine: this.log.bind(this),
...flags
...flags,
}
ux.table([res], columns, options)
}
Expand Down
41 changes: 21 additions & 20 deletions src/commands/db/create.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import {Args, Command, Flags, ux} from '@oclif/core'
import { Args, Command, Flags, ux } from '@oclif/core'
import {
CreateDatabaseParameters,
DatabaseObjectResponse,
} from '@notionhq/client/build/src/api-endpoints'
import * as notion from '../../notion'
import {
onCancel,
outputRawJson,
getDbTitle,
} from '../../helper'
import { onCancel, outputRawJson, getDbTitle } from '../../helper'

const prompts = require('prompts')
const prompts = require('prompts')

export default class DbCreate extends Command {
static description = 'Create a database'
Expand All @@ -37,17 +33,17 @@ export default class DbCreate extends Command {
{
description: 'Create a database with a specific page_id and output raw json with title',
command: `$ notion-cli db create PAGE_ID -t 'My Database' -r`,
}
},
]

static args = {
page_id: Args.string({required: true}),
page_id: Args.string({ required: true }),
}

static flags = {
title: Flags.string({
char: 't',
description: 'new database title'
description: 'new database title',
}),
raw: Flags.boolean({
char: 'r',
Expand All @@ -62,11 +58,16 @@ export default class DbCreate extends Command {

let dbTitle = flags.title
if (dbTitle == undefined) {
const dbPropPromptResult = await prompts([{
type: 'text',
name: 'title',
message: 'Please input database title',
}], { onCancel })
const dbPropPromptResult = await prompts(
[
{
type: 'text',
name: 'title',
message: 'Please input database title',
},
],
{ onCancel }
)
console.log(dbPropPromptResult)

dbTitle = dbPropPromptResult.title
Expand All @@ -83,13 +84,13 @@ export default class DbCreate extends Command {
type: 'text',
text: {
content: dbTitle,
}
}
},
},
],
properties: {
Name: {
title: {}
}
title: {},
},
},
}

Expand All @@ -111,7 +112,7 @@ export default class DbCreate extends Command {
}
const options = {
printLine: this.log.bind(this),
...flags
...flags,
}
ux.table([res], columns, options)
}
Expand Down

0 comments on commit 7b51c18

Please sign in to comment.