* debugger

* cleanup

* cu
This commit is contained in:
Johannes Bader 2017-08-31 16:09:22 -07:00 коммит произвёл GitHub
Родитель 387a2bd045
Коммит fe3ad548ff
5 изменённых файлов: 8 добавлений и 59 удалений

Просмотреть файл

@ -396,7 +396,6 @@ Import module.exports
############################################### ###############################################
# Global values # Global values
process.env["autorest.home"] = path.normalize("#{os.tmpdir()}/autorest#{hashCode(basefolder)}")
process.env.tmp = process.env.tmp or "#{basefolder}/tmp" process.env.tmp = process.env.tmp or "#{basefolder}/tmp"
package_json = require("#{basefolder}/package.json") package_json = require("#{basefolder}/package.json")
@ -408,7 +407,6 @@ Import
github_apikey: argv.github_apikey or process.env.GITHUB_APIKEY or null github_apikey: argv.github_apikey or process.env.GITHUB_APIKEY or null
nuget_apikey: argv.nuget_apikey or process.env.NUGET_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 npm_apikey: argv.npm_apikey or process.env.NPM_APIKEY or null
autorest_home: process.env["autorest.home"]
today: moment().format('YYYYMMDD') today: moment().format('YYYYMMDD')
now: moment().format('YYYYMMDD-HHmm') now: moment().format('YYYYMMDD-HHmm')
force: argv.force or false force: argv.force or false

Просмотреть файл

@ -17,7 +17,7 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio
``` yaml ``` yaml
use-extension: 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: pipeline:
azureresourceschema/modeler: azureresourceschema/modeler:

Просмотреть файл

@ -1,6 +1,6 @@
{ {
"name": "@microsoft.azure/autorest.azureresourceschema", "name": "@microsoft.azure/autorest.azureresourceschema",
"version": "1.9.5", "version": "1.9.6",
"description": "The Azure Resource Schema extension for classic generators in AutoRest.", "description": "The Azure Resource Schema extension for classic generators in AutoRest.",
"scripts": { "scripts": {
"start": "dotnet src/bin/netcoreapp2.0/autorest.azureresourceschema.dll --server", "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", "homepage": "https://github.com/Azure/autorest.azureresourceschema/blob/master/README.md",
"devDependencies": { "devDependencies": {
"@microsoft.azure/autorest.modeler": "1.9.4", "@microsoft.azure/autorest.modeler": "1.9.6",
"coffee-script": "^1.11.1", "coffee-script": "^1.11.1",
"dotnet-sdk-2.0.0": "^1.1.1", "dotnet-sdk-2.0.0": "^1.1.1",
"gulp": "^3.9.1", "gulp": "^3.9.1",

Просмотреть файл

@ -46,12 +46,7 @@ namespace AutoRest.AzureResourceSchema
return 1; return 1;
} }
private string plugin; public Program(Connection connection, string plugin, string sessionId) : base(connection, plugin, sessionId) { }
public Program(Connection connection, string plugin, string sessionId) : base(connection, sessionId)
{
this.plugin = plugin;
}
private T GetXmsCodeGenSetting<T>(CodeModel codeModel, string name) private T GetXmsCodeGenSetting<T>(CodeModel codeModel, string name)
{ {
@ -70,8 +65,6 @@ namespace AutoRest.AzureResourceSchema
protected override async Task<bool> ProcessInternal() protected override async Task<bool> ProcessInternal()
{ {
var codeGenerator = this.plugin;
var files = await ListInputs(); var files = await ListInputs();
if (files.Length != 1) if (files.Length != 1)
{ {
@ -80,20 +73,6 @@ namespace AutoRest.AzureResourceSchema
var modelAsJson = (await ReadFile(files[0])).EnsureYamlIsJson(); var modelAsJson = (await ReadFile(files[0])).EnsureYamlIsJson();
var codeModelT = new ModelSerializer<CodeModel>().Load(modelAsJson); 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 // build settings
var altNamespace = (await GetValue<string[]>("input-file") ?? new[] { "" }).FirstOrDefault()?.Split('/').Last().Split('\\').Last().Split('.').First(); 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("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.Add("UseDateTimeOffset", GetXmsCodeGenSetting<bool?>(codeModelT, "useDateTimeOffset") ?? await GetValue<bool?>("use-datetimeoffset") ?? false);
Settings.Instance.CustomSettings["ClientSideValidation"] = await GetValue<bool?>("client-side-validation") ?? 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") ?? Settings.DefaultMaximumCommentColumns;
Settings.Instance.MaximumCommentColumns = await GetValue<int?>("max-comment-columns") ?? defaultMaximumCommentColumns;
Settings.Instance.OutputFileName = await GetValue<string>("output-file"); 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 // process
var plugin = ExtensionsLoader.GetPlugin( var plugin = new AutoRest.AzureResourceSchema.PluginArs();
(await GetValue<bool?>("azure-arm") ?? false ? "Azure." : "") +
language +
(await GetValue<bool?>("fluent") ?? false ? ".Fluent" : "") +
(await GetValue<bool?>("testgen") ?? false ? ".TestGen" : ""));
Settings.PopulateSettings(plugin.Settings, Settings.Instance.CustomSettings); Settings.PopulateSettings(plugin.Settings, Settings.Instance.CustomSettings);
using (plugin.Activate()) using (plugin.Activate())
@ -147,14 +105,7 @@ namespace AutoRest.AzureResourceSchema
Settings.Instance.Namespace = Settings.Instance.Namespace ?? CodeNamer.Instance.GetNamespaceName(altNamespace); Settings.Instance.Namespace = Settings.Instance.Namespace ?? CodeNamer.Instance.GetNamespaceName(altNamespace);
var codeModel = plugin.Serializer.Load(modelAsJson); var codeModel = plugin.Serializer.Load(modelAsJson);
codeModel = plugin.Transformer.TransformCodeModel(codeModel); codeModel = plugin.Transformer.TransformCodeModel(codeModel);
if (await GetValue<bool?>("sample-generation") ?? false) plugin.CodeGenerator.Generate(codeModel).GetAwaiter().GetResult();
{
plugin.CodeGenerator.GenerateSamples(codeModel).GetAwaiter().GetResult();
}
else
{
plugin.CodeGenerator.Generate(codeModel).GetAwaiter().GetResult();
}
} }
// write out files // write out files

Просмотреть файл

@ -61,7 +61,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="YamlDotNet.Signed" Version="4.2.1" /> <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" /> --> <!-- <ProjectReference Include="../../autorest.common/src/autorest.common.csproj" /> -->
</ItemGroup> </ItemGroup>