Skip to content

Commit

Permalink
chore: script/dep cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Mar 25, 2024
1 parent c15e587 commit 51a83cf
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 240 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@salesforce/core": "^6.7.1",
"@salesforce/core": "^6.7.3",
"@salesforce/kit": "^3.0.15",
"@salesforce/ts-types": "^2.0.9",
"fast-levenshtein": "^3.0.0",
Expand All @@ -47,15 +47,12 @@
"@types/graceful-fs": "^4.1.9",
"@types/mime": "2.0.3",
"@types/minimatch": "^5.1.2",
"@types/proxy-from-env": "^1.0.4",
"@types/shelljs": "^0.8.15",
"deep-equal-in-any-order": "^1.1.19",
"deepmerge": "^4.3.1",
"eslint-plugin-sf-plugin": "^1.17.4",
"jsforce": "^2.0.0-beta.29",
"mocha-junit-reporter": "^1.23.3",
"mocha-snap": "^5.0.0",
"shelljs": "0.8.5",
"ts-node": "^10.9.2",
"ts-patch": "^3.1.1",
"typescript": "^5.4.2"
Expand Down
113 changes: 0 additions & 113 deletions scripts/localInstall.js

This file was deleted.

43 changes: 0 additions & 43 deletions scripts/repl.js

This file was deleted.

22 changes: 13 additions & 9 deletions scripts/update-registry/update2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// determine missing types from metadataCoverageReport
import * as shelljs from 'shelljs';
import { exec } from 'node:child_process';
import { promisify } from 'node:util';
import * as fs from 'fs';
import { MetadataRegistry } from '../../src';
import { exit } from 'process';
Expand All @@ -10,6 +11,7 @@ import { getCurrentApiVersion, getCoverage } from '../../src/registry/coverage';
import { env } from '@salesforce/kit';

export let metadataCoverage: CoverageObject;
const execProm = promisify(exec);

interface DescribeResult {
directoryName: string;
Expand Down Expand Up @@ -40,8 +42,10 @@ const updateProjectScratchDef = (missingTypes: [string, CoverageObjectType][]) =
}
};

const getMissingTypesAsDescribeResult = (missingTypes: [string, CoverageObjectType][]): DescribeResult[] => {
const describeResult = shelljs.exec('sf org list metadata-types -o registryBuilder --json', { silent: true });
const getMissingTypesAsDescribeResult = async (
missingTypes: [string, CoverageObjectType][]
): Promise<DescribeResult[]> => {
const describeResult = await execProm('sf org list metadata-types -o registryBuilder --json');
const metadataObjectsByName = new Map<string, DescribeResult>();
(JSON.parse(describeResult.stdout).result.metadataObjects as DescribeResult[]).map((describeObj) => {
metadataObjectsByName.set(describeObj.xmlName, describeObj);
Expand Down Expand Up @@ -105,12 +109,12 @@ const registryUpdate = (missingTypesAsDescribeResult: DescribeResult[]) => {
);

// create an org we can describe
shelljs.exec('sf project generate -n registryBuilder', { silent: true });
await execProm('sf project generate -n registryBuilder');
updateProjectScratchDef(missingTypes);
// TODO: sourceApi has to match the coverage report
if (!process.env.RB_EXISTING_ORG) {
const hasDefaultDevHub = Boolean(
JSON.parse(shelljs.exec('sf config get target-dev-hub --json', { silent: true }).stdout).result[0].value
JSON.parse((await execProm('sf config get target-dev-hub --json')).stdout).result[0].value
);

if (!hasDefaultDevHub) {
Expand All @@ -122,18 +126,18 @@ Example: \`sf config set defaultdevhubusername=<devhub-username> --global\`
exit(1);
}

shelljs.exec('sf org create scratch -f registryBuilder/config/project-scratch-def.json -y 1 -a registryBuilder');
await execProm('sf org create scratch -f registryBuilder/config/project-scratch-def.json -y 1 -a registryBuilder');
}
// describe the org
const missingTypesAsDescribeResult = getMissingTypesAsDescribeResult(missingTypes);
const missingTypesAsDescribeResult = await getMissingTypesAsDescribeResult(missingTypes);
console.log(missingTypesAsDescribeResult);
registryUpdate(missingTypesAsDescribeResult);

// update the registry

// destroy the scratch org and the project
if (!process.env.RB_EXISTING_ORG) {
shelljs.exec('sf org delete scratch -o registryBuilder --no-prompt');
await execProm('sf org delete scratch -o registryBuilder --no-prompt');
}
shelljs.rm('-rf', 'registryBuilder');
fs.rmSync('registryBuilder', { recursive: true, force: true });
})();
41 changes: 0 additions & 41 deletions scripts/util.js

This file was deleted.

43 changes: 21 additions & 22 deletions src/registry/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,35 @@ export const getCurrentApiVersion = async (): Promise<number> => {
};

export const getCoverage = async (apiVersion: number): Promise<CoverageObject> => {
const versionSources = [
{ cell: 'sdb3', test: 1 },
{ cell: 'ora15', test: 1 },
{ cell: 'sdb4s', test: 1 },
{ cell: 'sdb6', test: 1 },
{ cell: 'ora14', test: 1 },
{ cell: 'sdb10s', test: 1 },
{ cell: 'sdb27', test: 1 },
{ cell: 'ora16', test: 2 },
{ cell: 'sdb14', test: 2 },
{ cell: 'sdb15', test: 2 },
{ cell: 'sdb17s', test: 2 },
{ cell: 'sdb18s', test: 2 },
];
const urls = versionSources.map(
({ cell, test }) => `https://${cell}.test${test}.pc-rnd.pc-aws.salesforce.com/mdcoverage/api.jsp`
);

const results = await Promise.allSettled(
// one of these will match the current version, but they differ during the release cycle
// references: https://confluence.internal.salesforce.com/pages/viewpage.action?pageId=194189303
[
{ cell: 'sdb3', test: 1 },
{ cell: 'ora3', test: 1 },
{ cell: 'sdb4s', test: 1 },
{ cell: 'sdb6', test: 1 },
{ cell: 'ora6', test: 1 },
{ cell: 'sdb10s', test: 1 },
{ cell: 'ora7', test: 2 },
{ cell: 'ora8', test: 2 },
{ cell: 'sdb14', test: 2 },
{ cell: 'sdb15', test: 2 },
{ cell: 'sdb17s', test: 2 },
{ cell: 'sdb18s', test: 2 },
].map(async ({ cell, test }) =>
got(
getProxiedOptions(`https://${cell}.test${test}.pc-rnd.pc-aws.salesforce.com/mdcoverage/api.jsp`)
).json<CoverageObject>()
)
urls.map(getProxiedOptions).map(async (proxy) => got(proxy).json<CoverageObject>())
);
for (const result of results) {
if (result.status === 'fulfilled' && result.value?.apiVersion === apiVersion) {
return result.value;
}
}

console.log(`WARNING: Could not find coverage for api version ${apiVersion}`);

console.log(`WARNING: Could not find coverage for api version ${apiVersion}. Urls attempted:`);
urls.forEach((url) => console.log(url));
return {
apiVersion,
release: '',
Expand Down
Loading

0 comments on commit 51a83cf

Please sign in to comment.