Skip to content

Commit

Permalink
0.2.0 (#6)
Browse files Browse the repository at this point in the history
* Initial version of command: oa:data:soql:sel
  • Loading branch information
osieckiAdam authored Jan 5, 2020
1 parent 130dfe6 commit 6ac3a15
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 44 deletions.
7 changes: 1 addition & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ jobs:
command: yarn
- run:
name: Testing
command: yarn test
command: yarn testcov
- codecov/upload:
file: coverage/lcov.info
node-8:
<<: *test
docker:
- image: node:8
node-10:
<<: *test
docker:
Expand All @@ -48,7 +44,6 @@ workflows:
"osiecki-sfdx-plugins":
jobs:
- node-latest
- node-8
- node-10
- cache:
filters:
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
59 changes: 54 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ A plugin for the Salesforce CLI built by Adam Osiecki
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/osieckiAdam/osiecki-sfdx-plugins?branch=master&svg=true)](https://ci.appveyor.com/project/heroku/osiecki-sfdx-plugins/branch/master)
[![Codecov](https://codecov.io/gh/osieckiAdam/osiecki-sfdx-plugins/branch/master/graph/badge.svg)](https://codecov.io/gh/osieckiAdam/osiecki-sfdx-plugins)
[![Downloads/week](https://img.shields.io/npm/dw/osiecki-sfdx-plugins.svg)](https://npmjs.org/package/osiecki-sfdx-plugins)
[![License](https://img.shields.io/npm/l/osiecki-sfdx-plugins.svg)](https://github.com/osieckiAdam/osiecki-sfdx-plugins/blob/master/package.json) [![Greenkeeper badge](https://badges.greenkeeper.io/osieckiAdam/osiecki-sfdx-plugins.svg)](https://greenkeeper.io/)
[![License](https://img.shields.io/npm/l/osiecki-sfdx-plugins.svg)](https://github.com/osieckiAdam/osiecki-sfdx-plugins/blob/master/package.json)
[![Greenkeeper badge](https://badges.greenkeeper.io/osieckiAdam/osiecki-sfdx-plugins.svg)](https://greenkeeper.io/)
[![Known Vulnerabilities](https://snyk.io/test/github/osieckiAdam/osiecki-sfdx-plugins/badge.svg)](https://snyk.io/test/github/osieckiAdam/osiecki-sfdx-plugins)

## Setup
Expand Down Expand Up @@ -57,16 +58,16 @@ sfdx plugins:link
## Commands

<!-- commands -->

- [`sfdx oa:apex:log:delete [-c] [-a] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-oaapexlogdelete--c--a--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
* [`sfdx oa:apex:log:delete [-c] [-a] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-oaapexlogdelete--c--a--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
* [`sfdx oa:data:soql:sel -f <string> [-w <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-oadatasoqlsel--f-string--w-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)

## `sfdx oa:apex:log:delete [-c] [-a] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

delete ApexLog entries from Your org

```
USAGE
$ sfdx oa:apex:log:delete [-c] [-a] [-u <string>] [--apiversion <string>] [--json] [--loglevel
$ sfdx oa:apex:log:delete [-c] [-a] [-u <string>] [--apiversion <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
Expand Down Expand Up @@ -118,6 +119,54 @@ EXAMPLES
}
```

_See code: [lib\commands\oa\apex\log\delete.js](https://github.com/osieckiAdam/osiecki-sfdx-plugins/blob/v0.1.3/lib\commands\oa\apex\log\delete.js)_
_See code: [lib\commands\oa\apex\log\delete.js](https://github.com/osieckiAdam/osiecki-sfdx-plugins/blob/v0.2.0/lib\commands\oa\apex\log\delete.js)_

## `sfdx oa:data:soql:sel -f <string> [-w <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

generate query for all fields from SObject (SEL * FROM SObject)

```
USAGE
$ sfdx oa:data:soql:sel -f <string> [-w <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-f, --from=from (required) SObject to generate query
for
-u, --targetusername=targetusername username or alias for the target
org; overrides default target org
-w, --where=where Add WHERE clause to Your query
--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|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
EXAMPLES
sfdx oa:data:soql:sel -f ApexLog
Your query was succesfully copied to clipboard:
SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status, DurationMilliseconds,
SystemModstamp, StartTime, Location FROM ApexLog
sfdx oa:data:soql:sel -f ApexLog --json
{
"status": 0,
"result": {
"query": "SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status,
DurationMilliseconds, SystemModstamp, StartTime, Location FROM ApexLog"
}
}
sfdx oa:data:soql:sel -f ApexLog -w "LogLength > 100"
Your query was succesfully copied to clipboard:
SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status, DurationMilliseconds,
SystemModstamp, StartTime, Location FROM ApexLog WHERE Where LogLength > 100
```

_See code: [lib\commands\oa\data\soql\sel.js](https://github.com/osieckiAdam/osiecki-sfdx-plugins/blob/v0.2.0/lib\commands\oa\data\soql\sel.js)_
<!-- commandsstop -->
4 changes: 0 additions & 4 deletions messages/queryall.json

This file was deleted.

5 changes: 5 additions & 0 deletions messages/sel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"commandDescription": "generate query for all fields from SObject (SEL * FROM SObject)",
"fromFlagDescription": "SObject to generate query for",
"whereFlagDescription": "Add WHERE clause to Your query"
}
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "osiecki-sfdx-plugins",
"description": "SFDX plugins by Adam Osiecki",
"version": "0.1.3",
"version": "0.2.0",
"author": "Adam Osiecki @osieckiAdam",
"bugs": "https://github.com/osieckiAdam/osiecki-sfdx-plugins/issues",
"dependencies": {
Expand All @@ -10,7 +10,10 @@
"@oclif/errors": "^1",
"@salesforce/command": "^2",
"@salesforce/core": "^2",
"@types/copy-paste": "^1.1.30",
"@types/jsforce": "^1.9.12",
"clipboardy": "^2.1.0",
"copy-paste": "^1.3.0",
"tslib": "^1"
},
"devDependencies": {
Expand Down Expand Up @@ -61,7 +64,8 @@
"postpack": "rimraf oclif.manifest.json",
"posttest": "tslint -p test -t stylish",
"prepack": "rimraf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"test": "nyc --reporter=lcovonly --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"testcov": "nyc --reporter=lcovonly --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif-dev readme && git add README.md"
}
}
3 changes: 0 additions & 3 deletions src/commands/oa/apex/log/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ sfdx oa:apex:log:delete --json'
.sobject('ApexLog')
.find({}, ['Id'])
.execute({ autoFetch: true, maxFetch: 10000 }, async (err, records) => {
if (err) {
return console.error(err);
}
return records;
});
return response;
Expand Down
54 changes: 54 additions & 0 deletions src/commands/oa/data/soql/sel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { core, flags, SfdxCommand } from '@salesforce/command';
import { AnyJson } from '@salesforce/ts-types';
import ncp = require('copy-paste');

core.Messages.importMessagesDirectory(__dirname);
const messages = core.Messages.loadMessages('osiecki-sfdx-plugins', 'sel');

export default class Sel extends SfdxCommand {

public static description = messages.getMessage('commandDescription');
public static examples = [
`sfdx oa:data:soql:sel -f ApexLog
Your query was succesfully copied to clipboard:
SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status, DurationMilliseconds,
SystemModstamp, StartTime, Location FROM ApexLog
`,
`sfdx oa:data:soql:sel -f ApexLog --json
{
"status": 0,
"result": {
"query": "SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status,
DurationMilliseconds, SystemModstamp, StartTime, Location FROM ApexLog"
}
}
`,
`sfdx oa:data:soql:sel -f ApexLog -w "LogLength > 100"
Your query was succesfully copied to clipboard:
SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status, DurationMilliseconds,
SystemModstamp, StartTime, Location FROM ApexLog WHERE Where LogLength > 100
`
];

protected static requiresUsername = true;
protected static flagsConfig = {
from: flags.string({ char: 'f', required: true, description: messages.getMessage('fromFlagDescription') }),
where: flags.string({ char: 'w', description: messages.getMessage('whereFlagDescription') })
};

public async run(): Promise<AnyJson> {
let query: string = '';
const conn = this.org.getConnection();
await conn.sobject(this.flags.from).find().where(this.flags.where)
.toSOQL((err, res) => {
if (err) {
this.ux.log(err.message);
} else {
query += res;
ncp.copy(query);
this.ux.log('Your query was succesfully copied to clipbzoard:\n' + query);
}
});
return { query };
}
}
Loading

0 comments on commit 6ac3a15

Please sign in to comment.