Skip to content

Commit

Permalink
feat: migrate to oclif/core vd and oclif/test v4
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Aug 21, 2024
1 parent d36b065 commit 1b67f6b
Show file tree
Hide file tree
Showing 18 changed files with 1,000 additions and 1,233 deletions.
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,30 @@
"devDependencies": {
"@commercelayer/cli-dev": "^3.0.5",
"@commercelayer/eslint-config-ts": "^1.4.5",
"@oclif/plugin-help": "^6.2.6",
"@oclif/test": "^3.2.15",
"@oclif/plugin-help": "^6.2.8",
"@oclif/test": "^4.0.8",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@types/chai": "^4.3.16",
"@types/chai": "^4.3.17",
"@types/cli-progress": "^3.11.6",
"@types/inquirer": "^8.2.10",
"@types/mocha": "^10.0.7",
"@types/node": "^20.14.11",
"@types/node": "^22.4.1",
"@types/node-notifier": "^8.0.5",
"chai": "^4.4.1",
"chai": "^4.5.0",
"eslint": "^8.57.0",
"mocha": "^10.6.0",
"mocha": "^10.7.3",
"nyc": "^15.1.0",
"oclif": "^4.14.6",
"semantic-release": "^23.1.1",
"tsx": "^4.16.2",
"typescript": "^5.5.3"
"oclif": "^4.14.22",
"semantic-release": "^24.1.0",
"tsx": "^4.17.0",
"typescript": "^5.5.4"
},
"dependencies": {
"@commercelayer/cli-core": "^5.1.1",
"@commercelayer/sdk": "^6.10.0",
"@oclif/core": "^3.27.0",
"@commercelayer/cli-core": "beta",
"@commercelayer/sdk": "^6.13.0",
"@oclif/core": "4.0.17",
"cli-progress": "^3.12.0",
"inquirer": "^8.2.6",
"json-2-csv": "^3.20.0",
"node-notifier": "^10.0.1",
Expand Down
1,975 changes: 877 additions & 1,098 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/commands/resources/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { clApi, clToken, clColor, clUtil, clCommand, clConfig } from '@commercel
import type { CommerceLayerClient, QueryParamsList, ListResponse, Resource, QueryPageSize } from '@commercelayer/sdk'
import type { ArgOutput, FlagOutput, Input } from '@oclif/core/lib/interfaces/parser'
import notifier from 'node-notifier'
import cliProgress from 'cli-progress'


// const maxPagesWarning = 1000
Expand Down Expand Up @@ -135,7 +136,7 @@ export default class ResourcesAll extends Command {

if (((jwtData.exp - securityInterval) * 1000) <= Date.now()) {

await cliux.wait((securityInterval + 1) * 1000)
await clUtil.sleep((securityInterval + 1) * 1000)

const organization = flags.organization
const domain = flags.domain
Expand Down Expand Up @@ -222,7 +223,7 @@ export default class ResourcesAll extends Command {

const itemsDesc = resource.api.replace(/_/g, ' ')

const progressBar = blindMode ? blindProgressBar : cliux.progress({
const progressBar = blindMode ? blindProgressBar : new cliProgress.SingleBar({
format: `Fetching ${itemsDesc} ... | ${clColor.greenBright('{bar}')} | ${clColor.yellowBright('{percentage}%')} | {value}/{total} | {duration_formatted} | {eta_formatted}`,
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
Expand Down
15 changes: 7 additions & 8 deletions test/commands/resources/all.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:all', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/args.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:args', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/count.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:count', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/create.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:create', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/delete.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:delete', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/doc.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:doc', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:fetch', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/filters.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:filters', () => {
test
.timeout(15000)
.stdout()
.command(['resources:filters'])
.it('runs resources:filters', ctx => {
expect(ctx.stdout).to.contain('-= Commerce Layer API available resource filters =-').and.contain('*_eq')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/get.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:get', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/last.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:last', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/list.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:list', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/relationship.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:relationship', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/retrieve.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:retrieve', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:schema', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})
15 changes: 7 additions & 8 deletions test/commands/resources/update.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test } from '@oclif/test'
import { expect } from 'chai'
import { runCommand } from '@oclif/test'


describe('resources:update', () => {
test
.timeout(15000)
.stdout()
.command(['resources:noc'])
.it('runs NoC', ctx => {
expect(ctx.stdout).to.contain('-= NoC =-')
})
it('runs NoC', async () => {
const { stdout } = await runCommand<{ name: string }>(['resources:noc'])
expect(stdout).to.contain('-= NoC =-')
}).timeout(15000)
})

0 comments on commit 1b67f6b

Please sign in to comment.