How to use autorest - 10 common examples

To help you get started, we’ve selected a few autorest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / autorest / src / autorest / app.ts View on Github external
.option("force", {
    describe: "force the re-installation of the **autorest-core** extension and frameworks",
    type: "boolean",
    group: "### Installation",
  })
  .option("version", {
    describe: "use the specified version of the **autorest-core** extension",
    type: "string",
    group: "### Installation",
  })
  .argv;

const preview: boolean = args.preview;
const home: string = process.env["autorest.home"] || homedir();
process.env["autorest.home"] = home;
console.trace(`Autorest Home folder: ${process.env["autorest.home"]}`);
const rootFolder: string = join(home, ".autorest");
const dotnetFolder: string = join(home, ".dotnet");

const basePkgVersion = pkgVersion.indexOf("-") > -1 ? pkgVersion.substring(0, pkgVersion.indexOf("-")) : pkgVersion;
const maxPkgVersion = `${semver.major(basePkgVersion) + 1}.0.0`

const corePackage = "@microsoft.azure/autorest-core"; // autorest-core"
const versionRange = preview ? `>=${basePkgVersion}-any <${maxPkgVersion}` : `>=${basePkgVersion} <${maxPkgVersion}`; // the version range of the core package required.
const extensionManager: Promise = ExtensionManager.Create(rootFolder);

let currentVersion: Extension = null;
const frameworkVersion: string = null;

let requestedVersion: string = args.version || (args.latest && "latest") || "latest-installed";
const showInfo: boolean = args.autorest["show-info"] || false;
const listAvailable: boolean = args.autorest["list-available"] || false;
github Azure / autorest / src / autorest / app.ts View on Github external
group: "### Installation",
  })
  .option("force", {
    describe: "force the re-installation of the **autorest-core** extension and frameworks",
    type: "boolean",
    group: "### Installation",
  })
  .option("version", {
    describe: "use the specified version of the **autorest-core** extension",
    type: "string",
    group: "### Installation",
  })
  .argv;

const preview: boolean = args.preview;
const home: string = process.env["autorest.home"] || homedir();
process.env["autorest.home"] = home;
console.trace(`Autorest Home folder: ${process.env["autorest.home"]}`);
const rootFolder: string = join(home, ".autorest");
const dotnetFolder: string = join(home, ".dotnet");

const basePkgVersion = pkgVersion.indexOf("-") > -1 ? pkgVersion.substring(0, pkgVersion.indexOf("-")) : pkgVersion;
const maxPkgVersion = `${semver.major(basePkgVersion) + 1}.0.0`

const corePackage = "@microsoft.azure/autorest-core"; // autorest-core"
const versionRange = preview ? `>=${basePkgVersion}-any <${maxPkgVersion}` : `>=${basePkgVersion} <${maxPkgVersion}`; // the version range of the core package required.
const extensionManager: Promise = ExtensionManager.Create(rootFolder);

let currentVersion: Extension = null;
const frameworkVersion: string = null;

