@runfile/cli 1.0.1 → 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.
- package/README.md +61 -7
- package/bin/darwin-arm64/run +0 -0
- package/bin/darwin-arm64/runfile-lsp +0 -0
- package/bin/darwin-x64/run +0 -0
- package/bin/darwin-x64/runfile-lsp +0 -0
- package/bin/linux-arm64/run +0 -0
- package/bin/linux-arm64/runfile-lsp +0 -0
- package/bin/linux-x64/run +0 -0
- package/bin/linux-x64/runfile-lsp +0 -0
- package/bin/win32-arm64/run.exe +0 -0
- package/bin/win32-arm64/runfile-lsp.exe +0 -0
- package/bin/win32-x64/run.exe +0 -0
- package/bin/win32-x64/runfile-lsp.exe +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,6 +193,39 @@ run _aws -- s3api put-bucket-policy --bucket {{ bucket }} --policy {{ policy }}
|
|
|
193
193
|
`run :format` lays the block out, and a missing brace is underlined in your editor as you type — not reported
|
|
194
194
|
by the far end an hour later.
|
|
195
195
|
|
|
196
|
+
### Reading JSON without jq
|
|
197
|
+
|
|
198
|
+
`json_query` walks a path and answers with a **list**, where `[]` descends into every element the way jq's
|
|
199
|
+
`.[]` does. What comes back is one of the language's own lists — something to loop over and count, not text to
|
|
200
|
+
parse a second time.
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
# runfiles/audit/gate.run
|
|
204
|
+
# Fail when a dependency has a high or critical vulnerability
|
|
205
|
+
|
|
206
|
+
let report = ARG.report ? "osv.json"
|
|
207
|
+
let severities = json_query(read_file(report), "results[].packages[].groups[].max_severity")
|
|
208
|
+
let high = 0
|
|
209
|
+
|
|
210
|
+
for severity in severities
|
|
211
|
+
if severity != "" && number(severity) >= 7
|
|
212
|
+
high = high + 1
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
print("High or critical:", high)
|
|
217
|
+
|
|
218
|
+
if high != 0
|
|
219
|
+
exit(1)
|
|
220
|
+
end
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
`json_get` reads one value at a path, and `json_keys` opens an object up — there is no map type, so without it
|
|
224
|
+
an object is text and nothing more. `json_type` says what is at a path, which is the one question `json_get`
|
|
225
|
+
cannot answer: it hands back `""` for a null and the compact text for an object. `json_format` is `jq .`, and
|
|
226
|
+
`json_encode` goes the other way, turning a list into an array. Nothing here is a dependency your machine has
|
|
227
|
+
to already have.
|
|
228
|
+
|
|
196
229
|
### Any language you have installed
|
|
197
230
|
|
|
198
231
|
`exec <command>` runs that command with the block as its **stdin**, so a target can be a Python script, a Node
|
|
@@ -379,7 +412,7 @@ end
|
|
|
379
412
|
`append`, `prepend`, `concat_lists`, `sort`, `reverse`, `unique`, `slice`, `flatten`, `zip`, `index_of` and
|
|
380
413
|
`without`, beside `first`, `last`, `length` and `join`.
|
|
381
414
|
|
|
382
|
-
There are
|
|
415
|
+
There are 83 built-in functions — strings, lists, regex, paths, JSON, hashes, time, files. Your editor lists
|
|
383
416
|
them all with a description and an example; `run :list` is for targets, and the language server is for the
|
|
384
417
|
language.
|
|
385
418
|
|
|
@@ -387,7 +420,7 @@ language.
|
|
|
387
420
|
|
|
388
421
|
| Source | From |
|
|
389
422
|
| --- | --- |
|
|
390
|
-
| `ARG.name` | `--name=value` |
|
|
423
|
+
| `ARG.name` | `--name=value`, or `--name value` |
|
|
391
424
|
| `FLAG.name` | `--name` (a boolean) |
|
|
392
425
|
| `ARGS` | positional arguments, as a list |
|
|
393
426
|
| `ENV.NAME` | the environment |
|
|
@@ -399,8 +432,12 @@ language.
|
|
|
399
432
|
let port = ARG.port ? ENV.PORT ? "3000"
|
|
400
433
|
```
|
|
401
434
|
|
|
402
|
-
|
|
403
|
-
|
|
435
|
+
An argument takes its value two ways, `--key=value` and `--key value`, and nothing is declared to make the
|
|
436
|
+
second one work: `run` walks the target's parsed tree, so it already knows `ARG.target` takes a value and
|
|
437
|
+
`FLAG.force` does not. `--target aarch64` is the triple; `--force x` is a flag and a positional. Where a name
|
|
438
|
+
is read both ways the bare `--name` is the flag, and `--name=value` is the argument. A value starting with a
|
|
439
|
+
dash needs the `=` form — `--target --release` is refused rather than quietly setting the triple to
|
|
440
|
+
`--release`.
|
|
404
441
|
|
|
405
442
|
**A flag a target cannot read is an error**, not a typo you find out about later. `run` knows exactly what a
|
|
406
443
|
target reads by walking its parsed tree, so `--forse` stops the run and points at `--help`:
|
|
@@ -423,8 +460,9 @@ Environment
|
|
|
423
460
|
Nothing is declared for that — a `?` chain is what makes a value optional, and the literal it ends in is the
|
|
424
461
|
default. `run --stdin-args deploy` asks for the same list, in the same order, **before anything runs**.
|
|
425
462
|
|
|
426
|
-
|
|
427
|
-
|
|
463
|
+
That refusal has one exception, and it is the useful one: **a target that reads `ARGS`**. A wrapper can read
|
|
464
|
+
any word, so it gets any word — a `--flag` it does not claim for itself joins the positionals where it was
|
|
465
|
+
written, and forwarding a whole command line needs nothing special.
|
|
428
466
|
|
|
429
467
|
```sh
|
|
430
468
|
# runfiles/aws.run
|
|
@@ -434,7 +472,15 @@ $ docker run --rm amazon/aws-cli {{ ARGS }}
|
|
|
434
472
|
```
|
|
435
473
|
|
|
436
474
|
```bash
|
|
437
|
-
run aws
|
|
475
|
+
run aws s3api list-buckets --output json
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Everything after a bare `--` is passed through untouched, whatever the target reads. That is how a wrapper
|
|
479
|
+
forwards a word the target would otherwise claim — its own `--output`, or a `--help` meant for the command
|
|
480
|
+
inside:
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
run aws -- s3api list-buckets --help
|
|
438
484
|
```
|
|
439
485
|
|
|
440
486
|
### Interpolation quotes itself
|
|
@@ -642,6 +688,9 @@ invoke `run` from.
|
|
|
642
688
|
directory than hide it, `$HOME/runfiles/` and `$HOME/Runfiles/` are read too — but only one of the three may
|
|
643
689
|
hold anything.
|
|
644
690
|
|
|
691
|
+
**Not in CI.** A runner's home directory is nobody's, so `run` reads none of the three there: what runs is
|
|
692
|
+
what is checked in and reviewable. This is also why nothing has to be cleaned up after a job.
|
|
693
|
+
|
|
645
694
|
Everything relative — `.env-file`, `.add-path`, `glob`, `read_file`, `{{ RUN.parent }}`, the working directory
|
|
646
695
|
— resolves against **the parent of `runfiles/`**. One anchor, one rule.
|
|
647
696
|
|
|
@@ -659,6 +708,11 @@ error: `setup` has never been run
|
|
|
659
708
|
It re-triggers when `setup.run` itself changes, so a new dependency is not silently missed. `--dry-run` is
|
|
660
709
|
exempt, CI is exempt, and `RUNFILE_SKIP_PREPARE=1` bypasses it.
|
|
661
710
|
|
|
711
|
+
The record lives in `state.json` in the platform state directory. In CI there is none: a runner is built and
|
|
712
|
+
thrown away, so there is no earlier session whose `setup` this one could be relying on — the gate is not
|
|
713
|
+
enforced and the file is not written. `RUNFILE_SKIP_PREPARE=1` is different: it turns the gate off on a machine
|
|
714
|
+
whose state is still worth keeping, so a `setup` run under it is still recorded.
|
|
715
|
+
|
|
662
716
|
## Commands
|
|
663
717
|
|
|
664
718
|
| Command | |
|
package/bin/darwin-arm64/run
CHANGED
|
Binary file
|
|
Binary file
|
package/bin/darwin-x64/run
CHANGED
|
Binary file
|
|
Binary file
|
package/bin/linux-arm64/run
CHANGED
|
Binary file
|
|
Binary file
|
package/bin/linux-x64/run
CHANGED
|
Binary file
|
|
Binary file
|
package/bin/win32-arm64/run.exe
CHANGED
|
Binary file
|
|
Binary file
|
package/bin/win32-x64/run.exe
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED