Skip to content
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

Adding versioning check for TypeSpec init template #2121

Merged
merged 16 commits into from
Jul 7, 2023

Conversation

allenjzhang
Copy link
Member

Also:

  1. added options to bypass file generation
  2. added pre and post message
  3. per template version schema validation

@github-actions
Copy link
Contributor

Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status):
Playground: https://cadlplayground.z22.web.core.windows.net/prs/2121/

Website: https://cadlwebsite.z1.web.core.windows.net/prs/2121/

packages/compiler/src/init/init-template.ts Outdated Show resolved Hide resolved
packages/compiler/src/init/init-template.ts Outdated Show resolved Hide resolved
packages/compiler/src/init/init-template.ts Outdated Show resolved Hide resolved
packages/compiler/src/init/init.ts Outdated Show resolved Hide resolved
packages/compiler/src/init/init.ts Outdated Show resolved Hide resolved
packages/compiler/src/init/init.ts Outdated Show resolved Hide resolved
packages/compiler/src/init/init.ts Outdated Show resolved Hide resolved
@@ -286,7 +287,10 @@ async function validateTemplate(template: any, templatesUrl: TemplatesUrl): Prom
const validationTarget = templatesUrl.file as SourceFile;
let validationResult: ValidationResult;
// 1. If current version > minimumCompilerVersion, proceed with strict validation
if (template.minimumCompilerVersion && currentCompilerVersion > template.minimumCompilerVersion) {
if (
template.minimumCompilerVersion &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we using semver pacakge do we maybe just want to leave that as a semver range(>=0.45.0) and rename to compilerVersion

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the rename. Not sure about "leave that" means. compilerVersion default value as ">=0.46.0" ?

packages/compiler/src/init/init.ts Outdated Show resolved Hide resolved
function logDiagnostics(diagnostics: readonly Diagnostic[]): void {
diagnostics.forEach((diagnostic) => {
// eslint-disable-next-line no-console
console.log(diagnostic.message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we consider the rest of the diagnostic, code/severity not useful here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion

packages/compiler/src/init/init.ts Outdated Show resolved Hide resolved
@allenjzhang allenjzhang enabled auto-merge (squash) July 7, 2023 17:24
@allenjzhang allenjzhang merged commit ab7c20e into microsoft:main Jul 7, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants