sf-debug-log 0.0.20 → 0.0.22

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 CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  Commands to manage Salesforce debug logs.
4
4
 
5
+ Create trace flags for any user in the org selecting the debug level and time.
6
+ Retrive Apex logs related to a specific user to analyze them locally.
7
+
5
8
  ## Install
6
9
 
7
10
  ```bash
@@ -17,16 +20,14 @@ sf plugins install sf-debug-log
17
20
 
18
21
  ## `sf trace new`
19
22
 
20
- Create a new trace flag.
21
-
22
23
  ```
23
24
  USAGE
24
- $ sf trace new
25
+ $ sf trace new -o <value> [-u <value>] [-t <value>]
25
26
 
26
27
  FLAGS
27
- -o, --targetusername=<value> [required] A username or alias for the target org.
28
- -u, --name=<value> The name of the user to trace.
28
+ -o, --targetusername=<value> [required] Username or alias of the target Salesforce org.
29
29
  -t, --time=<value> [default: 60] The number of minutes to trace.
30
+ -u, --name=<value> [default: targetusername] Username, Name, or ID of the user for whom you want to retrieve the logs.
30
31
 
31
32
  GLOBAL FLAGS
32
33
  --json Format output as json.
@@ -34,28 +35,31 @@ GLOBAL FLAGS
34
35
  DESCRIPTION
35
36
  Create a new trace flag.
36
37
 
38
+ This command is used to create a trace flag for a specific user in the Salesforce org.
39
+
37
40
  EXAMPLES
38
41
  sf trace new -o DeveloperEdition -u "Raffaele Preziosi" -t 10
39
42
  ```
40
43
 
41
44
  ## `sf debug retrieve`
42
45
 
43
- Retrieve apex log files.
44
-
45
46
  ```
46
47
  USAGE
47
- $ sf debug retrieve
48
+ $ sf debug retrieve -o <value> [-u <value>] [-t <value>] [-d <value>]
48
49
 
49
50
  FLAGS
50
- -o, --targetusername=<value> [required] A username or alias for the target org.
51
- -u, --name=<value> The name of the user to trace.
52
- -t, --time=<value> [default: 60] Minutes to retrieve logs for.
51
+ -d, --folder=<value> [default: .sfdx/tools/debug/logs] The folder where the retrieved log files will be stored.
52
+ -o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
53
+ -t, --time=<value> [default: 60] The number of minutes to retrieve log files for.
54
+ -u, --user=<value> [default: targetusername] Username, Name, or ID of the user for whom you want to retrieve the logs.
53
55
 
54
56
  GLOBAL FLAGS
55
57
  --json Format output as json.
56
58
 
57
59
  DESCRIPTION
58
- Retrieves apex log files from the Salesforce platform.
60
+ Retrieve Apex log files from the Salesforce platform.
61
+
62
+ This command allows you to retrieve Apex log files from a Salesforce org.
59
63
 
60
64
  EXAMPLES
61
65
  sf debug retrieve -o DeveloperEdition -u "Raffaele Preziosi" -t 10
