Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from cristiand391/updates
Browse files Browse the repository at this point in the history
chore: updates
  • Loading branch information
cristiand391 committed Oct 2, 2023
2 parents 11387c2 + 5a8fbe2 commit 590142d
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 212 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
*/
module.exports = {
extends: ['eslint-config-salesforce-typescript', 'plugin:sf-plugin/recommended'],
rules: {
'sf-plugin/no-missing-messages': 'off',
'sf-plugin/no-hardcoded-messages-commands': 'off',
'sf-plugin/no-hardcoded-messages-flags': 'off'
}
};
29 changes: 9 additions & 20 deletions .github/workflows/manualRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,20 @@ on:

jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Conventional Changelog Action
id: changelog
uses: TriPSs/conventional-changelog-action@d360fad3a42feca6462f72c97c165d60a02d4bf2
# overriding some of the basic behaviors to just get the changelog
# https://github.com/TriPSs/conventional-changelog-action/releases/tag/v4.1.1
uses: TriPSs/conventional-changelog-action@05fc06b05ff372d7a3890bfe625d42a0d97844de
with:
git-user-name: Cristian Dominguez
github-token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
# always do the release, even if there are no semantic commits
skip-on-empty: false
output-file: 'CHANGELOG.md'
tag-prefix: ''
- uses: notiz-dev/github-action-json-property@2192e246737701f108a4571462b76c75e7376216
id: packageVersion
with:
path: 'package.json'
prop_path: 'version'
skip-on-empty: false
- name: Create Github Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
with:
tag_name: ${{ steps.packageVersion.outputs.prop }}
release_name: ${{ steps.packageVersion.outputs.prop }}
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ steps.changelog.outputs.tag }} --notes-file CHANGELOG.md
38 changes: 16 additions & 22 deletions .github/workflows/onRelease.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
name: publish

on:
workflow_dispatch:
release:
types: [released]
# support manual release in case something goes wrong and needs to be repeated or tested
workflow_dispatch:
inputs:
tag:
description: tag that needs to publish
type: string
required: true

jobs:
npm-publish:
runs-on: ubuntu-latest
steps:
- name: Release
uses: actions/checkout@v3
with:
ref: ${{ inputs.githubTag }}
- uses: actions/setup-node@v3
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
# https://github.com/actions/setup-node/releases/tag/v3.8.1
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
with:
node-version: ${{ inputs.nodeVersion }}
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
cache: yarn
- run: yarn install --network-timeout 600000
- run: yarn build
- run: npm install --global @salesforce/[email protected]
- run: |
sf-release npm:package:release \
--githubtag ${{ github.event.release.tag_name || inputs.tag || 'latest' }} \
--npmtag ${{ inputs.tag || 'latest' }}
--no-install
- name: Install dependencies
run: yarn install --network-timeout 600000
- name: Build
run: yarn build
- name: Publish to npm
run: npm publish --access public
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Empty file added CHANGELOG.md
Empty file.
44 changes: 0 additions & 44 deletions messages/org.api.md

This file was deleted.

15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
},
"bugs": "https://github.com/cristiand391/sf-plugin-api/issues",
"dependencies": {
"@oclif/core": "^2.11.8",
"@salesforce/core": "^5.2.1",
"@salesforce/sf-plugins-core": "^3.1.15",
"@oclif/core": "^2.15.0",
"@salesforce/core": "^5.3.3",
"@salesforce/sf-plugins-core": "^3.1.27",
"chalk": "^4",
"got": "11.8.5",
"proxy-agent": "^6.3.0"
"got": "11.8.6",
"proxy-agent": "^6.3.1"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^4.0.12",
Expand Down Expand Up @@ -51,7 +51,6 @@
},
"files": [
"/lib",
"/messages",
"/oclif.manifest.json"
],
"homepage": "https://github.com/cristiand391/sf-plugin-api",
Expand Down Expand Up @@ -98,8 +97,7 @@
"command": "tsc -p . --pretty --incremental",
"files": [
"src/**/*.ts",
"**/tsconfig.json",
"messages/**"
"**/tsconfig.json"
],
"output": [
"lib/**",
Expand All @@ -122,7 +120,6 @@
"files": [
"src/**/*.ts",
"test/**/*.ts",
"messages/**",
"**/.eslint*",
"**/tsconfig.json"
],
Expand Down
48 changes: 26 additions & 22 deletions src/commands/org/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@ import got, { Headers, Method } from 'got';
import * as chalk from 'chalk';
import { ProxyAgent } from 'proxy-agent';
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { SfError, Messages, Org } from '@salesforce/core';
import { SfError, Org } from '@salesforce/core';
import { Args, ux } from '@oclif/core';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages(
'@cristiand391/sf-plugin-api',
'org.api',
);

export class OrgApi extends SfCommand<void> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
public static readonly summary =
'Makes an authenticated HTTP request to the Salesforce REST API and prints the response.';
public static readonly description =
'You must specify a Salesforce org to use, either with the --target-org flag or by setting your default org with the `target-org` configuration variable.';
public static readonly examples = [
{
description: 'List information about limits in your org:',
command:
"<%= config.bin %> <%= command.id %> 'services/data/v56.0/limits' --target-org my-org",
},
{
description:
'Get response in XML format by specifying the "Accept" HTTP header:',
command:
"<%= config.bin %> <%= command.id %> 'services/data/v56.0/limits' --target-org my-org --header 'Accept: application/xml'",
},
];
public static enableJsonFlag = false;
public static readonly flags = {
// FIXME: getting a false positive from this eslint rule.
Expand All @@ -26,11 +34,11 @@ export class OrgApi extends SfCommand<void> {
// TODO: this is already set in the org flag but getting a wrong type if not set here.
// Fix flag types in oclif.
required: true,
helpValue: 'username'
helpValue: 'username',
}),
include: Flags.boolean({
char: 'i',
summary: messages.getMessage('flags.include.summary'),
summary: 'Include HTTP response status and headers in the output.',
default: false,
}),
method: Flags.custom<Method>({
Expand All @@ -44,18 +52,18 @@ export class OrgApi extends SfCommand<void> {
'OPTIONS',
'TRACE',
],
summary: messages.getMessage('flags.method.summary'),
summary: 'The HTTP method for the request.',
char: 'X',
default: 'GET',
})(),
header: Flags.string({
summary: messages.getMessage('flags.header.summary'),
summary: 'HTTP header in "key:value" format.',
helpValue: 'key:value',
char: 'H',
multiple: true,
}),
body: Flags.file({
summary: messages.getMessage('flags.body.summary'),
summary: 'The file to use as the body for the request.',
helpValue: 'file',
}),
};
Expand All @@ -73,13 +81,9 @@ export class OrgApi extends SfCommand<void> {
for (const header of keyValPair) {
const split = header.split(':');
if (split.length !== 2) {
throw new SfError(
messages.getMessage('errors.invalid-http-header', [header]),
'',
[
'Make sure the header is in a "key:value" format, e.g. "Accept: application/json"',
],
);
throw new SfError(`Failed to parse HTTP header: "${header}".`, '', [
'Make sure the header is in a "key:value" format, e.g. "Accept: application/json"',
]);
}
headers[split[0]] = split[1].trim();
}
Expand Down
2 changes: 1 addition & 1 deletion test/commands/org/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SfError } from '@salesforce/core';
import { expect } from 'chai';
import stripAnsi = require('strip-ansi');
import { stdout } from '@oclif/core';
import { OrgApi }from '../../../src/commands/org/api';
import { OrgApi } from '../../../src/commands/org/api';

describe('org api', () => {
const $$ = new TestContext();
Expand Down
Loading

0 comments on commit 590142d

Please sign in to comment.