Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"!dist/test/**"
],
"dependencies": {
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@rollup/plugin-virtual": "~3.0.1",
"@rollup/plugin-commonjs": "~23.0.2",
"@rollup/plugin-json": "~5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cadl-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@types/vscode": "~1.53.0",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/eslint-config-cadl": "~0.5.0",
"@cadl-lang/internal-build-utils": "~0.3.2",
"eslint": "^8.12.0",
Expand Down
12 changes: 12 additions & 0 deletions packages/compiler/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"name": "@cadl-lang/compiler",
"entries": [
{
"version": "0.38.1",
"tag": "@cadl-lang/compiler_v0.38.1",
"date": "Thu, 08 Dec 2022 22:04:15 GMT",
"comments": {
"patch": [
{
"comment": "Fix: `scalar` can be used inside of namespace block"
}
]
}
},
{
"version": "0.38.0",
"tag": "@cadl-lang/compiler_v0.38.0",
Expand Down
9 changes: 8 additions & 1 deletion packages/compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change Log - @cadl-lang/compiler

This log was last generated on Wed, 07 Dec 2022 17:21:52 GMT and should not be manually modified.
This log was last generated on Thu, 08 Dec 2022 22:04:15 GMT and should not be manually modified.

## 0.38.1
Thu, 08 Dec 2022 22:04:15 GMT

### Patches

- Fix: `scalar` can be used inside of namespace block

## 0.38.0
Wed, 07 Dec 2022 17:21:52 GMT
Expand Down
3 changes: 3 additions & 0 deletions packages/compiler/core/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ function createParser(code: string | SourceFile, options: ParseOptions = {}): Pa
case Token.ModelKeyword:
item = parseModelStatement(pos, decorators);
break;
case Token.ScalarKeyword:
item = parseScalarStatement(pos, decorators);
break;
case Token.NamespaceKeyword:
const ns = parseNamespaceStatement(pos, decorators);

Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cadl-lang/compiler",
"version": "0.38.0",
"version": "0.38.1",
"description": "Cadl Compiler Preview",
"author": "Microsoft Corporation",
"license": "MIT",
Expand Down
17 changes: 17 additions & 0 deletions packages/compiler/test/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,23 @@ describe("compiler: parser", () => {
["model bar<a, b> = a | b;", [/'{' expected/]],
]);
});

describe("scalar statements", () => {
parseEach([
"scalar uuid extends string;",
`@foo()
scalar uuid extends string;`,
`namespace Foo {
scalar uuid extends string;}
`,
]);

parseErrorEach([
["scalar uuid extends string { }", [/Statement expected./]],
["scalar uuid is string;", [/Statement expected./]],
]);
});

describe("interface statements", () => {
parseEach([
"interface Foo { }",
Expand Down
4 changes: 2 additions & 2 deletions packages/html-program-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"!dist/test/**"
],
"peerDependencies": {
"@cadl-lang/compiler": "~0.38.0"
"@cadl-lang/compiler": "~0.38.1"
},
"dependencies": {
"prettier": "~2.7.1",
Expand All @@ -66,7 +66,7 @@
"@types/prettier": "2.6.0",
"@types/react": "~18.0.5",
"@types/react-dom": "~18.0.1",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/eslint-config-cadl": "~0.5.0",
"@babel/core": "^7.0.0",
"eslint": "^8.12.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/library-linter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
"!dist/test/**"
],
"peerDependencies": {
"@cadl-lang/compiler": "~0.38.0"
"@cadl-lang/compiler": "~0.38.1"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/eslint-config-cadl": "~0.5.0",
"eslint": "^8.12.0",
"mocha": "~10.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
"!dist/test/**"
],
"peerDependencies": {
"@cadl-lang/compiler": "~0.38.0"
"@cadl-lang/compiler": "~0.38.1"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/eslint-config-cadl": "~0.5.0",
"@cadl-lang/eslint-plugin": "~0.38.0",
"eslint": "^8.12.0",
Expand Down
23 changes: 23 additions & 0 deletions packages/migrate/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
{
"name": "@cadl-lang/migrate",
"entries": [
{
"version": "0.38.1",
"tag": "@cadl-lang/migrate_v0.38.1",
"date": "Thu, 08 Dec 2022 22:04:15 GMT",
"comments": {
"patch": [
{
"comment": "Fix missing file env header"
},
{
"comment": "Fix issue with end of file getting dropped."
}
],
"dependency": [
{
"comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.38.0` to `~0.38.1`"
},
{
"comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.38.0` to `~0.38.1`"
}
]
}
},
{
"version": "0.38.0",
"tag": "@cadl-lang/migrate_v0.38.0",
Expand Down
10 changes: 9 additions & 1 deletion packages/migrate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Change Log - @cadl-lang/migrate

This log was last generated on Wed, 07 Dec 2022 17:21:52 GMT and should not be manually modified.
This log was last generated on Thu, 08 Dec 2022 22:04:15 GMT and should not be manually modified.

## 0.38.1
Thu, 08 Dec 2022 22:04:15 GMT

### Patches

- Fix missing file env header
- Fix issue with end of file getting dropped.

## 0.38.0
Wed, 07 Dec 2022 17:21:52 GMT
Expand Down
6 changes: 3 additions & 3 deletions packages/migrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cadl-lang/migrate",
"version": "0.38.0",
"version": "0.38.1",
"author": "Microsoft Corporation",
"description": "Migration tool for cadl.",
"homepage": "https://github.com/Microsoft/cadl",
Expand Down Expand Up @@ -39,13 +39,13 @@
],
"dependencies": {
"globby": "~13.1.1",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/compiler-v0.37": "npm:@cadl-lang/compiler@0.37.0"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/eslint-config-cadl": "~0.5.0",
"@cadl-lang/eslint-plugin": "~0.38.0",
"eslint": "^8.12.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/migrate/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

/* eslint-disable no-console */
import { migrateCadlFiles } from "./migrate.js";
import { migrateModelToScalar } from "./migrations/v0.38/model-to-scalars.js";
Expand Down
2 changes: 2 additions & 0 deletions packages/migrate/src/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ function migrateCadlContentInternal(
segments.push(action.content);
last = action.target.end;
}
segments.push(content.slice(last, -1));

const newContent = segments.join("");

try {
Expand Down
16 changes: 14 additions & 2 deletions packages/migrate/src/migrations/v0.38/model-to-scalars.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { CadlScriptNode, TemplateParameterDeclarationNode } from "@cadl-lang/compiler-v0.37";
import type {
CadlScriptNode,
Node,
TemplateParameterDeclarationNode,
} from "@cadl-lang/compiler-v0.37";
import {
CadlCompilerV0_37,
createMigration,
Expand All @@ -24,7 +28,7 @@ export const migrateModelToScalar = createMigration({
}

const actions: MigrateAction[] = [];
compilerV37.visitChildren(root, (node) => {
visitRecursive(compilerV37, root, (node) => {
if (
node.kind === compilerV37.SyntaxKind.ModelStatement &&
node.is &&
Expand All @@ -47,6 +51,14 @@ export const migrateModelToScalar = createMigration({
},
});

function visitRecursive(compiler: any, root: Node, callback: (node: Node) => void) {
const visit = (node: Node) => {
callback(node);
compiler.visitChildren(node, visit);
};
visit(root);
}

const builtInTypes = new Set([
"bytes",
"numeric",
Expand Down
42 changes: 41 additions & 1 deletion packages/migrate/test/model-to-scalars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { migrateCadlContent } from "../src/migrate.js";
import { migrateModelToScalar } from "../src/migrations/v0.38/model-to-scalars.js";

describe("migration: model to scalars", () => {
it("convert", async () => {
it("various models", async () => {
const [result] = await migrateCadlContent(
`
model foo is string;
Expand Down Expand Up @@ -35,4 +35,44 @@ scalar Resource<T> extends int32;
`.trim()
);
});

it("inside namespace", async () => {
const [result] = await migrateCadlContent(
`
namespace MyService {
model foo is string;
}
`,
migrateModelToScalar
);

strictEqual(
result.trim(),
`
namespace MyService {
scalar foo extends string;
}
`.trim()
);
});

it("with operations", async () => {
const [result] = await migrateCadlContent(
`
model foo is string;

op test(): string;
`,
migrateModelToScalar
);

strictEqual(
result.trim(),
`
scalar foo extends string;

op test(): string;
`.trim()
);
});
});
4 changes: 2 additions & 2 deletions packages/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
"!dist/test/**"
],
"peerDependencies": {
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/rest": "~0.38.0"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/rest": "~0.38.0",
"@cadl-lang/eslint-config-cadl": "~0.5.0",
"@cadl-lang/library-linter": "~0.38.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
],
"peerDependencies": {
"@cadl-lang/versioning": "~0.38.0",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/rest": "~0.38.0",
"@cadl-lang/openapi": "~0.38.0"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/rest": "~0.38.0",
"@cadl-lang/openapi": "~0.38.0",
"@cadl-lang/versioning": "~0.38.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
],
"dependencies": {
"@cadl-lang/versioning": "~0.38.0",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/rest": "~0.38.0",
"@cadl-lang/openapi3": "~0.38.0",
"@cadl-lang/openapi": "~0.38.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/prettier-plugin-cadl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"prettier": "~2.7.1"
},
"devDependencies": {
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/internal-build-utils": "~0.3.2",
"@rollup/plugin-commonjs": "~23.0.2",
"@rollup/plugin-json": "~5.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
"!dist/test/**"
],
"peerDependencies": {
"@cadl-lang/compiler": "~0.38.0"
"@cadl-lang/compiler": "~0.38.1"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/eslint-config-cadl": "~0.5.0",
"@cadl-lang/library-linter": "~0.38.0",
"@cadl-lang/eslint-plugin": "~0.38.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"dependencies": {
"@cadl-lang/versioning": "~0.38.0",
"@cadl-lang/compiler": "~0.38.0",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/rest": "~0.38.0",
"@cadl-lang/openapi": "~0.38.0",
"@cadl-lang/openapi3": "~0.38.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/versioning/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"!dist/test/**"
],
"dependencies": {
"@cadl-lang/compiler": "~0.38.0"
"@cadl-lang/compiler": "~0.38.1"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
Expand Down