@@ -0,0 +1,17 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type DebuglevelNewResult = {
3
+ isSuccess: boolean;
4
+ error?: string;
5
+ };
6
+ export default class DebuglevelNew extends SfCommand<DebuglevelNewResult> {
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
+ developername: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ };
14
+ run(): Promise<DebuglevelNewResult>;
15
+ private createDebugLevelRecord;
16
+ private selectDebugLevel;
17
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable class-methods-use-this */
4
+ const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
5
+ const core_1 = require("@salesforce/core");
6
+ const utils_1 = require("../../utils");
7
+ core_1.Messages.importMessagesDirectory(__dirname);
8
+ const messages = core_1.Messages.loadMessages('sf-debug-log', 'debuglevel.new');
9
+ const DEBUG_CATEGORIES = [
10
+ 'Database',
11
+ 'Workflow',
12
+ 'Validation',
13
+ 'Callout',
14
+ 'ApexCode',
15
+ 'ApexProfiling',
16
+ 'Visualforce',
17
+ 'System',
18
+ 'Wave',
19
+ 'Nba',
20
+ ];
21
+ const DEBUG_LEVELS = ['NONE', 'INTERNAL', 'FINEST', 'FINER', 'FINE', 'DEBUG', 'INFO', 'WARN', 'ERROR'];
22
+ class DebuglevelNew extends sf_plugins_core_1.SfCommand {
23
+ async run() {
24
+ const { flags } = await this.parse(DebuglevelNew);
25
+ const conn = flags.targetusername.getConnection();
26
+ try {
27
+ const debugLevel = this.createDebugLevelRecord(flags.developername);
28
+ for (const category of DEBUG_CATEGORIES) {
29
+ // eslint-disable-next-line no-await-in-loop
30
+ const level = await this.selectDebugLevel(category);
31
+ debugLevel[category] = level;
32
+ }
33
+ const result = await (0, utils_1.createDebugLevel)(conn, debugLevel);
34
+ if (!result.isSuccess) {
35
+ this.error(`Error to create Debug Level: ${result.error}`);
36
+ }
37
+ else {
38
+ this.log(`Debug Level ${flags.developername} created successfully.`);
39
+ }
40
+ return result;
41
+ }
42
+ catch (exception) {
43
+ const err = exception instanceof Error ? exception.message : String(exception);
44
+ this.log(`Error to create Debug Level: ${err}`);
45
+ return {
46
+ isSuccess: false,
47
+ error: err,
48
+ };
49
+ }
50
+ }
51
+ createDebugLevelRecord(developerName) {
52
+ return {
53
+ DeveloperName: developerName,
54
+ MasterLabel: developerName,
55
+ };
56
+ }
57
+ async selectDebugLevel(category) {
58
+ const levels = DEBUG_LEVELS;
59
+ const level = await this.prompt({
60
+ type: 'list',
61
+ name: 'level',
62
+ message: `Select ${category} debug level`,
63
+ loop: false,
64
+ choices: levels,
65
+ });
66
+ return level.level;
67
+ }
68
+ }
69
+ DebuglevelNew.summary = messages.getMessage('summary');
70
+ DebuglevelNew.description = messages.getMessage('description');
71
+ DebuglevelNew.examples = messages.getMessages('examples');
72
+ DebuglevelNew.flags = {
73
+ targetusername: sf_plugins_core_1.Flags.requiredOrg({
74
+ summary: messages.getMessage('flags.targetusername.summary'),
75
+ char: 'o',
76
+ required: true,
77
+ }),
78
+ developername: sf_plugins_core_1.Flags.string({
79
+ summary: messages.getMessage('flags.developerName.summary'),
80
+ char: 'n',
81
+ required: true,
82
+ }),
83
+ };
84
+ exports.default = DebuglevelNew;
85
+ //# sourceMappingURL=new.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/commands/debuglevel/new.ts"],"names":[],"mappings":";;AAAA,2CAA2C;AAC3C,iEAA+D;AAC/D,2CAAwD;AACxD,uCAA+C;AAE/C,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAEzE,MAAM,gBAAgB,GAAG;IACvB,UAAU;IACV,UAAU;IACV,YAAY;IACZ,SAAS;IACT,UAAU;IACV,eAAe;IACf,aAAa;IACb,QAAQ;IACR,MAAM;IACN,KAAK;CACN,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAavG,MAAqB,aAAc,SAAQ,2BAA8B;IAkBhE,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAClD,MAAM,IAAI,GAAe,KAAK,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;QAE9D,IAAI;YACF,MAAM,UAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YAEpE,KAAK,MAAM,QAAQ,IAAI,gBAAgB,EAAE;gBACvC,4CAA4C;gBAC5C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;gBACpD,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;aAC9B;YAED,MAAM,MAAM,GAA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AAC;AAE5C,mBAAK,GAAG;IAC7B,cAAc,EAAE,uBAAK,CAAC,WAAW,CAAC;QAChC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;QAC5D,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,aAAa,EAAE,uBAAK,CAAC,MAAM,CAAC;QAC1B,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;QAC3D,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,IAAI;KACf,CAAC;CACH,CAAC;kBAhBiB,aAAa"}
@@ -12,5 +12,6 @@ export default class TraceNew extends SfCommand<TraceNewResult> {
12
12
  time: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
13
  };
14
14
  run(): Promise<TraceNewResult>;
15
+ private selectToProceed;
15
16
  private selectDebugLevel;
16
17
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
4
4
  const core_1 = require("@salesforce/core");
5
5
  const utils_1 = require("../../utils");
6
- const MILLISECONDS_PER_MINUTE = 60000;
7
6
  core_1.Messages.importMessagesDirectory(__dirname);
8
7
  const messages = core_1.Messages.loadMessages('sf-debug-log', 'trace.new');
