Skip to content

Commit

Permalink
feat(v3): init packages
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Aug 28, 2018
1 parent b1ddca0 commit b192fc5
Show file tree
Hide file tree
Showing 54 changed files with 576 additions and 2,082 deletions.
File renamed without changes.
14 changes: 0 additions & 14 deletions config/babel.common.js

This file was deleted.

21 changes: 0 additions & 21 deletions config/rollup.config.common.js

This file was deleted.

31 changes: 0 additions & 31 deletions config/rollup.config.preact.js

This file was deleted.

29 changes: 0 additions & 29 deletions config/rollup.config.react.js

This file was deleted.

9 changes: 5 additions & 4 deletions packages/react/jest.config.js → jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
module.exports = {
rootDir: `./packages/${process.env.PKG}`,
testPathIgnorePatterns : ['node_modules'],
moduleFileExtensions : ['ts', 'tsx', 'js'],
setupFiles: [
'./jestSetup.js'
`./test/setup/index.js`
],
transform : {
'^.+\\.(ts|tsx)$' : 'ts-jest'
},
testMatch : [
'**/test/*.+(ts|tsx)',
'**/test/*.+(ts|tsx)'
]
`**/test/*.+(ts|tsx)`,
`**/test/*.+(ts|tsx)`
],
};
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"lerna": "2.5.1",
"lerna": "3.1.4",
"packages": [
".",
"packages/*"
],
"command": {
Expand Down
44 changes: 25 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
{
"name": "bem-react-core",
"version": "2.0.0",
"description": "BEM React Core",
"name": "bem-react",
"private": true,
"version": "3.0.0",
"description": "BEM React",
"repository": {
"url": "git://github.com/bem/bem-react-core.git",
"type": "git"
},
"keywords": [
"bem",
"react",
"preact",
"core"
],
"license": "MPL-2.0",
"scripts": {
"lint": "tsc -p . --noEmit && tslint -p . -t stylish",
"lint": "lerna run lint",
"test": "lerna run test",
"prepush": "lerna run test",
"commitmsg": "commitlint -e $GIT_PARAMS"
},
"devDependencies": {
"@babel/core": "7.0.0",
"@babel/helper-module-imports": "7.0.0",
"@babel/preset-env": "7.0.0",
"@commitlint/cli": "6.1.3",
"@commitlint/config-conventional": "6.1.3",
"babel-plugin-external-helpers": "6.22.0",
"babel-plugin-transform-object-assign": "6.22.0",
"babel-preset-env": "^1.6.1",
"gzip-size-cli": "2.1.0",
"@types/jest": "23.3.1",
"@types/react": "16.4.12",
"@types/react-dom": "16.0.7",
"chalk": "2.4.1",
"gzip-size-cli": "3.0.0",
"husky": "0.14.3",
"lerna": "^2.5.1",
"npm-run-all": "4.1.2",
"react-test-renderer": "16.3.0",
"rollup": "0.57.1",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-commonjs": "9.1.0",
"jest": "23.5.0",
"lerna": "3.2.0",
"rollup": "0.65.0",
"rollup-plugin-babel": "4.0.2",
"rollup-plugin-commonjs": "9.1.6",
"rollup-plugin-node-resolve": "3.3.0",
"rollup-plugin-replace": "2.0.0",
"tslint": "5.9.1",
"tslint-react": "3.5.1",
"typescript": "2.8.1",
"uglify-js": "3.3.18"
"rollup-plugin-typescript2": "0.17.0",
"rollup-plugin-uglify": "4.0.0",
"ts-jest": "23.1.4",
"tslint": "5.11.0",
"tslint-react": "3.6.0",
"typescript": "3.0.1",
"uglify-js": "3.4.8"
}
}
34 changes: 34 additions & 0 deletions packages/classname/classname.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { stringifyWrapper } from '@bem/sdk.naming.entity.stringify';

const react = require('@bem/sdk.naming.presets/react');

export type NoStrictEntityMods = Record<string, string | boolean | number | undefined>;

export type EntityFormatter = (mods?: NoStrictEntityMods) => string;

function modsToArray(block: string, elem?: string, mods?: NoStrictEntityMods) {
const arr = [];

if (!mods) return [];

for (const modName in mods) {
if (mods[modName] || mods[modName] === 0) {
arr.push({
block,
elem,
mod: {
name: modName,
val: mods[modName] === true ? true : String(mods[modName]),
},
});
}
}

return arr;
}

export function entity(block: string, elem?: string): EntityFormatter {
const naming = stringifyWrapper(react);

return (mods?: NoStrictEntityMods) => modsToArray(block, elem, mods).map(naming).join(' ');
}
File renamed without changes.
7 changes: 7 additions & 0 deletions packages/classname/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./build/cjs/di.production.min.js');
} else {
module.exports = require('./build/cjs/di.development.js');
}
35 changes: 35 additions & 0 deletions packages/classname/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@bem-react/classname",
"version": "0.0.1",
"description": "BEM React ClassName",
"repository": {
"url": "git://github.com/bem/bem-react-core.git",
"type": "git"
},
"keywords": [
"bem",
"core"
],
"main": "index.js",
"typings": ".rpt2_cache/placeholder/classname.d.ts",
"files": [
".rpt2_cache",
"build"
],
"license": "MPL-2.0",
"scripts": {
"prepublishOnly": "npm run build",
"build": "PKG=classname node ../../scripts/rollup/build.js",
"lint": "__DEV__=1 tsc -p . --noEmit && tslint -p . -t stylish",
"test": "echo 'PKG=classname NODE_ENV=test jest --config=../../jest.config.js'"
},
"dependencies": {
"@bem/sdk.naming.entity.stringify": "1.1.1",
"@bem/sdk.naming.presets": "0.2.2"
},
"peerDependencies": {
"react": "^15.6.2 || ^16.0.0"
},
"devDependencies": {
}
}
3 changes: 3 additions & 0 deletions packages/classname/test/placeholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
it('placeholder', () => {
expect(true).toBe(true);
});
Empty file.
3 changes: 3 additions & 0 deletions packages/classname/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.json"
}
File renamed without changes.
Loading

0 comments on commit b192fc5

Please sign in to comment.