Skip to content

new texei command : sandbox list #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Link the plugin: sfdx plugins:link .

<!-- commands -->
* [`sfdx texei:package:dependencies:install`](#sfdx-texeipackagedependenciesinstall)
* [`sfdx texei:sandbox:list`](#sfdx-texeisandboxlist)
* [`sfdx texei:user:update`](#sfdx-texeiuserupdate)

## `sfdx texei:package:dependencies:install`
Expand Down Expand Up @@ -58,7 +59,29 @@ EXAMPLE
$ texei:package:dependencies:install -u MyScratchOrg -v MyDevHub -k "1:MyPackage1Key 2: 3:MyPackage3Key" -b "DEV"
```

_See code: [src/commands/texei/package/dependencies/install.ts](https://github.com/texei/texei-sfdx-plugin/blob/v0.0.3/src/commands/texei/package/dependencies/install.ts)_
_See code: [src/commands/texei/package/dependencies/install.ts](https://github.com/texei/texei-sfdx-plugin/blob/v0.0.4/src/commands/texei/package/dependencies/install.ts)_

## `sfdx texei:sandbox:list`

Tools for sandboxes (list, refresh...)

```
USAGE
$ sfdx texei:sandbox:list

OPTIONS
-l, --list=list the <fieldName>=<value> pairs you’re updating
-u, --targetusername=targetusername username or alias for the target org; overrides default target org
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub org; overrides default dev hub org
--apiversion=apiversion override the api version used for api requests made by this command
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal) logging level for this command invocation

EXAMPLE
$ sfdx texei:sandbox:list --targetusername myOrg@example.com
```

_See code: [src/commands/texei/sandbox/list.ts](https://github.com/texei/texei-sfdx-plugin/blob/v0.0.4/src/commands/texei/sandbox/list.ts)_

## `sfdx texei:user:update`

Expand All @@ -81,5 +104,5 @@ EXAMPLES
$ sfdx texei:user:update --values "UserPermissionsKnowledgeUser=true --json"
```

_See code: [src/commands/texei/user/update.ts](https://github.com/texei/texei-sfdx-plugin/blob/v0.0.3/src/commands/texei/user/update.ts)_
_See code: [src/commands/texei/user/update.ts](https://github.com/texei/texei-sfdx-plugin/blob/v0.0.4/src/commands/texei/user/update.ts)_
<!-- commandsstop -->
6 changes: 6 additions & 0 deletions messages/list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"commandDescription": "Tools for sandboxes (list, refresh...) ",
"valuesFlagDescription": "the <fieldName>=<value> pairs you’re updating",
"errorNoOrgResults": "No results found for the organization '%s'.",
"list":"valuesFlagDescription"
}
2 changes: 1 addition & 1 deletion messages/update.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commandDescription": "Updates the current user of a scratch org",
"commandDescription": "Updates the current user of a scratch org!!",
"valuesFlagDescription": "the <fieldName>=<value> pairs you’re updating",
"errorNoOrgResults": "No results found for the organization '%s'."
}
77 changes: 77 additions & 0 deletions src/commands/texei/sandbox/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { core, SfdxCommand, flags } from '@salesforce/command';
var exec = require('child-process-promise').exec;

// Initialize Messages with the current plugin directory
core.Messages.importMessagesDirectory(__dirname);

// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
// or any library that is using the messages framework can also be loaded this way.
const messages = core.Messages.loadMessages('texei-sfdx-plugin', 'list');

export default class List extends SfdxCommand {

public static description = messages.getMessage('commandDescription');

public static examples = [
`$ sfdx texei:sandbox:list --targetusername myOrg@example.com`,
];

//public static args = [{ name: 'file' }];

protected static flagsConfig = {
// TODO: add flag for time color to warn refresh
list: flags.string({ char: 'l', description: messages.getMessage('valuesFlagDescription') })
};

// Comment this out if your command does not require an org username
protected static requiresUsername = true;

// Comment this out if your command does not support a hub org username
protected static supportsDevhubUsername = true;

// Set this to true if your command requires a project workspace; 'requiresProject' is false by default
protected static requiresProject = false;

public async run(): Promise<any> {

const values = this.flags.values;

// Define the query for retrieving Sandboxes informations
const query = "SELECT Id, SandboxName, Description, LicenseType FROM SandboxInfo";
const conn = this.org.getConnection();

try {
//Define our ouput list
let output = [];

// Query the org
const result = await conn.tooling.query(query) as any;

//
for (const record of result.records) {
// TODO: Add description and cut if too long ?
const sandboxInfo = {
id: record.Id,
name: record.SandboxName,
type: record.LicenseType
//description: record.Description
}

// Push result in ouput list
output.push(sandboxInfo);
}

// Show the list
this.ux.table(output, Object.keys(output[0]));

} catch (error) {


// Throw an error, sfdx library will manage the way to display it
//throw new core.SfdxError(records);
}

// Everything went fine, return an object that will be used for --json
return { org: this.org.getOrgId(), message: result };
}
}