Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
feat: use npm postinstall script to install sf
Browse files Browse the repository at this point in the history
  • Loading branch information
RodEsp committed Oct 7, 2021
1 parent 36b1418 commit 97791ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
15 changes: 0 additions & 15 deletions bin/run-sf

This file was deleted.

14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"homepage": "https://github.com/salesforcecli/sfdx-cli/",
"repository": "salesforcecli/sfdx-cli",
"bin": {
"sfdx": "bin/run",
"sf": "bin/run-sf"
"sfdx": "bin/run"
},
"engines": {
"node": ">=10"
Expand Down Expand Up @@ -90,7 +89,6 @@
}
},
"pinnedDependencies": [
"@salesforce/cli",
"@salesforce/plugin-alias",
"@salesforce/plugin-apex",
"@salesforce/plugin-auth",
Expand Down Expand Up @@ -119,7 +117,6 @@
"@oclif/plugin-update": "1.5.0",
"@oclif/plugin-warn-if-update-available": "^1.7.0",
"@oclif/plugin-which": "^1.0.3",
"@salesforce/cli": "1.0.5",
"@salesforce/kit": "^1.5.13",
"@salesforce/lazy-require": "^0.4.0",
"@salesforce/plugin-alias": "1.1.21",
Expand Down Expand Up @@ -204,24 +201,25 @@
"lint": "eslint \"src/**/*.ts\"",
"oclif-artifacts": "oclif manifest",
"pack:deb": "oclif pack:deb",
"pack:docker:slim": "./scripts/docker-publish-slim.js",
"pack:docker:full": "./scripts/docker-publish-full.js",
"pack:docker:slim": "./scripts/docker-publish-slim.js",
"pack:macos": "oclif pack:macos",
"pretarball": "sf-release cli:tarballs:prepare && ./scripts/include-sf.js",
"pack:tarballs": "oclif pack:tarballs",
"pack:verify": "sf-release cli:tarballs:verify",
"pack:win": "oclif pack:win",
"postinstall": "npm install @salesforce/cli -g",
"postpack": "rm -f oclif.manifest.json",
"posttest": "yarn test:deprecation-policy ",
"prepack": "yarn compile && yarn lint && yarn oclif-artifacts",
"prepare": "yarn compile && yarn lint",
"promote": "oclif promote",
"pretarball": "sf-release cli:tarballs:prepare && ./scripts/include-sf.js",
"promote-dist-tags": "./scripts/promote-dist-tags",
"promote-docker": "./scripts/docker-promote.js",
"promote": "oclif promote",
"snapshot-generate": "HOME=./ ./bin/run snapshot:generate",
"test": "mocha --recursive \"test/**/*.ts\" && nyc --report lcov --report cobertura mocha -t 240000 --require source-map-support/register --recursive \"dist/**/*.test.js\"",
"test-smoke-unix": "./tmp/sfdx/bin/sfdx version && ./tmp/sfdx/bin/sfdx help && ./tmp/sfdx/bin/sfdx plugins --core",
"test:deprecation-policy": "set HOME=./ ./bin/run snapshot:compare",
"test": "mocha --recursive \"test/**/*.ts\" && nyc --report lcov --report cobertura mocha -t 240000 --require source-map-support/register --recursive \"dist/**/*.test.js\"",
"trogdor": "yarn clean-all && yarn && yarn compile && yarn uts",
"upload:deb": "oclif upload:deb",
"upload:macos": "oclif upload:macos",
Expand Down
15 changes: 10 additions & 5 deletions scripts/include-sf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ const path = require('path');
const shelljs = require('shelljs');
const fs = require('fs');

const sfUnixPath = 'node_modules/@salesforce/cli/bin/run';
const sfGlobalPath = path.join(shelljs.exec('npm list -g --depth 0 | head -1'), 'node_modules', '@salesforce', 'cli');

// Copy sf to the bin/cli dir of sfdx
shelljs.mv('-f', sfGlobalPath, path.join(process.cwd(), 'bin', 'sf-cli'));

const sfUnixPath = 'bin/sf-cli/bin/run';
const sfBin = path.join('bin', 'sf');
const sfdxBin = path.join('bin', 'sfdx');

const sfWinPath = 'node_modules\\@salesforce\\cli\\bin\\run';
const sfCmd = path.join('bin', 'sf.cmd');
const sfdxCmd = path.join('bin', 'sfdx.cmd');

console.log(`---- Including SF ----`);
console.log(` Updating ${sfdxBin} with references to sf`);
const binContents = fs
Expand All @@ -24,6 +25,10 @@ console.log(` Writing ${sfBin}`);
fs.writeFileSync(sfBin, binContents);
shelljs.chmod('+x', sfBin);

const sfWinPath = 'bin\\sf-cli\\bin\\run';
const sfCmd = path.join('bin', 'sf.cmd');
const sfdxCmd = path.join('bin', 'sfdx.cmd');

console.log(` Updating ${sfCmd} with references to sf`);
const cmdContents = fs
.readFileSync(sfdxCmd, 'UTF-8')
Expand Down

0 comments on commit 97791ad

Please sign in to comment.