generate static method
Returns null when the configured entry already is a valid integration
entry in integration_test/ and needs no generated wrapper.
Implementation
static GeneratedIntegrationEntry? generate({
required String sourceRelativePath,
required String source,
required String Function() packageName,
required bool sourceHasApplicationEntry,
}) {
final sourcePath = sourceRelativePath.replaceAll('\\', '/');
final alreadyInIntegrationDirectory =
p.posix.split(p.posix.normalize(sourcePath)).first ==
'integration_test';
if (alreadyInIntegrationDirectory && sourceHasApplicationEntry) {
return null;
}
final destinationPath = alreadyInIntegrationDirectory
? EntrySourceTransformer.applicationIntegrationAdapterRelativePath(
sourcePath,
)
: p.posix.join('integration_test', p.posix.basename(sourcePath));
final contents = sourceHasApplicationEntry && !alreadyInIntegrationDirectory
? EntrySourceTransformer.applicationIntegrationWrapperContents(
sourcePath,
)
: _adapt(source, sourcePath, destinationPath, packageName());
return GeneratedIntegrationEntry(
relativePath: destinationPath,
contents: contents,
);
}