Skip to content

Commit

Permalink
feat: Improve monorepo workflow (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoRCD authored Jan 4, 2025
1 parent 0521269 commit 9cf35e9
Show file tree
Hide file tree
Showing 12 changed files with 312 additions and 110 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: stale

on:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest

permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v9
with:
exempt-issue-labels: triage,v3
stale-issue-message: 'This issue is stale because it has been open for 30 days with no activity.'
stale-issue-label: stale
stale-pr-label: stale
days-before-stale: 30
days-before-close: -1
Binary file modified bun.lockb
Binary file not shown.
13 changes: 1 addition & 12 deletions packages/cli/.env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
# Generated by Shelve CLI
NUXT_PRIVATE_RESEND_API_KEY=your_value
NUXT_PRIVATE_ENCRYPTION_KEY=your_value
NUXT_PRIVATE_ADMIN_EMAILS=your_value
TURBO_TOKEN=your_value
NUXT_OAUTH_GOOGLE_CLIENT_SECRET=your_value
NUXT_OAUTH_GITHUB_CLIENT_SECRET=your_value
NUXT_OAUTH_GOOGLE_CLIENT_ID=your_value
NUXT_SESSION_PASSWORD=your_value
DATABASE_URL=your_value
NUXT_PRIVATE_REDIS_URL=your_value
NUXT_OAUTH_GITHUB_CLIENT_ID=your_value
NUXT_PUBLIC_APP_URL=your_value
TEST=your_value
37 changes: 20 additions & 17 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img src="../../assets/preview.png" width="100%" alt="Shelve" />
<img src="../../assets/cover.png" width="100%" alt="Shelve" />

# Shelve CLI

Expand All @@ -22,25 +22,24 @@ bun a -d @shelve/cli

## Configuration

Configuration is loaded by [unjs/c12](https://github.com/unjs/c12) from cwd. You can use either `shelve.config.json`, `shelve.config.{ts,js,mjs,cjs}`, but running the CLI without any configuration will create a `shelve.config.json` file.
You have the option to create a `shelve.config.ts` file to enable type checking and autocompletion. The file should contain the following content:

```ts title="shelve.config.ts"
import { createShelveConfig } from "@shelve/cli"

export default createShelveConfig({
project: "my-project",
slug: "nuxtlabs",
token: "my-token",
url: "https://app.shelve.cloud",
confirmChanges: false,
envFileName: '.env',
autoUppercase: true,
})
```
Configuration is loaded from cwd. You can use either `shelve.json`, `shelve.config.json` or `.shelverc.json`, but running the CLI without any configuration will create a `shelve.json` file.

The CLI also has a json schema for the configuration file. that can be used to validate the configuration file. (see it [here](https://raw.githubusercontent.com/HugoRCD/shelve/main/packages/types/schema.json))

### Configuration example

```json
{
"slug": "nuxtlabs",
"project": "@nuxt/ui",
"confirmChanges": true
}
```

### Monorepo configuration

If you are using a monorepo, Shelve will automatically detect the root of the monorepo and look for the global `shelve.json` file. You can define here common configurations for all the projects in the monorepo (the team slug for example).

## Usage

```bash
Expand All @@ -65,6 +64,10 @@ Commands:
help [command] display help for command
```

### Monorepo usage

If you are using a monorepo, running a command at the root level will execute the command for all the projects in the monorepo that have a `shelve.json` file.

<!-- automd:fetch url="gh:hugorcd/markdown/main/src/local_development.md" -->

<details>
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shelve/cli",
"version": "2.12.0",
"version": "3.0.0",
"description": "The command-line interface for Shelve",
"homepage": "https://shelve.cloud",
"bugs": {
Expand Down Expand Up @@ -43,6 +43,7 @@
"@clack/prompts": "0.9.0",
"c12": "2.0.1",
"commander": "12.1.0",
"defu": "^6.1.4",
"npm-registry-fetch": "18.0.2",
"nypm": "0.4.1",
"ofetch": "1.4.1",
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/shelve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/HugoRCD/shelve/main/packages/types/schema.json",
"url": "http://localhost:3000",
"project": "@shelve/cli",
"slug": "shelve"
}
19 changes: 19 additions & 0 deletions packages/cli/src/services/file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs'
import { findFile as pkgFindFile } from 'pkg-types'

export class FileService {

Expand All @@ -18,4 +19,22 @@ export class FileService {
fs.unlinkSync(filename)
}

static async findFile(
patterns: string | string[],
options: { startingFrom: string; stopOnFirst?: boolean }
): Promise<string | null> {
const patternArray = Array.isArray(patterns) ? patterns : [patterns]

for (const pattern of patternArray) {
try {
const result = await pkgFindFile(pattern, options)
if (result && options.stopOnFirst) {
return result
}
} catch { /* empty */ }
}

return null
}

}
Loading

0 comments on commit 9cf35e9

Please sign in to comment.