9
8
  class TraceNew extends sf_plugins_core_1.SfCommand {
@@ -15,26 +14,46 @@ class TraceNew extends sf_plugins_core_1.SfCommand {
15
14
  try {
16
15
  this.spinner.start('Retriving debug levels...');
17
16
  user = flags.user ? flags.user : conn.getUsername();
18
- const [userId, debugLevels] = await Promise.all([(0, utils_1.getUserId)(conn, user), getDebugLevels(conn)]);
17
+ const userId = await (0, utils_1.getUserId)(conn, user);
18
+ const [activeFlag, debugLevels] = await Promise.all([(0, utils_1.getActiveTraceFlag)(conn, userId), (0, utils_1.getDebugLevels)(conn)]);
19
19
  this.spinner.stop();
20
+ if (activeFlag?.Id) {
21
+ const shouldProceed = await this.selectToProceed();
22
+ if (!shouldProceed) {
23
+ return { isSuccess: false, error: 'Trace Flag already exists for this user.' };
24
+ }
25
+ else {
26
+ this.spinner.start('Deleting existing Trace Flag...');
27
+ await conn.tooling.sobject('TraceFlag').delete(activeFlag.Id);
28
+ this.spinner.stop();
29
+ }
30
+ }
20
31
  const debuglevel = await this.selectDebugLevel(debugLevels);
21
32
  this.spinner.start('Creating Trace Flag...');
22
- result = await createTraceFlag(conn, userId, debuglevel, flags.time);
33
+ result = await (0, utils_1.createTraceFlag)(conn, userId, debuglevel, flags.time);
34
+ this.spinner.stop();
35
+ if (!result.isSuccess) {
36
+ this.error(`Error to create Trace Flag: ${result.error}`);
37
+ }
38
+ else {
39
+ this.log(`User Trace Flag successfully created for ${user}`);
40
+ }
41
+ return result;
23
42
  }
24
43
  catch (err) {
25
- result = {
44
+ return {
26
45
  isSuccess: false,
27
46
  error: err instanceof Error ? err.message : String(err),
28
47
  };
29
48
  }
30
- this.spinner.stop();
31
- if (!result.isSuccess) {
32
- this.error(`Error to create Trace Flag: ${result.error}`);
33
- }
34
- else {
35
- this.log(`User Trace Flag successfully created for ${user}`);
36
- }
37
- return result;
49
+ }
50
+ async selectToProceed() {
51
+ const proceed = await this.prompt({
52
+ type: 'confirm',
53
+ name: 'proceed',
54
+ message: 'Trace Flag already exists for this user. Do you want to proceed?',
55
+ });
56
+ return proceed.proceed;
38
57
  }
39
58
  async selectDebugLevel(debugLevels) {
40
59
  const debuglevel = await this.prompt({
@@ -67,30 +86,9 @@ TraceNew.flags = {
67
86
  }),
68
87
  time: sf_plugins_core_1.Flags.integer({
69
88
  summary: messages.getMessage('flags.time.summary'),
89
+ char: 't',
70
90
  default: 60,
71
91
  }),
72
92
  };
73
93
  exports.default = TraceNew;
74
- async function getDebugLevels(conn) {
75
- const results = await conn.tooling.query('SELECT Id, DeveloperName, Workflow, Validation, Callout, ApexCode, ApexProfiling, Visualforce, System, Database, Wave, Nba FROM DebugLevel');
76
- if (results?.records) {
77
- return results.records;
78
- }
79
- else {
80
- throw new Error('Error to retrieve Debug Levels');
81
- }
82
- }
83
- async function createTraceFlag(conn, userId, debugLevelId, time) {
84
- const result = await conn.tooling.sobject('TraceFlag').create({
85
- TracedEntityId: userId,
86
- DebugLevelId: debugLevelId,
87
- StartDate: new Date(Date.now()).toISOString(),
88
- logtype: 'USER_DEBUG',
89
- ExpirationDate: new Date(Date.now() + time * MILLISECONDS_PER_MINUTE).toISOString(),
90
- });
91
- return {
92
- isSuccess: result.success,
93
- error: result.success ? undefined : result.errors[0].message,
94
- };
95
- }
96
94
  //# sourceMappingURL=new.js.map
@@ -1 +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;QAC3B,IAAI,IAAI,CAAC;QAET,IAAI;YACF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAChD,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,WAAW,EAAa,CAAC;YAChE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,C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QAAQ,UAAU,CAAC,GAAG,GAAG;gBAC1U,KAAK,EAAE,UAAU,CAAC,EAAE;gBACpB,mEAAmE;gBACnE,KAAK,EAAE,UAAU,CAAC,aAAa;aAChC,CAAC,CAAC;SACJ,CAAC,CAAC;QAEH,OAAO,UAAU,CAAC,UAAU,CAAC;IAC/B,CAAC;;AAtFsB,gBAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACzC,iBAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAE5C,cAAK,GAAG;IAC7B,cAAc,EAAE,uBAAK,CAAC,WAAW,CAAC;QAChC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;QAC5D,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,IAAI,EAAE,uBAAK,CAAC,MAAM,CAAC;QACjB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;QAClD,IAAI,EAAE,GAAG;KACV,CAAC;IACF,IAAI,EAAE,uBAAK,CAAC,OAAO,CAAC;QAClB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;QAClD,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,EAAE;KACZ,CAAC;CACH,CAAC;kBAnBiB,QAAQ"}
package/lib/utils.d.ts CHANGED
@@ -1,3 +1,10 @@
1
1
  import { Connection } from '@salesforce/core';
2
+ import { Record } from 'jsforce';
3
+ import { TraceNewResult } from './commands/trace/new';
4
+ import { DebuglevelNewResult } from './commands/debuglevel/new';
2
5
  export declare function createFile(path: string, contents: string): Promise<void>;
3
6
  export declare function getUserId(connection: Connection, inputUser: string): Promise<string>;
7
+ export declare function getActiveTraceFlag(conn: Connection, userId: string): Promise<Record | undefined>;
8
+ export declare function getDebugLevels(conn: Connection): Promise<Record[]>;
9
+ export declare function createTraceFlag(conn: Connection, userId: string, debugLevelId: string, time: number): Promise<TraceNewResult>;
10
+ export declare function createDebugLevel(conn: Connection, debugLevel: Record): Promise<DebuglevelNewResult>;
package/lib/utils.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserId = exports.createFile = void 0;
3
+ exports.createDebugLevel = exports.createTraceFlag = exports.getDebugLevels = exports.getActiveTraceFlag = exports.getUserId = exports.createFile = void 0;
4
4
  const path_1 = require("path");
5
5
  const util_1 = require("util");
6
6
  const fs_1 = require("fs");
7
7
  const mkdirPromise = (0, util_1.promisify)(fs_1.mkdir);
8
8
  const writeFilePromise = (0, util_1.promisify)(fs_1.writeFile);
9
+ const MILLISECONDS_PER_MINUTE = 60000;
9
10
  async function createFile(path, contents) {
10
11
  await mkdirPromise((0, path_1.dirname)(path), { recursive: true });
11
12
  await writeFilePromise(path, contents);
@@ -38,4 +39,46 @@ function isId(input) {
38
39
  const idRegex = /[a-zA-Z0-9]{15}|[a-zA-Z0-9]{18}/;
39
40
  return idRegex.test(input);
40
41
  }
42
+ async function getActiveTraceFlag(conn, userId) {
43
+ const results = await conn.tooling.query(`SELECT Id, TracedEntityId, DebugLevelId, StartDate, ExpirationDate FROM TraceFlag WHERE TracedEntityId = '${userId}' AND ExpirationDate > ${new Date(Date.now()).toISOString()}`);
44
+ if (results?.records?.length > 0) {
45
+ return results.records[0];
46
+ }
47
+ else {
48
+ return undefined;
49
+ }
50
+ }
51
+ exports.getActiveTraceFlag = getActiveTraceFlag;
52
+ async function getDebugLevels(conn) {
53
+ const results = await conn.tooling.query('SELECT Id, DeveloperName, Workflow, Validation, Callout, ApexCode, ApexProfiling, Visualforce, System, Database, Wave, Nba FROM DebugLevel');
54
+ if (results?.records) {
55
+ return results.records;
56
+ }
57
+ else {
58
+ throw new Error('Error to retrieve Debug Levels');
59
+ }
60
+ }
61
+ exports.getDebugLevels = getDebugLevels;
62
+ async function createTraceFlag(conn, userId, debugLevelId, time) {
63
+ const result = await conn.tooling.sobject('TraceFlag').create({
64
+ TracedEntityId: userId,
65
+ DebugLevelId: debugLevelId,
66
+ StartDate: new Date(Date.now()).toISOString(),
67
+ logtype: 'USER_DEBUG',
68
+ ExpirationDate: new Date(Date.now() + time * MILLISECONDS_PER_MINUTE).toISOString(),
69
+ });
70
+ return {
71
+ isSuccess: result.success,
72
+ error: result.success ? undefined : result.errors[0].message,
73
+ };
74
+ }
75
+ exports.createTraceFlag = createTraceFlag;
76
+ async function createDebugLevel(conn, debugLevel) {
77
+ const result = await conn.tooling.sobject('DebugLevel').create(debugLevel);
78
+ return {
79
+ isSuccess: result.success,
80
+ error: result.success ? undefined : result.errors[0].message,
81
+ };
82
+ }
83
+ exports.createDebugLevel = createDebugLevel;
41
84
  //# sourceMappingURL=utils.js.map
package/lib/utils.js.map CHANGED
@@ -1 +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,cAAO,EAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACzC,CAAC;AAHD,gCAGC;AAEM,KAAK,UAAU,SAAS,CAAC,UAAsB,EAAE,SAAiB;IACvE,IAAI,MAAM,CAAC;IACX,IAAI,YAAY,CAAC,SAAS,CAAC,EAAE;QAC3B,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC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gB,CAAC,IAAgB,EAAE,UAAkB;IACzE,MAAM,MAAM,GAAe,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACvF,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;AAND,4CAMC"}
@@ -1,26 +1,26 @@
1
1
  # summary
2
2
 
3
- Retrieve apex log files.
3
+ Retrieve Apex log files from the Salesforce platform.
4
4
 
5
5
  # description
6
6
 
7
- Retrieves apex log files from the Salesforce platform.
7
+ This command allows you to retrieve Apex log files from a Salesforce org.
8
8
 
9
9
  # flags.user.summary
10
10
 
11
- Username or alias to retrieve logs for.
11
+ [default: targetusername] Username, Name, or ID of the user for whom you want to retrieve the logs.
12
12
 
13
13
  # flags.targetusername.summary
14
14
 
15
- Username or alias to retrieve logs for.
15
+ Username or alias of the target Salesforce org.
16
16
 
17
17
  # flags.time.summary
18
18
 
19
- Minutes to retrieve logs for.
19
+ The number of minutes to retrieve log files for.
20
20
 
21
21
  # flags.folder.summary
22
22
 
23
- Folder where the logs are stored.
23
+ The folder where the retrieved log files will be stored.
24
24
 
25
25
  # error.saveLogs
26
26
 
@@ -28,4 +28,4 @@ Failed to save logs: %s.
28
28
 
29
29
  # examples
30
30
 
31
- - <%= config.bin %> <%= command.id %>
31
+ sf debug retrieve -o MyDeveloperEdition -u "Raffaele Preziosi" -t 10
@@ -0,0 +1,19 @@
1
+ # summary
2
+
3
+ Create a new DebugLevel.
4
+
5
+ # description
6
+
7
+ More information about a command. Don't repeat the summary.
8
+
9
+ # flags.targetusername.summary
10
+
11
+ Username or alias of the target Salesforce org.
12
+
13
+ # flags.developerName.summary
14
+
15
+ The developer name of the new DebugLevel.
16
+
17
+ # examples
18
+
19
+ - <%= config.bin %> <%= command.id %>
@@ -2,13 +2,17 @@
2
2
 
3
3
  Create a trace flag for a user.
4
4
 
5
+ # description
6
+
7
+ This command is used to create a trace flag for a specific user in the Salesforce org.
8
+
5
9
  # flags.targetusername.summary
6
10
 
7
- A username or alias for the target org.
11
+ Username or alias of the target Salesforce org.
8
12
 
9
13
  # flags.user.summary
10
14
 
11
- The username of the user to create the trace flag for.
15
+ [default: targetusername] Username, Name, or ID of the user for whom you want to retrieve the logs.
12
16
 
13
17
  # flags.time.summary
14
18
 
@@ -20,4 +24,4 @@ Create User Trace Flag failed: %s.
20
24
 
21
25
  # examples
22
26
 
23
- example
27
+ sf trace new -o MyDeveloperEdition -u "Raffaele Preziosi" -t 10
@@ -1,17 +1,17 @@
1
1
  {
2
- "version": "0.0.20",
2
+ "version": "0.0.22",
3
3
  "commands": {
4
4
  "debug:retrieve": {
5
5
  "id": "debug:retrieve",
6
- "summary": "Retrieve apex log files.",
7
- "description": "Retrieves apex log files from the Salesforce platform.",
6
+ "summary": "Retrieve Apex log files from the Salesforce platform.",
7
+ "description": "This command allows you to retrieve Apex log files from a Salesforce org.",
8
8
  "strict": true,
9
9
  "pluginName": "sf-debug-log",
10
10
  "pluginAlias": "sf-debug-log",
11
11
  "pluginType": "core",
12
12
  "aliases": [],
13
13
  "examples": [
14
- "<%= config.bin %> <%= command.id %>"
14
+ "sf debug retrieve -o MyDeveloperEdition -u \"Raffaele Preziosi\" -t 10"
15
15
  ],
16
16
  "flags": {
17
17
  "json": {
@@ -25,7 +25,7 @@
25
25
  "name": "targetusername",
26
26
  "type": "option",
27
27
  "char": "o",
28
- "summary": "Username or alias to retrieve logs for.",
28
+ "summary": "Username or alias of the target Salesforce org.",
29
29
  "required": true,
30
30
  "multiple": false
31
31
  },
@@ -33,14 +33,14 @@
33
33
  "name": "user",
34
34
  "type": "option",
35
35
  "char": "u",
36
- "summary": "Username or alias to retrieve logs for.",
36
+ "summary": "[default: targetusername] Username, Name, or ID of the user for whom you want to retrieve the logs.",
37
37
  "multiple": false
38
38
  },
39
39
  "time": {
40
40
  "name": "time",
41
41
  "type": "option",
42
42
  "char": "t",
43
- "summary": "Minutes to retrieve logs for.",
43
+ "summary": "The number of minutes to retrieve log files for.",
44
44
  "multiple": false,
45
45
  "default": 60
46
46
  },
@@ -48,7 +48,7 @@
48
48
  "name": "folder",
49
49
  "type": "option",
50
50
  "char": "d",
51
- "summary": "Folder where the logs are stored.",
51
+ "summary": "The folder where the retrieved log files will be stored.",
52
52
  "multiple": false,
53
53
  "default": ".sfdx/tools/debug/logs"
54
54
  }
@@ -56,6 +56,46 @@
56
56
  "args": {},
57
57
  "hasDynamicHelp": true
58
58
  },
59
+ "debuglevel:new": {
60
+ "id": "debuglevel:new",
61
+ "summary": "Create a new DebugLevel.",
62
+ "description": "More information about a command. Don't repeat the summary.",
63
+ "strict": true,
64
+ "pluginName": "sf-debug-log",
65
+ "pluginAlias": "sf-debug-log",
66
+ "pluginType": "core",
67
+ "aliases": [],
68
+ "examples": [
69
+ "<%= config.bin %> <%= command.id %>"
70
+ ],
71
+ "flags": {
72
+ "json": {
73
+ "name": "json",
74
+ "type": "boolean",
75
+ "description": "Format output as json.",
76
+ "helpGroup": "GLOBAL",
77
+ "allowNo": false
78
+ },
79
+ "targetusername": {
80
+ "name": "targetusername",
81
+ "type": "option",
82
+ "char": "o",
83
+ "summary": "Username or alias of the target Salesforce org.",
84
+ "required": true,
85
+ "multiple": false
86
+ },
87
+ "developername": {
88
+ "name": "developername",
89
+ "type": "option",
90
+ "char": "n",
91
+ "summary": "The developer name of the new DebugLevel.",
92
+ "required": true,
93
+ "multiple": false
94
+ }
95
+ },
96
+ "args": {},
97
+ "hasDynamicHelp": true
98
+ },
59
99
  "trace:new": {
60
100
  "id": "trace:new",
61
101
  "summary": "Create a trace flag for a user.",
@@ -65,7 +105,7 @@
65
105
  "pluginType": "core",
66
106
  "aliases": [],
67
107
  "examples": [
68
- "example"
108
+ "sf trace new -o MyDeveloperEdition -u \"Raffaele Preziosi\" -t 10"
69
109
  ],
70
110
  "flags": {
71
111
  "json": {
@@ -79,7 +119,7 @@
79
119
  "name": "targetusername",
80
120
  "type": "option",
81
121
  "char": "o",
82
- "summary": "A username or alias for the target org.",
122
+ "summary": "Username or alias of the target Salesforce org.",
83
123
  "required": true,
84
124
  "multiple": false
85
125
  },
@@ -87,12 +127,13 @@
87
127
  "name": "user",
88
128
  "type": "option",
89
129
  "char": "u",
90
- "summary": "The username of the user to create the trace flag for.",
130
+ "summary": "[default: targetusername] Username, Name, or ID of the user for whom you want to retrieve the logs.",
91
131
  "multiple": false
92
132
  },
93
133
  "time": {
94
134
  "name": "time",
95
135
  "type": "option",
136
+ "char": "t",
96
137
  "summary": "The time for the trace flag.",
97
138
  "multiple": false,
98
139
  "default": 60
package/package.json CHANGED
@@ -1,199 +1,202 @@
1
- {
2
- "name": "sf-debug-log",
3
- "description": "Manage Salesforce Debug Logs",
4
- "version": "0.0.20",
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": "^8.0.0",
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": "Manage Salesforce Trace Flags"
72
- },
73
- "debug": {
74
- "description": "Manage Salesforce Debug Logs"
75
- }
76
- }
77
- },
78
- "scripts": {
79
- "build": "wireit",
80
- "clean": "sf-clean",
81
- "clean-all": "sf-clean all",
82
- "clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json",
83
- "compile": "wireit",
84
- "docs": "sf-docs",
85
- "format": "wireit",
86
- "lint": "wireit",
87
- "postpack": "shx rm -f oclif.manifest.json",
88
- "prepack": "sf-prepack",
89
- "test": "wireit",
90
- "test:only": "wireit",
91
- "version": "oclif readme"
92
- },
93
- "publishConfig": {
94
- "access": "public"
95
- },
96
- "wireit": {
97
- "build": {
98
- "dependencies": [
99
- "compile",
100
- "lint"
101
- ]
102
- },
103
- "compile": {
104
- "command": "tsc -p . --pretty --incremental",
105
- "files": [
106
- "src/**/*.ts",
107
- "**/tsconfig.json",
108
- "messages/**"
109
- ],
110
- "output": [
111
- "lib/**",
112
- "*.tsbuildinfo"
113
- ],
114
- "clean": "if-file-deleted"
115
- },
116
- "format": {
117
- "command": "prettier --write \"+(src|test|schemas)/**/*.+(ts|js|json)|command-snapshot.json\"",
118
- "files": [
119
- "src/**/*.ts",
120
- "test/**/*.ts",
121
- "schemas/**/*.json",
122
- "command-snapshot.json",
123
- ".prettier*"
124
- ],
125
- "output": []
126
- },
127
- "lint": {
128
- "command": "eslint src test --color --cache --cache-location .eslintcache",
129
- "files": [
130
- "src/**/*.ts",
131
- "test/**/*.ts",
132
- "messages/**",
133
- "**/.eslint*",
134
- "**/tsconfig.json"
135
- ],
136
- "output": []
137
- },
138
- "test:compile": {
139
- "command": "tsc -p \"./test\" --pretty",
140
- "files": [
141
- "test/**/*.ts",
142
- "**/tsconfig.json"
143
- ],
144
- "output": []
145
- },
146
- "test": {
147
- "dependencies": [
148
- "test:compile",
149
- "test:only",
150
- "lint"
151
- ]
152
- },
153
- "test:only": {
154
- "command": "nyc mocha \"test/**/*.test.ts\"",
155
- "env": {
156
- "FORCE_COLOR": "2"
157
- },
158
- "files": [
159
- "test/**/*.ts",
160
- "src/**/*.ts",
161
- "**/tsconfig.json",
162
- ".mocha*",
163
- "!*.nut.ts",
164
- ".nycrc"
165
- ],
166
- "output": []
167
- },
168
- "test:command-reference": {
169
- "command": "\"./bin/dev\" commandreference:generate --erroronwarnings",
170
- "files": [
171
- "src/**/*.ts",
172
- "messages/**",
173
- "package.json"
174
- ],
175
- "output": [
176
- "tmp/root"
177
- ]
178
- },
179
- "test:deprecation-policy": {
180
- "command": "\"./bin/dev\" snapshot:compare",
181
- "files": [
182
- "src/**/*.ts"
183
- ],
184
- "output": [],
185
- "dependencies": [
186
- "compile"
187
- ]
188
- },
189
- "test:json-schema": {
190
- "command": "\"./bin/dev\" schema:compare",
191
- "files": [
192
- "src/**/*.ts",
193
- "schemas"
194
- ],
195
- "output": []
196
- }
197
- },
198
- "author": "Raffaele Preziosi"
199
- }
1
+ {
2
+ "name": "sf-debug-log",
3
+ "description": "Manage Salesforce Debug Logs",
4
+ "version": "0.0.22",
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": "^8.0.0",
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": "Manage Salesforce Trace Flags"
72
+ },
73
+ "debug": {
74
+ "description": "Manage Salesforce Debug Logs"
75
+ },
76
+ "debuglevel": {
77
+ "description": "Manage Salesforce Debug Levels"
78
+ }
79
+ }
80
+ },
81
+ "scripts": {
82
+ "build": "wireit",
83
+ "clean": "sf-clean",
84
+ "clean-all": "sf-clean all",
85
+ "clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json",
86
+ "compile": "wireit",
87
+ "docs": "sf-docs",
88
+ "format": "wireit",
89
+ "lint": "wireit",
90
+ "postpack": "shx rm -f oclif.manifest.json",
91
+ "prepack": "sf-prepack",
92
+ "test": "wireit",
93
+ "test:only": "wireit",
94
+ "version": "oclif readme"
95
+ },
96
+ "publishConfig": {
97
+ "access": "public"
98
+ },
99
+ "wireit": {
100
+ "build": {
101
+ "dependencies": [
102
+ "compile",
103
+ "lint"
104
+ ]
105
+ },
106
+ "compile": {
107
+ "command": "tsc -p . --pretty --incremental",
108
+ "files": [
109
+ "src/**/*.ts",
110
+ "**/tsconfig.json",
111
+ "messages/**"
112
+ ],
113
+ "output": [
114
+ "lib/**",
115
+ "*.tsbuildinfo"
116
+ ],
117
+ "clean": "if-file-deleted"
118
+ },
119
+ "format": {
120
+ "command": "prettier --write \"+(src|test|schemas)/**/*.+(ts|js|json)|command-snapshot.json\"",
121
+ "files": [
122
+ "src/**/*.ts",
123
+ "test/**/*.ts",
124
+ "schemas/**/*.json",
125
+ "command-snapshot.json",
126
+ ".prettier*"
127
+ ],
128
+ "output": []
129
+ },
130
+ "lint": {
131
+ "command": "eslint src test --color --cache --cache-location .eslintcache",
132
+ "files": [
133
+ "src/**/*.ts",
134
+ "test/**/*.ts",
135
+ "messages/**",
136
+ "**/.eslint*",
137
+ "**/tsconfig.json"
138
+ ],
139
+ "output": []
140
+ },
141
+ "test:compile": {
142
+ "command": "tsc -p \"./test\" --pretty",
143
+ "files": [
144
+ "test/**/*.ts",
145
+ "**/tsconfig.json"
146
+ ],
147
+ "output": []
148
+ },
149
+ "test": {
150
+ "dependencies": [
151
+ "test:compile",
152
+ "test:only",
153
+ "lint"
154
+ ]
155
+ },
156
+ "test:only": {
157
+ "command": "nyc mocha \"test/**/*.test.ts\"",
158
+ "env": {
159
+ "FORCE_COLOR": "2"
160
+ },
161
+ "files": [
162
+ "test/**/*.ts",
163
+ "src/**/*.ts",
164
+ "**/tsconfig.json",
165
+ ".mocha*",
166
+ "!*.nut.ts",
167
+ ".nycrc"
168
+ ],
169
+ "output": []
170
+ },
171
+ "test:command-reference": {
172
+ "command": "\"./bin/dev\" commandreference:generate --erroronwarnings",
173
+ "files": [
174
+ "src/**/*.ts",
175
+ "messages/**",
176
+ "package.json"
177
+ ],
178
+ "output": [
179
+ "tmp/root"
180
+ ]
181
+ },
182
+ "test:deprecation-policy": {
183
+ "command": "\"./bin/dev\" snapshot:compare",
184
+ "files": [
185
+ "src/**/*.ts"
186
+ ],
187
+ "output": [],
188
+ "dependencies": [
189
+ "compile"
190
+ ]
191
+ },
192
+ "test:json-schema": {
193
+ "command": "\"./bin/dev\" schema:compare",
194
+ "files": [
195
+ "src/**/*.ts",
196
+ "schemas"
197
+ ],
198
+ "output": []
199
+ }
200
+ },
201
+ "author": "Raffaele Preziosi"
202
+ }