@salesforce/cli 2.45.6 → 2.46.1

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/bin/dev.js CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env ts-node
2
2
 
3
3
  async function main() {
4
- const oclif = await import('@oclif/core');
5
- oclif.settings.performanceEnabled = true;
6
- await oclif.execute({ development: true, dir: import.meta.url });
4
+ const { settings } = await import('@oclif/core/settings');
5
+ const { execute } = await import('@oclif/core/execute');
6
+
7
+ settings.performanceEnabled = true;
8
+ await execute({ development: true, dir: import.meta.url });
7
9
  }
8
10
 
9
11
  await main();
package/bin/run.js CHANGED
@@ -3,30 +3,13 @@
3
3
  // Pre-process/prune flags before creating or running the actual CLI
4
4
  (await import('../dist/flags.js')).preprocessCliFlags(process);
5
5
 
6
- const oclif = await import('@oclif/core');
7
- const { createRequire } = await import('module');
8
- const pjson = createRequire(import.meta.url)('../package.json');
6
+ // Since the CLI is a single process, we can have a larger amount of max listeners since
7
+ // the process gets shut down. Don't set it to 0 (no limit) since we should still be aware
8
+ // of rogue event listeners
9
+ process.setMaxListeners(parseInt(process.env.SF_MAX_EVENT_LISTENERS, 10) || 1000);
9
10
 
10
- const cli = await import('../dist/cli.js');
11
-
12
- async function main() {
13
- // Since the CLI is a single process, we can have a larger amount of max listeners since
14
- // the process gets shut down. Don't set it to 0 (no limit) since we should still be aware
15
- // of rouge event listeners
16
- process.setMaxListeners(parseInt(process.env.SF_MAX_EVENT_LISTENERS, 10) || 1000);
17
-
18
- // Don't let other plugins override the CLI specified max listener count
19
- process.setMaxListeners = () => {};
11
+ // Don't let other plugins override the CLI specified max listener count
12
+ process.setMaxListeners = () => {};
20
13
 
21
- cli
22
- .create({ version: pjson.version, bin: pjson.oclif.bin, channel: 'stable' })
23
- .run()
24
- .then(async () => {
25
- await oclif.flush();
26
- })
27
- .catch(async (err) => {
28
- await oclif.handle(err);
29
- });
30
- }
31
-
32
- await main();
14
+ const cli = await import('../dist/cli.js');
15
+ await cli.run();
package/dist/cli.js CHANGED
@@ -7,11 +7,10 @@
7
7
  import { platform, arch, release } from 'node:os';
8
8
  import { resolve } from 'node:path';
9
9
  import { fileURLToPath } from 'node:url';
