From 16fed540b51247feb3c535393caad903d42547fd Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 16 Feb 2018 12:18:02 -0800 Subject: [PATCH 1/3] Issue #230: Fix file path resolution for test and validation environment templates Previously the test-environment-maker and validation-environment-maker modules used a relative file path to reference their respective template files. However, this is invalid when the module is run from a dependent project since the current working directory will be the root of _that_ project rather than the root of synctos. Now it uses Node.js' built in path module to resolve the template file paths correctly. --- src/testing/test-environment-maker.js | 4 +++- src/testing/test-environment-maker.spec.js | 6 +++++- src/validation/validation-environment-maker.js | 4 +++- src/validation/validation-environment-maker.spec.js | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/testing/test-environment-maker.js b/src/testing/test-environment-maker.js index bab67be8..d7167745 100644 --- a/src/testing/test-environment-maker.js +++ b/src/testing/test-environment-maker.js @@ -9,6 +9,7 @@ exports.init = init; var fs = require('fs'); +var path = require('path'); var vm = require('vm'); var underscore = require('../../lib/underscore/underscore-min'); var simpleMock = require('../../lib/simple-mock/index'); @@ -19,7 +20,8 @@ function init(rawSyncFunction, syncFunctionFile) { displayErrors: true }; - var environmentTemplate = fs.readFileSync('templates/test-environment-template.js', 'utf8').trim(); + var filePath = path.resolve(__dirname, '../../templates/test-environment-template.js'); + var environmentTemplate = fs.readFileSync(filePath, 'utf8').trim(); // The test environment includes a placeholder string called "%SYNC_FUNC_PLACEHOLDER%" that is to be replaced with the contents of // the sync function diff --git a/src/testing/test-environment-maker.spec.js b/src/testing/test-environment-maker.spec.js index b86e248f..b62458bb 100644 --- a/src/testing/test-environment-maker.spec.js +++ b/src/testing/test-environment-maker.spec.js @@ -1,4 +1,5 @@ var expect = require('chai').expect; +var path = require('path'); var simpleMock = require('../../lib/simple-mock/index.js'); var mockRequire = require('mock-require'); @@ -48,7 +49,10 @@ describe('Test environment maker', function() { expect(result).to.eql(expectedResult); expect(fsMock.readFileSync.callCount).to.equal(1); - expect(fsMock.readFileSync.calls[0].args).to.eql([ 'templates/test-environment-template.js', 'utf8' ]); + expect(fsMock.readFileSync.calls[0].args).to.eql([ + path.resolve(__dirname, '../../templates/test-environment-template.js'), + 'utf8' + ]); expect(vmMock.runInThisContext.callCount).to.equal(1); expect(vmMock.runInThisContext.calls[0].args).to.eql([ diff --git a/src/validation/validation-environment-maker.js b/src/validation/validation-environment-maker.js index 25ffffe3..c9a68eb2 100644 --- a/src/validation/validation-environment-maker.js +++ b/src/validation/validation-environment-maker.js @@ -12,6 +12,7 @@ exports.init = init; var fs = require('fs'); +var path = require('path'); var vm = require('vm'); var underscore = require('../../lib/underscore/underscore-min'); var simpleMock = require('../../lib/simple-mock/index'); @@ -22,7 +23,8 @@ function init(docDefinitionsString, originalFilename) { displayErrors: true }; - var envTemplateString = fs.readFileSync('templates/validation-environment-template.js', 'utf8').trim(); + var filePath = path.resolve(__dirname, '../../templates/validation-environment-template.js'); + var envTemplateString = fs.readFileSync(filePath, 'utf8').trim(); // The test helper environment includes a placeholder string called "%DOC_DEFINITIONS_PLACEHOLDER%" that is to be replaced with the // contents of the document definitions diff --git a/src/validation/validation-environment-maker.spec.js b/src/validation/validation-environment-maker.spec.js index 3555ab49..dd337002 100644 --- a/src/validation/validation-environment-maker.spec.js +++ b/src/validation/validation-environment-maker.spec.js @@ -1,4 +1,5 @@ var expect = require('chai').expect; +var path = require('path'); var simpleMock = require('../../lib/simple-mock/index'); var mockRequire = require('mock-require'); @@ -40,7 +41,10 @@ describe('Validation environment maker', function() { expect(result).to.eql(expectedResult); expect(fsMock.readFileSync.callCount).to.equal(1); - expect(fsMock.readFileSync.calls[0].args).to.eql([ 'templates/validation-environment-template.js', 'utf8' ]); + expect(fsMock.readFileSync.calls[0].args).to.eql([ + path.resolve(__dirname, '../../templates/validation-environment-template.js'), + 'utf8' + ]); expect(vmMock.runInThisContext.callCount).to.equal(1); expect(vmMock.runInThisContext.calls[0].args).to.eql([ From 237365476f69e6bd0399fe54d10b1433ae3df8ca Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 16 Feb 2018 16:49:18 -0800 Subject: [PATCH 2/3] Issue #230: Update changelog for release of v2.0.0 --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51da0035..b449a3f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Change Log This project adheres to [Semantic Versioning](http://semver.org/). All notable changes will be documented in this file. -## [Unreleased] +## [2.0.0] - 2018-02-16 ### Added - [#43](https://github.com/Kashoo/synctos/issues/43): Tool to validate structure and semantics of a document definitions file - [#189](https://github.com/Kashoo/synctos/issues/189): Automatically create the output sync function file directory if it does not exist @@ -144,7 +144,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). All notable c ## [1.0.0] - 2016-07-12 First public release -[Unreleased]: https://github.com/Kashoo/synctos/compare/v1.10.0...HEAD +[Unreleased]: https://github.com/Kashoo/synctos/compare/v2.0.0...HEAD +[2.0.0]: https://github.com/Kashoo/synctos/compare/v1.10.0...v2.0.0 [1.10.0]: https://github.com/Kashoo/synctos/compare/v1.9.4...v1.10.0 [1.9.4]: https://github.com/Kashoo/synctos/compare/v1.9.3...v1.9.4 [1.9.3]: https://github.com/Kashoo/synctos/compare/v1.9.2...v1.9.3 From 873dec84a8bffdc85418789afad08f8e8e691a28 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 16 Feb 2018 16:49:32 -0800 Subject: [PATCH 3/3] 2.0.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b536c4f0..38ecc491 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "synctos", - "version": "1.12.0", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a0670a70..7764de9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "synctos", - "version": "1.12.0", + "version": "2.0.0", "description": "The Syncmaker. A tool to build comprehensive sync functions for Couchbase Sync Gateway.", "keywords": [ "couchbase",