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

refactor: migrate to monorepo #138

Merged
merged 3 commits into from
Oct 2, 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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
env: {
es6: true
}
}
14 changes: 11 additions & 3 deletions .github/workflows/check-linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # [email protected]

- name: Install Nodejs
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # [email protected]
with:
node-version: '18'
cache: 'pnpm'

- name: Install modules
run: yarn
run: pnpm i
- name: Run Prettier ESLint check
run: yarn lint
run: pnpm lint
125 changes: 125 additions & 0 deletions .github/workflows/monorepo-package-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Notification Manager package release

on:
push:
tags:
- 'react-cookie-manager@[0-9]+.[0-9]+.[0-9]+'
- 'sveltekit-cookie-manager@[0-9]+.[0-9]+.[0-9]+'

jobs:
publish-npm-package:
outputs:
library_dir: ${{ steps.detect_tag.outputs.library_dir }}
tag: ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Detect tag and set variable
id: detect_tag
run: |
# Set the library name based on the tag
if [[ ${{ github.ref }} =~ ^refs/tags/(.*)-cookie-manager.* ]]; then
library_name=${BASH_REMATCH[1]}
echo "library_dir=$library_name" >> "$GITHUB_OUTPUT"
else
echo "Invalid tag"
exit 1
fi

- name: Publish package
# The package directory is the library name e.g "apps/sveltekit | apps/react"
run: |
cd cookie-manager/${{ steps.detect_tag.outputs.library_dir }} && \
pnpm i && \
pnpm package && \
cp ../../LICENSE ../../NOTICE . && \
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

github_draft_release:
needs: publish-npm-package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare repository tags
run: |
# Fetch all tags
if git rev-parse --is-shallow-repository | grep -q 'true'; then
git fetch --prune --unshallow --tags -f
else
git fetch --prune --tags -f
fi
- name: Build changelog
id: build_changelog
run: |
echo "Building changelog..."

# Create a changelog file with a header:
echo "# What's Changed" > CHANGELOG.md

# Get the current tag from the workflow
current_tag="${{ needs.publish-npm-package.outputs.tag }}"

# Extract the tag type from the current tag
current_tag_type=$(echo "$current_tag" | awk -F'@' '{print $1}')

library_tags=$(git tag -l "$current_tag_type@*" --sort=-v:refname)

tag_array=()
while IFS= read -r line; do
tag_array+=("$line")
done <<< "$library_tags"

current_tag_index=-1
for i in "${!tag_array[@]}"; do
if [ "${tag_array[$i]}" == "$current_tag" ]; then
current_tag_index=$i
break
fi
done

if [ "$current_tag_index" -eq -1 ]; then
echo "Current tag $current_tag not found in the available tags."
exit 1
fi

if [ "$current_tag_index" -lt $((${#tag_array[@]} - 1)) ]; then
prev_tag="${tag_array[$((current_tag_index + 1))]}"
else
prev_tag=$(git rev-list --max-parents=0 HEAD)
fi

last_commit=$(git rev-list -n 1 "$prev_tag")

# Fill the changelog file with the commits since the last tag
# Set max tries to equal the maximum number of commits as protection
max_tries=$(git rev-list --count HEAD)
i=0
while [ "$(git rev-parse HEAD~$i)" != "$last_commit" ] && [ $i -lt $((max_tries-1)) ]; do
commit_message=$(git show -s --format=%s HEAD~$i)
echo "- $commit_message" >> CHANGELOG.md
i=$((i+1))
done

# Set the complete changelog URL
echo >> CHANGELOG.md
compare="${prev_tag}...${current_tag}"

echo "Appending full changelog URL to CHANGELOG.md..."
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${compare}" >> CHANGELOG.md

echo "Changelog built successfully."

- name: Create draft release
uses: softprops/action-gh-release@v1
with:
name: '@boxfish-studio/${{ github.ref_name }}'
tag_name: ${{ github.ref_name }}
body_path: CHANGELOG.md
draft: true
81 changes: 0 additions & 81 deletions .github/workflows/package-release.yml

This file was deleted.

44 changes: 38 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
.DS_Store
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Dependencies
node_modules
/build
/.svelte-kit
/package
.pnp
.pnp.js

# Local env files
.env
.env.*
!.env.example
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
.next/
out/
build
dist

# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Misc
.DS_Store
*.pem
.eslintcache

# Cookie Manager Package Specific
cookie-manager/*/src/lib/cookie-core
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged --allow-empty
pnpm exec lint-staged --allow-empty
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
engine-strict=true
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pnpm-lock.yaml
yarn.lock
node_modules
dist
.svelte-kit
.turbo
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"semi": false
"semi": false,
"plugins": ["prettier-plugin-svelte"]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
]
}
Loading
Loading