Skip to content

Setup monorepo structure #167

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

Merged
merged 16 commits into from
Apr 21, 2018
46 changes: 42 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@
aliases:
- &restore-cache
keys:
- v3-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
- v4-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
# Fallback in case checksum fails
- v3-dependencies-{{ .Branch }}-
- v4-dependencies-{{ .Branch }}-

- &install
# --frozen-lockfile ensures the build will fail if the lockfile needs to be updated
run: yarn --no-progress --frozen-lockfile

- &build
run:
command: yarn build
working_directory: packages/scroll-into-view-if-needed

- &save-cache
paths:
- node_modules
key: v2-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
key: v4-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}

- &cypress-dependencies-install
run:
Expand All @@ -18,6 +27,28 @@ aliases:

version: 2
jobs:
Typecheck:
docker:
- image: circleci/node:8
steps:
- checkout
- restore-cache: *restore-cache
- *install
- run:
command: yarn typecheck
working_directory: packages/scroll-into-view-if-needed
- save-cache: *save-cache

Build:
docker:
- image: circleci/node:8
steps:
- checkout
- restore-cache: *restore-cache
- *install
- *build
- save-cache: *save-cache

Website:
docker:
- image: circleci/node:carbon-browsers
Expand All @@ -28,6 +59,8 @@ jobs:
command: node --version && npm --version && npx --version && yarn --version
- *cypress-dependencies-install
- restore-cache: *restore-cache
- *install
- *build
- run: echo TODO
- save-cache: *save-cache

Expand All @@ -37,7 +70,8 @@ jobs:
steps:
- checkout
- restore-cache: *restore-cache
- run: echo TODO build
- *install
- *build
- save-cache: *save-cache
- run: yarn semantic-release

Expand All @@ -46,9 +80,13 @@ workflows:
version: 2
Build and Deploy:
jobs:
- Typecheck
- Build
- Website
- Semantic Release:
requires:
- Typecheck
- Build
- Website
filters:
branches:
Expand Down
3 changes: 0 additions & 3 deletions .prettierrc

This file was deleted.

60 changes: 60 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"private": true,
"workspaces": [
"packages/*",
"website"
],
"scripts": {
"precommit": "lint-staged",
"predeploy:website": "cd packages/scroll-into-view-if-needed && yarn build",
"deploy:website": "cd website && yarn deploy"
},
"devDependencies": {
"husky": "0.14.3",
"lint-staged": "7.0.4",
"prettier": "1.12.1",
"prettier-package-json": "1.5.1"
},
"lint-staged": {
"*.js": [
"prettier --write",
"git add"
],
"*.{ts,tsx}": [
"prettier --write",
"git add"
],
"*.json": [
"prettier --write",
"git add"
],
"*.md": [
"prettier --write",
"git add"
],
"**/package.json": [
"prettier-package-json --write",
"git add"
],
"**/.babelrc": [
"prettier --write",
"git add"
]
},
"prettier": {
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"overrides": [
{
"files": ".babelrc",
"options": {
"parser": "json"
}
}
]
},
"resolutions": {
"@types/react": "*"
}
}
22 changes: 22 additions & 0 deletions packages/scroll-into-view-if-needed/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const BABEL_ENV = process.env.BABEL_ENV
const building = BABEL_ENV != undefined && BABEL_ENV !== 'cjs'

const plugins = []

if (process.env.NODE_ENV === 'production') {
plugins.push('dev-expression')
}

