This commit is contained in:
Timothee Guerin 2021-09-29 09:07:58 -07:00
Родитель ed1445348e d0a7293a7b
Коммит c3e8c2b602
23 изменённых файлов: 171 добавлений и 46 удалений

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

@ -1,11 +0,0 @@
{
"changes": [
{
"packageName": "@autorest/configuration",
"comment": "Added missing help text for command line arguments",
"type": "patch"
}
],
"packageName": "@autorest/configuration",
"email": "chlowe@microsoft.com"
}

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

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

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

@ -40,8 +40,8 @@
}, },
"typings": "./dist/exports.d.ts", "typings": "./dist/exports.d.ts",
"devDependencies": { "devDependencies": {
"@autorest/configuration": "~1.7.0", "@autorest/configuration": "~1.7.2",
"@autorest/core": "~3.6.2", "@autorest/core": "~3.6.3",
"@autorest/common": "~1.3.0", "@autorest/common": "~1.3.0",
"@azure-tools/async-io": "~3.0.0", "@azure-tools/async-io": "~3.0.0",
"@azure-tools/extension": "~3.3.1", "@azure-tools/extension": "~3.3.1",

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

@ -1,6 +1,23 @@
{ {
"name": "@autorest/core", "name": "@autorest/core",
"entries": [ "entries": [
{
"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", "version": "3.6.2",
"tag": "@autorest/core_v3.6.2", "tag": "@autorest/core_v3.6.2",

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

@ -1,6 +1,13 @@
# Change Log - @autorest/core # Change Log - @autorest/core
This log was last generated on Fri, 17 Sep 2021 17:52:01 GMT and should not be manually modified. This log was last generated on Thu, 23 Sep 2021 19:51:32 GMT and should not be manually modified.
## 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 ## 3.6.2
Fri, 17 Sep 2021 17:52:01 GMT Fri, 17 Sep 2021 17:52:01 GMT

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

@ -1,6 +1,6 @@
{ {
"name": "@autorest/core", "name": "@autorest/core",
"version": "3.6.2", "version": "3.6.3",
"description": "AutoRest core module", "description": "AutoRest core module",
"engines": { "engines": {
"node": ">=12.0.0" "node": ">=12.0.0"
@ -43,7 +43,7 @@
"typings": "./dist/exports.d.ts", "typings": "./dist/exports.d.ts",
"devDependencies": { "devDependencies": {
"@autorest/common": "~1.3.0", "@autorest/common": "~1.3.0",
"@autorest/configuration": "~1.7.0", "@autorest/configuration": "~1.7.2",
"@autorest/schemas": "~1.3.1", "@autorest/schemas": "~1.3.1",
"@autorest/test-utils": "~0.4.0", "@autorest/test-utils": "~0.4.0",
"@azure-tools/async-io": "~3.0.0", "@azure-tools/async-io": "~3.0.0",

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

@ -1,10 +1,9 @@
import { AnyObject, DataHandle, DataSink, DataSource, Node, Transformer, visit } from "@azure-tools/datastore"; import { AnyObject, DataHandle, DataSink, DataSource, Node, Transformer, visit } from "@azure-tools/datastore";
import { resolveUri } from "@azure-tools/uri"; import { resolveUri } from "@azure-tools/uri";
import { AutorestContext } from "../context"; import { AutorestContext } from "../context";
import { Channel } from "../message";
export async function crawlReferences( export async function crawlReferences(
config: AutorestContext, context: AutorestContext,
inputScope: DataSource, inputScope: DataSource,
filesToCrawl: Array<DataHandle>, filesToCrawl: Array<DataHandle>,
sink: DataSink, sink: DataSink,
@ -21,13 +20,15 @@ export async function crawlReferences(
/** crawls a file for $refs and then recurses to get the $ref'd files */ /** crawls a file for $refs and then recurses to get the $ref'd files */
async function crawl(file: DataHandle) { async function crawl(file: DataHandle) {
const refProcessor = new RefProcessor(file, inputScope); const refProcessor = new RefProcessor(file, inputScope, {
includeXmsExamplesOriginalFileLocation: context.config["include-x-ms-examples-original-file"],
});
const output = await refProcessor.getOutput(); const output = await refProcessor.getOutput();
for (const fileUri of [...refProcessor.filesReferenced].filter((each) => !queued.has(each))) { for (const fileUri of [...refProcessor.filesReferenced].filter((each) => !queued.has(each))) {
queued.add(fileUri); queued.add(fileUri);
config.verbose(`Reading $ref'd file ${fileUri}`); context.verbose(`Reading $ref'd file ${fileUri}`);
const secondaryFile = await inputScope.readStrict(fileUri); const secondaryFile = await inputScope.readStrict(fileUri);
// mark secondary files with a tag so that we don't process operations for them. // mark secondary files with a tag so that we don't process operations for them.
@ -77,12 +78,16 @@ export async function crawlReferences(
return [...primary, ...secondary]; return [...primary, ...secondary];
} }
interface RefProcessorOptions {
includeXmsExamplesOriginalFileLocation?: boolean;
}
class RefProcessor extends Transformer<any, any> { class RefProcessor extends Transformer<any, any> {
public promises = new Array<Promise<void>>(); public promises = new Array<Promise<void>>();
public filesReferenced = new Set<string>(); public filesReferenced = new Set<string>();
private originalFileLocation: string; private originalFileLocation: string;
constructor(originalFile: DataHandle, private inputScope: DataSource) { constructor(originalFile: DataHandle, private inputScope: DataSource, private options: RefProcessorOptions = {}) {
super(originalFile); super(originalFile);
this.originalFileLocation = resolveUri(originalFile.originalDirectory, originalFile.identity[0]); this.originalFileLocation = resolveUri(originalFile.originalDirectory, originalFile.identity[0]);
@ -98,7 +103,9 @@ class RefProcessor extends Transformer<any, any> {
const refUri = resolveUri(this.originalFileLocation, refPath); const refUri = resolveUri(this.originalFileLocation, refPath);
const handle = await this.inputScope.readStrict(refUri); const handle = await this.inputScope.readStrict(refUri);
const exampleData = await handle.readObject<AnyObject>(); const exampleData = await handle.readObject<AnyObject>();
xmsExamples[key] = { ...exampleData, "x-ms-original-file": refUri }; xmsExamples[key] = this.options.includeXmsExamplesOriginalFileLocation
? { ...exampleData, "x-ms-original-file": refUri }
: exampleData;
} catch { } catch {
// skip examples that are not nice to us. // skip examples that are not nice to us.
} }

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

@ -1,6 +1,18 @@
{ {
"name": "@autorest/modelerfour", "name": "@autorest/modelerfour",
"entries": [ "entries": [
{
"version": "4.21.2",
"tag": "@autorest/modelerfour_v4.21.2",
"date": "Wed, 22 Sep 2021 15:23:39 GMT",
"comments": {
"patch": [
{
"comment": "**Fix** log error when using parameter with `content.<mediaType>` as not being supported"
}
]
}
},
{ {
"version": "4.21.1", "version": "4.21.1",
"tag": "@autorest/modelerfour_v4.21.1", "tag": "@autorest/modelerfour_v4.21.1",

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

@ -1,6 +1,13 @@
# Change Log - @autorest/modelerfour # Change Log - @autorest/modelerfour
This log was last generated on Thu, 16 Sep 2021 18:49:17 GMT and should not be manually modified. This log was last generated on Wed, 22 Sep 2021 15:23:39 GMT and should not be manually modified.
## 4.21.2
Wed, 22 Sep 2021 15:23:39 GMT
### Patches
- **Fix** log error when using parameter with `content.<mediaType>` as not being supported
## 4.21.1 ## 4.21.1
Thu, 16 Sep 2021 18:49:17 GMT Thu, 16 Sep 2021 18:49:17 GMT

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

@ -1,6 +1,6 @@
{ {
"name": "@autorest/modelerfour", "name": "@autorest/modelerfour",
"version": "4.21.1", "version": "4.21.2",
"description": "AutoRest Modeler Version Four (component)", "description": "AutoRest Modeler Version Four (component)",
"directories": { "directories": {
"doc": "docs" "doc": "docs"

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

@ -2039,7 +2039,10 @@ export class ModelerFour {
style: <SerializationStyle>(<unknown>parameter.style), style: <SerializationStyle>(<unknown>parameter.style),
explode: parameter.explode, explode: parameter.explode,
} }
: undefined, : {
style: contentType as any,
explode: parameter.explode,
},
), ),
}, },
language: { language: {

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

@ -1,6 +1,30 @@
{ {
"name": "@autorest/configuration", "name": "@autorest/configuration",
"entries": [ "entries": [
{
"version": "1.7.2",
"tag": "@autorest/configuration_v1.7.2",
"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`"
}
]
}
},
{
"version": "1.7.1",
"tag": "@autorest/configuration_v1.7.1",
"date": "Wed, 22 Sep 2021 15:23:39 GMT",
"comments": {
"patch": [
{
"comment": "Added missing help text for command line arguments"
}
]
}
},
{ {
"version": "1.7.0", "version": "1.7.0",
"tag": "@autorest/configuration_v1.7.0", "tag": "@autorest/configuration_v1.7.0",

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

@ -1,6 +1,20 @@
# Change Log - @autorest/configuration # Change Log - @autorest/configuration
This log was last generated on Wed, 08 Sep 2021 15:39:22 GMT and should not be manually modified. This log was last generated on Thu, 23 Sep 2021 19:51:32 GMT and should not be manually modified.
## 1.7.2
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`
## 1.7.1
Wed, 22 Sep 2021 15:23:39 GMT
### Patches
- Added missing help text for command line arguments
## 1.7.0 ## 1.7.0
Wed, 08 Sep 2021 15:39:22 GMT Wed, 08 Sep 2021 15:39:22 GMT

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

@ -1,6 +1,6 @@
{ {
"name": "@autorest/configuration", "name": "@autorest/configuration",
"version": "1.7.0", "version": "1.7.2",
"description": "Autorest configuration", "description": "Autorest configuration",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

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

@ -86,6 +86,11 @@ export interface AutorestNormalizedConfiguration extends AutorestRawConfiguratio
*/ */
eol?: "default" | "lf" | "crlf"; eol?: "default" | "lf" | "crlf";
/**
* Include x-ms-original-file property to x-ms-examples to get path to the original file where example was.
*/
"include-x-ms-examples-original-file"?: boolean;
/** /**
* Feature flags. Those flags enable/disable certain features * Feature flags. Those flags enable/disable certain features
*/ */

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

@ -66,6 +66,10 @@ export const AUTOREST_CONFIGURATION_SCHEMA = {
description: "Force updating the version of core even if there is a local version satisfying the requirement.", description: "Force updating the version of core even if there is a local version satisfying the requirement.",
}, },
memory: { type: "string", description: "Configure max memory allowed for autorest process(s)" }, memory: { type: "string", description: "Configure max memory allowed for autorest process(s)" },
"include-x-ms-examples-original-file": {
type: "boolean",
description: "Include x-ms-original-file property in x-ms-examples",
},
// Feature flags // Feature flags
"deduplicate-inline-models": { type: "boolean" }, "deduplicate-inline-models": { type: "boolean" },

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

@ -30,7 +30,7 @@
}, },
"homepage": "https://github.com/Azure/autorest#readme", "homepage": "https://github.com/Azure/autorest#readme",
"dependencies": { "dependencies": {
"@autorest/core": "~3.6.2", "@autorest/core": "~3.6.3",
"autorest": "~3.4.0", "autorest": "~3.4.0",
"source-map-support": "^0.5.19" "source-map-support": "^0.5.19"
}, },

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

@ -1,6 +1,18 @@
{ {
"name": "@autorest/compare", "name": "@autorest/compare",
"entries": [ "entries": [
{
"version": "0.4.2",
"tag": "@autorest/compare_v0.4.2",
"date": "Wed, 22 Sep 2021 20:33:38 GMT",
"comments": {
"patch": [
{
"comment": "**Fix** Issue when parsing parameter with public/private and default value"
}
]
}
},
{ {
"version": "0.4.1", "version": "0.4.1",
"tag": "@autorest/compare_v0.4.1", "tag": "@autorest/compare_v0.4.1",

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

@ -1,6 +1,13 @@
# Change Log - @autorest/compare # Change Log - @autorest/compare
This log was last generated on Wed, 08 Sep 2021 15:39:22 GMT and should not be manually modified. This log was last generated on Wed, 22 Sep 2021 20:33:38 GMT and should not be manually modified.
## 0.4.2
Wed, 22 Sep 2021 20:33:38 GMT
### Patches
- **Fix** Issue when parsing parameter with public/private and default value
## 0.4.1 ## 0.4.1
Wed, 08 Sep 2021 15:39:22 GMT Wed, 08 Sep 2021 15:39:22 GMT

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

@ -1,6 +1,6 @@
{ {
"name": "@autorest/compare", "name": "@autorest/compare",
"version": "0.4.1", "version": "0.4.2",
"description": "Compares the output between two AutoRest runs to check for material differences.", "description": "Compares the output between two AutoRest runs to check for material differences.",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {

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

@ -108,10 +108,7 @@ function extractField(fieldNode: Parser.SyntaxNode): FieldDetails {
} }
function extractParameter(parameterNode: Parser.SyntaxNode, ordinal: number): ParameterDetails { function extractParameter(parameterNode: Parser.SyntaxNode, ordinal: number): ParameterDetails {
const children = const { nameNode, typeNode } = parseParameterNode(parameterNode);
parameterNode.namedChildren.length === 3 ? parameterNode.namedChildren.slice(1) : parameterNode.namedChildren;
const [nameNode, typeNode] = children;
return { return {
name: nameNode.text, name: nameNode.text,
type: typeNode ? typeNode.children[1].text : "any", type: typeNode ? typeNode.children[1].text : "any",
@ -120,6 +117,23 @@ function extractParameter(parameterNode: Parser.SyntaxNode, ordinal: number): Pa
}; };
} }
function parseParameterNode(parameterNode: Parser.SyntaxNode) {
// For private options: MyType;
if (parameterNode.namedChildren.length === 3) {
const [accessibility, nameNode, typeNode] = parameterNode.namedChildren;
return { nameNode, typeNode };
}
// For private options: MyType = initialValue;
if (parameterNode.namedChildren.length === 4) {
const [accessibility, nameNode, typeNode, value] = parameterNode.namedChildren;
return { nameNode, typeNode };
}
// For options: MyType;
const [nameNode, typeNode] = parameterNode.namedChildren;
return { nameNode, typeNode };
}
function extractGenericParameter(genericParamNode: Parser.SyntaxNode, ordinal: number): GenericTypeParameterDetails { function extractGenericParameter(genericParamNode: Parser.SyntaxNode, ordinal: number): GenericTypeParameterDetails {
return { return {
name: genericParamNode.namedChildren[0].text, name: genericParamNode.namedChildren[0].text,

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

@ -9,6 +9,6 @@
"url": "https://github.com/Azure/autorest/issues" "url": "https://github.com/Azure/autorest/issues"
}, },
"devDependencies": { "devDependencies": {
"@microsoft.azure/autorest.testserver": "^3.0.21" "@microsoft.azure/autorest.testserver": "^3.0.40"
} }
} }

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

@ -62,27 +62,26 @@ languages:
- language: python - language: python
outputPath: ./output/python outputPath: ./output/python
oldArgs: oldArgs:
- --version:3.3.2 - --version:3.6.2
- --use:@autorest/modelerfour@4.18.4 - --use:@autorest/modelerfour@4.21.1
- --use:@autorest/python@5.7.0 - --use:@autorest/python@5.8.4
- --modelerfour.treat-type-object-as-anything - --modelerfour.treat-type-object-as-anything
newArgs: newArgs:
- --version:../packages/extensions/core - --version:../packages/extensions/core
- --use:../packages/extensions/modelerfour - --use:../packages/extensions/modelerfour
- --use:@autorest/python@5.7.0 - --use:@autorest/python@5.8.4
- --modelerfour.treat-type-object-as-anything - --modelerfour.treat-type-object-as-anything
- --modelerfour.seal-single-value-enum-by-default
- language: typescript - language: typescript
outputPath: ./output/typescript outputPath: ./output/typescript
oldArgs: oldArgs:
- --v3 - --v3
- --version:3.3.2 - --version:3.6.2
- --use:@autorest/modelerfour@4.18.4 - --use:@autorest/modelerfour@4.21.1
- --modelerfour.treat-type-object-as-anything - --modelerfour.treat-type-object-as-anything
- --package-name:test-package - --package-name:test-package
- --title:TestClient - --title:TestClient
- --use:@autorest/typescript@6.0.0-beta.5 - --use:@autorest/typescript@6.0.0-beta.13
newArgs: newArgs:
- --v3 - --v3
- --version:../packages/extensions/core - --version:../packages/extensions/core
@ -90,5 +89,4 @@ languages:
- --modelerfour.treat-type-object-as-anything - --modelerfour.treat-type-object-as-anything
- --package-name:test-package - --package-name:test-package
- --title:TestClient - --title:TestClient
- --modelerfour.seal-single-value-enum-by-default - --use:@autorest/typescript@6.0.0-beta.13
- --use:@autorest/typescript@6.0.0-beta.5