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.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.2",
"tag": "@cadl-lang/compiler_v0.38.2",
"date": "Fri, 09 Dec 2022 20:43:01 GMT",
"comments": {
"patch": [
{
"comment": "Fix: Revert breaking change to global cli usage"
}
]
}
},
{
"version": "0.38.1",
"tag": "@cadl-lang/compiler_v0.38.1",
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 Thu, 08 Dec 2022 22:04:15 GMT and should not be manually modified.
This log was last generated on Fri, 09 Dec 2022 20:43:01 GMT and should not be manually modified.

## 0.38.2
Fri, 09 Dec 2022 20:43:01 GMT

### Patches

- Fix: Revert breaking change to global cli usage

## 0.38.1
Thu, 08 Dec 2022 22:04:15 GMT
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/cmd/cadl-server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node
import { runScript } from "../dist/cmd/runner.js";
await runScript("dist/server/server.js");
await runScript("entrypoints/server.js", "dist/server/server.js");
2 changes: 1 addition & 1 deletion packages/compiler/cmd/cadl.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node
import { runScript } from "../dist/cmd/runner.js";
await runScript("dist/core/cli/cli.js");
await runScript("entrypoints/cli.js", "dist/core/cli/cli.js");
21 changes: 15 additions & 6 deletions packages/compiler/cmd/runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile, realpath, stat } from "fs/promises";
import path from "path";
import { access, constants, readFile, realpath, stat } from "fs/promises";
import { join, resolve } from "path";
import url from "url";
import { resolveModule, ResolveModuleHost } from "../core/module-resolver.js";

Expand All @@ -10,20 +10,29 @@ import { resolveModule, ResolveModuleHost } from "../core/module-resolver.js";
* Prevents loading two conflicting copies of Cadl modules from global and
* local package locations.
*/
export async function runScript(relativePath: string): Promise<void> {
export async function runScript(relativePath: string, backupPath: string): Promise<void> {
const packageRoot = await resolvePackageRoot();

if (packageRoot) {
const script = path.join(packageRoot, relativePath);
let script = join(packageRoot, relativePath);
if (!(await checkFileExists(script)) && backupPath) {
script = join(packageRoot, backupPath);
}
const scriptUrl = url.pathToFileURL(script).toString();
import(scriptUrl);
await import(scriptUrl);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch. I wonder why eslint didn't find this one.

} else {
throw new Error(
"Couldn't resolve Cadl compiler root. This is unexpected. Please file an issue at https://github.com/Microsoft/cadl."
);
}
}

function checkFileExists(file: string) {
return access(file, constants.F_OK)
.then(() => true)
.catch(() => false);
}

async function resolvePackageRoot(): Promise<string> {
if (process.env.CADL_SKIP_COMPILER_RESOLVE === "1") {
return await getThisPackageRoot();
Expand Down Expand Up @@ -55,5 +64,5 @@ async function resolvePackageRoot(): Promise<string> {
}

async function getThisPackageRoot() {
return path.resolve(await realpath(url.fileURLToPath(import.meta.url)), "../../..");
return resolve(await realpath(url.fileURLToPath(import.meta.url)), "../../..");
}
4 changes: 4 additions & 0 deletions packages/compiler/core/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* For backward compatibility where global compiler would look at ./node_modules/@cadl-lang/compiler/dist/core/cli/cli.js
*/
import "./cli/cli.js";
5 changes: 5 additions & 0 deletions packages/compiler/entrypoints/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* File serving as an entrypoint to resolve a local cadl install from a global install.
* DO NOT MOVE or this will create a breaking change for user of global cli.
*/
import "../dist/core/cli/cli.js";
5 changes: 5 additions & 0 deletions packages/compiler/entrypoints/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* File serving as an entrypoint to resolve a local cadl install from a global install.
* DO NOT MOVE or this will create a breaking change for user of global cli.
*/
import "../dist/server/server.js";
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.1",
"version": "0.38.2",
"description": "Cadl Compiler Preview",
"author": "Microsoft Corporation",
"license": "MIT",
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.1"
"@cadl-lang/compiler": "~0.38.2"
},
"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.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1"
"@cadl-lang/compiler": "~0.38.2"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1"
"@cadl-lang/compiler": "~0.38.2"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/compiler": "~0.38.2",
"@cadl-lang/eslint-config-cadl": "~0.5.0",
"@cadl-lang/eslint-plugin": "~0.38.0",
"eslint": "^8.12.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
],
"dependencies": {
"globby": "~13.1.1",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1",
"@cadl-lang/compiler": "~0.38.2",
"@cadl-lang/eslint-config-cadl": "~0.5.0",
"@cadl-lang/eslint-plugin": "~0.38.0",
"eslint": "^8.12.0",
Expand Down
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.1",
"@cadl-lang/compiler": "~0.38.2",
"@cadl-lang/rest": "~0.38.0"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1"
"@cadl-lang/compiler": "~0.38.2"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
"@types/node": "~18.11.9",
"@cadl-lang/compiler": "~0.38.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1",
"@cadl-lang/compiler": "~0.38.2",
"@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.1"
"@cadl-lang/compiler": "~0.38.2"
},
"devDependencies": {
"@types/mocha": "~10.0.0",
Expand Down