@peterseibel/hug 0.1.6 → 0.1.8

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,21 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@v5
16
+ - uses: actions/setup-node@v5
17
+ with:
18
+ node-version: 24
19
+ registry-url: https://registry.npmjs.org
20
+ - run: npm install -g npm@latest
21
+ - run: npm publish --provenance --access public
package/DEVELOPMENT.md CHANGED
@@ -47,29 +47,27 @@ Scoped packages are private by default. To publish as public:
47
47
  npm publish --access public
48
48
  ```
49
49
 
50
- ### Subsequent releases
50
+ ### Automated publishing via GitHub Actions
51
51
 
52
- 1. Bump the version in `package.json` (or use `npm version`):
52
+ Pushing a version tag triggers a GitHub Actions workflow that publishes to npm
53
+ automatically using [Trusted Publishing](https://docs.npmjs.com/trusted-publishers/)
54
+ (OIDC — no npm token needed).
53
55
 
54
- ```bash
55
- npm version patch # 0.1.0 -> 0.1.1
56
- npm version minor # 0.1.1 -> 0.2.0
57
- npm version major # 0.2.0 -> 1.0.0
58
- ```
56
+ **One-time setup:**
59
57
 
60
- `npm version` creates a git commit and tag automatically.
58
+ 1. On npmjs.com, go to the package settings for `@peterseibel/hug`.
59
+ 2. Add a trusted publisher: your GitHub user/repo and workflow filename
60
+ (`publish.yml`).
61
61
 
62
- 2. Publish:
62
+ **To release:**
63
63
 
64
- ```bash
65
- npm publish
66
- ```
67
-
68
- 3. Push the version commit and tag:
64
+ ```bash
65
+ npm version patch # or minor / major
66
+ git push --follow-tags
67
+ ```
69
68
 
70
- ```bash
71
- git push && git push --tags
72
- ```
69
+ `npm version` bumps `package.json`, commits, and creates a `v*` tag. Pushing
70
+ the tag triggers the workflow in `.github/workflows/publish.yml`.
73
71
 
74
72
  ## Dependencies
75
73
 
package/README.md CHANGED
@@ -104,12 +104,17 @@ hug deployments
104
104
 
105
105
  ## Branch-per-environment pattern
106
106
 
107
- Use `hug fork` with git branches to maintain separate Apps Script projects:
107
+ Use `hug fork` and `hug config` combined with git branches to maintain separate
108
+ Apps Script projects. Write code to use config values (e.g. using
109
+ `SPREADSHEET_ID` to a spreadsheet the script should use) rather than using
110
+ container-bound projects and then different branches can use different AppScript
111
+ projects each configured with separate resources as needed. And shared resources
112
+ can be shared by simply using the same config values.
108
113
 
109
114
  ```bash
110
- git checkout -b staging
115
+ git switch -c staging
111
116
  hug fork # new Apps Script project, updates .clasp.json
112
117
  hug config set SPREADSHEET_ID=1Bx.. # point at a staging spreadsheet
113
118
  hug deploy # deploys to the staging project
114
- git checkout main # .clasp.json and config.js switch back to production
119
+ git switch main # .clasp.json and config.js switch back to production
115
120
  ```
package/bin/hug CHANGED
@@ -11,7 +11,7 @@ done
11
11
  HUG_ROOT="$(cd "$(dirname "$SOURCE")/.." && pwd)"
12
12
  source "$HUG_ROOT/lib/common.sh"
13
13
 
14
- VERSION="0.1.0"
14
+ VERSION=$(grep '"version"' "$HUG_ROOT/package.json" | sed 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
15
15
 
16
16
  usage() {
17
17
  cat <<EOF
@@ -27,7 +27,7 @@ Project commands:
27
27
  Development commands:
28
28
  push Push local files to Apps Script
29
29
  pull [-f|--force] Pull remote files (refuses if uncommitted changes)
30
- open Open the project in the Apps Script editor
30
+ open [--container] Open the project script (or container)
31
31
 
32
32
  Configuration:
33
33
  config List config values
@@ -287,6 +287,7 @@ _write_config() {
287
287
  fi
288
288
 
289
289
  cat > config.js <<EOF
290
+ // No need to export as all .gs files are loaded into the same namespace
290
291
  const CONFIG = {
291
292
  ${entries}};
292
293
  EOF
@@ -421,7 +422,16 @@ cmd_pull() {
421
422
 
422
423
  cmd_open() {
423
424
  local clasp; clasp=$(find_clasp)
424
- run_clasp "$clasp" open "$@"
425
+ if [[ "${1:-}" == "--container" ]]; then
426
+ shift
427
+ if ! grep -q '"parentId"' .clasp.json 2>/dev/null; then
428
+ echo "Error: this project is not container-bound (no parentId in .clasp.json)" >&2
429
+ exit 1
430
+ fi
431
+ run_clasp "$clasp" open-container "$@"
432
+ else
433
+ run_clasp "$clasp" open-script "$@"
434
+ fi
425
435
  }
426
436
 
427
437
  cmd_versions() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peterseibel/hug",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "A lightweight wrapper around clasp for managing Google Apps Script projects",
5
5
  "bin": {
6
6
  "hug": "bin/hug"
@@ -9,6 +9,10 @@
9
9
  "google-apps-script",
10
10
  "clasp"
11
11
  ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/gigamonkey/hug"
15
+ },
12
16
  "license": "ISC",
13
17
  "dependencies": {
14
18
  "@google/clasp": "^3.2.0"