зеркало из https://github.com/Azure/autorest.git
Rename adl -> cadl (#4277)
This commit is contained in:
Родитель
48ab0a8aa1
Коммит
0f1d386efc
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@autorest/cadl",
|
||||
"comment": "",
|
||||
"type": "none"
|
||||
}
|
||||
],
|
||||
"packageName": "@autorest/cadl",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@autorest/configuration",
|
||||
"comment": "**Rename** `adl` -> `cadl`",
|
||||
"type": "minor"
|
||||
}
|
||||
],
|
||||
"packageName": "@autorest/configuration",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
dependencies:
|
||||
'@azure-tools/adl': 0.10.0
|
||||
'@azure-tools/async-io': 3.0.253
|
||||
'@azure-tools/eventing': 3.0.252
|
||||
'@azure-tools/object-comparison': 3.0.252
|
||||
'@azure-tools/tasks': 3.0.253
|
||||
'@azure-tools/uri': 3.1.1
|
||||
'@azure/logger': 1.0.2
|
||||
'@rush-temp/adl': file:projects/adl.tgz_ts-node@9.1.1+webpack@5.40.0
|
||||
'@cadl-lang/compiler': 0.19.0
|
||||
'@rush-temp/autorest': file:projects/autorest.tgz_ts-node@9.1.1
|
||||
'@rush-temp/cadl': file:projects/cadl.tgz_ts-node@9.1.1+webpack@5.40.0
|
||||
'@rush-temp/codegen': file:projects/codegen.tgz_prettier@2.3.1+ts-node@9.1.1
|
||||
'@rush-temp/codemodel': file:projects/codemodel.tgz_prettier@2.3.1
|
||||
'@rush-temp/common': file:projects/common.tgz_prettier@2.3.1+ts-node@9.1.1
|
||||
|
@ -116,20 +116,6 @@ dependencies:
|
|||
yarn: 1.22.10
|
||||
lockfileVersion: 5.2
|
||||
packages:
|
||||
/@azure-tools/adl/0.10.0:
|
||||
dependencies:
|
||||
autorest: 3.0.6339
|
||||
mkdirp: 1.0.4
|
||||
resolve: 1.20.0
|
||||
vscode-languageserver: 7.0.0
|
||||
vscode-languageserver-textdocument: 1.0.1
|
||||
yargs: 16.2.0
|
||||
dev: false
|
||||
engines:
|
||||
node: '>=14.0.0'
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-TPs30I4ggr5xqvO91HQwr59NuOvJ4ZPFY+dI9enEP1tWrDQrIvz7VatbNmt6xO4RCbdd+Q7TPZMEFnivhcGDuA==
|
||||
/@azure-tools/async-io/3.0.253:
|
||||
dependencies:
|
||||
'@azure-tools/tasks': 3.0.253
|
||||
|
@ -519,6 +505,24 @@ packages:
|
|||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
/@cadl-lang/compiler/0.19.0:
|
||||
dependencies:
|
||||
ajv: 8.4.0
|
||||
glob: 7.1.6
|
||||
js-yaml: 4.1.0
|
||||
mkdirp: 1.0.4
|
||||
node-watch: 0.7.1
|
||||
prettier: 2.2.1
|
||||
resolve: 1.20.0
|
||||
vscode-languageserver: 7.0.0
|
||||
vscode-languageserver-textdocument: 1.0.1
|
||||
yargs: 17.0.1
|
||||
dev: false
|
||||
engines:
|
||||
node: '>=14.0.0'
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-FCO44iX6xJ88rto/0LER3XJsA7Pdh5xgSGkgsM+uQSP4zBuxwcetFAaieIrp9tqfP1aremfRb5nTtxb6dhuurQ==
|
||||
/@cnakazawa/watch/1.0.4:
|
||||
dependencies:
|
||||
exec-sh: 0.3.4
|
||||
|
@ -1559,6 +1563,15 @@ packages:
|
|||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-+nu0HDv7kNSOua9apAVc979qd932rrZeb3WOvoiD31A/p1mIE5/9bN2027pE2rOPYEdS3UHzsvof4hY+lM9/WQ==
|
||||
/ajv/8.4.0:
|
||||
dependencies:
|
||||
fast-deep-equal: 3.1.3
|
||||
json-schema-traverse: 1.0.0
|
||||
require-from-string: 2.0.2
|
||||
uri-js: 4.4.1
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-7QD2l6+KBSLwf+7MuYocbWvRPdOu63/trReTLu2KFwkgctnub1auoF+Y1WYcm09CTM7quuscrzqmASaLHC/K4Q==
|
||||
/ajv/8.6.0:
|
||||
dependencies:
|
||||
fast-deep-equal: 3.1.3
|
||||
|
@ -1800,14 +1813,6 @@ packages:
|
|||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
|
||||
/autorest/3.0.6339:
|
||||
dev: false
|
||||
engines:
|
||||
node: '>=10.13.0'
|
||||
hasBin: true
|
||||
requiresBuild: true
|
||||
resolution:
|
||||
integrity: sha512-OCCmAxi5gUnh7yPho5A4n8kDrnp5uz4DdFrqwMmp/bU5DVByIdVwrWERlB7EnCFqQ9jz86oZtsjy91B07+zLnw==
|
||||
/available-typed-arrays/1.0.2:
|
||||
dependencies:
|
||||
array-filter: 1.0.0
|
||||
|
@ -5376,6 +5381,13 @@ packages:
|
|||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==
|
||||
/js-yaml/4.1.0:
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
dev: false
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
|
||||
/jsdom/16.6.0:
|
||||
dependencies:
|
||||
abab: 2.0.5
|
||||
|
@ -6133,6 +6145,12 @@ packages:
|
|||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg==
|
||||
/node-watch/0.7.1:
|
||||
dev: false
|
||||
engines:
|
||||
node: '>=6'
|
||||
resolution:
|
||||
integrity: sha512-UWblPYuZYrkCQCW5PxAwYSxaELNBLUckrTBBk8xr1/bUgyOkYYTsUcV4e3ytcazFEOyiRyiUrsG37pu6I0I05g==
|
||||
/nomnom/1.5.2:
|
||||
dependencies:
|
||||
colors: 0.5.1
|
||||
|
@ -6900,6 +6918,13 @@ packages:
|
|||
node: '>=6.0.0'
|
||||
resolution:
|
||||
integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
|
||||
/prettier/2.2.1:
|
||||
dev: false
|
||||
engines:
|
||||
node: '>=10.13.0'
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==
|
||||
/prettier/2.3.1:
|
||||
dev: false
|
||||
engines:
|
||||
|
@ -9055,6 +9080,20 @@ packages:
|
|||
node: '>=10'
|
||||
resolution:
|
||||
integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==
|
||||
/yargs/17.0.1:
|
||||
dependencies:
|
||||
cliui: 7.0.4
|
||||
escalade: 3.1.1
|
||||
get-caller-file: 2.0.5
|
||||
require-directory: 2.1.1
|
||||
string-width: 4.2.2
|
||||
y18n: 5.0.5
|
||||
yargs-parser: 20.2.7
|
||||
dev: false
|
||||
engines:
|
||||
node: '>=12'
|
||||
resolution:
|
||||
integrity: sha512-xBBulfCc8Y6gLFcrPvtqKz9hz8SO0l1Ni8GgDekvBX2ro0HRQImDGnikfc33cgzcYUSncapnNcZDjVFIH3f6KQ==
|
||||
/yarn/1.22.10:
|
||||
dev: false
|
||||
engines:
|
||||
|
@ -9081,40 +9120,6 @@ packages:
|
|||
node: '>=10'
|
||||
resolution:
|
||||
integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
|
||||
file:projects/adl.tgz_ts-node@9.1.1+webpack@5.40.0:
|
||||
dependencies:
|
||||
'@azure-tools/adl': 0.10.0
|
||||
'@types/jest': 26.0.20
|
||||
'@types/lodash': 4.14.168
|
||||
'@types/node': 14.14.34
|
||||
'@types/source-map-support': 0.5.3
|
||||
'@types/webpack': 4.41.26
|
||||
'@typescript-eslint/eslint-plugin': 4.17.0_8b165b9e54250ab9ac320f8b5af3f123
|
||||
'@typescript-eslint/parser': 4.17.0_eslint@7.21.0+typescript@4.4.2
|
||||
chalk: 4.1.0
|
||||
eslint: 7.21.0
|
||||
eslint-plugin-jest: 24.3.2_0a8bb714dcb5eb15815cf9c1a5256ac7
|
||||
eslint-plugin-node: 11.1.0_eslint@7.21.0
|
||||
eslint-plugin-prettier: 3.4.0_eslint@7.21.0+prettier@2.3.1
|
||||
eslint-plugin-unicorn: 33.0.1_eslint@7.21.0
|
||||
jest: 27.0.4_ts-node@9.1.1
|
||||
lodash: 4.17.21
|
||||
prettier: 2.3.1
|
||||
rimraf: 3.0.2
|
||||
source-map-support: 0.5.19
|
||||
ts-jest: 27.0.3_jest@27.0.4+typescript@4.4.2
|
||||
ts-loader: 9.2.3_typescript@4.4.2+webpack@5.40.0
|
||||
typescript: 4.4.2
|
||||
dev: false
|
||||
id: file:projects/adl.tgz
|
||||
name: '@rush-temp/adl'
|
||||
peerDependencies:
|
||||
ts-node: '*'
|
||||
webpack: '*'
|
||||
resolution:
|
||||
integrity: sha512-oyhfUgSMH7ef02un2vKk7DZKUxthhmn8Y1tNQxOwYvrRFNoFtSob2lPU4SI83uTY46Qj5Xx+a/e+8AgB0UQ6wQ==
|
||||
tarball: file:projects/adl.tgz
|
||||
version: 0.0.0
|
||||
file:projects/autorest.tgz_ts-node@9.1.1:
|
||||
dependencies:
|
||||
'@azure-tools/async-io': 3.0.253
|
||||
|
@ -9158,6 +9163,40 @@ packages:
|
|||
integrity: sha512-t00ssp/vOTE335m25xu595kuIx7NhVnXZ4UoebDSWjGmga75xRApP4bclhXlwTYB2QMB6qWxPdQbf+cGgx30bA==
|
||||
tarball: file:projects/autorest.tgz
|
||||
version: 0.0.0
|
||||
file:projects/cadl.tgz_ts-node@9.1.1+webpack@5.40.0:
|
||||
dependencies:
|
||||
'@cadl-lang/compiler': 0.19.0
|
||||
'@types/jest': 26.0.20
|
||||
'@types/lodash': 4.14.168
|
||||
'@types/node': 14.14.34
|
||||
'@types/source-map-support': 0.5.3
|
||||
'@types/webpack': 4.41.26
|
||||
'@typescript-eslint/eslint-plugin': 4.17.0_8b165b9e54250ab9ac320f8b5af3f123
|
||||
'@typescript-eslint/parser': 4.17.0_eslint@7.21.0+typescript@4.4.2
|
||||
chalk: 4.1.0
|
||||
eslint: 7.21.0
|
||||
eslint-plugin-jest: 24.3.2_0a8bb714dcb5eb15815cf9c1a5256ac7
|
||||
eslint-plugin-node: 11.1.0_eslint@7.21.0
|
||||
eslint-plugin-prettier: 3.4.0_eslint@7.21.0+prettier@2.3.1
|
||||
eslint-plugin-unicorn: 33.0.1_eslint@7.21.0
|
||||
jest: 27.0.4_ts-node@9.1.1
|
||||
lodash: 4.17.21
|
||||
prettier: 2.3.1
|
||||
rimraf: 3.0.2
|
||||
source-map-support: 0.5.19
|
||||
ts-jest: 27.0.3_jest@27.0.4+typescript@4.4.2
|
||||
ts-loader: 9.2.3_typescript@4.4.2+webpack@5.40.0
|
||||
typescript: 4.4.2
|
||||
dev: false
|
||||
id: file:projects/cadl.tgz
|
||||
name: '@rush-temp/cadl'
|
||||
peerDependencies:
|
||||
ts-node: '*'
|
||||
webpack: '*'
|
||||
resolution:
|
||||
integrity: sha512-5ZVwpkaVN7IdLdIywERX+zREg3EAA+qrPOdgwmFwFmou5/fFLvS3w0wWI4eAVc4TEOqHqSvuICHKDmmhnNpLjw==
|
||||
tarball: file:projects/cadl.tgz
|
||||
version: 0.0.0
|
||||
file:projects/codegen.tgz_prettier@2.3.1+ts-node@9.1.1:
|
||||
dependencies:
|
||||
'@azure-tools/async-io': 3.0.253
|
||||
|
@ -9242,7 +9281,7 @@ packages:
|
|||
prettier: '*'
|
||||
ts-node: '*'
|
||||
resolution:
|
||||
integrity: sha512-tydV9w8KDoUris6dnXEipTGsW+9S/IRs4qFrp7BaHl2n6qva94ydaSKy3d+ixtfyEczvo64I8ZFoZb7ZohOK6A==
|
||||
integrity: sha512-sXSv+9NNnWRKfgmQJaE6TJRq5ul51b5Yr3Mkt5Hk9aF9Gp4rLWCO5qufjz5o146CXydz1aw58scMGsZbLMp/bg==
|
||||
tarball: file:projects/common.tgz
|
||||
version: 0.0.0
|
||||
file:projects/compare.tgz_prettier@2.3.1:
|
||||
|
@ -9730,7 +9769,7 @@ packages:
|
|||
prettier: '*'
|
||||
ts-node: '*'
|
||||
resolution:
|
||||
integrity: sha512-HPw6q8Lfmbyxy/b0JZ3zXXF68ua7KGegMKTWmBN82or64UjJI1WSf5mlbeQlZGQ5v2ISn/b5TeLeKFylcRIYjw==
|
||||
integrity: sha512-6boIi1ErhEN0fDv8QtttPPqLYHYZYbWUfTRL8lVuELTJDI+pKvn12LEa+kZg4aE3nTqId06eDtapm967HsK4LQ==
|
||||
tarball: file:projects/test-utils.tgz
|
||||
version: 0.0.0
|
||||
file:projects/yaml.tgz_prettier@2.3.1+ts-node@9.1.1:
|
||||
|
@ -9764,15 +9803,15 @@ packages:
|
|||
version: 0.0.0
|
||||
registry: ''
|
||||
specifiers:
|
||||
'@azure-tools/adl': ~0.10.0
|
||||
'@azure-tools/async-io': ~3.0.0
|
||||
'@azure-tools/eventing': ~3.0.0
|
||||
'@azure-tools/object-comparison': ~3.0.0
|
||||
'@azure-tools/tasks': ~3.0.0
|
||||
'@azure-tools/uri': ~3.1.1
|
||||
'@azure/logger': ^1.0.2
|
||||
'@rush-temp/adl': file:./projects/adl.tgz
|
||||
'@cadl-lang/compiler': '~0.19.0 '
|
||||
'@rush-temp/autorest': file:./projects/autorest.tgz
|
||||
'@rush-temp/cadl': file:./projects/cadl.tgz
|
||||
'@rush-temp/codegen': file:./projects/codegen.tgz
|
||||
'@rush-temp/codemodel': file:./projects/codemodel.tgz
|
||||
'@rush-temp/common': file:./projects/common.tgz
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
parser: "@typescript-eslint/parser"
|
||||
extends:
|
||||
parser: "@typescript-eslint/parser"
|
||||
extends:
|
||||
- "../../../.default-eslintrc.yaml"
|
|
@ -1,10 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
import defaultConfig from "../../../jest.default.config.js";
|
||||
|
||||
const config = {
|
||||
...defaultConfig,
|
||||
testMatch: ["<rootDir>/src/**/*.test.ts", "<rootDir>/test/**/*.test.ts"],
|
||||
};
|
||||
|
||||
export default config;
|
||||
// @ts-check
|
||||
|
||||
import defaultConfig from "../../../jest.default.config.js";
|
||||
|
||||
const config = {
|
||||
...defaultConfig,
|
||||
testMatch: ["<rootDir>/src/**/*.test.ts", "<rootDir>/test/**/*.test.ts"],
|
||||
};
|
||||
|
||||
export default config;
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@autorest/adl",
|
||||
"name": "@autorest/cadl",
|
||||
"version": "0.0.2",
|
||||
"description": "AutoRest Adl",
|
||||
"description": "AutoRest Cadl plugin",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
|
@ -60,7 +60,7 @@
|
|||
"typescript": "~4.4.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@azure-tools/adl": "~0.10.0",
|
||||
"@cadl-lang/compiler": "~0.19.0 ",
|
||||
"@autorest/extension-base": "~3.3.0"
|
||||
}
|
||||
}
|
|
@ -1,42 +1,42 @@
|
|||
# AutoRest Modeler Four
|
||||
|
||||
## Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
||||
the rights to use your contribution. For details, visit https://cla.microsoft.com.
|
||||
|
||||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
||||
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
||||
provided by the bot. You will only need to do this once across all repos using our CLA.
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
||||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
|
||||
### Autorest plugin configuration
|
||||
|
||||
- Please don't edit this section unless you're re-configuring how the powershell extension plugs in to AutoRest
|
||||
AutoRest needs the below config to pick this up as a plug-in - see https://github.com/Azure/autorest/blob/master/docs/developer/architecture/AutoRest-extension.md
|
||||
|
||||
```yaml
|
||||
pipeline:
|
||||
adl/adl-compiler:
|
||||
output-artifact: swagger-document
|
||||
scope: perform-load
|
||||
|
||||
openapi-document/openapi-document-converter:
|
||||
input: adl/adl-compiler
|
||||
|
||||
swagger-document/loader-swagger:
|
||||
null: true
|
||||
|
||||
openapi-document/loader-openapi:
|
||||
null: true
|
||||
|
||||
openapi-document/individual/identity:
|
||||
null: true
|
||||
|
||||
swagger-document/identity:
|
||||
null: true
|
||||
```
|
||||
# AutoRest Modeler Four
|
||||
|
||||
## Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
||||
the rights to use your contribution. For details, visit https://cla.microsoft.com.
|
||||
|
||||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
||||
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
||||
provided by the bot. You will only need to do this once across all repos using our CLA.
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
||||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
|
||||
### Autorest plugin configuration
|
||||
|
||||
- Please don't edit this section unless you're re-configuring how the powershell extension plugs in to AutoRest
|
||||
AutoRest needs the below config to pick this up as a plug-in - see https://github.com/Azure/autorest/blob/master/docs/developer/architecture/AutoRest-extension.md
|
||||
|
||||
```yaml
|
||||
pipeline:
|
||||
cadl/cadl-compiler:
|
||||
output-artifact: swagger-document
|
||||
scope: perform-load
|
||||
|
||||
openapi-document/openapi-document-converter:
|
||||
input: cadl/cadl-compiler
|
||||
|
||||
swagger-document/loader-swagger:
|
||||
null: true
|
||||
|
||||
openapi-document/loader-openapi:
|
||||
null: true
|
||||
|
||||
openapi-document/individual/identity:
|
||||
null: true
|
||||
|
||||
swagger-document/identity:
|
||||
null: true
|
||||
```
|
|
@ -1,24 +1,26 @@
|
|||
// TODO-TIM fix this in extension-base
|
||||
import { Channel, Host } from "@autorest/extension-base";
|
||||
import { fileURLToPath } from "url";
|
||||
import { compileAdl } from "./adl-compiler.js";
|
||||
import { compileAdl } from "./cadl-compiler.js";
|
||||
|
||||
export async function setupAdlCompilerPlugin(host: Host) {
|
||||
const inputFiles = await host.GetValue("inputFileUris");
|
||||
const entrypoint = inputFiles[0];
|
||||
const result = await compileAdl(fileURLToPath(entrypoint));
|
||||
|
||||
if ("error" in result) {
|
||||
for (const diagnostic of result.error.diagnostics) {
|
||||
if ("diagnostics" in result) {
|
||||
for (const diagnostic of result.diagnostics) {
|
||||
host.Message({
|
||||
Channel: Channel.Error,
|
||||
Text: diagnostic.message,
|
||||
Source: [
|
||||
{
|
||||
document: `file:///${diagnostic.file.path.replace(/\\/g, "/")}`,
|
||||
Position: indexToPosition(diagnostic.file.text, diagnostic.pos),
|
||||
},
|
||||
],
|
||||
Source:
|
||||
diagnostic.file !== undefined
|
||||
? [
|
||||
{
|
||||
document: `file:///${diagnostic.file.path.replace(/\\/g, "/")}`,
|
||||
Position: indexToPosition(diagnostic.file.text, diagnostic.pos ?? 1),
|
||||
},
|
||||
]
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
import { CompilerHost, createProgram, DiagnosticError } from "@azure-tools/adl";
|
||||
import { readdir, readFile, realpath, stat } from "fs/promises";
|
||||
import { CompilerHost, createProgram, Diagnostic, createSourceFile } from "@cadl-lang/compiler";
|
||||
import { readFile, realpath, stat } from "fs/promises";
|
||||
import { join, resolve } from "path";
|
||||
import { fileURLToPath, pathToFileURL } from "url";
|
||||
|
||||
export function createAdlHost(writeFile: (path: string, content: string) => Promise<void>): CompilerHost {
|
||||
return {
|
||||
readFile: (path: string) => readFile(path, "utf-8"),
|
||||
readDir: (path: string) => readdir(path, { withFileTypes: true }),
|
||||
getCwd: () => process.cwd(),
|
||||
getExecutionRoot: () => resolve(fileURLToPath(import.meta.url), "../../node_modules/@azure-tools/adl"),
|
||||
readFile: async (path: string) => createSourceFile((await readFile(path, "utf-8")).toString(), path),
|
||||
resolveAbsolutePath: (path: string) => resolve(path),
|
||||
getExecutionRoot: () => resolve(fileURLToPath(import.meta.url), "../../node_modules/@cadl-lang/compiler"),
|
||||
getJsImport: (path: string) => import(pathToFileURL(path).href),
|
||||
writeFile,
|
||||
getLibDirs() {
|
||||
|
@ -26,20 +25,21 @@ export function createAdlHost(writeFile: (path: string, content: string) => Prom
|
|||
|
||||
export async function compileAdl(
|
||||
entrypoint: string,
|
||||
): Promise<{ compiledFiles: Record<string, string> } | { error: DiagnosticError }> {
|
||||
): Promise<{ compiledFiles: Record<string, string> } | { diagnostics: readonly Diagnostic[] }> {
|
||||
const output: Record<string, string> = {};
|
||||
const writeFile = async (path: string, content: string) => {
|
||||
output[path] = content;
|
||||
};
|
||||
|
||||
try {
|
||||
const program = await createProgram(createAdlHost(writeFile), {
|
||||
mainFile: entrypoint,
|
||||
});
|
||||
const program = await createProgram(createAdlHost(writeFile), entrypoint);
|
||||
if (program.diagnostics.length > 0) {
|
||||
return { diagnostics: program.diagnostics };
|
||||
}
|
||||
return { compiledFiles: output };
|
||||
} catch (e) {
|
||||
if (typeof e === "object" && e !== null && "diagnostics" in e) {
|
||||
return { error: e as DiagnosticError };
|
||||
return { diagnostics: (e as any).diagnostics };
|
||||
}
|
||||
throw e;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { AutoRestExtension } from "@autorest/extension-base";
|
||||
import { setupAdlCompilerPlugin } from "./adl-compiler-plugin.js";
|
||||
import { setupAdlCompilerPlugin } from "./cadl-compiler-plugin.js";
|
||||
|
||||
export async function initializePlugins(pluginHost: AutoRestExtension) {
|
||||
pluginHost.Add("adl-compiler", setupAdlCompilerPlugin);
|
|
@ -1,4 +1,4 @@
|
|||
import { compileAdl } from "adl-compiler";
|
||||
import { compileAdl } from "cadl-compiler";
|
||||
import { dirname, join } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
model Foo {
|
||||
bar: string;
|
||||
other: string;
|
||||
}
|
||||
model Foo {
|
||||
bar: string;
|
||||
other: string;
|
||||
}
|
|
@ -1,68 +1,68 @@
|
|||
# Default Configuration - OpenAPI 3 loader
|
||||
|
||||
This loads OpenAPI3 documents from the values in the configuration `input-file`.
|
||||
|
||||
It requires no normalization, and will pass out the `openapi-document` artifacts.
|
||||
|
||||
```yaml !$(adl)
|
||||
pipeline:
|
||||
openapi-document/loader-openapi:
|
||||
scope: perform-load
|
||||
|
||||
openapi-document/individual/transform:
|
||||
input: loader-openapi
|
||||
|
||||
openapi-document/individual/schema-validator-openapi:
|
||||
input: individual/transform
|
||||
|
||||
openapi-document/individual/identity:
|
||||
input: individual/schema-validator-openapi
|
||||
```
|
||||
|
||||
# Default Configuration -- OpenAPI2 loader
|
||||
|
||||
This loads OpenAPI2 documents from the values in the configuration `input-file`.
|
||||
|
||||
It converts the files to OpenAPI3 and processes them to normalization as
|
||||
`openapi-document` artifacts.
|
||||
|
||||
```yaml !$(adl)
|
||||
pipeline:
|
||||
swagger-document/loader-swagger:
|
||||
# plugin: loader # IMPLICIT: default to last item if split by '/'
|
||||
output-artifact: swagger-document
|
||||
scope: perform-load
|
||||
|
||||
swagger-document/individual/transform:
|
||||
input: loader-swagger
|
||||
output-artifact: swagger-document
|
||||
|
||||
swagger-document/individual/schema-validator-swagger:
|
||||
input: individual/transform
|
||||
output-artifact: swagger-document
|
||||
|
||||
swagger-document/individual/identity:
|
||||
input: individual/schema-validator-swagger
|
||||
output-artifact: swagger-document
|
||||
|
||||
# swagger-document/transform-immediate:
|
||||
# input:
|
||||
# - swagger-document-override/md-override-loader-swagger
|
||||
# - individual/identity
|
||||
# output-artifact: swagger-document
|
||||
|
||||
swagger-document/identity:
|
||||
# input: swagger-document/transform-immediate
|
||||
input: individual/schema-validator-swagger
|
||||
output-artifact: swagger-document
|
||||
|
||||
# OpenAPI
|
||||
openapi-document/openapi-document-converter:
|
||||
input: swagger-document/identity
|
||||
# output-artifact: openapi-document
|
||||
```
|
||||
|
||||
```yaml $(adl)
|
||||
use-extension:
|
||||
"@autorest/adl": latest
|
||||
```
|
||||
# Default Configuration - OpenAPI 3 loader
|
||||
|
||||
This loads OpenAPI3 documents from the values in the configuration `input-file`.
|
||||
|
||||
It requires no normalization, and will pass out the `openapi-document` artifacts.
|
||||
|
||||
```yaml !$(cadl)
|
||||
pipeline:
|
||||
openapi-document/loader-openapi:
|
||||
scope: perform-load
|
||||
|
||||
openapi-document/individual/transform:
|
||||
input: loader-openapi
|
||||
|
||||
openapi-document/individual/schema-validator-openapi:
|
||||
input: individual/transform
|
||||
|
||||
openapi-document/individual/identity:
|
||||
input: individual/schema-validator-openapi
|
||||
```
|
||||
|
||||
# Default Configuration -- OpenAPI2 loader
|
||||
|
||||
This loads OpenAPI2 documents from the values in the configuration `input-file`.
|
||||
|
||||
It converts the files to OpenAPI3 and processes them to normalization as
|
||||
`openapi-document` artifacts.
|
||||
|
||||
```yaml !$(cadl)
|
||||
pipeline:
|
||||
swagger-document/loader-swagger:
|
||||
# plugin: loader # IMPLICIT: default to last item if split by '/'
|
||||
output-artifact: swagger-document
|
||||
scope: perform-load
|
||||
|
||||
swagger-document/individual/transform:
|
||||
input: loader-swagger
|
||||
output-artifact: swagger-document
|
||||
|
||||
swagger-document/individual/schema-validator-swagger:
|
||||
input: individual/transform
|
||||
output-artifact: swagger-document
|
||||
|
||||
swagger-document/individual/identity:
|
||||
input: individual/schema-validator-swagger
|
||||
output-artifact: swagger-document
|
||||
|
||||
# swagger-document/transform-immediate:
|
||||
# input:
|
||||
# - swagger-document-override/md-override-loader-swagger
|
||||
# - individual/identity
|
||||
# output-artifact: swagger-document
|
||||
|
||||
swagger-document/identity:
|
||||
# input: swagger-document/transform-immediate
|
||||
input: individual/schema-validator-swagger
|
||||
output-artifact: swagger-document
|
||||
|
||||
# OpenAPI
|
||||
openapi-document/openapi-document-converter:
|
||||
input: swagger-document/identity
|
||||
# output-artifact: openapi-document
|
||||
```
|
||||
|
||||
```yaml $(cadl)
|
||||
use-extension:
|
||||
"@autorest/adl": latest
|
||||
```
|
||||
|
|
|
@ -148,8 +148,8 @@
|
|||
"shouldPublish": true
|
||||
},
|
||||
{
|
||||
"packageName": "@autorest/adl",
|
||||
"projectFolder": "packages/extensions/adl",
|
||||
"packageName": "@autorest/cadl",
|
||||
"projectFolder": "packages/extensions/cadl",
|
||||
"reviewCategory": "production",
|
||||
"shouldPublish": true
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче