@rebasepro/cli 0.16.0 → 0.16.1-canary.g0d7af95

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 (54) hide show
  1. package/dist/bundle.d.ts +28 -2
  2. package/dist/commands/build.d.ts +10 -0
  3. package/dist/commands/cloud/context.d.ts +17 -1
  4. package/dist/commands/cloud/databases.d.ts +1 -0
  5. package/dist/commands/cloud/deploy.d.ts +58 -0
  6. package/dist/commands/cloud/deployments.d.ts +42 -0
  7. package/dist/commands/cloud/env.d.ts +1 -0
  8. package/dist/commands/cloud/extensions.d.ts +1 -0
  9. package/dist/commands/cloud/projects.d.ts +14 -4
  10. package/dist/commands/cloud/resources.d.ts +10 -1
  11. package/dist/commands/db.d.ts +16 -0
  12. package/dist/commands/dev.d.ts +11 -0
  13. package/dist/commands/doctor.d.ts +1 -1
  14. package/dist/commands/init.d.ts +1 -1
  15. package/dist/commands/resources.d.ts +1 -0
  16. package/dist/constraints-BK1_4vci.js +80 -0
  17. package/dist/constraints-BK1_4vci.js.map +1 -0
  18. package/dist/daemon-Bdl4lrdt.js +252 -0
  19. package/dist/daemon-Bdl4lrdt.js.map +1 -0
  20. package/dist/daemon-entry-Brq-S8XX.js +378 -0
  21. package/dist/daemon-entry-Brq-S8XX.js.map +1 -0
  22. package/dist/dev-db/__fixtures__/cli-entry.d.ts +1 -0
  23. package/dist/dev-db/constraints.d.ts +98 -0
  24. package/dist/dev-db/daemon-entry.d.ts +35 -0
  25. package/dist/dev-db/daemon.d.ts +92 -0
  26. package/dist/dev-db/notification-proxy.d.ts +102 -0
  27. package/dist/dev-db/prepare.d.ts +63 -0
  28. package/dist/dev-db/pull.d.ts +92 -0
  29. package/dist/dev-db/resolve.d.ts +66 -0
  30. package/dist/dev-db/state.d.ts +93 -0
  31. package/dist/function-portability.d.ts +45 -0
  32. package/dist/index.d.ts +17 -17
  33. package/dist/index.es.js +5638 -4098
  34. package/dist/index.es.js.map +1 -1
  35. package/dist/manifest.d.ts +24 -1
  36. package/dist/pull-DqPRu1te.js +167 -0
  37. package/dist/pull-DqPRu1te.js.map +1 -0
  38. package/dist/resources/derive.d.ts +47 -0
  39. package/dist/state-c0CJ6Kwb.js +190 -0
  40. package/dist/state-c0CJ6Kwb.js.map +1 -0
  41. package/dist/telemetry/consent.d.ts +1 -1
  42. package/dist/telemetry/index.d.ts +7 -7
  43. package/dist/utils/dev-preflight.d.ts +73 -0
  44. package/package.json +13 -8
  45. package/templates/eject/backend/src/index.ts +15 -8
  46. package/templates/eject/config/resources.ts +24 -0
  47. package/templates/template/AGENTS.md +1 -1
  48. package/templates/template/CLAUDE.md +1 -1
  49. package/templates/template/README.md +1 -1
  50. package/templates/template/ai-instructions.md +5 -2
  51. package/templates/template/backend/functions/hello.ts +43 -22
  52. package/templates/template/config/resources.ts +57 -0
  53. package/templates/template/docker-compose.yml +10 -1
  54. package/templates/template/gitignore +1 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The managed database's state file, and the rules for trusting it.
