Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump deps and use internal fs #242

Merged
merged 2 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/config": "^1",
"@salesforce/command": "^4.0.4",
"@salesforce/core": "^2.26.1",
"@salesforce/command": "^4.1.2",
"@salesforce/core": "^2.28.0",
"@salesforce/source-deploy-retrieve": "^4.4.6",
"chalk": "^4.1.1",
"chalk": "^4.1.2",
"cli-ux": "^5.6.3",
"open": "^8.2.1",
"tslib": "^2"
Expand All @@ -27,26 +27,26 @@
"@salesforce/source-testkit": "^0.0.14",
"@salesforce/ts-sinon": "1.3.21",
"@types/debug": "^4.1.7",
"@types/jsforce": "^1.9.33",
"@types/jsforce": "^1.9.35",
"@types/shelljs": "^0.8.9",
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.28.5",
"chai": "^4.3.4",
"chai-each": "^0.0.1",
"cz-conventional-changelog": "^3.3.0",
"debug": "^4.3.2",
"eslint": "^7.31.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-salesforce": "^0.1.6",
"eslint-config-salesforce-license": "^0.1.6",
"eslint-config-salesforce-typescript": "^0.2.7",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsdoc": "^35.1.3",
"eslint-plugin-prettier": "^3.4.0",
"fast-glob": "^3.2.7",
"husky": "^4.3.8",
"lint-staged": "^11.1.1",
"lint-staged": "^11.2.0",
"mocha": "^8.4.0",
"nyc": "^15.1.0",
"prettier": "^2.3.2",
Expand All @@ -55,7 +55,7 @@
"shelljs": "^0.8.4",
"shx": "0.3.3",
"sinon": "10.0.0",
"ts-node": "^10.0.0",
"ts-node": "^10.2.1",
"typescript": "^4.1.3"
},
"config": {
Expand Down Expand Up @@ -128,14 +128,14 @@
"test": "sf-test",
"test:command-reference": "./bin/run commandreference:generate --erroronwarnings",
"test:deprecation-policy": "./bin/run snapshot:compare",
"test:nuts": "ts-node ./test/nuts/generateNuts.ts && nyc mocha \"**/*.nut.ts\" --slow 3000 --timeout 600000 --parallel --retries 0",
"test:nuts:convert": "PLUGIN_SOURCE_SEED_FILTER=\"convert\" ts-node ./test/nuts/generateNuts.ts && nyc mocha \"**/*.nut.ts\" --slow 3000 --timeout 600000 --parallel --retries 0",
"test:nuts:delete": "nyc mocha \"test/nuts/delete.nut.ts\" --slow 3000 --timeout 600000 --parallel --retries 0",
"test:nuts:deploy": "PLUGIN_SOURCE_SEED_FILTER=\"deploy\" ts-node ./test/nuts/generateNuts.ts && nyc mocha \"**/*.nut.ts\" --slow 3000 --timeout 600000 --parallel --retries 0",
"test:nuts:folders": "nyc mocha \"test/nuts/folderTypes.nut.ts\" --slow 3000 --timeout 600000",
"test:nuts:manifest:create": "nyc mocha \"test/nuts/create.nut.ts\" --slow 3000 --timeout 600000 --parallel --retries 0",
"test:nuts:retrieve": "PLUGIN_SOURCE_SEED_FILTER=\"retrieve\" ts-node ./test/nuts/generateNuts.ts && nyc mocha \"**/*.nut.ts\" --slow 3000 --timeout 600000 --parallel --retries 0",
"test:nuts:territory2": "nyc mocha \"test/nuts/territory2.nut.ts\" --slow 3000 --timeout 600000 --retries 0",
"test:nuts": "ts-node ./test/nuts/generateNuts.ts && nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
"test:nuts:convert": "PLUGIN_SOURCE_SEED_FILTER=\"convert\" ts-node ./test/nuts/generateNuts.ts && nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
"test:nuts:delete": "nyc mocha \"test/nuts/delete.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
"test:nuts:deploy": "PLUGIN_SOURCE_SEED_FILTER=\"deploy\" ts-node ./test/nuts/generateNuts.ts && nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
"test:nuts:folders": "nyc mocha \"test/nuts/folderTypes.nut.ts\" --slow 4500 --timeout 600000",
"test:nuts:manifest:create": "nyc mocha \"test/nuts/create.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
"test:nuts:retrieve": "PLUGIN_SOURCE_SEED_FILTER=\"retrieve\" ts-node ./test/nuts/generateNuts.ts && nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
"test:nuts:territory2": "nyc mocha \"test/nuts/territory2.nut.ts\" --slow 4500 --timeout 600000 --retries 0",
"version": "oclif-dev readme"
},
"husky": {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/force/source/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import * as os from 'os';
import { join, resolve } from 'path';
import * as fs from 'fs';
import { flags, FlagsConfig } from '@salesforce/command';
import { fs, Messages } from '@salesforce/core';
import { Messages } from '@salesforce/core';
import { MetadataConverter, ConvertResult } from '@salesforce/source-deploy-retrieve';
import { getString } from '@salesforce/ts-types';
import { SourceCommand } from '../../../sourceCommand';
Expand Down
3 changes: 2 additions & 1 deletion src/commands/force/source/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as os from 'os';
import * as fs from 'fs';
import { confirm } from 'cli-ux/lib/prompt';
import { flags, FlagsConfig } from '@salesforce/command';
import { fs, Messages } from '@salesforce/core';
import { Messages } from '@salesforce/core';
import { ComponentSet, RequestStatus, SourceComponent } from '@salesforce/source-deploy-retrieve';
import { Duration, once, env } from '@salesforce/kit';
import { getString } from '@salesforce/ts-types';
Expand Down
4 changes: 2 additions & 2 deletions src/commands/force/source/manifest/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
import * as os from 'os';
import { join } from 'path';
import * as fs from 'fs';
import { flags, FlagsConfig } from '@salesforce/command';
import { fs } from '@salesforce/core';
import { Messages } from '@salesforce/core';
import { SourceCommand } from '../../../../sourceCommand';
import { ComponentSetBuilder } from '../../../../componentSetBuilder';
Expand Down Expand Up @@ -97,7 +97,7 @@ export class create extends SourceCommand {
this.outputPath = this.manifestName;
}

return fs.writeFile(this.outputPath, componentSet.getPackageXml());
return fs.writeFileSync(this.outputPath, componentSet.getPackageXml());
}

