diff --git a/.gulp/common.iced b/.gulp/common.iced index 0ae10c3876..0fb93acc0c 100644 --- a/.gulp/common.iced +++ b/.gulp/common.iced @@ -1,10 +1,103 @@ +# place an object into global namespace +global['Import'] = (object) -> + for key, value of object + global[key] = value + +Import + # require into the global namespace (modulename = module) + Install: (modulename, module) -> + global[modulename] = require module or modulename + + # require a gulp-Plugin into the global namespace + Plugin: () -> + Install module,"gulp-#{module}" for module in arguments + + # require a module, placing exports into global namespace + Include: () -> + Import require module for module in arguments + + Tasks: () -> + require "#{__dirname}/#{module}" for module in arguments + +############################################### +# force-global a bunch of stuff. +require 'shelljs/global' fs = require('fs') path = require('path') +TerminalRenderer = require('marked-terminal') +vfs = require('vinyl-fs'); + +Install 'marked' +Install 'vinyl' +Install 'os' +Install 'path' +Install 'fs' +Install 'gulp' +Install 'util' +Install 'moment' +Install 'chalk' +Install 'yargs' +Install 'eol', 'gulp-line-ending-corrector' +Install 'through', 'through2-parallel' +Install 'run', 'run-sequence' +Install 'semver' + + +# force this into global namespace +global['argv'] = yargs.argv +global.verbose = argv.verbose or null + +############################################### +# UI stuff + +marked.setOptions { + renderer: new TerminalRenderer({ + heading: chalk.green.bold, + firstHeading: chalk.green.bold, + showSectionPrefix: false, + strong: chalk.bold.cyan, + em: chalk.cyan, + blockquote: chalk.magenta, + tab: 2 + }) +} + +set '+e' + +Import + force: argv.force or false + threshold: argv.threshold or ((os.cpus().length)-1) or 1 + watch: argv.watch or false + error: chalk.bold.red + error_message: chalk.bold.cyan + warning: chalk.bold.yellow + info: chalk.bold.green + quiet_info: chalk.green + +# do a bit of monkeypatching +_gulpStart = gulp.Gulp::start +_runTask = gulp.Gulp::_runTask + +gulp.Gulp::start = (taskName) -> + @currentStartTaskName = taskName + _gulpStart.apply this, arguments + return + +gulp.Gulp::_runTask = (task) -> + @currentRunTaskName = task.name + _runTask.apply this, arguments + return + +# echo 'this.currentStartTaskName: ' + this.currentStartTaskName +# echo 'this.currentRunTaskName: ' + this.currentRunTaskName + +# bring some gulp-Plugins along +Plugin 'filter' + concurrency = 0 queue = [] global.completed = [] -vfs = require('vinyl-fs'); module.exports = # lets us just handle each item in a stream easily. @@ -226,7 +319,6 @@ module.exports = echo "" echo "#{ error 'Task Failed:' } #{error_message text}" echo "" - rm '-rf', workdir process.exit(1) execute: (cmdline,options,callback, ondata)-> @@ -278,14 +370,63 @@ module.exports = proc.stdout.on 'data', ondata if ondata return proc +for key, value of module.exports + global[key] = value # build task for global build -module.exports.task 'build', 'builds project', -> +task 'build', 'builds project', -> echo "Building project in #{basefolder}" -module.exports.task 'clean', 'cleans the project files', -> +task 'clean', 'cleans the project files', -> # task for vs code -module.exports.task 'code', 'launches vs code', -> +task 'code', 'launches vs code', -> exec "code #{basefolder}" - \ No newline at end of file + +configString = (s)-> + "#{s.charAt 0 .toUpperCase()}#{s.slice 1 .toLowerCase() }" + + + +############################################### +task 'default','', -> + cmds = "" + + for name, t of gulp.tasks + cmds += "\n gulp **#{name}** - #{t.description}" if t.description? and t.description.length + switches = "" + + echo marked """ + +# Usage + +## gulp commands +#{cmds} + +## available switches + *--force* specify when you want to force an action (restore, etc) + *--verbose* enable verbose output + *--threshold=nn* set parallelism threshold (default = 10) + +#{switches} +""" + +task 'test', "Run Tests", -> + +task 'fix-line-endings', 'Fixes line endings to file-type appropriate values.', -> + source "**/*.iced" + .pipe eol {eolc: 'LF', encoding:'utf8'} + .pipe destination '.' + +package_json = require("#{basefolder}/package.json") + +task 'version-number', '!', (done)-> + if argv.version + global.version = argv.version if argv.version + done(); + else + # git rev-list --parents HEAD --count --full-history + execute "git rev-list --parents HEAD --count --full-history" , {silent:true}, (c,o,e)-> + pv = (package_json.version).trim() + global.version = "#{semver.major(pv)}.#{semver.minor(pv)}.#{o.trim()}" + done(); diff --git a/.gulp/except.iced b/.gulp/except.iced deleted file mode 100644 index 5d896b52ad..0000000000 --- a/.gulp/except.iced +++ /dev/null @@ -1,17 +0,0 @@ -through = require 'through2' -util = require 'util' - -module.exports = (match) -> - # await through.obj defer file, enc, callback - through.obj (file, enc, callback) -> - - # check if the file is an actual file. - # if it's not, just skip this tool. - if !file or !file.path - return callback null, file - - # do something with the file - if file.path.match( match ) - return callback null - - return callback null, file \ No newline at end of file diff --git a/.gulp/gulp.iced b/.gulp/gulp.iced deleted file mode 100644 index 28dd50b052..0000000000 --- a/.gulp/gulp.iced +++ /dev/null @@ -1,169 +0,0 @@ -# place an object into global namespace -global['Import'] = (object) -> - for key, value of object - global[key] = value - -Import - # require into the global namespace (modulename = module) - Install: (modulename, module) -> - global[modulename] = require module or modulename - - # require a gulp-Plugin into the global namespace - Plugin: () -> - Install module,"gulp-#{module}" for module in arguments - - # require a module, placing exports into global namespace - Include: () -> - Import require module for module in arguments - - Tasks: () -> - require "#{__dirname}/#{module}" for module in arguments - -############################################### -# force-global a bunch of stuff. -require 'shelljs/global' -Install 'marked' -Install 'vinyl' -Install 'os' -Install 'path' -Install 'fs' -Install 'gulp' -Install 'util' -Install 'moment' -Install 'chalk' -Install 'yargs' -Install 'ghrelease', 'gulp-github-release' -Install 'eol', 'gulp-line-ending-corrector' -Install 'through', 'through2-parallel' -Install 'run', 'run-sequence' - -# do a bit of monkeypatching -_gulpStart = gulp.Gulp::start -_runTask = gulp.Gulp::_runTask - -gulp.Gulp::start = (taskName) -> - @currentStartTaskName = taskName - _gulpStart.apply this, arguments - return - -gulp.Gulp::_runTask = (task) -> - @currentRunTaskName = task.name - _runTask.apply this, arguments - return - -# echo 'this.currentStartTaskName: ' + this.currentStartTaskName -# echo 'this.currentRunTaskName: ' + this.currentRunTaskName - -# bring some gulp-Plugins along -Plugin 'filter', - 'zip' - 'unzip' - 'rename' - -# force this into global namespace -global['argv'] = yargs.argv - -Include './common' - -configString = (s)-> - "#{s.charAt 0 .toUpperCase()}#{s.slice 1 .toLowerCase() }" - - -############################################### -# Global values -process.env.tmp = process.env.tmp or "#{basefolder}/tmp" - - -Import - versionsuffix: if argv["version-suffix"]? then "--version-suffix=#{argv["version-suffix"]}" else "" - version: argv.version or (cat "#{basefolder}/VERSION").trim() - github_apikey: argv.github_apikey or process.env.GITHUB_APIKEY or null - nuget_apikey: argv.nuget_apikey or process.env.NUGET_APIKEY or null - myget_apikey: argv.myget_apikey or process.env.MYGET_APIKEY or null - npm_apikey: argv.npm_apikey or process.env.NPM_APIKEY or null - github_feed: argv.feed or "azure" - today: moment().format('YYYYMMDD') - now: moment().format('YYYYMMDD-HHmm') - force: argv.force or false - threshold: argv.threshold or ((os.cpus().length)-1) or 1 - workdir: "#{process.env.tmp}/gulp/#{guid()}" - watch: argv.watch or false -global.verbose = argv.verbose or null - -mkdir "-p", workdir if !test "-d", workdir - -############################################### -# UI stuff -TerminalRenderer = require('marked-terminal') -marked.setOptions { - renderer: new TerminalRenderer({ - heading: chalk.green.bold, - firstHeading: chalk.green.bold, - showSectionPrefix: false, - strong: chalk.bold.cyan, - em: chalk.cyan, - blockquote: chalk.magenta, - tab: 2 - }) -} - -set '+e' - -Import - error: chalk.bold.red - error_message: chalk.bold.cyan - warning: chalk.bold.yellow - info: chalk.bold.green - quiet_info: chalk.green - -############################################### -task 'default','', -> - cmds = "" - - for name, t of gulp.tasks - cmds += "\n gulp **#{name}** - #{t.description}" if t.description? and t.description.length - switches = "" - - echo marked """ - -# Usage - -## gulp commands -#{cmds} - -## available switches - *--force* specify when you want to force an action (restore, etc) - *--nightly* generate label for package as 'YYYYMMDD-0000-nightly' - *--preview* generate label for package as 'YYYYMMDD-HHmm-preview' - *--verbose* enable verbose output - *--threshold=nn* set parallelism threshold (default = 10) - -#{switches} -""" - -task 'test', "Run Tests", -> - - -task 'fix-line-endings', 'Fixes line endings to file-type appropriate values.', -> - source "**/*.iced" - .pipe eol {eolc: 'LF', encoding:'utf8'} - .pipe destination '.' - -# CI job -task 'testci', "more", [], (done) -> - ## TEST SUITE - global.verbose = true - await run "test", defer _ - - ## REGRESSION TEST - global.verbose = false - # regenerate - await run "regenerate", defer _ - # diff ('add' first so 'diff' includes untracked files) - await execute "git add -A", defer code, stderr, stdout - await execute "git diff --staged -w", defer code, stderr, stdout - # eval - echo stderr - echo stdout - throw "Potentially unnoticed regression (see diff above)! Run `npm run regenerate`, then review and commit the changes." if stdout.length + stderr.length > 0 - done() diff --git a/gulpfile.iced b/.gulp/gulpfile.iced similarity index 88% rename from gulpfile.iced rename to .gulp/gulpfile.iced index 139acbd8bf..c747ea00c1 100644 --- a/gulpfile.iced +++ b/.gulp/gulpfile.iced @@ -1,21 +1,17 @@ -# set the base folder of this project -global.basefolder = "#{__dirname}" # use our tweaked version of gulp with iced coffee. -require './.gulp/gulp.iced' +require './common.iced' semver = require 'semver' # tasks required for this build Tasks "typescript", # compiling typescript "regeneration" # regenerating expected files - "publishing" # signing/publishing binaries to github and npm registry + "publishing" # publishing binaries to npm registry # Settings Import initialized: false packages: "#{basefolder}/packages" - release_name: if argv.nightly then "#{version}-#{today}-2300-nightly" else if argv.preview then "#{version}-#{now}-preview" else "#{version}" - package_name: if argv.nightly then "autorest-#{version}-#{today}-2300-nightly.zip" else if argv.preview then "autorest-#{version}-#{now}-preview.zip" else "autorest-#{version}.zip" autorest: (args,done,ignoreexitcode) -> # Run AutoRest from the original current directory. echo info "Queuing up: AutoRest #{args.join(' ')}" @@ -142,3 +138,24 @@ task 'init', "" ,(done)-> return null return null + + +# CI job +task 'testci', "more", [], (done) -> + ## TEST SUITE + global.verbose = true + await run "test", defer _ + + ## REGRESSION TEST + global.verbose = false + # regenerate + await run "regenerate", defer _ + # diff ('add' first so 'diff' includes untracked files) + await execute "git add -A", defer code, stderr, stdout + await execute "git diff --staged -w", defer code, stderr, stdout + # eval + echo stderr + echo stdout + throw "Potentially unnoticed regression (see diff above)! Run `npm run regenerate`, then review and commit the changes." if stdout.length + stderr.length > 0 + done() + diff --git a/.gulp/publishing.iced b/.gulp/publishing.iced index 4ea2993a23..e7fdadc7c5 100644 --- a/.gulp/publishing.iced +++ b/.gulp/publishing.iced @@ -1,5 +1,33 @@ -task 'publish/autorest' , '' , ['build/typescript'], (done) -> - execute "npm publish ", {cwd: "#{basefolder}/src/autorest" }, done +task 'publish-preview' , 'Publishes the the packages to NPM.',['version-number'], (done)-> + publish_core = false + publish_bootstrapper = false -task 'publish/autorest-core', '', ['build/typescript'], (done) -> - execute "npm publish ", {cwd: "#{basefolder}/src/autorest-core" }, done + execute 'git show --pretty="" --name-only "HEAD^1"',{silent:true}, (c,o,e)-> + publish_core = true if( o.indexOf("src/") >-1 ) + publish_bootstrapper = true if( o.indexOf("src/autorest/") >-1 ) + + return done() if !publish_core # neither need publishing + + # update core package.json + package_path = "#{basefolder}/src/autorest-core/package.json" + package_folder = "#{basefolder}/src/autorest-core" + package_json = require package_path + package_json.version = version + JSON.stringify(package_json,null,' ').to package_path + + # publish core package + execute "npm publish --tag preview",{cwd:package_folder, silent:false }, (c,o,e) -> + echo "\n\nPublished Core: #{package_json.name}@#{info package_json.version} (tagged as @preview)\n\n" + + return done() if !publish_bootstrapper # doesn't need new bootstrapper + + # update bootstrapepr package.json + package_path = "#{basefolder}/src/autorest/package.json" + package_folder = "#{basefolder}/src/autorest" + package_json = require package_path + package_json.version = version + JSON.stringify(package_json,null,' ').to package_path + + execute "npm publish --tag preview",{cwd:package_folder, silent:false }, (c,o,e) -> + echo "\n\nPublished Bootstrapper: #{package_json.name}@#{info package_json.version} (tagged as @preview)\n\n" + done() \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000000..f231d0173d --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,4 @@ +// set the base folder of this project +global.basefolder = `${__dirname}` +require ("rechoir").prepare(require('interpret').extensions, './.gulp/gulpfile.iced'); +require ('./.gulp/gulpfile.iced') diff --git a/package.json b/package.json index 5db20d684d..3235b0f05e 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "autorest-build", - "version": "1.0.0", + "version": "2.0.0", "description": "Tools for AutoRest build processes", "scripts": { "test": "gulp test", "testci": "gulp testci", "build": "gulp build --threshold=1", + "publish-preview": "gulp publish-preview", "install": "gulp npm-install --verbose" }, "repository": { @@ -69,4 +70,4 @@ "yauzl": "^2.7.0" }, "dependencies": {} -} +} \ No newline at end of file diff --git a/package/nuget/package.json b/package/nuget/package.json index d034093167..e8c1793d31 100644 --- a/package/nuget/package.json +++ b/package/nuget/package.json @@ -1,6 +1,6 @@ { "name": "autorest-nuget", - "version": "1.2.1", + "version": "2.0.0", "description": "AutoRest Nuget Package", "main": "main.js", "scripts": { @@ -9,6 +9,6 @@ "author": "", "license": "ISC", "dependencies": { - "autorest": "^1.2.2" + "autorest": "^2.0.0" } -} +} \ No newline at end of file diff --git a/src/autorest-core/package.json b/src/autorest-core/package.json index 2767024370..eb5abb6010 100644 --- a/src/autorest-core/package.json +++ b/src/autorest-core/package.json @@ -1,6 +1,6 @@ { "name": "@microsoft.azure/autorest-core", - "version": "2.0.5", + "version": "2.0.0", "description": "AutoRest core module", "engines": { "node": ">=7.10.0" @@ -21,7 +21,7 @@ "main": "./dist/main.js", "scripts": { "test": "./node_modules/.bin/mocha ./dist/test", - "prepare": "shx rm -rf ./dist/ && shx mkdir -p ./dist/ && tsc && cd ./static_modules && npm install", + "prepare": "shx mkdir -p ./dist/ && cd ./static_modules && npm install", "prepublishonly": "gulp build" }, "typings": "./dist/main.d.ts", @@ -74,4 +74,4 @@ "yargs": "^8.0.2" }, "dependencies": {} -} +} \ No newline at end of file diff --git a/src/autorest-core/static_modules/package.json b/src/autorest-core/static_modules/package.json index 2885f5fafe..ddc2d61777 100644 --- a/src/autorest-core/static_modules/package.json +++ b/src/autorest-core/static_modules/package.json @@ -1,6 +1,6 @@ { "name": "static_modules", - "version": "1.0.0", + "version": "2.0.0", "description": "builds the static_modules file", "scripts": { "postinstall": "node ./create-static-fs" @@ -17,6 +17,7 @@ "linq-es2015": "^2.4.25", "pify": "^3.0.0", "safe-eval": "^0.3.0", + "semver-regex": "^1.0.0", "source-map": "^0.5.6", "strip-bom": "^3.0.0", "untildify": "^3.0.2", @@ -29,4 +30,4 @@ "type": "git", "url": "git+https://github.com/olydis/dotnet-2.0.0.git" } -} +} \ No newline at end of file diff --git a/src/autorest/package.json b/src/autorest/package.json index e3b83a53f2..44c3248a2a 100644 --- a/src/autorest/package.json +++ b/src/autorest/package.json @@ -1,6 +1,6 @@ { "name": "autorest", - "version": "2.0.5", + "version": "2.0.0", "description": "The AutoRest tool generates client libraries for accessing RESTful web services. Input to AutoRest is a spec that describes the REST API using the Open API Initiative format.", "engines": { "node": ">=7.10.0" @@ -63,4 +63,4 @@ "linq-es2015": "^2.4.24", "semver": "^5.3.0" } -} +} \ No newline at end of file diff --git a/src/autorest/static_modules/package.json b/src/autorest/static_modules/package.json index a2989d8d36..0df5a5a5b6 100644 --- a/src/autorest/static_modules/package.json +++ b/src/autorest/static_modules/package.json @@ -1,6 +1,6 @@ { "name": "static_modules", - "version": "1.0.0", + "version": "2.0.0", "description": "builds the static_modules file", "scripts": { "postinstall": "node ./create-static-fs" @@ -19,4 +19,4 @@ "type": "git", "url": "git+https://github.com/olydis/dotnet-2.0.0.git" } -} +} \ No newline at end of file