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

Commit

Permalink
chore: rename command (#20)
Browse files Browse the repository at this point in the history
* chore: rename command

also:
* drops support for node 14
* stop shipping source map and typedef files.
* add flag labels
  • Loading branch information
cristiand391 authored Aug 21, 2023
1 parent 58ab226 commit 11387c2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 36 deletions.
12 changes: 0 additions & 12 deletions LICENSE.txt

This file was deleted.

2 changes: 1 addition & 1 deletion command-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"command": "env:api",
"command": "org:api",
"plugin": "@cristiand391/sf-plugin-api",
"flags": ["body", "header", "include", "method", "target-org"],
"alias": [],
Expand Down
File renamed without changes.
18 changes: 7 additions & 11 deletions src/commands/env/api.ts → src/commands/org/api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/*
* 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
*/

import { readFile } from 'node:fs/promises';
import { EOL } from 'node:os';
import got, { Headers, Method } from 'got';
Expand All @@ -17,10 +10,10 @@ import { Args, ux } from '@oclif/core';
Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages(
'@cristiand391/sf-plugin-api',
'env.api',
'org.api',
);

export default class EnvApi extends SfCommand<void> {
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');
Expand All @@ -33,6 +26,7 @@ export default class EnvApi 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'
}),
include: Flags.boolean({
char: 'i',
Expand All @@ -56,11 +50,13 @@ export default class EnvApi extends SfCommand<void> {
})(),
header: Flags.string({
summary: messages.getMessage('flags.header.summary'),
helpValue: 'key:value',
char: 'H',
multiple: true,
}),
body: Flags.file({
summary: messages.getMessage('flags.body.summary'),
helpValue: 'file',
}),
};

Expand Down Expand Up @@ -92,7 +88,7 @@ export default class EnvApi extends SfCommand<void> {
}

public async run(): Promise<void> {
const { flags, args } = await this.parse(EnvApi);
const { flags, args } = await this.parse(OrgApi);

const org = flags['target-org'];

Expand All @@ -111,7 +107,7 @@ export default class EnvApi extends SfCommand<void> {
// eslint-disable-next-line sf-plugin/get-connection-with-version
org.getConnection().getConnectionOptions().accessToken
}`,
...(flags.header ? EnvApi.getHeaders(flags.header) : {}),
...(flags.header ? OrgApi.getHeaders(flags.header) : {}),
},
body:
flags.method === 'GET'
Expand Down
7 changes: 0 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
/*
* Copyright (c) 2021, 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
*/

export = {};
10 changes: 5 additions & 5 deletions test/commands/env/api.test.ts → test/commands/org/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { SfError } from '@salesforce/core';
import { expect } from 'chai';
import stripAnsi = require('strip-ansi');
import { stdout } from '@oclif/core';
import EnvApi from '../../../src/commands/env/api';
import { OrgApi }from '../../../src/commands/org/api';

describe('env api', () => {
describe('org api', () => {
const $$ = new TestContext();
const testOrg = new MockTestOrgData('1234', {
username: '[email protected]',
Expand Down Expand Up @@ -35,7 +35,7 @@ describe('env api', () => {
.get('/services/data/v56.0/limits')
.reply(200, orgLimitsResponse);

await EnvApi.run([
await OrgApi.run([
'services/data/v56.0/limits',
'--target-org',
'[email protected]',
Expand Down Expand Up @@ -63,7 +63,7 @@ describe('env api', () => {
.get('/services/data')
.reply(200, xmlRes);

await EnvApi.run([
await OrgApi.run([
'services/data',
'--header',
'Accept: application/xml',
Expand All @@ -79,7 +79,7 @@ describe('env api', () => {

it('should validate HTTP headers are in a "key:value" format', async () => {
try {
await EnvApi.run([
await OrgApi.run([
'services/data',
'--header',
'Accept application/xml',
Expand Down

0 comments on commit 11387c2

Please sign in to comment.