prepareApp static method
ProjectFilePreparer
prepareApp(
- Directory appDirectory, {
- Set<
FlutterPlatform> ? platforms, - String? scloudDirPath,
Analyzes the Flutter app in appDirectory and compiles the list of
paths whose contents are to be included.
For an app resolved in a Dart workspace, bespoke deployment files are created, and the app, the workspace packages it depends on, and the workspace root files are included. Otherwise only the app directory is included.
When platforms is given, the code of the other platforms is left out.
Specify scloudDirPath to override the default scloud directory path.
Returns a ProjectFilePreparer object to be used to filter project files.
Throws WorkspaceException if appDirectory is not a Flutter app,
if its package graph is missing, or if the preparation fails.
Throws FailureException if the app has no code for one of platforms.
Implementation
static ProjectFilePreparer prepareApp(
Directory appDirectory, {
Set<FlutterPlatform>? platforms,
String? scloudDirPath,
}) {
final appPubspec = TenantProjectPubspec.fromProjectDir(appDirectory);
if (!appPubspec.isFlutterApp()) {
_throwWorkspaceException(
message: 'The directory ${appDirectory.path} is not a Flutter app.',
hint: 'A Flutter app depends on the Flutter SDK.',
);
}
final excludedPlatformPaths = platforms == null
? const <String>[]
: _excludedPlatformPaths(appDirectory, platforms);
if (!appPubspec.isWorkspaceResolved()) {
WorkspaceProjectLogic.validateIncludedAppPackages([appPubspec.pubspec]);
return ProjectFilePreparer(
isWorkspace: false,
rootDirectory: appDirectory,
scloudDir: Directory(scloudDirPath ?? ScloudIgnore.scloudDirName),
includedSubPaths: const ['.'],
includedPackagePaths: [],
projectPackageName: appPubspec.pubspec.name,
projectVersion: appPubspec.pubspec.version,
keepFlutterEnvironment: true,
excludedSubPaths: excludedPlatformPaths,
packageGraph: _loadAppPackageGraph(appDirectory),
);
}
return _prepareWorkspace(
appDirectory,
projectPackageName: appPubspec.pubspec.name,
excludedProjectSubPaths: excludedPlatformPaths,
projectDirFilename: _scloudAppDirFilename,
validateIncludedPackages:
WorkspaceProjectLogic.validateIncludedAppPackages,
pubGetCommand: 'flutter pub get',
keepFlutterEnvironment: true,
scloudDirPath: scloudDirPath,
);
}