Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oc version fix #11

Merged
merged 4 commits into from
Jan 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cli/domain/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var format = require('../../utils/format');
var fs = require('fs-extra');
var hashBuilder = require('../../utils/hash-builder');
var request = require('../../utils/request');
var originalPackage = require('../../package.json');
var path = require('path');
var Targz = require('tar.gz');
var uglifyJs = require('uglify-js');
Expand Down Expand Up @@ -143,15 +142,16 @@ module.exports = function(){
}

fs.mkdirSync(publishPath);

var component = fs.readJsonSync(path.join(componentPath, 'package.json')),
ocInfo = fs.readJsonSync(path.join(__dirname, '../../package.json')),
template = fs.readFileSync(path.join(componentPath, component.oc.files.template.src)).toString();

if(!validator.validateComponentName(component.name)){
return callback('name not valid');
}

component.oc.version = originalPackage.version;
component.oc.version = ocInfo.version;

if(component.oc.files.template.type === 'handlebars'){

Expand Down
4 changes: 2 additions & 2 deletions components/oc-client/_package/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oc-client",
"description": "",
"version": "0.3.0",
"version": "0.3.1",
"dependencies": {},
"repository": "",
"oc": {
Expand All @@ -21,6 +21,6 @@
"src": "server.js"
}
},
"version": "0.2.0"
"version": "0.3.1"
}
}
2 changes: 1 addition & 1 deletion components/oc-client/_package/src/oc-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/oc-client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oc-client",
"description": "",
"version": "0.3.0",
"version": "0.3.1",
"dependencies": {},
"repository": "",
"oc": {
Expand Down
2 changes: 1 addition & 1 deletion components/oc-client/src/oc-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oc",
"version": "0.3.0",
"version": "0.3.1",
"description": "An experimental framework to develop and distribute html components",
"main": "index.js",
"bin": {
Expand Down
68 changes: 35 additions & 33 deletions test/unit/cli-domain-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,42 @@ var sinon = require('sinon');

describe('cli : domain : local', function(){

describe('when packaging', function(){
describe('when packaging', function(){

var readJsonSyncStub = sinon.stub();
var readFileSyncStub = sinon.stub();
var packageMock = {
version: '1.2.3'
};
var fsMock = {
readdirSync: sinon.spy(),
mkdirSync: sinon.spy(),
readJsonSync: readJsonSyncStub,
readFileSync: readFileSyncStub
};
var mockComponent = {
name: 'helloworld',
oc: {
files: {
template: {
type: 'wrongtype',
src: ''
}
}
}
};
readJsonSyncStub.returns(mockComponent);
readFileSyncStub.returns('');
var Local = injectr('../../cli/domain/local.js', { 'fs-extra' : fsMock, '../../package.json': packageMock });
var readJsonSyncStub = sinon.stub();
var readFileSyncStub = sinon.stub();

it('should add version to package.json file', function(done){
var local = new Local();
local.package('.', function(err, res){
expect(mockComponent.oc.version).to.eql('1.2.3');
done();
});
});
var fsMock = {
readdirSync: sinon.spy(),
mkdirSync: sinon.spy(),
readJsonSync: readJsonSyncStub,
readFileSync: readFileSyncStub
};

var mockComponent = {
name: 'helloworld',
oc: {
files: {
template: {
type: 'wrongtype',
src: ''
}
}
}
};
readJsonSyncStub.withArgs('package.json').returns(mockComponent);
readJsonSyncStub.withArgs('../../package.json').returns({
version: '1.2.3'
});
readFileSyncStub.returns('');
var Local = injectr('../../cli/domain/local.js', { 'fs-extra' : fsMock }, { __dirname: '' });

it('should add version to package.json file', function(done){
var local = new Local();
local.package('.', function(err, res){
expect(mockComponent.oc.version).to.eql('1.2.3');
done();
});
});
});
});
2 changes: 1 addition & 1 deletion test/unit/registry-app-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var sinon = require('sinon');
var getAppStart = function(mockedRepository, options, callback){
var appStart = injectr('../../registry/app-start.js', {
'./domain/repository': mockedRepository
}, { console: console, __dirname: '.'});
}, { console: { log: sinon.stub() }, __dirname: '.'});

return appStart(options, callback);
};
Expand Down