Skip to content

Commit

Permalink
fix: parking orbit plugin-info
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Mar 25, 2022
1 parent 56edd21 commit f18721f
Show file tree
Hide file tree
Showing 6 changed files with 1,114 additions and 586 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@salesforce/plugin-info",
"description": "Plugin for accessing cli info from the command line",
"version": "1.3.1",
"version": "2.0.0",
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"main": "lib/index.js",
"dependencies": {
"@oclif/config": "^1",
"@oclif/plugin-help": "^3.3.1",
"@salesforce/command": "^4.1.5",
"@salesforce/core": "^2.29.0",
"@salesforce/kit": "^1.5.17",
"@oclif/core": "^1.6.3",
"@salesforce/command": "^5.0.1",
"@salesforce/core": "^3.10.1",
"@salesforce/kit": "^1.5.34",
"got": "^11.8.2",
"marked": "^4.0.1",
"marked-terminal": "^4.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/shared/getInfoConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { join } from 'path';
import { fs } from '@salesforce/core';
import * as fs from 'fs';
import { PJSON } from '@oclif/config';

export interface PjsonWithInfo extends PJSON {
Expand Down Expand Up @@ -42,7 +42,7 @@ const getInfoConfig = async (path: string): Promise<InfoConfig> => {
// TODO: could add env var support for these values
const fullPath = join(path, 'package.json');

const json = (await fs.readJson(fullPath)) as PjsonWithInfo;
const json = JSON.parse(await fs.promises.readFile(fullPath, 'utf8')) as PjsonWithInfo;

const { info } = json.oclif;

Expand Down
4 changes: 2 additions & 2 deletions test/commands/info/releasenotes/display.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import * as Sinon from 'sinon';
import * as SinonChai from 'sinon-chai';
import { expect, use as chaiUse } from 'chai';
import { fromStub, stubInterface, stubMethod, spyMethod } from '@salesforce/ts-sinon';
import { IConfig } from '@oclif/config';
import { shouldThrow } from '@salesforce/core/lib/testSetup';
import { UX } from '@salesforce/command';
import { marked } from 'marked';
import { Env } from '@salesforce/kit';
import { Lifecycle } from '@salesforce/core';
import { Config } from '@oclif/core';
import * as getInfoConfig from '../../../../src/shared/getInfoConfig';
import * as getReleaseNotes from '../../../../src/shared/getReleaseNotes';
import * as getDistTagVersion from '../../../../src/shared/getDistTagVersion';
Expand All @@ -37,7 +37,7 @@ describe('info:releasenotes:display', () => {
let parseReleaseNotesSpy: Sinon.SinonSpy;
let markedParserSpy: Sinon.SinonSpy;

const oclifConfigStub = fromStub(stubInterface<IConfig>(sandbox));
const oclifConfigStub = fromStub(stubInterface<Config>(sandbox));

class TestDisplay extends Display {
public async runIt() {
Expand Down
11 changes: 6 additions & 5 deletions test/shared/getInfoConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import * as pathPkg from 'path';
import * as fs from 'fs';
import { expect, use as chaiUse } from 'chai';
import * as Sinon from 'sinon';
import * as SinonChai from 'sinon-chai';
import { stubMethod, spyMethod } from '@salesforce/ts-sinon';
import { fs } from '@salesforce/core';
import { shouldThrow } from '@salesforce/core/lib/testSetup';
import { getInfoConfig, PjsonWithInfo } from '../../src/shared/getInfoConfig';

Expand All @@ -19,7 +19,7 @@ chaiUse(SinonChai);
describe('getInfoConfig tests', () => {
const sandbox = Sinon.createSandbox();

let readJsonStub: Sinon.SinonStub;
let readFileStub: Sinon.SinonStub;
let joinSpy: Sinon.SinonSpy;

let pjsonMock: PjsonWithInfo;
Expand All @@ -41,7 +41,8 @@ describe('getInfoConfig tests', () => {
},
};

readJsonStub = stubMethod(sandbox, fs, 'readJson').returns(pjsonMock);
// keep pjsonMock as JSON to access values in tests
readFileStub = stubMethod(sandbox, fs.promises, 'readFile').resolves(JSON.stringify(pjsonMock));
joinSpy = spyMethod(sandbox, pathPkg, 'join');
});

Expand All @@ -63,7 +64,7 @@ describe('getInfoConfig tests', () => {

const expected = pathPkg.join(path, 'package.json');

expect(readJsonStub.args[0][0]).to.deep.equal(expected);
expect(readFileStub.args[0][0]).to.deep.equal(expected);
});

it('info config is extracted from package.json', async () => {
Expand All @@ -73,7 +74,7 @@ describe('getInfoConfig tests', () => {
});

it('throws an error if info config does not exist', async () => {
readJsonStub.returns({ oclif: {} });
readFileStub.returns(JSON.stringify({ oclif: {} }));

try {
await shouldThrow(getInfoConfig(path));
Expand Down
2 changes: 1 addition & 1 deletion test/shared/parseReleaseNotes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as fs from 'fs';
import { expect, use as chaiUse } from 'chai';
import * as Sinon from 'sinon';
import * as SinonChai from 'sinon-chai';
import { spyMethod } from '@salesforce/ts-sinon';
import { fs } from '@salesforce/core';
import { marked } from 'marked';
import { parseReleaseNotes } from '../../src/shared/parseReleaseNotes';

Expand Down
Loading

0 comments on commit f18721f

Please sign in to comment.