Skip to content

fix: cloud run command does not respect useLegacyWorkflow flag #4664

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 1 commit into from
Jun 3, 2019
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
22 changes: 11 additions & 11 deletions lib/common/services/commands-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ export class CommandsService implements ICommandsService {
private $extensibilityService: IExtensibilityService,
private $optionsTracker: IOptionsTracker,
private $projectDataService: IProjectDataService) {
let projectData = null;
try {
projectData = this.$projectDataService.getProjectData();
} catch (err) {
this.$logger.trace(`Error while trying to get project data. More info: ${err}`);
}

this.$options.setupOptions(projectData);
this.$options.printMessagesForDeprecatedOptions(this.$logger);
}

public allCommands(opts: { includeDevCommands: boolean }): string[] {
Expand Down Expand Up @@ -114,8 +105,17 @@ export class CommandsService implements ICommandsService {

private async tryExecuteCommandAction(commandName: string, commandArguments: string[]): Promise<boolean | ICanExecuteCommandOutput> {
const command = this.$injector.resolveCommand(commandName);
if (!command || (command && !command.isHierarchicalCommand)) {
this.$options.validateOptions(command ? command.dashedOptions : null);
if (!command || !command.isHierarchicalCommand) {
let projectData = null;
try {
projectData = this.$projectDataService.getProjectData();
} catch (err) {
this.$logger.trace(`Error while trying to get project data. More info: ${err}`);
}

const dashedOptions = command ? command.dashedOptions : null;
this.$options.validateOptions(dashedOptions, projectData);
this.$options.printMessagesForDeprecatedOptions(this.$logger);
}

return this.canExecuteCommand(commandName, commandArguments);
Expand Down
3 changes: 1 addition & 2 deletions lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ interface IAndroidBundleOptions {

interface IOptions extends IRelease, IDeviceIdentifier, IJustLaunch, IAvd, IAvailableDevices, IProfileDir, IHasEmulatorOption, IBundleString, IPlatformTemplate, IHasEmulatorOption, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, IAndroidBundleOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions, IPluginSeedOptions, IGenerateOptions {
argv: IYargArgv;
validateOptions(commandSpecificDashedOptions?: IDictionary<IDashedOption>): void;
validateOptions(commandSpecificDashedOptions?: IDictionary<IDashedOption>, projectData?: IProjectData): void;
options: IDictionary<IDashedOption>;
shorthands: string[];
/**
Expand Down Expand Up @@ -573,7 +573,6 @@ interface IOptions extends IRelease, IDeviceIdentifier, IJustLaunch, IAvd, IAvai
performance: Object;
cleanupLogFile: string;
workflow: any;
setupOptions(projectData: IProjectData): void;
printMessagesForDeprecatedOptions(logger: ILogger): void;
}

Expand Down
15 changes: 8 additions & 7 deletions lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export class Options {

public options: IDictionary<IDashedOption>;

public setupOptions(projectData: IProjectData): void {
public setupOptions(projectData: IProjectData, commandSpecificDashedOptions?: IDictionary<IDashedOption>): void {
if (commandSpecificDashedOptions) {
_.extend(this.options, commandSpecificDashedOptions);
this.setArgv();
}

if (this.argv.release && this.argv.hmr) {
this.$errors.failWithoutHelp("The options --release and --hmr cannot be used simultaneously.");
}
Expand Down Expand Up @@ -173,12 +178,8 @@ export class Options {
return this.argv[optionName];
}

public validateOptions(commandSpecificDashedOptions?: IDictionary<IDashedOption>): void {
if (commandSpecificDashedOptions) {
_.extend(this.options, commandSpecificDashedOptions);
this.setArgv();
}

public validateOptions(commandSpecificDashedOptions?: IDictionary<IDashedOption>, projectData?: IProjectData): void {
this.setupOptions(projectData, commandSpecificDashedOptions);
const parsed = Object.create(null);
// DO NOT REMOVE { } as when they are missing and some of the option values is false, the each stops as it thinks we have set "return false".
_.each(_.keys(this.argv), optionName => {
Expand Down
4 changes: 2 additions & 2 deletions test/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ describe("options", () => {
it(`should pass correctly when ${testCase.name} and useLegacyWorkflow is ${useLegacyWorkflow}`, () => {
(testCase.args || []).forEach(arg => process.argv.push(arg));

const options = createOptions(testInjector);
const options: any = createOptions(testInjector);
const projectData = <IProjectData>{ useLegacyWorkflow };
options.setupOptions(projectData);

Expand Down Expand Up @@ -359,7 +359,7 @@ describe("options", () => {
errors.failWithoutHelp = (error: string) => actualError = error;
(testCase.args || []).forEach(arg => process.argv.push(arg));

const options = createOptions(testInjector);
const options: any = createOptions(testInjector);
options.setupOptions(null);

(testCase.args || []).forEach(arg => process.argv.pop());
Expand Down