Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Remove orElse variants from Command (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 authored Dec 7, 2023
1 parent 9a4e2b0 commit 7456edd
Show file tree
Hide file tree
Showing 14 changed files with 479 additions and 409 deletions.
29 changes: 11 additions & 18 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
name: Setup
description: Perform standard setup and install dependencies.
description: Perform standard setup and install dependencies using pnpm.
inputs:
cachixAuthToken:
description: The cachix auth token
node-version:
description: The version of Node.js to install
required: true
default: 20.9.0

runs:
using: composite
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "::set-output name=pnpm_cache_dir::$(nix develop --command -- pnpm store path)"
- uses: actions/cache@v3
name: Cache pnpm
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Install node
uses: actions/setup-node@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
cache: pnpm
node-version: ${{ inputs.node-version }}
- name: Install dependencies
shell: bash
run: nix develop --command -- pnpm install --ignore-scripts
run: pnpm install --ignore-scripts
13 changes: 7 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies
uses: ./.github/actions/setup
with:
cachixAuthToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: nix develop --command -- pnpm build
- run: pnpm build
- name: Check source state
run: nix develop --command -- git add src && git diff-index --cached HEAD --exit-code src
- run: nix develop --command -- pnpm circular
run: git add src && git diff-index --cached HEAD --exit-code src
- run: pnpm circular
- name: Create Release Pull Request or Publish
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
id: changesets
uses: changesets/action@v1
with:
publish: nix develop --command -- pnpm changeset publish
version: pnpm update-version
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
11 changes: 3 additions & 8 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/setup
with:
cachixAuthToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Check flake.lock
uses: DeterminateSystems/flake-checker-action@main
with:
fail-mode: true
- run: nix develop --command -- pnpm check
- run: nix develop --command -- pnpm lint
- run: pnpm check
- run: pnpm lint
4 changes: 1 addition & 3 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ jobs:
fetch-depth: 0
- name: Install dependencies
uses: ./.github/actions/setup
with:
cachixAuthToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: nix develop --command -- pnpm docgen
- run: pnpm docgen
- name: Build pages Jekyll
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/jekyll-build-pages@v1
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,29 @@ jobs:

- name: Install dependencies
uses: ./.github/actions/setup
with:
cachixAuthToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Exit pre-release mode
if: ${{ hashFiles('.changeset/pre.json') != '' }}
run: nix develop --command -- pnpm changeset pre exit
run: pnpm changeset pre exit

- name: Version snapshot
run: nix develop --command -- pnpm changeset version --snapshot ${{ steps.command.outputs.snapshot }} | grep -q "All files have been updated"
run: pnpm changeset version --snapshot ${{ steps.command.outputs.snapshot }} | grep -q "All files have been updated"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build snapshot
run: nix develop --command -- pnpm build
run: pnpm build

- name: Set registry config
run: nix develop --command -- pnpm config set --location project "//registry.npmjs.org/:_authToken" "${{ secrets.NPM_TOKEN }}"
run: pnpm config set --location project "//registry.npmjs.org/:_authToken" "${{ secrets.NPM_TOKEN }}"

- name: Publish snapshot
id: snapshot
run: |
# Publish and extract published tags from stdout.
output=$(nix develop --command -- pnpm changeset publish --tag ${{ steps.command.outputs.snapshot }} --no-git-tag)
output=$(pnpm changeset publish --tag ${{ steps.command.outputs.snapshot }} --no-git-tag)
output=$(echo "$output" | awk '/packages published successfully:/{flag=1; next} flag')
output=$(echo "$output" | grep -o '@[^ ]*' | awk '{print "\"" $0 "\""}' | paste -sd ',')
output=$(echo "$output" | grep -o '[^ ]*@[^ ]*' | awk '{print "\"" $0 "\""}' | paste -sd ',')
echo "tags=[$output]" >> $GITHUB_OUTPUT
- name: Update comment (success)
Expand All @@ -96,7 +94,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const commands = ${{ steps.snapshot.outputs.tags }}.map(tag => '```sh\n' + `nix develop --command -- pnpm add ${tag}` + '\n```')
const commands = ${{ steps.snapshot.outputs.tags }}.map(tag => '```sh\n' + `pnpm add ${tag}` + '\n```')
const header = `**Good news @${{ github.actor }}, your snapshot has been published!**`
const footer = `You can review the build log [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).`
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/setup
with:
cachixAuthToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: nix develop --command -- pnpm vitest
- run: pnpm vitest
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@effect/build-utils": "^0.5.1",
"@effect/docgen": "^0.3.6",
"@effect/build-utils": "^0.7.0",
"@effect/docgen": "^0.3.7",
"@effect/eslint-plugin": "^0.1.2",
"@effect/language-service": "^0.0.21",
"@effect/platform": "^0.33.0",
Expand Down Expand Up @@ -99,7 +99,7 @@
"stackframe": "^1.3.4",
"tsx": "^4.6.2",
"typescript": "^5.3.2",
"vite": "^5.0.5",
"vite": "^5.0.6",
"vitest": "^1.0.1"
}
}
36 changes: 18 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/internal/cliApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,11 @@ const prefixCommand = <A>(self: Command.Command<A>): ReadonlyArray<string> => {
break
}
case "Map": {
command = command.command as InternalCommand.Instruction
break
}
case "OrElse": {
prefix = ReadonlyArray.empty()
command = undefined
command = command.command
break
}
case "Subcommands": {
command = command.parent as InternalCommand.Instruction
command = command.parent
break
}
}
Expand Down
Loading

0 comments on commit 7456edd

Please sign in to comment.