launchr-cli 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ name: Deploy GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - docs/**
9
+ - .github/workflows/deploy-pages.yml
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ contents: read
14
+ pages: write
15
+ id-token: write
16
+
17
+ concurrency:
18
+ group: pages
19
+ cancel-in-progress: true
20
+
21
+ jobs:
22
+ deploy:
23
+ runs-on: ubuntu-latest
24
+ environment:
25
+ name: github-pages
26
+ url: ${{ steps.deployment.outputs.page_url }}
27
+ steps:
28
+ - name: Checkout
29
+ uses: actions/checkout@v4
30
+
31
+ - name: Setup Pages
32
+ uses: actions/configure-pages@v5
33
+
34
+ - name: Upload artifact
35
+ uses: actions/upload-pages-artifact@v3
36
+ with:
37
+ path: docs
38
+
39
+ - name: Deploy to GitHub Pages
40
+ id: deployment
41
+ uses: actions/deploy-pages@v4
@@ -7,8 +7,21 @@ on:
7
7
  release:
8
8
  types:
9
9
  - published
10
+ workflow_dispatch:
11
+ inputs:
12
+ dry_run:
13
+ description: "Run validation only (do not publish to npm)"
14
+ required: false
15
+ type: boolean
16
+ default: true
17
+ tag:
18
+ description: "Optional tag to validate (example: v1.2.3)"
19
+ required: false
20
+ type: string
21
+ default: ""
10
22
 
11
23
  permissions:
24
+ id-token: write
12
25
  contents: read
13
26
 
14
27
  jobs:
@@ -25,10 +38,18 @@ jobs:
25
38
  - name: Setup Node.js
26
39
  uses: actions/setup-node@v4
27
40
  with:
28
- node-version: 20
29
- registry-url: https://registry.npmjs.org
41
+ node-version: 24
30
42
  cache: npm
31
43
 
44
+ - name: Verify npm version supports trusted publishing
45
+ run: |
46
+ NPM_VERSION="$(npm --version)"
47
+ echo "npm version: ${NPM_VERSION}"
48
+ if [ "$(printf '%s\n' "11.5.1" "${NPM_VERSION}" | sort -V | head -n1)" != "11.5.1" ]; then
49
+ echo "npm ${NPM_VERSION} is too old for trusted publishing (requires >=11.5.1)."
50
+ exit 1
51
+ fi
52
+
32
53
  - name: Install dependencies
33
54
  run: npm ci
34
55
 
@@ -40,6 +61,8 @@ jobs:
40
61
  run: |
41
62
  if [ "${{ github.event_name }}" = "release" ]; then
42
63
  TAG="${{ github.event.release.tag_name }}"
64
+ elif [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.tag }}" ]; then
65
+ TAG="${{ inputs.tag }}"
43
66
  else
44
67
  TAG="${{ github.ref_name }}"
45
68
  fi
@@ -50,6 +73,16 @@ jobs:
50
73
  PKG_VERSION="$(node -p "JSON.parse(require('fs').readFileSync('package.json', 'utf8')).version")"
51
74
  EXPECTED_TAG="v$PKG_VERSION"
52
75
 
76
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.dry_run }}" = "true" ] && [ -z "${{ inputs.tag }}" ]; then
77
+ echo "Dry run without tag input. Skipping tag/version check."
78
+ exit 0
79
+ fi
80
+
81
+ if [ -z "${{ steps.tag.outputs.tag }}" ]; then
82
+ echo "No tag resolved. Provide a tag input like $EXPECTED_TAG for manual publish."
83
+ exit 1
84
+ fi
85
+
53
86
  if [ "${{ steps.tag.outputs.tag }}" != "$EXPECTED_TAG" ]; then
54
87
  echo "Tag ${{ steps.tag.outputs.tag }} does not match package version $EXPECTED_TAG."
55
88
  exit 1
@@ -67,11 +100,25 @@ jobs:
67
100
  echo "already_published=false" >> "$GITHUB_OUTPUT"
68
101
  fi
69
102
 
103
+ - name: Ensure tokenless trusted publish path
104
+ if: steps.npm_check.outputs.already_published != 'true' && !(github.event_name == 'workflow_dispatch' && inputs.dry_run)
105
+ run: |
106
+ if [ -n "${NODE_AUTH_TOKEN:-}" ] || [ -n "${NPM_TOKEN:-}" ]; then
107
+ echo "Detected publish token env vars. Trusted publishing should run without npm write tokens."
108
+ exit 1
109
+ fi
110
+
70
111
  - name: Publish to npm
71
- if: steps.npm_check.outputs.already_published != 'true'
72
- run: npm publish --access public
73
- env:
74
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
112
+ if: steps.npm_check.outputs.already_published != 'true' && !(github.event_name == 'workflow_dispatch' && inputs.dry_run)
113
+ run: npm publish --access public --provenance
114
+
115
+ - name: Validate npm publish (dry run)
116
+ if: github.event_name == 'workflow_dispatch' && inputs.dry_run
117
+ run: npm publish --access public --dry-run
118
+
119
+ - name: Skip publish (dry run)
120
+ if: github.event_name == 'workflow_dispatch' && inputs.dry_run
121
+ run: echo "Dry run mode enabled. Publish step skipped."
75
122
 
76
123
  - name: Skip publish (already published)
77
124
  if: steps.npm_check.outputs.already_published == 'true'
@@ -0,0 +1,79 @@
1
+ # Contribution Guide
2
+
3
+ This document covers installation, local development, testing, and release flow for `launchr`.
4
+
5
+ ## Prerequisites
6
+ - Node.js 20+
7
+ - npm
8
+
9
+ ## Installation
10
+ From the repository root:
11
+
12
+ ```bash
13
+ npm install
14
+ npm link
15
+ ```
16
+
17
+ After linking, `launchr` is available in your shell.
18
+
19
+ ## Local Development
20
+ Run the CLI directly from source:
21
+
22
+ ```bash
23
+ npm start
24
+ ```
25
+
26
+ Run with arguments:
27
+
28
+ ```bash
29
+ npm start -- help
30
+ npm start -- list
31
+ ```
32
+
33
+ Use the linked binary:
34
+
35
+ ```bash
36
+ launchr help
37
+ ```
38
+
39
+ ## Configuration for Local Testing
40
+ The CLI reads commands from:
41
+
42
+ `~/.launchr-configurations/launchr-commands.json`
43
+
44
+ If the file is missing, run:
45
+
46
+ ```bash
47
+ launchr init
48
+ ```
49
+
50
+ or answer `yes` to the auto-create prompt.
51
+
52
+ ## Running Tests
53
+ ```bash
54
+ npm test
55
+ ```
56
+
57
+ ## Publish to npm (GitHub Actions)
58
+ The workflow is located at:
59
+
60
+ `.github/workflows/publish-npm.yml`
61
+
62
+ Publishing is triggered when you:
63
+ - push a tag matching `v*`
64
+ - publish a GitHub Release
65
+
66
+ Rules:
67
+ - tag must match package version in `package.json` (example: `v1.2.3`)
68
+ - tests must pass before publish
69
+ - if that version already exists on npm, publish is skipped
70
+
71
+ Required GitHub secret:
72
+ - `NPM_TOKEN` with npm publish access
73
+
74
+ Typical release flow:
75
+
76
+ ```bash
77
+ npm version patch
78
+ git push origin main --follow-tags
79
+ ```
package/README.md CHANGED
@@ -1,94 +1,59 @@
1
1
  # launchr CLI
2
2
 
3
- <p align="center">
4
- <img src="assets/launchr-logo.png" alt="launchr logo" width="420">
5
- </p>
3
+ ![launchr](assets/launchr-logo.png)
6
4
 
7
- `launchr` is a configuration-driven CLI to build URLs from typed parameters and open them in your default browser.
5
+ `launchr` is a configuration-driven CLI that turns typed flags into URLs and opens them in your default browser.
8
6
 
9
- Built with:
10
- - Node.js (ESM)
11
- - `zx`
12
- - `fs/promises`
7
+ ## Install via npm
8
+ `launchr` requires Node.js 20+.
13
9
 
14
- ## Requirements
15
- - Node.js 20+
10
+ Install globally:
16
11
 
17
- ## Install
18
12
  ```bash
19
- npm install
20
- npm link
13
+ npm install -g launchr-cli
14
+ launchr help
21
15
  ```
22
16
 
23
- After linking, `launchr` is available in your shell.
24
-
25
- ## Publish to npm (GitHub Actions)
26
- This repository includes an automated workflow at:
27
-
28
- `.github/workflows/publish-npm.yml`
29
-
30
- It publishes to npm when you either:
31
- - push a tag matching `v*`
32
- - publish a GitHub Release
17
+ Run without installing globally:
33
18
 
34
- Rules:
35
- - tag must match package version in `package.json` (example: `v1.2.3`)
36
- - tests must pass before publish
37
- - if that version already exists on npm, publish is skipped
38
-
39
- Required GitHub secret:
40
- - `NPM_TOKEN`: npm automation token with publish access
41
-
42
- Typical release flow:
43
19
  ```bash
44
- npm version patch
45
- git push origin main --follow-tags
20
+ npx launchr-cli help
46
21
  ```
47
22
 
48
- ## Configuration Location
49
- `launchr` uses:
23
+ Local development instructions are in [CONTRIBUTION.md](CONTRIBUTION.md).
50
24
 
51
- `~/.launchr-configurations/launchr-commands.json`
25
+ ## Product Features
26
+ - Configuration-driven custom commands defined in JSON.
27
+ - Interactive command creation with `launchr add` for command metadata, URL template, and parameter definitions.
28
+ - Typed runtime parameters with support for `string`, `integer`, `boolean`, and `single-choice-list`.
29
+ - Short-flag interface for all parameters (for example `-q`, `-e`, `-t`).
30
+ - Dynamic help and usage output for both built-in and custom commands.
31
+ - URL templating with named placeholders (for example `{query}`) mapped to parameter keys.
32
+ - Automatic config bootstrap prompt when the config file does not exist.
33
+ - Strong validation for config schema, placeholder integrity, unknown flags, required values, types, and allowed values.
52
34
 
53
- If the file is missing, the CLI prompts:
54
-
55
- `No configuration found. Do you want to create one? (yes/no)`
56
-
57
- If declined, the CLI exits with:
58
-
59
- `Configuration file is required to use this CLI.`
60
-
61
- ## Commands
35
+ ## Built-in Commands
62
36
  ```bash
63
37
  launchr
64
38
  launchr help
65
39
  launchr list
66
- launchr init
40
+ launchr add
67
41
  launchr <custom-command> help
68
42
  launchr <custom-command> [flags]
69
43
  ```
70
44
 
71
- ## Interactive Setup
72
- Run:
73
- ```bash
74
- launchr init
75
- ```
45
+ `launchr init` remains available as a deprecated alias in v1.x and will be removed in v2.0.0.
46
+
47
+ ## Configuration
48
+ Configuration is stored at:
49
+
50
+ `~/.launchr-configurations/launchr-commands.json`
51
+
52
+ If the file is missing, `launchr` prompts to create it. If you decline, the CLI exits with:
53
+
54
+ `Configuration file is required to use this CLI.`
76
55
 
77
- You will be asked for:
78
- - command name
79
- - description
80
- - URL template (with named placeholders like `{query}`)
81
- - parameters (loop until `done`)
82
- - key
83
- - type (`string`, `integer`, `boolean`, `single-choice-list`)
84
- - flag (`q` means `-q`)
85
- - required (`true/false`)
86
- - default value
87
- - allowed values (for `single-choice-list`)
88
-
89
- Type `finish` when asked for command name to stop immediately.
90
-
91
- ## JSON Example
56
+ ## Command Definition Example
92
57
  ```json
93
58
  {
94
59
  "grafana": {
@@ -100,10 +65,7 @@ Type `finish` when asked for command name to stop immediately.
100
65
  "flag": "e",
101
66
  "defaultValue": "staging",
102
67
  "required": true,
103
- "values": [
104
- "staging",
105
- "production"
106
- ]
68
+ "values": ["staging", "production"]
107
69
  },
108
70
  "query": {
109
71
  "type": "string",
@@ -113,38 +75,19 @@ Type `finish` when asked for command name to stop immediately.
113
75
  },
114
76
  "timeframe": {
115
77
  "type": "single-choice-list",
116
-
117
78
  "flag": "t",
118
79
  "defaultValue": "5m",
119
80
  "required": true,
120
- "values": [
121
- "5m",
122
- "10m",
123
- "1h",
124
- "6h"
125
- ]
81
+ "values": ["5m", "10m", "1h", "6h"]
126
82
  }
127
83
  }
128
84
  }
129
85
  }
130
86
  ```
131
87
 
132
- ## Usage Examples
88
+ ## Usage Example
133
89
  ```bash
134
90
  launchr list
135
91
  launchr grafana help
136
92
  launchr grafana -e production -q error -t 5m
137
93
  ```
138
-
139
- ## Validation and Errors
140
- - schema validation on config load
141
- - malformed JSON detection
142
- - required parameter checks
143
- - type checks (`string`, `integer`, `boolean`, `single-choice-list`)
144
- - allowed-value checks for `single-choice-list`
145
- - URL placeholder count checks
146
-
147
- ## Tests
148
- ```bash
149
- npm test
150
- ```
@@ -0,0 +1,15 @@
1
+ # launchr v1.1.0
2
+
3
+ Command naming transition release.
4
+
5
+ ## Highlights
6
+
7
+ - Added `launchr add` as the canonical interactive command-definition flow.
8
+ - Kept `launchr init` as a backward-compatible alias in v1.x.
9
+ - Added deprecation warning when alias is used: `"init" is deprecated. Use "launchr add".`
10
+ - Updated help output and documentation to guide users to `launchr add`.
11
+
12
+ ## Transition Policy
13
+
14
+ - v1.x: `add` is canonical; `init` remains available as deprecated alias.
15
+ - v2.0.0: `init` alias is removed; `add` is the only interactive entrypoint.
Binary file
Binary file
Binary file
Binary file
Binary file