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

chore: rename command #20

Merged
merged 5 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
"compilerOptions": {
"strict": true,
"module": "commonjs",
"target": "es2020",
"lib": ["es2020"],
"sourceMap": true,
"declaration": true,
"target": "ES2021",
"lib": ["ES2021"],
"moduleResolution": "node",
"alwaysStrict": true,
"noUnusedLocals": true,
Expand Down