@salesforce/core-bundle 7.4.0 → 7.5.0

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/lib/index.d.ts CHANGED
@@ -1675,7 +1675,7 @@ declare module '@salesforce/core-bundle/index' {
1675
1675
  export { Messages, StructuredMessage } from '@salesforce/core-bundle/messages';
1676
1676
  export { Org, SandboxProcessObject, StatusEvent, SandboxInfo, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, ResumeSandboxRequest, OrgTypes, ResultEvent, ScratchOrgRequest, } from '@salesforce/core-bundle/org/org';
1677
1677
  export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from '@salesforce/core-bundle/org/orgConfigProperties';
1678
- export { PackageDir, NamedPackageDir, PackageDirDependency, SfProject, SfProjectJson } from '@salesforce/core-bundle/sfProject';
1678
+ export { NamedPackageDir, SfProject, SfProjectJson } from '@salesforce/core-bundle/sfProject';
1679
1679
  export { SchemaValidator } from '@salesforce/core-bundle/schema/validator';
1680
1680
  export { SfError } from '@salesforce/core-bundle/sfError';
1681
1681
  export { PollingClient } from '@salesforce/core-bundle/status/pollingClient';
@@ -3942,6 +3942,7 @@ declare module '@salesforce/core-bundle/org/scratchOrgInfoApi' {
3942
3942
  */
3943
3943
  export const deploySettings: (scratchOrg: Org, orgSettings: SettingsGenerator, apiVersion: string, timeout?: Duration) => Promise<void>;
3944
3944
  /**
3945
+ * Makes sure the scratch org's instanceUrl is resolvable (that is, DNS is ready)
3945
3946
  *
3946
3947
  * @param scratchOrgAuthInfo an AuthInfo class from the scratch org
3947
3948
  * @returns AuthInfo
@@ -4518,42 +4519,10 @@ declare module '@salesforce/core-bundle/sfError' {
4518
4519
  }
4519
4520
  declare module '@salesforce/core-bundle/sfProject' {
4520
4521
  import { Dictionary, JsonMap, Nullable, Optional } from '@salesforce/ts-types';
4522
+ import { PackageDir, ProjectJson as ProjectJsonSchema, PackagePackageDir } from '@salesforce/schemas';
4521
4523
  import { ConfigFile } from '@salesforce/core-bundle/config/configFile';
4522
4524
  import { ConfigContents } from '@salesforce/core-bundle/config/configStackTypes';
4523
- export type PackageDirDependency = {
4524
- [k: string]: unknown;
4525
- package: string;
4526
- versionNumber?: string;
4527
- };
4528
- export type PackageDir = {
4529
- ancestorId?: string;
4530
- ancestorVersion?: string;
4531
- default?: boolean;
4532
- definitionFile?: string;
4533
- dependencies?: PackageDirDependency[];
4534
- includeProfileUserLicenses?: boolean;
4535
- package?: string;
4536
- packageMetadataAccess?: {
4537
- permissionSets: string | string[];
4538
- permissionSetLicenses: string | string[];
4539
- };
4540
- path: string;
4541
- postInstallScript?: string;
4542
- postInstallUrl?: string;
4543
- releaseNotesUrl?: string;
4544
- scopeProfiles?: boolean;
4545
- uninstallScript?: string;
4546
- versionDescription?: string;
4547
- versionName?: string;
4548
- versionNumber?: string;
4549
- unpackagedMetadata?: {
4550
- path: string;
4551
- };
4552
- seedMetadata?: {
4553
- path: string;
4554
- };
4555
- };
4556
- export type NamedPackageDir = PackageDir & {
4525
+ type NameAndFullPath = {
4557
4526
  /**
4558
4527
  * The [normalized](https://nodejs.org/api/path.html#path_path_normalize_path) path used as the package name.
4559
4528
  */
@@ -4563,20 +4532,9 @@ declare module '@salesforce/core-bundle/sfProject' {
4563
4532
  */
4564
4533
  fullPath: string;
4565
4534
  };
4566
- export type ProjectJson = ConfigContents & {
4567
- packageDirectories: PackageDir[];
4568
- namespace?: string;
4569
- sourceApiVersion?: string;
4570
- sfdcLoginUrl?: string;
4571
- signupTargetLoginUrl?: string;
4572
- oauthLocalPort?: number;
4573
- plugins?: {
4574
- [k: string]: unknown;
4575
- };
4576
- packageAliases?: {
4577
- [k: string]: string;
4578
- };
4579
- };
4535
+ export type NamedPackagingDir = PackagePackageDir & NameAndFullPath;
4536
+ export type NamedPackageDir = PackageDir & NameAndFullPath;
4537
+ export type ProjectJson = ConfigContents & ProjectJsonSchema;
4580
4538
  /**
4581
4539
  * The sfdx-project.json config object. This file determines if a folder is a valid sfdx project.
4582
4540
  *
@@ -4595,6 +4553,7 @@ declare module '@salesforce/core-bundle/sfProject' {
4595
4553
  * **See** [force:project:create](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_create_new.htm)
4596
4554
  */
4597
4555
  export class SfProjectJson extends ConfigFile<ConfigFile.Options, ProjectJson> {
4556
+ /** json properties that are uppercase, or allow uppercase keys inside them */
4598
4557
  static BLOCKLIST: string[];
4599
4558
  static getFileName(): string;
4600
4559
  static getDefaultOptions(isGlobal?: boolean): ConfigFile.Options;
@@ -4679,7 +4638,7 @@ declare module '@salesforce/core-bundle/sfProject' {
4679
4638
  *
4680
4639
  * @param packageDir
4681
4640
  */
4682
- addPackageDirectory(packageDir: NamedPackageDir): void;
4641
+ addPackageDirectory(packageDir: PackageDir): void;
4683
4642
  private doesPackageExist;
4684
4643
  private validateKeys;
4685
4644
  }
@@ -4877,6 +4836,11 @@ declare module '@salesforce/core-bundle/sfProject' {
4877
4836
  getPackageIdFromAlias(alias: string): Optional<string>;
4878
4837
  getAliasesFromPackageId(id: string): string[];
4879
4838
  }
4839
+ /** differentiate between the Base PackageDir (path, maybe default) and the Packaging version (package and maybe a LOT of other fields) by whether is has the `package` property */
4840
+ export const isPackagingDirectory: (packageDir: PackageDir) => packageDir is PackagePackageDir;
4841
+ /** differentiate between the Base PackageDir (path, maybe default) and the Packaging version (package and maybe a LOT of other fields) by whether is has the `package` property */
4842
+ export const isNamedPackagingDirectory: (packageDir: NamedPackageDir) => packageDir is NamedPackagingDir;
4843
+ export {};
4880
4844
 
4881
4845
  }
4882
4846
  declare module '@salesforce/core-bundle/stateAggregator/accessors/aliasAccessor' {
@@ -6193,8 +6157,9 @@ declare module '@salesforce/core-bundle/util/findSuggestion' {
6193
6157
 
6194
6158
  }
6195
6159
  declare module '@salesforce/core-bundle/util/findUppercaseKeys' {
6196
- import { JsonMap, Optional } from '@salesforce/ts-types';
6197
- export const findUpperCaseKeys: (data?: JsonMap, sectionBlocklist?: string[]) => Optional<string>;
6160
+ import { JsonMap } from '@salesforce/ts-types';
6161
+ /** will throw on any upperCase unless they are present in the allowList. Recursively searches the object, returning valid keys */
6162
+ export const ensureNoUppercaseKeys: (path: string) => (allowList?: string[]) => (data: JsonMap) => string[];
6198
6163
 
6199
6164
  }
6200
6165
  declare module '@salesforce/core-bundle/util/getJwtAudienceUrl' {
package/lib/index.js CHANGED
@@ -952,13 +952,7 @@ var require_duration = __commonJS({
952
952
  * The string representation of this `Duration`. e.g. "645 seconds"
953
953
  */
954
954
  toString() {
955
- return this.pluralize();
956
- }
957
- pluralize(num = this.quantity, unit = this.unit) {
958
- const name = _Duration.Unit[unit].toLowerCase();
959
- if (num === 1)
960
- return `${num} ${name.slice(0, name.length - 1)}`;
961
- return `${num} ${name}`;
955
+ return pluralize(this.quantity, this.unit);
962
956
  }
963
957
  };
964
958
  exports2.Duration = Duration;
@@ -996,6 +990,10 @@ var require_duration = __commonJS({
996
990
  return Object.assign(promise, { interrupt: wake });
997
991
  }
998
992
  exports2.sleep = sleep;
993
+ var pluralize = (num, unit) => {
994
+ const name = Duration.Unit[unit].toLowerCase();
995
+ return `${num} ${num === 1 ? name.slice(0, name.length - 1) : name}`;
996
+ };
999
997
  }
1000
998
  });
1001
999
 
@@ -5426,7 +5424,7 @@ var require_package = __commonJS({
5426
5424
  "node_modules/thread-stream/package.json"(exports2, module2) {
5427
5425
  module2.exports = {
5428
5426
  name: "thread-stream",
5429
- version: "2.7.0",
5427
+ version: "3.1.0",
5430
5428
  description: "A streaming way to send data to a Node.js Worker Thread",
5431
5429
  main: "index.js",
5432
5430
  types: "index.d.ts",
@@ -5441,7 +5439,7 @@ var require_package = __commonJS({
5441
5439
  fastbench: "^1.0.1",
5442
5440
  husky: "^9.0.6",
5443
5441
  "pino-elasticsearch": "^8.0.0",
5444
- "sonic-boom": "^3.0.0",
5442
+ "sonic-boom": "^4.0.1",
5445
5443
  standard: "^17.0.0",
5446
5444
  tap: "^16.2.0",
5447
5445
  "ts-node": "^10.8.0",
@@ -5449,7 +5447,8 @@ var require_package = __commonJS({
5449
5447
  "why-is-node-running": "^2.2.2"
5450
5448
  },
5451
5449
  scripts: {
5452
- test: 'standard && npm run transpile && tap "test/**/*.test.*js" && tap --ts test/*.test.*ts',
5450
+ build: "tsc --noEmit",
5451
+ test: 'standard && npm run build && npm run transpile && tap "test/**/*.test.*js" && tap --ts test/*.test.*ts',
5453
5452
  "test:ci": "standard && npm run transpile && npm run test:ci:js && npm run test:ci:ts",
5454
5453
  "test:ci:js": 'tap --no-check-coverage --timeout=120 --coverage-report=lcovonly "test/**/*.test.*js"',
5455
5454
  "test:ci:ts": 'tap --ts --no-check-coverage --coverage-report=lcovonly "test/**/*.test.*ts"',
@@ -5459,7 +5458,8 @@ var require_package = __commonJS({
5459
5458
  },
5460
5459
  standard: {
5461
5460
  ignore: [
5462
- "test/ts/**/*"
5461
+ "test/ts/**/*",
5462
+ "test/syntax-error.mjs"
5463
5463
  ]
5464
5464
  },
5465
5465
  repository: {
@@ -6035,7 +6035,10 @@ var require_transport = __commonJS({
6035
6035
  stream.flushSync();
6036
6036
  }
6037
6037
  function transport(fullOptions) {
6038
- const { pipeline, targets, levels, dedupe, options = {}, worker = {}, caller = getCallers() } = fullOptions;
6038
+ const { pipeline, targets, levels, dedupe, worker = {}, caller = getCallers() } = fullOptions;
6039
+ const options = {
6040
+ ...fullOptions.options
6041
+ };
6039
6042
  const callers = typeof caller === "string" ? [caller] : caller;
6040
6043
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
6041
6044
  let target = fullOptions.target;
@@ -6044,20 +6047,30 @@ var require_transport = __commonJS({
6044
6047
  }
6045
6048
  if (targets) {
6046
6049
  target = bundlerOverrides["pino-worker"] || join(__dirname, "worker.js");
6047
- options.targets = targets.map((dest) => {
6050
+ options.targets = targets.filter((dest) => dest.target).map((dest) => {
6048
6051
  return {
6049
6052
  ...dest,
6050
6053
  target: fixTarget(dest.target)
6051
6054
  };
6052
6055
  });
6056
+ options.pipelines = targets.filter((dest) => dest.pipeline).map((dest) => {
6057
+ return dest.pipeline.map((t) => {
6058
+ return {
6059
+ ...t,
6060
+ level: dest.level,
6061
+ // duplicate the pipeline `level` property defined in the upper level
6062
+ target: fixTarget(t.target)
6063
+ };
6064
+ });
6065
+ });
6053
6066
  } else if (pipeline) {
6054
- target = bundlerOverrides["pino-pipeline-worker"] || join(__dirname, "worker-pipeline.js");
6055
- options.targets = pipeline.map((dest) => {
6067
+ target = bundlerOverrides["pino-worker"] || join(__dirname, "worker.js");
6068
+ options.pipelines = [pipeline.map((dest) => {
6056
6069
  return {
6057
6070
  ...dest,
6058
6071
  target: fixTarget(dest.target)
6059
6072
  };
6060
- });
6073
+ })];
6061
6074
  }
6062
6075
  if (levels) {
6063
6076
  options.levels = levels;
@@ -6640,7 +6653,7 @@ var require_levels = __commonJS({
6640
6653
  var require_meta = __commonJS({
6641
6654
  "node_modules/pino/lib/meta.js"(exports2, module2) {
6642
6655
  "use strict";
6643
- module2.exports = { version: "8.21.0" };
6656
+ module2.exports = { version: "9.2.0" };
6644
6657
  }
6645
6658
  });
6646
6659
 
@@ -7604,7 +7617,7 @@ var require_pino = __commonJS({
7604
7617
  return f(p);
7605
7618
  }
7606
7619
  }
7607
- globalThis.__bundlerPathsOverrides = { ...globalThis.__bundlerPathsOverrides || {}, "thread-stream-worker": pinoBundlerAbsolutePath("./thread-stream-worker.js"), "pino-worker": pinoBundlerAbsolutePath("./pino-worker.js"), "pino/file": pinoBundlerAbsolutePath("./pino-file.js"), "pino-pipeline-worker": pinoBundlerAbsolutePath("./pino-pipeline-worker.js"), "pino-pretty": pinoBundlerAbsolutePath("./pino-pretty.js") };
7620
+ globalThis.__bundlerPathsOverrides = { ...globalThis.__bundlerPathsOverrides || {}, "thread-stream-worker": pinoBundlerAbsolutePath("./thread-stream-worker.js"), "pino-worker": pinoBundlerAbsolutePath("./pino-worker.js"), "pino/file": pinoBundlerAbsolutePath("./pino-file.js"), "pino-pretty": pinoBundlerAbsolutePath("./pino-pretty.js") };
7608
7621
  var os = require("os");
7609
7622
  var stdSerializers = require_pino_std_serializers();
7610
7623
  var caller = require_caller();
@@ -12075,7 +12088,7 @@ var require_package2 = __commonJS({
12075
12088
  "package.json"(exports2, module2) {
12076
12089
  module2.exports = {
12077
12090
  name: "@salesforce/core-bundle",
12078
- version: "7.4.0",
12091
+ version: "7.5.0",
12079
12092
  description: "Core libraries to interact with SFDX projects, orgs, and APIs.",
12080
12093
  main: "lib/index",
12081
12094
  types: "lib/index.d.ts",
@@ -12112,9 +12125,9 @@ var require_package2 = __commonJS({
12112
12125
  ],
12113
12126
  dependencies: {
12114
12127
  "@jsforce/jsforce-node": "^3.2.0",
12115
- "@salesforce/kit": "^3.1.2",
12128
+ "@salesforce/kit": "^3.1.6",
12116
12129
  "@salesforce/schemas": "^1.9.0",
12117
- "@salesforce/ts-types": "^2.0.9",
12130
+ "@salesforce/ts-types": "^2.0.10",
12118
12131
  ajv: "^8.15.0",
12119
12132
  "change-case": "^4.1.2",
12120
12133
  "fast-levenshtein": "^3.0.0",
@@ -12123,16 +12136,16 @@ var require_package2 = __commonJS({
12123
12136
  js2xmlparser: "^4.0.1",
12124
12137
  jsonwebtoken: "9.0.2",
12125
12138
  jszip: "3.10.1",
12126
- pino: "^8.21.0",
12139
+ pino: "^9.2.0",
12127
12140
  "pino-abstract-transport": "^1.2.0",
12128
- "pino-pretty": "^10.3.1",
12141
+ "pino-pretty": "^11.2.1",
12129
12142
  "proper-lockfile": "^4.1.2",
12130
12143
  semver: "^7.6.2",
12131
12144
  "ts-retry-promise": "^0.8.1"
12132
12145
  },
12133
12146
  devDependencies: {
12134
- "@salesforce/dev-scripts": "^8.5.0",
12135
- "@salesforce/ts-sinon": "^1.4.19",
12147
+ "@salesforce/dev-scripts": "^10.1.1",
12148
+ "@salesforce/ts-sinon": "^1.4.22",
12136
12149
  "@types/benchmark": "^2.1.5",
12137
12150
  "@types/chai-string": "^1.4.5",
12138
12151
  "@types/fast-levenshtein": "^0.0.4",
@@ -14538,16 +14551,24 @@ function __asyncGenerator(thisArg, _arguments, generator) {
14538
14551
  if (!Symbol.asyncIterator)
14539
14552
  throw new TypeError("Symbol.asyncIterator is not defined.");
14540
14553
  var g = generator.apply(thisArg, _arguments || []), i, q = [];
14541
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
14554
+ return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
14542
14555
  return this;
14543
14556
  }, i;
14544
- function verb(n) {
14545
- if (g[n])
14557
+ function awaitReturn(f) {
14558
+ return function(v) {
14559
+ return Promise.resolve(v).then(f, reject);
14560
+ };
14561
+ }
14562
+ function verb(n, f) {
14563
+ if (g[n]) {
14546
14564
  i[n] = function(v) {
14547
14565
  return new Promise(function(a, b) {
14548
14566
  q.push([n, v, a, b]) > 1 || resume(n, v);
14549
14567
  });
14550
14568
  };
14569
+ if (f)
14570
+ i[n] = f(i[n]);
14571
+ }
14551
14572
  }
14552
14573
  function resume(n, v) {
14553
14574
  try {
@@ -14651,7 +14672,7 @@ function __addDisposableResource(env, value, async) {
14651
14672
  if (value !== null && value !== void 0) {
14652
14673
  if (typeof value !== "object" && typeof value !== "function")
14653
14674
  throw new TypeError("Object expected.");
14654
- var dispose;
14675
+ var dispose, inner;
14655
14676
  if (async) {
14656
14677
  if (!Symbol.asyncDispose)
14657
14678
  throw new TypeError("Symbol.asyncDispose is not defined.");
@@ -14661,9 +14682,19 @@ function __addDisposableResource(env, value, async) {
14661
14682
  if (!Symbol.dispose)
14662
14683
  throw new TypeError("Symbol.dispose is not defined.");
14663
14684
  dispose = value[Symbol.dispose];
14685
+ if (async)
14686
+ inner = dispose;
14664
14687
  }
14665
14688
  if (typeof dispose !== "function")
14666
14689
  throw new TypeError("Object not disposable.");
14690
+ if (inner)
14691
+ dispose = function() {
14692
+ try {
14693
+ inner.call(this);
14694
+ } catch (e) {
14695
+ return Promise.reject(e);
14696
+ }
14697
+ };
14667
14698
  env.stack.push({ value, dispose, async });
14668
14699
  } else if (async) {
14669
14700
  env.stack.push({ async: true });
@@ -92184,25 +92215,19 @@ var require_findUppercaseKeys = __commonJS({
92184
92215
  "lib/util/findUppercaseKeys.js"(exports2) {
92185
92216
  "use strict";
92186
92217
  Object.defineProperty(exports2, "__esModule", { value: true });
92187
- exports2.findUpperCaseKeys = void 0;
92218
+ exports2.ensureNoUppercaseKeys = void 0;
92219
+ var strict_1 = require("node:assert/strict");
92188
92220
  var ts_types_1 = require_lib();
92189
- var kit_1 = require_lib2();
92190
- var findUpperCaseKeys = (data, sectionBlocklist = []) => {
92191
- let key;
92192
- (0, kit_1.findKey)(data, (val, k) => {
92193
- if (/^[A-Z]/.test(k)) {
92194
- key = k;
92195
- } else if ((0, ts_types_1.isJsonMap)(val)) {
92196
- if (sectionBlocklist.includes(k)) {
92197
- return key;
92198
- }
92199
- key = (0, exports2.findUpperCaseKeys)((0, ts_types_1.asJsonMap)(val));
92200
- }
92201
- return key;
92202
- });
92203
- return key;
92221
+ var messages_12 = require_messages();
92222
+ var coreMessages = new messages_12.Messages("@salesforce/core-bundle", "core", /* @__PURE__ */ new Map([["authInfoCreationError", "Must pass a username and/or OAuth options when creating an AuthInfo instance."], ["authInfoOverwriteError", "Cannot create an AuthInfo instance that will overwrite existing auth data."], ["authInfoOverwriteError.actions", ["Create the AuthInfo instance using existing auth data by just passing the username. E.g., `AuthInfo.create({ username: 'my@user.org' });`."]], ["authCodeExchangeError", "Error authenticating with auth code due to: %s"], ["authCodeUsernameRetrievalError", "Could not retrieve the username after successful auth code exchange.\n\nDue to: %s"], ["jwtAuthError", "Error authenticating with JWT config due to: %s"], ["jwtAuthErrors", "Error authenticating with JWT.\nErrors encountered:\n%s"], ["refreshTokenAuthError", "Error authenticating with the refresh token due to: %s"], ["orgDataNotAvailableError", "An attempt to refresh the authentication token failed with a 'Data Not Found Error'. The org identified by username %s does not appear to exist. Likely cause is that the org was deleted by another user or has expired."], ["orgDataNotAvailableError.actions", ["Run `sfdx force:org:list --clean` to remove stale org authentications.", "Use `sfdx force:config:set` to update the defaultusername.", "Use `sfdx force:org:create` to create a new org.", "Use `sfdx auth` to authenticate an existing org."]], ["namedOrgNotFound", "No authorization information found for %s."], ["noAliasesFound", "Nothing to set."], ["invalidFormat", "Setting aliases must be in the format <key>=<value> but found: [%s]."], ["invalidJsonCasing", 'All JSON input must have heads down camelcase keys. E.g., `{ sfdcLoginUrl: "https://login.salesforce.com" }`\nFound "%s" at %s'], ["missingClientId", "Client ID is required for JWT authentication."]]));
92223
+ var ensureNoUppercaseKeys = (path) => (allowList = []) => (data) => {
92224
+ const keys2 = getKeys(data, allowList);
92225
+ const upperCaseKeys = keys2.filter((key) => /^[A-Z]/.test(key)).join(", ");
92226
+ (0, strict_1.strictEqual)(upperCaseKeys.length, 0, coreMessages.getMessage("invalidJsonCasing", [upperCaseKeys, path]));
92227
+ return keys2;
92204
92228
  };
92205
- exports2.findUpperCaseKeys = findUpperCaseKeys;
92229
+ exports2.ensureNoUppercaseKeys = ensureNoUppercaseKeys;
92230
+ var getKeys = (data, allowList) => Object.entries(data).filter(([k]) => !allowList.includes(k)).flatMap(([key, value]) => (0, ts_types_1.isJsonMap)(value) ? [key, ...getKeys(value, allowList)] : [key]);
92206
92231
  }
92207
92232
  });
92208
92233
 
@@ -93232,7 +93257,7 @@ var require_sfProject = __commonJS({
93232
93257
  return result;
93233
93258
  };
93234
93259
  Object.defineProperty(exports2, "__esModule", { value: true });
93235
- exports2.SfProject = exports2.SfProjectJson = void 0;
93260
+ exports2.isNamedPackagingDirectory = exports2.isPackagingDirectory = exports2.SfProject = exports2.SfProjectJson = void 0;
93236
93261
  var node_path_1 = require("node:path");
93237
93262
  var fs = __importStar2(require("node:fs"));
93238
93263
  var kit_1 = require_lib2();
@@ -93246,8 +93271,8 @@ var require_sfProject = __commonJS({
93246
93271
  var messages_12 = require_messages();
93247
93272
  var findUppercaseKeys_1 = require_findUppercaseKeys();
93248
93273
  var messages = new messages_12.Messages("@salesforce/core-bundle", "config", /* @__PURE__ */ new Map([["unknownConfigKey", "Unknown config name: %s."], ["deprecatedConfigKey", "Deprecated config name: %s. Please use %s instead."], ["invalidWrite", "The writeSync method is not allowed on SfdxConfig. Use the async write method instead."], ["invalidConfigValue", "Invalid config value: %s."], ["invalidInstanceUrl", "Specify a valid Salesforce instance URL."], ["invalidApiVersion", "Specify a valid Salesforce API version, for example, 42.0."], ["invalidCustomOrgMetadataTemplates", "Specify a valid repository URL or directory for the custom org metadata templates."], ["invalidIsvDebuggerSid", "Specify a valid Debugger SID."], ["invalidIsvDebuggerUrl", "Specify a valid Debugger URL."], ["invalidNumberConfigValue", "Specify a valid positive integer, for example, 150000."], ["invalidBooleanConfigValue", "The config value can only be set to true or false."], ["invalidProjectWorkspace", "This directory does not contain a valid Salesforce DX project."], ["schemaValidationError", 'The config file "%s" is not schema valid.\nDue to: %s'], ["schemaValidationError.actions", ["Fix the invalid entries at %s."]], ["missingDefaultPath", 'In sfdx-project.json, be sure to specify which package directory (path) is the default. Example: `[{ "path": "packageDirectory1", "default": true }, { "path": "packageDirectory2" }]`'], ["missingPackageDirectory", 'The path "%s", specified in sfdx-project.json, does not exist. Be sure this directory is included in your project root.'], ["invalidPackageDirectory", 'The path "%s", specified in sfdx-project.json, must be indicated as a relative path to the project root.'], ["multipleDefaultPaths", "In sfdx-project.json, indicate only one package directory (path) as the default."], ["singleNonDefaultPackage", 'The sfdx-project.json file must include one, and only one, default package directory (path). Because your sfdx-project.json file contains only one package directory, it must be the default. Remove the `"default": false` key and try again.'], ["target-org", "Username or alias of the org that all commands run against by default. (sf only)"], ["target-dev-hub", "Username or alias of your default Dev Hub org. (sf only)"], ["defaultUsername", "Username or alias of the org that all commands run against by default. (sfdx only)"], ["defaultDevHubUsername", "Username or alias of your default Dev Hub org. (sfdx only)"], ["isvDebuggerSid", "ISV debugger SID (sfdx only)"], ["isvDebuggerUrl", "ISV debugger URL (sfdx only)"], ["org-isv-debugger-sid", "ISV debugger SID."], ["org-isv-debugger-url", "ISV debugger URL."], ["apiVersion", "API version of your project. Default: API version of your Dev Hub org. (sfdx only)"], ["org-api-version", "API version of your project. Default: API version of your Dev Hub org."], ["disableTelemetry", "Disables the collection of usage and user environment information, etc. Default: false. (sfdx only)"], ["disable-telemetry", "Disables the collection of usage and user environment information, etc. Default: false."], ["maxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000. (sfdx only)"], ["org-max-query-limit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000."], ["restDeploy", "Whether deployments use the Metadata REST API (true) or SOAP API (false, default value). (sfdx only)"], ["instanceUrl", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com. (sfdx only)"], ["org-instance-url", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com."], ["customOrgMetadataTemplates", "A valid repository URL or directory for the custom org metadata templates."], ["org-custom-metadata-templates", "A valid repository URL or directory for the custom org metadata templates."], ["org-capitalize-record-types", "Whether record types are capitalized on scratch org creation."], ["invalidId", "The given id %s is not a valid 15 or 18 character Salesforce ID."]]));
93249
- var coreMessages = new messages_12.Messages("@salesforce/core-bundle", "core", /* @__PURE__ */ new Map([["authInfoCreationError", "Must pass a username and/or OAuth options when creating an AuthInfo instance."], ["authInfoOverwriteError", "Cannot create an AuthInfo instance that will overwrite existing auth data."], ["authInfoOverwriteError.actions", ["Create the AuthInfo instance using existing auth data by just passing the username. E.g., `AuthInfo.create({ username: 'my@user.org' });`."]], ["authCodeExchangeError", "Error authenticating with auth code due to: %s"], ["authCodeUsernameRetrievalError", "Could not retrieve the username after successful auth code exchange.\n\nDue to: %s"], ["jwtAuthError", "Error authenticating with JWT config due to: %s"], ["jwtAuthErrors", "Error authenticating with JWT.\nErrors encountered:\n%s"], ["refreshTokenAuthError", "Error authenticating with the refresh token due to: %s"], ["orgDataNotAvailableError", "An attempt to refresh the authentication token failed with a 'Data Not Found Error'. The org identified by username %s does not appear to exist. Likely cause is that the org was deleted by another user or has expired."], ["orgDataNotAvailableError.actions", ["Run `sfdx force:org:list --clean` to remove stale org authentications.", "Use `sfdx force:config:set` to update the defaultusername.", "Use `sfdx force:org:create` to create a new org.", "Use `sfdx auth` to authenticate an existing org."]], ["namedOrgNotFound", "No authorization information found for %s."], ["noAliasesFound", "Nothing to set."], ["invalidFormat", "Setting aliases must be in the format <key>=<value> but found: [%s]."], ["invalidJsonCasing", 'All JSON input must have heads down camelcase keys. E.g., `{ sfdcLoginUrl: "https://login.salesforce.com" }`\nFound "%s" at %s'], ["missingClientId", "Client ID is required for JWT authentication."]]));
93250
93274
  var SfProjectJson = class _SfProjectJson extends configFile_12.ConfigFile {
93275
+ /** json properties that are uppercase, or allow uppercase keys inside them */
93251
93276
  static BLOCKLIST = ["packageAliases"];
93252
93277
  static getFileName() {
93253
93278
  return internal_1.SFDX_PROJECT_JSON;
@@ -93446,10 +93471,7 @@ var require_sfProject = __commonJS({
93446
93471
  * @param packageDir
93447
93472
  */
93448
93473
  addPackageDirectory(packageDir) {
93449
- const dirIndex = this.getContents().packageDirectories.findIndex((pd) => {
93450
- const withId = pd;
93451
- return withId.path === packageDir.path && !withId.id && !withId.package || !!packageDir.package && packageDir.package === withId.package;
93452
- });
93474
+ const dirIndex = this.getContents().packageDirectories.findIndex(findPackageDir(packageDir));
93453
93475
  const packageDirEntry = Object.assign({}, dirIndex > -1 ? this.getContents().packageDirectories[dirIndex] : packageDir, packageDir);
93454
93476
  const modifiedPackagesDirs = dirIndex > -1 ? (
93455
93477
  // replace the matching entry with the new entry
@@ -93460,15 +93482,13 @@ var require_sfProject = __commonJS({
93460
93482
  );
93461
93483
  this.set("packageDirectories", modifiedPackagesDirs);
93462
93484
  }
93485
+ // keep it because testSetup stubs it!
93463
93486
  // eslint-disable-next-line class-methods-use-this
93464
93487
  doesPackageExist(packagePath) {
93465
93488
  return fs.existsSync(packagePath);
93466
93489
  }
93467
93490
  validateKeys() {
93468
- const upperCaseKey = (0, findUppercaseKeys_1.findUpperCaseKeys)(this.toObject(), _SfProjectJson.BLOCKLIST);
93469
- if (upperCaseKey) {
93470
- throw coreMessages.createError("invalidJsonCasing", [upperCaseKey, this.getPath()]);
93471
- }
93491
+ (0, findUppercaseKeys_1.ensureNoUppercaseKeys)(this.getPath())(_SfProjectJson.BLOCKLIST)(this.toObject());
93472
93492
  }
93473
93493
  };
93474
93494
  exports2.SfProjectJson = SfProjectJson;
@@ -93661,7 +93681,9 @@ var require_sfProject = __commonJS({
93661
93681
  */
93662
93682
  getPackageNameFromPath(path) {
93663
93683
  const packageDir = this.getPackageFromPath(path);
93664
- return packageDir ? packageDir.package ?? packageDir.path : void 0;
93684
+ if (!packageDir)
93685
+ return void 0;
93686
+ return (0, exports2.isNamedPackagingDirectory)(packageDir) ? packageDir.package : packageDir.path;
93665
93687
  }
93666
93688
  /**
93667
93689
  * Returns the package directory.
@@ -93794,6 +93816,17 @@ var require_sfProject = __commonJS({
93794
93816
  }
93795
93817
  };
93796
93818
  exports2.SfProject = SfProject;
93819
+ var isPackagingDirectory = (packageDir) => isPackagingDir(packageDir);
93820
+ exports2.isPackagingDirectory = isPackagingDirectory;
93821
+ var isNamedPackagingDirectory = (packageDir) => isPackagingDir(packageDir);
93822
+ exports2.isNamedPackagingDirectory = isNamedPackagingDirectory;
93823
+ var isPackagingDir = (packageDir) => "package" in packageDir && typeof packageDir.package === "string";
93824
+ var findPackageDir = (target) => (potentialMatch) => (
93825
+ // an entry w/o a package or id is considered a directory entry for which a package has yet to be created
93826
+ // find a matching dir entry that where path is the same and id and package are not present
93827
+ potentialMatch.path === target.path && !("id" in potentialMatch) && !(0, exports2.isPackagingDirectory)(potentialMatch) || // if that fails, then find a matching dir entry package is present and is same as the new entry
93828
+ (0, exports2.isPackagingDirectory)(target) && (0, exports2.isPackagingDirectory)(potentialMatch) && target.package === potentialMatch.package
93829
+ );
93797
93830
  }
93798
93831
  });
93799
93832
 
@@ -94672,13 +94705,14 @@ var require_scratchOrgInfoApi = __commonJS({
94672
94705
  const logger = await logger_12.Logger.child("scratchOrgInfoApi-resolveUrl");
94673
94706
  const { instanceUrl } = scratchOrgAuthInfo.getFields();
94674
94707
  if (!instanceUrl) {
94675
- const sfError = new sfError_12.SfError("Org does not have instanceUrl");
94676
- sfError.setData({
94677
- orgId: scratchOrgAuthInfo.getFields().orgId,
94678
- username: scratchOrgAuthInfo.getFields().username,
94679
- instanceUrl
94708
+ throw sfError_12.SfError.create({
94709
+ message: "Org does not have instanceUrl",
94710
+ data: {
94711
+ orgId: scratchOrgAuthInfo.getFields().orgId,
94712
+ username: scratchOrgAuthInfo.getFields().username,
94713
+ instanceUrl
94714
+ }
94680
94715
  });
94681
- throw sfError;
94682
94716
  }
94683
94717
  logger.debug(`processScratchOrgInfoResult - resultData.instanceUrl: ${instanceUrl}`);
94684
94718
  const options = {
@@ -107099,10 +107133,12 @@ var require_scratchOrgSettingsGenerator = __commonJS({
107099
107133
  if (status !== RequestStatus.Succeeded.toString()) {
107100
107134
  const componentFailures = (0, ts_types_1.ensureObject)(result.details).componentFailures;
107101
107135
  const failures = (Array.isArray(componentFailures) ? componentFailures : [componentFailures]).map((failure) => `[${failure.problemType}] ${failure.fullName} : ${failure.problem} `).join("\n");
107102
- const error = new sfError_12.SfError(`A scratch org was created with username ${username}, but the settings failed to deploy due to:
107103
- ${failures}`, "ProblemDeployingSettings");
107104
- error.setData(result);
107105
- throw error;
107136
+ throw sfError_12.SfError.create({
107137
+ message: `A scratch org was created with username ${username}, but the settings failed to deploy due to:
107138
+ ${failures}`,
107139
+ name: "ProblemDeployingSettings",
107140
+ data: { ...result, username }
107141
+ });
107106
107142
  }
107107
107143
  }
107108
107144
  async createDeployPackageContents(apiVersion) {
@@ -107283,7 +107319,7 @@ var require_scratchOrgInfoGenerator = __commonJS({
107283
107319
  if (Reflect.has(scratchOrgInfo, "package2AncestorIds")) {
107284
107320
  throw new sfError_12.SfError(messages.getMessage("Package2AncestorsIdsKeyNotSupportedError"), "DeprecationError");
107285
107321
  }
107286
- const packagesWithAncestors = (await projectJson.getPackageDirectories()).filter((packageDir) => packageDir.ancestorId ?? packageDir.ancestorVersion);
107322
+ const packagesWithAncestors = (await projectJson.getPackageDirectories()).filter(sfProject_12.isPackagingDirectory).filter((packageDir) => packageDir.ancestorId ?? packageDir.ancestorVersion);
107287
107323
  if (packagesWithAncestors.length === 0) {
107288
107324
  return "";
107289
107325
  }
@@ -107426,6 +107462,7 @@ var require_scratchOrgCreate = __commonJS({
107426
107462
  var orgConfigProperties_12 = require_orgConfigProperties();
107427
107463
  var sfProject_12 = require_sfProject();
107428
107464
  var stateAggregator_12 = require_stateAggregator();
107465
+ var sfError_12 = require_sfError();
107429
107466
  var org_12 = require_org();
107430
107467
  var scratchOrgInfoApi_1 = require_scratchOrgInfoApi();
107431
107468
  var scratchOrgSettingsGenerator_12 = __importDefault3(require_scratchOrgSettingsGenerator());
@@ -107479,6 +107516,12 @@ var require_scratchOrgCreate = __commonJS({
107479
107516
  signupTargetLoginUrlConfig,
107480
107517
  retry: 0
107481
107518
  });
107519
+ await setExitCodeIfError(68)(scratchOrgAuthInfo.handleAliasAndDefaultSettings({
107520
+ alias,
107521
+ setDefault: setDefault ?? false,
107522
+ setDefaultDevHub: false,
107523
+ setTracksSource: tracksSource ?? true
107524
+ }));
107482
107525
  const scratchOrg = await org_12.Org.create({ aliasOrUsername: username });
107483
107526
  const configAggregator = await configAggregator_12.ConfigAggregator.create();
107484
107527
  await (0, scratchOrgLifecycleEvents_12.emit)({ stage: "deploy settings", scratchOrgInfo: soi });
@@ -107487,16 +107530,10 @@ var require_scratchOrgCreate = __commonJS({
107487
107530
  capitalizeRecordTypes
107488
107531
  });
107489
107532
  await settingsGenerator.extract({ ...soi, ...definitionjson });
107490
- const [authInfo] = await Promise.all([
107533
+ const [authInfo] = await setExitCodeIfError(68)(Promise.all([
107491
107534
  (0, scratchOrgInfoApi_1.resolveUrl)(scratchOrgAuthInfo),
107492
107535
  (0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, apiVersion ?? configAggregator.getPropertyValue(orgConfigProperties_12.OrgConfigProperties.ORG_API_VERSION) ?? await scratchOrg.retrieveMaxApiVersion())
107493
- ]);
107494
- await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
107495
- alias,
107496
- setDefault: setDefault ?? false,
107497
- setDefaultDevHub: false,
107498
- setTracksSource: tracksSource ?? true
107499
- });
107536
+ ]));
107500
107537
  cache.unset(soi.Id ?? jobId);
107501
107538
  const authFields = authInfo.getFields();
107502
107539
  await Promise.all([(0, scratchOrgLifecycleEvents_12.emit)({ stage: "done", scratchOrgInfo: soi }), cache.write(), (0, scratchOrgLifecycleEvents_12.emitPostOrgCreate)(authFields)]);
@@ -107573,14 +107610,20 @@ var require_scratchOrgCreate = __commonJS({
107573
107610
  signupTargetLoginUrlConfig,
107574
107611
  retry: retry || 0
107575
107612
  });
107576
- const scratchOrg = await org_12.Org.create({
107577
- aliasOrUsername: soi.Username ?? soi.SignupUsername
107578
- });
107613
+ await setExitCodeIfError(68)(scratchOrgAuthInfo.handleAliasAndDefaultSettings({
107614
+ ...{
107615
+ alias,
107616
+ setDefault,
107617
+ setDefaultDevHub: false,
107618
+ setTracksSource: tracksSource === false ? false : true
107619
+ }
107620
+ }));
107621
+ const scratchOrg = await org_12.Org.create({ aliasOrUsername: soi.Username ?? soi.SignupUsername });
107579
107622
  const username = scratchOrg.getUsername();
107580
107623
  logger.debug(`scratch org username ${username}`);
107581
107624
  await (0, scratchOrgLifecycleEvents_12.emit)({ stage: "deploy settings", scratchOrgInfo: soi });
107582
107625
  const configAggregator = await configAggregator_12.ConfigAggregator.create();
107583
- const [authInfo] = await Promise.all([
107626
+ const [authInfo] = await setExitCodeIfError(68)(Promise.all([
107584
107627
  (0, scratchOrgInfoApi_1.resolveUrl)(scratchOrgAuthInfo),
107585
107628
  (0, scratchOrgInfoApi_1.deploySettings)(
107586
107629
  scratchOrg,
@@ -107589,15 +107632,7 @@ var require_scratchOrgCreate = __commonJS({
107589
107632
  // some of our "wait" time has already been used. Calculate how much remains that we can spend on the deployment.
107590
107633
  kit_1.Duration.milliseconds(wait.milliseconds - (Date.now() - startTimestamp))
107591
107634
  )
107592
- ]);
107593
- await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
107594
- ...{
107595
- alias,
107596
- setDefault,
107597
- setDefaultDevHub: false,
107598
- setTracksSource: tracksSource === false ? false : true
107599
- }
107600
- });
107635
+ ]));
107601
107636
  cache.unset(scratchOrgInfoId);
107602
107637
  const authFields = authInfo.getFields();
107603
107638
  await Promise.all([(0, scratchOrgLifecycleEvents_12.emit)({ stage: "done", scratchOrgInfo: soi }), cache.write(), (0, scratchOrgLifecycleEvents_12.emitPostOrgCreate)(authFields)]);
@@ -107621,10 +107656,17 @@ var require_scratchOrgCreate = __commonJS({
107621
107656
  async function getCapitalizeRecordTypesConfig() {
107622
107657
  const configAgg = await configAggregator_12.ConfigAggregator.create();
107623
107658
  const value = configAgg.getInfo("org-capitalize-record-types").value;
107624
- if (value !== void 0)
107625
- return (0, kit_1.toBoolean)(value);
107626
- return value;
107659
+ return value !== void 0 ? (0, kit_1.toBoolean)(value) : void 0;
107627
107660
  }
107661
+ var setExitCodeIfError = (exitCode) => async (p) => {
107662
+ try {
107663
+ return await p;
107664
+ } catch (e) {
107665
+ const sfError = sfError_12.SfError.wrap(e);
107666
+ sfError.exitCode = exitCode;
107667
+ throw sfError;
107668
+ }
107669
+ };
107628
107670
  }
107629
107671
  });
107630
107672