Skip to content

Commit

Permalink
refactor: 💡 Rename ima packages to @ima scoped packages (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipoliko committed Nov 13, 2019
1 parent 4b35a02 commit 337df5f
Show file tree
Hide file tree
Showing 133 changed files with 411 additions and 337 deletions.
2 changes: 1 addition & 1 deletion jest.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module.exports = {
verbose: true,
testEnvironment: 'node',
modulePaths: ['<rootDir>/'],
testRegex: '(/__tests__/.*|(\\.|/)(Spec))\\.jsx?$'
testRegex: '(/__tests__/).*Spec\\.jsx?$'
};
11 changes: 4 additions & 7 deletions packages/core/build.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
const js = [
'./node_modules/ima/**/!(vendorLinker|gulpfile|build|test|*Spec).{js,jsx}',
'!./node_modules/ima/polyfill/*.js'
'./node_modules/@ima/core/**/!(vendorLinker|gulpfile|build|test|*Spec).{js,jsx}',
'!./node_modules/@ima/core/polyfill/*.js'
];

const mainjs = ['./node_modules/ima/main.js'];

const vendors = {
common: ['ima-helpers', 'classnames', 'react', 'react-dom', 'memoize-one'],
common: ['@ima/helpers', 'classnames', 'react', 'react-dom', 'memoize-one'],

server: ['react-dom/server.js'],

client: [],

test: ['ima/test.js', 'react-test-renderer', 'enzyme']
test: ['@ima/core/test.js', 'react-test-renderer', 'enzyme']
};

module.exports = {
js,
mainjs,
vendors
};
1 change: 1 addition & 0 deletions packages/core/index.cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/ima.server.cjs.js');
1 change: 1 addition & 0 deletions packages/core/index.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/ima.server.esm';
13 changes: 0 additions & 13 deletions packages/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "@ima/core",
"version": "17.0.0-rc.3",
"description": "IMA.js framework for isomorphic javascript application",
"main": "dist/ima.server.cjs.js",
"module": "dist/ima.server.esm.js",
"main": "index.cjs.js",
"module": "index.esm.js",
"scripts": {
"test": "npm run test:jest && npm run test:es && npm run test:size",
"test:jest": "jest --no-watchman -c jest.conf.js",
"test:jest": "../../node_modules/.bin/jest --no-watchman -c jest.conf.js",
"test:es": "es-check es5 './polyfill/*.js'",
"test:size": "size-limit",
"preversion": "npm test",
Expand Down Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"classnames": "^2.2.6",
"ima-helpers": "^0.16.1",
"@ima/helpers": "^17.0.0-rc.3",
"memoize-one": "^5.1.1",
"node-fetch": "^2.6.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function generateConfig(environemnt) {
namedExports: true // Default: true
}),
replace({
"path.dirname(path.resolve('ima'))":
"path.dirname(require.resolve('ima'))",
"path.dirname(path.resolve('@ima/core'))":
"path.dirname(require.resolve('@ima/core'))",
delimiters: ['', '']
}),
jscc({
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import $Helper from 'ima-helpers';
import $Helper from '@ima/helpers';
import ns from './namespace';
import ObjectContainer from './ObjectContainer';
import Router from './router/Router';

ns.namespace('ima');
ns.namespace('ima.core');

/**
* Environment name value in the production environment.
Expand Down Expand Up @@ -177,4 +177,4 @@ export default class Bootstrap {
}
}

ns.ima.Bootstrap = Bootstrap;
ns.ima.core.Bootstrap = Bootstrap;
30 changes: 15 additions & 15 deletions packages/core/src/ObjectContainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ns from './namespace';

ns.namespace('ima');
ns.namespace('ima.core');

/**
* The Object Container is an enhanced dependency injector with support for
Expand Down Expand Up @@ -47,7 +47,7 @@ export default class ObjectContainer {
* @return {string} The IMA binding state.
*/
static get IMA_BINDING_STATE() {
return 'ima';
return 'ima.core';
}

/**
Expand All @@ -70,15 +70,15 @@ export default class ObjectContainer {
/**
* Initializes the object container.
*
* @param {ima.Namespace} namespace The namespace container, used to
* @param {ima.core.Namespace} namespace The namespace container, used to
* access classes and values using their fully qualified names.
*/
constructor(namespace) {
/**
* The namespace container, used to access classes and values using
* their fully qualified names.
*
* @type {ima.Namespace}
* @type {ima.core.Namespace}
*/
this._namespace = namespace;

Expand Down Expand Up @@ -134,15 +134,15 @@ export default class ObjectContainer {
if ($Debug) {
if (this._bindingState === ObjectContainer.PLUGIN_BINDING_STATE) {
throw new Error(
`ima.ObjectContainer:bind Object container ` +
`ima.core.ObjectContainer:bind Object container ` +
`is locked. You do not have the permission to ` +
`create a new alias named ${name}.`
);
}

if (typeof classConstructor !== 'function') {
throw new Error(
`ima.ObjectContainer:bind The second ` +
`ima.core.ObjectContainer:bind The second ` +
`argument has to be a class constructor function, ` +
`but ${classConstructor} was provided. Fix alias ` +
`${name} for your bind.js file.`
Expand Down Expand Up @@ -190,15 +190,15 @@ export default class ObjectContainer {
if ($Debug) {
if (this._entries.has(name) || !!this._getEntryFromConstant(name)) {
throw new Error(
`ima.ObjectContainer:constant The ${name} ` +
`ima.core.ObjectContainer:constant The ${name} ` +
`constant has already been declared and cannot be ` +
`redefined.`
);
}

if (this._bindingState === ObjectContainer.PLUGIN_BINDING_STATE) {
throw new Error(
`ima.ObjectContainer:constant The ${name} ` +
`ima.core.ObjectContainer:constant The ${name} ` +
`constant can't be declared in plugin. ` +
`The constant must be define in app/config/bind.js file.`
);
Expand Down Expand Up @@ -232,7 +232,7 @@ export default class ObjectContainer {
if ($Debug) {
if (typeof classConstructor !== 'function') {
throw new Error(
`ima.ObjectContainer:inject The first ` +
`ima.core.ObjectContainer:inject The first ` +
`argument has to be a class constructor function, ` +
`but ${classConstructor} was provided. Fix your ` +
`bind.js file.`
Expand All @@ -244,7 +244,7 @@ export default class ObjectContainer {
this._bindingState === ObjectContainer.PLUGIN_BINDING_STATE
) {
throw new Error(
`ima.ObjectContainer:inject The ` +
`ima.core.ObjectContainer:inject The ` +
`${classConstructor.name} has already had its ` +
`default dependencies configured, and the object ` +
`container is currently locked, therefore the ` +
Expand Down Expand Up @@ -299,7 +299,7 @@ export default class ObjectContainer {
this._bindingState === ObjectContainer.PLUGIN_BINDING_STATE
) {
throw new Error(
'ima.ObjectContainer:provide The ' +
'ima.core.ObjectContainer:provide The ' +
'implementation of the provided interface ' +
`(${interfaceConstructor.name}) has already been ` +
`configured and cannot be overridden.`
Expand All @@ -310,7 +310,7 @@ export default class ObjectContainer {
let prototype = implementationConstructor.prototype;
if (!(prototype instanceof interfaceConstructor)) {
throw new Error(
'ima.ObjectContainer:provide The specified ' +
'ima.core.ObjectContainer:provide The specified ' +
`class (${implementationConstructor.name}) does not ` +
`implement the ${interfaceConstructor.name} ` +
`interface.`
Expand Down Expand Up @@ -441,7 +441,7 @@ export default class ObjectContainer {
setBindingState(bindingState, bindingPluginName = null) {
if (this._bindingState === ObjectContainer.APP_BINDING_STATE) {
throw new Error(
`ima.ObjectContainer:setBindingState The setBindingState() ` +
`ima.core.ObjectContainer:setBindingState The setBindingState() ` +
`method has to be called only by the bootstrap script. Other ` +
`calls are not allowed.`
);
Expand Down Expand Up @@ -486,7 +486,7 @@ export default class ObjectContainer {
if ($Debug) {
if (!entry) {
throw new Error(
`ima.ObjectContainer:_getEntry There is no constant, ` +
`ima.core.ObjectContainer:_getEntry There is no constant, ` +
`alias, registered class, registered interface with ` +
`configured implementation or namespace entry ` +
`identified as ${name}. Check your bind.js file for ` +
Expand Down Expand Up @@ -705,7 +705,7 @@ export default class ObjectContainer {
}
}

ns.ima.ObjectContainer = ObjectContainer;
ns.ima.core.ObjectContainer = ObjectContainer;

/**
* Object container entry, representing either a class, interface, constant or
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/BootstrapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('Bootstrap', () => {
$Env: 'prod',
__meta__: {}
},
'ima'
'ima.core'
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/ObjectContainerSpec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ObjectContainer from '../ObjectContainer';
import ns from '../namespace';

describe('ima.ObjectContainer', () => {
describe('ima.core.ObjectContainer', () => {
let oc = null;

function classConstructorWithDependencies(dependency) {
Expand Down
17 changes: 15 additions & 2 deletions packages/core/src/__tests__/renderServerAppSpec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import React from 'react';
import $Helper from 'ima-helpers';
import $Helper from '@ima/helpers';
import ControllerInterface from '../controller/Controller';
import ServerPageRenderer from '../page/renderer/ServerPageRenderer';
import Response from '../router/Response';
import * as ima from '../main';
import vendorLinker from '../vendorLinker';

jest.mock('path', () => {
const original = jest.requireActual('path');
const resolve = (...args) => {
if (args[1] === undefined && args[0] === '@ima/core') {
return original.join(process.cwd(), 'index.js');
}

return original.resolve(...args);
};

return Object.assign({}, original, { resolve });
});

describe('Render server application', () => {
let router = null;
let ReactDOM = {
Expand Down Expand Up @@ -55,7 +68,7 @@ describe('Render server application', () => {
beforeAll(done => {
vendorLinker.set('react', React);
vendorLinker.set('react-dom', ReactDOM);
vendorLinker.set('ima-helpers', $Helper);
vendorLinker.set('@ima/helpers', $Helper);

let app = ima.createImaApp();
let bootConfig = ima.getClientBootConfig(
Expand Down
17 changes: 15 additions & 2 deletions packages/core/src/__tests__/reviveClientAppSpec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import React from 'react';
import jsdom from 'jsdom';
import $Helper from 'ima-helpers';
import $Helper from '@ima/helpers';
import ControllerInterface from '../controller/Controller';
import AbstractDocumentView from '../page/AbstractDocumentView';
import * as ima from '../main';
import vendorLinker from '../vendorLinker';

jest.mock('path', () => {
const original = jest.requireActual('path');
const resolve = (...args) => {
if (args[1] === undefined && args[0] === '@ima/core') {
return original.join(process.cwd(), 'index.js');
}

return original.resolve(...args);
};

return Object.assign({}, original, { resolve });
});

const MASTER_ELEMENT_ID = 'some-id';

describe('Revive client application', () => {
Expand Down Expand Up @@ -98,7 +111,7 @@ describe('Revive client application', () => {

vendorLinker.set('react', React);
vendorLinker.set('react-dom', ReactDOM);
vendorLinker.set('ima-helpers', $Helper);
vendorLinker.set('@ima/helpers', $Helper);

spyOn(ReactDOM, 'render');

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/cache/CacheImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class CacheImpl extends Cache {
if ($Debug) {
if (!this._canSerializeValue(serializeEntry.value)) {
throw new Error(
`ima.cache.CacheImpl:serialize An ` +
`ima.core.cache.CacheImpl:serialize An ` +
`attempt to serialize ` +
`${serializeEntry.value.toString()}, stored ` +
`using the key ${key}, was made, but the value ` +
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/cache/__tests__/CacheEntrySpec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import CacheEntry from '../CacheEntry';

describe('ima.cache.CacheEntry', () => {
describe('ima.core.cache.CacheEntry', () => {
let cacheEntry = null;

beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/cache/__tests__/CacheImplSpec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Helper from 'ima-helpers';
import Helper from '@ima/helpers';
import CacheFactory from '../CacheFactory';
import Cache from '../CacheImpl';
import MapStorage from 'src/storage/MapStorage';

describe('ima.cache.CacheImpl', () => {
describe('ima.core.cache.CacheImpl', () => {
let cache = null;
let cacheStorage = null;
let cacheFactory = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config/bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import Window from '../window/Window';

export default (ns, oc, config) => {
//**************START VENDORS**************
oc.constant('$Helper', vendorLinker.get('ima-helpers', true));
oc.constant('$Helper', vendorLinker.get('@ima/helpers', true));

//React
oc.constant('$React', vendorLinker.get('react', true));
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/controller/AbstractController.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class AbstractController extends Controller {
*/
load() {
throw new GenericError(
'The ima.controller.AbstractController.load method is abstract ' +
'The ima.core.controller.AbstractController.load method is abstract ' +
'and must be overridden'
);
}
Expand Down Expand Up @@ -125,7 +125,7 @@ export default class AbstractController extends Controller {
*/
setMetaParams() {
throw new GenericError(
'The ima.controller.AbstractController.setMetaParams method is ' +
'The ima.core.controller.AbstractController.setMetaParams method is ' +
'abstract and must be overridden'
);
}
Expand Down
Loading

0 comments on commit 337df5f

Please sign in to comment.