Родитель
387a2bd045
Коммит
fe3ad548ff
|
@ -396,7 +396,6 @@ Import module.exports
|
|||
|
||||
###############################################
|
||||
# Global values
|
||||
process.env["autorest.home"] = path.normalize("#{os.tmpdir()}/autorest#{hashCode(basefolder)}")
|
||||
process.env.tmp = process.env.tmp or "#{basefolder}/tmp"
|
||||
|
||||
package_json = require("#{basefolder}/package.json")
|
||||
|
@ -408,7 +407,6 @@ Import
|
|||
github_apikey: argv.github_apikey or process.env.GITHUB_APIKEY or null
|
||||
nuget_apikey: argv.nuget_apikey or process.env.NUGET_APIKEY or null
|
||||
npm_apikey: argv.npm_apikey or process.env.NPM_APIKEY or null
|
||||
autorest_home: process.env["autorest.home"]
|
||||
today: moment().format('YYYYMMDD')
|
||||
now: moment().format('YYYYMMDD-HHmm')
|
||||
force: argv.force or false
|
||||
|
|
|
@ -17,7 +17,7 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio
|
|||
|
||||
``` yaml
|
||||
use-extension:
|
||||
"@microsoft.azure/autorest.modeler": "1.9.4" # keep in sync with package.json's dev dependency in order to have meaningful tests
|
||||
"@microsoft.azure/autorest.modeler": "1.9.6" # keep in sync with package.json's dev dependency in order to have meaningful tests
|
||||
|
||||
pipeline:
|
||||
azureresourceschema/modeler:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@microsoft.azure/autorest.azureresourceschema",
|
||||
"version": "1.9.5",
|
||||
"version": "1.9.6",
|
||||
"description": "The Azure Resource Schema extension for classic generators in AutoRest.",
|
||||
"scripts": {
|
||||
"start": "dotnet src/bin/netcoreapp2.0/autorest.azureresourceschema.dll --server",
|
||||
|
@ -27,7 +27,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/Azure/autorest.azureresourceschema/blob/master/README.md",
|
||||
"devDependencies": {
|
||||
"@microsoft.azure/autorest.modeler": "1.9.4",
|
||||
"@microsoft.azure/autorest.modeler": "1.9.6",
|
||||
"coffee-script": "^1.11.1",
|
||||
"dotnet-sdk-2.0.0": "^1.1.1",
|
||||
"gulp": "^3.9.1",
|
||||
|
|
|
@ -46,12 +46,7 @@ namespace AutoRest.AzureResourceSchema
|
|||
return 1;
|
||||
}
|
||||
|
||||
private string plugin;
|
||||
|
||||
public Program(Connection connection, string plugin, string sessionId) : base(connection, sessionId)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public Program(Connection connection, string plugin, string sessionId) : base(connection, plugin, sessionId) { }
|
||||
|
||||
private T GetXmsCodeGenSetting<T>(CodeModel codeModel, string name)
|
||||
{
|
||||
|
@ -70,8 +65,6 @@ namespace AutoRest.AzureResourceSchema
|
|||
|
||||
protected override async Task<bool> ProcessInternal()
|
||||
{
|
||||
var codeGenerator = this.plugin;
|
||||
|
||||
var files = await ListInputs();
|
||||
if (files.Length != 1)
|
||||
{
|
||||
|
@ -80,20 +73,6 @@ namespace AutoRest.AzureResourceSchema
|
|||
var modelAsJson = (await ReadFile(files[0])).EnsureYamlIsJson();
|
||||
var codeModelT = new ModelSerializer<CodeModel>().Load(modelAsJson);
|
||||
|
||||
// get internal name
|
||||
var language = new[] {
|
||||
"CSharp",
|
||||
"Ruby",
|
||||
"NodeJS",
|
||||
"Python",
|
||||
"Go",
|
||||
"Php",
|
||||
"Java",
|
||||
"AzureResourceSchema",
|
||||
"JsonRpcClient" }
|
||||
.Where(x => x.ToLowerInvariant() == codeGenerator)
|
||||
.First();
|
||||
|
||||
// build settings
|
||||
var altNamespace = (await GetValue<string[]>("input-file") ?? new[] { "" }).FirstOrDefault()?.Split('/').Last().Split('\\').Last().Split('.').First();
|
||||
|
||||
|
@ -114,32 +93,11 @@ namespace AutoRest.AzureResourceSchema
|
|||
Settings.Instance.CustomSettings.Add("SyncMethods", GetXmsCodeGenSetting<string>(codeModelT, "syncMethods") ?? await GetValue("sync-methods") ?? "essential");
|
||||
Settings.Instance.CustomSettings.Add("UseDateTimeOffset", GetXmsCodeGenSetting<bool?>(codeModelT, "useDateTimeOffset") ?? await GetValue<bool?>("use-datetimeoffset") ?? false);
|
||||
Settings.Instance.CustomSettings["ClientSideValidation"] = await GetValue<bool?>("client-side-validation") ?? false;
|
||||
int defaultMaximumCommentColumns = codeGenerator == "go" ? 120 : Settings.DefaultMaximumCommentColumns;
|
||||
Settings.Instance.MaximumCommentColumns = await GetValue<int?>("max-comment-columns") ?? defaultMaximumCommentColumns;
|
||||
Settings.Instance.MaximumCommentColumns = await GetValue<int?>("max-comment-columns") ?? Settings.DefaultMaximumCommentColumns;
|
||||
Settings.Instance.OutputFileName = await GetValue<string>("output-file");
|
||||
if (codeGenerator == "csharp")
|
||||
{
|
||||
Settings.Instance.Header = $"<auto-generated>\n{Settings.Instance.Header}\n</auto-generated>";
|
||||
}
|
||||
if (codeGenerator == "ruby" || codeGenerator == "python")
|
||||
{
|
||||
// TODO: sort out matters here entirely instead of relying on Input being read somewhere...
|
||||
var inputFile = await GetValue<string[]>("input-file");
|
||||
Settings.Instance.Input = inputFile.FirstOrDefault();
|
||||
Settings.Instance.PackageName = await GetValue("package-name");
|
||||
Settings.Instance.PackageVersion = await GetValue("package-version");
|
||||
}
|
||||
if (codeGenerator == "go")
|
||||
{
|
||||
Settings.Instance.PackageVersion = await GetValue("package-version");
|
||||
}
|
||||
|
||||
// process
|
||||
var plugin = ExtensionsLoader.GetPlugin(
|
||||
(await GetValue<bool?>("azure-arm") ?? false ? "Azure." : "") +
|
||||
language +
|
||||
(await GetValue<bool?>("fluent") ?? false ? ".Fluent" : "") +
|
||||
(await GetValue<bool?>("testgen") ?? false ? ".TestGen" : ""));
|
||||
var plugin = new AutoRest.AzureResourceSchema.PluginArs();
|
||||
Settings.PopulateSettings(plugin.Settings, Settings.Instance.CustomSettings);
|
||||
|
||||
using (plugin.Activate())
|
||||
|
@ -147,15 +105,8 @@ namespace AutoRest.AzureResourceSchema
|
|||
Settings.Instance.Namespace = Settings.Instance.Namespace ?? CodeNamer.Instance.GetNamespaceName(altNamespace);
|
||||
var codeModel = plugin.Serializer.Load(modelAsJson);
|
||||
codeModel = plugin.Transformer.TransformCodeModel(codeModel);
|
||||
if (await GetValue<bool?>("sample-generation") ?? false)
|
||||
{
|
||||
plugin.CodeGenerator.GenerateSamples(codeModel).GetAwaiter().GetResult();
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.CodeGenerator.Generate(codeModel).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
// write out files
|
||||
var outFS = Settings.Instance.FileSystemOutput;
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||
<PackageReference Include="YamlDotNet.Signed" Version="4.2.1" />
|
||||
<PackageReference Include="autorest.common" Version="2.1.14" />
|
||||
<PackageReference Include="autorest.common" Version="2.2.18" />
|
||||
<!-- <ProjectReference Include="../../autorest.common/src/autorest.common.csproj" /> -->
|
||||
</ItemGroup>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче