@faable/faable 4.10.0 → 4.11.0

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.
@@ -36,12 +36,5 @@ const parse_user_ids = (args, stdin) => {
36
36
  }
37
37
  return ids;
38
38
  };
39
- const read_stdin = async () => {
40
- const chunks = [];
41
- for await (const chunk of process.stdin) {
42
- chunks.push(Buffer.from(chunk));
43
- }
44
- return Buffer.concat(chunks).toString('utf8');
45
- };
46
39
 
47
- export { parse_user_ids, read_stdin, wants_stdin };
40
+ export { parse_user_ids, wants_stdin };
@@ -2,9 +2,10 @@ import { withAuthHints, requireAuthAdmin } from '../../../api/auth_admin.js';
2
2
  import { log } from '../../../log.js';
3
3
  import { tenant_options } from '../options.js';
4
4
  import { json_option, print_json } from '../../../lib/listing.js';
5
- import { wants_stdin, read_stdin, parse_user_ids } from './ids.js';
5
+ import { wants_stdin, parse_user_ids } from './ids.js';
6
6
  import { resolve_user_refs } from './resolve.js';
7
7
  import { confirm } from '../../../lib/interactive.js';
8
+ import { read_stdin } from '../../../lib/stdin.js';
8
9
 
9
10
  const users_reinstate = {
10
11
  command: 'reinstate [user_ids..]',
@@ -2,9 +2,10 @@ import { withAuthHints, requireAuthAdmin } from '../../../api/auth_admin.js';
2
2
  import { log } from '../../../log.js';
3
3
  import { tenant_options } from '../options.js';
4
4
  import { json_option, print_json } from '../../../lib/listing.js';
5
- import { wants_stdin, read_stdin, parse_user_ids } from './ids.js';
5
+ import { wants_stdin, parse_user_ids } from './ids.js';
6
6
  import { resolve_user_refs } from './resolve.js';
7
7
  import { confirm } from '../../../lib/interactive.js';
8
+ import { read_stdin } from '../../../lib/stdin.js';
8
9
 
9
10
  const users_suspend = {
10
11
  command: 'suspend [user_ids..]',
@@ -1,4 +1,5 @@
1
1
  import { log } from '../../../log.js';
2
+ import { format_bytes } from '../inspect/detail.js';
2
3
  import { follow_remote_build } from './follow.js';
3
4
  import { collect_manifest } from './manifest.js';
4
5
  import { upload_missing_blobs } from './upload.js';
@@ -18,7 +19,10 @@ const deploy_remote = async (props) => {
18
19
  const { api, app, git, release, workdir } = props;
19
20
  log.info(`☁️ Remote build`);
20
21
  const manifest = await collect_manifest(workdir);
21
- log.info(`🗂️ ${manifest.length} files in the source manifest`);
22
+ // The total is what the api weighs against the plan when the app's last
23
+ // build came out too large — say it before anything is uploaded.
24
+ const total = manifest.reduce((sum, f) => sum + f.size, 0);
25
+ log.info(`🗂️ ${manifest.length} files in the source manifest (${format_bytes(total)})`);
22
26
  await upload_missing_blobs(api, app.id, workdir, manifest);
23
27
  // No `plan`: the builder re-detects on the assembled tree and syncs the app's
24
28
  // runtime_strategy on completion.
@@ -2,6 +2,7 @@ import { readFileSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
3
  import { requireApi } from '../../../api/context.js';
4
4
  import { print_json, json_option } from '../../../lib/listing.js';
5
+ import { read_stdin } from '../../../lib/stdin.js';
5
6
  import { log } from '../../../log.js';
6
7
  import { resolve_app_id } from '../resolve_app_id.js';
7
8
  import { managed_warning } from './managed_names.js';
@@ -20,9 +21,11 @@ const DEFAULT_ENV_FILE = '.env';
20
21
  // even after the script, and dies with "node: -: not found" before the CLI
21
22
  // runs; the short alias is invisible to it.
22
23
  const STDIN = '-';
23
- const read_env_file = (raw_path) => {
24
+ const read_env_file = async (raw_path) => {
25
+ // Asynchronously: `readFileSync(0)` throws EAGAIN on a pipe that has not
26
+ // been written yet (lib/stdin.ts).
24
27
  if (raw_path === STDIN)
25
- return parse_env(readFileSync(0, 'utf8'), 'stdin');
28
+ return parse_env(await read_stdin(), 'stdin');
26
29
  const path = raw_path || DEFAULT_ENV_FILE;
27
30
  let content;
28
31
  try {
@@ -86,7 +89,7 @@ const secrets_set = {
86
89
  }
87
90
  // Validate EVERYTHING before writing ANY, so one malformed line or pair
88
91
  // aborts the whole command with no partial writes.
89
- const from_file = env_file === undefined ? [] : read_env_file(env_file);
92
+ const from_file = env_file === undefined ? [] : await read_env_file(env_file);
90
93
  const parsed = combine(from_file, parse_pairs(pairs));
91
94
  if (env_file !== undefined) {
92
95
  const path = env_file === STDIN ? 'stdin' : env_file || DEFAULT_ENV_FILE;
@@ -0,0 +1,15 @@
1
+ // All of stdin, read asynchronously.
2
+ //
3
+ // Never `readFileSync(0)`: when stdin is a pipe from another process that has
4
+ // not written yet (`faable auth webhooks create --json | … | faable deploy
5
+ // secrets set -f -`), the descriptor is non-blocking and the synchronous read
6
+ // throws EAGAIN instead of waiting.
7
+ const read_stdin = async () => {
8
+ const chunks = [];
9
+ for await (const chunk of process.stdin) {
10
+ chunks.push(Buffer.from(chunk));
11
+ }
12
+ return Buffer.concat(chunks).toString('utf8');
13
+ };
14
+
15
+ export { read_stdin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/faable",
3
- "version": "4.10.0",
3
+ "version": "4.11.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Marc Pomar <marc@faable.com>",