3
+ *
4
+ * The daemon outlives the command that started it — `rebase db push` in one
5
+ * terminal and `rebase dev` in another have to reach the *same* PGlite, because
6
+ * two processes opening one data directory would corrupt it. So the daemon
7
+ * records where it is, and every command reads that record.
8
+ *
9
+ * A record on disk is a claim, not a fact. The process it names may have been
10
+ * killed, the machine may have rebooted and handed the pid to something else,
11
+ * and the port may now belong to a stranger. {@link readState} therefore only
12
+ * parses; deciding whether a record is live is {@link isDaemonAlive}'s job, and
13
+ * it asks the daemon rather than the operating system.
14
+ */
15
+ /** Everything under here is generated and gitignored. */
16
+ export declare const DEV_DB_DIR = ".rebase";
17
+ /** PGlite's own data directory. Deleting it is what `--reset` means. */
18
+ export declare const DATA_DIR_NAME = "pgdata";
19
+ /** The record the daemon writes once it is accepting connections. */
20
+ export declare const STATE_FILE_NAME = "pglite.json";
21
+ /**
22
+ * Held by whoever is currently starting a daemon.
23
+ *
24
+ * Without it, `rebase dev` and `rebase db push` started in the same second both
25
+ * see no state file, both spawn, and two processes open one PGlite data
26
+ * directory — the exact corruption the single-daemon design exists to prevent.
27
+ * Observed as `ENOTEMPTY` during cleanup, which is the harmless way for it to
28
+ * show up; the harmful way is a damaged database.
29
+ */
30
+ export declare const START_LOCK_NAME = "starting.lock";
31
+ export interface DaemonState {
32
+ /** TCP port the socket server is listening on, chosen when it started. */
33
+ port: number;
34
+ /** The daemon process. Used only as a fast negative check. */
35
+ pid: number;
36
+ /** Absolute path of the PGlite data directory this daemon has open. */
37
+ dataDir: string;
38
+ /** ISO timestamp, for diagnostics. */
39
+ startedAt: string;
40
+ /**
41
+ * A random token the daemon also answers with over the wire, on
42
+ * {@link identityPort}.
43
+ *
44
+ * Without it, "is the daemon alive?" degrades to "is something listening on
45
+ * that port?", which is a different question and answers yes for whatever
46
+ * process happened to take the port after a reboot. Rebase would then send
47
+ * migrations to a stranger.
48
+ */
49
+ token: string;
50
+ /** Loopback port that answers the identity check. */
51
+ identityPort: number;
52
+ }
53
+ export declare function devDbDir(projectRoot: string): string;
54
+ export declare function dataDir(projectRoot: string): string;
55
+ export declare function stateFile(projectRoot: string): string;
56
+ export declare function startLockFile(projectRoot: string): string;
57
+ /**
58
+ * Take the start lock, or report that somebody else holds it.
59
+ *
60
+ * `wx` is the whole mechanism: create-if-absent is a single atomic syscall, so
61
+ * exactly one of two racing processes can succeed no matter how close together
62
+ * they arrive.
63
+ *
64
+ * A lock older than `staleAfterMs` is broken rather than waited on — the holder
65
+ * may have been killed between creating it and starting anything, and a
66
+ * developer should never have to know this file exists in order to unstick
67
+ * their project.
68
+ */
69
+ export declare function acquireStartLock(projectRoot: string, staleAfterMs: number): boolean;
70
+ export declare function releaseStartLock(projectRoot: string): void;
71
+ /**
72
+ * Parse the record, or `null` for anything that is not one.
73
+ *
74
+ * Every failure is the same answer — absent — because every failure has the
75
+ * same remedy: start a daemon. A corrupt state file is not worth an error
76
+ * message to a user who never wrote it.
77
+ */
78
+ export declare function readState(projectRoot: string): DaemonState | null;
79
+ export declare function writeState(projectRoot: string, state: DaemonState): void;
80
+ export declare function clearState(projectRoot: string): void;
81
+ /** Is *some* process with this pid running? A fast, cheap negative check. */
82
+ export declare function pidRunning(pid: number): boolean;
83
+ /** Can a TCP connection be opened to this port on loopback? */
84
+ export declare function portAccepting(port: number, timeoutMs?: number): Promise<boolean>;
85
+ /**
86
+ * Ask a port for a free one, then hand back the number.
87
+ *
88
+ * Deliberately not the probe `rebase init` uses: that one has a documented
89
+ * failure where a port is free to probe and unusable to publish. This binds on
90
+ * loopback only, which is also where the daemon listens, so a port that binds
91
+ * here binds there.
92
+ */
93
+ export declare function findFreePort(): Promise<number>;
@@ -0,0 +1,45 @@
1
+ /** What a single finding is about. */
2
+ export type PortabilityIssueKind = "node-builtin" | "node-only-package" | "module-scope-env" | "root-barrel-import" | "unknown-package";
3
+ export interface PortabilityIssue {
4
+ kind: PortabilityIssueKind;
5
+ /** 1-based line in the function file. */
6
+ line: number;
7
+ /** One sentence, already phrased for a terminal. */
8
+ message: string;
9
+ /**
10
+ * Whether this is a problem *today*, on Node, rather than only a constraint
11
+ * on where the function could run. Exactly one kind is:
12
+ * `module-scope-env`, which is a latent crash on any host where a variable
13
+ * happens to be unset at import time, and takes every other function in the
14
+ * same directory down with it — the loader reports a file that throws on
15
+ * import as simply "skipped".
16
+ */
17
+ actionable: boolean;
18
+ }
19
+ export interface FunctionPortability {
20
+ /** Function name — the filename without extension, as it mounts. */
21
+ name: string;
22
+ /** Path relative to the project root. */
23
+ file: string;
24
+ /** Empty when the function depends on nothing host-specific. */
25
+ issues: PortabilityIssue[];
26
+ /** True when `issues` contains nothing that pins it to Node. */
27
+ portable: boolean;
28
+ }
29
+ /** Analyse one function file's source. Exported for testing. */
30
+ export declare function analyseFunctionSource(source: string, name: string, file: string): FunctionPortability;
31
+ /**
32
+ * Analyse every function in a directory.
33
+ *
34
+ * @param functionsDir Absolute path to the functions directory.
35
+ * @param projectRoot For rendering paths people recognise.
36
+ */
37
+ export declare function analyseFunctionsDirectory(functionsDir: string, projectRoot: string): FunctionPortability[];
38
+ /**
39
+ * The lines to print after a build, or nothing at all.
40
+ *
41
+ * Silent when every function is portable and nothing is actionable, because a
42
+ * report that always prints is a report nobody reads. Actionable findings are
43
+ * always shown; the rest collapse to a single count with a pointer.
44
+ */
45
+ export declare function summarisePortability(results: FunctionPortability[]): string[];
package/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- export * from "./cli";
2
- export * from "./commands/init";
3
- export * from "./commands/schema";
4
- export * from "./commands/db";
5
- export * from "./commands/dev";
6
- export * from "./commands/build";
7
- export * from "./commands/eject";
8
- export * from "./commands/start";
9
- export * from "./commands/auth";
10
- export * from "./commands/doctor";
11
- export * from "./commands/generate_sdk";
12
- export * from "./commands/cloud";
13
- export * from "./commands/apps";
14
- export * from "./utils/project";
15
- export * from "./utils/package-manager";
16
- export * from "./manifest";
17
- export * from "./bundle";
1
+ export * from "./cli.js";
2
+ export * from "./commands/init.js";
3
+ export * from "./commands/schema.js";
4
+ export * from "./commands/db.js";
5
+ export * from "./commands/dev.js";
6
+ export * from "./commands/build.js";
7
+ export * from "./commands/eject.js";
8
+ export * from "./commands/start.js";
9
+ export * from "./commands/auth.js";
10
+ export * from "./commands/doctor.js";
11
+ export * from "./commands/generate_sdk.js";
12
+ export * from "./commands/cloud/index.js";
13
+ export * from "./commands/apps.js";
14
+ export * from "./utils/project.js";
15
+ export * from "./utils/package-manager.js";
16
+ export * from "./manifest.js";
17
+ export * from "./bundle.js";