initial
This commit is contained in:
Родитель
460402d366
Коммит
e428f286bc
|
@ -1,288 +1,3 @@
|
|||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
**/Properties/launchSettings.json
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Typescript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
node_modules/
|
||||
.vscode/
|
||||
package-lock.json
|
14
README.md
14
README.md
|
@ -1,14 +0,0 @@
|
|||
|
||||
# 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.
|
|
@ -0,0 +1,31 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const autorest_extension_base_1 = require("autorest-extension-base");
|
||||
const extension = new autorest_extension_base_1.AutoRestExtension();
|
||||
extension.Add("hello-world", (autoRestApi) => __awaiter(this, void 0, void 0, function* () {
|
||||
// read files offered to this plugin
|
||||
const inputFileUris = yield autoRestApi.ListInputs();
|
||||
const inputFiles = yield Promise.all(inputFileUris.map(uri => autoRestApi.ReadFile(uri)));
|
||||
// read a setting
|
||||
const isDebugFlagSet = yield autoRestApi.GetValue("debug");
|
||||
// emit a messages
|
||||
autoRestApi.Message({
|
||||
Channel: "warning",
|
||||
Text: "Hello World! The `debug` flag is " + (isDebugFlagSet ? "set" : "not set"),
|
||||
});
|
||||
autoRestApi.Message({
|
||||
Channel: "information",
|
||||
Text: "AutoRest offers the following input files: " + inputFiles.join(", "),
|
||||
});
|
||||
// emit a file (all input files concatenated)
|
||||
autoRestApi.WriteFile("concat.txt", inputFiles.join("\n---\n"));
|
||||
}));
|
||||
extension.Run();
|
|
@ -0,0 +1,25 @@
|
|||
import { AutoRestExtension } from "autorest-extension-base";
|
||||
|
||||
const extension = new AutoRestExtension();
|
||||
|
||||
extension.Add("hello-world", async autoRestApi => {
|
||||
// read files offered to this plugin
|
||||
const inputFileUris = await autoRestApi.ListInputs();
|
||||
const inputFiles = await Promise.all(inputFileUris.map(uri => autoRestApi.ReadFile(uri)));
|
||||
// read a setting
|
||||
const isDebugFlagSet = await autoRestApi.GetValue("debug");
|
||||
|
||||
// emit a messages
|
||||
autoRestApi.Message({
|
||||
Channel: "warning",
|
||||
Text: "Hello World! The `debug` flag is " + (isDebugFlagSet ? "set" : "not set"),
|
||||
});
|
||||
autoRestApi.Message({
|
||||
Channel: "information",
|
||||
Text: "AutoRest offers the following input files: " + inputFiles.join(", "),
|
||||
});
|
||||
// emit a file (all input files concatenated)
|
||||
autoRestApi.WriteFile("concat.txt", inputFiles.join("\n---\n"));
|
||||
});
|
||||
|
||||
extension.Run();
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "autorest-extension-helloworld",
|
||||
"version": "0.1.0",
|
||||
"description": "Simple AutoRest extension",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"start": "node dist/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/olydis/autorest-extension-helloworld.git"
|
||||
},
|
||||
"keywords": [
|
||||
"autorest",
|
||||
"extension"
|
||||
],
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^7.0.18"
|
||||
},
|
||||
"dependencies": {
|
||||
"autorest-extension-base": "https://github.com/olydis/autorest-extension-base"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
# 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.
|
||||
|
||||
|
||||
# Simple AutoRest Extension
|
||||
|
||||
A simple AutoRest extension that can be used as a template for or documentation about writing such extensions.
|
||||
Since this a TypeScript project, we distinguish between language agnostic and language dependent requirements.
|
||||
|
||||
## Language Agnostic Requirements
|
||||
|
||||
More information about these can be found [here](https://github.com/Azure/autorest/tree/master/docs/developer), summary:
|
||||
|
||||
1) Specify the start command of the extension as the `start` script in the `package.json`
|
||||
2) Implement the AutoRest extension protocol (here: handled by library, see below)
|
||||
3) Hook up plugins into the AutoRest pipeline DAG, e.g.
|
||||
|
||||
``` yaml
|
||||
pipeline:
|
||||
hello-world: # <- name of plugin
|
||||
scope: hello
|
||||
# ^ will make this plugin run only when `--hello` is passed on the CLI or
|
||||
# when there is `hello: true | <some object>` in the configuration file
|
||||
|
||||
#input: swagger-document/identity
|
||||
# ^ other pipeline step to use as a predecessor in the DAG
|
||||
# takes the outputs of that step as input to this plugin.
|
||||
# If no `input` is declared here, the plugin runs immediately and gets
|
||||
# the `input-file`s of this AutoRest call as its inputs.
|
||||
|
||||
output-artifact: some-file-generated-by-hello-world
|
||||
# ^ tag that is assigned to files written out by this pipeline step
|
||||
# This allows other pipeline steps to conveniently refer to or filter out
|
||||
# all the files that this pipeline step wrote out.
|
||||
```
|
||||
|
||||
Except for emitting messages, a pipeline step has no visible effect if the files it generates are not consumed by another pipeline step.
|
||||
In the following, we add another pipeline step that consumes the output of `hello-world`.
|
||||
Specifically, we instantiate the built-in `emitter` plugin that writes files to disk or hands them to AutoRest-as-a-library consumers.
|
||||
|
||||
``` yaml
|
||||
pipeline:
|
||||
hello-world/emitter: # <- 'hello-world' is arbitrary name, 'emitter' is a plugin built into AutoRest
|
||||
input: hello-world
|
||||
# ^ predecessor to this pipeline step
|
||||
scope: scope-hello-world/emitter
|
||||
# ^ scope that defines the inputs/outputs for the emitter plugin
|
||||
|
||||
scope-hello-world/emitter:
|
||||
input-artifact: some-file-generated-by-hello-world
|
||||
output-uri-expr: $key
|
||||
# ^ JavaScript expression that can be used to alter the file name used for writing out,
|
||||
# e.g. to add an extension, enforce a certain casing, or overwrite the path altogether
|
||||
# '$key' is represents the filename (but can be any string!) assigned to a file by the emitting pipeline step
|
||||
|
||||
output-artifact: some-file-generated-by-hello-world
|
||||
# ^ cause artifacts with that tag to actually be emitted (remove this if the expectation is
|
||||
# that the customer has to explicitly ask for an artifact). For instance,
|
||||
# the built-in pipeline of AutoRest generates a number of intermediate artifacts
|
||||
# (e.g. fully resolved OpenAPI definition) that are not written out by default.
|
||||
```
|
||||
|
||||
## Language Specific Requirements: TypeScript
|
||||
|
||||
For TypeScript projects, simply import [autorest-extension-base](https://github.com/olydis/autorest-extension-base) which implements the AutoRest extension protocol and offers a simple API to register plugins.
|
||||
See [index.ts](./index.ts).
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"es2016",
|
||||
"dom"
|
||||
],
|
||||
"outDir": "dist",
|
||||
"module": "commonjs",
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"target": "es2016"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
Загрузка…
Ссылка в новой задаче