Skip to content

Commit

Permalink
Merge branch 'salesforcecli:main' into support-sfdx-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jayree authored Aug 24, 2022
2 parents c93c2c9 + 15ac6bc commit 07fa26b
Show file tree
Hide file tree
Showing 21 changed files with 1,703 additions and 978 deletions.
33 changes: 19 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ workflows:
filters:
branches:
only: main
context: CLI_CTC
# - release-management/test-nut:
# matrix:
# parameters:
# os:
# - linux
# - windows
# sfdx_version:
# - latest
# node_version:
# - latest
# requires:
# - release-management/test-package
context:
- CLI_CTC
- AWS
- release
- release-management/test-nut:
matrix:
parameters:
os:
- linux
- windows
sfdx_version:
- latest
node_version:
- latest
requires:
- release-management/test-package
context: na40-auth-url
when: << pipeline.parameters.run-auto-workflows >>
test-ts-update:
triggers:
Expand Down Expand Up @@ -79,7 +83,8 @@ workflows:
only:
- main
jobs:
- release-management/dependabot-automerge
- release-management/dependabot-automerge:
context: release
parameters:
run-auto-workflows:
description: >
Expand Down
20 changes: 10 additions & 10 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "monthly"
interval: 'monthly'
labels:
- "dependencies"
- 'dependencies'
open-pull-requests-limit: 100
pull-request-branch-name:
separator: "-"
separator: '-'
ignore:
- dependency-name: "typescript"
- dependency-name: "sinon"
- dependency-name: "string-ansi"
- dependency-name: "*"
update-types: ["version-update:semver-major"]
- dependency-name: 'typescript'
- dependency-name: 'sinon'
- dependency-name: 'string-ansi'
- dependency-name: '*'
update-types: ['version-update:semver-major']
23 changes: 0 additions & 23 deletions .github/workflows/slackprnotification.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package-lock.json
# debug logs
npm-error.log
yarn-error.log
lerna-debug.log


# compile source
lib
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [2.0.1](https://github.com/salesforcecli/plugin-info/compare/v2.0.0...v2.0.1) (2022-05-24)

### Bug Fixes

- add prompt to examples ([981c3d3](https://github.com/salesforcecli/plugin-info/commit/981c3d3ac38659d537fb641d1501d4d85c31e37e))

## [2.0.0](https://github.com/salesforcecli/plugin-info/compare/v1.3.1...v2.0.0) (2022-04-01)

### Bug Fixes

- parking orbit plugin-info ([f18721f](https://github.com/salesforcecli/plugin-info/commit/f18721ff411cb4720d6d297d3250206129eb620b))

### [1.3.1](https://github.com/salesforcecli/plugin-info/compare/v1.3.0...v1.3.1) (2022-03-16)

### Bug Fixes

- remove force.ts ([c663604](https://github.com/salesforcecli/plugin-info/commit/c6636048571b198f7ae23c1fb014ebc180075bb9))

## [1.3.0](https://github.com/salesforcecli/plugin-info/compare/v1.2.1...v1.3.0) (2022-02-28)

### Features

- json output ([edd0b99](https://github.com/salesforcecli/plugin-info/commit/edd0b991edc0383dc6d6fb20a9e4daa15eb82a55))
- migrate force command from toolbelt ([68ecc16](https://github.com/salesforcecli/plugin-info/commit/68ecc1643a672e72fd34ea9e224e30a917aa840b))
- support api from config ([25ac49d](https://github.com/salesforcecli/plugin-info/commit/25ac49d8d4f0ff10dcdf740f4e6cdd4eb1c3d8db))

### [1.2.1](https://github.com/salesforcecli/plugin-info/compare/v1.2.0...v1.2.1) (2022-02-10)

### Bug Fixes

- proxy support for got ([#75](https://github.com/salesforcecli/plugin-info/issues/75)) ([2d9abef](https://github.com/salesforcecli/plugin-info/commit/2d9abefe045d9fcfde9c79df416e5b809b5461d6))

## [1.2.0](https://github.com/salesforcecli/plugin-info/compare/v1.1.4...v1.2.0) (2022-01-05)

### Features
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ ALIASES
EXAMPLES
Display release notes for the currently installed CLI version:
sfdx info:releasenotes:display
$ sfdx info:releasenotes:display
Display release notes for CLI version 7.120.0:
sfdx info:releasenotes:display --version 7.120.0
$ sfdx info:releasenotes:display --version 7.120.0
Display release notes for the CLI version that corresponds to a tag (stable, stable-rc, latest, latest-rc, rc):
sfdx info:releasenotes:display --version latest
$ sfdx info:releasenotes:display --version latest
```

_See code: [src/commands/info/releasenotes/display.ts](https://github.com/salesforcecli/plugin-info/blob/v1.1.4/src/commands/info/releasenotes/display.ts)_
_See code: [src/commands/info/releasenotes/display.ts](https://github.com/salesforcecli/plugin-info/blob/v2.0.0/src/commands/info/releasenotes/display.ts)_

<!-- commandsstop -->
3 changes: 2 additions & 1 deletion command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"command": "info:releasenotes:display",
"plugin": "@salesforce/plugin-info",
"flags": ["hook", "json", "loglevel", "version"]
"flags": ["hook", "json", "loglevel", "version"],
"alias": ["whatsnew"]
}
]
6 changes: 3 additions & 3 deletions messages/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ module.exports = {
},
examples: [
`Display release notes for the currently installed CLI version:
<%= config.bin %> <%= command.id %>
$ <%= config.bin %> <%= command.id %>
Display release notes for CLI version 7.120.0:
<%= config.bin %> <%= command.id %> --version 7.120.0
$ <%= config.bin %> <%= command.id %> --version 7.120.0
Display release notes for the CLI version that corresponds to a tag (%s):
<%= config.bin %> <%= command.id %> --version latest
$ <%= config.bin %> <%= command.id %> --version latest
`,
],
footer: `---
Expand Down
23 changes: 15 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"name": "@salesforce/plugin-info",
"description": "Plugin for accessing cli info from the command line",
"version": "1.2.0",
"version": "2.0.1",
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"main": "lib/index.js",
"dependencies": {
"@oclif/config": "^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.4",
"@salesforce/core": "^3.10.1",
"@salesforce/kit": "^1.5.34",
"got": "^11.8.2",
"marked": "^4.0.1",
"marked-terminal": "^4.2.0",
"proxy-agent": "^5.0.0",
"proxy-from-env": "^1.1.0",
"semver": "^7.3.5",
"tslib": "^2"
},
"devDependencies": {
"@oclif/dev-cli": "^1",
"@oclif/plugin-command-snapshot": "^2.2.2",
"@oclif/plugin-command-snapshot": "^3",
"@salesforce/cli-plugins-testkit": "^1.4.17",
"@salesforce/dev-config": "^3.0.0",
"@salesforce/dev-scripts": "^2.0.0",
Expand All @@ -27,6 +30,7 @@
"@types/fs-extra": "^9.0.13",
"@types/marked": "^4.0.0",
"@types/marked-terminal": "^3.1.3",
"@types/proxy-from-env": "^1.0.1",
"@types/semver": "^7.3.8",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
Expand All @@ -47,7 +51,7 @@
"nyc": "^15.1.0",
"prettier": "^2.4.1",
"pretty-quick": "^3.1.0",
"shx": "0.3.3",
"shx": "0.3.4",
"sinon": "^11.1.1",
"sinon-chai": "^3.7.0",
"ts-node": "^10.4.0",
Expand All @@ -59,7 +63,7 @@
}
},
"engines": {
"node": ">=12.0.0"
"node": ">=14.0.0"
},
"files": [
"/lib",
Expand All @@ -77,6 +81,9 @@
"license": "BSD-3-Clause",
"oclif": {
"commands": "./lib/commands",
"additionalHelpFlags": [
"-h"
],
"bin": "sfdx",
"devPlugins": [
"@oclif/plugin-help",
Expand Down
15 changes: 13 additions & 2 deletions src/commands/info/releasenotes/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class Display extends SfdxCommand {
}),
};

public async run(): Promise<void> {
public async run(): Promise<DisplayOutput> {
const env = new Env();

const isHook = !!this.flags.hook;
Expand Down Expand Up @@ -101,7 +101,13 @@ export default class Display extends SfdxCommand {

tokens.unshift(marked.lexer(`# Release notes for '${plugin.name}':`)[0]);

this.ux.log(marked.parser(tokens));
if (this.flags.json) {
const body = tokens.map((token) => token.raw).join(os.EOL);

return { body, url: releaseNotesPath };
} else {
this.ux.log(marked.parser(tokens));
}

if (isHook) {
if (env.getBoolean(HIDE_FOOTER)) {
Expand Down Expand Up @@ -142,3 +148,8 @@ export default class Display extends SfdxCommand {
}
}
}

interface DisplayOutput {
body: string;
url: string;
}
4 changes: 3 additions & 1 deletion src/shared/getDistTagVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

import got from 'got';
import * as ProxyAgent from 'proxy-agent';
import { getProxyForUrl } from 'proxy-from-env';
import { SFDX_RELEASE_NOTES_TIMEOUT } from '../constants';

export type DistTagJson = {
Expand All @@ -16,7 +18,7 @@ export type DistTagJson = {
const getDistTagVersion = async (url: string, distTag: string): Promise<string> => {
// TODO: Could use npm instead here. That way private cli repos could auth with .npmrc
// -- could utilize this: https://github.com/salesforcecli/plugin-trust/blob/0393b906a30e8858816625517eda5db69377c178/src/lib/npmCommand.ts
const options = { timeout: SFDX_RELEASE_NOTES_TIMEOUT };
const options = { timeout: SFDX_RELEASE_NOTES_TIMEOUT, agent: { https: ProxyAgent(getProxyForUrl(url)) } };

const body = await got(url, options).json<DistTagJson>();

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
3 changes: 3 additions & 0 deletions src/shared/getReleaseNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import got from 'got';
import { major } from 'semver';
import { getProxyForUrl } from 'proxy-from-env';
import * as ProxyAgent from 'proxy-agent';
import { SFDX_RELEASE_NOTES_TIMEOUT } from '../constants';

const getReleaseNotes = async (base: string, filename: string, version: string): Promise<string> => {
Expand All @@ -17,6 +19,7 @@ const getReleaseNotes = async (base: string, filename: string, version: string):
const options = {
timeout: SFDX_RELEASE_NOTES_TIMEOUT,
throwHttpErrors: false,
agent: { https: ProxyAgent(getProxyForUrl(rawBase)) },
};

const getPromises = [
Expand Down
18 changes: 15 additions & 3 deletions test/commands/info/releasenotes/display.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { expect, use as chaiUse } from 'chai';
import * as os from 'os';
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 @@ -36,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 Expand Up @@ -250,4 +251,15 @@ describe('info:releasenotes:display', () => {
expect(lifecycleStub.calledOnce).to.be.true;
expect(uxLogStub.args[2]).to.be.undefined;
});

it('supports json output', async () => {
const json = await runDisplayCmd(['--json']);

const expected = {
body: `# Release notes for 'sfdx':${os.EOL}## Release notes for 3.3.3`,
url: mockInfoConfig.releasenotes.releaseNotesPath,
};

expect(json).to.deep.equal(expected);
});
});
5 changes: 4 additions & 1 deletion test/nuts/blank.nut.ts → test/nuts/placeholder.nut.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
describe.skip('this repo does not have any NUTS tests', () => {
it('this is just a placeholder for automation');
});
Loading

0 comments on commit 07fa26b

Please sign in to comment.