Skip to content

Commit bf81d08

Browse files
authored
feat: use sf-plugins-core (#116)
* feat: use sf-plugins-core * chore: code review
1 parent 55aa176 commit bf81d08

File tree

4 files changed

+53
-23
lines changed

4 files changed

+53
-23
lines changed

bin/dev

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
process.env.NODE_ENV = 'development';
44

5-
const g = global.oclif = global.oclif || {};
5+
const g = (global.oclif = global.oclif || {});
6+
7+
const path = require('path');
8+
const project = path.join(__dirname, '..', 'tsconfig.json');
69

710
// In dev mode, always show stack traces
811
global.oclif.debug = true;
912

10-
require('ts-node').register()
13+
require('ts-node').register({ project });
1114

12-
require('@oclif/core').run()
13-
.then(require('@oclif/core/flush'))
14-
.catch(require('@oclif/core/handle'))
15+
require('@oclif/core').run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'));

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@oclif/core": "^0.5.31",
8+
"@oclif/core": "^0.5.34",
99
"@salesforce/core": "3.4.2",
10-
"@salesforce/plugin-deploy-retrieve-utils": "^0.0.10",
10+
"@salesforce/sf-plugins-core": "^0.0.13",
1111
"tslib": "^2"
1212
},
1313
"devDependencies": {

src/commands/deploy.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@
88
import { Command, Flags } from '@oclif/core';
99
import { fs, Messages } from '@salesforce/core';
1010
import { Env } from '@salesforce/kit';
11-
import {
12-
Deployable,
13-
Deployer,
14-
generateTableChoices,
15-
DeployOptions,
16-
Prompter,
17-
} from '@salesforce/plugin-deploy-retrieve-utils';
11+
import { Deployable, Deployer, generateTableChoices, Prompter, SfHook } from '@salesforce/sf-plugins-core';
1812

1913
Messages.importMessagesDirectory(__dirname);
2014

@@ -47,8 +41,9 @@ export default class Deploy extends Command {
4741
this.log(`Using options found in ${DEPLOY_OPTIONS_FILE}`);
4842
}
4943

50-
let deployers = (await this.config.runHook('project:findDeployers', options)) as Deployer[];
51-
deployers = deployers.reduce((x, y) => x.concat(y), [] as Deployer[]);
44+
const hookResults = await SfHook.run(this.config, 'sf:deploy', options);
45+
46+
let deployers = hookResults.successes.flatMap((s) => s.result);
5247

5348
if (deployers.length === 0) {
5449
this.log('Found nothing in the project to deploy');
@@ -61,7 +56,7 @@ export default class Deploy extends Command {
6156
this.log('Nothing was selected to deploy.');
6257
}
6358

64-
const deployOptions: DeployOptions = {};
59+
const deployOptions: Deployer.Options = {};
6560
for (const deployer of deployers) {
6661
const opts = options[deployer.getName()] ?? {};
6762
deployOptions[deployer.getName()] = await deployer.setup(flags, opts);
@@ -89,9 +84,9 @@ export default class Deploy extends Command {
8984
return deployFileExists ? false : true;
9085
}
9186

92-
public async readOptions(): Promise<DeployOptions> {
87+
public async readOptions(): Promise<Record<string, Deployer.Options>> {
9388
if (await fs.fileExists(DEPLOY_OPTIONS_FILE)) {
94-
return (await fs.readJson(DEPLOY_OPTIONS_FILE)) as DeployOptions;
89+
return (await fs.readJson(DEPLOY_OPTIONS_FILE)) as Record<string, Deployer.Options>;
9590
} else {
9691
return {};
9792
}
@@ -111,9 +106,9 @@ export default class Deploy extends Command {
111106
const deployables: Deployable[] = deployers.reduce((x, y) => x.concat(y.deployables), [] as Deployable[]);
112107
const columns = { name: 'APP OR PACKAGE', type: 'TYPE', path: 'PATH' };
113108
const options = deployables.map((deployable) => ({
114-
name: deployable.getAppName(),
115-
type: deployable.getAppType(),
116-
path: deployable.getAppPath(),
109+
name: deployable.getName(),
110+
type: deployable.getType(),
111+
path: deployable.getPath(),
117112
value: deployable,
118113
}));
119114
const prompter = new Prompter();
@@ -138,7 +133,7 @@ export default class Deploy extends Command {
138133
}
139134

140135
const final: Deployer[] = [];
141-
for (const [parent, children] of chosenDeployers.entries()) {
136+
for (const [parent, children] of Array.from(chosenDeployers.entries())) {
142137
parent.selectDeployables(children);
143138
final.push(parent);
144139
}

yarn.lock

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,29 @@
708708
widest-line "^3.1.0"
709709
wrap-ansi "^7.0.0"
710710

711+
"@oclif/core@^0.5.33", "@oclif/core@^0.5.34":
712+
version "0.5.34"
713+
resolved "https://registry.npmjs.org/@oclif/core/-/core-0.5.34.tgz#d8cadcd609929560e6cc836c45d94bc99379e1f6"
714+
integrity sha512-laLrm2tvIOr6uboDMVdAbBJMeAAgV0otkoF8imdyhYCsNcmXFyV3x0kwNGbEUYG945CQ0V00u7MS7tmlwdZlGw==
715+
dependencies:
716+
"@oclif/linewrap" "^1.0.0"
717+
chalk "^4.1.0"
718+
clean-stack "^3.0.0"
719+
cli-ux "^5.1.0"
720+
debug "^4.1.1"
721+
fs-extra "^9.0.1"
722+
get-package-type "^0.1.0"
723+
globby "^11.0.1"
724+
indent-string "^4.0.0"
725+
is-wsl "^2.1.1"
726+
lodash.template "^4.4.0"
727+
semver "^7.3.2"
728+
string-width "^4.2.0"
729+
strip-ansi "^6.0.0"
730+
tslib "^2.0.0"
731+
widest-line "^3.1.0"
732+
wrap-ansi "^7.0.0"
733+
711734
"@oclif/dev-cli@^1":
712735
version "1.26.0"
713736
resolved "https://registry.npmjs.org/@oclif/dev-cli/-/dev-cli-1.26.0.tgz#e3ec294b362c010ffc8948003d3770955c7951fd"
@@ -1217,6 +1240,17 @@
12171240
resolved "https://registry.npmjs.org/@salesforce/schemas/-/schemas-1.0.1.tgz#d1db56759d2b22a7688e1821aec564e979237ad2"
12181241
integrity sha512-78pP1GB/DbIS8nSWGL0GpQ27g02drrEo0vzYdRipGYAIXHMzlh1gqEsq0pOiIQlPm1MxWyEqbmf4GG5qSVsd0Q==
12191242

1243+
"@salesforce/sf-plugins-core@^0.0.13":
1244+
version "0.0.13"
1245+
resolved "https://registry.npmjs.org/@salesforce/sf-plugins-core/-/sf-plugins-core-0.0.13.tgz#c7f762d94f1cb9bb36b3f486eaa24f66eccaf488"
1246+
integrity sha512-hw7dlMNwGlAuJAPaXWotj0JjOEZxr8yyC9Y/NwW1vtM/NFragv77z6QxUDBsebA6t9C+vub8rH0JTP950dvBpg==
1247+
dependencies:
1248+
"@oclif/core" "^0.5.33"
1249+
"@salesforce/kit" "^1.5.8"
1250+
"@salesforce/ts-types" "^1.5.13"
1251+
cli-ux "^5.6.2"
1252+
inquirer "^8.1.1"
1253+
12201254
"@salesforce/source-deploy-retrieve@^4.1.0":
12211255
version "4.1.0"
12221256
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-4.1.0.tgz#b28b8e1c9c810884315c564751e8854c4e1e16d3"

0 commit comments

Comments
 (0)