// noop this method because any errors will be reported by the createManifest method
Expand Down
8 changes: 4 additions & 4 deletions src/commands/force/source/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import * as os from 'os';
import * as path from 'path';
import * as fs from 'fs';
import * as open from 'open';
import { getString } from '@salesforce/ts-types';
import { fs, AuthInfo } from '@salesforce/core';
import { AuthInfo, SfdcUrl } from '@salesforce/core';
import { flags, FlagsConfig } from '@salesforce/command';
import { Messages, sfdc, SfdxError } from '@salesforce/core';
import checkLightningDomain from '@salesforce/core/lib/util/checkLightningDomain';
import { SourceComponent, MetadataResolver } from '@salesforce/source-deploy-retrieve';
import { OpenResultFormatter, OpenCommandResult } from '../../../formatters/openResultFormatter';
import { SourceCommand } from '../../../sourceCommand';
Expand Down Expand Up @@ -81,7 +81,7 @@ export class Open extends SourceCommand {
}

private getTypeNameDefinitionByFileName(fsPath: string): string | undefined {
if (fs.fileExistsSync(fsPath)) {
if (fs.existsSync(fsPath)) {
const metadataResolver = new MetadataResolver();
const components: SourceComponent[] = metadataResolver.getComponentsFromPath(fsPath);
return components[0].type.name;
Expand Down Expand Up @@ -121,7 +121,7 @@ export class Open extends SourceCommand {
}

try {
const result = await checkLightningDomain(url);
const result = await new SfdcUrl(url).checkLightningDomain();

if (result) {
return act();
Expand Down
4 changes: 3 additions & 1 deletion test/commands/source/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
* 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 * as fs from 'fs';
import { join } from 'path';
import * as sinon from 'sinon';
import { expect } from 'chai';
import { ComponentSet } from '@salesforce/source-deploy-retrieve';
import { fs, Lifecycle, Org, SfdxProject } from '@salesforce/core';
import { Lifecycle, Org, SfdxProject } from '@salesforce/core';
import { fromStub, stubInterface, stubMethod } from '@salesforce/ts-sinon';
import { IConfig } from '@oclif/config';
import { UX } from '@salesforce/command';
Expand Down
5 changes: 3 additions & 2 deletions test/commands/source/open.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as fs from 'fs';
import { join } from 'path';
import * as sinon from 'sinon';
import { expect } from 'chai';
import { SourceComponent, MetadataResolver } from '@salesforce/source-deploy-retrieve';
import { fromStub, stubInterface, stubMethod } from '@salesforce/ts-sinon';
import { IConfig } from '@oclif/config';
import { AuthInfo, SfdxProject, Org, fs, MyDomainResolver } from '@salesforce/core';
import { AuthInfo, SfdxProject, Org, MyDomainResolver } from '@salesforce/core';
import { Open } from '../../../src/commands/force/source/open';
import { OpenCommandResult } from '../../../src/formatters/openResultFormatter';

Expand Down Expand Up @@ -112,7 +113,7 @@ describe('force:source:open', () => {
return frontDoorUrl;
},
});
stubMethod(sandbox, fs, 'fileExistsSync').returns(true);
stubMethod(sandbox, fs, 'existsSync').returns(true);
getComponentsFromPathStub = stubMethod(sandbox, MetadataResolver.prototype, 'getComponentsFromPath').callsFake(
(fsPath: string) => {
if (fsPath.includes('flexipage')) {
Expand Down
2 changes: 1 addition & 1 deletion test/nuts/create.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as fs from 'fs';
import { join } from 'path';
import { expect } from '@salesforce/command/lib/test';
import { TestSession } from '@salesforce/cli-plugins-testkit';
import { execCmd } from '@salesforce/cli-plugins-testkit';
import { fs } from '@salesforce/core';
import { Dictionary } from '@salesforce/ts-types';

describe('force:source:manifest:create', () => {
Expand Down
14 changes: 7 additions & 7 deletions test/nuts/delete.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import { expect } from 'chai';
import { execCmd } from '@salesforce/cli-plugins-testkit';
import { SourceTestkit } from '@salesforce/source-testkit';
import { fs } from '@salesforce/core';

describe('source:delete NUTs', () => {
const executable = path.join(process.cwd(), 'bin', 'run');
Expand Down Expand Up @@ -50,8 +50,8 @@ describe('source:delete NUTs', () => {
}
).jsonOutput.result;
expect(response.deletedSource).to.have.length(2);
expect(fs.fileExistsSync(pathToJson)).to.be.false;
expect(fs.fileExistsSync(pathToXml)).to.be.false;
expect(fs.existsSync(pathToJson)).to.be.false;
expect(fs.existsSync(pathToXml)).to.be.false;
});

it('should source:delete an ApexClass using the metadata param', () => {
Expand All @@ -63,7 +63,7 @@ describe('source:delete NUTs', () => {
}
).jsonOutput.result;
expect(response.deletedSource).to.have.length(2);
expect(fs.fileExistsSync(pathToClass)).to.be.false;
expect(fs.existsSync(pathToClass)).to.be.false;
});

it('should source:delete all Prompts using the metadata param', () => {
Expand All @@ -88,7 +88,7 @@ describe('source:delete NUTs', () => {
}
).jsonOutput.result;
expect(response.deletedSource).to.have.length(2);
expect(fs.fileExistsSync(pathToClass)).to.be.false;
expect(fs.existsSync(pathToClass)).to.be.false;
});

it('should NOT delete local files with --checkonly', () => {
Expand All @@ -101,7 +101,7 @@ describe('source:delete NUTs', () => {
).jsonOutput.result;
expect(response.deletedSource).to.have.length(2);
expect(response.deletes[0].checkOnly).to.be.true;
expect(fs.fileExistsSync(pathToClass)).to.be.true;
expect(fs.existsSync(pathToClass)).to.be.true;
});

it('should run tests with a delete', async () => {
Expand All @@ -116,6 +116,6 @@ describe('source:delete NUTs', () => {
expect(response.runTestsEnabled).to.be.true;
expect(response.checkOnly).to.be.false;
// ensure a failed delete attempt won't delete local files
expect(fs.fileExistsSync(pathToClass)).to.be.true;
expect(fs.existsSync(pathToClass)).to.be.true;
});
});
27 changes: 14 additions & 13 deletions test/nuts/generateNuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import * as shelljs from 'shelljs';
import { fs } from '@salesforce/core';
import { EXECUTABLES, RepoConfig, TEST_REPOS_MAP } from './testMatrix';

const SEED_FILTER = process.env.PLUGIN_SOURCE_SEED_FILTER || '';

async function getSeedFiles(): Promise<string[]> {
function getSeedFiles(): string[] {
const seedDir = path.join(__dirname, 'seeds');
const files = await fs.readdir(seedDir);
const files = fs.readdirSync(seedDir);
return files
.filter((f) => f.endsWith('.seed.ts'))
.filter((f) => f.includes(SEED_FILTER))
Expand All @@ -26,13 +26,13 @@ function parseRepoName(repo?: RepoConfig): string {
return repo ? repo.gitUrl.split('/').reverse()[0].replace('.git', '') : '';
}

async function generateNut(
function generateNut(
generatedDir: string,
seedName: string,
seedContents: string,
executable: string,
repo?: RepoConfig
): Promise<void> {
): void {
const repoName = parseRepoName(repo);
const executableName = path.basename(executable);
const nutFileName = repoName
Expand All @@ -49,25 +49,26 @@ async function generateNut(
.replace(/%REPO_URL%/g, repo?.gitUrl)
.replace(/%EXECUTABLE%/g, executable)
.replace(/%REPO_NAME%/g, repoName);
await fs.writeFile(nutFilePath, contents);
fs.writeFileSync(nutFilePath, contents);
}

async function generateNuts(): Promise<void> {
function generateNuts(): void {
const generatedDir = path.resolve(__dirname, 'generated');
shelljs.rm('-rf', generatedDir);
await fs.mkdirp(generatedDir);
const seeds = await getSeedFiles();
fs.mkdirSync(generatedDir, { recursive: true });
const seeds = getSeedFiles();
for (const seed of seeds) {
const seedName = path.basename(seed).replace('.seed.ts', '');
const seedContents = await fs.readFile(seed, 'UTF-8');
const seedContents = fs.readFileSync(seed).toString();
for (const executable of EXECUTABLES.filter((e) => !e.skip)) {
const hasRepo = /const\sREPO\s=\s/.test(seedContents);
if (hasRepo) {
for (const repo of [...TEST_REPOS_MAP.values()].filter((r) => !r.skip)) {
await generateNut(generatedDir, seedName, seedContents, executable.path, repo);
const repos = Array.from(TEST_REPOS_MAP.values()).filter((r) => !r.skip);
for (const repo of repos) {
generateNut(generatedDir, seedName, seedContents, executable.path, repo);
}
} else {
await generateNut(generatedDir, seedName, seedContents, executable.path);
generateNut(generatedDir, seedName, seedContents, executable.path);
}
}
}
Expand Down
Loading