Skip to content

Commit

Permalink
Added build:all and install-all scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
matux committed Feb 29, 2024
1 parent bae55a6 commit 8f540fd
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 19 deletions.
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.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.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(`Building ${p}`);
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(`Installing (${cmd}) ${p}`);
execSync(cmd, {
stdio: 'inherit',
cwd: p,
});
});

0 comments on commit 8f540fd

Please sign in to comment.