Skip to content

Commit

Permalink
fix: remove ref to dev dep
Browse files Browse the repository at this point in the history
  • Loading branch information
peternhale committed Aug 22, 2022
1 parent f61bfc9 commit a51323a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/package/packageConvert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import * as os from 'os';
import * as fs from 'fs';
import { Connection, Messages, Org, SfProject } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { uniqid } from '@salesforce/core/lib/testSetup';
import { Many } from '@salesforce/ts-types';
import { uniqid } from '../utils/uniqid';
import * as pkgUtils from '../utils/packageUtils';
import { PackagingSObjects, PackageVersionCreateRequestResult } from '../interfaces';
import { consts } from '../constants';
Expand Down
2 changes: 1 addition & 1 deletion src/package/packageVersionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import {
SfProject,
} from '@salesforce/core';
import { ComponentSetBuilder, ConvertResult, MetadataConverter } from '@salesforce/source-deploy-retrieve';
import { uniqid } from '@salesforce/core/lib/testSetup';
import SettingsGenerator from '@salesforce/core/lib/org/scratchOrgSettingsGenerator';
import * as xml2js from 'xml2js';
import { PackageDirDependency } from '@salesforce/core/lib/sfProject';
import { getAncestorIds, ScratchOrgInfoPayload } from '@salesforce/core/lib/org/scratchOrgInfoGenerator';
import { QueryResult } from 'jsforce';
import { uniqid } from '../utils/uniqid';
import * as pkgUtils from '../utils/packageUtils';
import { BuildNumberToken, VersionNumber } from '../utils/versionNumber';
import {
Expand Down
30 changes: 30 additions & 0 deletions src/utils/uniqid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { randomBytes } from 'crypto';
import * as util from 'util';

/**
* A function to generate a unique id and return it in the context of a template, if supplied.
*
* A template is a string that can contain `${%s}` to be replaced with a unique id.
* If the template contains the "%s" placeholder, it will be replaced with the unique id otherwise the id will be appended to the template.
*
* @param options an object with the following properties:
* - template: a template string.
* - length: the length of the unique id as presented in hexadecimal.
*/
export function uniqid(options?: { template?: string; length?: number }): string {
const uniqueString = randomBytes(Math.ceil((options?.length ?? 32) / 2.0))
.toString('hex')
.slice(0, options?.length ?? 32);
if (!options?.template) {
return uniqueString;
}
return options.template.includes('%s')
? util.format(options.template, uniqueString)
: `${options.template}${uniqueString}`;
}
27 changes: 2 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -711,30 +711,7 @@
strip-ansi "6.0.1"
ts-retry-promise "^0.6.0"

"@salesforce/core@^3.20.1", "@salesforce/core@^3.21.1":
version "3.25.0"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-3.25.0.tgz#ae163d45d640326c999da1664a1e6111ce7d6482"
integrity sha512-Rfj9uOXu/rABXJ6gLgO39Epw8FlRL7QNpVj0Q0VN+vHkxCs+icuQQ3iBAczkKfjXRqRLfjGZc+iiJBDWUyWdXw==
dependencies:
"@salesforce/bunyan" "^2.0.0"
"@salesforce/kit" "^1.5.41"
"@salesforce/schemas" "^1.1.0"
"@salesforce/ts-types" "^1.5.20"
"@types/graceful-fs" "^4.1.5"
"@types/semver" "^7.3.9"
ajv "^8.11.0"
archiver "^5.3.0"
change-case "^4.1.2"
debug "^3.2.7"
faye "^1.4.0"
form-data "^4.0.0"
graceful-fs "^4.2.9"
js2xmlparser "^4.0.1"
jsforce "^2.0.0-beta.16"
jsonwebtoken "8.5.1"
ts-retry-promise "^0.6.0"

"@salesforce/core@^3.26.1":
"@salesforce/core@^3.20.1", "@salesforce/core@^3.21.1", "@salesforce/core@^3.26.1":
version "3.26.1"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-3.26.1.tgz#8d65c6b12085494106a2c7d2545902fa1ff95522"
integrity sha512-B2mhsiiAu9hkLAwkDu+Y5ArAtRJIx2oeqP8ofupLlSH4tohzcUmfKgCDZEk9iLC1sc5kmD1S/4DlS1QZhnNs8A==
Expand Down Expand Up @@ -4026,7 +4003,7 @@ jsesc@^2.5.1:
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4"
integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==

jsforce@^2.0.0-beta.16, jsforce@beta:
jsforce@beta:
version "2.0.0-beta.16"
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-2.0.0-beta.16.tgz#3e5bdbe660d3be2be80fa144456380345011584b"
integrity sha512-oeeOYiRI/1nkUT7YK3irIhyc+J12Ti2sKkGELmeJkPRvcbR2txIenVsV9zW+Q/Ie2uUulhl3pWXk38IyqySSpA==
Expand Down

0 comments on commit a51323a

Please sign in to comment.