@peterseibel/hug 0.1.5 → 0.1.7

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.
Files changed (3) hide show
  1. package/README.md +8 -3
  2. package/bin/hug +14 -2
  3. package/package.json +1 -1
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
@@ -4,7 +4,9 @@ set -euo pipefail
4
4
 
5
5
  SOURCE="${BASH_SOURCE[0]}"
6
6
  while [[ -L "$SOURCE" ]]; do
7
+ DIR="$(cd "$(dirname "$SOURCE")" && pwd)"
7
8
  SOURCE="$(readlink "$SOURCE")"
9
+ [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE"
8
10
  done
9
11
  HUG_ROOT="$(cd "$(dirname "$SOURCE")/.." && pwd)"
10
12
  source "$HUG_ROOT/lib/common.sh"
@@ -25,7 +27,7 @@ Project commands:
25
27
  Development commands:
26
28
  push Push local files to Apps Script
27
29
  pull [-f|--force] Pull remote files (refuses if uncommitted changes)
28
- open Open the project in the Apps Script editor
30
+ open [--container] Open the project script (or container)
29
31
 
30
32
  Configuration:
31
33
  config List config values
@@ -285,6 +287,7 @@ _write_config() {
285
287
  fi
286
288
 
287
289
  cat > config.js <<EOF
290
+ // No need to export as all .gs files are loaded into the same namespace
288
291
  const CONFIG = {
289
292
  ${entries}};
290
293
  EOF
@@ -419,7 +422,16 @@ cmd_pull() {
419
422
 
420
423
  cmd_open() {
421
424
  local clasp; clasp=$(find_clasp)
422
- 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
423
435
  }
424
436
 
425
437
  cmd_versions() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peterseibel/hug",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "A lightweight wrapper around clasp for managing Google Apps Script projects",
5
5
  "bin": {
6
6
  "hug": "bin/hug"