sf-debug-log 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -0
- package/lib/commands/retrieve.d.ts +17 -0
- package/lib/commands/retrieve.js +101 -0
- package/lib/commands/retrieve.js.map +1 -0
- package/lib/commands/trace/new.d.ts +16 -0
- package/lib/commands/trace/new.js +95 -0
- package/lib/commands/trace/new.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/utils.d.ts +3 -0
- package/lib/utils.js +41 -0
- package/lib/utils.js.map +1 -0
- package/messages/retrieve.md +31 -0
- package/messages/trace.new.md +23 -0
- package/oclif.manifest.json +105 -0
- package/package.json +198 -0
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# debug-log
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/debug-log) [](https://npmjs.org/package/debug-log) [](https://raw.githubusercontent.com/salesforcecli/debug-log/main/LICENSE.txt)
|
|
4
|
+
|
|
5
|
+
## Using the template
|
|
6
|
+
|
|
7
|
+
This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
|
|
8
|
+
|
|
9
|
+
1. Please get in touch with the Platform CLI team. We want to help you develop your plugin.
|
|
10
|
+
2. Generate your plugin:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
sf plugins install dev
|
|
14
|
+
sf dev generate plugin
|
|
15
|
+
|
|
16
|
+
git init -b main
|
|
17
|
+
git add . && git commit -m "chore: initial commit"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
3. Create your plugin's repo in the salesforcecli github org
|
|
21
|
+
4. When you're ready, replace the contents of this README with the information you want.
|
|
22
|
+
|
|
23
|
+
## Learn about `sf` plugins
|
|
24
|
+
|
|
25
|
+
Salesforce CLI plugins are based on the [oclif plugin framework](<(https://oclif.io/docs/introduction.html)>). Read the [plugin developer guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_architecture_sf_cli.htm) to learn about Salesforce CLI plugin development.
|
|
26
|
+
|
|
27
|
+
This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the [node developer packages](#tooling) used by Salesforce.
|
|
28
|
+
|
|
29
|
+
Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the `posttest` script and it is required to keep these tests active in your plugin if you plan to have it bundled.
|
|
30
|
+
|
|
31
|
+
### Tooling
|
|
32
|
+
|
|
33
|
+
- [@salesforce/core](https://github.com/forcedotcom/sfdx-core)
|
|
34
|
+
- [@salesforce/kit](https://github.com/forcedotcom/kit)
|
|
35
|
+
- [@salesforce/sf-plugins-core](https://github.com/salesforcecli/sf-plugins-core)
|
|
36
|
+
- [@salesforce/ts-types](https://github.com/forcedotcom/ts-types)
|
|
37
|
+
- [@salesforce/ts-sinon](https://github.com/forcedotcom/ts-sinon)
|
|
38
|
+
- [@salesforce/dev-config](https://github.com/forcedotcom/dev-config)
|
|
39
|
+
- [@salesforce/dev-scripts](https://github.com/forcedotcom/dev-scripts)
|
|
40
|
+
|
|
41
|
+
### Hooks
|
|
42
|
+
|
|
43
|
+
For cross clouds commands, e.g. `sf env list`, we utilize [oclif hooks](https://oclif.io/docs/hooks) to get the relevant information from installed plugins.
|
|
44
|
+
|
|
45
|
+
This plugin includes sample hooks in the [src/hooks directory](src/hooks). You'll just need to add the appropriate logic. You can also delete any of the hooks if they aren't required for your plugin.
|
|
46
|
+
|
|
47
|
+
# Everything past here is only a suggestion as to what should be in your specific plugin's description
|
|
48
|
+
|
|
49
|
+
This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).
|
|
50
|
+
|
|
51
|
+
We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
|
|
52
|
+
|
|
53
|
+
## Install
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
sf plugins install debug-log@x.y.z
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Issues
|
|
60
|
+
|
|
61
|
+
Please report any issues at https://github.com/forcedotcom/cli/issues
|
|
62
|
+
|
|
63
|
+
## Contributing
|
|
64
|
+
|
|
65
|
+
1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
66
|
+
2. Create a new issue before starting your project so that we can keep track of
|
|
67
|
+
what you are trying to add/fix. That way, we can also offer suggestions or
|
|
68
|
+
let you know if there is already an effort in progress.
|
|
69
|
+
3. Fork this repository.
|
|
70
|
+
4. [Build the plugin locally](#build)
|
|
71
|
+
5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
|
|
72
|
+
6. Edit the code in your fork.
|
|
73
|
+
7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
|
|
74
|
+
8. Sign CLA (see [CLA](#cla) below).
|
|
75
|
+
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
|
|
76
|
+
|
|
77
|
+
### CLA
|
|
78
|
+
|
|
79
|
+
External contributors will be required to sign a Contributor's License
|
|
80
|
+
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
|
|
81
|
+
|
|
82
|
+
### Build
|
|
83
|
+
|
|
84
|
+
To build the plugin locally, make sure to have yarn installed and run the following commands:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Clone the repository
|
|
88
|
+
git clone git@github.com:salesforcecli/debug-log
|
|
89
|
+
|
|
90
|
+
# Install the dependencies and compile
|
|
91
|
+
yarn && yarn build
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Run using local run file.
|
|
98
|
+
./bin/dev hello world
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Link your plugin to the sf cli
|
|
105
|
+
sf plugins link .
|
|
106
|
+
# To verify
|
|
107
|
+
sf plugins
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Commands
|
|
111
|
+
|
|
112
|
+
<!-- commands -->
|
|
113
|
+
|
|
114
|
+
- [`sf hello world`](#sf-hello-world)
|
|
115
|
+
|
|
116
|
+
## `sf hello world`
|
|
117
|
+
|
|
118
|
+
Say hello either to the world or someone you know.
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
USAGE
|
|
122
|
+
$ sf hello world [--json] [-n <value>]
|
|
123
|
+
|
|
124
|
+
FLAGS
|
|
125
|
+
-n, --name=<value> [default: World] The name of the person you'd like to say hello to.
|
|
126
|
+
|
|
127
|
+
GLOBAL FLAGS
|
|
128
|
+
--json Format output as json.
|
|
129
|
+
|
|
130
|
+
DESCRIPTION
|
|
131
|
+
Say hello either to the world or someone you know.
|
|
132
|
+
|
|
133
|
+
Say hello either to the world or someone you know.
|
|
134
|
+
|
|
135
|
+
EXAMPLES
|
|
136
|
+
Say hello to the world:
|
|
137
|
+
|
|
138
|
+
$ sf hello world
|
|
139
|
+
|
|
140
|
+
Say hello to someone you know:
|
|
141
|
+
|
|
142
|
+
$ sf hello world --name Astro
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
<!-- commandsstop -->
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type RetrieveResult = {
|
|
3
|
+
isSuccess: boolean;
|
|
4
|
+
error?: string;
|
|
5
|
+
};
|
|
6
|
+
export default class Retrieve extends SfCommand<RetrieveResult> {
|
|
7
|
+
static readonly summary: string;
|
|
8
|
+
static readonly description: string;
|
|
9
|
+
static readonly examples: string[];
|
|
10
|
+
static readonly flags: {
|
|
11
|
+
targetusername: import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
+
user: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
time: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
+
folder: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<RetrieveResult>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
7
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
8
|
+
const core_1 = require("@salesforce/core");
|
|
9
|
+
const sanitize_filename_1 = __importDefault(require("sanitize-filename"));
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
12
|
+
const messages = core_1.Messages.loadMessages('sf-debug-log', 'retrieve');
|
|
13
|
+
class Retrieve extends sf_plugins_core_1.SfCommand {
|
|
14
|
+
async run() {
|
|
15
|
+
const { flags } = await this.parse(Retrieve);
|
|
16
|
+
const conn = flags.targetusername.getConnection();
|
|
17
|
+
let result;
|
|
18
|
+
try {
|
|
19
|
+
this.spinner.start('Retriving debug logs...');
|
|
20
|
+
const user = flags.user ? flags.user : conn.getUsername();
|
|
21
|
+
const userId = await (0, utils_1.getUserId)(conn, user);
|
|
22
|
+
const logs = await getLogs(conn, userId, flags.time);
|
|
23
|
+
await saveLogs(conn, logs, flags.folder);
|
|
24
|
+
this.spinner.stop();
|
|
25
|
+
return { isSuccess: true };
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
result = {
|
|
29
|
+
isSuccess: false,
|
|
30
|
+
error: err instanceof Error ? err.message : String(err),
|
|
31
|
+
};
|
|
32
|
+
throw messages.createError('error.saveLogs', [result.error]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
Retrieve.summary = messages.getMessage('summary');
|
|
37
|
+
Retrieve.description = messages.getMessage('description');
|
|
38
|
+
Retrieve.examples = messages.getMessages('examples');
|
|
39
|
+
Retrieve.flags = {
|
|
40
|
+
targetusername: sf_plugins_core_1.Flags.requiredOrg({
|
|
41
|
+
summary: messages.getMessage('flags.targetusername.summary'),
|
|
42
|
+
char: 'o',
|
|
43
|
+
required: true,
|
|
44
|
+
}),
|
|
45
|
+
user: sf_plugins_core_1.Flags.string({
|
|
46
|
+
summary: messages.getMessage('flags.user.summary'),
|
|
47
|
+
char: 'u',
|
|
48
|
+
}),
|
|
49
|
+
time: sf_plugins_core_1.Flags.integer({
|
|
50
|
+
summary: messages.getMessage('flags.time.summary'),
|
|
51
|
+
char: 't',
|
|
52
|
+
default: 60,
|
|
53
|
+
}),
|
|
54
|
+
folder: sf_plugins_core_1.Flags.directory({
|
|
55
|
+
summary: messages.getMessage('flags.folder.summary'),
|
|
56
|
+
char: 'd',
|
|
57
|
+
default: 'tools/debug/logs',
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
exports.default = Retrieve;
|
|
61
|
+
async function getLogs(conn, userId, time) {
|
|
62
|
+
const dateTime = new Date(Date.now());
|
|
63
|
+
dateTime.setMinutes(dateTime.getMinutes() - time);
|
|
64
|
+
const startTime = dateTime.toISOString();
|
|
65
|
+
const queryResult = await conn.query(`SELECT Id, LogUser.Name, LogLength, Request, Operation,
|
|
66
|
+
Application, Status, DurationMilliseconds,
|
|
67
|
+
SystemModstamp, RequestIdentifier
|
|
68
|
+
FROM ApexLog
|
|
69
|
+
WHERE SystemModstamp > ${startTime}
|
|
70
|
+
AND LogUserId = '${userId}'
|
|
71
|
+
ORDER BY SystemModstamp DESC`);
|
|
72
|
+
if (queryResult.records.length === 0) {
|
|
73
|
+
throw new Error('No debug logs found');
|
|
74
|
+
}
|
|
75
|
+
return queryResult.records;
|
|
76
|
+
}
|
|
77
|
+
async function saveLogs(conn, logs, directory) {
|
|
78
|
+
// Use Promise.all to parallelize the download and save operations
|
|
79
|
+
await Promise.all(logs.map(async (log) => {
|
|
80
|
+
const url = `${conn.instanceUrl}/apexdebug/traceDownload.apexp?id=${log.Id}`;
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
82
|
+
const date = new Date(log.SystemModstamp);
|
|
83
|
+
const hours = date.getHours();
|
|
84
|
+
const minutes = date.getMinutes();
|
|
85
|
+
const seconds = date.getSeconds();
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions
|
|
87
|
+
const fileName = `(${hours}-${minutes}-${seconds}) ${log.DurationMilliseconds}ms ${log.Request} ${log.Operation} ${log.Status}.log`;
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
89
|
+
const sanitizedFileName = (0, sanitize_filename_1.default)(fileName);
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions
|
|
91
|
+
const filePath = `${directory}/${log.LogUser.Name}/${sanitizedFileName}`;
|
|
92
|
+
try {
|
|
93
|
+
const body = await conn.request(url);
|
|
94
|
+
await (0, utils_1.createFile)(filePath, body);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
throw new Error('Error saving debug logs');
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
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,CAAC,OAAO,CAAC,IAAI,IAAI,iBAAiB,EAAE,CAAC;QACzE,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACrC,MAAM,IAAA,kBAAU,EAAC,QAAQ,EAAE,IAAc,CAAC,CAAC;SAC5C;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC5C;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type TraceNewResult = {
|
|
3
|
+
isSuccess: boolean;
|
|
4
|
+
error?: string;
|
|
5
|
+
};
|
|
6
|
+
export default class TraceNew extends SfCommand<TraceNewResult> {
|
|
7
|
+
static readonly summary: string;
|
|
8
|
+
static readonly examples: string[];
|
|
9
|
+
static readonly flags: {
|
|
10
|
+
targetusername: import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
|
+
user: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
+
time: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<TraceNewResult>;
|
|
15
|
+
private selectDebugLevel;
|
|
16
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
4
|
+
const core_1 = require("@salesforce/core");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const MILLISECONDS_PER_MINUTE = 60000;
|
|
7
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
8
|
+
const messages = core_1.Messages.loadMessages('sf-debug-log', 'trace.new');
|
|
9
|
+
class TraceNew extends sf_plugins_core_1.SfCommand {
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(TraceNew);
|
|
12
|
+
const conn = flags.targetusername.getConnection();
|
|
13
|
+
let result;
|
|
14
|
+
try {
|
|
15
|
+
this.spinner.start('Retriving debug levels...');
|
|
16
|
+
const user = flags.user ? flags.user : conn.getUsername();
|
|
17
|
+
const [userId, debugLevels] = await Promise.all([(0, utils_1.getUserId)(conn, user), getDebugLevels(conn)]);
|
|
18
|
+
this.spinner.stop();
|
|
19
|
+
const debuglevel = await this.selectDebugLevel(debugLevels);
|
|
20
|
+
this.spinner.start('Creating Trace Flag...');
|
|
21
|
+
result = await createTraceFlag(conn, userId, debuglevel, flags.time);
|
|
22
|
+
this.spinner.stop();
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
result = {
|
|
26
|
+
isSuccess: false,
|
|
27
|
+
error: err instanceof Error ? err.message : String(err),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (!result.isSuccess) {
|
|
31
|
+
throw messages.createError('error.createTraceFlag', [result.error]);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.log(`User Trace Flag successfully created for ${flags.user}`);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
async selectDebugLevel(debugLevels) {
|
|
39
|
+
const debuglevel = await this.prompt({
|
|
40
|
+
type: 'list',
|
|
41
|
+
name: 'debugLevel',
|
|
42
|
+
message: 'Select Debug Level',
|
|
43
|
+
choices: debugLevels.map((debugLevel) => ({
|
|
44
|
+
loop: false,
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/restrict-template-expressions
|
|
46
|
+
name: `${debugLevel.DeveloperName} (DB:${debugLevel.Database} Callout:${debugLevel.Callout} ApexCode:${debugLevel.ApexCode} Validation:${debugLevel.Validation} Workflow:${debugLevel.Workflow} Profiling:${debugLevel.ApexProfiling} Visualforce:${debugLevel.Visualforce} System:${debugLevel.System} Wave:${debugLevel.Wave} Nba:${debugLevel.Nba})`,
|
|
47
|
+
value: debugLevel.Id,
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
49
|
+
short: debugLevel.DeveloperName,
|
|
50
|
+
})),
|
|
51
|
+
});
|
|
52
|
+
return debuglevel.debugLevel;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
TraceNew.summary = messages.getMessage('summary');
|
|
56
|
+
TraceNew.examples = messages.getMessages('examples');
|
|
57
|
+
TraceNew.flags = {
|
|
58
|
+
targetusername: sf_plugins_core_1.Flags.requiredOrg({
|
|
59
|
+
summary: messages.getMessage('flags.targetusername.summary'),
|
|
60
|
+
char: 'o',
|
|
61
|
+
required: true,
|
|
62
|
+
}),
|
|
63
|
+
user: sf_plugins_core_1.Flags.string({
|
|
64
|
+
summary: messages.getMessage('flags.user.summary'),
|
|
65
|
+
char: 'u',
|
|
66
|
+
}),
|
|
67
|
+
time: sf_plugins_core_1.Flags.integer({
|
|
68
|
+
summary: messages.getMessage('flags.time.summary'),
|
|
69
|
+
default: 60,
|
|
70
|
+
}),
|
|
71
|
+
};
|
|
72
|
+
exports.default = TraceNew;
|
|
73
|
+
async function getDebugLevels(conn) {
|
|
74
|
+
const results = await conn.tooling.query('SELECT Id, DeveloperName, Workflow, Validation, Callout, ApexCode, ApexProfiling, Visualforce, System, Database, Wave, Nba FROM DebugLevel');
|
|
75
|
+
if (results?.records) {
|
|
76
|
+
return results.records;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
throw new Error('Error to retrieve Debug Levels');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function createTraceFlag(conn, userId, debugLevelId, time) {
|
|
83
|
+
const result = await conn.tooling.sobject('TraceFlag').create({
|
|
84
|
+
TracedEntityId: userId,
|
|
85
|
+
DebugLevelId: debugLevelId,
|
|
86
|
+
StartDate: new Date(Date.now()).toISOString(),
|
|
87
|
+
logtype: 'USER_DEBUG',
|
|
88
|
+
ExpirationDate: new Date(Date.now() + time * MILLISECONDS_PER_MINUTE).toISOString(),
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
isSuccess: result.success,
|
|
92
|
+
error: result.success ? undefined : result.errors[0].message,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=new.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/commands/trace/new.ts"],"names":[],"mappings":";;AAAA,iEAA+D;AAC/D,2CAAwD;AAExD,uCAAwC;AAExC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAEtC,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;AAOpE,MAAqB,QAAS,SAAQ,2BAAyB;IAoBtD,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7C,MAAM,IAAI,GAAe,KAAK,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;QAC9D,IAAI,MAAsB,CAAC;QAE3B,IAAI;YACF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAChD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,WAAW,EAAa,CAAC;YACtE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAA,iBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC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H,CAAC;AAED,KAAK,UAAU,eAAe,CAC5B,IAAgB,EAChB,MAAc,EACd,YAAoB,EACpB,IAAY;IAEZ,MAAM,MAAM,GAAe,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;QACxE,cAAc,EAAE,MAAM;QACtB,YAAY,EAAE,YAAY;QAC1B,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE;QAC7C,OAAO,EAAE,YAAY;QACrB,cAAc,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,uBAAuB,CAAC,CAAC,WAAW,EAAE;KACpF,CAAC,CAAC;IACH,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,OAAO;QACzB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO;KAC7D,CAAC;AACJ,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iBAAS,EAAE,CAAC"}
|
package/lib/utils.d.ts
ADDED
package/lib/utils.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserId = exports.createFile = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const util_1 = require("util");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const mkdirPromise = (0, util_1.promisify)(fs_1.mkdir);
|
|
8
|
+
const writeFilePromise = (0, util_1.promisify)(fs_1.writeFile);
|
|
9
|
+
async function createFile(path, contents) {
|
|
10
|
+
await mkdirPromise((0, path_1.dirname)(path), { recursive: true });
|
|
11
|
+
await writeFilePromise(path, contents);
|
|
12
|
+
}
|
|
13
|
+
exports.createFile = createFile;
|
|
14
|
+
async function getUserId(connection, inputUser) {
|
|
15
|
+
let result;
|
|
16
|
+
if (isValidEmail(inputUser)) {
|
|
17
|
+
result = await connection.tooling.sobject('User').findOne({ Username: inputUser });
|
|
18
|
+
}
|
|
19
|
+
else if (isId(inputUser)) {
|
|
20
|
+
result = await connection.tooling.sobject('User').findOne({ Id: inputUser });
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
result = await connection.tooling.sobject('User').findOne({ Name: inputUser });
|
|
24
|
+
}
|
|
25
|
+
if (result?.Id) {
|
|
26
|
+
return result.Id;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error(`User ${inputUser} not found`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.getUserId = getUserId;
|
|
33
|
+
function isValidEmail(input) {
|
|
34
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
35
|
+
return emailRegex.test(input);
|
|
36
|
+
}
|
|
37
|
+
function isId(input) {
|
|
38
|
+
const idRegex = /[a-zA-Z0-9]{15}|[a-zA-Z0-9]{18}/;
|
|
39
|
+
return idRegex.test(input);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+BAAiC;AACjC,2BAAsC;AAGtC,MAAM,YAAY,GAAG,IAAA,gBAAS,EAAC,UAAK,CAAC,CAAC;AACtC,MAAM,gBAAgB,GAAG,IAAA,gBAAS,EAAC,cAAS,CAAC,CAAC;AAEvC,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,QAAgB;IAC7D,MAAM,YAAY,CAAC,IAAA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|
+
|
|
3
|
+
Retrieve apex log files.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Retrieves apex log files from the Salesforce platform.
|
|
8
|
+
|
|
9
|
+
# flags.user.summary
|
|
10
|
+
|
|
11
|
+
Username or alias to retrieve logs for.
|
|
12
|
+
|
|
13
|
+
# flags.targetusername.summary
|
|
14
|
+
|
|
15
|
+
Username or alias to retrieve logs for.
|
|
16
|
+
|
|
17
|
+
# flags.time.summary
|
|
18
|
+
|
|
19
|
+
Start time for the logs to retrieve.
|
|
20
|
+
|
|
21
|
+
# flags.folder.summary
|
|
22
|
+
|
|
23
|
+
Folder where the logs are stored.
|
|
24
|
+
|
|
25
|
+
# error.saveLogs
|
|
26
|
+
|
|
27
|
+
Failed to save logs: %s.
|
|
28
|
+
|
|
29
|
+
# examples
|
|
30
|
+
|
|
31
|
+
- <%= config.bin %> <%= command.id %>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Create a trace flag for a user.
|
|
4
|
+
|
|
5
|
+
# flags.targetusername.summary
|
|
6
|
+
|
|
7
|
+
A username or alias for the target org.
|
|
8
|
+
|
|
9
|
+
# flags.user.summary
|
|
10
|
+
|
|
11
|
+
The username of the user to create the trace flag for.
|
|
12
|
+
|
|
13
|
+
# flags.time.summary
|
|
14
|
+
|
|
15
|
+
The time for the trace flag.
|
|
16
|
+
|
|
17
|
+
# error.createTraceFlag
|
|
18
|
+
|
|
19
|
+
Create User Trace Flag failed: %s.
|
|
20
|
+
|
|
21
|
+
# examples
|
|
22
|
+
|
|
23
|
+
example
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.0.2",
|
|
3
|
+
"commands": {
|
|
4
|
+
"retrieve": {
|
|
5
|
+
"id": "retrieve",
|
|
6
|
+
"summary": "Retrieve apex log files.",
|
|
7
|
+
"description": "Retrieves apex log files from the Salesforce platform.",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"pluginName": "sf-debug-log",
|
|
10
|
+
"pluginAlias": "sf-debug-log",
|
|
11
|
+
"pluginType": "core",
|
|
12
|
+
"aliases": [],
|
|
13
|
+
"examples": [
|
|
14
|
+
"<%= config.bin %> <%= command.id %>"
|
|
15
|
+
],
|
|
16
|
+
"flags": {
|
|
17
|
+
"json": {
|
|
18
|
+
"name": "json",
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"description": "Format output as json.",
|
|
21
|
+
"helpGroup": "GLOBAL",
|
|
22
|
+
"allowNo": false
|
|
23
|
+
},
|
|
24
|
+
"targetusername": {
|
|
25
|
+
"name": "targetusername",
|
|
26
|
+
"type": "option",
|
|
27
|
+
"char": "o",
|
|
28
|
+
"summary": "Username or alias to retrieve logs for.",
|
|
29
|
+
"required": true,
|
|
30
|
+
"multiple": false
|
|
31
|
+
},
|
|
32
|
+
"user": {
|
|
33
|
+
"name": "user",
|
|
34
|
+
"type": "option",
|
|
35
|
+
"char": "u",
|
|
36
|
+
"summary": "Username or alias to retrieve logs for.",
|
|
37
|
+
"multiple": false
|
|
38
|
+
},
|
|
39
|
+
"time": {
|
|
40
|
+
"name": "time",
|
|
41
|
+
"type": "option",
|
|
42
|
+
"char": "t",
|
|
43
|
+
"summary": "Start time for the logs to retrieve.",
|
|
44
|
+
"multiple": false,
|
|
45
|
+
"default": 60
|
|
46
|
+
},
|
|
47
|
+
"folder": {
|
|
48
|
+
"name": "folder",
|
|
49
|
+
"type": "option",
|
|
50
|
+
"char": "d",
|
|
51
|
+
"summary": "Folder where the logs are stored.",
|
|
52
|
+
"multiple": false,
|
|
53
|
+
"default": "tools/debug/logs"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"args": {},
|
|
57
|
+
"hasDynamicHelp": true
|
|
58
|
+
},
|
|
59
|
+
"trace:new": {
|
|
60
|
+
"id": "trace:new",
|
|
61
|
+
"summary": "Create a trace flag for a user.",
|
|
62
|
+
"strict": true,
|
|
63
|
+
"pluginName": "sf-debug-log",
|
|
64
|
+
"pluginAlias": "sf-debug-log",
|
|
65
|
+
"pluginType": "core",
|
|
66
|
+
"aliases": [],
|
|
67
|
+
"examples": [
|
|
68
|
+
"example"
|
|
69
|
+
],
|
|
70
|
+
"flags": {
|
|
71
|
+
"json": {
|
|
72
|
+
"name": "json",
|
|
73
|
+
"type": "boolean",
|
|
74
|
+
"description": "Format output as json.",
|
|
75
|
+
"helpGroup": "GLOBAL",
|
|
76
|
+
"allowNo": false
|
|
77
|
+
},
|
|
78
|
+
"targetusername": {
|
|
79
|
+
"name": "targetusername",
|
|
80
|
+
"type": "option",
|
|
81
|
+
"char": "o",
|
|
82
|
+
"summary": "A username or alias for the target org.",
|
|
83
|
+
"required": true,
|
|
84
|
+
"multiple": false
|
|
85
|
+
},
|
|
86
|
+
"user": {
|
|
87
|
+
"name": "user",
|
|
88
|
+
"type": "option",
|
|
89
|
+
"char": "u",
|
|
90
|
+
"summary": "The username of the user to create the trace flag for.",
|
|
91
|
+
"multiple": false
|
|
92
|
+
},
|
|
93
|
+
"time": {
|
|
94
|
+
"name": "time",
|
|
95
|
+
"type": "option",
|
|
96
|
+
"summary": "The time for the trace flag.",
|
|
97
|
+
"multiple": false,
|
|
98
|
+
"default": 60
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"args": {},
|
|
102
|
+
"hasDynamicHelp": true
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sf-debug-log",
|
|
3
|
+
"description": "Manage Salesforce Debug Logs",
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@oclif/core": "^2.11.8",
|
|
7
|
+
"@salesforce/core": "^5.2.0",
|
|
8
|
+
"@salesforce/kit": "^3.0.8",
|
|
9
|
+
"@salesforce/sf-plugins-core": "^3.1.14",
|
|
10
|
+
"sanitize-filename": "^1.6.3",
|
|
11
|
+
"tslib": "^2"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@salesforce/cli-plugins-testkit": "^4.3.0",
|
|
15
|
+
"@salesforce/dev-config": "^4.0.1",
|
|
16
|
+
"@salesforce/dev-scripts": "^5.7.0",
|
|
17
|
+
"@salesforce/prettier-config": "^0.0.3",
|
|
18
|
+
"@salesforce/ts-sinon": "^1.4.14",
|
|
19
|
+
"@swc/core": "^1.3.19",
|
|
20
|
+
"@types/inquirer": "^9.0.3",
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
|
22
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
23
|
+
"chai": "^4.3.6",
|
|
24
|
+
"eslint": "^8.47.0",
|
|
25
|
+
"eslint-config-prettier": "^8.5.0",
|
|
26
|
+
"eslint-config-salesforce": "^2.0.2",
|
|
27
|
+
"eslint-config-salesforce-typescript": "^1.1.2",
|
|
28
|
+
"eslint-plugin-import": "2.28.1",
|
|
29
|
+
"eslint-plugin-jsdoc": "^46.4.6",
|
|
30
|
+
"eslint-plugin-sf-plugin": "^1.16.2",
|
|
31
|
+
"husky": "^7.0.4",
|
|
32
|
+
"mocha": "^9.2.2",
|
|
33
|
+
"nyc": "^15.1.0",
|
|
34
|
+
"oclif": "^3.9.1",
|
|
35
|
+
"prettier": "^2.8.8",
|
|
36
|
+
"pretty-quick": "^3.1.3",
|
|
37
|
+
"shx": "0.3.4",
|
|
38
|
+
"sinon": "10.0.0",
|
|
39
|
+
"ts-node": "^10.9.1",
|
|
40
|
+
"typescript": "^5.1.6",
|
|
41
|
+
"wireit": "^0.10.0"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=16.0.0"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"/lib",
|
|
48
|
+
"/messages",
|
|
49
|
+
"/oclif.manifest.json"
|
|
50
|
+
],
|
|
51
|
+
"keywords": [
|
|
52
|
+
"force",
|
|
53
|
+
"salesforce",
|
|
54
|
+
"sfdx",
|
|
55
|
+
"salesforcedx",
|
|
56
|
+
"sfdx-plugin",
|
|
57
|
+
"sf-plugin",
|
|
58
|
+
"sf"
|
|
59
|
+
],
|
|
60
|
+
"license": "BSD-3-Clause",
|
|
61
|
+
"main": "lib/index.js",
|
|
62
|
+
"oclif": {
|
|
63
|
+
"commands": "./lib/commands",
|
|
64
|
+
"bin": "sf",
|
|
65
|
+
"topicSeparator": " ",
|
|
66
|
+
"devPlugins": [
|
|
67
|
+
"@oclif/plugin-help"
|
|
68
|
+
],
|
|
69
|
+
"topics": {
|
|
70
|
+
"trace": {
|
|
71
|
+
"description": "description for trace"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"scripts": {
|
|
76
|
+
"build": "wireit",
|
|
77
|
+
"clean": "sf-clean",
|
|
78
|
+
"clean-all": "sf-clean all",
|
|
79
|
+
"clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json",
|
|
80
|
+
"compile": "wireit",
|
|
81
|
+
"docs": "sf-docs",
|
|
82
|
+
"format": "wireit",
|
|
83
|
+
"lint": "wireit",
|
|
84
|
+
"postinstall": "yarn husky install",
|
|
85
|
+
"postpack": "shx rm -f oclif.manifest.json",
|
|
86
|
+
"prepack": "sf-prepack",
|
|
87
|
+
"test": "wireit",
|
|
88
|
+
"test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel",
|
|
89
|
+
"test:only": "wireit",
|
|
90
|
+
"version": "oclif readme"
|
|
91
|
+
},
|
|
92
|
+
"publishConfig": {
|
|
93
|
+
"access": "public"
|
|
94
|
+
},
|
|
95
|
+
"wireit": {
|
|
96
|
+
"build": {
|
|
97
|
+
"dependencies": [
|
|
98
|
+
"compile",
|
|
99
|
+
"lint"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"compile": {
|
|
103
|
+
"command": "tsc -p . --pretty --incremental",
|
|
104
|
+
"files": [
|
|
105
|
+
"src/**/*.ts",
|
|
106
|
+
"**/tsconfig.json",
|
|
107
|
+
"messages/**"
|
|
108
|
+
],
|
|
109
|
+
"output": [
|
|
110
|
+
"lib/**",
|
|
111
|
+
"*.tsbuildinfo"
|
|
112
|
+
],
|
|
113
|
+
"clean": "if-file-deleted"
|
|
114
|
+
},
|
|
115
|
+
"format": {
|
|
116
|
+
"command": "prettier --write \"+(src|test|schemas)/**/*.+(ts|js|json)|command-snapshot.json\"",
|
|
117
|
+
"files": [
|
|
118
|
+
"src/**/*.ts",
|
|
119
|
+
"test/**/*.ts",
|
|
120
|
+
"schemas/**/*.json",
|
|
121
|
+
"command-snapshot.json",
|
|
122
|
+
".prettier*"
|
|
123
|
+
],
|
|
124
|
+
"output": []
|
|
125
|
+
},
|
|
126
|
+
"lint": {
|
|
127
|
+
"command": "eslint src test --color --cache --cache-location .eslintcache",
|
|
128
|
+
"files": [
|
|
129
|
+
"src/**/*.ts",
|
|
130
|
+
"test/**/*.ts",
|
|
131
|
+
"messages/**",
|
|
132
|
+
"**/.eslint*",
|
|
133
|
+
"**/tsconfig.json"
|
|
134
|
+
],
|
|
135
|
+
"output": []
|
|
136
|
+
},
|
|
137
|
+
"test:compile": {
|
|
138
|
+
"command": "tsc -p \"./test\" --pretty",
|
|
139
|
+
"files": [
|
|
140
|
+
"test/**/*.ts",
|
|
141
|
+
"**/tsconfig.json"
|
|
142
|
+
],
|
|
143
|
+
"output": []
|
|
144
|
+
},
|
|
145
|
+
"test": {
|
|
146
|
+
"dependencies": [
|
|
147
|
+
"test:compile",
|
|
148
|
+
"test:only",
|
|
149
|
+
"lint"
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
"test:only": {
|
|
153
|
+
"command": "nyc mocha \"test/**/*.test.ts\"",
|
|
154
|
+
"env": {
|
|
155
|
+
"FORCE_COLOR": "2"
|
|
156
|
+
},
|
|
157
|
+
"files": [
|
|
158
|
+
"test/**/*.ts",
|
|
159
|
+
"src/**/*.ts",
|
|
160
|
+
"**/tsconfig.json",
|
|
161
|
+
".mocha*",
|
|
162
|
+
"!*.nut.ts",
|
|
163
|
+
".nycrc"
|
|
164
|
+
],
|
|
165
|
+
"output": []
|
|
166
|
+
},
|
|
167
|
+
"test:command-reference": {
|
|
168
|
+
"command": "\"./bin/dev\" commandreference:generate --erroronwarnings",
|
|
169
|
+
"files": [
|
|
170
|
+
"src/**/*.ts",
|
|
171
|
+
"messages/**",
|
|
172
|
+
"package.json"
|
|
173
|
+
],
|
|
174
|
+
"output": [
|
|
175
|
+
"tmp/root"
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
"test:deprecation-policy": {
|
|
179
|
+
"command": "\"./bin/dev\" snapshot:compare",
|
|
180
|
+
"files": [
|
|
181
|
+
"src/**/*.ts"
|
|
182
|
+
],
|
|
183
|
+
"output": [],
|
|
184
|
+
"dependencies": [
|
|
185
|
+
"compile"
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
"test:json-schema": {
|
|
189
|
+
"command": "\"./bin/dev\" schema:compare",
|
|
190
|
+
"files": [
|
|
191
|
+
"src/**/*.ts",
|
|
192
|
+
"schemas"
|
|
193
|
+
],
|
|
194
|
+
"output": []
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
"author": "Raffaele Preziosi"
|
|
198
|
+
}
|