Skip to content

Commit e0d66cf

Browse files
authored
refactor: migrate to monorepo (#138)
* feat: migrate to monorepo * fix: format * chore: remove old workflow
1 parent f9e138b commit e0d66cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+7321
-11145
lines changed

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** @type {import("eslint").Linter.Config} */
2+
module.exports = {
3+
env: {
4+
es6: true
5+
}
6+
}

.github/workflows/check-linter.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ jobs:
66
linter:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v3
10+
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # [email protected]
11+
12+
- name: Install Nodejs
13+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # [email protected]
14+
with:
15+
node-version: '18'
16+
cache: 'pnpm'
17+
1018
- name: Install modules
11-
run: yarn
19+
run: pnpm i
1220
- name: Run Prettier ESLint check
13-
run: yarn lint
21+
run: pnpm lint
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Notification Manager package release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'react-cookie-manager@[0-9]+.[0-9]+.[0-9]+'
7+
- 'sveltekit-cookie-manager@[0-9]+.[0-9]+.[0-9]+'
8+
9+
jobs:
10+
publish-npm-package:
11+
outputs:
12+
library_dir: ${{ steps.detect_tag.outputs.library_dir }}
13+
tag: ${{ github.ref_name }}
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 16
20+
registry-url: https://registry.npmjs.org/
21+
- name: Detect tag and set variable
22+
id: detect_tag
23+
run: |
24+
# Set the library name based on the tag
25+
if [[ ${{ github.ref }} =~ ^refs/tags/(.*)-cookie-manager.* ]]; then
26+
library_name=${BASH_REMATCH[1]}
27+
echo "library_dir=$library_name" >> "$GITHUB_OUTPUT"
28+
else
29+
echo "Invalid tag"
30+
exit 1
31+
fi
32+
33+
- name: Publish package
34+
# The package directory is the library name e.g "apps/sveltekit | apps/react"
35+
run: |
36+
cd cookie-manager/${{ steps.detect_tag.outputs.library_dir }} && \
37+
pnpm i && \
38+
pnpm package && \
39+
cp ../../LICENSE ../../NOTICE . && \
40+
npm publish --access=public
41+
env:
42+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
43+
44+
github_draft_release:
45+
needs: publish-npm-package
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v3
50+
- name: Prepare repository tags
51+
run: |
52+
# Fetch all tags
53+
if git rev-parse --is-shallow-repository | grep -q 'true'; then
54+
git fetch --prune --unshallow --tags -f
55+
else
56+
git fetch --prune --tags -f
57+
fi
58+
- name: Build changelog
59+
id: build_changelog
60+
run: |
61+
echo "Building changelog..."
62+
63+
# Create a changelog file with a header:
64+
echo "# What's Changed" > CHANGELOG.md
65+
66+
# Get the current tag from the workflow
67+
current_tag="${{ needs.publish-npm-package.outputs.tag }}"
68+
69+
# Extract the tag type from the current tag
70+
current_tag_type=$(echo "$current_tag" | awk -F'@' '{print $1}')
71+
72+
library_tags=$(git tag -l "$current_tag_type@*" --sort=-v:refname)
73+
74+
tag_array=()
75+
while IFS= read -r line; do
76+
tag_array+=("$line")
77+
done <<< "$library_tags"
78+
79+
current_tag_index=-1
80+
for i in "${!tag_array[@]}"; do
81+
if [ "${tag_array[$i]}" == "$current_tag" ]; then
82+
current_tag_index=$i
83+
break
84+
fi
85+
done
86+
87+
if [ "$current_tag_index" -eq -1 ]; then
88+
echo "Current tag $current_tag not found in the available tags."
89+
exit 1
90+
fi
91+
92+
if [ "$current_tag_index" -lt $((${#tag_array[@]} - 1)) ]; then
93+
prev_tag="${tag_array[$((current_tag_index + 1))]}"
94+
else
95+
prev_tag=$(git rev-list --max-parents=0 HEAD)
96+
fi
97+
98+
last_commit=$(git rev-list -n 1 "$prev_tag")
99+
100+
# Fill the changelog file with the commits since the last tag
101+
# Set max tries to equal the maximum number of commits as protection
102+
max_tries=$(git rev-list --count HEAD)
103+
i=0
104+
while [ "$(git rev-parse HEAD~$i)" != "$last_commit" ] && [ $i -lt $((max_tries-1)) ]; do
105+
commit_message=$(git show -s --format=%s HEAD~$i)
106+
echo "- $commit_message" >> CHANGELOG.md
107+
i=$((i+1))
108+
done
109+
110+
# Set the complete changelog URL
111+
echo >> CHANGELOG.md
112+
compare="${prev_tag}...${current_tag}"
113+
114+
echo "Appending full changelog URL to CHANGELOG.md..."
115+
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${compare}" >> CHANGELOG.md
116+
117+
echo "Changelog built successfully."
118+
119+
- name: Create draft release
120+
uses: softprops/action-gh-release@v1
121+
with:
122+
name: '@boxfish-studio/${{ github.ref_name }}'
123+
tag_name: ${{ github.ref_name }}
124+
body_path: CHANGELOG.md
125+
draft: true

.github/workflows/package-release.yml

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

.gitignore

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
1-
.DS_Store
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# Dependencies
24
node_modules
3-
/build
4-
/.svelte-kit
5-
/package
5+
.pnp
6+
.pnp.js
7+
8+
# Local env files
69
.env
7-
.env.*
8-
!.env.example
10+
.env.local
11+
.env.development.local
12+
.env.test.local
13+
.env.production.local
14+
15+
# Testing
16+
coverage
17+
18+
# Turbo
19+
.turbo
20+
21+
# Vercel
22+
.vercel
23+
24+
# Build Outputs
25+
.next/
26+
out/
27+
build
28+
dist
29+
30+
# Debug
31+
npm-debug.log*
32+
yarn-debug.log*
33+
yarn-error.log*
34+
35+
# Misc
36+
.DS_Store
37+
*.pem
938
.eslintcache
39+
40+
# Cookie Manager Package Specific
41+
cookie-manager/*/src/lib/cookie-core

.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-
npx lint-staged --allow-empty
4+
pnpm exec lint-staged --allow-empty

.npmrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
engine-strict=true

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pnpm-lock.yaml
2+
yarn.lock
3+
node_modules
4+
dist
5+
.svelte-kit
6+
.turbo

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"singleQuote": true,
44
"trailingComma": "none",
55
"printWidth": 100,
6-
"semi": false
6+
"semi": false,
7+
"plugins": ["prettier-plugin-svelte"]
78
}

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"eslint.workingDirectories": [
3+
{
4+
"mode": "auto"
5+
}
6+
]
7+
}

0 commit comments

Comments
 (0)