Skip to content

Commit

Permalink
feat: remove core from dependencies (#592)
Browse files Browse the repository at this point in the history
* feat: remove core from dependencies

* chore: dir test

* chore: apply suggestions
  • Loading branch information
mingxuanzhangsfdx authored Jul 30, 2024
1 parent 2e8a285 commit f4dc06d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 719 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "jsdoc", "eslint-plugin-header"],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"extends": ["plugin:@typescript-eslint/recommended"],
"rules": {
"ban-ts-ignore": "off",
"@typescript-eslint/ban-ts-ignore": "off",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"/messages"
],
"dependencies": {
"@salesforce/core": "^8.1.1",
"@salesforce/kit": "^3.1.6",
"ejs": "^3.1.10",
"got": "^11.8.2",
Expand Down Expand Up @@ -85,4 +84,4 @@
"publishConfig": {
"access": "public"
}
}
}
17 changes: 11 additions & 6 deletions src/service/gitRepoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
* See https://github.com/vercel/next.js for more information
*/

import { Global } from '@salesforce/core';
import * as crypto from 'crypto';
import * as fs from 'fs';
import got from 'got';
import * as path from 'path';
import { Stream } from 'stream';
import * as tar from 'tar';
import * as os from 'node:os';
import { promisify } from 'util';
import { nls } from '../i18n';
import { HttpsProxyAgent } from 'hpagent';
Expand All @@ -28,6 +28,15 @@ interface RepoInfo {
filePath: string;
}

const SFDX_STATE_FOLDER = '.sfdx';

/**
* The full system path to the preferred global state folder
*/
export function DIR(): string {
return path.join(os.homedir(), SFDX_STATE_FOLDER);
}

/**
* extract repo info from uri
* @param repoUri uri to git repo
Expand Down Expand Up @@ -86,11 +95,7 @@ export function getStoragePathForCustomTemplates(repoUri: URL): string {
.update(repoUri.href)
.digest('hex');

const customTemplatesPath = path.join(
Global.DIR,
'custom-templates',
folderHash
);
const customTemplatesPath = path.join(DIR(), 'custom-templates', folderHash);
return customTemplatesPath;
}

Expand Down
25 changes: 25 additions & 0 deletions test/service/gitRepoUtils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2024, 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 { SinonStub, stub } from 'sinon';
import { expect } from 'chai';
import { DIR } from '../../src/service/gitRepoUtils';
import * as os from 'os';
import * as path from 'path';

describe('DIR', () => {
let homedirStub: SinonStub;
beforeEach(() => {
homedirStub = stub(os, 'homedir');
});
it('should return DIR', () => {
const homedir = '/Users/johndoe';
homedirStub.returns(homedir);
const sfdxStateFolder = '.sfdx';
const dir = DIR();
expect(dir).to.eql(path.join(homedir, sfdxStateFolder));
});
});
Loading

0 comments on commit f4dc06d

Please sign in to comment.