Skip to content

Commit

Permalink
chore: remove dependencies and fix task execution (#5)
Browse files Browse the repository at this point in the history
* Squash fix/task-run (merge-base acccf00, previous tip 5b7792a7e5b4b2b83df28824b44885e8a1bf8116)

commit 5b7792a7e5b4b2b83df28824b44885e8a1bf8116
Author: maastrich <pinsaultm@gmail.com>
Date:   Sat Nov 30 14:53:34 2024 +0100

    remove moonx binary

commit 8e7abcc0074db0e405a499f8870abe3be245f656
Author: maastrich <pinsaultm@gmail.com>
Date:   Sat Nov 30 14:52:42 2024 +0100

    chore: remove dependencies and fix task execution

* bump version to 0.1.4

* change: update postinstall script to prepare

* Refactor GitHub Actions workflows for improved structure and caching

* change: update workflow job name and refactor setup-binary script

* Add existence check for source binary before renaming

* Refactor GitHub Actions workflows to remove setup job and streamline dependency installation

* fix: update build command in deploy workflow to include current directory

* fix: update artifact upload path in deploy workflow

* fix: add permission change for renamed binary in setup-binary script

* fix: restore postinstall script in package.json

* fix: remove unused toto.js file
  • Loading branch information
maastrich authored Nov 30, 2024
1 parent acccf00 commit 74c6b58
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: check

on:
push:
branches:
- main
pull_request:
branches:
- main
Expand Down
36 changes: 30 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,42 @@ jobs:
build:
runs-on: ubuntu-latest
name: build and deploy
strategy:
matrix:
platform: [darwin, linux]
arch: [x64, arm64]
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- uses: pnpm/action-setup@v2
with:
version: 8
- name: install dependencies
run: bun install
- name: check prettier
run: bun run prettier
- name: add prepatch version
run: pnpm version prepatch --preid="pr-$GITHUB_RUN_ID" --no-git-tag-version
- run: bun install
- run: bun build . --target="bun-${{ matrix.platform }}-${{ matrix.arch }}" --outfile="bin/${{ matrix.platform }}-${{ matrix.arch }}" --compile
# upload the build artifact
- uses: actions/upload-artifact@v4
with:
path: bin
name: ${{ matrix.platform }}-${{ matrix.arch }}
deploy:
runs-on: ubuntu-latest
name: deploy
needs: build
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/cache/restore@v4
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
- uses: actions/download-artifact@v4
with:
path: bin
- run: pnpm version prepatch --preid="pr-$GITHUB_RUN_ID" --no-git-tag-version
if: github.event_name == 'pull_request'
- name: authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
Expand Down
5 changes: 0 additions & 5 deletions bin/moonx

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@maastrich/moonx",
"version": "0.1.3",
"version": "0.1.4",
"description": "A CLI tool to help you with moon syntax",
"keywords": [
"moon",
Expand All @@ -17,32 +17,30 @@
"mx": "bin/moonx"
},
"files": [
"src",
"bin"
"bin",
"scripts/setup-binary.js"
],
"scripts": {
"build": "bun build --compile . --outfile=\"bin/moonx\"",
"postinstall": "bun run build",
"postinstall": "node scripts/setup-binary.js",
"prettier": "prettier --write .",
"semver-check": "bun run scripts/semver-check.ts",
"sort": "bun x sort-package-json"
},
"dependencies": {
"@moonrepo/types": "^1.21.3",
"cac": "^6.7.14",
"chalk": "^5.3.0",
"node-emoji": "^2.1.0",
"nunjucks": "^3.2.4",
"yaml": "^2.3.4"
},
"devDependencies": {
"@moonrepo/types": "^1.21.3",
"@trivago/prettier-plugin-sort-imports": "^4.2.1",
"@types/nunjucks": "^3.2.6",
"@types/semver": "^7.5.5",
"@withfig/autocomplete-types": "^1.29.0",
"bun-types": "^1.0.11",
"cac": "^6.7.14",
"chalk": "^5.3.0",
"node-emoji": "^2.1.0",
"nunjucks": "^3.2.4",
"prettier": "^3.0.3",
"semver": "^7.6.3",
"sort-package-json": "^2.6.0"
"sort-package-json": "^2.6.0",
"yaml": "^2.3.4"
}
}
20 changes: 20 additions & 0 deletions scripts/setup-binary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { chmodSync, existsSync, renameSync } from "node:fs";
import { join } from "node:path";

const { platform, arch } = process;

const src = join(
process.cwd(),
"bin",
`${platform}-${arch}`,
`${platform}-${arch}`,
);
const dest = join(process.cwd(), "bin", "moonx");

if (!existsSync(src)) {
console.error(`Binary not found: ${src}`);
process.exit(0);
}

renameSync(src, dest);
chmodSync(dest, 0o755);
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ for (const [name, workspaces] of commands) {
return;
}

return moon([filterd.map((ws) => `${name}:${ws}`), rest].flat(), {
return moon([filterd.map((ws) => `${ws}:${name}`), rest].flat(), {
stdout: "inherit",
stderr: "inherit",
stdin: "inherit",
Expand Down

0 comments on commit 74c6b58

Please sign in to comment.