module.exports = {
presets: [
'@babel/preset-typescript',
[
'@babel/preset-env',
{
loose: true,
modules: building ? false : 'commonjs',
},
],
],
plugins: plugins,
}
6 changes: 6 additions & 0 deletions packages/scroll-into-view-if-needed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist
es
typings
umd
/*.js
!.babelrc.js
114 changes: 40 additions & 74 deletions packages/scroll-into-view-if-needed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,56 @@
"type": "git",
"url": "git+https://github.com/stipsan/scroll-into-view-if-needed.git"
},
"version": "0.0.0-dev",
"main": "dist/bundle.js",
"version": "2.0.0-dev",
"main": "index.js",
"files": [
"auto.js",
"compute.js",
"es",
"ponyfill.js",
"umd"
],
"scripts": {
"prebuild": "yarn clean",
"build": "yarn build:tsc && yarn build:rollup",
"build:example": "next build example",
"build:rollup": "rollup -c",
"build:tsc": "yarn tsc:main",
"clean": "rimraf dist",
"precommit": "lint-staged",
"predev": "yarn build",
"dev": "concurrently \"yarn tsc:main --watch\" \"yarn build:rollup -w\" \"next dev example\"",
"docs": "next build example && DOCS=true next export -o ./docs example && npx -p https://gist.github.com/stipsan/bbf4adcdafd9eabfa6a9a42397a1c1b9 -c 'git-update-ghpages'",
"build": "yarn build:cjs && yarn build:es && yarn build:umd && yarn build:umd.min",
"build:cjs": "BABEL_ENV=cjs babel src -d . --extensions '.ts'",
"build:es": "BABEL_ENV=es babel src -d es --extensions '.ts'",
"build:umd": "BABEL_ENV=umd NODE_ENV=development rollup -c -f umd -o umd/scroll-into-view-if-needed.js",
"build:umd.min": "BABEL_ENV=umd NODE_ENV=production rollup -c -f umd -o umd/scroll-into-view-if-needed.min.js",
"clean": "rimraf 'umd' 'es'",
"dev": "concurrently 'tsc --watch' 'yarn build:cjs --watch'",
"prepublishOnly": "unset npm_config_cafile && yarn build",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"prestart": "yarn build",
"start": "next start example",
"test": "cypress run --browser chrome --reporter junit --reporter-options 'mochaFile=junit/test-results.xml'",
"tsc:main": "tsc -p ."
"typecheck": "tsc"
},
"dependencies": {
"invariant": "2.2.4",
"warning": "3.0.0"
},
"devDependencies": {
"@cypress/browserify-preprocessor": "1.0.2",
"@types/next": "2.4.9",
"@types/node": "9.6.6",
"@types/prettier": "1.12.0",
"@types/react": "16.3.11",
"@types/react-dom": "16.0.5",
"@zeit/next-typescript": "0.1.1",
"babel-cli": "^6.23.0",
"@babel/cli": "7.0.0-beta.44",
"@babel/core": "7.0.0-beta.44",
"@babel/plugin-external-helpers": "7.0.0-beta.44",
"@babel/preset-env": "7.0.0-beta.44",
"@babel/preset-typescript": "7.0.0-beta.44",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-dev-expression": "0.2.1",
"babel-plugin-styled-components": "1.5.1",
"babel-preset-env": "^1.2.1",
"babel-preset-es2015-rollup": "^3.0.0",
"browserify": "16.2.0",
"bulma": "0.7.0",
"codemirror": "5.36.0",
"concurrently": "^3.5.0",
"cypress": "2.1.0",
"husky": "^0.14.3",
"lint-staged": "^4.3.0",
"next": "5.1.0",
"prettier": "1.12.0",
"prettier-browser": "git://github.com/prettier/prettier.git#1.8.2",
"prettier-package-json": "1.5.1",
"react": "16.3.1",
"react-codemirror2": "4.2.1",
"react-dom": "16.3.1",
"react-syntax-highlighter": "7.0.2",
"release-relief": "^1.0.1",
"release-relief": "1.0.1",
"rimraf": "^2.6.1",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^2.0.0",
"scroll-into-view-if-needed": "link:.",
"styled-components": "3.2.6",
"system-font-stack": "1.0.5",
"tsify": "4.0.0",
"typescript": "2.8.3",
"uglifyjs-webpack-plugin": "^1.0.1"
"rollup": "0.58.1",
"rollup-plugin-babel": "4.0.0-beta.4",
"rollup-plugin-commonjs": "9.1.0",
"rollup-plugin-node-resolve": "3.3.0",
"rollup-plugin-replace": "2.0.0",
"rollup-plugin-uglify": "3.0.0",
"typescript": "2.8.3"
},
"keywords": [
"behavior-smooth",
"if-needed",
"polyfill",
"ponyfill",
"scroll",
"scroll-into-view",
Expand All @@ -82,38 +68,18 @@
"smoothscroll",
"typescript"
],
"lint-staged": {
"*.js": [
"prettier --write",
"git add"
],
"*.{ts,tsx}": [
"prettier --write",
"git add"
],
"*.json": [
"prettier --write",
"git add"
],
"*.md": [
"prettier --write",
"git add"
],
"package.json": [
"prettier-package-json --write",
"git add"
"browserify": {
"transform": [
"loose-envify"
]
},
"module": "index.js",
"module": "es/index.js",
"release": {
"analyzeCommits": "semantic-release-tamia/analyzeCommits",
"verifyConditions": "condition-circle",
"generateNotes": "semantic-release-tamia/generateNotes",
"verifyRelease": "semantic-release-tamia/verifyRelease"
},
"resolutions": {
"@types/react": "16.3.11"
},
"sideEffects": false,
"typings": "typings/index.d.ts"
}
50 changes: 22 additions & 28 deletions packages/scroll-into-view-if-needed/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
import babel from 'rollup-plugin-babel'
import uglify from 'rollup-plugin-uglify'
import replace from 'rollup-plugin-replace'
import commonjs from 'rollup-plugin-commonjs'
import nodeResolve from 'rollup-plugin-node-resolve'
const globals = {}
import resolve from 'rollup-plugin-node-resolve'

const onwarn = message => {
const suppressed = ['UNRESOLVED_IMPORT', 'THIS_IS_UNDEFINED']

if (!suppressed.find(code => message.code === code)) {
return console.warn(message.message)
}
}

export default {
entry: 'index.js',
dest: 'dist/bundle.js',
format: 'umd',
moduleName: 'scrollIntoViewIfNeeded',
exports: 'default',
globals,
onwarn,
const config = {
input: 'src/index.ts',
name: 'scrollIntoView',
plugins: [
nodeResolve({
jsnext: true,
main: true,
babel({
exclude: 'node_modules/**',
}),
resolve({
extensions: ['.ts', '.js', '.json'],
}),

commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: 'node_modules/**', // Default: undefined

// if false then skip sourceMap generation for CommonJS modules
sourceMap: false, // Default: true
include: /node_modules/,
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
],
}

if (process.env.NODE_ENV === 'production') {
config.plugins.push(uglify())
}

export default config
Loading