Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nareshbhatia committed May 7, 2018
0 parents commit 6f9d3ab
Show file tree
Hide file tree
Showing 12 changed files with 5,085 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [ "env", "stage-1" ]
}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# testing
/coverage

# production
dist

# IDEs and editors
/.idea
/.vscode

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
Thumbs.db

*.log
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Lerna and Yarn Workspaces Concepts
==================================
This is an example to demonstrate Lerna and Yarn Workspaces concepts.

Getting Started
---------------
```bash
$ yarn
$ yarn build
$ yarn start
```

Testing
-------
```bash
$ yarn test
```
9 changes: 9 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"lerna": "2.9.0",
"packages": [
"packages/*"
],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true
}
43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "lerna-workspaces-concepts",
"description": "Example to demonstrate Lerna and Yarn Workspaces concepts",
"version": "1.0.0",
"private": true,
"author": "Naresh Bhatia",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/nareshbhatia/lerna-workspaces-concepts.git"
},
"workspaces": [
"packages/*"
],
"scripts": {
"test": "jest",
"del-dist": "lerna exec --parallel -- del-cli dist",
"prebuild": "yarn del-dist",
"build": "lerna exec -- babel src -d dist --ignore test.js",
"start": "node packages/weather-app/dist/weather-app"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-jest": "^22.4.3",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-1": "^6.24.1",
"del-cli": "^1.1.0",
"jest": "^22.4.3",
"lerna": "^2.9.0"
},
"jest": {
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 95,
"lines": 95,
"statements": 95
}
},
"collectCoverage": true
}
}
11 changes: 11 additions & 0 deletions packages/temp-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "temp-utils",
"description": "Temperature utilities",
"version": "1.0.0",
"author": "Naresh Bhatia",
"license": "MIT",
"main": "dist/index.js",
"dependencies": {
"lodash": "^4.17.5"
}
}
1 change: 1 addition & 0 deletions packages/temp-utils/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { c2f, f2c, average } from './temp-utils';
16 changes: 16 additions & 0 deletions packages/temp-utils/src/temp-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import reduce from 'lodash/reduce';

export function c2f(c) {
return c * 1.8 + 32;
}

export function f2c(f) {
return (f - 32) / 1.8;
}

export function average(temps) {
const sum = reduce(temps, function(sum, temp) {
return sum + temp;
}, 0);
return sum / temps.length;
}
13 changes: 13 additions & 0 deletions packages/temp-utils/src/temp-utils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { c2f, f2c, average } from './temp-utils';

test('converts 100 centigrade to 212 fahrenheit', () => {
expect(c2f(100)).toBe(212);
});

test('converts 212 fahrenheit to 100 centigrade', () => {
expect(f2c(212)).toBe(100);
});

test('calculates the average of [10, 20, 30] as 20', () => {
expect(average([10, 20, 30])).toBe(20);
});
11 changes: 11 additions & 0 deletions packages/weather-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "weather-app",
"description": "Weather App",
"version": "1.0.0",
"author": "Naresh Bhatia",
"license": "MIT",
"main": "weather-app.js",
"dependencies": {
"temp-utils": "^1.0.0"
}
}
5 changes: 5 additions & 0 deletions packages/weather-app/src/weather-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { c2f, f2c, average } from 'temp-utils';

console.log(`100 degrees C = ${c2f(100)} degrees F`);
console.log(`212 degrees F = ${f2c(212)} degrees C`);
console.log(`average of [10, 20, 30] = ${average([10, 20, 30])}`);
Loading

0 comments on commit 6f9d3ab

Please sign in to comment.