Merge branch 'main' into feature/application-octet-stream-formdata

This commit is contained in:
Timothee Guerin 2021-10-20 14:58:53 -07:00 коммит произвёл GitHub
Родитель 2812591537 fb1e174d52
Коммит 92409ee3d7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
454 изменённых файлов: 12353 добавлений и 27423 удалений

Просмотреть файл

@ -6,6 +6,7 @@ plugins:
- unicorn
- node
- jest
- import
env:
es6: true
@ -16,6 +17,9 @@ extends:
- plugin:@typescript-eslint/recommended
- plugin:node/recommended
- plugin:jest/recommended
- plugin:jest/recommended
- plugin:import/recommended
- plugin:import/typescript
globals:
Atomics: readonly
@ -27,30 +31,30 @@ parserOptions:
project: ./tsconfig.json
rules:
"@typescript-eslint/no-this-alias": "off"
"@typescript-eslint/interface-name-prefix": "off"
"@typescript-eslint/explicit-function-return-type": "off"
"@typescript-eslint/no-explicit-any": "off"
"@typescript-eslint/no-empty-interface": "off"
"@typescript-eslint/no-namespace": "off"
"@typescript-eslint/explicit-member-accessibility": "off"
"@typescript-eslint/no-unused-vars": "off"
"@typescript-eslint/no-parameter-properties": "off"
"@typescript-eslint/no-angle-bracket-type-assertion": "off"
"@typescript-eslint/no-use-before-define": "off"
"@typescript-eslint/no-var-requires": "off"
"@typescript-eslint/no-empty-function": "off"
"@typescript-eslint/explicit-module-boundary-types": "off"
"@typescript-eslint/ban-types": "off"
"@typescript-eslint/consistent-type-assertions": "off"
"@typescript-eslint/no-floating-promises": "warn"
"@typescript-eslint/no-this-alias": off
"@typescript-eslint/interface-name-prefix": off
"@typescript-eslint/explicit-function-return-type": off
"@typescript-eslint/no-explicit-any": off
"@typescript-eslint/no-empty-interface": off
"@typescript-eslint/no-namespace": off
"@typescript-eslint/explicit-member-accessibility": off
"@typescript-eslint/no-unused-vars": off
"@typescript-eslint/no-parameter-properties": off
"@typescript-eslint/no-angle-bracket-type-assertion": off
"@typescript-eslint/no-use-before-define": off
"@typescript-eslint/no-var-requires": off
"@typescript-eslint/no-empty-function": off
"@typescript-eslint/explicit-module-boundary-types": off
"@typescript-eslint/ban-types": off
"@typescript-eslint/consistent-type-assertions": off
"@typescript-eslint/no-floating-promises": warn
"require-atomic-updates": "off"
"require-atomic-updates": off
# Prettier config https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
prettier/prettier: "warn"
arrow-body-style: "off"
prefer-arrow-callback: "off"
prettier/prettier: warn
arrow-body-style: off
prefer-arrow-callback: off
# Unicorn plugin config
unicorn/filename-case: warn
@ -75,10 +79,24 @@ rules:
jest/no-focused-tests: warn
jest/no-identical-title: warn
# =================================================
# Import plugin
# =================================================
import/no-default-export: warn
import/no-self-import: warn # This cause many circular dependency issues with index files.
import/no-internal-modules: off
import/no-unresolved: off
import/order:
- warn
- groups: ["builtin", "external", "parent", "sibling", "index"]
alphabetize:
order: "asc"
caseInsensitive: true
# Basic config
no-console: warn
no-undef: "off"
no-unused-vars: "off"
no-undef: off
no-unused-vars: off
no-multiple-empty-lines:
- warn
- max: 2

Просмотреть файл

@ -1,24 +0,0 @@
FROM ubuntu:bionic
LABEL maintainer="fearthecowboy"
# Required for install
RUN apt-get update && apt-get install -y curl libunwind8 libicu60
# NodeJS
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt-get update && apt-get install -y nodejs && \
npm install npm@latest -g
# Autorest
RUN npm install -g autorest@latest
RUN autorest --reset --allow-no-input --csharp --ruby --python --java --go --nodejs --typescript --azure-validator --preview
# Set the locale to UTF-8
RUN apt-get clean && apt-get update && apt-get install -y locales
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENTRYPOINT ["autorest"]

Просмотреть файл

@ -1,11 +1,11 @@
{
"changes": [
{
"packageName": "@azure-tools/yaml",
"packageName": "@autorest/cadl",
"comment": "",
"type": "none"
}
],
"packageName": "@azure-tools/yaml",
"packageName": "@autorest/cadl",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -1,11 +0,0 @@
{
"changes": [
{
"packageName": "@autorest/codemodel",
"comment": "Types tweak to allow string enums value to accept string literals",
"type": "patch"
}
],
"packageName": "@autorest/codemodel",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@autorest/common",
"comment": "**Fix** Issue with coloring [] wrapped elements",
"type": "patch"
}
],
"packageName": "@autorest/common",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -2,8 +2,8 @@
"changes": [
{
"packageName": "@autorest/common",
"comment": "",
"type": "none"
"comment": "**Removed** identitySourceMapping",
"type": "minor"
}
],
"packageName": "@autorest/common",

Просмотреть файл

@ -2,7 +2,7 @@
"changes": [
{
"packageName": "@autorest/configuration",
"comment": "**Remove** quick-check plugin from defautl configuration",
"comment": "**Consolidate** configuration schema to add description and missing settings",
"type": "minor"
}
],

Просмотреть файл

@ -1,11 +0,0 @@
{
"changes": [
{
"packageName": "@autorest/configuration",
"comment": "",
"type": "none"
}
],
"packageName": "@autorest/configuration",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -2,8 +2,8 @@
"changes": [
{
"packageName": "@autorest/core",
"comment": "",
"type": "none"
"comment": "**Fix** --help crash",
"type": "patch"
}
],
"packageName": "@autorest/core",

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@autorest/core",
"comment": "**Updated** `--help` to use configuration schema and be consistent",
"type": "minor"
}
],
"packageName": "@autorest/core",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -2,7 +2,7 @@
"changes": [
{
"packageName": "@autorest/core",
"comment": "**Remove** quick-check plugin",
"comment": "**Added** Support for sourcemap in autorest extensions",
"type": "minor"
}
],

Просмотреть файл

@ -2,8 +2,8 @@
"changes": [
{
"packageName": "@autorest/core",
"comment": "",
"type": "none"
"comment": "**Internal** Remove use of extension method `.last`",
"type": "patch"
}
],
"packageName": "@autorest/core",

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@autorest/extension-base",
"comment": "**Breaking** updated logging api to provide sourcemap support ",
"type": "minor"
}
],
"packageName": "@autorest/extension-base",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@autorest/modelerfour",
"comment": "Uptake change to extension-base to provide sourcemap support for errors",
"type": "minor"
}
],
"packageName": "@autorest/modelerfour",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@autorest/modelerfour",
"comment": "**Added** Support for overriding shared param description",
"type": "minor"
}
],
"packageName": "@autorest/modelerfour",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@autorest/schemas",
"comment": "**Remove** empty version validation from schema validator",
"type": "patch"
}
],
"packageName": "@autorest/schemas",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@azure-tools/codegen",
"comment": "**Removed** `shadow` and replace with `shadowPosition`",
"type": "minor"
}
],
"packageName": "@azure-tools/codegen",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -2,7 +2,7 @@
"changes": [
{
"packageName": "@azure-tools/datastore",
"comment": "Extract yaml logic in own package `@azure-tools/yaml`",
"comment": "Added support for identity sourcemap type",
"type": "minor"
}
],

Просмотреть файл

@ -1,11 +0,0 @@
{
"changes": [
{
"packageName": "@azure-tools/datastore",
"comment": "**Added** New tree source map builder replacing graph builder",
"type": "minor"
}
],
"packageName": "@azure-tools/datastore",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@azure-tools/datastore",
"comment": "**Fix** Performance issue with not reusing DataHandle causing multiple instance of sourcemaps to be loaded at the same time",
"type": "patch"
}
],
"packageName": "@azure-tools/datastore",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -1,11 +0,0 @@
{
"changes": [
{
"packageName": "@azure-tools/datastore",
"comment": "**Added** Support for yaml `<<` merge keyword in parser\"",
"type": "minor"
}
],
"packageName": "@azure-tools/datastore",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@azure-tools/json",
"comment": "**Fix** stack overflow when walking circular tree",
"type": "patch"
}
],
"packageName": "@azure-tools/json",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -1,11 +0,0 @@
{
"changes": [
{
"packageName": "@azure-tools/oai2-to-oai3",
"comment": "**Updated** to use new tree source map builder",
"type": "minor"
}
],
"packageName": "@azure-tools/oai2-to-oai3",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -1,11 +0,0 @@
{
"changes": [
{
"packageName": "@azure-tools/oai2-to-oai3",
"comment": "Tweaking request body processing and removed some invalid swagger processing with `type: file` with non `formData` parmaeter",
"type": "minor"
}
],
"packageName": "@azure-tools/oai2-to-oai3",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -2,10 +2,10 @@
"changes": [
{
"packageName": "@azure-tools/openapi",
"comment": "Types update",
"comment": "Tweak types for description next to parameter",
"type": "patch"
}
],
"packageName": "@azure-tools/openapi",
"email": "tiguerin@microsoft.com"
}
}

Просмотреть файл

@ -1,11 +0,0 @@
{
"changes": [
{
"packageName": "@azure-tools/openapi",
"comment": "Tweaks types to allow string enums value to accept string literals",
"type": "patch"
}
],
"packageName": "@azure-tools/openapi",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "autorest",
"comment": "**Remove** legacy code",
"type": "minor"
}
],
"packageName": "autorest",
"email": "tiguerin@microsoft.com"
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

15
docker/all/readme.md Normal file
Просмотреть файл

