Skip to content

Commit

Permalink
feat: convert to monorepo (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruisaraiva19 authored Apr 13, 2022
1 parent 210efab commit 64071b3
Show file tree
Hide file tree
Showing 21 changed files with 2,919 additions and 839 deletions.
3 changes: 2 additions & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"buildCommand": "compile",
"buildCommand": "build",
"sandboxes": ["/packages/example"],
"node": "16"
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
dist
build
.cache
.parcel-cache
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build example
run: yarn example:build
run: yarn build --filter=react-youtube-example...
- name: Deploy to GitHub pages
if: success()
uses: crazy-max/ghaction-github-pages@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run tests
run: yarn test
run: yarn test --filter=react-youtube
- name: Build
run: yarn compile
run: yarn build --filter=react-youtube
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
run: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Install dependencies
run: yarn install
- name: Run tests
run: yarn test:ci
run: yarn test --filter=react-youtube
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
node_modules
npm-debug.log
dist
es
.vscode/*
.cache/*
.parcel-cache/*
build/*
dist/
.vscode/
.cache/
.parcel-cache/
build/
.turbo
4 changes: 0 additions & 4 deletions browserslist

This file was deleted.

46 changes: 0 additions & 46 deletions example/example.jsx

This file was deleted.

86 changes: 17 additions & 69 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,32 @@
{
"name": "react-youtube",
"version": "1.0.0-semantic-release",
"description": "React.js powered YouTube player component",
"main": "dist/YouTube.js",
"module": "dist/YouTube.mjs",
"types": "dist/YouTube.d.ts",
"targets": {
"main": false,
"module": false,
"types": false
},
"sideEffects": false,
"files": [
"dist/**"
],
"repository": {
"type": "git",
"url": "[email protected]:tjallingt/react-youtube.git"
},
"keywords": [
"react",
"youtube",
"player",
"react-component"
],
"author": "Tjalling Tolle <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/tjallingt/react-youtube/issues"
},
"homepage": "https://github.com/tjallingt/react-youtube",
"dependencies": {
"fast-deep-equal": "3.1.3",
"prop-types": "15.8.1",
"youtube-player": "5.5.2"
"private": true,
"scripts": {
"dev": "turbo run dev --parallel",
"build": "turbo run build",
"test": "turbo run test",
"clean": "turbo run clean && rm -rf node_modules",
"release": "turbo run release --concurrency=1",
"lint": "eslint packages --ext .ts,.tsx,.js,.jsx",
"commit": "git-cz",
"prepare": "husky install"
},
"devDependencies": {
"@commitlint/cli": "16.2.3",
"@commitlint/config-conventional": "16.2.1",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "12.1.4",
"@types/jest": "27.4.1",
"@types/youtube-player": "5.5.6",
"@typescript-eslint/eslint-plugin": "5.19.0",
"@typescript-eslint/parser": "5.19.0",
"commitizen": "4.2.4",
"cross-env": "7.0.3",
"cz-conventional-changelog": "3.3.0",
"eslint": "8.13.0",
"eslint-config-prettier": "8.5.0",
"eslint-config-react-app": "7.0.0",
"eslint-config-react-app": "7.0.1",
"eslint-plugin-prettier": "4.0.0",
"husky": "7.0.4",
"jest": "27.5.1",
"lint-staged": "12.3.7",
"parcel": "2.4.1",
"prettier": "2.6.2",
"process": "0.11.10",
"react": "17.0.2",
"react-dom": "17.0.2",
"ts-jest": "27.1.4",
"tsup": "5.12.4",
"turbo": "1.2.2",
"typescript": "4.6.3"
},
"peerDependencies": {
"react": ">=0.14.1"
},
"engines": {
"node": ">= 14.x"
},
"scripts": {
"test": "jest",
"test:ci": "jest --ci --runInBand",
"compile": "tsup src/YouTube.tsx --format esm,cjs --dts --external react",
"prepublishOnly": "npm run compile",
"lint": "eslint src example --ext .ts,.tsx,.js,.jsx",
"example": "parcel example/index.html --public-url /react-youtube/ --open",
"example:build": "parcel build example/index.html --public-url /react-youtube/ --dist-dir build",
"commit": "git-cz",
"prepare": "husky install"
},
"lint-staged": {
"*.js": "eslint --ext .ts,.tsx,.js,.jsx --fix",
"*.{html,json}": "prettier --write"
Expand All @@ -87,8 +36,7 @@
"path": "cz-conventional-changelog"
}
},
"jest": {
"testEnvironment": "jsdom",
"preset": "ts-jest"
}
"workspaces": [
"packages/*"
]
}
4 changes: 2 additions & 2 deletions example/README.md → packages/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Run with NPM:

```bash
$ npm run example
npm run dev
```

or with Yarn:

```bash
$ yarn example
yarn dev
```
5 changes: 3 additions & 2 deletions example/index.html → packages/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<title>react-youtube example</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="example.jsx"></script>
<div id="app"></div>

<script type="module" src="src/index.jsx"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions packages/example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "react-youtube-example",
"version": "0.0.0",
"description": "react-youtube example starter project",
"scripts": {
"dev": "parcel index.html --public-url /react-youtube/ --open",
"build": "parcel build index.html --public-url /react-youtube/ --dist-dir build",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
"dependencies": {
"react": "17.0.2",
"react-dom": "17.0.2",
"react-youtube": "0.0.0"
},
"devDependencies": {
"parcel": "2.4.1",
"process": "0.11.10"
},
"keywords": [
"javascript",
"starter"
],
"browserslist": "> 0.1%, not dead, not op_mini all, ie 11"
}
60 changes: 60 additions & 0 deletions packages/example/src/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import YouTube from 'react-youtube';

import './styles.css';

const VIDEOS = ['XxVg_s8xAms', '-DX3vJiqxm4'];

function YouTubeComponentExample() {
const [player, setPlayer] = useState(0);
const [videoIndex, setVideoIndex] = useState(0);
const [width, setWidth] = useState(600);
const [hidden, setHidden] = useState(false);
const [autoplay, setAutoplay] = useState(false);

return (
<div className="App">
<div style={{ display: 'flex', marginBottom: '1em' }}>
<button type="button" onClick={() => player.seekTo(120)}>
Seek to 2 minutes
</button>
<button type="button" onClick={() => setVideoIndex((videoIndex + 1) % VIDEOS.length)}>
Change video
</button>
<label>
<input
type="range"
min="300"
max="1080"
value={width}
onChange={(event) => setWidth(event.currentTarget.value)}
/>
Width ({width}px)
</label>
<button type="button" onClick={() => setHidden(!hidden)}>
{hidden ? 'Show' : 'Hide'}
</button>
<label>
<input type="checkbox" value={autoplay} onChange={(event) => setAutoplay(event.currentTarget.checked)} />
Autoplaying
</label>
</div>

{hidden ? (
'mysterious'
) : (
<YouTube
videoId={VIDEOS[videoIndex]}
autoplay={autoplay}
width={width}
height={width * (9 / 16)}
className="container"
onReady={(event) => setPlayer(event.target)}
/>
)}
</div>
);
}

ReactDOM.render(<YouTubeComponentExample />, document.getElementById('app'));
6 changes: 6 additions & 0 deletions packages/example/src/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#app {
font-family: sans-serif;
display: flex;
align-items: center;
flex-direction: column;
}
Loading

0 comments on commit 64071b3

Please sign in to comment.