зеркало из https://github.com/Azure/autorest.git
Merge branch 'release/3.6.x' of https://github.com/Azure/autorest into main
This commit is contained in:
Коммит
9d3554b656
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@autorest/core",
|
||||
"comment": "",
|
||||
"type": "none"
|
||||
}
|
||||
],
|
||||
"packageName": "@autorest/core",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -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;
|
|
@ -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",
|
||||
|
@ -41,7 +44,7 @@
|
|||
"typings": "./dist/exports.d.ts",
|
||||
"devDependencies": {
|
||||
"@autorest/configuration": "~1.7.2",
|
||||
"@autorest/core": "~3.6.4",
|
||||
"@autorest/core": "~3.6.5",
|
||||
"@autorest/common": "~1.3.0",
|
||||
"@azure-tools/async-io": "~3.0.0",
|
||||
"@azure-tools/extension": "~3.3.1",
|
||||
|
|
|
@ -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
|
|
@ -1,6 +1,18 @@
|
|||
{
|
||||
"name": "@autorest/core",
|
||||
"entries": [
|
||||
{
|
||||
"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",
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
# Change Log - @autorest/core
|
||||
|
||||
This log was last generated on Tue, 05 Oct 2021 16:39:50 GMT and should not be manually modified.
|
||||
This log was last generated on Wed, 06 Oct 2021 17:36:17 GMT and should not be manually modified.
|
||||
|
||||
## 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@autorest/core",
|
||||
"version": "3.6.4",
|
||||
"version": "3.6.5",
|
||||
"description": "AutoRest core module",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
|
|
|
@ -100,8 +100,6 @@ csharp:
|
|||
);
|
||||
}
|
||||
|
||||
let exitcode = 0;
|
||||
|
||||
let cleared = false;
|
||||
async function doClearFolders(protectFiles: Set<string>, clearFolders: Set<string>, logger: IAutorestLogger) {
|
||||
if (!cleared) {
|
||||
|
@ -196,7 +194,7 @@ async function currentMain(logger: IAutorestLogger, args: AutorestCliArgs): Prom
|
|||
}
|
||||
logger.info("Generation Complete");
|
||||
// return the exit code to the caller.
|
||||
return exitcode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function shallowMerge(existing: any, more: any) {
|
||||
|
@ -240,6 +238,7 @@ async function resourceSchemaBatch(api: AutoRest, logger: IAutorestLogger): Prom
|
|||
|
||||
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")) {
|
||||
|
@ -248,7 +247,7 @@ async function resourceSchemaBatch(api: AutoRest, logger: IAutorestLogger): Prom
|
|||
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;
|
||||
}
|
||||
|
@ -289,7 +288,7 @@ async function resourceSchemaBatch(api: AutoRest, logger: IAutorestLogger): Prom
|
|||
// ok, kick off the process for that one.
|
||||
await instance.Process().finish.then(async (result) => {
|
||||
if (result !== true) {
|
||||
exitcode++;
|
||||
exitCode++;
|
||||
throw result;
|
||||
}
|
||||
});
|
||||
|
@ -298,7 +297,7 @@ async function resourceSchemaBatch(api: AutoRest, logger: IAutorestLogger): Prom
|
|||
|
||||
await outstanding;
|
||||
|
||||
return exitcode;
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
async function batch(api: AutoRest, logger: IAutorestLogger): Promise<void> {
|
||||
|
@ -342,6 +341,7 @@ async function main() {
|
|||
try {
|
||||
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) {
|
||||
|
@ -360,7 +360,7 @@ async function main() {
|
|||
} finally {
|
||||
logger.debug("Exiting.");
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(exitcode);
|
||||
process.exit(exitCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/Azure/autorest#readme",
|
||||
"dependencies": {
|
||||
"@autorest/core": "~3.6.4",
|
||||
"@autorest/core": "~3.6.5",
|
||||
"autorest": "~3.4.1",
|
||||
"source-map-support": "^0.5.19"
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче