Skip to content

Commit

Permalink
fix: remove filesystem mock, update @oclif/core to 2.8.12 (pinned) an…
Browse files Browse the repository at this point in the history
…d add override (#467)

* fix: remove filesystem mock
* fix: update @oclif/core to 2.8.12 (pinned) and add override in @oclif/plugins-plugin
  • Loading branch information
shazron committed Jul 13, 2023
1 parent d710269 commit 4e4b648
Show file tree
Hide file tree
Showing 8 changed files with 12,697 additions and 24,784 deletions.
37,439 changes: 12,674 additions & 24,765 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@adobe/aio-cli-plugin-info": "^3.0.1",
"@adobe/aio-cli-plugin-runtime": "^6.1.0",
"@adobe/aio-cli-plugin-telemetry": "^1.2.0",
"@oclif/core": "^1.16.0",
"@oclif/core": "2.8.12",
"@oclif/plugin-autocomplete": "^2.3.1",
"@oclif/plugin-help": "^5.1.12",
"@oclif/plugin-not-found": "^2.3.26",
Expand Down Expand Up @@ -130,5 +130,10 @@
"link": "ln -s \"$(pwd)\"/bin/run /usr/local/bin/aio",
"unlink": "rm /usr/local/bin/aio",
"e2e": "jest --collectCoverage=false --testRegex './e2e/e2e.js'"
},
"overrides": {
"@oclif/plugins-plugin@^2.4.7": {
"@oclif/core": "2.8.12"
}
}
}
4 changes: 2 additions & 2 deletions src/commands/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

const { Command, Flags, CliUx: cli } = require('@oclif/core')
const { Command, Flags, ux } = require('@oclif/core')
const fetch = require('node-fetch')
const inquirer = require('inquirer')
const { sortValues } = require('../helpers')
Expand Down Expand Up @@ -84,7 +84,7 @@ class DiscoCommand extends Command {
}
}
// skip ones that aren't from us
cli.ux.table(plugins, columns)
ux.table(plugins, columns)
}

async run () {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/rollback.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

const { Command, Flags, CliUx: cli } = require('@oclif/core')
const { Command, Flags, ux } = require('@oclif/core')
const inquirer = require('inquirer')
const { prompt, hideNPMWarnings } = require('../helpers')

Expand All @@ -35,7 +35,7 @@ class RollbackCommand extends Command {
}
}

cli.ux.table(plugins, columns)
ux.table(plugins, columns)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/commands/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

const { Command, Flags, CliUx: cli } = require('@oclif/core')
const { Command, Flags, ux } = require('@oclif/core')
const inquirer = require('inquirer')
const chalk = require('chalk')
const ora = require('ora')
Expand Down Expand Up @@ -45,7 +45,7 @@ class UpdateCommand extends Command {
}
}

cli.ux.table(plugins, columns)
ux.table(plugins, columns)
}

/**
Expand Down
12 changes: 8 additions & 4 deletions test/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@

const fetch = require('node-fetch')
const { prompt, sortValues, getNpmLatestVersion, getNpmLocalVersion, hideNPMWarnings } = require('../src/helpers')
const fileSystem = require('jest-plugin-fs').default
const inquirer = require('inquirer')
const { stderr } = require('stdout-stderr')
const fs = require('fs')

jest.mock('fs')
jest.mock('inquirer')

beforeEach(() => {
fetch.resetMocks()
fileSystem.restore()
fs.readFileSync.mockRestore()
})

describe('sort tests', () => {
Expand Down Expand Up @@ -216,8 +217,11 @@ test('getNpmLocalVersion', async () => {
const packageJson = {
version: packageVersion
}
fileSystem.mock({
[`${cliRoot}/node_modules/${npmPackage}/package.json`]: JSON.stringify(packageJson)

fs.readFileSync.mockImplementation((filePath) => {
if (filePath === `${cliRoot}/node_modules/${npmPackage}/package.json`) {
return JSON.stringify(packageJson)
}
})

return expect(getNpmLocalVersion(cliRoot, npmPackage)).resolves.toEqual(packageVersion)
Expand Down
8 changes: 3 additions & 5 deletions test/hookerror.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ jest.mock('@oclif/core', () => {
}
}
},
CliUx: {
ux: {
cli: {
open: jest.fn()
}
ux: {
cli: {
open: jest.fn()
}
},
Command: jest.fn(),
Expand Down
3 changes: 0 additions & 3 deletions test/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jest.useFakeTimers()
const fetch = require('jest-fetch-mock')
jest.setMock('node-fetch', fetch)

// dont touch the real fs
jest.mock('fs', () => require('jest-plugin-fs/mock'))

// trap console log
// note: if you use console.log, some of these tests will start failing because they depend on the order/position of the output
beforeEach(() => { stdout.start(); stdout.print = false })
Expand Down

0 comments on commit 4e4b648

Please sign in to comment.