Skip to content
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

Added build:all and install-all scripts #117

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Update npm
run: npm install -g npm@^${{ matrix.npm }}

- name: Set up cache
- name: Cache
uses: actions/cache@v4
with:
path: ~/.npm
Expand All @@ -46,14 +46,8 @@ jobs:
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install library dependencies
run: npm ci
- name: Install examples/react-17 dependencies
run: cd examples/react-17 && npm ci
- name: Install examples/nextjs dependencies
run: cd examples/nextjs && npm ci
- name: Install examples/typescript dependencies
run: cd examples/typescript && npm ci
- name: Install
run: node scripts/install-all.js ci

- name: Lint
uses: wearerequired/lint-action@v2
Expand All @@ -64,14 +58,23 @@ jobs:
eslint_args: '--max-warnings 0'
eslint_extensions: js,jsx,ts,tsx

- name: Build library
run: npm run build
- name: Build examples/react-17
run: cd examples/react-17 && npm run build
- name: Build examples/nextjs
run: cd examples/nextjs && npm run build
- name: Build examples/typescript
run: cd examples/typescript && npm run build
- name: Build
run: npm run build:all

- name: Test
run: npm run test

install:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up node 20
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install
run: node scripts/install-all.js
2 changes: 1 addition & 1 deletion examples/nextjs/package-lock.json

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

3 changes: 3 additions & 0 deletions examples/react-17/package-lock.json

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

126 changes: 126 additions & 0 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"lint": "eslint src babel.config.js index.d.ts",
"build:clean": "rimraf dist lib bundles",
"build:files": "rollup --config",
"build": "npm run build:clean && npm run build:files"
"build": "npm run build:clean && npm run build:files",
"build:examples": "ts-node ./scripts/build-examples.ts",
"build:all": "npm run build && ts-node ./scripts/build-examples.ts"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -87,6 +89,7 @@
"rollup": "^4.12.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5"
},
"peerDependencies": {
Expand Down
16 changes: 16 additions & 0 deletions scripts/build-examples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { execSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';

const examples = path.join(__dirname, '..', 'examples');

fs.readdirSync(examples)
.map((p) => path.join(examples, p))
.filter((p) => fs.statSync(p).isDirectory())
.forEach((p) => {
console.log(`\n\x1b[32mBuilding \x1b[1m${p}\x1b[0m`);
execSync('npm run build', {
stdio: 'inherit',
cwd: p,
});
});
20 changes: 20 additions & 0 deletions scripts/install-all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');

const cmd = process.argv.includes('ci') ? 'npm ci' : 'npm install';

const root = path.join(__dirname, '..');
const examples = path.join(root, 'examples');

fs.readdirSync(examples)
.map((p) => path.join(examples, p))
.concat(root)
.filter((p) => fs.statSync(p).isDirectory())
.forEach((p) => {
console.log(`\n\x1b[32mInstalling (${cmd}) \x1b[1m${p}\x1b[0m`);
execSync(cmd, {
stdio: 'inherit',
cwd: p,
});
});
Loading