-
Notifications
You must be signed in to change notification settings - Fork 246
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
feat(rosetta): make assembly validation opt-in #2252
Conversation
Assembly validation (i.e: checking that the content of the `.jsii` file correctly implements the `@jsii/spec` schema) can be slow and memory intensive. It is however typically not of great use, since we should normally be able to assume assemblies are valid. Added a `--validate-assemblies` option (default `false`) to control whether the JSON Schema validation is done or not.
export async function loadAssemblies( | ||
assemblyLocations: readonly string[], | ||
validateAssemblies: boolean, | ||
): Promise<readonly LoadedAssembly[]> { | ||
return Promise.all(assemblyLocations.map(loadAssembly)); | ||
|
||
async function loadAssembly(location: string): Promise<LoadedAssembly> { | ||
const stat = await fs.stat(location); | ||
if (stat.isDirectory()) { | ||
ret.push({ | ||
assembly: await loadAssemblyFromFile(path.join(loc, '.jsii')), // eslint-disable-line no-await-in-loop | ||
directory: loc, | ||
}); | ||
} else { | ||
ret.push({ | ||
assembly: await loadAssemblyFromFile(loc), // eslint-disable-line no-await-in-loop | ||
directory: path.dirname(loc), | ||
}); | ||
return loadAssembly(path.join(location, '.jsii')); | ||
} | ||
return { | ||
assembly: await loadAssemblyFromFile(location, validateAssemblies), | ||
directory: path.dirname(location), | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-worked this code largely to remove the linter exclusions... It does the same work, except in parallel instead of serially, which could be a little faster, since this involves I/O wait.
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Merging (with squash)... |
Assembly validation (i.e: checking that the content of the
.jsii
filecorrectly implements the
@jsii/spec
schema) can be slow and memoryintensive. It is however typically not of great use, since we should
normally be able to assume assemblies are valid.
Added a
--validate-assemblies
option (defaultfalse
) to controlwhether the JSON Schema validation is done or not.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.