Skip to content

Commit

Permalink
feat: update sf-plugins-core and oclif/core (#493)
Browse files Browse the repository at this point in the history
* feat: update sf-plugins-core and oclif/core

* chore: update deps

* chore: ts conflict

* chore: testing issues
  • Loading branch information
mdonnalley authored Jan 30, 2023
1 parent 1a1b3bb commit c2bdb13
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 78 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^1.23.2",
"@oclif/core": "^2.0.7",
"@salesforce/core": "^3.32.11",
"@salesforce/kit": "^1.8.2",
"@salesforce/sf-plugins-core": "^1.21.8",
"@salesforce/sf-plugins-core": "^2.0.1",
"chalk": "^4",
"change-case": "^4.1.2",
"open": "^8.4.0",
Expand Down Expand Up @@ -128,4 +128,4 @@
"access": "public"
},
"main": "lib/index.js"
}
}
45 changes: 36 additions & 9 deletions schemas/env-create-scratch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"type": "string"
}
},
"required": ["scratchOrgInfo", "warnings", "orgId"],
"required": [
"scratchOrgInfo",
"warnings",
"orgId"
],
"additionalProperties": false
},
"ScratchOrgInfo": {
Expand Down Expand Up @@ -86,7 +90,11 @@
},
"Release": {
"type": "string",
"enum": ["Current", "Previous", "Preview"]
"enum": [
"Current",
"Previous",
"Preview"
]
},
"ScratchOrg": {
"type": "string"
Expand All @@ -102,7 +110,13 @@
},
"Status": {
"type": "string",
"enum": ["New", "Creating", "Active", "Error", "Deleted"]
"enum": [
"New",
"Creating",
"Active",
"Error",
"Deleted"
]
},
"SignupEmail": {
"type": "string"
Expand Down Expand Up @@ -142,14 +156,16 @@
}
}
},
"required": ["enabled", "disabled"],
"required": [
"enabled",
"disabled"
],
"additionalProperties": false
}
},
"required": [
"LoginUrl",
"AuthCode",
"Snapshot",
"Status",
"SignupEmail",
"SignupUsername",
Expand Down Expand Up @@ -195,7 +211,12 @@
"description": "Any valid JSON value."
},
"JsonPrimitive": {
"type": ["null", "boolean", "number", "string"],
"type": [
"null",
"boolean",
"number",
"string"
],
"description": "Any valid JSON primitive value."
},
"JsonCollection": {
Expand Down Expand Up @@ -312,7 +333,10 @@
"type": "string"
},
"namespacePrefix": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
},
"isSandbox": {
"type": "boolean"
Expand All @@ -321,11 +345,14 @@
"type": "boolean"
},
"trailExpirationDate": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
}
},
"additionalProperties": false,
"description": "Fields for authorization, org, and local information."
}
}
}
}
45 changes: 36 additions & 9 deletions schemas/env-resume-scratch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"type": "string"
}
},
"required": ["scratchOrgInfo", "warnings", "orgId"],
"required": [
"scratchOrgInfo",
"warnings",
"orgId"
],
"additionalProperties": false
},
"ScratchOrgInfo": {
Expand Down Expand Up @@ -86,7 +90,11 @@
},
"Release": {
"type": "string",
"enum": ["Current", "Previous", "Preview"]
"enum": [
"Current",
"Previous",
"Preview"
]
},
"ScratchOrg": {
"type": "string"
Expand All @@ -102,7 +110,13 @@
},
"Status": {
"type": "string",
"enum": ["New", "Creating", "Active", "Error", "Deleted"]
"enum": [
"New",
"Creating",
"Active",
"Error",
"Deleted"
]
},
"SignupEmail": {
"type": "string"
Expand Down Expand Up @@ -142,14 +156,16 @@
}
}
},
"required": ["enabled", "disabled"],
"required": [
"enabled",
"disabled"
],
"additionalProperties": false
}
},
"required": [
"LoginUrl",
"AuthCode",
"Snapshot",
"Status",
"SignupEmail",
"SignupUsername",
Expand Down Expand Up @@ -195,7 +211,12 @@
"description": "Any valid JSON value."
},
"JsonPrimitive": {
"type": ["null", "boolean", "number", "string"],
"type": [
"null",
"boolean",
"number",
"string"
],
"description": "Any valid JSON primitive value."
},
"JsonCollection": {
Expand Down Expand Up @@ -312,7 +333,10 @@
"type": "string"
},
"namespacePrefix": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
},
"isSandbox": {
"type": "boolean"
Expand All @@ -321,11 +345,14 @@
"type": "boolean"
},
"trailExpirationDate": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
}
},
"additionalProperties": false,
"description": "Fields for authorization, org, and local information."
}
}
}
}
28 changes: 5 additions & 23 deletions src/commands/env/create/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,13 @@ import {
SandboxRequest,
SfError,
} from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { Ux } from '@salesforce/sf-plugins-core/lib/ux';
import * as Interfaces from '@oclif/core/lib/interfaces';
import { Interfaces } from '@oclif/core';
import { SandboxCommandBase } from '../../../shared/sandboxCommandBase';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-env', 'create.sandbox');

type CmdFlags = {
'definition-file': string;
'set-default': boolean;
alias: string;
async: boolean;
'poll-interval': Duration;
wait: Duration;
name: string;
'license-type': string;
'no-prompt': boolean;
'target-org': Org;
clone: string;
json: boolean;
'no-track-source': boolean;
};

