Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 29, 2024
1 parent 15a59e2 commit b7ef11f
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
push:
branches:
- main
paths:
- 'packages/cli/**'

jobs:
publish:
name: Publish
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Build
run: bun run build
- name: Get version
id: get_version
run: echo "version=$(node -p "require('./packages/cli/package.json').version")" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: Release v${{ steps.get_version.outputs.version }}
generate_release_notes: true
- name: Setup NPM Auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Publish to NPM
run: cd packages/cli && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on:
push:
branches:
- main

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: 🔍 Run type checking
run: bun run typecheck
# - name: 🚨 Run linting
# run: bun run lint
- name: 🧪 Run unit tests
run: bun run test
10 changes: 8 additions & 2 deletions packages/cli/src/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export async function clean() {
// Process each file format and pattern
for (const [format, { include }] of Object.entries(config.files)) {
for (const pattern of include) {
const sourcePath = pattern.replace("[locale]", source);
const sourcePath =
typeof pattern === "string"
? pattern.replace("[locale]", source)
: pattern.from.replace("[locale]", source);

// Read source file to get reference keys
const sourceContent = await fs.readFile(
Expand All @@ -37,7 +40,10 @@ export async function clean() {

// Clean each target locale file
for (const locale of targets) {
const targetPath = pattern.replace("[locale]", locale);
const targetPath =
typeof pattern === "string"
? pattern.replace("[locale]", locale)
: pattern.from.replace("[locale]", locale);

try {
const targetContent = await fs.readFile(
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/commands/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export async function diff() {
const sourceLocale = config.locale.source;
const [fileFormat] = Object.keys(config.files);
const sourcePattern = config.files[fileFormat].include[0];
const sourcePath = sourcePattern.replace("[locale]", sourceLocale);
const sourcePath =
typeof sourcePattern === "string"
? sourcePattern.replace("[locale]", sourceLocale)
: sourcePattern.from.replace("[locale]", sourceLocale);

// Get git diff for source file
const diff = execSync(`git diff HEAD -- ${sourcePath}`, {
Expand Down

0 comments on commit b7ef11f

Please sign in to comment.