10
- import { Config, run as oclifRun, settings } from '@oclif/core';
11
- import { set } from '@salesforce/kit';
12
- import Debug from 'debug';
13
- import { default as nodeEnv, Env } from './util/env.js';
14
- const debug = Debug('sf');
10
+ import { execute } from '@oclif/core/execute';
11
+ import { Config } from '@oclif/core/config';
12
+ import NodeEnv, { Env } from './util/env.js';
13
+ import { sfStartupLogger, logger } from './logger.js';
15
14
  const envVars = [
16
15
  ...new Set([
17
16
  ...Object.keys(process.env).filter((e) => e.startsWith('SF_') || e.startsWith('SFDX_')),
@@ -32,13 +31,6 @@ export const UPDATE_DISABLED_INSTALLER = 'Manual and automatic CLI updates have
32
31
  export const UPDATE_DISABLED_NPM = 'Use "npm update --global @salesforce/cli" to update npm-based installations.';
33
32
  export const UPDATE_DISABLED_DEMO = 'Manual and automatic CLI updates have been disabled in DEMO mode. ' +
34
33
  'To check for a new version, unset the environment variable SF_ENV.';
35
- export function configureUpdateSites(config, env = nodeEnv) {
36
- const npmRegistry = env.getNpmRegistryOverride();
37
- if (npmRegistry) {
38
- // Override config value if set via envar
39
- set(config, 'pjson.oclif.warn-if-update-available.registry', npmRegistry);
40
- }
41
- }
42
34
  export function configureAutoUpdate(envars) {
43
35
  if (envars.isDemoMode()) {
44
36
  // Disable autoupdates in demo mode
@@ -62,11 +54,12 @@ export function configureAutoUpdate(envars) {
62
54
  envars.setUpdateInstructions(UPDATE_DISABLED_NPM);
63
55
  }
64
56
  }
65
- function debugCliInfo(version, channel, env, config) {
57
+ function debugCliInfo(env, config) {
66
58
  function debugSection(section, items) {
67
59
  const pad = 25;
68
- debug('%s:', section.padStart(pad));
69
- items.forEach(([name, value]) => debug('%s: %s', name.padStart(pad), value));
60
+ const header = `### ${section} ###`;
61
+ sfStartupLogger.debug('%s', header.padStart(pad));
62
+ items.forEach(([name, value]) => sfStartupLogger.debug('%s: %s', name.padStart(pad), value));
70
63
  }
71
64
  debugSection('OS', [
72
65
  ['platform', platform()],
@@ -76,8 +69,8 @@ function debugCliInfo(version, channel, env, config) {
76
69
  ]);
77
70
  debugSection('NODE', [['version', process.versions.node]]);
78
71
  debugSection('CLI', [
79
- ['version', version],
80
- ['channel', channel],
72
+ ['version', config.version],
73
+ ['channel', config.channel],
81
74
  ['bin', config.bin],
82
75
  ['data', config.dataDir],
83
76
  ['cache', config.cacheDir],
@@ -86,26 +79,16 @@ function debugCliInfo(version, channel, env, config) {
86
79
  debugSection('ENV', [...envVars].map((key) => [key, env.getString(key, '<not set>')]));
87
80
  debugSection('ARGS', process.argv.map((arg, i) => [i.toString(), arg]));
88
81
  }
89
- export function create({ version, bin, channel, run, env }) {
90
- settings.performanceEnabled = true;
91
- const root = resolve(fileURLToPath(import.meta.url), '..');
92
- const args = process.argv.slice(2);
93
- const environment = env ?? nodeEnv;
94
- return {
95
- async run() {
96
- const config = new Config({
97
- name: bin,
98
- root,
99
- version,
100
- channel,
101
- });
102
- await config.load();
103
- configureUpdateSites(config, environment);
104
- configureAutoUpdate(environment);
105
- debugCliInfo(version, channel, environment, config);
106
- // Example of how run is used in a test https://github.com/salesforcecli/cli/pull/171/files#diff-1deee0a575599b2df117c280da319f7938aaf6fdb0c04bcdbde769dbf464be69R46
107
- return run ? run(args, config) : oclifRun(args, config);
108
- },
109
- };
82
+ export async function run() {
83
+ configureAutoUpdate(NodeEnv);
84
+ const config = await Config.load({
85
+ root: resolve(fileURLToPath(import.meta.url), '..'),
86
+ logger,
87
+ enablePerf: true,
88
+ });
89
+ debugCliInfo(NodeEnv, config);
90
+ return execute({
91
+ loadOptions: config,
92
+ });
110
93
  }
111
94
  //# sourceMappingURL=cli.js.map
@@ -4,7 +4,7 @@
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
  */
7
- import { CommandHelp } from '@oclif/core';
7
+ import { CommandHelp } from '@oclif/core/help';
8
8
  export class SfCommandHelp extends CommandHelp {
9
9
  constructor(command, config, opts) {
10
10
  super(command, config, opts);
@@ -4,10 +4,11 @@
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
  */
7
- import { Help, toConfiguredId } from '@oclif/core';
8
- import stripAnsi from 'strip-ansi';
9
- import chalk from 'chalk';
7
+ import { Help } from '@oclif/core/help';
8
+ import { toConfiguredId } from '@oclif/core/util/ids';
9
+ import { Ansis } from 'ansis';
10
10
  import { SfCommandHelp } from './sfCommandHelp.js';
11
+ const ansis = new Ansis();
11
12
  export default class SfHelp extends Help {
12
13
  constructor(config, opts) {
13
14
  super(config, opts);
@@ -54,9 +55,9 @@ export default class SfHelp extends Help {
54
55
  log(...args) {
55
56
  const formatted = args.map((arg) => {
56
57
  let formattedArg = arg.slice();
57
- const matches = stripAnsi(formattedArg).match(this.commandIdRegex) ?? [];
58
+ const matches = ansis.strip(formattedArg).match(this.commandIdRegex) ?? [];
58
59
  for (const match of matches) {
59
- formattedArg = formattedArg.replaceAll(match, chalk.dim(match));
60
+ formattedArg = formattedArg.replaceAll(match, ansis.dim(match));
60
61
  }
61
62
  return formattedArg;
62
63
  });
@@ -1,10 +1,4 @@
1
- /*
2
- * Copyright (c) 2021, salesforce.com, inc.
3
- * All rights reserved.
4
- * Licensed under the BSD 3-Clause license.
5
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
- */
7
- import { ux } from '@oclif/core';
1
+ import ux from '@oclif/core/ux';
8
2
  export const hook = async function ({ config }) {
9
3
  if (process.env.SF_HIDE_RELEASE_NOTES === 'true')
10
4
  return;
@@ -13,9 +7,9 @@ export const hook = async function ({ config }) {
13
7
  }
14
8
  catch (err) {
15
9
  const error = err;
16
- ux.log('NOTE: This error can be ignored in CI and may be silenced in the future');
17
- ux.log('- Set the SF_HIDE_RELEASE_NOTES env var to "true" to skip this script\n');
18
- ux.log(error.message);
10
+ ux.stdout('NOTE: This error can be ignored in CI and may be silenced in the future');
11
+ ux.stdout('- Set the SF_HIDE_RELEASE_NOTES env var to "true" to skip this script\n');
12
+ ux.stdout(error.message);
19
13
  }
20
14
  };
21
15
  export default hook;
@@ -4,8 +4,8 @@
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
  */
7
- import * as os from 'node:os';
8
- import { toConfiguredId, toStandardizedId, loadHelpClass } from '@oclif/core';
7
+ import os from 'node:os';
8
+ import { toConfiguredId, toStandardizedId } from '@oclif/core/util/ids';
9
9
  function buildChoices(matches, config) {
10
10
  const configuredIds = matches.map((p) => toConfiguredId(p.id, config));
11
11
  const maxCommandLength = configuredIds.reduce((max, id) => Math.max(max, id.length), 0);
@@ -38,6 +38,7 @@ async function determineCommand(config, matches) {
38
38
  const hook = async function ({ config, matches, argv }) {
39
39
  const command = await determineCommand(config, matches.filter((m) => !m.hidden));
40
40
  if (argv.includes('--help') || argv.includes('-h')) {
41
+ const { loadHelpClass } = await import('@oclif/core/help');
41
42
  const Help = await loadHelpClass(config);
42
43
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
43
44
  const help = new Help(config, config.pjson.helpOptions);
@@ -4,12 +4,12 @@
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
  */
7
- import { Errors } from '@oclif/core';
8
7
  const hook = async function (options) {
9
8
  const verifySignHookResult = await this.config.runHook('plugins:preinstall:verify:signature', options);
10
9
  const pluginTrustFailure = verifySignHookResult.failures.find((failure) => failure.plugin.name === '@salesforce/plugin-trust');
11
10
  if (pluginTrustFailure !== undefined) {
12
- await Errors.handle(pluginTrustFailure.error);
11
+ const { handle } = await import('@oclif/core/handle');
12
+ await handle(pluginTrustFailure.error);
13
13
  }
14
14
  };
15
15
  export default hook;
@@ -4,7 +4,6 @@
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
  */
7
- import { ux } from '@oclif/core';
8
7
  // eslint-disable-next-line @typescript-eslint/require-await
9
8
  const hook = async function ({ Command, config }) {
10
9
  if (process.argv.includes('--json'))
@@ -20,6 +19,7 @@ const hook = async function ({ Command, config }) {
20
19
  if (!specifiedVersion)
21
20
  return;
22
21
  if (plugin.version !== specifiedVersion) {
22
+ const { ux } = await import('@oclif/core/ux');
23
23
  ux.warn(`Plugin ${plugin.name} (${plugin.version}) differs from the version specified by ${config.bin} (${specifiedVersion})`);
24
24
  }
25
25
  };
package/dist/logger.js ADDED
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2023, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+ import { format } from 'node:util';
8
+ import { Logger } from '@salesforce/core/logger';
9
+ const customLogger = (namespace) => {
10
+ const sfLogger = new Logger(namespace);
11
+ return {
12
+ child: (ns, delimiter) => customLogger(`${namespace}${delimiter ?? ':'}${ns}`),
13
+ debug: (formatter, ...args) => sfLogger.debug(format(formatter, ...args)),
14
+ error: (formatter, ...args) => sfLogger.error(format(formatter, ...args)),
15
+ info: (formatter, ...args) => sfLogger.info(format(formatter, ...args)),
16
+ trace: (formatter, ...args) => sfLogger.trace(format(formatter, ...args)),
17
+ warn: (formatter, ...args) => sfLogger.warn(format(formatter, ...args)),
18
+ namespace,
19
+ };
20
+ };
21
+ export const logger = customLogger('sf:oclif');
22
+ export const sfStartupLogger = customLogger('sf-startup');
23
+ //# sourceMappingURL=logger.js.map
package/dist/util/env.js CHANGED
@@ -31,12 +31,6 @@ export class Env extends EnvVars {
31
31
  isInstaller() {
32
32
  return this.getBoolean(Env.SF_INSTALLER);
33
33
  }
34
- getNpmRegistryOverride() {
35
- return this.getString(Env.SF_NPM_REGISTRY);
36
- }
37
- setNpmRegistryOverride(value) {
38
- return this.setString(Env.SF_NPM_REGISTRY, value);
39
- }
40
34
  normalizeAutoupdateDisabled() {
41
35
  // Ensure that the legacy envar always causes the oclif counterpart to be set
42
36
  // see https://github.com/oclif/plugin-update/blob/3946fb296a0a95544ab6364b36a1f7422c8aeddf/src/hooks/init.ts#L22