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

Prettify all the things #732

Merged
merged 1 commit into from
Nov 2, 2017
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
5 changes: 4 additions & 1 deletion src/cli/domain/get-mocked-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ const findPath = function(pathToResolve, fileName) {
return undefined;
} else {
const getParent = function(x) {
return x.split('/').slice(0, -1).join('/');
return x
.split('/')
.slice(0, -1)
.join('/');
},
parentDir = pathToResolve ? getParent(pathToResolve) : rootDir;

Expand Down
6 changes: 3 additions & 3 deletions src/cli/domain/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ module.exports = function(opts) {
requestsHeaders = _.extend(requestsHeaders, {
Authorization:
'Basic ' +
new Buffer(options.username + ':' + options.password).toString(
'base64'
)
new Buffer(options.username + ':' + options.password).toString(
'base64'
)
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const builtin = {
message: isValid
? ''
: strings.errors.registry
.CONFIGURATION_PUBLISH_BASIC_AUTH_CREDENTIALS_MISSING
.CONFIGURATION_PUBLISH_BASIC_AUTH_CREDENTIALS_MISSING
};
},
middleware: function(authConfig) {
Expand Down
5 changes: 4 additions & 1 deletion src/registry/middleware/file-uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ module.exports = function(req, res, next) {
}

const normaliseFileName = x =>
x.replace('.tar.gz', '').replace(/\W+/g, '-').toLowerCase();
x
.replace('.tar.gz', '')
.replace(/\W+/g, '-')
.toLowerCase();

const upload = multer({
limits: {
Expand Down
16 changes: 9 additions & 7 deletions src/registry/routes/helpers/get-components-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ module.exports = history => {
});
});

return _.sortBy(result, 'publishDate').reverse().map(x => ({
name: x.name,
version: x.version,
publishDate: !x.publishDate
? 'Unknown'
: dateStringified(new Date(x.publishDate))
}));
return _.sortBy(result, 'publishDate')
.reverse()
.map(x => ({
name: x.name,
version: x.version,
publishDate: !x.publishDate
? 'Unknown'
: dateStringified(new Date(x.publishDate))
}));
};
9 changes: 5 additions & 4 deletions src/registry/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function(repository) {
}

const isHtmlRequest =
!!req.headers.accept && req.headers.accept.indexOf('text/html') >= 0,
!!req.headers.accept && req.headers.accept.indexOf('text/html') >= 0,
baseResponse = {
href: res.conf.baseUrl,
ocVersion: packageInfo.version,
Expand Down Expand Up @@ -66,9 +66,10 @@ module.exports = function(repository) {
components: componentsInfo,
componentsReleases,
componentsList: _.map(componentsInfo, component => {
const state = !!component.oc && !!component.oc.state
? component.oc.state
: '';
const state =
!!component.oc && !!component.oc.state
? component.oc.state
: '';

if (state) {
stateCounts[state] = stateCounts[state] || 0;
Expand Down
2 changes: 1 addition & 1 deletion src/registry/routes/static-redirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function(repository) {
return function(req, res) {
let filePath;
const clientPath =
(res.conf.prefix ? res.conf.prefix : '/') + 'oc-client/client.js',
(res.conf.prefix ? res.conf.prefix : '/') + 'oc-client/client.js',
clientMapPath =
(res.conf.prefix ? res.conf.prefix : '/') +
'oc-client/oc-client.min.map';
Expand Down
4 changes: 3 additions & 1 deletion src/registry/views/static/component-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ oc.cmd.push(function() {
});

$('.refresh-preview').click(function() {
var splitted = $('#href').val().split('?'),
var splitted = $('#href')
.val()
.split('?'),
url = splitted[0],
lang = $('#lang').val();

Expand Down
29 changes: 17 additions & 12 deletions test/acceptance/registry-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ const path = require('path');
const request = require('minimal-request');

describe('registry (ui interface)', () => {

let registry, result, error, headers;

const next = (done) => (e, r, d) => {
const next = done => (e, r, d) => {
error = e;
result = r;
headers = d.response.headers;
Expand Down Expand Up @@ -37,11 +36,14 @@ describe('registry (ui interface)', () => {
after(done => registry.close(done));

describe('GET / with Accept: text/html', () => {
before((done) => {
request({
url: 'http://localhost:3030',
headers: { accept: 'text/html' }
}, next(done));
before(done => {
request(
{
url: 'http://localhost:3030',
headers: { accept: 'text/html' }
},
next(done)
);
});

it('should not error', () => {
Expand All @@ -55,11 +57,14 @@ describe('registry (ui interface)', () => {
});

describe('GET /oc-client/~info with Accept: text/html', () => {
before((done) => {
request({
url: 'http://localhost:3030/oc-client/~info',
headers: { accept: 'text/html' }
}, next(done));
before(done => {
request(
{
url: 'http://localhost:3030/oc-client/~info',
headers: { accept: 'text/html' }
},
next(done)
);
});

it('should not error', () => {
Expand Down
91 changes: 59 additions & 32 deletions test/acceptance/registry/registry-with-fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ describe('registry', () => {
let registry;
let result;

function retrieveRegistryConfiguration(port, pathToComponents, fallbackRegistryUrl){
function retrieveRegistryConfiguration(
port,
pathToComponents,
fallbackRegistryUrl
) {
return {
local: true,
path: path.resolve(pathToComponents),
Expand All @@ -24,34 +28,47 @@ describe('registry', () => {
};
}

function next(done){
return function(e, r){
function next(done) {
return function(e, r) {
result = r;
done();
};
}

before((done) => {
registry = new oc.Registry(retrieveRegistryConfiguration(3030, 'test/fixtures/components', 'http://localhost:3031'));
fallbackRegistry = new oc.Registry(retrieveRegistryConfiguration(3031, 'test/fixtures/fallback-registry-components'));
before(done => {
registry = new oc.Registry(
retrieveRegistryConfiguration(
3030,
'test/fixtures/components',
'http://localhost:3031'
)
);
fallbackRegistry = new oc.Registry(
retrieveRegistryConfiguration(
3031,
'test/fixtures/fallback-registry-components'
)
);
registry.start(() => {
fallbackRegistry.start(done);
});
});

after((done) => {
after(done => {
registry.close(() => {
fallbackRegistry.close(done);
});
});

describe('GET /welcome', () => {

before((done) => {
request({
url: 'http://localhost:3030/welcome',
json: true
}, next(done));
before(done => {
request(
{
url: 'http://localhost:3030/welcome',
json: true
},
next(done)
);
});

it('should respond with the local registry url', () => {
Expand All @@ -64,16 +81,20 @@ describe('registry', () => {
});

describe('GET /fallback-hello-world', () => {

before((done) => {
request({
url: 'http://localhost:3030/fallback-hello-world',
json: true
}, next(done));
before(done => {
request(
{
url: 'http://localhost:3030/fallback-hello-world',
json: true
},
next(done)
);
});

it('should respond with the fallback registry url', () => {
expect(result.href).to.eql('http://localhost:3031/fallback-hello-world');
expect(result.href).to.eql(
'http://localhost:3031/fallback-hello-world'
);
});

it('should respond the `Hello world!` html', () => {
Expand All @@ -82,12 +103,15 @@ describe('registry', () => {
});

describe('GET /fallback-hello-world/~info', () => {

before((done) => {
request({
url: 'http://localhost:3030/fallback-welcome-with-optional-parameters/~info',
json: true
}, next(done));
before(done => {
request(
{
url:
'http://localhost:3030/fallback-welcome-with-optional-parameters/~info',
json: true
},
next(done)
);
});

it('should respond with requested component', () => {
Expand All @@ -100,12 +124,15 @@ describe('registry', () => {
});

describe('GET /fallback-hello-world/~preview', () => {

before((done) => {
request({
url: 'http://localhost:3030/fallback-welcome-with-optional-parameters/~preview',
json: true
}, next(done));
before(done => {
request(
{
url:
'http://localhost:3030/fallback-welcome-with-optional-parameters/~preview',
json: true
},
next(done)
);
});

it('should respond with requested component', () => {
Expand Down
56 changes: 32 additions & 24 deletions test/integration/targz.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,49 @@ const targz = require('targz');
const _ = require('lodash');

describe('The targz dependency', () => {

describe('when compressing a folder with targz', () => {

const file = path.resolve(__dirname, '../fixtures/test.tar.gz');

beforeEach((done) => {
const from = path.resolve(__dirname, '../fixtures/components/hello-world');
targz.compress({
src: from,
dest: file,
tar: {
map: function(fileName) {
return _.extend(fileName, {
name: 'hello-world/' + fileName.name
});
beforeEach(done => {
const from = path.resolve(
__dirname,
'../fixtures/components/hello-world'
);
targz.compress(
{
src: from,
dest: file,
tar: {
map: function(fileName) {
return _.extend(fileName, {
name: 'hello-world/' + fileName.name
});
}
}
}
}, done);
},
done
);
});

it('should create the file', () => {
expect(fs.existsSync(file));
});

describe('when decompressing the created file', () => {

let error;
const to = path.resolve(__dirname, '../fixtures/targz-test');

beforeEach((done) => {
targz.decompress({
src: file,
dest: to
}, (err) => {
error = err;
done();
});
beforeEach(done => {
targz.decompress(
{
src: file,
dest: to
},
err => {
error = err;
done();
}
);
});

it('should throw no error', () => {
Expand All @@ -52,7 +58,9 @@ describe('The targz dependency', () => {

it('should contain the files', () => {
expect(fs.existsSync(to)).to.be.true;
expect(fs.readFileSync(path.join(to, 'hello-world/template.html')).toString()).to.be.equal('Hello world!');
expect(
fs.readFileSync(path.join(to, 'hello-world/template.html')).toString()
).to.be.equal('Hello world!');
});
});
});
Expand Down
Loading