let requestedVersion: string = args.version || (args.latest && "latest") || "latest-installed";
github microsoft / vscode-azuretools / kudu / gulpfile.js View on Github external
async function build() {
    // use local version of autorest extensions instead of global machine versions
    await autorest.initialize("./node_modules/@microsoft.azure/autorest-core");

    const autorestInstance = await autorest.create();
    autorestInstance.AddConfiguration({
        "nodejs": {
            "package-name": "vscode-azurekudu",
            "license-header": "MICROSOFT_MIT_NO_VERSION",
            "add-credentials": "true",
        },
        "title": "KuduClient",
        "input-file": path.join(__dirname, 'swagger.json')
    });
    autorestInstance.Message.Subscribe((_, msg) => {
        if (msg.Channel !== 'file' && msg.Text) {
            console.log(msg.FormattedMessage || msg.Text);
        }
    });
    autorestInstance.GeneratedFile.Subscribe((_, file) => {
        if (file.uri.includes('lib')) {
github microsoft / vscode-azuretools / kudu / gulpfile.js View on Github external
async function build() {
    // use local version of autorest extensions instead of global machine versions
    await autorest.initialize("./node_modules/@microsoft.azure/autorest-core");

    const autorestInstance = await autorest.create();
    autorestInstance.AddConfiguration({
        "nodejs": {
            "package-name": "vscode-azurekudu",
            "license-header": "MICROSOFT_MIT_NO_VERSION",
            "add-credentials": "true",
        },
        "title": "KuduClient",
        "input-file": path.join(__dirname, 'swagger.json')
    });
    autorestInstance.Message.Subscribe((_, msg) => {
        if (msg.Channel !== 'file' && msg.Text) {
            console.log(msg.FormattedMessage || msg.Text);
        }
    });
github Azure / autorest / src / autorest / autorest-as-a-service.ts View on Github external
import { lookup } from "dns";
import { Extension, ExtensionManager } from "@microsoft.azure/extension";
import { homedir } from "os";
import { dirname, join, resolve } from "path";
import { Enumerable as IEnumerable, From } from "linq-es2015";
import { Exception, LazyPromise } from "@microsoft.azure/polyfill";

import * as semver from "semver";
import { isFile, mkdir, isDirectory } from "@microsoft.azure/async-io";

export const pkgVersion: string = require(`${__dirname}/../package.json`).version;
const home: string = process.env["autorest.home"] || homedir();
process.env["autorest.home"] = home;

export const rootFolder: string = join(home, ".autorest");

export const extensionManager: Promise = ExtensionManager.Create(rootFolder);
export const corePackage = "@microsoft.azure/autorest-core"; // autorest-core"
const basePkgVersion = pkgVersion.indexOf("-") > -1 ? pkgVersion.substring(0, pkgVersion.indexOf("-")) : pkgVersion;
const versionRange = `^${basePkgVersion}`; // the version range of the core package required.

export const networkEnabled: Promise = new Promise((r, j) => {
  lookup("8.8.8.8", 4, (err, address, family) => {
    r(err ? false : true);
  });
});

export async function availableVersions() {
  if (await networkEnabled) {
github Azure / autorest / core / lib / autorest-core.ts View on Github external
public constructor(private fileSystem: IFileSystem = new RealFileSystem(), public configFileOrFolderUri?: string) {
    super();
    // ensure the environment variable for the home folder is set.
    process.env['autorest.home'] = process.env['autorest.home'] || homedir();
  }
github Azure / autorest / src / autorest / autorest-as-a-service.ts View on Github external
import { lookup } from "dns";
import { Extension, ExtensionManager } from "@microsoft.azure/extension";
import { homedir } from "os";
import { dirname, join, resolve } from "path";
import { Enumerable as IEnumerable, From } from "linq-es2015";
import { Exception, LazyPromise } from "@microsoft.azure/polyfill";

import * as semver from "semver";
import { isFile, mkdir, isDirectory } from "@microsoft.azure/async-io";

export const pkgVersion: string = require(`${__dirname}/../package.json`).version;
const home: string = process.env["autorest.home"] || homedir();
process.env["autorest.home"] = home;

export const rootFolder: string = join(home, ".autorest");

export const extensionManager: Promise = ExtensionManager.Create(rootFolder);
export const corePackage = "@microsoft.azure/autorest-core"; // autorest-core"
const basePkgVersion = pkgVersion.indexOf("-") > -1 ? pkgVersion.substring(0, pkgVersion.indexOf("-")) : pkgVersion;
const versionRange = `^${basePkgVersion}`; // the version range of the core package required.

export const networkEnabled: Promise = new Promise((r, j) => {
  lookup("8.8.8.8", 4, (err, address, family) => {
    r(err ? false : true);
  });
});

export async function availableVersions() {
github Azure / autorest / src / vscode-autorest / server / document-context.ts View on Github external
public async Activate(): Promise {
    // tell autorest that it's view needs to be re-created.
    this.Manager.verbose(`Invalidating Autorest view.`);
    this.autorest.Invalidate();

    // if there is a process() running, kill it. 
    this.cancel();

    // reaquire the config file.
    this.autorest.configFileUri = await AutoRest.DetectConfigurationFile(this, this.RootUri);

    // if autorest is about to restart the work, stop that
    // so we can push it out a bit more.
    if (this._readyToRun) {
      clearTimeout(this._readyToRun);
      this._readyToRun = null;
    }
    return await this.RunAutoRest();
  }
github Azure / autorest / src / vscode-autorest / server / document-context.ts View on Github external
public get autorest(): AutoRest {
    if (!this._autoRest) {
      this._autoRest = new AutoRest(this, this.configurationFile);
      this._autoRest.AddConfiguration({ "output-artifact": ["swagger-document", "swagger-document.map"] });

      this.Manager.listenForResults(this._autoRest);
      this.autorest.GeneratedFile.Subscribe((instance, artifact) => {
        this._outputs.set(artifact.uri, artifact.content);
      })
      this._autoRest.Finished.Subscribe((autorest, success) => {
        this.cancel = () => true;

        if (success) {
          this.FlushDiagnostics(true);
          this.ClearDiagnostics();
        }
        this.Manager.verbose(`AutoRest Process Finished with '${success}'.`);
      })
    }
github Azure / autorest / src / vscode-autorest / server / document-context.ts View on Github external
        yield* From(items).Where(each => AutoRest.IsConfigurationExtension(GetExtension(each))).Select(each => ResolveUri(folderUri, each));
      }

autorest

The AutoRest tool generates client libraries for accessing RESTful web services. Input to AutoRest is an OpenAPI spec that describes the REST API.

MIT
Latest version published 1 year ago

Package Health Score

81 / 100
Full package analysis