Skip to content

Commit 3e681ff

Browse files
authored
chore: rework project side configuration (#64)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a pre-installation script to enforce the use of `pnpm` as the package manager. - Updated workspace configuration to include all subdirectories under `apps` and `libs`. - Added new GitHub Actions workflows for CI checks, cache cleanup, and release automation. - Implemented a new target for semantic release in the flowbite-angular library. - **Chores** - Modified CI workflow and other configuration files to transition from `npm` to `pnpm`. - Removed environment variables from the Vercel configuration. - Introduced a new composite action for installing dependencies using `pnpm`. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 8eaf281 + 3e1affc commit 3e681ff

File tree

19 files changed

+22874
-41695
lines changed

19 files changed

+22874
-41695
lines changed

.github/actions/setup/action.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
########################################################################################
2+
# "pnpm install" composite action for pnpm 7/8+ #
3+
#--------------------------------------------------------------------------------------#
4+
# Requirement: @setup/node should be run before #
5+
# #
6+
# Usage in workflows steps: #
7+
# #
8+
# - name: 📥 Monorepo install #
9+
# uses: ./.github/actions/pnpm-install #
10+
# with: #
11+
# enable-corepack: false # (default) #
12+
# cwd: ${{ github.workspace }}/apps/my-app # (default = '.') #
13+
# #
14+
# Reference: #
15+
# - latest: https://gist.github.com/belgattitude/838b2eba30c324f1f0033a797bab2e31 #
16+
# #
17+
# Versions: #
18+
# - 1.1.0 - 15-07-2023 - Add project custom directory support. #
19+
########################################################################################
20+
21+
name: 'PNPM install'
22+
description: 'Run pnpm install with cache enabled'
23+
24+
inputs:
25+
enable-corepack:
26+
description: 'Enable corepack'
27+
required: false
28+
default: 'false'
29+
cwd:
30+
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
31+
required: false
32+
default: '.'
33+
34+
runs:
35+
using: 'composite'
36+
37+
steps:
38+
- name: ⚙️ Enable Corepack
39+
if: ${{ inputs.enable-corepack == 'true' }}
40+
shell: bash
41+
working-directory: ${{ inputs.cwd }}
42+
run: |
43+
corepack enable
44+
echo "corepack enabled"
45+
46+
- uses: pnpm/action-setup@v4
47+
if: ${{ inputs.enable-corepack == 'false' }}
48+
with:
49+
run_install: false
50+
# If you're not setting the packageManager field in package.json, add the version here
51+
version: latest-9
52+
53+
- name: Expose pnpm config(s) through "$GITHUB_OUTPUT"
54+
id: pnpm-config
55+
shell: bash
56+
run: |
57+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
58+
59+
- name: Cache rotation keys
60+
id: cache-rotation
61+
shell: bash
62+
run: |
63+
echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
64+
65+
- uses: actions/cache@v4
66+
name: Setup pnpm cache
67+
with:
68+
path: ${{ steps.pnpm-config.outputs.STORE_PATH }}
69+
key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('**/pnpm-lock.yaml') }}
70+
restore-keys: |
71+
${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-
72+
73+
# Prevent store to grow over time (not needed with yarn)
74+
# Note: not perfect as it prune too much in monorepos so the idea
75+
# is to use cache-rotation as above. In the future this might work better.
76+
#- name: Prune pnpm store
77+
# shell: bash
78+
# run: pnpm prune store
79+
80+
- name: Install dependencies
81+
shell: bash
82+
working-directory: ${{ inputs.cwd }}
83+
run: pnpm install --frozen-lockfile --prefer-offline
84+
env:
85+
# Other environment variables
86+
HUSKY: '0' # By default do not run HUSKY install
87+
88+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
89+
uses: nrwl/nx-set-shas@v2

.github/workflows/cache_cleanup.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
2+
name: Cleanup caches for closed branches
3+
4+
on:
5+
pull_request:
6+
types:
7+
- closed
8+
workflow_dispatch:
9+
10+
jobs:
11+
cleanup:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v4
16+
17+
- name: Cleanup
18+
run: |
19+
gh extension install actions/gh-actions-cache
20+
21+
REPO=${{ github.repository }}
22+
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
23+
24+
echo "Fetching list of cache key"
25+
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 | grep pnpm)
26+
27+
## Setting this to not fail the workflow while deleting cache keys.
28+
set +e
29+
echo "Deleting caches..."
30+
for cacheKey in $cacheKeysForPR
31+
do
32+
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
33+
done
34+
echo "Done"
35+
env:
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci-checks.yaml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI Checks
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
concurrency: ${{ github.ref }}
8+
9+
jobs:
10+
lint:
11+
name: Lint the code 🕵
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out the code 🗄
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup NodeJS 💿
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
24+
- name: Monorepo install
25+
uses: ./.github/actions/setup
26+
27+
- name: Lint the code 🕵
28+
run: pnpm all:lint
29+
30+
test:
31+
name: Run unit tests 🔬
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Check out the code 🗄
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
38+
39+
- name: Setup NodeJS 💿
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: 20
43+
44+
- name: Monorepo install
45+
uses: ./.github/actions/setup
46+
47+
- name: Run unit tests 🔬
48+
run: pnpm all:test -- --ci --verbose
49+
50+
build:
51+
name: Build code 🛠
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Check out the code 🗄
55+
uses: actions/checkout@v4
56+
with:
57+
fetch-depth: 0
58+
59+
- name: Setup NodeJS 💿
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: 20
63+
64+
- name: Monorepo install
65+
uses: ./.github/actions/setup
66+
67+
- name: Build code 🛠
68+
run: pnpm all:build

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- next
9+
- next-major
10+
- alpha
11+
- beta
12+
13+
jobs:
14+
release:
15+
name: Release new version 🛠
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
issues: write
20+
pull-requests: write
21+
steps:
22+
- name: Check out the code 🗄
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Setup NodeJS 💿
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
32+
- name: Monorepo install
33+
uses: ./.github/actions/setup
34+
35+
- name: Release new version 🛠
36+
run: pnpm lib:release -- --ci --verbose --skip-nx-cache
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm run all:lint
4+
pnpm all:lint

.nxreleaserc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"repositoryUrl": "https://github.com/themesberg/flowbite-angular/",
3+
"tagFormat": "${PROJECT_NAME}@v${version}",
4+
"branches": ["main"]
5+
}
6+

.prettierignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
.angular
77

88
/.nx/cache
9-
/.nx/workspace-data
9+
/.nx/workspace-data
10+
11+
pnpm-lock.yaml

apps/docs/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@
104104
}
105105
}
106106
}
107-

docs/files/contributors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ To contribute, you will need (of course) to be able to build and start the docum
88

99
1. Make sure you have `Node.js > v20` installed
1010
2. Run `git clone https://github.com/themesberg/flowbite-angular.git`
11-
3. Run `npm i`
11+
3. Run `pnpm i`
1212
> [!WARNING]
1313
> If some errors happen, check the logs ; it could be some dependencies outside Node.js (example with [parcel library](https://github.com/parcel-bundler/watcher) ; this library needs a C++ compiler installed on the computer)
14-
4. Run `npm run docs:serve`
14+
4. Run `pnpm docs:serve`
1515
> [!TIP]
1616
> This will start local dev server on `localhost:4200`
1717

0 commit comments

Comments
 (0)