This commit is contained in:
Timothee Guerin 2021-10-05 10:58:18 -07:00 коммит произвёл GitHub
Родитель b0c66762f8
Коммит bf1ff432b9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 123 добавлений и 96 удалений

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

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

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

@ -1,6 +1,18 @@
{
"name": "autorest",
"entries": [
{
"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",

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

@ -1,6 +1,13 @@
# Change Log - autorest
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 Tue, 05 Oct 2021 17:04:21 GMT and should not be manually modified.
## 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

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

@ -1,6 +1,6 @@
{
"name": "autorest",
"version": "3.4.0",
"version": "3.4.1",
"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"
@ -41,7 +41,7 @@
"typings": "./dist/exports.d.ts",
"devDependencies": {
"@autorest/configuration": "~1.7.2",
"@autorest/core": "~3.6.3",
"@autorest/core": "~3.6.4",
"@autorest/common": "~1.3.0",
"@azure-tools/async-io": "~3.0.0",
"@azure-tools/extension": "~3.3.1",

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

@ -9,6 +9,7 @@ import "source-map-support/register";
declare const isDebuggerEnabled: boolean;
const cwd = process.cwd();
import { AutorestSyncLogger, ConsoleLoggerSink } from "@autorest/common";
import chalk from "chalk";
import { clearTempData } from "./actions";
import { parseAutorestArgs } from "./args";
@ -96,7 +97,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.
@ -132,7 +141,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.

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

@ -1,5 +1,5 @@
import { dirname, join, resolve } from "path";
import { AutorestSyncLogger, ConsoleLoggerSink } from "@autorest/common";
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";
@ -33,12 +33,11 @@ const cwd = process.cwd();
* Tries to load the configuration of autorest.
* @param args CLI args.
*/
export async function loadConfig(args: AutorestArgs): Promise<AutorestConfiguration | undefined> {
export async function loadConfig(sink: LoggerSink, args: AutorestArgs): Promise<AutorestConfiguration | undefined> {
const configFileOrFolder = resolveUri(createFolderUri(cwd), args.configFileOrFolder || ".");
const enableLogging = args["debug-cli-config-loading"];
const logger = new AutorestSyncLogger({
sinks: enableLogging ? [new ConsoleLoggerSink()] : [],
sinks: enableLogging ? [sink] : [],
});
const loader = new ConfigurationLoader(logger, defaultConfigUri, configFileOrFolder, {
@ -46,12 +45,6 @@ export async function loadConfig(args: AutorestArgs): Promise<AutorestConfigurat
});
try {
const { config } = await loader.load([args], true);
if (config.version) {
// eslint-disable-next-line no-console
console.log(
chalk.yellow(`NOTE: AutoRest core version selected from configuration: ${chalk.yellow.bold(config.version)}.`),
);
}
return config;
} catch (e) {
// eslint-disable-next-line no-console

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

@ -1,6 +1,18 @@
{
"name": "@autorest/core",
"entries": [
{
"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",

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

@ -1,6 +1,13 @@
# Change Log - @autorest/core
This log was last generated on Thu, 23 Sep 2021 19:51:32 GMT and should not be manually modified.
This log was last generated on Tue, 05 Oct 2021 16:39:50 GMT and should not be manually modified.
## 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

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

@ -1,6 +1,6 @@
{
"name": "@autorest/core",
"version": "3.6.3",
"version": "3.6.4",
"description": "AutoRest core module",
"engines": {
"node": ">=12.0.0"

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

@ -14,6 +14,7 @@ import {
AutorestLogger,
AutorestSyncLogger,
Exception,
IAutorestLogger,
} from "@autorest/common";
import { AutorestCliArgs, parseAutorestCliArgs } from "@autorest/configuration";
@ -103,9 +104,9 @@ 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 {
@ -120,32 +121,7 @@ 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 args = parseAutorestCliArgs([...autorestArgs, ...more]);
const logger = new AutorestSyncLogger({
sinks: [new ConsoleLogger()],
processors: [new FilterLogger({ level: getLogLevel(args.options) })],
});
async function currentMain(logger: IAutorestLogger, args: AutorestCliArgs): Promise<number> {
if (!args.options["message-format"] || args.options["message-format"] === "regular") {
logger.info(`> Loading AutoRest core '${__dirname}' (${VERSION})`);
}
@ -202,7 +178,7 @@ async function currentMain(autorestArgs: Array<string>): Promise<number> {
}
if (context.config["batch"]) {
await batch(api, args, logger);
await batch(api, logger);
} else {
const result = await api.Process().finish;
if (result !== true) {
@ -252,12 +228,12 @@ async function currentMain(autorestArgs: Array<string>): Promise<number> {
}
} 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;
}
@ -296,7 +272,7 @@ function getRds(schema: any, path: string): Array<string> {
return result;
}
async function resourceSchemaBatch(api: AutoRest, logger: AutorestLogger): 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>();
@ -364,15 +340,12 @@ async function resourceSchemaBatch(api: AutoRest, logger: AutorestLogger): Promi
return exitcode;
}
async function batch(api: AutoRest, args: AutorestCliArgs, logger: AutorestLogger): 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";
if (!isjson) {
logger.info(`Processing batch task - ${JSON.stringify(batchTaskConfig)} .`);
}
// update batch task config section
for (const key of Object.keys(batchTaskConfigReference)) {
delete batchTaskConfigReference[key];
@ -391,61 +364,64 @@ async function batch(api: AutoRest, args: AutorestCliArgs, logger: AutorestLogge
}
}
/**
* 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) {
// 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);
}
}
}
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", () => {

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

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

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

@ -32,7 +32,7 @@
},
"homepage": "https://github.com/Azure/autorest.compare#readme",
"dependencies": {
"autorest": "~3.4.0",
"autorest": "~3.4.1",
"chalk": "^4.1.0",
"diff": "^4.0.1",
"js-yaml": "~4.0.0",