@ -0,0 +1,15 @@
**Note Docker images are in progress.**
# About This Image
Image for [AutoRest](https://github.com/Azure/autorest)
This image contains the base autorest cli with:
- dotnet 5
- python 3
- java 8
# How to Use the Image
See the [documentation](https://github.com/Azure/autorest/blob/main/docs/docker.md)

Просмотреть файл

@ -0,0 +1,41 @@
FROM azuresdk/autorest
# DOTNET
ENV DOTNET_VERSION=5.0
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
curl \
ca-certificates \
\
# .NET dependencies
libc6 \
libgcc1 \
libgssapi-krb5-2 \
libicu66 \
libssl1.1 \
libstdc++6 \
zlib1g \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -Channel ${DOTNET_VERSION} -Runtime dotnet -InstallDir /usr/share/dotnet \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
# PYTHON
ENV PYTHON_VERSION=3.8
RUN apt-get update && apt-get install -y \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-venv \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# JAVA
ENV JAVA_VERSION=8
RUN apt-get update && apt-get install -y \
openjdk-${JAVA_VERSION}-jdk \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT [ "autorest" ]

11
docker/base/readme.md Normal file
Просмотреть файл

@ -0,0 +1,11 @@
**Note Docker images are in progress.**
# About This Image
Image for [AutoRest](https://github.com/Azure/autorest)
This image contains the base autorest cli without any installed plugin.
# How to Use the Image
See the [documentation](https://github.com/Azure/autorest/blob/main/docs/docker.md)

Просмотреть файл

@ -0,0 +1,11 @@
FROM ubuntu:latest
RUN apt update && apt install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt install nodejs -y && rm -rf /var/lib/apt/lists/*
RUN npm install -g autorest
ENTRYPOINT [ "autorest" ]

9
docker/build.sh Normal file
Просмотреть файл

@ -0,0 +1,9 @@
#!/bin/bash
set -x;
docker build -t azuresdk/autorest ./base/ubuntu
docker build -t azuresdk/autorest-dotnet ./dotnet/ubuntu
docker build -t azuresdk/autorest-python ./python/ubuntu
docker build -t azuresdk/autorest-java ./java/ubuntu
docker build -t azuresdk/autorest-all ./all/ubuntu

13
docker/dotnet/readme.md Normal file
Просмотреть файл

@ -0,0 +1,13 @@
**Note Docker images are in progress.**
# About This Image
Image for [AutoRest](https://github.com/Azure/autorest)
This image contains the base autorest cli with:
- dotnet
# How to Use the Image
See the [documentation](https://github.com/Azure/autorest/blob/main/docs/docker.md)

Просмотреть файл

@ -0,0 +1,23 @@
FROM azuresdk/autorest
ENV DOTNET_VERSION=5.0
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
curl \
ca-certificates \
\
# .NET dependencies
libc6 \
libgcc1 \
libgssapi-krb5-2 \
libicu66 \
libssl1.1 \
libstdc++6 \
zlib1g \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -Channel ${DOTNET_VERSION} -Runtime dotnet -InstallDir /usr/share/dotnet \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
ENTRYPOINT [ "autorest" ]

13
docker/java/readme.md Normal file
Просмотреть файл

@ -0,0 +1,13 @@
**Note Docker images are in progress.**
# About This Image
Image for [AutoRest](https://github.com/Azure/autorest)
This image contains the base autorest cli with:
- java 8
# How to Use the Image
See the [documentation](https://github.com/Azure/autorest/blob/main/docs/docker.md)

Просмотреть файл

@ -0,0 +1,9 @@
FROM azuresdk/autorest
ENV JAVA_VERSION=8
RUN apt-get update && apt-get install -y \
openjdk-${JAVA_VERSION}-jdk \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT [ "autorest" ]

13
docker/python/readme.md Normal file
Просмотреть файл

@ -0,0 +1,13 @@
**Note Docker images are in progress.**
# About This Image
Image for [AutoRest](https://github.com/Azure/autorest)
This image contains the base autorest cli with:
- python 3
# How to Use the Image
See the [documentation](https://github.com/Azure/autorest/blob/main/docs/docker.md)

Просмотреть файл

@ -0,0 +1,11 @@
FROM azuresdk/autorest
ENV PYTHON_VERSION=3.8
RUN apt-get update && apt-get install -y \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-venv \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT [ "autorest" ]

Просмотреть файл

@ -10,6 +10,6 @@ This is highly-language specific, so please refer to the documentation we have f
<!--LINKS-->
[python]: https://github.com/Azure/autorest.python/tree/autorestv3/docs/client/readme.md
[java]: https://github.com/Azure/autorest.java/tree/v4/docs/client/readme.md
[java]: https://github.com/Azure/autorest.java/blob/main/docs/client/readme.md
[csharp]: https://github.com/Azure/autorest.csharp/tree/feature/v3/docs/client/readme.md
[typescript]: https://github.com/Azure/autorest.typescript/tree/v6/docs/client/readme.md

Просмотреть файл

@ -72,7 +72,7 @@
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
const azureBlobContainer_coverage = "https://autorestci.blob.core.windows.net/autorest-ci-coverage-report";
const coverageCategories = ["General", "Azure"];
const coverageCategories = ["General", "Azure", "Optional", "LLC"];
function semverCompare(v1, v2) {
const v1parts = v1.split(/[^\d]+/).map(Number);
@ -106,7 +106,12 @@
];
const reportsByRepo /*: { [repo: string]: { version: string, uri: string }[]] }*/ = {};
for (const report of reports) {
const [match, repo, version] = /^autorest\.(.+)_(.+)\.md$/.exec(report);
const didMatch = /^autorest\.(.+)_(.+)\.md$/.exec(report);
if (!didMatch) {
console.error("Unexpected report name", report);
continue;
}
const [match, repo, version] = didMatch;
if (!reportsByRepo[repo]) reportsByRepo[repo] = [];
reportsByRepo[repo].push({ version: version, uri: `${azureBlobContainer_coverage}/${report}` });
}
@ -147,7 +152,7 @@
const response = await request;
const coverage = +/ (\d+)%/.exec(
response.split("\n").filter((l) => l.startsWith("##") && l.includes(cat))[0],
)[1];
)?.[1];
const color = `hsl(${coverage === 100 ? 120 : (Math.pow(coverage / 100, 1.8) * 70) | 0},100%,60%)`;
return $("<div>")
.text(coverage + "%")

Просмотреть файл

@ -2,12 +2,11 @@
This is a table tracking the implementation of new features across Autorest generators and which version there were added.
| Feature | Core Version | Modelerfour version | Python | CSharp | Java | Typescript | Go | Swift |
| ---------------------------------------- | ------------ | ------------------- | ------- | ----------------------------------- | ---- | ---------- | --- | ----- |
| [`AnyObject` vs `Any`][any-feat] | | `4.19.0` | `5.8.0` | `v3.0.0-beta.20210428.3` |
| [Security standarization][security-feat] | | `4.19.0` | | [WIP: PR#1128][security-csharp-wip] |
| Feature | Core Version | Modelerfour version | Python | CSharp | Java | Typescript | Go | Swift |
| ---------------------------------------- | ------------ | ------------------- | ------- | ----------------------- | ---- | ---------- | --- | ----- |
| [`AnyObject` vs `Any`][any-feat] | | `4.19.0` | `5.8.0` | `3.0.0-beta.20210428.3` |
| [Security standarization][security-feat] | | `4.19.0` | | `3.0.0-beta.20210620.8` |
| [Deprecation][deprecation-feat] | | `4.19.0` |
| [Header ignore][header-ignore] | | `4.20.0` |
<!-- Feature links -->

19
docs/docker.md Normal file
Просмотреть файл

@ -0,0 +1,19 @@
# Use AutoRest with docker
AutoRest provide some docker images:
| Image | Description | Image size | Ubuntu |
| -------------------------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------------------ |
| `azuresdk/autorest` | Base image with node installed | ![](https://img.shields.io/docker/image-size/azuresdk/autorest) | :heavy_check_mark: |
| `azuresdk/autorest-python` | Base image + python 3 For building python sdk | ![](https://img.shields.io/docker/image-size/azuresdk/autorest-python) | :heavy_check_mark: |
| `azuresdk/autorest-dotnet` | Base image + dotnet. For building csharp sdk | ![](https://img.shields.io/docker/image-size/azuresdk/autorest-dotnet) | :heavy_check_mark: |
| `azuresdk/autorest-java` | Base image + java. For building java sdk | ![](https://img.shields.io/docker/image-size/azuresdk/autorest-java) | :heavy_check_mark: |
| `azuresdk/autorest-all` | Base image with all the languages for building any of the sdk above | ![](https://img.shields.io/docker/image-size/azuresdk/autorest-all) | :heavy_check_mark: |
## Usage
```bash
# Run the autorest image that fits your need(see next section for different options) and mount the current directory to access the openapi spec there.
docker run -v "${pwd}:/specs" -t <autorest-image> \
--input-file=/specs/openapi.json
```

Просмотреть файл

@ -850,10 +850,13 @@ Note: The extension is not tight to this particular scenario (you could model an
## x-ms-client-default
Set the default value for a property or a parameter.
Set the default value for a property or a parameter on the client.
With this extension, you can set a default value for a property or parameter that is independent of how the property / parameter's schema is handling a default.
With this extension, you can set a default value for a property or parameter that is independent of how the property / parameter's schema is handling a default. This is different than the `default` value
you can specify
**`x-ms-client-default` vs `default`:**
- `default`: This represent the server default. From the point of view of the client this is just documentation, it will be ignored.
- `x-ms-client-default`: This represent the default on the client. It can be used to make a required property optional.
**Parent element**: [Parameter Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject) or [Property on the Schema Definition](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#schemaObject).

Просмотреть файл

@ -1,313 +1,324 @@
# <img align="center" src="../images/logo.png"> Directives
Directives are used to tweak the generated code prior to generation, and are included in your configuration file (usually a README file). For example, if you want to change a property's name from the name defined in the OpenAPI definition, you can add a directive in your readme to accomplish this.
We usually recommend changing the swagger before going the directive route, but if you'd like the original swagger to remain untouched (for example, you want to rename the generated model in the Python SDK, but not in other SDKs), directives are the route for you.
> Stylistic note: we recommend annotating your directives in your config file with a header about what the directive is doing.
## Structure and Terminology
Directives consist of three parts:
- **Location**: denoted by the field `from`, which document are we trying to transform. For swagger transformations, it's always `from: swagger-document`.
- **Filter**: denoted by the field `where`, contains the criteria to select the object.
- An `operation` is filtered by
- its path in the swagger's [`paths`][paths] object AND
- it's HTTP verb
- A `parameter` is filtered by:
- its location in its `operation` (see above) OR
- its name in the swagger's `parameters` object, if it's defined as a common parameter there (see the Common Parameters for Various Paths section [here][parameters] for more information)
- A `model` can be filtered by:
- its name in the [components or definitions][components] section OR
- its location in its outer object, if defined within another object OR
- its location in an operation, if defined within an operation
- A `property` can be filtered by:
- its location within its parent object
- **Transform**: denoted by the field `transform`, the actions we would like to be applied on the specified objects. The list of available variables and functions can be found in [eval.ts](https://github.com/Azure/autorest/blob/main/packages/extensions/core/src/lib/plugins/transformer/eval.ts)
## Built-in Directives
[See built in directives here](./built-in-directives.md)
## Debug a directive
### `debug` flag
Directive provide a `debug` field that will enable verbose logging of the directive run.
Example:
```yaml
directive:
- from: swagger-document
where: $.paths
debug: true
transform: >-
$["x-abc"] = true
```
### `$lib.log` function
Along with some other available function to the transform context(See [eval.ts](https://github.com/Azure/autorest/blob/main/packages/extensions/core/src/lib/plugins/transformer/eval.ts)) `$lib.log` lets you log.
```yaml
directive:
- from: swagger-document
where: $.paths
transform: >-
$lib.log($);
$["x-abc"] = true
```
## Directive Scenarios
The following directives cover the most common tweaking scenarios for generation. Most of those have a `built-in` [directive](./built-in-directives.md) helper and are shown here as examples.
- [Operation Rename](#operation-rename "Operation Rename")
- [Parameter Rename](#parameter-rename "Parameter Rename")
- [Model Rename](#model-rename "Model Rename")
- [Property Rename](#property-rename "Property Rename")
- [Enum Value Rename](#enum-value-rename "Enum Value Rename")
- [Change Description](#change-description "Change Description")
### Operation Rename
A common use case is renaming an operation. Say you have the following operation in your swagger:
```yaml
...
"paths": {
"/vm": {
"get": {
"operationId": "getVirtualMachine",
...
}
}
...
}
```
and you'd like to rename it from `getVirtualMachine` to `getVM`. You would refer to this operation with the combination of its `path` and its http `verb`.
As always, you use `from: swagger-document` to specify you're changing your swagger document. Finally, what you're transforming is the `"operationId"`.
Putting this together, your directive looks like:
```yaml
### Directive renaming operation from "getVirtualMachine" to "getVM"
directive:
from: swagger-document
where: '$.paths["/vm"].get'
transform: >
$["operationId"] = "getVM";
```
### Parameter Rename
To select the parameter, you either refer to its location inside the operation it's defined within, or its name in the [common `parameters` section][parameters].
We'll go over both in this example. In both cases, we'll be looking to rename parameter `id` to `identifier`.
#### Parameter defined in operation
```yaml
...
"paths": {
"/vm": {
"get": {
"operationId": "getVirtualMachine"
"parameters": [
{
"name": "id",
...
}
]
}
}
...
}
```
Referring to the parameter's location in the operation, our filter would be `where: '$.paths["/vm"].get.parameters[0]'`. We're changing the name of the parameter,
so you could apply your transform to the `name` field. However, it's better to change the [`x-ms-client-name`][x_ms_client_name] field instead, since there could be
this field defined for your parameter, and this field overrides the `name` field. This becomes
```yaml
### Directive renaming "getVirtualMachine"'s parameter "id" to "identifier".
directive:
from: swagger-document
where: '$.paths["/vm"].get.parameters[0]'
transform: >
$["x-ms-client-name"] = "identifier";
```
#### Parameter defined in the "Parameters" section
```yaml
---
"parameters": { "Id": { "name": "id", ... } }
```
Now, we refer to the parameters location within the swagger's `parameters` object. This changes our filter to `where: '$.parameters["Id"]'`, and leads us
to the following directive:
```yaml
### Directive renaming "getVirtualMachine"'s parameter "id" to "identifier".
directive:
from: swagger-document
where: '$.parameters["Id"]'
transform: >
$["x-ms-client-name"] = "identifier";
```
### Model Rename
We have the following swagger:
```yaml
...
"definitions": {
"VM": {
"type": "object"
...
}
...
}
```
and we'd like to rename the model `VM` to `VirtualMachine`. We refer to the model with filter `where: #.definitions.VM`. Since the location we're trying to transform
is listed as a key in the swagger dictionary and not a field, we change the model's name by adding in field [`x-ms-client-name`][x_ms_client_name]. Thus, our directive looks like
```yaml
### Directive renaming "VM" model to "VirtualMachine"
directive:
from: swagger-document
where: "$.definitions.VM"
transform: >
$["x-ms-client-name"] = "VirtualMachine";
```
### Property Rename
Let's say we want to rename the following property from `id` to `identifier`.
```yaml
...
"definitions": {
"VM": {
"type": "object"
"properties": {
"id": {
...
}
}
}
...
}
```
We refer to the property based on its location in its parent object, giving us filter `where: #.definitions.VM.properties.id`. Similar to a [model](#model-rename "model"), we have to use
[`x-ms-client-name`][x_ms_client_name] since there's no `name` field to change. This gives us
```yaml
### Directive renaming "id" property to "identifier"
directive:
from: swagger-document
where: "$.definitions.VM.properties.id"
transform: >
$["x-ms-client-name"] = "identifier";
```
### Enum Value Rename
Renaming an enum requires referencing the [`x-ms-enum`][x_ms_enum] used to define the enum. In this scenario, we're looking to change the name of an enum value from `AzureVM` to `AzureVirtualMachine`.
As you can see from the swagger:
```yaml
...
"definitions": {
"VM": {
"type": "object"
"properties": {
"virtualMachineType": {
"type": "string",
"enum": [
"Azure_VM",
...
],
"x-ms-enum": {
"name": "VirtualMachineTypes",
"values": [
{
"value": "Azure_VM"
"name": "AzureVM"
...
},
...
]
}
}
}
}
...
}
```
This gives us directive
```yaml
### Directive renaming enum AzureVM to AzureVirtualMachine
directive:
from: swagger-document
where: "$.definitions.VM.properties.virtualMachineType.x-ms-enum.values[0]"
transform: >
$["x-ms-client-name"] = "AzureVirtualMachine";
```
Now, we would access the enum through `VirtualMachineTypes.AzureVirtualMachine` instead of `VirtualMachineTypes.AzureVM`.
### Change Description
Changing a description is very similar whether you're changing an operation's description or a model's description etc. The only thing that varies is how to refer to the object whose description your changing. Since this is covered in the previous examples, we won't do separate sections for this. Instead, we will show you how to change a property's description, which can be easily extended to another object, i.e. an operation.
Let's say we [renamed the property](#property-rename "Property Rename") from `id` to `identifier`, and we want to change all references in the description of `id` to `identifier`:
```yaml
...
"definitions": {
"VM": {
"type": "object"
"properties": {
"id": {
"description": "The 'id' property is used to identify your VM instance.
}
}
}
...
}
```
We once again refer to the property's location as `where: #.definitions.VM.properties.id`, and we want to change the `description` field in the property. This gives uss
```yaml
### Directive changing references of 'id' to 'identifier' in the 'identifier' property's description
directive:
from: swagger-document
where: "$.definitions.VM.properties.id"
transform: >
$["description"] = $["description].replace("'id'", "'identifier'");
```
For language-specific directives, see the ones for:
- [Python][python]
<!-- LINKS -->
[python]: https://github.com/Azure/autorest.python/blob/autorestv3/docs/generate/directives.md
[paths]: https://swagger.io/docs/specification/paths-and-operations/
[parameters]: https://swagger.io/docs/specification/describing-parameters/
[components]: https://swagger.io/docs/specification/components/
[x_ms_client_name]: https://github.com/Azure/autorest/blob/main/docs/extensions/readme.md#x-ms-client-name
[x_ms_enum]: https://github.com/Azure/autorest/blob/main/docs/extensions/readme.md#x-ms-enum
# <img align="center" src="../images/logo.png"> Directives
Directives are used to tweak the generated code prior to generation, and are included in your configuration file (usually a README file). For example, if you want to change a property's name from the name defined in the OpenAPI definition, you can add a directive in your readme to accomplish this.
We usually recommend changing the swagger before going the directive route, but if you'd like the original swagger to remain untouched (for example, you want to rename the generated model in the Python SDK, but not in other SDKs), directives are the route for you.
> Stylistic note: we recommend annotating your directives in your config file with a header about what the directive is doing.
## Structure and Terminology
Directives consist of three parts:
- **Location**: denoted by the field `from`, which document are we trying to transform. For swagger transformations, it's always `from: swagger-document`.
- **Filter**: denoted by the field `where`, contains the criteria to select the object.
- An `operation` is filtered by
- its path in the swagger's [`paths`][paths] object AND
- it's HTTP verb
- A `parameter` is filtered by:
- its location in its `operation` (see above) OR
- its name in the swagger's `parameters` object, if it's defined as a common parameter there (see the Common Parameters for Various Paths section [here][parameters] for more information)
- A `model` can be filtered by:
- its name in the [components or definitions][components] section OR
- its location in its outer object, if defined within another object OR
- its location in an operation, if defined within an operation
- A `property` can be filtered by:
- its location within its parent object
- **Transform**: denoted by the field `transform`, the actions we would like to be applied on the specified objects. The list of available variables and functions can be found in [eval.ts](https://github.com/Azure/autorest/blob/main/packages/extensions/core/src/lib/plugins/transformer/eval.ts)
## Built-in Directives
[See built in directives here](./built-in-directives.md)
## Debug a directive
### JsonPath.com
To make sure the `where` clause is defined correctly you can use https://jsonpath.com to verify all the elements wanted are selected.
Usage:
1. Paste `where` clause in the `JSONPath Syntax` input
1. Paste spec in the `Inputs` section
1. Evaluation result should be an array of all the object that were matched with the given path.
**NOTE**: The library used in this website is slightly different and there could be inconsistency for some edge cases. You can use the next [section](#debug) to debug the issue and check if autorest is selecting the same elements.
### `debug` flag
Directive provide a `debug` field that will enable verbose logging of the directive run.
Example:
```yaml
directive:
- from: swagger-document
where: $.paths
debug: true
transform: |
$["x-abc"] = true
```
### `$lib.log` function
Along with some other available function to the transform context(See [eval.ts](https://github.com/Azure/autorest/blob/main/packages/extensions/core/src/lib/plugins/transformer/eval.ts)) `$lib.log` lets you log.
```yaml
directive:
- from: swagger-document
where: $.paths
transform: |
$lib.log($);
$["x-abc"] = true
```
## Directive Scenarios
The following directives cover the most common tweaking scenarios for generation. Most of those have a `built-in` [directive](./built-in-directives.md) helper and are shown here as examples.
- [Operation Rename](#operation-rename "Operation Rename")
- [Parameter Rename](#parameter-rename "Parameter Rename")
- [Model Rename](#model-rename "Model Rename")
- [Property Rename](#property-rename "Property Rename")
- [Enum Value Rename](#enum-value-rename "Enum Value Rename")
- [Change Description](#change-description "Change Description")
### Operation Rename
A common use case is renaming an operation. Say you have the following operation in your swagger:
```yaml
...
"paths": {
"/vm": {
"get": {
"operationId": "getVirtualMachine",
...
}
}
...
}
```
and you'd like to rename it from `getVirtualMachine` to `getVM`. You would refer to this operation with the combination of its `path` and its http `verb`.
As always, you use `from: swagger-document` to specify you're changing your swagger document. Finally, what you're transforming is the `"operationId"`.
Putting this together, your directive looks like:
```yaml
### Directive renaming operation from "getVirtualMachine" to "getVM"
directive:
from: swagger-document
where: '$.paths["/vm"].get'
transform: >
$["operationId"] = "getVM";
```
### Parameter Rename
To select the parameter, you either refer to its location inside the operation it's defined within, or its name in the [common `parameters` section][parameters].
We'll go over both in this example. In both cases, we'll be looking to rename parameter `id` to `identifier`.
#### Parameter defined in operation
```yaml
...
"paths": {
"/vm": {
"get": {
"operationId": "getVirtualMachine"
"parameters": [
{
"name": "id",
...
}
]
}
}
...
}
```
Referring to the parameter's location in the operation, our filter would be `where: '$.paths["/vm"].get.parameters[0]'`. We're changing the name of the parameter,
so you could apply your transform to the `name` field. However, it's better to change the [`x-ms-client-name`][x_ms_client_name] field instead, since there could be
this field defined for your parameter, and this field overrides the `name` field. This becomes
```yaml
### Directive renaming "getVirtualMachine"'s parameter "id" to "identifier".
directive:
from: swagger-document
where: '$.paths["/vm"].get.parameters[0]'
transform: >
$["x-ms-client-name"] = "identifier";
```
#### Parameter defined in the "Parameters" section
```yaml
---
"parameters": { "Id": { "name": "id", ... } }
```
Now, we refer to the parameters location within the swagger's `parameters` object. This changes our filter to `where: '$.parameters["Id"]'`, and leads us
to the following directive:
```yaml
### Directive renaming "getVirtualMachine"'s parameter "id" to "identifier".
directive:
from: swagger-document
where: '$.parameters["Id"]'
transform: >
$["x-ms-client-name"] = "identifier";
```
### Model Rename
We have the following swagger:
```yaml
...
"definitions": {
"VM": {
"type": "object"
...
}
...
}
```
and we'd like to rename the model `VM` to `VirtualMachine`. We refer to the model with filter `where: #.definitions.VM`. Since the location we're trying to transform
is listed as a key in the swagger dictionary and not a field, we change the model's name by adding in field [`x-ms-client-name`][x_ms_client_name]. Thus, our directive looks like
```yaml
### Directive renaming "VM" model to "VirtualMachine"
directive:
from: swagger-document
where: "$.definitions.VM"
transform: >
$["x-ms-client-name"] = "VirtualMachine";
```
### Property Rename
Let's say we want to rename the following property from `id` to `identifier`.
```yaml
...
"definitions": {
"VM": {
"type": "object"
"properties": {
"id": {
...
}
}
}
...
}
```
We refer to the property based on its location in its parent object, giving us filter `where: #.definitions.VM.properties.id`. Similar to a [model](#model-rename "model"), we have to use
[`x-ms-client-name`][x_ms_client_name] since there's no `name` field to change. This gives us
```yaml
### Directive renaming "id" property to "identifier"
directive:
from: swagger-document
where: "$.definitions.VM.properties.id"
transform: >
$["x-ms-client-name"] = "identifier";
```
### Enum Value Rename
Renaming an enum requires referencing the [`x-ms-enum`][x_ms_enum] used to define the enum. In this scenario, we're looking to change the name of an enum value from `AzureVM` to `AzureVirtualMachine`.
As you can see from the swagger:
```yaml
...
"definitions": {
"VM": {
"type": "object"
"properties": {
"virtualMachineType": {
"type": "string",
"enum": [
"Azure_VM",
...
],
"x-ms-enum": {
"name": "VirtualMachineTypes",
"values": [
{
"value": "Azure_VM"
"name": "AzureVM"
...
},
...
]
}
}
}
}
...
}
```
This gives us directive
```yaml
### Directive renaming enum AzureVM to AzureVirtualMachine
directive:
from: swagger-document
where: "$.definitions.VM.properties.virtualMachineType.x-ms-enum.values[0]"
transform: >
$["x-ms-client-name"] = "AzureVirtualMachine";
```
Now, we would access the enum through `VirtualMachineTypes.AzureVirtualMachine` instead of `VirtualMachineTypes.AzureVM`.
### Change Description
Changing a description is very similar whether you're changing an operation's description or a model's description etc. The only thing that varies is how to refer to the object whose description your changing. Since this is covered in the previous examples, we won't do separate sections for this. Instead, we will show you how to change a property's description, which can be easily extended to another object, i.e. an operation.
Let's say we [renamed the property](#property-rename "Property Rename") from `id` to `identifier`, and we want to change all references in the description of `id` to `identifier`:
```yaml
...
"definitions": {
"VM": {
"type": "object"
"properties": {
"id": {
"description": "The 'id' property is used to identify your VM instance.
}
}
}
...
}
```
We once again refer to the property's location as `where: #.definitions.VM.properties.id`, and we want to change the `description` field in the property. This gives uss
```yaml
### Directive changing references of 'id' to 'identifier' in the 'identifier' property's description
directive:
from: swagger-document
where: "$.definitions.VM.properties.id"
transform: >
$["description"] = $["description].replace("'id'", "'identifier'");
```
For language-specific directives, see the ones for:
- [Python][python]
<!-- LINKS -->
[python]: https://github.com/Azure/autorest.python/blob/autorestv3/docs/generate/directives.md
[paths]: https://swagger.io/docs/specification/paths-and-operations/
[parameters]: https://swagger.io/docs/specification/describing-parameters/
[components]: https://swagger.io/docs/specification/components/
[x_ms_client_name]: https://github.com/Azure/autorest/blob/main/docs/extensions/readme.md#x-ms-client-name
[x_ms_enum]: https://github.com/Azure/autorest/blob/main/docs/extensions/readme.md#x-ms-enum

Просмотреть файл

@ -75,9 +75,8 @@ Those are flags that affect autorest only
Those flags are temporary and will be removed in the future. Those flags are here to have a smoother rollout of certain feature.
| Flag | Description |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `--mark-oai3-errors-as-warnings` | Mark OpenAPI3 validation(schema) error as warnings. (When removed OpenAPI3 validation errors will always fail the pipeline) |
| Flag | Description |
| ---- | ----------- |
## Python Flags
@ -131,9 +130,9 @@ Those flags are temporary and will be removed in the future. Those flags are her
| `--customization-jar-path=FILEPATH` | Pass in the path to your .jar file that contains customizations to the output files. This will allow AutoRest to dynamically load the class you provide in `--customization-class`. |
| `--customization-class=NAME` | Use in conjunction with `--customization-jar-path`. That flag tells AutoRest where to look for your custom class, while `--customization-class` tells AutoRest the name of your custom class. |
## TS Flags
## TypeScript Flags
| Flag | Description |
| Flag | Description | | | | |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | --- | --- |
| `--source-code-folder-path=DIRECTORY` | Where to output the generated code inside the `output-folder`. Use in the scenario when you are going to write a convenience layer on top of the generated code. Defaults to `src`. | | | | x |
| `--generate-metadata` | Whether to generate extra metadata in your package. For instance, generates a README file, license file etc if set to `true`. Defaults to `false`. |
@ -142,12 +141,11 @@ Those flags are temporary and will be removed in the future. Those flags are her
## Go flags
| Flag | Description |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--module=NAME` | The name of the module. This is the name your module will be published under. |
| `--file-prefix=PREFIX` | Optional prefix to file names. For example, if you set your file prefix to "zzz", all generated code files will begin with "zzz". |
| `--openapi-type=arm\|data-plane` | Specify if you want to generate `data-plane` code or `arm` code. |
| `--armcore-connection` | If set to `true`, we output the code with the `Connection` type specified in [`armcore`][armcore_connection]. If not, we output a new `Connection` constructor with the generated code. Defaults to `false`. |
| Flag | Description |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `--module=NAME` | The name of the module. This is the name your module will be published under. |
| `--file-prefix=PREFIX` | Optional prefix to file names. For example, if you set your file prefix to "zzz", all generated code files will begin with "zzz". |
| `--openapi-type=arm\|data-plane` | Specify if you want to generate `data-plane` code or `arm` code. |
## Swift flags
@ -157,7 +155,7 @@ Those flags are temporary and will be removed in the future. Those flags are her
## Debugging flags
| Flag | Description | Python | .NET | Java | TS | Go |
| Flag | Description | Python | .NET | Java | TS | Go | |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ---- | ---- | --- | --- | --- |
| `--verbose` | Log verbose-level information during generation time | x | x | x | x | x |
| `--debug` | Log debug-level information during generation time | x | x | x | x | x |
@ -189,7 +187,7 @@ Those flags are temporary and will be removed in the future. Those flags are her
[java_context]: https://azuresdkdocs.blob.core.windows.net/$web/java/azure-core/1.0.0/index.html?com/azure/core/util/Context.html
[artifact_id]: https://maven.apache.org/guides/mini/guide-naming-conventions.html
[fluent_docs]: https://github.com/Azure/autorest.java#additional-settings-for-fluent
[armcore_connection]: https://github.com/Azure/azure-sdk-for-go/blob/master/sdk/armcore/connection.go
[armcore_connection]: https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/azcore/arm/connection.go
[debugging]: https://github.com/Azure/autorest/blob/main/docs/troubleshooting.md#debugging
[black]: https://pypi.org/project/black/
[ts_async_iterator]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html#async-iterators

Просмотреть файл

@ -44,7 +44,7 @@ For a full-set of flags, go to our [flag index][flags]
The first step in an AutoRest journey usually starts with generating a single OpenAPI file. We will also show
how to set options during generation by building up our command-line step-by-step.
The first step here is to have your OpenAPI file definition of your client ([docs][openapi_introduction]) on how to do that).
The first step here is to have your OpenAPI file definition of your client ([docs][openapi_introduction] on how to do that).
This example will use an example OpenAPI definition found [here][pets_swagger], so feel free to follow along with
our sample code. To get things started, the command that starts AutoRest on the command line is `autorest`, so this is what our command line
looks like to start with:
@ -159,7 +159,7 @@ Let's start by examining what behavior we want to have when generating. The sugg
Let's say we want to generate our first [pets.json][pets_swagger] if you specify `--tag=v1`, and we want to generate our second [petsv2.json][pets_v2_swagger]
if `--tag=v2` is specified on the command line. Let's go about putting in the markdown code to make this possible.
Starting with the flags we wantin both cases, we add in a `yaml` code block with no condition for entry.
Starting with the flags we want in both cases, we add in a `yaml` code block with no condition for entry.
````
### General settings
@ -411,7 +411,7 @@ For language-specific information about generation, please refer to our language
[mgmt_storage]: https://github.com/Azure/azure-rest-api-specs/tree/master/specification/storage/resource-manager
[how_autorest]: ./how-autorest-generates-code-from-openapi.md
[python]: https://github.com/Azure/autorest.python/tree/autorestv3/docs/generate/readme.md
[java]: https://github.com/Azure/autorest.java/tree/v4/docs/generate/readme.md
[java]: https://github.com/Azure/autorest.java/blob/main/docs/generate/readme.md
[csharp]: https://github.com/Azure/autorest.csharp/tree/feature/v3/readme.md
[azure_sdk_for_python]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk
[azure_sdk_for_java]: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk

Просмотреть файл

@ -1,7 +1,7 @@
# <img align="center" src="./images/logo.png"> Introduction to AutoRest
The **AutoRest** tool generates client libraries for accessing RESTful web services. Input to *AutoRest* is a spec that describes the REST API using the [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification) format.
Here we go into some of the general terms you'll see when gonig through our documentation and interacting with AutoRests.
Here we go into some of the general terms you'll see when going through our documentation and interacting with AutoRests.
## What is OpenAPI?
@ -27,4 +27,4 @@ See our [landing page][landing_page] to get started with writing your OpenAPI de
[swagger_docs]: https://swagger.io/docs/
[openapi_docs]: ./openapi/readme.md
[landing_page]: readme.md
[extensions]: extensions/readme.md
[extensions]: extensions/readme.md

Просмотреть файл

@ -2,8 +2,7 @@
## General Guidance
First, make sure when generating you are using AutoRest V3. Follow the steps in [our installation section][install] for information on upgrading
and confirming your new AutoRest version.
First, make sure when generating you are using AutoRest V3. Follow the steps in [our installation section][install] for information on upgrading and confirming your new AutoRest version.
## New Features
@ -11,15 +10,19 @@ and confirming your new AutoRest version.
AutoRest 3.0 finally supports OpenAPI3 files as an input format, with the following caveats:
- existing AutoRest v2 generators may not support all features from OpenAPI3. (see next section)
- `anyOf`, `oneOf` are not currently supported
- other OpenAPI3 specific features may not be entirely supported.
### Generators
### Generators - **Breaking**
A new set of language generator plugins are being written that adopt the lighter-weight patterns for Azure Core libraries.<br>
Existing V2 generators will default to processing with the AutoRest 2 pipeline. <br>
See the language generator flags [here][language_flags]
**The older generators are only compatible with Autorest V2.**
| Generator | Packages names | Autorest Core |
| ----------- | -------------------------------------- | ------------- |
| V2 (Track1) | `@microsoft.azure/autorest.<language>` | `2.x` |
| V3 (Track2) | `@autorest/<language>` | `3.x` |
### Generate More Idiomatic SDKs
@ -38,6 +41,6 @@ For language-specific information about migration and changes, please refer to o
[language_flags]: https://github.com/Azure/autorest/blob/main/docs/generate/readme.md#language-flags
[guidelines]: https://azure.github.io/azure-sdk/general_introduction.html
[python]: https://github.com/Azure/autorest.python/tree/autorestv3/docs/migrate/readme.md
[java]: https://github.com/Azure/autorest.java/tree/v4/docs/migrate/readme.md
[java]: https://github.com/Azure/autorest.java/blob/main/docs/migrate/readme.md
[csharp]: https://github.com/Azure/autorest.csharp/tree/feature/v3/docs/migrate/readme.md
[typescript]: https://github.com/Azure/autorest.typescript/tree/v6/docs/migrate/readme.md

Просмотреть файл

@ -32,9 +32,11 @@
- [How][powershell] do I use AutoRest to build `Powershell` cmdlets?
9. [Troubleshooting][troubleshooting]
9. Use `autorest` via [docker][docker]
10. [FAQ][faq]
10. [Troubleshooting][troubleshooting]
11. [FAQ][faq]
<!-- LINKS -->
@ -46,5 +48,6 @@
[migrate]: https://github.com/Azure/autorest/blob/main/docs/migrate/readme.md
[dev]: https://github.com/Azure/autorest/blob/main/docs/developer/readme.md
[powershell]: https://github.com/Azure/autorest.powershell/blob/master/docs/readme.md
[docker]: https://github.com/Azure/autorest/blob/main/docs/docker.md
[troubleshooting]: https://github.com/Azure/autorest/blob/main/docs/troubleshooting.md
[faq]: https://github.com/Azure/autorest/blob/main/docs/faq.md

Двоичные данные
docs/releases/images/logger-after.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 28 KiB

Двоичные данные
docs/releases/images/logger-before.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 26 KiB

Просмотреть файл

@ -0,0 +1,47 @@
# July 2021 Release - Autorest Core 3.5.0, Modelerfour 4.20.0
Changelogs for full details:
- [Autorest Core](https://github.com/Azure/autorest/blob/main/packages/extensions/core/CHANGELOG.md)
- [Modelerfour](https://github.com/Azure/autorest/blob/main/packages/extensions/modelerfour/CHANGELOG.md)
## Directive debugging
A new property `debug` has been added on directive which will enable additional logging when the directive is running.
Usage:
```yaml
directive:
from: openapi-document
where: $.definitions.Foo
debug: true
transform: |
$.readOnly = true;
```
Autorest will now log which documents, paths, inital values of each instance before executing the transform and resulting value after.
## End of line configuration
New configuration `eol` which lets you configure the end of line regardless of the system autorest is being run on.
Usage:
```yaml
eol: lf # Force unix line ending
eol: crlf # Force windows line ending
eol: default # Keep system default
```
## Performance improvements
Autorest core 3.5.0 introduce some improvements on the memory management reducing its overall usage. This is mostly notable for very large specs.
A new flag was added(`--memory`) which can be used to configure the max memory autorest is allowed to used.
Usage:
```yaml
memory: 8g # Allow up to 8GB of memory
```

3
docs/releases/readme.md Normal file
Просмотреть файл

@ -0,0 +1,3 @@
# Autorest release notes
1. [September 2021 - Autorest Core 3.6.0, Modelerfour 4.21.0](./september-2021.md)

Просмотреть файл

@ -0,0 +1,37 @@
# September 2021 Release - Autorest Core 3.6.0, Modelerfour 4.21.0
Changelogs for full details:
- [Autorest Core](https://github.com/Azure/autorest/blob/main/packages/extensions/core/CHANGELOG.md)
- [Modelerfour](https://github.com/Azure/autorest/blob/main/packages/extensions/modelerfour/CHANGELOG.md)
## Performance improvments
The latest version of autorest core and modelerfour have seen a large focus on performance.
With this latest release we now have quite a significant result for large OpenAPI specifications.
Here is a small benchmark of the progress made over the recent version and what this release brings(Number in seconds).
| Service | Core: 3.3.2 M4: 4.18.4 | Core: 3.4.5 M4: 4.19.3 | Core: 3.5.1 M4: 4.20.0 | Core: 3.5.1 M4: 4.20.0 (with --skip-sourcemap) | Core: 3.6.x M4: 4.21.x |
| ------- | ---------------------- | ---------------------- | ---------------------- | ---------------------------------------------- | ---------------------- |
| Web | 58 | 51.5 | 89.93 | 46 | 26 |
| Network | 76 | 66 | 113.3 | 60 | 35 |
| SQL | 108 | 61 | 86 | 54 | 33 |
| MsGraph | Out of memory | Out of memory | - | 5025 | 600 |
Overall we can see large Azure specs recieve a 2-3x speed increase while Ms Graph which is the largest spec by far(500k lines) achieve nearly 10x speed up.
## Sourcemaps and tracing error original sources
One major bottleneck in the performance was logic related to the sourcemap creation. Sourcemap used to be disabled in previous autorest core version due to its inefficency and was reintroduced in `3.3.0` but only now really addressed the performance issue that came with it. Without sourcemaps when an error occured in autorest the stacktrace woudl present you with an intermediate in-memory file position which didn't was meaningless or confusing.
With this complete redesign of how sourcemaps works in the autorest pipeline there is now a fast sourcemap creation and consumption which lets errors be traced back to the original location in the swagger specs or autorest configuration.
## Logging redesign
This is mostly an internal change to how autorest present the user with information.
It will log information in a cleaner and more consistent maner.
| Before | After |
| ------------------------------- | ------------------------------ |
| ![](./images/logger-before.png) | ![](./images/logger-after.png) |

Просмотреть файл

@ -46,6 +46,6 @@ If you would like to actually debug through a language generator's code, see our
[csharp_generation]: https://github.com/Azure/autorest.csharp/tree/feature/v3/docs/troubleshooting.md#generation-errors
[typescript_generation]: https://github.com/Azure/autorest.typescript/tree/v6/docs/troubleshooting.md#generation-errors
[python_debug]: https://github.com/Azure/autorest.python/tree/autorestv3/docs/troubleshooting.md#debugging
[java_debug]: https://github.com/Azure/autorest.java/blob/v4/docs/client/troubleshooting.md#debugging
[java_debug]: https://github.com/Azure/autorest.java/blob/main/docs/client/troubleshooting.md#debugging
[csharp_debug]: https://github.com/Azure/autorest.csharp/tree/feature/v3/docs/troubleshooting.md#debugging
[typescript_debug]: https://github.com/Azure/autorest.typescript/tree/v6/docs/troubleshooting.md#debugging

Просмотреть файл

@ -5,31 +5,68 @@
trigger:
- main
- release/*
pool:
vmImage: "ubuntu-latest"
jobs:
- job: stable
displayName: Publish stable
steps:
- template: ./templates/build.yaml
- script: npx @microsoft/rush publish --publish --pack --include-all
displayName: Pack packages
stages:
- stage: npm
jobs:
- job: stable
displayName: Publish stable
steps:
- template: ./templates/build.yaml
- script: |
NPM_AUTH_TOKEN="$(azure-sdk-npm-token)" npx @microsoft/rush publish --publish --include-all --set-access-level public
displayName: Publish packages
- script: npx @microsoft/rush publish --publish --pack --include-all
displayName: Pack packages
- job: prerelease
displayName: Publish prerelease
dependsOn: stable # Publish prerelease after to prevent race condition.
steps:
- template: ./templates/build.yaml
- script: |
NPM_AUTH_TOKEN="$(azure-sdk-npm-token)" npx @microsoft/rush publish --publish --include-all --set-access-level public
displayName: Publish packages
- script: node ./eng/bump-for-prerelease.js
displayName: Bump version to prerelease targets
- job: prerelease
displayName: Publish prerelease
dependsOn: stable # Publish prerelease after to prevent race condition.
steps:
- template: ./templates/build.yaml
- script: |
NPM_AUTH_TOKEN="$(azure-sdk-npm-token)" npx @microsoft/rush publish --publish --include-all --set-access-level public --tag next
displayName: Publish packages
- script: node ./eng/bump-for-prerelease.js
displayName: Bump version to prerelease targets
- script: |
NPM_AUTH_TOKEN="$(azure-sdk-npm-token)" npx @microsoft/rush publish --publish --include-all --set-access-level public --tag next
displayName: Publish packages
- stage: Docker
dependsOn: npm
jobs:
- template: ./templates/build-and-push-docker.yaml
parameters:
name: base
image: azuresdk/autorest
dockerFolder: ./docker/base/ubuntu
readmePath: docker/base/readme.md
- template: ./templates/build-and-push-docker.yaml
parameters:
name: dotnet
image: azuresdk/autorest-dotnet
dockerFolder: ./docker/dotnet/ubuntu
readmePath: docker/dotnet/readme.md
- template: ./templates/build-and-push-docker.yaml
parameters:
name: python
image: azuresdk/autorest-python
dockerFolder: ./docker/python/ubuntu
readmePath: docker/python/readme.md
- template: ./templates/build-and-push-docker.yaml
parameters:
name: java
image: azuresdk/autorest-java
dockerFolder: ./docker/java/ubuntu
readmePath: docker/java/readme.md
- template: ./templates/build-and-push-docker.yaml
parameters:
name: all
image: azuresdk/autorest-all
dockerFolder: ./docker/all/ubuntu
readmePath: docker/all/readme.md

Просмотреть файл

@ -0,0 +1,41 @@
# Template building a docker image and publishing it
parameters:
- name: name
type: string
- name: image
type: string
- name: dockerFolder
type: string
- name: readmePath
type: string
jobs:
- job: ${{ parameters.name }}
displayName: Publish to docker ${{ parameters.dockerFolder }}
steps:
- task: DockerInstaller@0
inputs:
dockerVersion: "17.09.0-ce"
- script: |
echo "$(DockerHub-azuresdkPass)" | docker login -u "azuresdk" --password-stdin
displayName: Login to docker hub.
- script: |
docker build -t ${{ parameters.image }} .
displayName: Build image
workingDirectory: ${{ parameters.dockerFolder }}
- script: |
docker push ${{ parameters.image }}
displayName: Publish image
- script: |
echo '/workspace/${{parameters.readmePath}}'
docker run -v $PWD:/workspace \
-e DOCKERHUB_USERNAME="azuresdk" \
-e DOCKERHUB_PASSWORD="$(DockerHub-azuresdkPass)" \
-e DOCKERHUB_REPOSITORY='${{ parameters.image }}' \
-e README_FILEPATH='/workspace/${{parameters.readmePath}}' \
peterevans/dockerhub-description:2.1.0
displayName: Update readme

Просмотреть файл

@ -1,15 +1,15 @@
# Template for building projects
steps:
- task: NodeTool@0
inputs:
versionSpec: "14.x"
displayName: "Install Node.js"
- script: |
npm install -g npm@6 # Seems to be an with npm 7 and publishing https://github.com/npm/cli/issues/2624.
npx @microsoft/rush install
displayName: "Install dependencies"
- script: |
npx @microsoft/rush rebuild
displayName: "Build"
# Template for building projects
steps:
- task: NodeTool@0
inputs:
versionSpec: "14.x"
displayName: "Install Node.js"
- script: |
npm install -g npm@6 # Seems to be an with npm 7 and publishing https://github.com/npm/cli/issues/2624.
npx @microsoft/rush install
displayName: "Install dependencies"
- script: |
npx @microsoft/rush rebuild
displayName: "Build"

Просмотреть файл

@ -46,7 +46,12 @@ jobs:
npm link --force
displayName: Install autorest-compare
- script: npm install
- script: |
npm install
echo "Autorest TestServer Version"
npm ls "@microsoft.azure/autorest.testserver"
displayName: Install dependencies
workingDirectory: regression-tests

Просмотреть файл

@ -1,6 +1,58 @@
{
"name": "autorest",
"entries": [
{
"version": "3.4.2",
"tag": "autorest_v3.4.2",
"date": "Tue, 15 Oct 2021 17:00:00 GMT",
"comments": {
"patch": [
{
"comment": "**fix** issue with extension method causing conflict when loading autorest core v2"
}
]
}
},
{
"version": "3.4.1",
"tag": "autorest_v3.4.1",
"date": "Tue, 05 Oct 2021 17:04:21 GMT",
"comments": {
"patch": [
{
"comment": "**fix** Respect `message-format` option"
}
]
}
},
{
"version": "3.4.0",
"tag": "autorest_v3.4.0",
"date": "Wed, 08 Sep 2021 15:39:22 GMT",
"comments": {
"minor": [
{
"comment": "*Uptake** New logger"
}
],
"patch": [
{
"comment": "**Fix** If an error occures in the config loading, ignore and try to load a version of @autorest/core"
}
],
"dependency": [
{
"comment": "Updating dependency \"@autorest/configuration\" from `~1.6.0` to `~1.7.0`"
},
{
"comment": "Updating dependency \"@autorest/core\" from `~3.5.0` to `~3.6.0`"
},
{
"comment": "Updating dependency \"@autorest/common\" from `~1.2.0` to `~1.3.0`"
}
]
}
},
{
"version": "3.3.2",
"tag": "autorest_v3.3.2",

Просмотреть файл

@ -1,6 +1,31 @@
# Change Log - autorest
This log was last generated on Tue, 20 Jul 2021 16:57:32 GMT and should not be manually modified.
This log was last generated on Fri, 15 Oct 2021 16:48:57 GMT and should not be manually modified.
## 3.4.2
Tue, 15 Oct 2021 17:00:00 GMT
### Patches
- **fix** issue with extension method causing conflict when loading autorest core v2
## 3.4.1
Tue, 05 Oct 2021 17:04:21 GMT
### Patches
- **fix** Respect `message-format` option
## 3.4.0
Wed, 08 Sep 2021 15:39:22 GMT
### Minor changes
- *Uptake** New logger
### Patches
- **Fix** If an error occures in the config loading, ignore and try to load a version of @autorest/core
## 3.3.2
Tue, 20 Jul 2021 16:57:32 GMT

Просмотреть файл

@ -1,47 +1,3 @@
#!/usr/bin/env node
/* eslint-disable no-console */
global.isDebuggerEnabled =
!!require("inspector").url() || global.v8debug || /--debug|--inspect/.test(process.execArgv.join(" "));
const maxMemorySizeArg = process.argv.join(" ").match(/--max-memory-size=(\w+)/);
const maxMemorySize = maxMemorySizeArg && parseInt(maxMemorySizeArg[1]);
if (isNaN(maxMemorySize)) {
console.error(`\nWarning: --max-memory-size parameter '${maxMemorySizeArg[1]}' is not an integer, ignoring it.\n`);
}
// if the process was started with a low heap size (and we're not debugging!) then respawn with a bigger heap size.
if (
maxMemorySize &&
!isDebuggerEnabled &&
require("v8").getHeapStatistics().heap_size_limit < maxMemorySize * 1024000
) {
process.env["NODE_OPTIONS"] = `${
process.env["NODE_OPTIONS"] || ""
} --max-old-space-size=${maxMemorySize} --no-warnings`;
const argv =
process.argv.indexOf("--break") === -1
? process.argv.slice(1)
: ["--inspect-brk", ...process.argv.slice(1).filter((each) => each !== "--break")];
require("child_process")
.spawn(process.execPath, argv, { argv0: "node", stdio: "inherit" })
.on("close", (code) => {
process.exit(code);
});
} else {
try {
const v = process.versions.node.split(".");
if (v[0] < 12) {
console.error("\nFATAL: Node v12 or higher (v12.x minimum, v14.x LTS recommended) is required for AutoRest.\n");
process.exit(1);
}
if (v[0] > 14) {
console.error("\nWARNING: AutoRest has not been tested with Node versions greater than v14.\n");
}
require(`${__dirname}/../dist/app.js`);
} catch (e) {
console.error(e);
}
}
// Need to have this intermediate file due to rush issue with generated bin https://github.com/microsoft/rushstack/issues/2400
require("../dist/app.js");

Просмотреть файл

@ -0,0 +1,11 @@
// @ts-check
const defaultConfig = require("./jest.config");
const config = {
...defaultConfig,
setupFilesAfterEnv: ["<rootDir>/test/setup-jest-e2e.ts"],
testMatch: ["<rootDir>/test/**/*.e2e.ts"],
};
module.exports = config;

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "autorest",
"version": "3.3.2",
"version": "3.4.2",
"description": "The AutoRest tool generates client libraries for accessing RESTful web services. Input to AutoRest is an OpenAPI spec that describes the REST API.",
"engines": {
"node": ">=12.0.0"
@ -27,8 +27,11 @@
},
"scripts": {
"start": "node ./dist/src/app.js",
"test": "jest --watch --coverage=false",
"test:ci": "jest --ci",
"test": "jest --coverage=false --watch",
"test:unit:ci": "jest --ci",
"test:e2e": "jest --forceExit --runInBand --config ./jest.e2e.config.js",
"test:e2e:ci": "jest --ci --forceExit --runInBand --config ./jest.e2e.config.js",
"test:ci": "npm run test:unit:ci && npm run test:e2e:ci",
"build": "tsc -p tsconfig.build.json",
"build:prod": "webpack",
"watch": "tsc -p tsconfig.build.json --watch",
@ -40,8 +43,9 @@
},
"typings": "./dist/exports.d.ts",
"devDependencies": {
"@autorest/configuration": "~1.6.0",
"@autorest/core": "~3.5.0",
"@autorest/configuration": "~1.7.3",
"@autorest/core": "~3.6.6",
"@autorest/common": "~1.3.0",
"@azure-tools/async-io": "~3.0.0",
"@azure-tools/extension": "~3.3.1",
"@azure-tools/tasks": "~3.0.0",
@ -60,6 +64,7 @@
"eslint-plugin-node": "~11.1.0",
"eslint-plugin-prettier": "~3.4.0",
"eslint-plugin-unicorn": "~33.0.1",
"eslint-plugin-import": "~2.24.2",
"eslint": "^7.17.0",
"jest": "^27.0.4",
"jsonpath": "1.0.0",
@ -71,7 +76,7 @@
"source-map-support": "^0.5.19",
"ts-jest": "^27.0.3",
"ts-loader": "~9.2.3",
"typescript": "~4.3.4",
"typescript": "~4.4.2",
"untildify": "^4.0.0",
"webpack-cli": "~4.7.2",
"webpack": "~5.40.0"

Просмотреть файл

@ -1,8 +1,8 @@
import { color } from "@autorest/common";
import { Package } from "@azure-tools/extension";
import { gt } from "semver";
import { AutorestArgs } from "../args";
import { extensionManager, networkEnabled } from "../autorest-as-a-service";
import { color } from "../coloring";
import { VERSION } from "../constants";
/**

Просмотреть файл

@ -1,7 +1,7 @@
import { isDirectory, readdir, rmdir } from "@azure-tools/async-io";
import chalk from "chalk";
import { tmpdir } from "os";
import { join } from "path";
import { isDirectory, readdir, rmdir } from "@azure-tools/async-io";
import chalk from "chalk";
/**
* Clears out all autorest-temp folders from the temp folder.

Просмотреть файл

@ -6,18 +6,20 @@
/* eslint-disable no-console */
import "source-map-support/register";
declare const isDebuggerEnabled: boolean;
const cwd = process.cwd();
import { AutorestSyncLogger, ConsoleLoggerSink } from "@autorest/common";
import chalk from "chalk";
import { newCorePackage, ensureAutorestHome, runCoreWithRequire, runCoreOutOfProc } from "./autorest-as-a-service";
import { color } from "./coloring";
import { parseAutorestArgs } from "./args";
import { resetAutorest, showAvailableCoreVersions, showInstalledExtensions } from "./commands";
import { clearTempData } from "./actions";
import { loadConfig, resolveCoreVersion } from "./utils";
import { parseAutorestArgs } from "./args";
import { newCorePackage, ensureAutorestHome, runCoreWithRequire, runCoreOutOfProc } from "./autorest-as-a-service";
import { resetAutorest, showAvailableCoreVersions, showInstalledExtensions } from "./commands";
import { VERSION } from "./constants";
import { loadConfig, resolveCoreVersion } from "./utils";
const isDebuggerEnabled =
// eslint-disable-next-line node/no-unsupported-features/node-builtins
!!require("inspector").url() || global.v8debug || /--debug|--inspect/.test(process.execArgv.join(" "));
const launchCore = isDebuggerEnabled ? runCoreWithRequire : runCoreOutOfProc;
// aliases, round one.
@ -58,7 +60,7 @@ function logBanner() {
)}]`,
),
);
console.log(color("(C) 2018 **Microsoft Corporation.**"));
console.log(`(C) 2018 ${chalk.bold("Microsoft Corporation.")}`);
console.log(chalk.blue.bold.underline("https://aka.ms/autorest"));
}
}
@ -97,7 +99,15 @@ async function main() {
} catch {
// We have a chance to fail again later if this proves problematic.
}
const config = await loadConfig(args);
const sink = new ConsoleLoggerSink({ format: args["message-format"] });
const logger = new AutorestSyncLogger({
sinks: [sink],
});
const config = await loadConfig(sink, args);
if (config?.version) {
logger.info(`AutoRest core version selected from configuration: ${chalk.yellow.bold(config.version)}.`);
}
const coreVersionPath = await resolveCoreVersion(config);
// let's strip the extra stuff from the command line before we require the core module.
@ -133,7 +143,7 @@ async function main() {
process.argv = newArgs;
if (args.debug) {
console.log(`Starting ${newCorePackage} from ${coreVersionPath}`);
logger.debug(`Starting ${newCorePackage} from ${coreVersionPath}`);
}
// reset the working folder to the correct place.

Просмотреть файл

@ -16,7 +16,11 @@ export interface AutorestArgs {
force?: boolean;
verbose?: boolean;
"message-format"?: "regular" | "json" | "yaml";
/**
* To enable logs of the config loading in the cli.
*/
"debug-cli-config-loading"?: boolean;
"message-format"?: "regular" | "json";
"list-available"?: boolean;
"clear-temp"?: boolean;
"list-installed"?: boolean;

Просмотреть файл

@ -1,25 +1,25 @@
/* eslint-disable no-process-exit */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { spawn } from "child_process";
import { lookup } from "dns";
import { Extension, ExtensionManager, Package } from "@azure-tools/extension";
import { homedir } from "os";
import { join } from "path";
import { mkdtempSync, rmdirSync } from "fs";
import { homedir, tmpdir } from "os";
import { Exception } from "@azure-tools/tasks";
import { join } from "path";
import { AutorestConfiguration } from "@autorest/configuration";
import { isFile, mkdir, isDirectory } from "@azure-tools/async-io";
import { Extension, ExtensionManager, Package } from "@azure-tools/extension";
import { Exception, When } from "@azure-tools/tasks";
import * as semver from "semver";
import { isFile, mkdir, isDirectory } from "@azure-tools/async-io";
import { When } from "@azure-tools/tasks";
import { mkdtempSync, rmdirSync } from "fs";
import { tmpdir } from "os";
import { spawn } from "child_process";
import { AutorestArgs } from "./args";
import { VERSION } from "./constants";
import { AutorestConfiguration } from "@autorest/configuration";
import { parseMemory } from "./utils";
const inWebpack = typeof __webpack_require__ === "function";
const nodeRequire = inWebpack ? __non_webpack_require__ : require;
const nodeRequire = inWebpack ? __non_webpack_require__! : require;
process.env["autorest.home"] = process.env["AUTOREST_HOME"] || process.env["autorest.home"] || homedir();
@ -39,7 +39,7 @@ export const extensionManager: Promise<ExtensionManager> = ExtensionManager.Crea
export const oldCorePackage = "@microsoft.azure/autorest-core";
export const newCorePackage = "@autorest/core";
const basePkgVersion = semver.parse(VERSION.indexOf("-") > -1 ? VERSION.substring(0, VERSION.indexOf("-")) : VERSION);
const basePkgVersion = semver.parse(VERSION.indexOf("-") > -1 ? VERSION.substring(0, VERSION.indexOf("-")) : VERSION)!;
/**
* The version range of the core package required.
@ -87,7 +87,7 @@ export async function installedCores() {
return result.sort((a, b) => semver.compare(b.version, a.version));
}
export async function resolveEntrypoint(localPath: string | null, entrypoint: string): Promise<string | null> {
export async function resolveEntrypoint(localPath: string, entrypoint: string): Promise<string | undefined> {
try {
// did they specify the package directory directly
if (await isDirectory(localPath)) {
@ -148,11 +148,11 @@ export async function resolveEntrypoint(localPath: string | null, entrypoint: st
} catch {
// no worries
}
return null;
return undefined;
}
export async function runCoreOutOfProc(
localPath: string | null,
localPath: string,
entrypoint: string,
config?: AutorestConfiguration,
): Promise<any> {
@ -174,6 +174,7 @@ export async function runCoreOutOfProc(
// Creates the nodejs command to load the target core
// - copies the argv parameters
// - loads the js file with coloring (core expects a global function called 'color' )
// This is needed currently for @autorest/core version older than 3.6.0(After autorest-core include the color itself.)
// - loads the actual entrypoint that we expect is there.
const cmd = `
process.argv = ${JSON.stringify(process.argv)};
@ -186,10 +187,11 @@ export async function runCoreOutOfProc(
const p = spawn(process.execPath, ["-e", cmd], { stdio: ["inherit", "inherit", "inherit"], env });
p.on("close", (code, signal) => {
process.exit(code);
process.exit(code ?? -1);
});
// set up a promise to wait for the event to fire
await When(p, "exit", "close");
process.exit(0);
}
} catch (E) {
@ -199,7 +201,7 @@ export async function runCoreOutOfProc(
}
export async function runCoreWithRequire(
localPath: string | null,
localPath: string,
entrypoint: string,
config?: AutorestConfiguration,
): Promise<any> {
@ -230,7 +232,7 @@ export async function selectVersion(
minimumVersion?: string,
): Promise<Extension> {
const installedVersions = await installedCores();
let currentVersion = installedVersions[0] || null;
let currentVersion: Extension | null = installedVersions[0] || null;
// the consumer can say I want the latest-installed, but at least XXX.XXX
if (minimumVersion && currentVersion && !semver.satisfies(currentVersion.version, minimumVersion)) {
@ -254,7 +256,7 @@ export async function selectVersion(
}
}
let selectedVersion: Extension = null;
let selectedVersion: Extension | null = null;
// take the highest version that satisfies the version range.
for (const each of installedVersions.sort((a, b) => semver.compare(a?.version, b?.version))) {
if (semver.satisfies(each.version, requestedVersion)) {
@ -289,7 +291,7 @@ export async function selectVersion(
}
let corePackageName = newCorePackage;
let pkg: Package;
let pkg: Package | undefined = undefined;
try {
// try the package
pkg = await (await extensionManager).findPackage(newCorePackage, requestedVersion);

Просмотреть файл

@ -1,64 +0,0 @@
import chalk from "chalk";
function addStyle(style: string, text: string): string {
return `▌PUSH:${style}${text}▌POP▐`;
}
function compileStyledText(text: string): string {
const styleStack = ["(x => x)"];
let result = "";
let consumedUpTo = 0;
const appendPart = (end: number) => {
const CHALK = chalk;
result += eval(styleStack[styleStack.length - 1])(text.slice(consumedUpTo, end));
consumedUpTo = end;
};
const commandRegex = /▌(.+?)▐/g;
let i: RegExpExecArray;
// eslint-disable-next-line no-cond-assign
while ((i = commandRegex.exec(text))) {
const startIndex = i.index;
const length = i[0].length;
const command = i[1].split(":");
// append up to here with current style
appendPart(startIndex);
// process command
consumedUpTo += length;
switch (command[0]) {
case "PUSH":
styleStack.push("CHALK." + command[1]);
break;
case "POP":
styleStack.pop();
break;
}
}
appendPart(text.length);
return result;
}
export function color(text: string): string {
return compileStyledText(
text
.replace(/\*\*(.*?)\*\*/gm, addStyle("bold", "$1"))
.replace(/(\[.*?s\])/gm, addStyle("yellow.bold", "$1"))
.replace(/^# (.*)/gm, addStyle("greenBright", "$1"))
.replace(/^## (.*)/gm, addStyle("green", "$1"))
.replace(/^### (.*)/gm, addStyle("cyanBright", "$1"))
.replace(/(https?:\/\/\S*)/gm, addStyle("blue.bold.underline", "$1"))
.replace(/__(.*)__/gm, addStyle("italic", "$1"))
.replace(/^>(.*)/gm, addStyle("cyan", " $1"))
.replace(/^!(.*)/gm, addStyle("red.bold", " $1"))
.replace(/^(ERROR) (.*?):(.*)/gm, `\n${addStyle("red.bold", "$1")} ${addStyle("green", "$2")}:$3`)
.replace(/^(WARNING) (.*?):(.*)/gm, `\n${addStyle("yellow.bold", "$1")} ${addStyle("green", "$2")}:$3`)
.replace(
/^(\s* - \w*:\/\/\S*):(\d*):(\d*) (.*)/gm,
`${addStyle("cyan", "$1")}:${addStyle("cyan.bold", "$2")}:${addStyle("cyan.bold", "$3")} $4`,
)
.replace(/`(.+?)`/gm, addStyle("gray", "$1"))
.replace(/"(.*?)"/gm, addStyle("gray", '"$1"'))
.replace(/'(.*?)'/gm, addStyle("gray", "'$1'")),
);
}

Просмотреть файл

@ -1,7 +1,7 @@
/* eslint-disable no-console */
import { color } from "@autorest/common";
import { AutorestArgs } from "../args";
import { extensionManager, rootFolder } from "../autorest-as-a-service";
import { color } from "../coloring";
/**
* Reset autorest, this will:

Просмотреть файл

@ -2,7 +2,6 @@
import chalk from "chalk";
import { AutorestArgs } from "../args";
import { extensionManager, newCorePackage, oldCorePackage } from "../autorest-as-a-service";
import { color } from "../coloring";
/**
* Shows all the autorest extensions that are installed.
@ -24,16 +23,15 @@ export const showInstalledExtensions = async (args: AutorestArgs): Promise<numbe
if (args.json) {
console.log(JSON.stringify(extensions, null, " "));
} else {
const title = `\n\n${chalk.greenBright("Showing All Installed Extensions")}\n`;
if (table) {
console.log(
color(
`\n\n# Showing All Installed Extensions\n\n ${chalk.underline("Type".padEnd(10))} ${chalk.underline(
"Extension Name".padEnd(40),
)} ${chalk.underline("Version".padEnd(12))} ${chalk.underline("Location")} ${table}\n\n`,
),
`${title}\n ${chalk.underline("Type".padEnd(10))} ${chalk.underline(
"Extension Name".padEnd(40),
)} ${chalk.underline("Version".padEnd(12))} ${chalk.underline("Location")} ${table}\n\n`,
);
} else {
console.log(color("\n\n# Showing All Installed Extensions\n\n > No Extensions are currently installed.\n\n"));
console.log(`${title}\n ${chalk.cyan("No Extensions are currently installed.")}\n\n`);
}
}
return 0;

Просмотреть файл

@ -2,8 +2,8 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from "path";
import { existsSync } from "fs";
import * as path from "path";
const resolveAppRoot = () => {
let current = path.resolve(__dirname);

Просмотреть файл

@ -3,19 +3,22 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/* eslint-disable @typescript-eslint/triple-slash-reference */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/// <reference path="../definitions/core.d.ts" />
/// <reference path="../definitions/vscode.d.ts" />
// everything else.
import { runCoreWithRequire, resolveEntrypoint, ensureAutorestHome, selectVersion } from "./autorest-as-a-service";
import { resolve } from "path";
import { GenerationResults, IFileSystem, AutoRest as IAutoRest } from "autorest-core";
import { LanguageClient } from "vscode-languageclient";
// exports the public AutoRest definitions
import { GenerationResults, IFileSystem, AutoRest as IAutoRest } from "autorest-core";
import { runCoreWithRequire, resolveEntrypoint, ensureAutorestHome, selectVersion } from "./autorest-as-a-service";
export { Message, Artifact, GenerationResults, IFileSystem } from "autorest-core";
export { color } from "./coloring";
// This is needed currently in autorest-as-service when starting @autorest/core out of proc for @autorest/core version older than 3.6.0
export { color } from "@autorest/common";
/**
* The Channel that a message is registered with.
@ -87,13 +90,13 @@ let modulePath: string | undefined = undefined;
export async function getLanguageServiceEntrypoint(
requestedVersion = "latest-installed",
minimumVersion?: string,
): Promise<string> {
): Promise<string | undefined> {
if (!modulePath && !busy) {
// if we haven't already got autorest-core, let's do that now with the default settings.
// eslint-disable-next-line @typescript-eslint/no-use-before-define
await initialize(requestedVersion, minimumVersion);
}
return resolveEntrypoint(modulePath, "language-service");
return resolveEntrypoint(modulePath!, "language-service");
}
/**
@ -110,13 +113,13 @@ export async function getLanguageServiceEntrypoint(
export async function getApplicationEntrypoint(
requestedVersion = "latest-installed",
minimumVersion?: string,
): Promise<string> {
): Promise<string | undefined> {
if (!modulePath && !busy) {
// if we haven't already got autorest-core, let's do that now with the default settings.
// eslint-disable-next-line @typescript-eslint/no-use-before-define
await initialize(requestedVersion, minimumVersion);
}
return resolveEntrypoint(modulePath, "app");
return resolveEntrypoint(modulePath!, "app");
}
/**

Просмотреть файл

@ -1,4 +1,4 @@
import { parseMemory } from "./utils";
import { getRequestedCoreVersion, parseMemory } from "./utils";
describe("autorest: Utils", () => {
it("resolve max memory config from gb string", () => {
@ -14,4 +14,21 @@ describe("autorest: Utils", () => {
expect(() => parseMemory("abdef")).toThrowError();
expect(() => parseMemory("4096")).toThrowError();
});
describe("getRequestedCoreVersion", () => {
it("returns version in config if present", () => {
expect(getRequestedCoreVersion({ version: "3.1.0" })).toEqual("3.1.0");
expect(getRequestedCoreVersion({ version: "3.1.0", latest: true })).toEqual("3.1.0");
expect(getRequestedCoreVersion({ version: "3.1.0", preview: true })).toEqual("3.1.0");
});
it("returns 'latest' in latest flag is on but config is not passed", () => {
expect(getRequestedCoreVersion({ latest: true })).toEqual("latest");
expect(getRequestedCoreVersion({ latest: true, preview: true })).toEqual("latest");
});
it("returns 'preview' in preview flag is on but config and latest is not passed", () => {
expect(getRequestedCoreVersion({ preview: true })).toEqual("preview");
});
});
});

Просмотреть файл

@ -1,17 +1,19 @@
import { AutorestArgs } from "./args";
import { AutorestConfiguration, ConfigurationLoader } from "@autorest/configuration";
import { AutorestLogger } from "@autorest/configuration/node_modules/@autorest/common";
import { createFileOrFolderUri, createFolderUri, resolveUri } from "@azure-tools/uri";
import { AppRoot } from "./constants";
import { extensionManager, networkEnabled, selectVersion } from "./autorest-as-a-service";
import chalk from "chalk";
import { checkForAutoRestUpdate } from "./actions";
import { isFile } from "@azure-tools/async-io";
import { dirname, join, resolve } from "path";
import { AutorestLogger, AutorestSyncLogger, ConsoleLoggerSink, IAutorestLogger, LoggerSink } from "@autorest/common";
import { AutorestConfiguration, AutorestNormalizedConfiguration, ConfigurationLoader } from "@autorest/configuration";
import { isFile } from "@azure-tools/async-io";
import { createFileOrFolderUri, createFolderUri, resolveUri } from "@azure-tools/uri";
import chalk from "chalk";
import untildify from "untildify";
import { checkForAutoRestUpdate } from "./actions";
import { AutorestArgs } from "./args";
import { extensionManager, networkEnabled, selectVersion } from "./autorest-as-a-service";
import { AppRoot } from "./constants";
const inWebpack = typeof __webpack_require__ === "function";
const nodeRequire = inWebpack ? __non_webpack_require__ : require;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const nodeRequire = inWebpack ? __non_webpack_require__! : require;
const defaultConfigUri = inWebpack
? resolveUri(createFolderUri(AppRoot), `dist/resources/default-configuration.md`)
: createFileOrFolderUri(nodeRequire.resolve("@autorest/configuration/resources/default-configuration.md"));
@ -22,7 +24,7 @@ const defaultConfigUri = inWebpack
* @returns npm version/tag.
*/
export const getRequestedCoreVersion = (args: AutorestArgs): string | undefined => {
return args.version || (args.latest && "latest") || (args.preview && "preview");
return args.version ?? (args.latest ? "latest" : args.preview ? "preview" : undefined);
};
const cwd = process.cwd();
@ -31,29 +33,24 @@ const cwd = process.cwd();
* Tries to load the configuration of autorest.
* @param args CLI args.
*/
export async function loadConfig(args: AutorestArgs): Promise<AutorestConfiguration> {
export async function loadConfig(sink: LoggerSink, args: AutorestArgs): Promise<AutorestConfiguration | undefined> {
const configFileOrFolder = resolveUri(createFolderUri(cwd), args.configFileOrFolder || ".");
/* eslint-disable no-console */
const logger: AutorestLogger = {
fatal: (x) => args.verbose && console.error(x),
info: (x) => args.verbose && console.log(x),
verbose: (x) => args.verbose && console.log(x),
trackError: (x) => console.error(x),
trackWarning: (x) => console.error(x),
};
/* eslint-enable no-console */
const enableLogging = args["debug-cli-config-loading"];
const logger = new AutorestSyncLogger({
sinks: enableLogging ? [sink] : [],
});
const loader = new ConfigurationLoader(logger, defaultConfigUri, configFileOrFolder, {
extensionManager: await extensionManager,
});
const { config } = await loader.load([args], true);
if (config.version) {
try {
const { config } = await loader.load([args], true);
return config;
} catch (e) {
// eslint-disable-next-line no-console
console.log(
chalk.yellow(`NOTE: AutoRest core version selected from configuration: ${chalk.yellow.bold(config.version)}.`),
);
logger.log({ level: "warning", message: "Error occured while loading configuration." });
return undefined;
}
return config;
}
/**
@ -80,7 +77,7 @@ export async function resolvePathForLocalVersion(requestedVersion: string | null
return undefined;
}
export async function resolveCoreVersion(config: AutorestConfiguration): Promise<string> {
export async function resolveCoreVersion(config: AutorestNormalizedConfiguration = {}): Promise<string> {
const requestedVersion: string = getRequestedCoreVersion(config) ?? "latest-installed";
const localVersion = await resolvePathForLocalVersion(config.version ? requestedVersion : null);

Просмотреть файл

@ -0,0 +1,33 @@
import { execFile, ExecFileException } from "child_process";
import { join } from "path";
const root = join(__dirname, "..");
const coreRoot = join(root, "../../extensions/core");
const cliEntrypoint = join(root, "./entrypoints/app.js");
interface AutorestResult {
stderr: string;
stdout: string;
exitCode: number;
error?: ExecFileException;
}
async function runAutorest(args: string[]): Promise<AutorestResult> {
return new Promise((resolve, reject) => {
execFile("node", [cliEntrypoint, `--version=${coreRoot}`, ...args], (error, stdout, stderr) => {
resolve({ stdout, stderr, exitCode: error?.code ?? 0, error: error === null ? undefined : error });
});
});
}
describe("Failures", () => {
it("returns zero exit code on success", async () => {
const { exitCode, stdout, stderr } = await runAutorest(["--help"]);
console.log(stdout, stderr);
expect(exitCode).toEqual(0);
});
it("returns non-zero exit code on failure", async () => {
const { exitCode } = await runAutorest(["--input-file=doesnotexists.yaml"]);
expect(exitCode).not.toEqual(0);
});
});

Просмотреть файл

@ -0,0 +1 @@
jest.setTimeout(100_000); // in milliseconds

Просмотреть файл

@ -2,7 +2,6 @@
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"strictNullChecks": false,
"types": ["node", "jest"]
},
"include": ["src/**/*.ts", "definitions/**/*.d.ts", "test/**/*.ts"]

Просмотреть файл

@ -0,0 +1,3 @@
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"
},
@ -49,6 +49,7 @@
"eslint-plugin-node": "~11.1.0",
"eslint-plugin-prettier": "~3.4.0",
"eslint-plugin-unicorn": "~33.0.1",
"eslint-plugin-import": "~2.24.2",
"eslint": "^7.17.0",
"jest": "^27.0.4",
"lodash": "~4.17.20",
@ -57,10 +58,10 @@
"source-map-support": "^0.5.19",
"ts-jest": "^27.0.3",
"ts-loader": "~9.2.3",
"typescript": "~4.3.4"
"typescript": "~4.4.2"
},
"dependencies": {
"@azure-tools/adl": "~0.10.0",
"@autorest/extension-base": "~3.3.0"
"@cadl-lang/compiler": "~0.19.0 ",
"@autorest/extension-base": "~3.3.2"
}
}

Просмотреть файл

@ -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 { Channel, Host } from "@autorest/extension-base";
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 { readFile, realpath, stat } from "fs/promises";
import { join, resolve } from "path";
import { fileURLToPath, pathToFileURL } from "url";
import { CompilerHost, createProgram, Diagnostic, createSourceFile } from "@cadl-lang/compiler";
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 ("diagnostics" in e) {
return { error: e };
if (typeof e === "object" && e !== null && "diagnostics" in e) {
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,6 +1,167 @@
{
"name": "@autorest/core",
"entries": [
{
"version": "3.6.6",
"tag": "@autorest/core_v3.6.6",
"date": "Mon, 11 Oct 2021 21:01:13 GMT",
"comments": {
"patch": [
{
"comment": "**Fix** Unreferenced discriminated union option being removed"
}
]
}
},
{
"version": "3.6.5",
"tag": "@autorest/core_v3.6.5",
"date": "Wed, 06 Oct 2021 17:36:17 GMT",
"comments": {
"patch": [
{
"comment": "**Fix** exit code always 0"
}
]
}
},
{
"version": "3.6.4",
"tag": "@autorest/core_v3.6.4",
"date": "Tue, 05 Oct 2021 16:39:50 GMT",
"comments": {
"patch": [
{
"comment": "**Fix** `message-format` not being respected"
}
]
}
},
{
"version": "3.6.3",
"tag": "@autorest/core_v3.6.3",
"date": "Thu, 23 Sep 2021 19:51:32 GMT",
"comments": {
"patch": [
{
"comment": "**Added** `include-x-ms-examples-original-file` flag to activate `x-ms-original-file` injection in `x-ms-examples`"
}
],
"dependency": [
{
"comment": "Updating dependency \"@autorest/configuration\" from `~1.7.1` to `~1.7.2`"
}
]
}
},
{
"version": "3.6.2",
"tag": "@autorest/core_v3.6.2",
"date": "Fri, 17 Sep 2021 17:52:01 GMT",
"comments": {
"patch": [
{
"comment": "**Fix** Deduplicating enums dropped `format` property"
}
],
"dependency": [
{
"comment": "Updating dependency \"@autorest/schemas\" from `~1.3.0` to `~1.3.1`"
}
]
}
},
{
"version": "3.6.1",
"tag": "@autorest/core_v3.6.1",
"date": "Thu, 16 Sep 2021 18:49:17 GMT",
"comments": {
"patch": [
{
"comment": "**Fix** Deduplicating `boolean` enums changed type to `string`"
}
]
}
},
{
"version": "3.6.0",
"tag": "@autorest/core_v3.6.0",
"date": "Wed, 08 Sep 2021 15:39:22 GMT",
"comments": {
"patch": [
{
"comment": "**Perf** Minor perf in merger plugin"
},
{
"comment": "**Perf** Minor performance improvement in allof cleaner plugin"
},
{
"comment": "Log error when directive where clause is invalid"
},
{
"comment": "Improve erorr message for directive when there is an error in the transform code"
},
{
"comment": "**Fix** Error in config loading would not be logged as the logging session would not be awaited on"
}
],
"minor": [
{
"comment": "**Uptake** New logger"
},
{
"comment": "Uptake new changes to Swagger->OpenApi3 converter"
},
{
"comment": "`x-ms-examples` loaded via $ref will save orignal location with `x-ms-original-file` extension property"
},
{
"comment": "Keep `x-` extension properties when merging enums"
},
{
"comment": "**Perf** Small perf improvement for components cleaner plugin"
},
{
"comment": " **Update** to new path mapping sourcemap functionality"
},
{
"comment": "**Remove** quick-check plugin"
}
],
"dependency": [
{
"comment": "Updating dependency \"@autorest/common\" from `~1.2.0` to `~1.3.0`"
},
{
"comment": "Updating dependency \"@autorest/configuration\" from `~1.6.0` to `~1.7.0`"
},
{
"comment": "Updating dependency \"@autorest/schemas\" from `~1.2.0` to `~1.3.0`"
},
{
"comment": "Updating dependency \"@autorest/test-utils\" from `~0.3.0` to `~0.4.0`"
},
{
"comment": "Updating dependency \"@azure-tools/codegen\" from `~2.6.0` to `~2.7.0`"
},
{
"comment": "Updating dependency \"@azure-tools/datastore\" from `~4.4.0` to `~4.5.0`"
},
{
"comment": "Updating dependency \"@azure-tools/deduplication\" from `~3.1.0` to `~3.1.1`"
},
{
"comment": "Updating dependency \"@azure-tools/json\" from `~1.1.0` to `~1.2.0`"
},
{
"comment": "Updating dependency \"@azure-tools/oai2-to-oai3\" from `~4.3.0` to `~4.4.0`"
},
{
"comment": "Updating dependency \"@azure-tools/openapi\" from `~3.2.0` to `~3.2.1`"
}
]
}
},
{
"version": "3.5.0",
"tag": "@autorest/core_v3.5.0",

Просмотреть файл

@ -1,6 +1,69 @@
# Change Log - @autorest/core
This log was last generated on Mon, 19 Jul 2021 15:15:41 GMT and should not be manually modified.
This log was last generated on Mon, 11 Oct 2021 21:01:13 GMT and should not be manually modified.
## 3.6.6
Mon, 11 Oct 2021 21:01:13 GMT
### Patches
- **Fix** Unreferenced discriminated union option being removed
## 3.6.5
Wed, 06 Oct 2021 17:36:17 GMT
### Patches
- **Fix** exit code always 0
## 3.6.4
Tue, 05 Oct 2021 16:39:50 GMT
### Patches
- **Fix** `message-format` not being respected
## 3.6.3
Thu, 23 Sep 2021 19:51:32 GMT
### Patches
- **Added** `include-x-ms-examples-original-file` flag to activate `x-ms-original-file` injection in `x-ms-examples`
## 3.6.2
Fri, 17 Sep 2021 17:52:01 GMT
### Patches
- **Fix** Deduplicating enums dropped `format` property
## 3.6.1
Thu, 16 Sep 2021 18:49:17 GMT
### Patches
- **Fix** Deduplicating `boolean` enums changed type to `string`
## 3.6.0
Wed, 08 Sep 2021 15:39:22 GMT
### Minor changes
- **Uptake** New logger
- Uptake new changes to Swagger->OpenApi3 converter
- `x-ms-examples` loaded via $ref will save orignal location with `x-ms-original-file` extension property
- Keep `x-` extension properties when merging enums
- **Perf** Small perf improvement for components cleaner plugin
- **Update** to new path mapping sourcemap functionality
- **Remove** quick-check plugin
### Patches
- **Perf** Minor perf in merger plugin
- **Perf** Minor performance improvement in allof cleaner plugin
- Log error when directive where clause is invalid
- Improve erorr message for directive when there is an error in the transform code
- **Fix** Error in config loading would not be logged as the logging session would not be awaited on
## 3.5.0
Mon, 19 Jul 2021 15:15:41 GMT

Просмотреть файл

@ -0,0 +1,10 @@
// @ts-check
const defaultConfig = require("./jest.config");
const config = {
...defaultConfig,
testMatch: ["<rootDir>/test/**/*.e2e.ts"],
};
module.exports = config;

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "@autorest/core",
"version": "3.5.1",
"version": "3.6.6",
"description": "AutoRest core module",
"engines": {
"node": ">=12.0.0"
@ -27,8 +27,11 @@
"autorest-language-service": "./entrypoints/language-service.js"
},
"scripts": {
"test": "jest --coverage=false --forceExit --runInBand",
"test:ci": "jest --ci --forceExit --runInBand",
"test": "jest --coverage=false --watch",
"test:unit:ci": "jest --ci",
"test:e2e": "jest --forceExit --runInBand --config ./jest.e2e.config.js",
"test:e2e:ci": "jest --ci --forceExit --runInBand --config ./jest.e2e.config.js",
"test:ci": "npm run test:unit:ci && npm run test:e2e:ci",
"watch": "tsc -p ./tsconfig.build.json --watch",
"build": "tsc -p ./tsconfig.build.json",
"build:prod": "webpack",
@ -39,21 +42,20 @@
},
"typings": "./dist/exports.d.ts",
"devDependencies": {
"@autorest/common": "~1.2.0",
"@autorest/configuration": "~1.6.0",
"@autorest/schemas": "~1.2.0",
"@autorest/test-utils": "~0.3.0",
"@autorest/common": "~1.3.0",
"@autorest/configuration": "~1.7.3",
"@autorest/schemas": "~1.3.1",
"@autorest/test-utils": "~0.4.0",
"@azure-tools/async-io": "~3.0.0",
"@azure-tools/codegen": "~2.6.0",
"@azure-tools/datastore": "~4.4.0",
"@azure-tools/deduplication": "~3.1.0",
"@azure-tools/codegen": "~2.8.0",
"@azure-tools/datastore": "~4.5.1",
"@azure-tools/deduplication": "~3.1.1",
"@azure-tools/extension": "~3.3.1",
"@azure-tools/json": "~1.1.0",
"@azure-tools/json": "~1.2.0",
"@azure-tools/jsonschema": "~1.1.0",
"@azure-tools/linq": "~3.1.0",
"@azure-tools/oai2-to-oai3": "~4.3.0",
"@azure-tools/oai2-to-oai3": "~4.4.0",
"@azure-tools/object-comparison": "~3.0.0",
"@azure-tools/openapi": "~3.2.0",
"@azure-tools/openapi": "~3.2.1",
"@azure-tools/tasks": "~3.0.0",
"@azure-tools/uri": "~3.1.1",
"@azure-tools/yaml": "~1.0.0",
@ -76,10 +78,10 @@
"eslint-plugin-node": "~11.1.0",
"eslint-plugin-prettier": "~3.4.0",
"eslint-plugin-unicorn": "~33.0.1",
"eslint-plugin-import": "~2.24.2",
"eslint": "^7.17.0",
"jest": "^27.0.4",
"jsonpath": "1.0.0",
"linq-es2015": "^2.4.25",
"lodash": "~4.17.20",
"mkdirp": "~0.5.1",
"prettier": "~2.3.1",
@ -89,7 +91,7 @@
"source-map": "0.7.3",
"ts-jest": "^27.0.3",
"ts-loader": "~9.2.3",
"typescript": "~4.3.4",
"typescript": "~4.4.2",
"vscode-jsonrpc": "^3.5.0",
"vscode-languageserver": "3.5.1",
"webpack-cli": "~4.7.2",

Просмотреть файл

@ -4,21 +4,28 @@
*--------------------------------------------------------------------------------------------*/
/* eslint-disable no-console */
import "source-map-support/register";
import { omit } from "lodash";
import { configureLibrariesLogger } from "@autorest/common";
import { EventEmitter } from "events";
import { resolve as currentDirectory } from "path";
import {
configureLibrariesLogger,
color,
ConsoleLogger,
FilterLogger,
AutorestLogger,
AutorestSyncLogger,
Exception,
IAutorestLogger,
} from "@autorest/common";
import { AutorestCliArgs, parseAutorestCliArgs } from "@autorest/configuration";
EventEmitter.defaultMaxListeners = 100;
process.env["ELECTRON_RUN_AS_NODE"] = "1";
delete process.env["ELECTRON_NO_ATTACH_CONSOLE"];
const color: (text: string) => string = (<any>global).color ? (<any>global).color : (p) => p;
// start of autorest-ng
// the console app starts for real here.
import { EnhancedFileSystem, RealFileSystem } from "@azure-tools/datastore";
import { parseYAML } from "@azure-tools/yaml";
import {
clearFolder,
createFolderUri,
@ -28,64 +35,17 @@ import {
writeBinary,
writeString,
} from "@azure-tools/uri";
import { resolve as currentDirectory } from "path";
import { Help } from "./help";
import { omit } from "lodash";
import { ArtifactWriter } from "./artifact-writer";
import { printAutorestHelp } from "./commands";
import { Artifact } from "./lib/artifact";
import { AutoRest, IsOpenApiDocument, Shutdown } from "./lib/autorest-core";
import { Exception } from "@autorest/common";
import { Channel, Message } from "./lib/message";
import { VERSION } from "./lib/constants";
import { AutorestCoreLogger } from "./lib/context/logger";
import { ArtifactWriter } from "./artifact-writer";
import { getLogLevel } from "./lib/context";
let verbose = false;
let debug = false;
// TODO remove this when redesigning the logger integration. This is a hack to reuse the logic of the AutorestCoreLogger
// https://github.com/Azure/autorest/issues/4024
class RootLogger extends AutorestCoreLogger {
public constructor() {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
super({} as any, null!, null!);
}
public log(message: Message) {
outputMessage(message, () => {});
}
}
function outputMessage(m: Message, errorCounter: () => void) {
switch (m.Channel) {
case Channel.Debug:
if (debug) {
console.log(color(m.FormattedMessage || m.Text));
}
break;
case Channel.Verbose:
if (verbose) {
console.log(color(m.FormattedMessage || m.Text));
}
break;
case Channel.Information:
console.log(color(m.FormattedMessage || m.Text));
break;
case Channel.Warning:
console.log(color(m.FormattedMessage || m.Text));
break;
case Channel.Error:
case Channel.Fatal:
errorCounter();
console.error(color(m.FormattedMessage || m.Text));
break;
}
}
function subscribeMessages(api: AutoRest, errorCounter: () => void) {
api.Message.Subscribe((_, m) => {
return outputMessage(m, errorCounter);
});
}
async function autorestInit(title = "API-NAME", inputs: Array<string> = ["LIST INPUT FILES HERE"]) {
const cwdUri = createFolderUri(currentDirectory());
for (let i = 0; i < inputs.length; ++i) {
@ -140,12 +100,10 @@ csharp:
);
}
let exitcode = 0;
let cleared = false;
async function doClearFolders(protectFiles: Set<string>, clearFolders: Set<string>) {
async function doClearFolders(protectFiles: Set<string>, clearFolders: Set<string>, logger: IAutorestLogger) {
if (!cleared) {
timestampDebugLog("Clearing Folders.");
logger.debug("Clearing Folders.");
cleared = true;
for (const folder of clearFolders) {
try {
@ -160,37 +118,16 @@ async function doClearFolders(protectFiles: Set<string>, clearFolders: Set<strin
}
}
async function currentMain(autorestArgs: Array<string>): Promise<number> {
if (autorestArgs[0] === "init") {
await autorestInit();
return 0;
}
// add probes for readme.*.md files when a standalone arg is given.
const more = [];
for (const each of autorestArgs) {
const match = /^--([^=:]+)([=:](.+))?$/g.exec(each);
if (match && !match[3]) {
// it's a solitary --foo (ie, no specified value) argument
more.push(`--try-require=readme.${match[1]}.md`);
}
}
// We need to check if verbose logging should be enabled before parsing the args.
verbose = verbose || autorestArgs.indexOf("--verbose") !== -1;
const logger = new RootLogger();
const args = parseAutorestCliArgs([...autorestArgs, ...more], { logger });
async function currentMain(logger: IAutorestLogger, args: AutorestCliArgs): Promise<number> {
if (!args.options["message-format"] || args.options["message-format"] === "regular") {
console.log(color(`> Loading AutoRest core '${__dirname}' (${VERSION})`));
logger.info(`> Loading AutoRest core '${__dirname}' (${VERSION})`);
}
verbose = verbose || (args.options["verbose"] ?? false);
debug = debug || (args.options["debug"] ?? false);
// Only show library logs if in verbose or debug mode.
if (verbose || debug) {
configureLibrariesLogger("verbose", console.log);
configureLibrariesLogger("verbose", (...x) => logger.debug(x.join(" ")));
}
// identify where we are starting from.
@ -204,13 +141,13 @@ async function currentMain(autorestArgs: Array<string>): Promise<number> {
const githubToken = args.options["github-auth-token"] ?? process.env.GITHUB_AUTH_TOKEN;
// get an instance of AutoRest and add the command line switches to the configuration.
const api = new AutoRest(
logger,
new EnhancedFileSystem(githubToken),
resolveUri(currentDirUri, args.configFileOrFolder ?? "."),
);
api.AddConfiguration(args.options);
// listen for output messages and file writes
subscribeMessages(api, () => exitcode++);
const artifacts: Array<Artifact> = [];
const clearFolders = new Set<string>();
const protectFiles = new Set<string>();
@ -227,20 +164,18 @@ async function currentMain(autorestArgs: Array<string>): Promise<number> {
artifactWriter.writeArtifact(artifact);
});
api.Message.Subscribe((_, message) => {
if (message.Channel === Channel.Protect && message.Details) {
protectFiles.add(message.Details);
}
api.ProtectFile.Subscribe((_, filename) => {
protectFiles.add(filename);
});
api.ClearFolder.Subscribe((_, folder) => clearFolders.add(folder));
// maybe a resource schema batch process
if (context.config["resource-schema-batch"]) {
return resourceSchemaBatch(api);
return resourceSchemaBatch(api, logger);
}
if (context.config["batch"]) {
await batch(api, args);
await batch(api, logger);
} else {
const result = await api.Process().finish;
if (result !== true) {
@ -249,55 +184,17 @@ async function currentMain(autorestArgs: Array<string>): Promise<number> {
}
if (context.config.help) {
// no fs operations on --help! Instead, format and print artifacts to console.
// - print boilerplate help
console.log("");
console.log("");
console.log(color("**Usage**: autorest `[configuration-file.md] [...options]`"));
console.log("");
console.log(color(" See: https://aka.ms/autorest/cli for additional documentation"));
// - sort artifacts by name (then content, just for stability)
const helpArtifacts = artifacts.sort((a, b) =>
a.uri === b.uri ? (a.content > b.content ? 1 : -1) : a.uri > b.uri ? 1 : -1,
);
// - format and print
for (const helpArtifact of helpArtifacts) {
const { result: help, errors } = parseYAML<Help>(helpArtifact.content);
if (errors.length > 0) {
for (const { message, position } of errors) {
console.error(color(`!Parsing error at **${helpArtifact.uri}**:__${position}: ${message}__`));
}
}
if (!help) {
continue;
}
const activatedBySuffix = help.activationScope ? ` (activated by --${help.activationScope})` : "";
console.log("");
console.log(color(`### ${help.categoryFriendlyName}${activatedBySuffix}`));
if (help.description) {
console.log(color(help.description));
}
console.log("");
for (const settingHelp of help.settings) {
const keyPart = `--${settingHelp.key}`;
const typePart = settingHelp.type ? `=<${settingHelp.type}>` : " "; // `[=<boolean>]`;
const settingPart = `${keyPart}\`${typePart}\``;
// if (!settingHelp.required) {
// settingPart = `[${settingPart}]`;
// }
console.log(color(` ${settingPart.padEnd(30)} **${settingHelp.description}**`));
}
}
printAutorestHelp(artifacts);
} else {
// perform file system operations.
await doClearFolders(protectFiles, clearFolders);
await doClearFolders(protectFiles, clearFolders, logger);
timestampDebugLog("Writing Outputs.");
logger.debug("Writing Outputs.");
await artifactWriter.wait();
}
timestampLog("Generation Complete");
logger.info("Generation Complete");
// return the exit code to the caller.
return exitcode;
return 0;
}
function shallowMerge(existing: any, more: any) {
@ -334,13 +231,14 @@ function getRds(schema: any, path: string): Array<string> {
return result;
}
async function resourceSchemaBatch(api: AutoRest): Promise<number> {
async function resourceSchemaBatch(api: AutoRest, logger: IAutorestLogger): Promise<number> {
// get the configuration
const outputs = new Map<string, string>();
const schemas = new Array<string>();
let outstanding: Promise<void> = Promise.resolve();
let exitCode = 0;
// ask for the view without
const config = await api.RegenerateView();
for (const batchContext of config.getNestedConfiguration("resource-schema-batch")) {
@ -349,13 +247,13 @@ async function resourceSchemaBatch(api: AutoRest): Promise<number> {
const path = resolveUri(config.configFileFolderUri, eachFile);
const content = await readUri(path);
if (!(await IsOpenApiDocument(content))) {
exitcode++;
exitCode++;
console.error(color(`!File ${path} is not a OpenAPI file.`));
continue;
}
// Create the autorest instance for that item
const instance = new AutoRest(new RealFileSystem(), config.configFileFolderUri);
const instance = new AutoRest(logger, new RealFileSystem(), config.configFileFolderUri);
instance.GeneratedFile.Subscribe((_, file) => {
if (file.uri.endsWith(".json")) {
const more = JSON.parse(file.content);
@ -380,18 +278,17 @@ async function resourceSchemaBatch(api: AutoRest): Promise<number> {
}
}
});
subscribeMessages(instance, () => exitcode++);
// set configuration for that item
instance.AddConfiguration(omit(batchContext, "input-file"));
instance.AddConfiguration({ "input-file": eachFile });
console.log(`Running autorest for *${path}* `);
logger.info(`Running autorest for *${path}* `);
// ok, kick off the process for that one.
await instance.Process().finish.then(async (result) => {
if (result !== true) {
exitcode++;
exitCode++;
throw result;
}
});
@ -400,24 +297,15 @@ async function resourceSchemaBatch(api: AutoRest): Promise<number> {
await outstanding;
return exitcode;
return exitCode;
}
async function batch(api: AutoRest, args: AutorestCliArgs): Promise<void> {
async function batch(api: AutoRest, logger: IAutorestLogger): Promise<void> {
const config = await api.view;
const batchTaskConfigReference: any = {};
api.AddConfiguration(batchTaskConfigReference);
for (const batchTaskConfig of config.GetEntry(<any>"batch")) {
const isjson = args.options["message-format"] === "json" || args.options["message-format"] === "yaml";
if (!isjson) {
outputMessage(
{
Channel: Channel.Information,
Text: `Processing batch task - ${JSON.stringify(batchTaskConfig)} .`,
},
() => {},
);
}
logger.info(`Processing batch task - ${JSON.stringify(batchTaskConfig)} .`);
// update batch task config section
for (const key of Object.keys(batchTaskConfigReference)) {
delete batchTaskConfigReference[key];
@ -427,73 +315,74 @@ async function batch(api: AutoRest, args: AutorestCliArgs): Promise<void> {
const result = await api.Process().finish;
if (result !== true) {
outputMessage(
{
Channel: Channel.Error,
Text: `Failure during batch task - ${JSON.stringify(batchTaskConfig)} -- ${result}.`,
},
() => {},
);
logger.trackError({
code: "Batch/Error",
message: `Failure during batch task - ${JSON.stringify(batchTaskConfig)} -- ${result}`,
});
throw result;
}
}
}
/**
* Entry point
*/
async function mainImpl(): Promise<number> {
let autorestArgs: Array<string> = [];
const exitcode = 0;
async function main() {
const argv = process.argv.slice(2);
if (argv[0] === "init") {
await autorestInit();
return;
}
const args = await getCliArgs(argv);
const logger = new AutorestSyncLogger({
sinks: [new ConsoleLogger({ format: args.options["message-format"] })],
processors: [new FilterLogger({ level: getLogLevel(args.options) })],
});
let exitCode = 0;
try {
autorestArgs = process.argv.slice(2);
return await currentMain(autorestArgs);
return await currentMain(logger, args);
} catch (e) {
exitCode = 1;
// be very careful about the following check:
// - doing the inversion (instanceof Error) doesn't reliably work since that seems to return false on Errors marshalled from safeEval
if (e instanceof Exception) {
console.log(e.message);
return e.exitCode;
logger.log({ level: "error", message: e.message });
exitCode = e.exitCode;
}
if (e !== false) {
console.error(color(`!${e}`));
logger.log({ level: "error", message: `!${e}` });
}
}
return 1;
}
function timestampLog(content: string) {
console.log(color(`[${Math.floor(process.uptime() * 100) / 100} s] ${content}`));
}
function timestampDebugLog(content: string) {
if (debug) {
console.log(color(`[${Math.floor(process.uptime() * 100) / 100} s] ${content}`));
}
}
async function main() {
let exitcode = 0;
try {
exitcode = await mainImpl();
} catch {
exitcode = 102;
} finally {
try {
timestampDebugLog("Shutting Down.");
logger.debug("Shutting Down.");
await Shutdown();
} catch {
timestampDebugLog("Shutting Down: (trouble?)");
logger.debug("Shutting Down: (trouble?)");
} finally {
timestampDebugLog("Exiting.");
logger.debug("Exiting.");
// eslint-disable-next-line no-process-exit
process.exit(exitcode);
process.exit(exitCode);
}
}
}
async function getCliArgs(argv: string[]) {
// add probes for readme.*.md files when a standalone arg is given.
const more = [];
for (const each of argv) {
const match = /^--([^=:]+)([=:](.+))?$/g.exec(each);
if (match && !match[3]) {
// it's a solitary --foo (ie, no specified value) argument
more.push(`--try-require=readme.${match[1]}.md`);
}
}
// We need to check if verbose logging should be enabled before parsing the args.
verbose = verbose || argv.indexOf("--verbose") !== -1;
return parseAutorestCliArgs([...argv, ...more]);
}
// Run
void main();
process.on("exit", () => {

Просмотреть файл

@ -1,8 +1,8 @@
jest.mock("@azure-tools/uri");
import { AutorestRawConfiguration } from "@autorest/configuration";
import { writeString, writeBinary } from "@azure-tools/uri";
import { AutorestRawConfiguration } from "../../../libs/configuration/dist";
import { ArtifactWriter } from "../src/artifact-writer";
import { ArtifactWriter } from "./artifact-writer";
const TestStrings = {
mixed: "some\ndifferent\r\nline\nendings\r\n",

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше