Skip to content

Commit

Permalink
feat: separate tables for scratch orgs (#100)
Browse files Browse the repository at this point in the history
* feat: separate tables for scratch orgs

* chore: keep up with core changes

* chore: update core
  • Loading branch information
mdonnalley authored Aug 4, 2021
1 parent 0f0aae4 commit c3b18d8
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 227 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^0.5.26",
"@salesforce/core": "3.3.5",
"@salesforce/core": "3.3.8",
"cli-ux": "^5.6.3",
"open": "^8.2.0",
"tslib": "^2"
Expand Down
112 changes: 47 additions & 65 deletions schemas/env-display.json
Original file line number Diff line number Diff line change
@@ -1,88 +1,70 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/SfOrg",
"$ref": "#/definitions/OrgAuthorization",
"definitions": {
"SfOrg": {
"OrgAuthorization": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Optional%3CAnyJson%3E"
},
"properties": {
"alias": {
"orgId": {
"type": "string"
},
"username": {
"type": "string"
},
"orgId": {
"type": "string"
"oauthMethod": {
"type": "string",
"enum": [
"jwt",
"web",
"token",
"unknown"
]
},
"aliases": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "null"
}
]
},
"configs": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "null"
}
]
},
"isScratchOrg": {
"type": "boolean"
},
"instanceUrl": {
"type": "string"
},
"accessToken": {
"type": "string"
},
"oauthMethod": {
"type": "string",
"enum": ["jwt", "web", "token", "unknown"]
},
"error": {
"type": "string"
}
}
},
"Optional<AnyJson>": {
"anyOf": [
{
"$ref": "#/definitions/AnyJson"
},
{
"not": {}
}
],
"description": "A union type for either the parameterized type `T` or `undefined` -- the opposite of {@link NonOptional } ."
},
"AnyJson": {
"anyOf": [
{
"$ref": "#/definitions/JsonPrimitive"
},
{
"$ref": "#/definitions/JsonCollection"
}
],
"description": "Any valid JSON value."
},
"JsonPrimitive": {
"type": ["null", "boolean", "number", "string"],
"description": "Any valid JSON primitive value."
},
"JsonCollection": {
"anyOf": [
{
"$ref": "#/definitions/JsonMap"
},
{
"$ref": "#/definitions/JsonArray"
}
],
"description": "Any valid JSON collection value."
},
"JsonMap": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Optional%3CAnyJson%3E"
},
"properties": {},
"description": "Any JSON-compatible object."
},
"JsonArray": {
"type": "array",
"items": {
"$ref": "#/definitions/AnyJson"
},
"description": "Any JSON-compatible array."
"required": [
"orgId",
"username",
"oauthMethod"
],
"additionalProperties": false
}
}
}
}
116 changes: 49 additions & 67 deletions schemas/env-list.json
Original file line number Diff line number Diff line change
@@ -1,94 +1,76 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/SfOrgs",
"$ref": "#/definitions/Environments",
"definitions": {
"SfOrgs": {
"Environments": {
"type": "array",
"items": {
"$ref": "#/definitions/SfOrg"
"$ref": "#/definitions/OrgAuthorization"
}
},
"SfOrg": {
"OrgAuthorization": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Optional%3CAnyJson%3E"
},
"properties": {
"alias": {
"orgId": {
"type": "string"
},
"username": {
"type": "string"
},
"orgId": {
"type": "string"
"oauthMethod": {
"type": "string",
"enum": [
"jwt",
"web",
"token",
"unknown"
]
},
"aliases": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "null"
}
]
},
"configs": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "null"
}
]
},
"isScratchOrg": {
"type": "boolean"
},
"instanceUrl": {
"type": "string"
},
"accessToken": {
"type": "string"
},
"oauthMethod": {
"type": "string",
"enum": ["jwt", "web", "token", "unknown"]
},
"error": {
"type": "string"
}
}
},
"Optional<AnyJson>": {
"anyOf": [
{
"$ref": "#/definitions/AnyJson"
},
{
"not": {}
}
],
"description": "A union type for either the parameterized type `T` or `undefined` -- the opposite of {@link NonOptional } ."
},
"AnyJson": {
"anyOf": [
{
"$ref": "#/definitions/JsonPrimitive"
},
{
"$ref": "#/definitions/JsonCollection"
}
],
"description": "Any valid JSON value."
},
"JsonPrimitive": {
"type": ["null", "boolean", "number", "string"],
"description": "Any valid JSON primitive value."
},
"JsonCollection": {
"anyOf": [
{
"$ref": "#/definitions/JsonMap"
},
{
"$ref": "#/definitions/JsonArray"
}
],
"description": "Any valid JSON collection value."
},
"JsonMap": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Optional%3CAnyJson%3E"
},
"properties": {},
"description": "Any JSON-compatible object."
},
"JsonArray": {
"type": "array",
"items": {
"$ref": "#/definitions/AnyJson"
},
"description": "Any JSON-compatible array."
"required": [
"orgId",
"username",
"oauthMethod"
],
"additionalProperties": false
}
}
}
}
6 changes: 4 additions & 2 deletions schemas/env-open.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"type": "string"
}
},
"required": ["url"],
"required": [
"url"
],
"additionalProperties": false
}
}
}
}
12 changes: 6 additions & 6 deletions src/commands/env/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Command, Flags } from '@oclif/core';
import { cli } from 'cli-ux';
import { AuthInfo, SfOrg, Messages, SfdxError } from '@salesforce/core';
import { AuthInfo, OrgAuthorization, Messages, SfdxError } from '@salesforce/core';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-env', 'display');
Expand All @@ -23,13 +23,13 @@ export default class EnvDisplay extends Command {
}),
};

// TODO: Change SfOrg type to a more generalized auth type once we have Functions envs integrated.
// TODO: Change OrgAuthorization type to a more generalized auth type once we have Functions envs integrated.

public async run(): Promise<SfOrg> {
public async run(): Promise<OrgAuthorization> {
const { flags } = await this.parse(EnvDisplay);

let authorizations: SfOrg[];
let foundAuthorization: SfOrg;
let authorizations: OrgAuthorization[];
let foundAuthorization: OrgAuthorization;

try {
if (await AuthInfo.hasAuthentications()) {
Expand All @@ -44,7 +44,7 @@ export default class EnvDisplay extends Command {

foundAuthorization =
authorizations.find((auth) => auth.username === targetEnv) ??
authorizations.find((auth) => auth.alias === targetEnv);
authorizations.find((auth) => auth.aliases?.includes(targetEnv));

if (foundAuthorization) {
const columns = {
Expand Down
Loading

0 comments on commit c3b18d8

Please sign in to comment.