Skip to content

feat: use sf-plugins-core #116

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

Merged
merged 2 commits into from
Sep 2, 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
11 changes: 6 additions & 5 deletions bin/dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

process.env.NODE_ENV = 'development';

const g = global.oclif = global.oclif || {};
const g = (global.oclif = global.oclif || {});

const path = require('path');
const project = path.join(__dirname, '..', 'tsconfig.json');

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

require('ts-node').register()
require('ts-node').register({ project });

require('@oclif/core').run()
.then(require('@oclif/core/flush'))
.catch(require('@oclif/core/handle'))
require('@oclif/core').run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'));
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^0.5.31",
"@oclif/core": "^0.5.34",
"@salesforce/core": "3.4.2",
"@salesforce/plugin-deploy-retrieve-utils": "^0.0.10",
"@salesforce/sf-plugins-core": "^0.0.13",
"tslib": "^2"
},
"devDependencies": {
Expand Down
27 changes: 11 additions & 16 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
import { Command, Flags } from '@oclif/core';
import { fs, Messages } from '@salesforce/core';
import { Env } from '@salesforce/kit';
import {
Deployable,
Deployer,
generateTableChoices,
DeployOptions,
Prompter,
} from '@salesforce/plugin-deploy-retrieve-utils';
import { Deployable, Deployer, generateTableChoices, Prompter, SfHook } from '@salesforce/sf-plugins-core';

Messages.importMessagesDirectory(__dirname);

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

let deployers = (await this.config.runHook('project:findDeployers', options)) as Deployer[];
deployers = deployers.reduce((x, y) => x.concat(y), [] as Deployer[]);
const hookResults = await SfHook.run(this.config, 'sf:deploy', options);

let deployers = hookResults.successes.flatMap((s) => s.result);

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

const deployOptions: DeployOptions = {};
const deployOptions: Deployer.Options = {};
for (const deployer of deployers) {
const opts = options[deployer.getName()] ?? {};
deployOptions[deployer.getName()] = await deployer.setup(flags, opts);
Expand Down Expand Up @@ -89,9 +84,9 @@ export default class Deploy extends Command {
return deployFileExists ? false : true;
}

public async readOptions(): Promise<DeployOptions> {
public async readOptions(): Promise<Record<string, Deployer.Options>> {
if (await fs.fileExists(DEPLOY_OPTIONS_FILE)) {
return (await fs.readJson(DEPLOY_OPTIONS_FILE)) as DeployOptions;
return (await fs.readJson(DEPLOY_OPTIONS_FILE)) as Record<string, Deployer.Options>;
} else {
return {};
}
Expand All @@ -111,9 +106,9 @@ export default class Deploy extends Command {
const deployables: Deployable[] = deployers.reduce((x, y) => x.concat(y.deployables), [] as Deployable[]);
const columns = { name: 'APP OR PACKAGE', type: 'TYPE', path: 'PATH' };
const options = deployables.map((deployable) => ({
name: deployable.getAppName(),
type: deployable.getAppType(),
path: deployable.getAppPath(),
name: deployable.getName(),
type: deployable.getType(),
path: deployable.getPath(),
value: deployable,
}));
const prompter = new Prompter();
Expand All @@ -138,7 +133,7 @@ export default class Deploy extends Command {
}

const final: Deployer[] = [];
for (const [parent, children] of chosenDeployers.entries()) {
for (const [parent, children] of Array.from(chosenDeployers.entries())) {
parent.selectDeployables(children);
final.push(parent);
}
Expand Down
34 changes: 34 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,29 @@
widest-line "^3.1.0"
wrap-ansi "^7.0.0"

"@oclif/core@^0.5.33", "@oclif/core@^0.5.34":
version "0.5.34"
resolved "https://registry.npmjs.org/@oclif/core/-/core-0.5.34.tgz#d8cadcd609929560e6cc836c45d94bc99379e1f6"
integrity sha512-laLrm2tvIOr6uboDMVdAbBJMeAAgV0otkoF8imdyhYCsNcmXFyV3x0kwNGbEUYG945CQ0V00u7MS7tmlwdZlGw==
dependencies:
"@oclif/linewrap" "^1.0.0"
chalk "^4.1.0"
clean-stack "^3.0.0"
cli-ux "^5.1.0"
debug "^4.1.1"
fs-extra "^9.0.1"
get-package-type "^0.1.0"
globby "^11.0.1"
indent-string "^4.0.0"
is-wsl "^2.1.1"
lodash.template "^4.4.0"
semver "^7.3.2"
string-width "^4.2.0"
strip-ansi "^6.0.0"
tslib "^2.0.0"
widest-line "^3.1.0"
wrap-ansi "^7.0.0"

"@oclif/dev-cli@^1":
version "1.26.0"
resolved "https://registry.npmjs.org/@oclif/dev-cli/-/dev-cli-1.26.0.tgz#e3ec294b362c010ffc8948003d3770955c7951fd"
Expand Down Expand Up @@ -1217,6 +1240,17 @@
resolved "https://registry.npmjs.org/@salesforce/schemas/-/schemas-1.0.1.tgz#d1db56759d2b22a7688e1821aec564e979237ad2"
integrity sha512-78pP1GB/DbIS8nSWGL0GpQ27g02drrEo0vzYdRipGYAIXHMzlh1gqEsq0pOiIQlPm1MxWyEqbmf4GG5qSVsd0Q==

"@salesforce/sf-plugins-core@^0.0.13":
version "0.0.13"
resolved "https://registry.npmjs.org/@salesforce/sf-plugins-core/-/sf-plugins-core-0.0.13.tgz#c7f762d94f1cb9bb36b3f486eaa24f66eccaf488"
integrity sha512-hw7dlMNwGlAuJAPaXWotj0JjOEZxr8yyC9Y/NwW1vtM/NFragv77z6QxUDBsebA6t9C+vub8rH0JTP950dvBpg==
dependencies:
"@oclif/core" "^0.5.33"
"@salesforce/kit" "^1.5.8"
"@salesforce/ts-types" "^1.5.13"
cli-ux "^5.6.2"
inquirer "^8.1.1"

"@salesforce/source-deploy-retrieve@^4.1.0":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-4.1.0.tgz#b28b8e1c9c810884315c564751e8854c4e1e16d3"
Expand Down