widefleet 0.0.1 → 0.3.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Widefleet contributors
3
+ Copyright (c) 2026 Everyday Systems 42 GmbH
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,72 +1,112 @@
1
- # widefleet
1
+ # Install the Widefleet CLI
2
2
 
3
- Check HTTP endpoints from the command line or JavaScript. This initial release
4
- provides a small HTTP health-check utility, with no runtime dependencies.
5
- It does not deploy applications or provide the full Widefleet platform CLI.
3
+ Use the Widefleet CLI to create and deploy apps from your own machine. You need
4
+ access to a Widefleet installation; if you do not have one yet, start with the
5
+ [local quickstart](https://widefleet.com/docs/getting-started/quickstart).
6
6
 
7
- Requires Node.js 22 or newer.
7
+ ## Install the CLI
8
8
 
9
- ## Command line
10
-
11
- Once published to npm:
9
+ The CLI supports Linux x64 with glibc, macOS on Apple Silicon and Intel,
10
+ and Windows x64. Install Node.js 26 and pnpm 12.4.2 for app development.
12
11
 
13
12
  ```sh
14
- npx widefleet check https://example.com
15
- npx widefleet check https://example.com https://example.org --timeout 3000 --json
13
+ pnpm add --global widefleet
14
+ widefleet --version
16
15
  ```
17
16
 
18
- From this repository:
17
+ The installation commands work in Fish too. If pnpm reports that its global bin directory is missing from PATH, run `pnpm setup`, open a new terminal, and retry the installation. This configures pnpm's global command directory for your shell.
18
+
19
+ To update, rerun the install command. To uninstall, run `pnpm remove --global widefleet`. pnpm owns the complete installation directory; keep its package contents together.
20
+
21
+ App access groups, the catalog, D1 migration commands and Workflows require
22
+ CLI and platform `0.3.0` or newer. Update matching platform components together;
23
+ see the [CLI version notes](https://widefleet.com/docs/reference/cli).
24
+
25
+ The CLI includes its native executable, bundler and SvelteKit starter. App
26
+ developers do not need Docker or a checkout of the platform repository when
27
+ connecting to an existing installation.
28
+
29
+ ## Create an app
19
30
 
20
31
  ```sh
21
- node bin/widefleet.js check https://example.com
32
+ widefleet init my-app
33
+ cd my-app
34
+ pnpm install --frozen-lockfile
35
+ pnpm dev
22
36
  ```
23
37
 
24
- Checks send HTTP GET requests, follow redirects and consider final status codes
25
- 200–299 healthy. URLs are checked sequentially in the supplied order. Timing is
26
- measured through receiving the final response headers; response bodies are
27
- cancelled without being read. The default timeout is 5,000 milliseconds per URL.
28
- Requests have no retries. Only use this command with endpoints intended for GET
29
- requests. URLs containing embedded credentials are rejected.
30
-
31
- Example JSON output:
32
-
33
- ```json
34
- [
35
- {
36
- "url": "https://example.com/",
37
- "ok": true,
38
- "status": 200,
39
- "durationMs": 123
40
- }
41
- ]
38
+ The starter includes a notes app, a D1 database, private R2 file storage and a
39
+ server-side identity helper. Local development uses a synthetic user. Open the
40
+ local URL printed by `pnpm dev`, then stop that server with Ctrl-C before continuing.
41
+
42
+ ## Connect and deploy
43
+
44
+ Set your installation's management URL. The following commands use Bash:
45
+
46
+ ```sh
47
+ export PLATFORM_URL=https://platform.example.com
48
+ widefleet login
49
+ pnpm check
50
+ widefleet deploy
42
51
  ```
43
52
 
44
- Network failures have `status: null` and an `error` message. The reported URL is
45
- the normalized input URL. Exit codes are `0` when every endpoint is healthy,
46
- `1` when an endpoint fails and `2` for invalid command-line arguments.
53
+ In Fish, use `set -gx PLATFORM_URL https://platform.example.com` instead of `export`.
54
+ In PowerShell, use `$env:PLATFORM_URL = "https://platform.example.com"`.
47
55
 
48
- ## JavaScript
56
+ Approve the device code in your browser. The CLI stores credentials in your
57
+ operating system's credential store: Keychain on macOS, Credential Manager on
58
+ Windows, and Secret Service on Linux. The store must be available and unlocked.
49
59
 
50
- ```js
51
- import { checkUrl } from "widefleet";
60
+ For the local demo, use `http://localhost:25450` as `PLATFORM_URL` and approve the
61
+ code with `admin@example.test`.
52
62
 
53
- const result = await checkUrl("https://example.com", { timeoutMs: 3000 });
54
- console.log(result.ok, result.status, result.durationMs);
63
+ The target app is identified by your installation and the `name` in
64
+ `wrangler.jsonc`. The first deploy creates it when needed; later deploys update
65
+ the same app. After successful activation, the CLI prints `Deployment succeeded`
66
+ and the app URL. Open it, sign in with your company account, and add a note and
67
+ photo to verify the deployed app's database and file storage.
68
+
69
+ For ongoing development, follow [app development](https://widefleet.com/docs/guides/app-development).
70
+
71
+ ## Headless login
72
+
73
+ On Linux and macOS without an available credential store, CLI 0.2.1 or newer supports an
74
+ explicit session file. Set it before login and keep it set for subsequent commands:
75
+
76
+ ```sh
77
+ export PLATFORM_SESSION_FILE="$HOME/.local/state/widefleet/session.json"
78
+ widefleet login
55
79
  ```
56
80
 
57
- `checkUrl` returns the same result object as the command line. Invalid URLs,
58
- embedded credentials and invalid timeouts throw; HTTP errors, connection errors
59
- and timeouts produce an unsuccessful result instead.
81
+ This file contains unencrypted access and refresh tokens. Keep it outside the app
82
+ project and shared folders. The CLI restricts its permissions and renews the saved
83
+ session automatically. Use `widefleet logout` with the same setting to revoke the
84
+ refresh token and remove the file. See [CLI authentication](https://widefleet.com/docs/reference/authentication)
85
+ for exact file permissions, token scopes, renewal, logout failures and external credentials.
86
+
87
+ Session files require Unix file permissions and are unavailable on Windows. Use
88
+ Credential Manager for saved logins or `PLATFORM_ACCESS_TOKEN` for noninteractive
89
+ commands. In PowerShell, set a token with `$env:PLATFORM_ACCESS_TOKEN = "TOKEN"`.
60
90
 
61
- ## Development
91
+ ## Inspect runtime logs
62
92
 
63
93
  ```sh
64
- npm test
65
- npm pack --dry-run
94
+ widefleet logs
95
+ widefleet logs --level error
66
96
  ```
67
97
 
68
- Tests use local HTTP servers and synthetic responses. Installation requires no
69
- dependencies or lifecycle scripts. The publishable archive includes only the
70
- CLI, library, manifest, README and license.
98
+ Runtime logs require telemetry services enabled by the operator; the local demo
99
+ includes them. A failed log query is not evidence that the app has no errors.
100
+
101
+ ## If setup fails
102
+
103
+ | Symptom | Next step |
104
+ | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
105
+ | Registry returns 404 | Check the package name and published version on [npm](https://www.npmjs.com/package/widefleet). |
106
+ | `widefleet` is not found | Reopen the terminal after `pnpm setup`; check `Get-Command widefleet -All` in PowerShell or `type -a widefleet` in Bash/Fish for an older installation on PATH. |
107
+ | Login cannot access the credential store | Check your operating system's credential store; see [headless login](#headless-login) for alternatives. |
108
+ | Deployment fails or stays queued | Follow [deployment diagnostics](https://widefleet.com/docs/guides/deployments#inspect-a-failure). |
71
109
 
72
- Publishing and version updates are documented in [PUBLISHING.md](PUBLISHING.md).
110
+ Next, [share the app with colleagues](https://widefleet.com/docs/guides/applications) or
111
+ [publish an isolated preview](https://widefleet.com/docs/guides/deployments). The [CLI reference](https://widefleet.com/docs/reference/cli)
112
+ lists common commands and output behavior.
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+
3
+ // tools/cli-launcher.ts
4
+ import { spawn } from "node:child_process";
5
+ import { createRequire } from "node:module";
6
+
7
+ // tools/cli-platforms.ts
8
+ var cliPlatforms = [
9
+ { name: "linux-x64-gnu", os: "linux", cpu: "x64", extension: "" },
10
+ { name: "darwin-arm64", os: "darwin", cpu: "arm64", extension: "" },
11
+ { name: "darwin-x64", os: "darwin", cpu: "x64", extension: "" },
12
+ { name: "win32-x64-msvc", os: "win32", cpu: "x64", extension: ".exe" }
13
+ ];
14
+ function cliPlatform(os, cpu) {
15
+ const platform = cliPlatforms.find((entry) => entry.os === os && entry.cpu === cpu);
16
+ if (!platform)
17
+ throw new Error(
18
+ `Unsupported Widefleet platform: ${os}-${cpu}. Supported: ${cliPlatforms.map((entry) => entry.name).join(", ")}`
19
+ );
20
+ return platform;
21
+ }
22
+
23
+ // tools/cli-launcher.ts
24
+ function launch() {
25
+ const platform = cliPlatform(process.platform, process.arch);
26
+ const dependency = `widefleet-${platform.name}`;
27
+ const require2 = createRequire(import.meta.url);
28
+ let executable;
29
+ try {
30
+ executable = require2.resolve(`${dependency}/widefleet`);
31
+ } catch {
32
+ throw new Error(
33
+ `The native CLI package ${dependency} is missing. Reinstall widefleet with optional dependencies enabled. Linux requires glibc.`
34
+ );
35
+ }
36
+ const child = spawn(executable, process.argv.slice(2), { stdio: "inherit" });
37
+ const interrupt = () => {
38
+ if (process.platform !== "win32") child.kill("SIGINT");
39
+ };
40
+ const terminate = () => child.kill("SIGTERM");
41
+ process.on("SIGINT", interrupt);
42
+ process.on("SIGTERM", terminate);
43
+ child.on("error", (error) => {
44
+ console.error(`Could not start Widefleet: ${error.message}`);
45
+ process.exitCode = 1;
46
+ });
47
+ child.on("close", (code, signal) => {
48
+ process.removeListener("SIGINT", interrupt);
49
+ process.removeListener("SIGTERM", terminate);
50
+ process.exitCode = code ?? (signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 1);
51
+ });
52
+ }
53
+ try {
54
+ launch();
55
+ } catch (error) {
56
+ console.error(error instanceof Error ? error.message : "Could not launch Widefleet");
57
+ process.exitCode = 1;
58
+ }
package/package.json CHANGED
@@ -1,42 +1,41 @@
1
1
  {
2
2
  "name": "widefleet",
3
- "version": "0.0.1",
4
- "description": "Check HTTP endpoints from the command line or JavaScript.",
5
- "type": "module",
3
+ "version": "0.3.1",
4
+ "description": "Widefleet CLI with its Worker bundler and app starter",
6
5
  "license": "MIT",
7
- "engines": {
8
- "node": ">=22"
9
- },
6
+ "type": "module",
10
7
  "bin": {
11
- "widefleet": "bin/widefleet.js"
8
+ "widefleet": "./bin/widefleet.mjs"
9
+ },
10
+ "engines": {
11
+ "node": ">=26"
12
12
  },
13
- "exports": "./src/check.js",
13
+ "os": [
14
+ "linux",
15
+ "darwin",
16
+ "win32"
17
+ ],
18
+ "cpu": [
19
+ "x64",
20
+ "arm64"
21
+ ],
14
22
  "files": [
15
- "bin/",
16
- "src/",
23
+ "bin",
17
24
  "README.md",
18
25
  "LICENSE"
19
26
  ],
20
- "scripts": {
21
- "test": "node --test",
22
- "prepublishOnly": "npm test"
27
+ "optionalDependencies": {
28
+ "widefleet-linux-x64-gnu": "0.3.1",
29
+ "widefleet-darwin-arm64": "0.3.1",
30
+ "widefleet-darwin-x64": "0.3.1",
31
+ "widefleet-win32-x64-msvc": "0.3.1"
23
32
  },
24
33
  "repository": {
25
34
  "type": "git",
26
- "url": "git+https://github.com/widefleet/npm.git"
35
+ "url": "git+https://github.com/widefleet/widefleet.git"
27
36
  },
28
- "bugs": {
29
- "url": "https://github.com/widefleet/npm/issues"
30
- },
31
- "homepage": "https://widefleet.com",
32
- "keywords": [
33
- "http",
34
- "healthcheck",
35
- "cli",
36
- "widefleet"
37
- ],
38
37
  "publishConfig": {
39
- "registry": "https://registry.npmjs.org/",
38
+ "registry": "https://registry.npmjs.org",
40
39
  "access": "public"
41
40
  }
42
41
  }
package/bin/widefleet.js DELETED
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env node
2
- import { readFileSync } from "node:fs";
3
- import { parseArgs } from "node:util";
4
- import { checkUrl } from "../src/check.js";
5
-
6
- const help = `Widefleet HTTP checks
7
-
8
- Usage:
9
- widefleet check <url> [url ...] [--timeout <ms>] [--json]
10
-
11
- Options:
12
- -t, --timeout <ms> Timeout per URL in milliseconds (default: 5000)
13
- --json Print a JSON array of results
14
- -h, --help Show help
15
- -v, --version Show the package version
16
-
17
- Checks send GET requests and follow redirects. HTTP 200-299 is healthy.
18
- Exit codes: 0 = all healthy, 1 = an endpoint failed, 2 = invalid arguments.
19
- `;
20
-
21
- async function main() {
22
- const { values, positionals } = parseArgs({
23
- allowPositionals: true,
24
- options: {
25
- timeout: { type: "string", short: "t", default: "5000" },
26
- json: { type: "boolean", default: false },
27
- help: { type: "boolean", short: "h" },
28
- version: { type: "boolean", short: "v" },
29
- },
30
- });
31
-
32
- if (values.help || process.argv.length === 2) {
33
- process.stdout.write(help);
34
- return;
35
- }
36
- if (values.version) {
37
- const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
38
- console.log(manifest.version);
39
- return;
40
- }
41
-
42
- const [command, ...inputs] = positionals;
43
- if (command !== "check" || inputs.length === 0) {
44
- throw new Error("Usage: widefleet check <url> [url ...] [--timeout <ms>] [--json]");
45
- }
46
- if (!/^[1-9]\d*$/.test(values.timeout) || Number(values.timeout) > 2147483647) {
47
- throw new Error("Timeout must be an integer between 1 and 2147483647 milliseconds.");
48
- }
49
-
50
- // Validate every URL before making requests, even when a later input is invalid.
51
- const urls = inputs.map((input) => {
52
- const url = new URL(input);
53
- if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password) {
54
- throw new Error("Use http:// or https:// URLs without embedded credentials.");
55
- }
56
- return url;
57
- });
58
-
59
- const results = [];
60
- for (const url of urls) {
61
- const result = await checkUrl(url, { timeoutMs: Number(values.timeout) });
62
- results.push(result);
63
- if (!values.json) {
64
- console.log(`${result.ok ? "OK" : "FAIL"} ${result.url} ${result.status ?? result.error} (${result.durationMs} ms)`);
65
- }
66
- }
67
- if (values.json) {
68
- console.log(JSON.stringify(results, null, 2));
69
- }
70
- process.exitCode = results.every((result) => result.ok) ? 0 : 1;
71
- }
72
-
73
- try {
74
- await main();
75
- } catch (error) {
76
- console.error(`widefleet: ${error instanceof Error ? error.message : String(error)}`);
77
- process.exitCode = 2;
78
- }
package/src/check.js DELETED
@@ -1,44 +0,0 @@
1
- /**
2
- * Check an HTTP endpoint with a GET request, following redirects.
3
- * The timeout covers receiving response headers; the response body is not read.
4
- * Invalid inputs throw. HTTP and network failures return an unsuccessful result.
5
- */
6
- export async function checkUrl(input, { timeoutMs = 5000 } = {}) {
7
- const url = new URL(input);
8
- if (url.protocol !== "http:" && url.protocol !== "https:") {
9
- throw new TypeError("Only http:// and https:// URLs are supported.");
10
- }
11
- if (url.username || url.password) {
12
- throw new TypeError("URLs containing credentials are not supported.");
13
- }
14
- if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2147483647) {
15
- throw new TypeError("Timeout must be an integer between 1 and 2147483647 milliseconds.");
16
- }
17
-
18
- const started = performance.now();
19
- const signal = AbortSignal.timeout(timeoutMs);
20
- try {
21
- const response = await fetch(url, {
22
- method: "GET",
23
- redirect: "follow",
24
- signal,
25
- headers: { "user-agent": "widefleet-http-check" },
26
- });
27
- const durationMs = Math.round(performance.now() - started);
28
- // Stop streaming immediately: a health check does not need the response body.
29
- if (response.body) {
30
- await response.body.cancel();
31
- }
32
- return { url: url.href, ok: response.ok, status: response.status, durationMs };
33
- } catch (error) {
34
- return {
35
- url: url.href,
36
- ok: false,
37
- status: null,
38
- durationMs: Math.round(performance.now() - started),
39
- error: signal.aborted
40
- ? `Timed out after ${timeoutMs} ms`
41
- : error instanceof Error ? error.message : String(error),
42
- };
43
- }
44
- }