Skip to content

Commit

Permalink
Merge pull request #1210 from opencomponents/remove-new
Browse files Browse the repository at this point in the history
remove new references on non-classes
  • Loading branch information
ricardo-devis-agullo authored Sep 22, 2021
2 parents 5bfd9ac + 164089e commit 4386f6a
Show file tree
Hide file tree
Showing 36 changed files with 77 additions and 77 deletions.
4 changes: 2 additions & 2 deletions src/cli/domain/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const strings = require('../../resources');
const validator = require('../../registry/domain/validators');

module.exports = function() {
return _.extend(this, {
return {
clean,
cleanup: function(compressedPackagePath, callback) {
return fs.unlink(compressedPackagePath, callback);
Expand Down Expand Up @@ -71,5 +71,5 @@ module.exports = function() {
},
mock: mock(),
package: packageComponents()
});
};
};
4 changes: 2 additions & 2 deletions src/cli/domain/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function(opts) {
}-${process.arch}`
};

return _.extend(this, {
return {
add: function(registry, callback) {
if (registry.slice(registry.length - 1) !== '/') {
registry += '/';
Expand Down Expand Up @@ -159,5 +159,5 @@ module.exports = function(opts) {
fs.writeJson(settings.configFile.src, res, callback);
});
}
});
};
};
2 changes: 1 addition & 1 deletion src/cli/facade/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ module.exports = function(dependencies) {
return callback(err);
}

const registry = new oc.Registry({
const registry = oc.Registry({
baseUrl,
prefix: opts.prefix || '',
dependencies: dependencies.modules,
Expand Down
4 changes: 2 additions & 2 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ if (semver.lt(currentNodeVersion, minSupportedVersion)) {
}

const dependencies = {
local: new Local(),
local: Local(),
logger,
registry: new Registry()
registry: Registry()
};

function processCommand(command, commandName, cli, level, prefix) {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/programmatic-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const Local = require('./domain/local');
function wrap(cmdScript, withRegistry) {
return function(options, cb) {
const dependencies = {
local: new Local(),
local: Local(),
logger: options.logger || { log() {}, err() {}, ok() {}, warn() {} }
};

if (withRegistry) {
const Registry = require('./domain/registry');
dependencies.registry = new Registry({ registry: options.registry });
dependencies.registry = Registry({ registry: options.registry });
}

const opts = _.omit(options, 'logger', 'registry');
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const versionHandler = require('./version-handler');
const errorToString = require('../../utils/error-to-string');

module.exports = function(conf) {
const cdn = !conf.local && new conf.storage.adapter(conf.storage.options);
const cdn = !conf.local && conf.storage.adapter(conf.storage.options);
const options = !conf.local && conf.storage.options;
const repositorySource = conf.local
? 'local repository'
Expand Down
2 changes: 1 addition & 1 deletion src/registry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = function(options) {
const plugins = [];
const app = middleware.bind(express(), options);
let server;
const repository = new Repository(options);
const repository = Repository(options);

const close = callback => {
if (server && server.listening) {
Expand Down
18 changes: 9 additions & 9 deletions src/registry/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const settings = require('../resources/settings');

module.exports.create = function(app, conf, repository) {
const routes = {
component: new ComponentRoute(conf, repository),
components: new ComponentsRoute(conf, repository),
componentInfo: new ComponentInfoRoute(conf, repository),
componentPreview: new ComponentPreviewRoute(conf, repository),
index: new IndexRoute(repository),
publish: new PublishRoute(repository),
staticRedirector: new StaticRedirectorRoute(repository),
plugins: new PluginsRoute(conf),
dependencies: new DependenciesRoute(conf)
component: ComponentRoute(conf, repository),
components: ComponentsRoute(conf, repository),
componentInfo: ComponentInfoRoute(conf, repository),
componentPreview: ComponentPreviewRoute(conf, repository),
index: IndexRoute(repository),
publish: PublishRoute(repository),
staticRedirector: StaticRedirectorRoute(repository),
plugins: PluginsRoute(conf),
dependencies: DependenciesRoute(conf)
};

const prefix = conf.prefix;
Expand Down
2 changes: 1 addition & 1 deletion src/registry/routes/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const GetComponentHelper = require('./helpers/get-component');
const strings = require('../../resources');

module.exports = function(conf, repository) {
const getComponent = new GetComponentHelper(conf, repository);
const getComponent = GetComponentHelper(conf, repository);

return function(req, res) {
getComponent(
Expand Down
2 changes: 1 addition & 1 deletion src/registry/routes/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const GetComponentHelper = require('./helpers/get-component');
const strings = require('../../resources');

module.exports = function(conf, repository) {
const getComponent = new GetComponentHelper(conf, repository);
const getComponent = GetComponentHelper(conf, repository);
const setHeaders = (results, res) => {
if (!results || results.length !== 1 || !results[0] || !res.set) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/registry/routes/helpers/get-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const urlBuilder = require('../../domain/url-builder');
const validator = require('../../domain/validators');

module.exports = function(conf, repository) {
const client = new Client({ templates: conf.templates }),
const client = Client({ templates: conf.templates }),
cache = new Cache({
verbose: !!conf.verbosity,
refreshInterval: conf.refreshInterval
});

const renderer = function(options, cb) {
const nestedRenderer = new NestedRenderer(renderer, options.conf),
retrievingInfo = new GetComponentRetrievingInfo(options);
const nestedRenderer = NestedRenderer(renderer, options.conf),
retrievingInfo = GetComponentRetrievingInfo(options);
let responseHeaders = {};

const getLanguage = () => {
Expand Down
2 changes: 1 addition & 1 deletion tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ocClientBrowser.getLib((err, libContent) => {
);

const Local = require('../src/cli/domain/local');
const local = new Local();
const local = Local();
const packageOptions = {
componentPath: path.join(__dirname, clientComponentDir),
production: true,
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/registry-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('registry (ui interface)', () => {
};

const initializeRegistry = (configuration, cb) => {
registry = new oc.Registry(configuration);
registry = oc.Registry(configuration);
registry.start(cb);
};

Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('registry', () => {
};

const initializeRegistry = function(configuration, cb) {
registry = new oc.Registry(configuration);
registry = oc.Registry(configuration);
registry.start(cb);
};

Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/registry/registry-with-fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ describe('registry', () => {
}

before(done => {
registry = new oc.Registry(
registry = oc.Registry(
retrieveRegistryConfiguration(
3030,
'test/fixtures/components',
'http://localhost:3031'
)
);
fallbackRegistry = new oc.Registry(
fallbackRegistry = oc.Registry(
retrieveRegistryConfiguration(
3031,
'test/fixtures/fallback-registry-components'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cli-domain-get-components-by-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const initialise = function() {
{ __dirname: '' }
);

const local = new GetComponentsByDir();
const local = GetComponentsByDir();

return { local: local, fs: fsMock };
};
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cli-domain-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const initialise = function() {
{ __dirname: '' }
);

const local = new Local();
const local = Local();

return { local: local, fs: fsMock };
};
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cli-domain-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getRegistry = function(dependencies, opts) {
}
);

return new Registry(opts);
return Registry(opts);
};

describe('cli : domain : registry', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cli-facade-clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('cli : facade : clean', () => {
read: readMock
});

const cleanFacade = new CleanFacade({ local, logger: logSpy });
const cleanFacade = CleanFacade({ local, logger: logSpy });
cleanFacade(options.params, () => {
done();
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cli-facade-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('cli : facade : dev', () => {
const logSpy = {},
DevFacade = require('../../src/cli/facade/dev'),
Local = require('../../src/cli/domain/local'),
local = new Local(),
devFacade = new DevFacade({ local, logger: logSpy });
local = Local(),
devFacade = DevFacade({ local, logger: logSpy });

const execute = function(dirName, port) {
logSpy.err = sinon.spy();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cli-facade-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe('cli : facade : init', () => {
const logSpy = {},
InitFacade = require('../../src/cli/facade/init'),
Local = injectr('../../src/cli/domain/local.js', deps, {}),
local = new Local({ logger: { log: () => {} } }),
initFacade = new InitFacade({ local: local, logger: logSpy });
local = Local({ logger: { log: () => {} } }),
initFacade = InitFacade({ local: local, logger: logSpy });

const execute = function(componentPath, templateType) {
logSpy.err = sinon.spy();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cli-facade-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('cli : facade : mock', () => {
const logSpy = {},
MockFacade = require('../../src/cli/facade/mock'),
Local = require('../../src/cli/domain/local'),
local = new Local(),
mockFacade = new MockFacade({ local: local, logger: logSpy });
local = Local(),
mockFacade = MockFacade({ local: local, logger: logSpy });

const execute = function() {
logSpy.ok = sinon.spy();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cli-facade-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const sinon = require('sinon');
describe('cli : facade : package', () => {
const logSpy = {},
Local = require('../../src/cli/domain/local'),
local = new Local(),
local = Local(),
PackageFacade = require('../../src/cli/facade/package.js'),
packageFacade = new PackageFacade({ local: local, logger: logSpy });
packageFacade = PackageFacade({ local: local, logger: logSpy });

const execute = function(compress, cb) {
logSpy.err = sinon.stub();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cli-facade-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('cli : facade : preview', () => {
const PreviewFacade = injectr('../../src/cli/facade/preview.js', {
open: openSpy
}),
previewFacade = new PreviewFacade({
previewFacade = PreviewFacade({
logger: logSpy,
registry: registryStub
});
Expand Down
6 changes: 3 additions & 3 deletions test/unit/cli-facade-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const sinon = require('sinon');
describe('cli : facade : publish', () => {
const logSpy = {},
Registry = require('../../src/cli/domain/registry'),
registry = new Registry(),
registry = Registry(),
Local = require('../../src/cli/domain/local'),
local = new Local(),
local = Local(),
readStub = sinon.stub().yields(null, 'test'),
mockComponent = {
name: 'hello-world',
Expand All @@ -37,7 +37,7 @@ describe('cli : facade : publish', () => {
'fs-extra': fsMock,
read: readStub
}),
publishFacade = new PublishFacade({
publishFacade = PublishFacade({
registry,
local,
logger: logSpy
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cli-facade-registry-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const sinon = require('sinon');
describe('cli : facade : registry : add', () => {
const logSpy = {},
Registry = require('../../src/cli/domain/registry'),
registry = new Registry(),
registry = Registry(),
RegistryFacade = require('../../src/cli/facade/registry-add'),
registryFacade = new RegistryFacade({ registry: registry, logger: logSpy });
registryFacade = RegistryFacade({ registry: registry, logger: logSpy });

const execute = function() {
logSpy.err = sinon.spy();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cli-facade-registry-ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const sinon = require('sinon');
describe('cli : facade : registry : ls', () => {
const logSpy = {},
Registry = require('../../src/cli/domain/registry'),
registry = new Registry(),
registry = Registry(),
RegistryFacade = require('../../src/cli/facade/registry-ls'),
registryFacade = new RegistryFacade({ registry: registry, logger: logSpy });
registryFacade = RegistryFacade({ registry: registry, logger: logSpy });

const execute = function() {
logSpy.err = sinon.spy();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cli-facade-registry-remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const sinon = require('sinon');
describe('cli : facade : registry : remove', () => {
const logSpy = {},
Registry = require('../../src/cli/domain/registry'),
registry = new Registry(),
registry = Registry(),
RegistryFacade = require('../../src/cli/facade/registry-remove'),
registryFacade = new RegistryFacade({ registry: registry, logger: logSpy });
registryFacade = RegistryFacade({ registry: registry, logger: logSpy });

const execute = function() {
logSpy.err = sinon.spy();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/registry-domain-nested-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('registry : routes : helpers : nested-renderer', () => {
renderer = sinon.stub().yields(rendererMocks);
}

nestedRenderer = new NestedRenderer(renderer, conf || {});
nestedRenderer = NestedRenderer(renderer, conf || {});
};

describe('when rendering nested component', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/registry-domain-repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('registry : domain : repository', () => {
components: { 'hello-world': { '1.0.0': { publishDate: 1234567890 } } }
};

const repository = new Repository(cdnConfiguration);
const repository = Repository(cdnConfiguration);

describe('when getting the list of available components', () => {
before(done => {
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('registry : domain : repository', () => {
const conf = _.extend(cdnConfiguration, {
templates: [require('oc-template-jade')]
});
const repository = new Repository(conf);
const repository = Repository(conf);
expect(repository.getTemplatesInfo().length).to.equal(3);
});
});
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('registry : domain : repository', () => {
env: { name: 'local' }
};

const repository = new Repository(localConfiguration);
const repository = Repository(localConfiguration);

describe('when getting the list of available components', () => {
before(done => {
Expand Down
Loading

0 comments on commit 4386f6a

Please sign in to comment.