export enum SandboxLicenseType {
developer = 'Developer',
developerPro = 'Developer_Pro',
Expand All @@ -56,8 +39,7 @@ export default class CreateSandbox extends SandboxCommandBase<SandboxProcessObje
public static description = messages.getMessage('description');
public static examples = messages.getMessages('examples');

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public static flags: Interfaces.FlagInput<Omit<CmdFlags, 'json'>> = {
public static flags = {
// needs to change when new flags are available
'definition-file': Flags.file({
exists: true,
Expand Down Expand Up @@ -117,7 +99,7 @@ export default class CreateSandbox extends SandboxCommandBase<SandboxProcessObje
description: messages.getMessage('flags.clone.description'),
exclusive: ['license-type'],
}),
'license-type': Flags.enum({
'license-type': Flags.string({
char: 'l',
summary: messages.getMessage('flags.licenseType.summary'),
exclusive: ['definition-file', 'clone'],
Expand All @@ -140,11 +122,11 @@ export default class CreateSandbox extends SandboxCommandBase<SandboxProcessObje
};
public static readonly state = 'beta';
protected readonly lifecycleEventNames = ['postorgcreate'];
private flags: CmdFlags;
private flags: Interfaces.InferredFlags<typeof CreateSandbox.flags>;

public async run(): Promise<SandboxProcessObject> {
this.sandboxRequestConfig = await this.getSandboxRequestConfig();
this.flags = (await this.parse(CreateSandbox)).flags as CmdFlags;
this.flags = (await this.parse(CreateSandbox)).flags;
this.debug('Create started with args %s ', this.flags);
this.validateFlags();
return this.createSandbox();
Expand Down
13 changes: 2 additions & 11 deletions src/commands/env/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { Interfaces } from '@oclif/core';
import { Messages } from '@salesforce/core';
import { Flags, SfCommand, JsonObject, SfHook, EnvList as Env } from '@salesforce/sf-plugins-core';
import { toKey, toValue } from '../../utils';
Expand Down Expand Up @@ -78,17 +79,7 @@ export default class EnvList extends SfCommand<Environments> {
}),
};

private flags!: {
all: boolean;
columns: string[];
csv: boolean;
filter: string;
json: boolean;
'no-header': boolean;
'no-truncate': boolean;
output: string;
sort: string;
};
private flags!: Interfaces.InferredFlags<typeof EnvList.flags>;

public async run(): Promise<Environments> {
this.flags = (await this.parse(EnvList)).flags;
Expand Down
14 changes: 3 additions & 11 deletions src/commands/env/resume/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,18 @@ import {
SfError,
} from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import * as Interfaces from '@oclif/core/lib/interfaces';
import { Interfaces } from '@oclif/core';
import { SandboxCommandBase } from '../../../shared/sandboxCommandBase';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-env', 'resume.sandbox');

type CmdFlags = {
wait: Duration;
name: string;
'job-id': string;
'target-org': Org;
'use-most-recent': boolean;
};

export default class ResumeSandbox extends SandboxCommandBase<SandboxProcessObject> {
public static summary = messages.getMessage('summary');
public static description = messages.getMessage('description');
public static examples = messages.getMessages('examples');

public static flags: Interfaces.FlagInput<CmdFlags> = {
public static flags = {
wait: Flags.duration({
char: 'w',
summary: messages.getMessage('flags.wait.summary'),
Expand Down Expand Up @@ -79,7 +71,7 @@ export default class ResumeSandbox extends SandboxCommandBase<SandboxProcessObje
};
public static readonly state = 'beta';
protected readonly lifecycleEventNames = ['postorgcreate'];
private flags: CmdFlags;
private flags: Interfaces.InferredFlags<typeof ResumeSandbox.flags>;

public async run(): Promise<SandboxProcessObject> {
this.sandboxRequestConfig = await this.getSandboxRequestConfig();
Expand Down
6 changes: 3 additions & 3 deletions src/shared/orgHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Optional } from '@salesforce/ts-types';
import { AuthFields } from '@salesforce/core';
import { Command, Hook, Hooks } from '@oclif/core/lib/interfaces';
import { Command, Interfaces, Hook } from '@oclif/core';

type HookOpts<T> = {
options: { Command: Command.Class; argv: string[]; commandId: string };
Expand All @@ -33,12 +33,12 @@ type PostOrgCreateOpts = HookOpts<OrgCreateResult>;
/**
* Extends OCLIF's Hooks interface to add types for hooks that run on org commands
*/
export interface OrgHooks extends Hooks {
export interface OrgHooks extends Interfaces.Hooks {
postorgcreate: PostOrgCreateOpts;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type OrgHook<T> = (this: Hook.Context, options: T extends keyof Hooks ? OrgHooks[T] : T) => any;
export type OrgHook<T> = (this: Hook.Context, options: T extends keyof Interfaces.Hooks ? OrgHooks[T] : T) => any;

// eslint-disable-next-line no-redeclare
export declare namespace OrgHook {
Expand Down
4 changes: 2 additions & 2 deletions src/shared/sandboxProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import * as os from 'os';
import { StatusEvent, ResultEvent, SandboxProcessObject } from '@salesforce/core';
import { Ux } from '@salesforce/sf-plugins-core/lib/ux';
import { CliUx } from '@oclif/core';
import { ux } from '@oclif/core';
import { getClockForSeconds } from '../utils/timeUtils';
import { StagedProgress } from './stagedProgress';

Expand Down Expand Up @@ -85,7 +85,7 @@ export class SandboxProgress extends StagedProgress<SandboxStatusData> {
return [];
}
const tableRows: string[] = [];
CliUx.ux.table(this.getTableDataFromProcessObj(sandboxUsername, sandboxProgress), columns, {
ux.table(this.getTableDataFromProcessObj(sandboxUsername, sandboxProgress), columns, {
printLine: (s: string): void => {
tableRows.push(s);
},
Expand Down
Loading

0 comments on commit c2bdb13

Please sign in to comment.