From 48f6bd8f3040c015c47a0dd60bbb028ec52320f8 Mon Sep 17 00:00:00 2001 From: azlam Date: Tue, 8 Aug 2023 23:33:04 +1000 Subject: [PATCH] fix(deps): fix usage of glob --- packages/core/src/apex/parser/ApexTypeFetcher.ts | 4 ++-- packages/core/src/apextest/ApexTestSuite.ts | 5 +++-- packages/core/src/artifacts/ArtifactFetcher.ts | 4 ++-- packages/core/src/metadata/MetadataFiles.ts | 4 ++-- packages/core/src/package/components/MetadataCount.ts | 4 +--- .../package/packageInstallers/InstallSourcePackageImpl.ts | 6 +++--- packages/sfprofiles/src/impl/metadata/metadataFiles.ts | 4 ++-- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/core/src/apex/parser/ApexTypeFetcher.ts b/packages/core/src/apex/parser/ApexTypeFetcher.ts index d92d77ec2..3dff890f1 100644 --- a/packages/core/src/apex/parser/ApexTypeFetcher.ts +++ b/packages/core/src/apex/parser/ApexTypeFetcher.ts @@ -1,6 +1,6 @@ import * as fs from 'fs-extra'; const path = require('path'); -const glob = require('glob'); +const { globSync } = require('glob'); import ApexTypeListener from './listeners/ApexTypeListener'; @@ -33,7 +33,7 @@ export default class ApexTypeFetcher { public getClassesClassifiedByType(): ApexSortedByType { let clsFiles: string[]; if (fs.existsSync(this.searchDir)) { - clsFiles = glob.sync(`**/*.cls`, { + clsFiles = globSync(`**/*.cls`, { cwd: this.searchDir, absolute: true, }); diff --git a/packages/core/src/apextest/ApexTestSuite.ts b/packages/core/src/apextest/ApexTestSuite.ts index 21bfef93b..abf1b3fed 100644 --- a/packages/core/src/apextest/ApexTestSuite.ts +++ b/packages/core/src/apextest/ApexTestSuite.ts @@ -1,13 +1,14 @@ -const glob = require('glob'); + const fs = require('fs-extra'); import path from 'path'; import xml2json from '../utils/xml2json'; +import { globSync } from 'glob'; export default class ApexTestSuite { public constructor(private sourceDir: string, private suiteName: string) {} public async getConstituentClasses(): Promise { - let testSuitePaths: string[] = glob.sync(`**${this.suiteName}.testSuite-meta.xml`, { + let testSuitePaths: string[] = globSync(`**${this.suiteName}.testSuite-meta.xml`, { cwd: this.sourceDir, absolute: true, }); diff --git a/packages/core/src/artifacts/ArtifactFetcher.ts b/packages/core/src/artifacts/ArtifactFetcher.ts index 2f5d54237..92c667f20 100644 --- a/packages/core/src/artifacts/ArtifactFetcher.ts +++ b/packages/core/src/artifacts/ArtifactFetcher.ts @@ -1,7 +1,7 @@ import path = require('path'); import * as fs from 'fs-extra'; import SFPLogger, { Logger, LoggerLevel } from '@dxatscale/sfp-logger'; -const glob = require('glob'); +const { globSync } = require('glob'); import AdmZip = require('adm-zip'); import semver = require('semver'); import tar = require('tar'); @@ -140,7 +140,7 @@ export default class ArtifactFetcher { pattern = `**/*sfpowerscripts_artifact*.@(zip|tgz)`; } - let artifacts: string[] = glob.sync(pattern, { + let artifacts: string[] = globSync(pattern, { cwd: artifactDirectory, absolute: true, }); diff --git a/packages/core/src/metadata/MetadataFiles.ts b/packages/core/src/metadata/MetadataFiles.ts index 881c14b79..cffbea0d6 100644 --- a/packages/core/src/metadata/MetadataFiles.ts +++ b/packages/core/src/metadata/MetadataFiles.ts @@ -5,8 +5,8 @@ import FileUtils from '../utils/Fileutils'; import * as _ from 'lodash'; import ignore from 'ignore'; import * as fs from 'fs-extra'; -import * as glob from 'glob'; import ProjectConfig from '../project/ProjectConfig'; +import { globSync } from 'glob'; const SEP = /\/|\\/; @@ -259,7 +259,7 @@ export default class MetadataFiles { let extension = path.parse(filePath).ext; associatedFilePattern = filePath.replace(extension, '.*'); } - let files = glob.sync(associatedFilePattern); + let files = globSync(associatedFilePattern); for (let i = 0; i < files.length; i++) { if (fs.lstatSync(files[i]).isDirectory() == false) { let oneFilePath = path.join('.', files[i]); diff --git a/packages/core/src/package/components/MetadataCount.ts b/packages/core/src/package/components/MetadataCount.ts index 6854ff441..0265694ac 100644 --- a/packages/core/src/package/components/MetadataCount.ts +++ b/packages/core/src/package/components/MetadataCount.ts @@ -1,6 +1,4 @@ -const { - glob - } = require('glob') +const glob = require('glob') import path from 'path'; export default class MetadataCount { diff --git a/packages/core/src/package/packageInstallers/InstallSourcePackageImpl.ts b/packages/core/src/package/packageInstallers/InstallSourcePackageImpl.ts index 8a2eb0615..f208ab305 100644 --- a/packages/core/src/package/packageInstallers/InstallSourcePackageImpl.ts +++ b/packages/core/src/package/packageInstallers/InstallSourcePackageImpl.ts @@ -4,7 +4,6 @@ import DeployDestructiveManifestToOrgImpl from '../components/DeployDestructiveM import SFPLogger, { COLOR_SUCCESS, COLOR_WARNING, Logger, LoggerLevel } from '@dxatscale/sfp-logger'; import * as fs from 'fs-extra'; const path = require('path'); -const glob = require('glob'); const tmp = require('tmp'); import { InstallPackage, SfpPackageInstallationOptions } from './InstallPackage'; import DeploySourceToOrgImpl, { DeploymentOptions } from '../../deployers/DeploySourceToOrgImpl'; @@ -19,6 +18,7 @@ import DeploymentOptionDisplayer from '../../display/DeploymentOptionDisplayer'; import PackageComponentPrinter from '../../display/PackageComponentPrinter'; import DeployErrorDisplayer from '../../display/DeployErrorDisplayer'; import { COLOR_ERROR } from '@dxatscale/sfp-logger'; +import { globSync } from 'glob'; export default class InstallSourcePackageImpl extends InstallPackage { private pathToReplacementForceIgnore: string; @@ -268,7 +268,7 @@ export default class InstallSourcePackageImpl extends InstallPackage { this.logger ); //copy the original profiles to temporary location - profileFolders = glob.sync('**/profiles', { + profileFolders = globSync('**/profiles', { cwd: path.join(sourceDirectoryPath), }); if (profileFolders.length > 0) { @@ -327,7 +327,7 @@ export default class InstallSourcePackageImpl extends InstallPackage { //Now deploy the profies alone - const profilesDirs = glob.sync('**/profiles/', { + const profilesDirs = globSync('**/profiles/', { cwd: path.join(sourceDirectoryPath, sourceDirectory), absolute: true, }); diff --git a/packages/sfprofiles/src/impl/metadata/metadataFiles.ts b/packages/sfprofiles/src/impl/metadata/metadataFiles.ts index c5d556625..7cdf12cf0 100644 --- a/packages/sfprofiles/src/impl/metadata/metadataFiles.ts +++ b/packages/sfprofiles/src/impl/metadata/metadataFiles.ts @@ -4,9 +4,9 @@ import FileUtils from 'utils/fileutils'; import _ from 'lodash'; import ignore from 'ignore'; import * as fs from 'fs-extra'; -import * as glob from 'glob'; import { Sfpowerkit } from 'utils/sfpowerkit'; import SFPLogger, {LoggerLevel } from '@dxatscale/sfp-logger'; +import { globSync } from 'glob'; const SEP = /\/|\\/; @@ -265,7 +265,7 @@ export default class MetadataFiles { let extension = path.parse(filePath).ext; associatedFilePattern = filePath.replace(extension, '.*'); } - let files = glob.sync(associatedFilePattern); + let files = globSync(associatedFilePattern); for (let i = 0; i < files.length; i++) { if (fs.lstatSync(files[i]).isDirectory() == false) { let oneFilePath = path.join('.', files[i]);