зеркало из https://github.com/Azure/autorest.az.git
Коммит
b2f7de368e
15
README.md
15
README.md
|
@ -5,21 +5,32 @@ See documentation [here](doc/00-overview.md)
|
|||
``` yaml
|
||||
use-extension:
|
||||
"@autorest/cli.common": "latest"
|
||||
"@autorest/fakesdk": "/home/qiaozha/code/fakesdk"
|
||||
"az": "$(this-folder)"
|
||||
|
||||
pipeline-model: v3
|
||||
clicommon: true
|
||||
fakesdk123: true
|
||||
pipeline:
|
||||
az:
|
||||
input: fakesdk
|
||||
output-artifact: source-file-fakesdk-inaz
|
||||
az/aznamer:
|
||||
plugin: fakenamer
|
||||
input: cli.common
|
||||
output-artifact: source-file-cli
|
||||
|
||||
az/renamer:
|
||||
input: az/aznamer
|
||||
output-artifact: source-file-cli
|
||||
az/emitter:
|
||||
input: az
|
||||
input:
|
||||
- az
|
||||
- az/renamer
|
||||
scope: scope-here
|
||||
|
||||
scope-here:
|
||||
is-object: false
|
||||
output-artifact:
|
||||
- source-file-cli
|
||||
- source-file-fakesdk-inaz
|
||||
```
|
||||
|
|
|
@ -5,6 +5,20 @@ variables:
|
|||
NodeVersion: '10.x'
|
||||
|
||||
jobs:
|
||||
- job: Linter
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- task: TSLint@1
|
||||
inputs:
|
||||
RuleLibrary: 'tslint'
|
||||
Ruleset: 'tsrecommended'
|
||||
FileSelectionType: 'fileGlob'
|
||||
Files: '**\*.ts'
|
||||
OutputFormat: 'json'
|
||||
ToolVersion: 'latest'
|
||||
TypeScriptVersion: 'latest'
|
||||
|
||||
- job: 'Build'
|
||||
|
||||
pool:
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
"dependencies": {
|
||||
"@autorest/modelerfour": "^4.1.60",
|
||||
"@azure-tools/autorest-extension-base": "~3.1.0",
|
||||
"@microsoft.azure/autorest.python": "^3.0.52",
|
||||
"node-yaml": "^3.2.0"
|
||||
},
|
||||
"files": [
|
||||
|
|
86
src/index.ts
86
src/index.ts
|
@ -6,6 +6,92 @@ export type FileCallback = (path: string, rows: string[]) => void;
|
|||
|
||||
const extension = new AutoRestExtension();
|
||||
|
||||
extension.Add("aznamer", async autoRestApi => {
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// read files offered to this plugin
|
||||
const inputFileUris = await autoRestApi.ListInputs();
|
||||
|
||||
const inputFiles: string[] = await Promise.all(inputFileUris.map(uri => autoRestApi.ReadFile(uri)));
|
||||
|
||||
// read a setting
|
||||
|
||||
const isDebugFlagSet = await autoRestApi.GetValue("debug");
|
||||
let azSettings = await autoRestApi.GetValue("az");
|
||||
|
||||
|
||||
// emit messages
|
||||
|
||||
autoRestApi.Message({
|
||||
Channel: Channel.Warning,
|
||||
Text: "Hello World az namer ! The `debug` flag is " + (isDebugFlagSet ? "set" : "not set"),
|
||||
});
|
||||
|
||||
autoRestApi.Message({
|
||||
Channel: Channel.Warning,
|
||||
Text: "az namer settings " + JSON.stringify(azSettings)
|
||||
});
|
||||
|
||||
autoRestApi.Message({
|
||||
Channel: Channel.Information,
|
||||
Text: "AutoRest offers the following input files: " + inputFileUris.join(", "),
|
||||
});
|
||||
|
||||
// emit a file (all input files concatenated)
|
||||
|
||||
autoRestApi.WriteFile("myfolder/az-namer.txt", inputFiles.join("\n---\n"));
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Error(e.message + " -- " + JSON.stringify(e.stack));
|
||||
}
|
||||
});
|
||||
|
||||
extension.Add("renamer", async autoRestApi => {
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// read files offered to this plugin
|
||||
const inputFileUris = await autoRestApi.ListInputs();
|
||||
|
||||
const inputFiles: string[] = await Promise.all(inputFileUris.map(uri => autoRestApi.ReadFile(uri)));
|
||||
|
||||
// read a setting
|
||||
|
||||
const isDebugFlagSet = await autoRestApi.GetValue("debug");
|
||||
let azSettings = await autoRestApi.GetValue("az");
|
||||
|
||||
|
||||
// emit messages
|
||||
|
||||
autoRestApi.Message({
|
||||
Channel: Channel.Warning,
|
||||
Text: "Hello World az renamer ! The `debug` flag is " + (isDebugFlagSet ? "set" : "not set"),
|
||||
});
|
||||
|
||||
autoRestApi.Message({
|
||||
Channel: Channel.Warning,
|
||||
Text: "az renamer settings " + JSON.stringify(azSettings)
|
||||
});
|
||||
|
||||
autoRestApi.Message({
|
||||
Channel: Channel.Information,
|
||||
Text: "AutoRest offers the following input files: " + inputFileUris.join(", "),
|
||||
});
|
||||
|
||||
// emit a file (all input files concatenated)
|
||||
|
||||
autoRestApi.WriteFile("myfolder/az-renamer.txt", inputFiles.join("\n---\n"));
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Error(e.message + " -- " + JSON.stringify(e.stack));
|
||||
}
|
||||
});
|
||||
|
||||
extension.Add("az", async autoRestApi => {
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче