runWithConfig method
Runs this command with prepared configuration (options). Subclasses should override this method.
Implementation
@override
Future<void> runWithConfig(final Configuration commandConfig) async {
final projectConfigFile = globalConfiguration.projectConfigFile;
final consoleServer = globalConfiguration.consoleServer;
final openBrowser = globalConfiguration.browser;
final projectId = commandConfig.optionalValue(LaunchOption.projectId);
final preDeployScripts = commandConfig.value(LaunchOption.preDeployScripts);
final deploy = commandConfig.value(LaunchOption.deploy);
final dartVersionOverride = commandConfig.optionalValue(
LaunchOption.dartVersion,
);
final tui = commandConfig.value(LaunchOption.tui);
// Deploy-specific options
final concurrency = commandConfig.value(LaunchOption.concurrency);
final dryRun = commandConfig.value(LaunchOption.dryRun);
final showFiles = commandConfig.value(LaunchOption.showFiles);
final outputPath = commandConfig.optionalValue(LaunchOption.output);
final wait = commandConfig.value(LaunchOption.wait);
final projectDirectory = runner.verifiedProjectDirectory();
if (projectConfigFile != null) {
if (projectId == null) {
throw FailureException(
error:
'The configuration file $projectConfigFile lacks a project ID.',
);
}
if (commandConfig.valueSourceType(LaunchOption.projectId) !=
ValueSourceType.config) {
final config = ScloudConfigIO.readFromFile(projectConfigFile.path);
if (config?.projectId != projectId) {
final confirm = await logger.confirm(
'The specified project ID "$projectId" does not match the scloud config file "${config?.projectId}".'
'\nContinue with deployment to "$projectId"?',
defaultValue: false,
);
if (!confirm) {
logger.info('Deployment cancelled.');
throw UserAbortException();
}
}
}
// Unambiguous scloud.<ext> file found, perform a deploy
logger.debug('Project directory is: ${projectDirectory.path}');
await Deploy.deploy(
runner.serviceProvider.cloudApiClient,
runner.serviceProvider.fileUploaderFactory,
logger: logger,
projectId: projectId,
projectDir: projectDirectory.path,
projectConfigFilePath: projectConfigFile.path,
concurrency: concurrency,
dryRun: dryRun,
showFiles: showFiles,
skipTailingStatus: !wait,
outputPath: outputPath?.path,
dartVersionOverride: dartVersionOverride,
);
return;
}
await Launch.launch(
runner.serviceProvider.cloudApiClient,
runner.serviceProvider.fileUploaderFactory,
logger: logger,
projectDirectory: projectDirectory,
projectId: projectId,
includePreDeployScripts: preDeployScripts,
performDeploy: deploy,
dartVersionOverride: dartVersionOverride,
tui: tui,
consoleServer: consoleServer,
openBrowser: openBrowser,
deployConcurrency: concurrency,
deployDryRun: dryRun,
deployShowFiles: showFiles,
deployOutputPath: outputPath?.path,
deploySkipTailingStatus: !wait,
);
}