From a25d3d0d6d53361514b3f7086c591d1d16119c4f Mon Sep 17 00:00:00 2001 From: Junyi Yi Date: Mon, 16 Apr 2018 18:53:58 -0700 Subject: [PATCH] Add publish script to package the whole project. --- .gitignore | 4 ++++ DEVDOC.md | 8 ++++++++ gulpfile.js | 10 +++++++++- package.json | 7 ++++++- src/Templates/TfProviderTemplateBase.cs | 2 +- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a2c9f1f..a16bd44 100644 --- a/.gitignore +++ b/.gitignore @@ -293,3 +293,7 @@ __pycache__/ # AutoRest generated folder samples/**/generated/ + +# NPM Package +*.tgz +*.tar \ No newline at end of file diff --git a/DEVDOC.md b/DEVDOC.md index 5c02c9a..db4daff 100644 --- a/DEVDOC.md +++ b/DEVDOC.md @@ -42,6 +42,14 @@ The `clean` task clears all intermediate files as well as all the binary files. $ npm run clean ``` +### Package + +The `package` task generates a ready-to-publish *.tgz file which includes all the binaries. This task also forces to rebuild the whole project using `Release` configuration. + +```shell +$ npm run package +``` + ## Working with IDE ### Visual Studio diff --git a/gulpfile.js b/gulpfile.js index 3a9e321..2c2cd99 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,7 @@ const path = require('path'); const gulp = require('gulp'); +const clean = require('gulp-clean'); const { clean: dotnet_clean, build: dotnet_build @@ -9,7 +10,9 @@ const shrun = require('gulp-run'); gulp.task('clean', () => { return gulp.src('*.sln', { read: false }) - .pipe(dotnet_clean()); + .pipe(dotnet_clean()) + .pipe(gulp.src(['*.tgz', '*.tar'])) + .pipe(clean({ force: true })); }); gulp.task('build:debug', () => { @@ -22,6 +25,11 @@ gulp.task('build', ['clean'], () => { .pipe(dotnet_build({ configuration: 'Release' })); }); +gulp.task('publish', ['build'], () => { + return gulp.src('.', { read: false }) + .pipe(shrun('npm pack')); +}); + function getAutoRestCommand(config) { const plugin = path.resolve('.').replace(/\\/g, '\\\\'); diff --git a/package.json b/package.json index 2085fc2..29a564f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "clean": "gulp clean", "build": "gulp build", "build:debug": "gulp build:debug", - "samples:hdinsight": "gulp run:hdinsight" + "samples:hdinsight": "gulp run:hdinsight", + "package": "gulp publish" }, "repository": { "type": "git", @@ -25,11 +26,15 @@ "url": "https://github.com/Azure/autorest.terraform-provider/issues" }, "homepage": "https://github.com/Azure/autorest.terraform-provider#readme", + "files": [ + "bin/" + ], "devDependencies": { "@microsoft.azure/autorest.modeler": "^2.3.47", "autorest": "^2.0.4245", "dotnet-sdk-2.0.0": "^1.4.4", "gulp": "^3.9.1", + "gulp-clean": "^0.4.0", "gulp-cli": "^2.0.1", "gulp-dotnet-cli": "^1.1.0", "gulp-run": "^1.7.1" diff --git a/src/Templates/TfProviderTemplateBase.cs b/src/Templates/TfProviderTemplateBase.cs index 0b3277e..dc994f0 100644 --- a/src/Templates/TfProviderTemplateBase.cs +++ b/src/Templates/TfProviderTemplateBase.cs @@ -30,7 +30,7 @@ namespace AutoRest.Terraform protected new TemplateIndentation Indentation { get; set; } protected CodeNamerTf CodeNamer => Singleton.Instance; - private protected V OtherModel() + protected V OtherModel() where V : ITfProviderGenerator => Singleton.Instance;