From c40de56a714048491951bd616c414523584a4812 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 19:27:47 +0300 Subject: [PATCH 01/14] Fix mixed deps for prod and dev build --- build/tasks/build.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index 9062edf0..37ae4414 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -43,16 +43,16 @@ gulp.task('inlineTemplates', ['sass'], function() { }); var JS_DEPS = argv.prod ? [ + 'lib/utils/browser-update.js', + 'node_modules/zone.js/dist/zone.min.js', + 'node_modules/reflect-metadata/Reflect.js', + 'node_modules/babel-polyfill/dist/polyfill.min.js' +]: [ 'lib/utils/browser-update.js', 'node_modules/zone.js/dist/zone.js', 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/reflect-metadata/Reflect.js', 'node_modules/babel-polyfill/dist/polyfill.js' -] : [ - 'lib/utils/browser-update.js', - 'node_modules/zone.js/dist/zone.min.js', - 'node_modules/reflect-metadata/Reflect.js', - 'node_modules/babel-polyfill/dist/polyfill.min.js' ]; var outputFileName = paths.redocBuilt + (argv.prod ? '.min.js' : '.js'); From 18c3f605a069b487526f6f2619f60b6a4fc8b8a9 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 19:28:16 +0300 Subject: [PATCH 02/14] Minor refactoring in json-schema-lazy --- lib/components/JsonSchema/json-schema-lazy.js | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.js index b03b66ec..209180d3 100644 --- a/lib/components/JsonSchema/json-schema-lazy.js +++ b/lib/components/JsonSchema/json-schema-lazy.js @@ -35,19 +35,23 @@ export class JsonSchemaLazy { return schema && schema.$ref || this.pointer; } + _loadAfterSelf() { + return this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { + this.initComponent(compRef); + if (compRef.changeDetectorRef) { + compRef.changeDetectorRef.detectChanges(); + } else { + compRef.hostView.changeDetectorRef.detectChanges(); + } + return compRef; + }); + } + load() { if (this.optionsService.options.disableLazySchemas) return; if (this.loaded) return; if (this.pointer) { - this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { - this.initComponent(compRef); - // trigger change detection - if (compRef.changeDetectorRef) { - compRef.changeDetectorRef.detectChanges(); - } else { - compRef.hostView.changeDetectorRef.detectChanges(); - } - }); + this._loadAfterSelf(); } this.loaded = true; } @@ -63,29 +67,13 @@ export class JsonSchemaLazy { // skip caching view with tabs inside (discriminator) as it needs attached controller // FIXME: get rid of dependency on selector if ($element.querySelector('.discriminator-wrap')) { - this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { - this.initComponent(compRef); - if (compRef.changeDetectorRef) { - compRef.changeDetectorRef.detectChanges(); - } else { - compRef.hostView.changeDetectorRef.detectChanges(); - } - }); return; } insertAfter($element.cloneNode(true), this.elementRef.nativeElement); } ); }); } else { - cache[this.pointer] = this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { - this.initComponent(compRef); - if (compRef.changeDetectorRef) { - compRef.changeDetectorRef.detectChanges(); - } else { - compRef.hostView.changeDetectorRef.detectChanges(); - } - return compRef; - }); + cache[this.pointer] = this._loadAfterSelf(); } } From 1d0579f1142950028411adeb79e885df3b4ddc2b Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 19:29:12 +0300 Subject: [PATCH 03/14] Remove debug log messages --- lib/components/base.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/components/base.js b/lib/components/base.js index 30d8246d..38bd2b57 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -86,9 +86,6 @@ export function RedocComponent(options) { pipes: pipes }); - console.log(options.selector, options.detect ? - (options.onPushOnly ? 'OnPush' : 'Default') : 'Detached'); - return componentDecorator(target) || target; }; } From 9c5d002eda5f172a999be3b116c0e3095fd499e4 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 19:31:30 +0300 Subject: [PATCH 04/14] Add basic error message (part of #48) --- karma.conf.js | 2 +- ...-styles.scss => redoc-initial-styles.scss} | 17 ++++++++++ lib/components/Redoc/redoc.js | 33 ++++++++++++------- lib/components/Redoc/redoc.spec.js | 11 ++++--- 4 files changed, 46 insertions(+), 17 deletions(-) rename lib/components/Redoc/{redoc-loading-styles.scss => redoc-initial-styles.scss} (92%) diff --git a/karma.conf.js b/karma.conf.js index a9dc7af0..d87d3cb3 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -63,7 +63,7 @@ module.exports = function (config) { proxies: { '/tests/': '/base/tests/', - '/lib/components/Redoc/redoc-loading-styles.css': '/base/.tmp/lib/components/Redoc/redoc-loading-styles.css', + '/lib/components/Redoc/redoc-initial-styles.css': '/base/.tmp/lib/components/Redoc/redoc-initial-styles.css', '/lib/': '/base/lib/', '/jspm_packages/': '/base/jspm_packages/', '/node_modules/': '/base/node_modules/', diff --git a/lib/components/Redoc/redoc-loading-styles.scss b/lib/components/Redoc/redoc-initial-styles.scss similarity index 92% rename from lib/components/Redoc/redoc-loading-styles.scss rename to lib/components/Redoc/redoc-initial-styles.scss index a9da11a6..008b946d 100644 --- a/lib/components/Redoc/redoc-loading-styles.scss +++ b/lib/components/Redoc/redoc-initial-styles.scss @@ -48,3 +48,20 @@ redoc.loading:after { redoc.loading-remove:before, redoc.loading-remove:after { opacity: 0; } + +.redoc-error { + padding: 20px; + text-align: center; + color: #cc0000; + + > h2 { + color: #cc0000; + font-size: 40px; + } +} + +.redoc-error-details { + max-width: 750px; + margin: 0 auto; + font-size: 18px; +} diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index b7c43cb4..b30de6f7 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -15,7 +15,7 @@ import SchemaManager from '../../utils/SchemaManager'; import { OptionsService, RedocEventsService } from '../../services/index'; import detectScollParent from 'scrollparent'; -import './redoc-loading-styles.css!css'; +import './redoc-initial-styles.css!css'; var dom = new BrowserDomAdapter(); var _modeLocked = false; @@ -86,17 +86,15 @@ export class Redoc extends BaseComponent { } return bootstrap(Redoc, providers); }) - .then( - (appRef) => { - Redoc.hideLoadingAnimation(); - Redoc.appRef = appRef; - console.log('ReDoc bootstrapped!'); - }, - error => { - console.log(error); - throw error; - } - ); + .then(appRef => { + Redoc.hideLoadingAnimation(); + Redoc.appRef = appRef; + console.log('ReDoc bootstrapped!'); + }, err => { + console.log(err); + Redoc.hideLoadingAnimation(); + Redoc.displayError(err); + }); } static autoInit() { @@ -109,6 +107,17 @@ export class Redoc extends BaseComponent { } } + static displayError(err) { + console.log(err); + let redocEl = dom.query('redoc'); + let heading = 'Oops... ReDoc failed to render this spec'; + let details = err.message; + let erroHtml = `
+

${heading}

+
${details}
`; + redocEl.innerHTML = erroHtml; + } + static destroy() { let el = dom.query('redoc'); let elClone; diff --git a/lib/components/Redoc/redoc.spec.js b/lib/components/Redoc/redoc.spec.js index d4cd8289..12723b6f 100644 --- a/lib/components/Redoc/redoc.spec.js +++ b/lib/components/Redoc/redoc.spec.js @@ -72,12 +72,15 @@ describe('Redoc components', () => { res.should.be.instanceof(Promise); }); - it('should reject promise for not specifed url', (done) => { + it('should hide loading animation and display message in case of error', async(() => { + spyOn(Redoc, 'hideLoadingAnimation').and.callThrough(); + spyOn(Redoc, 'displayError').and.callThrough(); let res = Redoc.init(); - res.then(() => { done.fail('Should not been called'); }, () => { - done(); + return res.then(() => { + expect(Redoc.hideLoadingAnimation).toHaveBeenCalled(); + expect(Redoc.displayError).toHaveBeenCalled(); }); - }); + })); //skip because of PhantomJS crashes on this testcase xit('should init redoc', (done) => { From bdbf7e0ab183a93745d04d0016cf7d82098c8fb0 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 19:51:57 +0300 Subject: [PATCH 05/14] Fixed e2e tests (button was not clickable) --- tests/e2e/redoc.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/redoc.spec.js b/tests/e2e/redoc.spec.js index 50608752..a34d27d6 100644 --- a/tests/e2e/redoc.spec.js +++ b/tests/e2e/redoc.spec.js @@ -72,6 +72,8 @@ describe('Language tabs sync', () => { var $item = $$('[operation-id="addPet"] tabs > ul > li').last(); // check if correct item expect($item.getText()).toContain('PHP'); + var EC = protractor.ExpectedConditions; + browser.wait(EC.elementToBeClickable($item), 2000); $item.click().then(() => { expect($('[operation-id="updatePet"] li.active').getText()).toContain('PHP'); }); From ed69beb2bcf904bafde358b35b6abda158065164 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 20:12:54 +0300 Subject: [PATCH 06/14] disable sourcemaps for prod build --- build/tasks/build.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index 37ae4414..acce9ea3 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -12,6 +12,7 @@ var sass = require('gulp-sass'); var replace = require('gulp-replace'); var rename = require('gulp-rename'); var argv = require('yargs').argv; +var gulpIf = require('gulp-if'); gulp.task('build', function (callback) { if (argv.skipRebuild) { @@ -66,9 +67,9 @@ gulp.task('sass', function () { // concatenate angular2 deps gulp.task('concatDeps', function() { return gulp.src(JS_DEPS.concat([outputFileName])) - .pipe(sourcemaps.init({loadMaps: true})) + .pipe(gulpIf(!argv.prod, sourcemaps.init({loadMaps: true}))) .pipe(concat(outputFileName)) - .pipe(sourcemaps.write('.')) + .pipe(gulpIf(!argv.prod, sourcemaps.write('.'))) .pipe(gulp.dest('.')) }); From 8e6ce26ea6f104e09d87fffab9274cbe63d905c2 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 20:13:39 +0300 Subject: [PATCH 07/14] use json-schema-ref-parser instead of SwaggerParser (fixes #46) --- lib/utils/SchemaManager.js | 4 +- package.json | 8 +-- system.config.js | 114 ++++++++++++++++--------------------- 3 files changed, 52 insertions(+), 74 deletions(-) diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index 3ba6f650..ecef93df 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -1,5 +1,5 @@ 'use strict'; -import SwaggerParser from 'swagger-parser'; +import JsonSchemaRefParser from 'json-schema-ref-parser'; import JsonPointer from './JsonPointer'; import {methods as swaggerMethods} from './swagger-defs'; @@ -22,7 +22,7 @@ export default class SchemaManager { let promise = new Promise((resolve, reject) => { this._schema = {}; - SwaggerParser.bundle(url, {http: {withCredentials: false}}) + JsonSchemaRefParser.bundle(url, {http: {withCredentials: false}}) .then( (schema) => { this._schema = schema; diff --git a/package.json b/package.json index e91e47c8..b593f7bd 100644 --- a/package.json +++ b/package.json @@ -44,12 +44,12 @@ "json-formatter-js": "npm:json-formatter-js@^0.2.0", "json-pointer": "npm:json-pointer@^0.3.0", "json-schema-instantiator": "npm:json-schema-instantiator@^0.3.0", + "json-schema-ref-parser": "npm:json-schema-ref-parser@^3.1.2", "marked": "npm:marked@^0.3.5", "prismjs": "npm:prismjs@^1.3.0", "rxjs": "npm:rxjs@5.0.0-beta.6", "scrollparent": "npm:scrollparent@^0.1.0", "stream-http": "npm:stream-http@^2.3.0", - "swagger-parser": "npm:swagger-parser@4.0.0-beta.2", "zone.js": "npm:zone.js@0.6.12" }, "devDependencies": { @@ -63,11 +63,6 @@ "overrides": { "github:Robdel12/DropKick@2.1.7": { "format": "global" - }, - "npm:json-schema-ref-parser@3.1.2": { - "map": { - "http": "npm:stream-http@2.3.0" - } } } }, @@ -81,6 +76,7 @@ "gulp": "^3.9.1", "gulp-concat": "^2.6.0", "gulp-eslint": "^1.1.1", + "gulp-if": "^2.0.1", "gulp-inline-ng2-template": "^1.1.2", "gulp-protractor": "^2.1.0", "gulp-rename": "^1.2.2", diff --git a/system.config.js b/system.config.js index e1c14140..2983ac4c 100644 --- a/system.config.js +++ b/system.config.js @@ -54,16 +54,16 @@ System.config({ "json-formatter-js": "npm:json-formatter-js@0.2.0", "json-pointer": "npm:json-pointer@0.3.0", "json-schema-instantiator": "npm:json-schema-instantiator@0.3.0", + "json-schema-ref-parser": "npm:json-schema-ref-parser@3.1.2", "marked": "npm:marked@0.3.5", "prismjs": "npm:prismjs@1.3.0", "rxjs": "npm:rxjs@5.0.0-beta.6", "scrollparent": "npm:scrollparent@0.1.0", "stream-http": "npm:stream-http@2.3.0", - "swagger-parser": "npm:swagger-parser@4.0.0-beta.2", "systemjs/plugin-json": "github:systemjs/plugin-json@0.1.2", "zone.js": "npm:zone.js@0.6.12", "github:jspm/nodelibs-assert@0.1.0": { - "assert": "npm:assert@1.3.0" + "assert": "npm:assert@1.4.0" }, "github:jspm/nodelibs-buffer@0.1.0": { "buffer": "npm:buffer@3.6.0" @@ -105,7 +105,7 @@ System.config({ "path-browserify": "npm:path-browserify@0.0.0" }, "github:jspm/nodelibs-process@0.1.2": { - "process": "npm:process@0.11.2" + "process": "npm:process@0.11.3" }, "github:jspm/nodelibs-punycode@0.1.0": { "punycode": "npm:punycode@1.3.2" @@ -176,13 +176,14 @@ System.config({ "sprintf-js": "npm:sprintf-js@1.0.3", "util": "github:jspm/nodelibs-util@0.1.0" }, - "npm:asn1.js@4.5.2": { + "npm:asn1.js@4.6.0": { "assert": "github:jspm/nodelibs-assert@0.1.0", "bn.js": "npm:bn.js@4.11.3", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "fs": "github:jspm/nodelibs-fs@0.1.2", "inherits": "npm:inherits@2.0.1", "minimalistic-assert": "npm:minimalistic-assert@1.0.0", + "systemjs-json": "github:systemjs/plugin-json@0.1.2", "vm": "github:jspm/nodelibs-vm@0.1.0" }, "npm:asn1@0.2.3": { @@ -205,7 +206,11 @@ System.config({ "stream": "github:jspm/nodelibs-stream@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0" }, - "npm:assert@1.3.0": { + "npm:assert@1.4.0": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "buffer-shims": "npm:buffer-shims@1.0.0", + "process": "github:jspm/nodelibs-process@0.1.2", "util": "npm:util@0.10.3" }, "npm:async@1.5.2": { @@ -215,10 +220,9 @@ System.config({ "crypto": "github:jspm/nodelibs-crypto@0.1.0", "url": "github:jspm/nodelibs-url@0.1.0" }, - "npm:aws4@1.3.2": { + "npm:aws4@1.4.1": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", - "lru-cache": "npm:lru-cache@4.0.1", "process": "github:jspm/nodelibs-process@0.1.2", "querystring": "github:jspm/nodelibs-querystring@0.1.0", "url": "github:jspm/nodelibs-url@0.1.0" @@ -293,6 +297,9 @@ System.config({ "readable-stream": "npm:readable-stream@2.0.6", "util": "github:jspm/nodelibs-util@0.1.0" }, + "npm:buffer-shims@1.0.0": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0" + }, "npm:buffer-xor@1.0.3": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "systemjs-json": "github:systemjs/plugin-json@0.1.2" @@ -461,7 +468,7 @@ System.config({ "inherits": "npm:inherits@2.0.1", "systemjs-json": "github:systemjs/plugin-json@0.1.2" }, - "npm:es6-promise@3.1.2": { + "npm:es6-promise@3.2.1": { "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:evp_bytestokey@1.0.0": { @@ -488,7 +495,7 @@ System.config({ "fs": "github:jspm/nodelibs-fs@0.1.2", "http": "github:jspm/nodelibs-http@1.7.1", "https": "github:jspm/nodelibs-https@0.1.0", - "mime-types": "npm:mime-types@2.1.10", + "mime-types": "npm:mime-types@2.1.11", "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2", "url": "github:jspm/nodelibs-url@0.1.0", @@ -502,7 +509,7 @@ System.config({ "is-property": "npm:is-property@1.0.2", "systemjs-json": "github:systemjs/plugin-json@0.1.2" }, - "npm:getpass@0.1.5": { + "npm:getpass@0.1.6": { "assert-plus": "npm:assert-plus@1.0.0", "fs": "github:jspm/nodelibs-fs@0.1.2", "process": "github:jspm/nodelibs-process@0.1.2", @@ -547,7 +554,7 @@ System.config({ "crypto": "github:jspm/nodelibs-crypto@0.1.0", "http": "github:jspm/nodelibs-http@1.7.1", "jsprim": "npm:jsprim@1.2.2", - "sshpk": "npm:sshpk@1.8.2", + "sshpk": "npm:sshpk@1.8.3", "util": "github:jspm/nodelibs-util@0.1.0" }, "npm:https-browserify@0.0.0": { @@ -582,7 +589,7 @@ System.config({ "crypto": "github:jspm/nodelibs-crypto@0.1.0", "jsbn": "npm:jsbn@0.1.0" }, - "npm:js-yaml@3.6.0": { + "npm:js-yaml@3.6.1": { "argparse": "npm:argparse@1.0.7", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "esprima": "npm:esprima@2.7.2", @@ -605,11 +612,12 @@ System.config({ "buffer": "github:jspm/nodelibs-buffer@0.1.0", "call-me-maybe": "npm:call-me-maybe@1.0.1", "debug": "npm:debug@2.2.0", - "es6-promise": "npm:es6-promise@3.1.2", + "es6-promise": "npm:es6-promise@3.2.1", "events": "github:jspm/nodelibs-events@0.1.1", "fs": "github:jspm/nodelibs-fs@0.1.2", - "https": "github:jspm/nodelibs-https@0.1.0", - "js-yaml": "npm:js-yaml@3.6.0", + "http": "npm:stream-http@2.3.0", + "https": "npm:stream-http@2.3.0", + "js-yaml": "npm:js-yaml@3.6.1", "ono": "npm:ono@2.2.1", "process": "github:jspm/nodelibs-process@0.1.2", "punycode": "github:jspm/nodelibs-punycode@0.1.0", @@ -631,36 +639,33 @@ System.config({ "util": "github:jspm/nodelibs-util@0.1.0", "verror": "npm:verror@1.3.6" }, - "npm:lodash._stringtopath@4.7.1": { + "npm:lodash._basetostring@4.12.0": { "process": "github:jspm/nodelibs-process@0.1.2" }, - "npm:lodash.get@4.2.1": { - "lodash._stringtopath": "npm:lodash._stringtopath@4.7.1" + "npm:lodash._stringtopath@4.8.0": { + "lodash._basetostring": "npm:lodash._basetostring@4.12.0", + "process": "github:jspm/nodelibs-process@0.1.2" }, - "npm:lru-cache@4.0.1": { - "pseudomap": "npm:pseudomap@1.0.2", - "util": "github:jspm/nodelibs-util@0.1.0", - "yallist": "npm:yallist@2.0.0" + "npm:lodash.get@4.3.0": { + "lodash._stringtopath": "npm:lodash._stringtopath@4.8.0" }, "npm:miller-rabin@4.0.0": { "bn.js": "npm:bn.js@4.11.3", "brorand": "npm:brorand@1.0.5" }, - "npm:mime-db@1.22.0": { + "npm:mime-db@1.23.0": { "systemjs-json": "github:systemjs/plugin-json@0.1.2" }, - "npm:mime-types@2.1.10": { - "mime-db": "npm:mime-db@1.22.0", + "npm:mime-types@2.1.11": { + "mime-db": "npm:mime-db@1.23.0", "path": "github:jspm/nodelibs-path@0.1.0" }, "npm:node-uuid@1.4.7": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0" }, - "npm:oauth-sign@0.8.1": { - "assert": "github:jspm/nodelibs-assert@0.1.0", + "npm:oauth-sign@0.8.2": { "crypto": "github:jspm/nodelibs-crypto@0.1.0", - "process": "github:jspm/nodelibs-process@0.1.2", "querystring": "github:jspm/nodelibs-querystring@0.1.0" }, "npm:ono@2.2.1": { @@ -675,7 +680,7 @@ System.config({ "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:parse-asn1@5.0.0": { - "asn1.js": "npm:asn1.js@4.5.2", + "asn1.js": "npm:asn1.js@4.6.0", "browserify-aes": "npm:browserify-aes@1.0.6", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "create-hash": "npm:create-hash@1.1.2", @@ -707,12 +712,12 @@ System.config({ "process": "github:jspm/nodelibs-process@0.1.2", "systemjs-json": "github:systemjs/plugin-json@0.1.2" }, - "npm:process@0.11.2": { - "assert": "github:jspm/nodelibs-assert@0.1.0" - }, - "npm:pseudomap@1.0.2": { + "npm:process-nextick-args@1.0.7": { "process": "github:jspm/nodelibs-process@0.1.2" }, + "npm:process@0.11.3": { + "assert": "github:jspm/nodelibs-assert@0.1.0" + }, "npm:public-encrypt@4.0.0": { "bn.js": "npm:bn.js@4.11.3", "browserify-rsa": "npm:browserify-rsa@4.0.1", @@ -748,7 +753,7 @@ System.config({ "inherits": "npm:inherits@2.0.1", "isarray": "npm:isarray@1.0.0", "process": "github:jspm/nodelibs-process@0.1.2", - "process-nextick-args": "npm:process-nextick-args@1.0.6", + "process-nextick-args": "npm:process-nextick-args@1.0.7", "string_decoder": "npm:string_decoder@0.10.31", "util-deprecate": "npm:util-deprecate@1.0.2" }, @@ -765,7 +770,7 @@ System.config({ }, "npm:request@2.72.0": { "aws-sign2": "npm:aws-sign2@0.6.0", - "aws4": "npm:aws4@1.3.2", + "aws4": "npm:aws4@1.4.1", "bl": "npm:bl@1.1.2", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "caseless": "npm:caseless@0.11.0", @@ -783,16 +788,16 @@ System.config({ "is-typedarray": "npm:is-typedarray@1.0.0", "isstream": "npm:isstream@0.1.2", "json-stringify-safe": "npm:json-stringify-safe@5.0.1", - "mime-types": "npm:mime-types@2.1.10", + "mime-types": "npm:mime-types@2.1.11", "node-uuid": "npm:node-uuid@1.4.7", - "oauth-sign": "npm:oauth-sign@0.8.1", + "oauth-sign": "npm:oauth-sign@0.8.2", "process": "github:jspm/nodelibs-process@0.1.2", "qs": "npm:qs@6.1.0", "querystring": "github:jspm/nodelibs-querystring@0.1.0", "stream": "github:jspm/nodelibs-stream@0.1.0", "stringstream": "npm:stringstream@0.0.5", "tough-cookie": "npm:tough-cookie@2.2.2", - "tunnel-agent": "npm:tunnel-agent@0.4.2", + "tunnel-agent": "npm:tunnel-agent@0.4.3", "url": "github:jspm/nodelibs-url@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0", "zlib": "github:jspm/nodelibs-zlib@0.1.0" @@ -822,14 +827,14 @@ System.config({ "amdefine": "npm:amdefine@1.0.0", "process": "github:jspm/nodelibs-process@0.1.2" }, - "npm:sshpk@1.8.2": { + "npm:sshpk@1.8.3": { "asn1": "npm:asn1@0.2.3", "assert-plus": "npm:assert-plus@1.0.0", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "dashdash": "npm:dashdash@1.13.1", "ecc-jsbn": "npm:ecc-jsbn@0.1.1", - "getpass": "npm:getpass@0.1.5", + "getpass": "npm:getpass@0.1.6", "jodid25519": "npm:jodid25519@1.0.2", "jsbn": "npm:jsbn@0.1.0", "stream": "github:jspm/nodelibs-stream@0.1.0", @@ -871,31 +876,8 @@ System.config({ "npm:supports-color@2.0.0": { "process": "github:jspm/nodelibs-process@0.1.2" }, - "npm:swagger-parser@4.0.0-beta.2": { - "buffer": "github:jspm/nodelibs-buffer@0.1.0", - "call-me-maybe": "npm:call-me-maybe@1.0.1", - "debug": "npm:debug@2.2.0", - "es6-promise": "npm:es6-promise@3.1.2", - "events": "github:jspm/nodelibs-events@0.1.1", - "fs": "github:jspm/nodelibs-fs@0.1.2", - "http": "github:jspm/nodelibs-http@1.7.1", - "https": "github:jspm/nodelibs-https@0.1.0", - "json-schema-ref-parser": "npm:json-schema-ref-parser@3.1.2", - "ono": "npm:ono@2.2.1", - "process": "github:jspm/nodelibs-process@0.1.2", - "punycode": "github:jspm/nodelibs-punycode@0.1.0", - "querystring": "github:jspm/nodelibs-querystring@0.1.0", - "stream": "github:jspm/nodelibs-stream@0.1.0", - "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0", - "swagger-methods": "npm:swagger-methods@1.0.0", - "swagger-schema-official": "npm:swagger-schema-official@2.0.0-bab6bed", - "systemjs-json": "github:systemjs/plugin-json@0.1.2", - "url": "github:jspm/nodelibs-url@0.1.0", - "util": "github:jspm/nodelibs-util@0.1.0", - "z-schema": "npm:z-schema@3.17.0" - }, "npm:timers-browserify@1.4.2": { - "process": "npm:process@0.11.2" + "process": "npm:process@0.11.3" }, "npm:to-arraybuffer@1.0.1": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", @@ -908,7 +890,7 @@ System.config({ "url": "github:jspm/nodelibs-url@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0" }, - "npm:tunnel-agent@0.4.2": { + "npm:tunnel-agent@0.4.3": { "assert": "github:jspm/nodelibs-assert@0.1.0", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "events": "github:jspm/nodelibs-events@0.1.1", @@ -946,7 +928,7 @@ System.config({ }, "npm:z-schema@3.17.0": { "commander": "npm:commander@2.9.0", - "lodash.get": "npm:lodash.get@4.2.1", + "lodash.get": "npm:lodash.get@4.3.0", "process": "github:jspm/nodelibs-process@0.1.2", "request": "npm:request@2.72.0", "systemjs-json": "github:systemjs/plugin-json@0.1.2", From c80f13738fcb55a01b2dd2d3cfab3eca20012c74 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 20:14:18 +0300 Subject: [PATCH 08/14] Use prod build on demo --- demo/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/index.html b/demo/index.html index 0c4ccf2c..d75490ce 100644 --- a/demo/index.html +++ b/demo/index.html @@ -20,6 +20,6 @@ - + From 6f8ea60da781f33770ac07bf8f49c8891763c2c2 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 20:36:10 +0300 Subject: [PATCH 09/14] Add version getter to ReDoc runtime --- build/tasks/build.js | 8 +++++++- lib/components/Redoc/redoc.js | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index acce9ea3..cfa51f39 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -73,7 +73,7 @@ gulp.task('concatDeps', function() { .pipe(gulp.dest('.')) }); -gulp.task('bundle', ['inlineTemplates'], function bundle(cb) { +gulp.task('bundle', ['injectVersionFile', 'inlineTemplates'], function bundle(cb) { fs.existsSync('dist') || fs.mkdirSync('dist'); var builder = new Builder('./', 'system.config.js'); @@ -122,3 +122,9 @@ gulp.task('concatPrism', function() { .pipe(concat(path.join(paths.tmp, 'prismjs-bundle.js'))) .pipe(gulp.dest('.')) }); + +// needs inlineTemplates run before to create .tmp/lib folder +gulp.task('injectVersionFile', ['inlineTemplates'], function() { + var version = require('../../package.json').version; + fs.writeFileSync(path.join(paths.tmp, 'lib/version.json'), JSON.stringify(version)); +}) diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index b30de6f7..456d1c18 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -5,6 +5,8 @@ import { bootstrap } from '@angular/platform-browser-dynamic'; import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { RedocComponent, BaseComponent } from '../base'; +import detectScollParent from 'scrollparent'; + import { ApiInfo } from '../ApiInfo/api-info'; import { ApiLogo } from '../ApiLogo/api-logo'; import { MethodsList } from '../MethodsList/methods-list'; @@ -13,8 +15,9 @@ import { SideMenu } from '../SideMenu/side-menu'; import { StickySidebar } from '../../shared/components/index'; import SchemaManager from '../../utils/SchemaManager'; import { OptionsService, RedocEventsService } from '../../services/index'; +import redocVersion from '../../version.json!json'; + -import detectScollParent from 'scrollparent'; import './redoc-initial-styles.css!css'; var dom = new BrowserDomAdapter(); @@ -118,6 +121,10 @@ export class Redoc extends BaseComponent { redocEl.innerHTML = erroHtml; } + static get version() { + return redocVersion; + } + static destroy() { let el = dom.query('redoc'); let elClone; From f2b1ba8cdaa2a4c65158aecead7f1b3ad3dc36b3 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 20:51:31 +0300 Subject: [PATCH 10/14] Add gulp copydebug task --- build/tasks/build.js | 18 ++++++++++++------ demo/index.html | 1 - gulpfile.js | 1 + package.json | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index cfa51f39..3ab8725c 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -24,10 +24,18 @@ gulp.task('build', function (callback) { 'concatPrism', 'bundle', 'concatDeps', + 'copyDebug', callback ); }); +gulp.task('copyDebug', () => { + if (!argv.prod) { + // copy for be accessible from demo for debug + cp(paths.redocBuilt + '.js', paths.redocBuilt + '.min.js'); + } +}); + gulp.task('rebuild', function(done) { return runSequence( 'bundle', @@ -73,7 +81,7 @@ gulp.task('concatDeps', function() { .pipe(gulp.dest('.')) }); -gulp.task('bundle', ['injectVersionFile', 'inlineTemplates'], function bundle(cb) { +gulp.task('bundle', ['injectVersionFile', 'inlineTemplates'], function bundle(done) { fs.existsSync('dist') || fs.mkdirSync('dist'); var builder = new Builder('./', 'system.config.js'); @@ -82,13 +90,11 @@ gulp.task('bundle', ['injectVersionFile', 'inlineTemplates'], function bundle(cb outputFileName, { format:'umd', sourceMaps: !argv.prod, lowResSourceMaps: true, minify: argv.prod } ) - .then(function() { + .then(() => { // wait some time to allow flush - setTimeout(() => cb(), 500); + setTimeout(() => done(), 500); }) - .catch(function(err) { - cb(new Error(err)); - }); + .catch(err => done(err)); }); gulp.task('concatPrism', function() { diff --git a/demo/index.html b/demo/index.html index d75490ce..cbcd26f1 100644 --- a/demo/index.html +++ b/demo/index.html @@ -18,7 +18,6 @@ - diff --git a/gulpfile.js b/gulpfile.js index 978fd983..e72a09e3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1 +1,2 @@ +require('shelljs/global'); require('require-dir')('build/tasks'); diff --git a/package.json b/package.json index b593f7bd..e3595801 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "reflect-metadata": "^0.1.2", "require-dir": "^0.3.0", "run-sequence": "^1.1.5", + "shelljs": "^0.7.0", "should": "^8.0.2", "sinon": "^1.17.2", "systemjs-builder": "^0.15.16", From 82060357c728819acd04ace21e618d2eacb6fa81 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 22:37:10 +0300 Subject: [PATCH 11/14] Get rid of bash --- build/prepare_deploy.js | 32 ++++++++++++++++++++++++++++++++ build/prepare_deploy.sh | 21 --------------------- build/run_tests.js | 13 +++++++++++++ build/run_tests.sh | 8 -------- package.json | 4 ++-- 5 files changed, 47 insertions(+), 31 deletions(-) create mode 100755 build/prepare_deploy.js delete mode 100755 build/prepare_deploy.sh create mode 100755 build/run_tests.js delete mode 100755 build/run_tests.sh diff --git a/build/prepare_deploy.js b/build/prepare_deploy.js new file mode 100755 index 00000000..74638103 --- /dev/null +++ b/build/prepare_deploy.js @@ -0,0 +1,32 @@ +#!/usr/bin/env node +'use strict'; +require('shelljs/global'); + +var paths = require('./paths'); +var path = require('path'); + +// copy old releases +mkdir('-p', '.ghpages-tmp'); +cd('.ghpages-tmp'); + +// reset local changes before checkout +exec('git reset --hard'); +exec('git fetch origin gh-pages:gh-pages'); +exec('git checkout gh-pages'); +cp('-R', '../releases/*', '.'); +exec('git checkout @{-1}'); +cd('..'); + +// build +exec('npm run build-dist'); +cd('demo'); +mkdir('-p', 'dist'); +cp('-R', '../dist/*', './dist/'); +mkdir('-p', 'releases'); +cp('-R', '../.ghpages-tmp/*', './releases/'); +cd('..'); +var version = 'v' + require(path.join(__dirname, '../package.json')).version + '/'; +var versionDir = path.join(paths.releases, version); +mkdir('-p', versionDir) +cp(paths.redocBuilt + '.min.js', versionDir); +cp(paths.redocBuilt + '.min.js', path.join(paths.releases, 'latest/')); diff --git a/build/prepare_deploy.sh b/build/prepare_deploy.sh deleted file mode 100755 index c544aa4b..00000000 --- a/build/prepare_deploy.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e -set -x -# copy old releases -mkdir -p .ghpages-tmp && cd .ghpages-tmp -# reset local changes before checkout -git reset --hard -git fetch origin gh-pages:gh-pages -git checkout gh-pages -cp -R ../releases/* . -git checkout @{-1} -cd - - -# build -npm run build-dist -cd demo -cp -R ../dist/* ./dist/ -mkdir -p releases -cp -R ../.ghpages-tmp/* ./releases/ -cd - -gulp copy-version diff --git a/build/run_tests.js b/build/run_tests.js new file mode 100755 index 00000000..40b488fa --- /dev/null +++ b/build/run_tests.js @@ -0,0 +1,13 @@ +#!/usr/bin/env node +'use strict'; + +require('shelljs/global'); +set('-e'); + +if (process.env.JOB === 'e2e-guru') { + exec('npm run e2e'); +} else { + exec('npm run unit'); + console.log('Starting Basic E2E'); + exec('npm run e2e'); +} diff --git a/build/run_tests.sh b/build/run_tests.sh deleted file mode 100755 index 6d05f49d..00000000 --- a/build/run_tests.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -if [ "$JOB" = "e2e-guru" ]; then - npm run e2e -else - npm run unit - echo "Starting Basic E2E" - npm run e2e -fi diff --git a/package.json b/package.json index e3595801..8a6c5fdd 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,14 @@ }, "main": "dist/redoc.min.js", "scripts": { - "test": "gulp lint && ./build/run_tests.sh", + "test": "gulp lint && node ./build/run_tests.js", "jspm-install": "jspm install", "start": "gulp serve", "build-dist": "gulp build --prod", "branch-release": "git reset --hard && branch-release", "unit": "gulp test", "e2e": "gulp e2e --prod", - "deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo" + "deploy": "node ./build/prepare_deploy.js && deploy-to-gh-pages demo" }, "keywords": [ "OpenAPI", From 1ec5f9d12dfa74357001c4e0396f2f392764838d Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 22:45:12 +0300 Subject: [PATCH 12/14] fix unit tests: add version.json to karma serveed --- karma.conf.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index d87d3cb3..a8dde48c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -57,13 +57,15 @@ module.exports = function (config) { jspm: { config: 'system.config.js', loadFiles: ['tests/setup.js', 'tests/helpers.js', 'tests/unit/*.spec.js', 'lib/**/*.js'], - serveFiles: ['tests/schemas/**/*.json','tests/schemas/**/*.yml', 'lib/**/*.html', '.tmp/*js', '.tmp/lib/**/*.css'], + serveFiles: ['tests/schemas/**/*.json','tests/schemas/**/*.yml', 'lib/**/*.html', + '.tmp/lib/**/*.json', '.tmp/*js', '.tmp/lib/**/*.css'], nocache: true }, proxies: { '/tests/': '/base/tests/', '/lib/components/Redoc/redoc-initial-styles.css': '/base/.tmp/lib/components/Redoc/redoc-initial-styles.css', + '/lib/version.json': '/base/.tmp/lib/version.json', '/lib/': '/base/lib/', '/jspm_packages/': '/base/jspm_packages/', '/node_modules/': '/base/node_modules/', From 37bbd7f405c45760de5d43d76801d0fd6ab1ea54 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 22:56:10 +0300 Subject: [PATCH 13/14] fix broken unit tests --- build/tasks/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tasks/test.js b/build/tasks/test.js index 6b93998e..444b2307 100644 --- a/build/tasks/test.js +++ b/build/tasks/test.js @@ -5,7 +5,7 @@ var Server = require('karma').Server; /** * Run test once and exit */ -gulp.task('test', ['concatPrism', 'inlineTemplates'], function (done) { +gulp.task('test', ['concatPrism', 'inlineTemplates', 'injectVersionFile'], function (done) { new Server({ configFile: __dirname + '/../../karma.conf.js', singleRun: true From 61d9a424772599305cd83efd2853d112850dd239 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 20 May 2016 23:04:11 +0300 Subject: [PATCH 14/14] bump version (v0.12.0) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8a6c5fdd..c40c1599 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "redoc", "description": "Swagger-generated API Reference Documentation", - "version": "0.11.1", + "version": "0.12.0", "repository": { "type": "git", "url": "git://github.com/Rebilly/ReDoc"