@rebasepro/cli 0.25.1 → 0.27.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.
- package/README.md +2 -1
- package/bin/rebase.js +143 -4
- package/dist/{agent-setup-BYb2Tbdz.js → agent-setup-D9mHRZ5R.js} +125 -3
- package/dist/agent-setup-D9mHRZ5R.js.map +1 -0
- package/dist/{api-keys-CSMbsmAn.js → api-keys-CyJ26KEJ.js} +41 -9
- package/dist/api-keys-CyJ26KEJ.js.map +1 -0
- package/dist/{apps-iBXNZhVN.js → apps-CdrFm7Y3.js} +6 -6
- package/dist/{apps-iBXNZhVN.js.map → apps-CdrFm7Y3.js.map} +1 -1
- package/dist/{atlas-dev-database-BusbHP6n.js → atlas-dev-database-BODqdCWt.js} +2 -2
- package/dist/{atlas-dev-database-BusbHP6n.js.map → atlas-dev-database-BODqdCWt.js.map} +1 -1
- package/dist/{auth-DRsTWPky.js → auth-dII2jCO1.js} +10 -7
- package/dist/auth-dII2jCO1.js.map +1 -0
- package/dist/{branch-pointer-Bn_FjNld.js → branch-pointer-BQUF6lYa.js} +1 -1
- package/dist/{build-et7Rccxi.js → build-D-t5FSg0.js} +13 -13
- package/dist/build-D-t5FSg0.js.map +1 -0
- package/dist/{bundle-DlqkDYSe.js → bundle-CrAWbpbG.js} +171 -22
- package/dist/bundle-CrAWbpbG.js.map +1 -0
- package/dist/bundle.d.ts +39 -11
- package/dist/{cloud-B-ZIjHrA.js → cloud-B2_oJmK7.js} +9404 -4889
- package/dist/cloud-B2_oJmK7.js.map +1 -0
- package/dist/collections-dir-DlvDhime.js +69 -0
- package/dist/collections-dir-DlvDhime.js.map +1 -0
- package/dist/commands/agent-setup.d.ts +58 -0
- package/dist/commands/api-keys.d.ts +13 -0
- package/dist/commands/cloud/activity.d.ts +25 -0
- package/dist/commands/cloud/app-key.d.ts +18 -0
- package/dist/commands/cloud/auth.d.ts +14 -0
- package/dist/commands/cloud/billing-invoices.d.ts +39 -0
- package/dist/commands/cloud/bundle-deploy.d.ts +8 -15
- package/dist/commands/cloud/claim.d.ts +7 -0
- package/dist/commands/cloud/context.d.ts +115 -6
- package/dist/commands/cloud/deploy-summary.d.ts +162 -0
- package/dist/commands/cloud/deploy.d.ts +64 -0
- package/dist/commands/cloud/env.d.ts +24 -0
- package/dist/commands/cloud/guests.d.ts +11 -0
- package/dist/commands/cloud/index.d.ts +14 -1
- package/dist/commands/cloud/init.d.ts +143 -0
- package/dist/commands/cloud/login-flow.d.ts +51 -0
- package/dist/commands/cloud/notifications.d.ts +28 -0
- package/dist/commands/cloud/orgs.d.ts +13 -0
- package/dist/commands/cloud/previews.d.ts +123 -0
- package/dist/commands/cloud/projects.d.ts +4 -0
- package/dist/commands/cloud/resources.d.ts +90 -14
- package/dist/commands/cloud/runtime-logs.d.ts +176 -0
- package/dist/commands/cloud/service-key.d.ts +15 -0
- package/dist/commands/cloud/token-capabilities.d.ts +61 -8
- package/dist/commands/cloud/tokens.d.ts +18 -3
- package/dist/commands/cloud/usage.d.ts +63 -0
- package/dist/commands/dev.d.ts +10 -0
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/generate-view.d.ts +94 -0
- package/dist/commands/generate_sdk.d.ts +15 -0
- package/dist/commands/skills.d.ts +4 -3
- package/dist/commands/storage.d.ts +4 -0
- package/dist/commands/verify.d.ts +96 -0
- package/dist/{consent-BaB-eQKG.js → consent-BD7F29T3.js} +2 -2
- package/dist/{consent-BaB-eQKG.js.map → consent-BD7F29T3.js.map} +1 -1
- package/dist/{console-BlD9kjFW.js → console-BXB6-8GT.js} +12 -6
- package/dist/console-BXB6-8GT.js.map +1 -0
- package/dist/{context-DHiiiJ5C.js → context-GUxkZm-S.js} +481 -24
- package/dist/context-GUxkZm-S.js.map +1 -0
- package/dist/{daemon-DDMRbz4T.js → daemon-Cp7oNXth.js} +2 -2
- package/dist/{daemon-DDMRbz4T.js.map → daemon-Cp7oNXth.js.map} +1 -1
- package/dist/{db-9P6MnmdC.js → db-KzlqddGD.js} +37 -30
- package/dist/db-KzlqddGD.js.map +1 -0
- package/dist/{derive-MTdClnkc.js → derive-ae9UOoOB.js} +2 -2
- package/dist/{derive-MTdClnkc.js.map → derive-ae9UOoOB.js.map} +1 -1
- package/dist/{dev-BDN_OKXA.js → dev-DTqVMgB3.js} +59 -32
- package/dist/dev-DTqVMgB3.js.map +1 -0
- package/dist/{dev-preflight-FT9GbJVj.js → dev-preflight-Cxv3TiD1.js} +2 -2
- package/dist/{dev-preflight-FT9GbJVj.js.map → dev-preflight-Cxv3TiD1.js.map} +1 -1
- package/dist/{dev-server-CIZwAfZa.js → dev-server-OJsUGZEB.js} +2 -2
- package/dist/{dev-server-CIZwAfZa.js.map → dev-server-OJsUGZEB.js.map} +1 -1
- package/dist/{doctor-D8YXz7df.js → doctor-BRWOlqeG.js} +13 -11
- package/dist/doctor-BRWOlqeG.js.map +1 -0
- package/dist/{eject-izG2KjMo.js → eject-DABcDnPN.js} +3 -3
- package/dist/{eject-izG2KjMo.js.map → eject-DABcDnPN.js.map} +1 -1
- package/dist/{fold-static-CybSay_W.js → fold-static-BGlpi22F.js} +3 -3
- package/dist/{fold-static-CybSay_W.js.map → fold-static-BGlpi22F.js.map} +1 -1
- package/dist/generate-view-IFwCADvb.js +662 -0
- package/dist/generate-view-IFwCADvb.js.map +1 -0
- package/dist/{generate_sdk-B4R65oUV.js → generate_sdk-BvcWvoUh.js} +33 -7
- package/dist/generate_sdk-BvcWvoUh.js.map +1 -0
- package/dist/index.es.js +57 -38
- package/dist/index.es.js.map +1 -1
- package/dist/{init-DYaeppEN.js → init-CaU6GhwI.js} +8 -8
- package/dist/{init-DYaeppEN.js.map → init-CaU6GhwI.js.map} +1 -1
- package/dist/last-dev-database-DpW5dfoX.js +2 -0
- package/dist/{manifest-nvPdLlJY.js → manifest-BtzDy7KQ.js} +36 -3
- package/dist/{manifest-nvPdLlJY.js.map → manifest-BtzDy7KQ.js.map} +1 -1
- package/dist/{normalize-imports-BYw8ad87.js → normalize-imports-CK_Mpcej.js} +3 -3
- package/dist/{normalize-imports-BYw8ad87.js.map → normalize-imports-CK_Mpcej.js.map} +1 -1
- package/dist/{path-flags-BFgG9V6y.js → path-flags-DNvtEi2-.js} +5 -4
- package/dist/path-flags-DNvtEi2-.js.map +1 -0
- package/dist/{prepare-1rVNd2PF.js → prepare-CTw9NEkh.js} +4 -4
- package/dist/{prepare-1rVNd2PF.js.map → prepare-CTw9NEkh.js.map} +1 -1
- package/dist/{project-g4K6kV1t.js → project-CasK56vN.js} +2 -2
- package/dist/{project-g4K6kV1t.js.map → project-CasK56vN.js.map} +1 -1
- package/dist/resolve-D647F1LA.js +2 -0
- package/dist/{resources-CovP8AZ-.js → resources-CPSC5Kcu.js} +4 -4
- package/dist/{resources-CovP8AZ-.js.map → resources-CPSC5Kcu.js.map} +1 -1
- package/dist/{schema-nuxvvc50.js → schema-BSXwZSiI.js} +9 -7
- package/dist/schema-BSXwZSiI.js.map +1 -0
- package/dist/{skills-DeUIsZcT.js → skills-BU2flMOy.js} +52 -7
- package/dist/skills-BU2flMOy.js.map +1 -0
- package/dist/{start-RzZqDroW.js → start-CflvYL60.js} +5 -5
- package/dist/{start-RzZqDroW.js.map → start-CflvYL60.js.map} +1 -1
- package/dist/static-syntax-check.d.ts +64 -0
- package/dist/{status-D9Zm88NZ.js → status-BREvtzJm.js} +7 -7
- package/dist/{status-D9Zm88NZ.js.map → status-BREvtzJm.js.map} +1 -1
- package/dist/{storage-BB3umRfw.js → storage-DtOXGflp.js} +159 -15
- package/dist/storage-DtOXGflp.js.map +1 -0
- package/dist/{telemetry-HfU5uAh1.js → telemetry-CgwJPVMO.js} +2 -2
- package/dist/{telemetry-HfU5uAh1.js.map → telemetry-CgwJPVMO.js.map} +1 -1
- package/dist/{telemetry-TseNLk6X.js → telemetry-DwK5RQJl.js} +4 -4
- package/dist/{telemetry-TseNLk6X.js.map → telemetry-DwK5RQJl.js.map} +1 -1
- package/dist/{upgrade-apiPKKE_.js → upgrade-B7sVwL8S.js} +4 -4
- package/dist/{upgrade-apiPKKE_.js.map → upgrade-B7sVwL8S.js.map} +1 -1
- package/dist/utils/bundle-lock.d.ts +9 -0
- package/dist/utils/collections-dir.d.ts +14 -0
- package/dist/utils/path-flags.d.ts +2 -1
- package/dist/utils/tool-stdio.d.ts +1 -1
- package/dist/verify-D7UsV_qe.js +730 -0
- package/dist/verify-D7UsV_qe.js.map +1 -0
- package/package.json +9 -7
- package/templates/eject/backend/src/index.ts +9 -1
- package/templates/generated-schemas/ecommerce.ts +3 -0
- package/templates/overlays/baas/README.md +2 -2
- package/templates/overlays/baas/ai-instructions.md +15 -1
- package/templates/overlays/baas/package.json +1 -0
- package/templates/overlays/baas/pnpm-workspace.yaml +4 -0
- package/templates/template/.claude/hooks/post-edit-collection.sh +99 -0
- package/templates/template/.claude/settings.json +17 -0
- package/templates/template/.env.example +11 -2
- package/templates/template/ai-instructions.md +24 -3
- package/templates/template/config/collections/presets/ecommerce/index.ts +23 -0
- package/templates/template/docker-compose.yml +4 -1
- package/templates/template/frontend/package.json +1 -0
- package/templates/template/pnpm-workspace.yaml +4 -1
- package/templates/views/AppView.tsx.tmpl +138 -0
- package/templates/views/EntityView.tsx.tmpl +64 -0
- package/templates/views/index.ts.tmpl +8 -0
- package/dist/agent-setup-BYb2Tbdz.js.map +0 -1
- package/dist/api-keys-CSMbsmAn.js.map +0 -1
- package/dist/auth-DRsTWPky.js.map +0 -1
- package/dist/build-et7Rccxi.js.map +0 -1
- package/dist/bundle-DlqkDYSe.js.map +0 -1
- package/dist/cloud-B-ZIjHrA.js.map +0 -1
- package/dist/console-BlD9kjFW.js.map +0 -1
- package/dist/context-DHiiiJ5C.js.map +0 -1
- package/dist/db-9P6MnmdC.js.map +0 -1
- package/dist/dev-BDN_OKXA.js.map +0 -1
- package/dist/doctor-D8YXz7df.js.map +0 -1
- package/dist/generate_sdk-B4R65oUV.js.map +0 -1
- package/dist/last-dev-database-B_75fxZC.js +0 -2
- package/dist/path-flags-BFgG9V6y.js.map +0 -1
- package/dist/resolve-BQUAC3Wi.js +0 -2
- package/dist/schema-nuxvvc50.js.map +0 -1
- package/dist/skills-DeUIsZcT.js.map +0 -1
- package/dist/storage-BB3umRfw.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as resolveTsx, h as resolvePluginCliScript, l as getActiveBackendPlugin, m as resolveLocalBin } from "./project-
|
|
1
|
+
import { g as resolveTsx, h as resolvePluginCliScript, l as getActiveBackendPlugin, m as resolveLocalBin } from "./project-CasK56vN.js";
|
|
2
2
|
import { n as cliVersion } from "./version-Buyyo1ut.js";
|
|
3
|
-
import { g as resolveBackendPaths, u as compareMountOrder } from "./manifest-
|
|
3
|
+
import { g as resolveBackendPaths, u as compareMountOrder } from "./manifest-BtzDy7KQ.js";
|
|
4
4
|
import { n as summarisePortability, t as analyseFunctionsDirectory } from "./function-portability-BIvlvR9q.js";
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import fs from "fs";
|
|
@@ -16,7 +16,7 @@ import zlib from "zlib";
|
|
|
16
16
|
*
|
|
17
17
|
* Inherited, so its output streams as it happens. With `quietStdout` its stdout
|
|
18
18
|
* goes to stderr instead, for a command whose own stdout carries a result:
|
|
19
|
-
* `rebase cloud deploy`
|
|
19
|
+
* `rebase cloud deploy --json` owes stdout exactly one
|
|
20
20
|
* JSON value, and a `vite v6 building…` line in front of it is a result no
|
|
21
21
|
* parser can read. The tool's output still reaches the person watching.
|
|
22
22
|
*/
|
|
@@ -130,6 +130,68 @@ function writeSibling(target, source, compress) {
|
|
|
130
130
|
return compressed.byteLength;
|
|
131
131
|
}
|
|
132
132
|
//#endregion
|
|
133
|
+
//#region src/utils/bundle-lock.ts
|
|
134
|
+
/**
|
|
135
|
+
* One build of a project's bundle at a time.
|
|
136
|
+
*
|
|
137
|
+
* Every build empties `dist-bundle/` and compiles into it, and nothing stopped
|
|
138
|
+
* two from doing so at once: two `rebase cloud deploy`s from the same directory,
|
|
139
|
+
* a deploy beside a `rebase build`. The run that starts second deletes files the
|
|
140
|
+
* first has already emitted. The first has no way to notice, finishes, and packs
|
|
141
|
+
* what is left, so a bundle ships with `songs.js` and without the `songs.json`
|
|
142
|
+
* beside it, and the failure appears at boot on a machine far from the cause.
|
|
143
|
+
*
|
|
144
|
+
* The file lives in `.rebase/`, beside the generated tsconfig the runs also
|
|
145
|
+
* share, which no upload carries. It records the holder's pid so that a run
|
|
146
|
+
* killed part way leaves nothing to clean up by hand.
|
|
147
|
+
*/
|
|
148
|
+
/** Whether `pid` is a process. EPERM is one that belongs to somebody else. */
|
|
149
|
+
function isRunning(pid) {
|
|
150
|
+
try {
|
|
151
|
+
process.kill(pid, 0);
|
|
152
|
+
return true;
|
|
153
|
+
} catch (err) {
|
|
154
|
+
return err instanceof Error && "code" in err && err.code === "EPERM";
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Take the project's build lock, or throw naming the process that holds it.
|
|
159
|
+
*
|
|
160
|
+
* Returns the release, which may be called more than once. The lock also goes
|
|
161
|
+
* with the process, and a process is never refused by itself: `fail()` ends a
|
|
162
|
+
* run on the spot with no `finally` behind it, and a build that threw leaves the
|
|
163
|
+
* lock with a caller that may build again.
|
|
164
|
+
*/
|
|
165
|
+
function lockBundleBuild(projectRoot) {
|
|
166
|
+
const lockPath = path.join(projectRoot, ".rebase", "bundle-build.lock");
|
|
167
|
+
fs.mkdirSync(path.dirname(lockPath), { recursive: true });
|
|
168
|
+
for (;;) {
|
|
169
|
+
try {
|
|
170
|
+
fs.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
171
|
+
break;
|
|
172
|
+
} catch (err) {
|
|
173
|
+
if (!(err instanceof Error && "code" in err && err.code === "EEXIST")) throw err;
|
|
174
|
+
}
|
|
175
|
+
let holder;
|
|
176
|
+
try {
|
|
177
|
+
holder = fs.readFileSync(lockPath, "utf8");
|
|
178
|
+
} catch {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (Number(holder) === process.pid) break;
|
|
182
|
+
if (holder === "" || isRunning(Number(holder))) throw new Error(`Another build of this project is running${holder ? ` (process ${holder})` : ""}, and two builds share dist-bundle/: the second would delete what the first has already written. Wait for it to finish. If nothing is running, delete ${lockPath}.`);
|
|
183
|
+
fs.rmSync(lockPath, { force: true });
|
|
184
|
+
}
|
|
185
|
+
const release = () => {
|
|
186
|
+
process.off("exit", release);
|
|
187
|
+
try {
|
|
188
|
+
if (Number(fs.readFileSync(lockPath, "utf8")) === process.pid) fs.rmSync(lockPath, { force: true });
|
|
189
|
+
} catch {}
|
|
190
|
+
};
|
|
191
|
+
process.on("exit", release);
|
|
192
|
+
return release;
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
133
195
|
//#region src/bundle.ts
|
|
134
196
|
/**
|
|
135
197
|
* Building a project bundle.
|
|
@@ -570,6 +632,47 @@ var BUNDLE_DEP_MANIFESTS = [
|
|
|
570
632
|
"backend/package.json"
|
|
571
633
|
];
|
|
572
634
|
/**
|
|
635
|
+
* Where a project's npm configuration may live, in the order they are joined.
|
|
636
|
+
* npm reads the last value of a repeated key, so the backend's own file wins.
|
|
637
|
+
*/
|
|
638
|
+
var BUNDLE_NPMRC_FILES = [".npmrc", "backend/.npmrc"];
|
|
639
|
+
/** npm keys whose value is a credential, bare or scoped to a registry (`//host/:_authToken`). */
|
|
640
|
+
var NPMRC_CREDENTIAL_KEY = /(^|:)(_authToken|_auth|_password|password|username|email|certfile|keyfile)$/;
|
|
641
|
+
/** A value npm expands from the environment at install time: `${NPM_TOKEN}`. */
|
|
642
|
+
var NPMRC_ENV_REFERENCE = /^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/;
|
|
643
|
+
/**
|
|
644
|
+
* The npm configuration a bundle carries, so the runtime's `npm ci` can reach a
|
|
645
|
+
* private registry — or `null` when the project has none.
|
|
646
|
+
*
|
|
647
|
+
* A pod installs the bundle's dependencies when it starts, from the public
|
|
648
|
+
* registry unless told otherwise, so a dependency published to a private
|
|
649
|
+
* registry or under a private scope could not install. This hands npm the
|
|
650
|
+
* project's own `.npmrc`. Credentials stay out of the bundle: every credential
|
|
651
|
+
* must be a `${VAR}` reference, which npm expands from the pod's environment —
|
|
652
|
+
* `rebase cloud env set NPM_TOKEN=… --secret`. A literal token would be
|
|
653
|
+
* uploaded with the code and stored beside every deployment, so it fails the
|
|
654
|
+
* build instead.
|
|
655
|
+
*/
|
|
656
|
+
function bundledNpmrc(projectRoot) {
|
|
657
|
+
const parts = [];
|
|
658
|
+
for (const relative of BUNDLE_NPMRC_FILES) {
|
|
659
|
+
const file = path.join(projectRoot, relative);
|
|
660
|
+
if (!fs.existsSync(file)) continue;
|
|
661
|
+
const text = fs.readFileSync(file, "utf8");
|
|
662
|
+
text.split(/\r?\n/).forEach((line, index) => {
|
|
663
|
+
const trimmed = line.trim();
|
|
664
|
+
if (trimmed === "" || trimmed.startsWith("#") || trimmed.startsWith(";")) return;
|
|
665
|
+
const eq = trimmed.indexOf("=");
|
|
666
|
+
if (eq === -1) return;
|
|
667
|
+
const key = trimmed.slice(0, eq).trim();
|
|
668
|
+
const value = trimmed.slice(eq + 1).trim();
|
|
669
|
+
if (NPMRC_CREDENTIAL_KEY.test(key) && !NPMRC_ENV_REFERENCE.test(value)) throw new Error(`${relative}:${index + 1} sets ${key} to a literal value. The bundle would carry it to the platform with your code. Write it as a reference instead — ${key}=\${NPM_TOKEN} — and set the value with \`rebase cloud env set NPM_TOKEN=… --secret\`.`);
|
|
670
|
+
});
|
|
671
|
+
parts.push(`# from ${relative}\n${text.trimEnd()}\n`);
|
|
672
|
+
}
|
|
673
|
+
return parts.length > 0 ? parts.join("\n") : null;
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
573
676
|
* Specifiers the registry the managed runtime installs from cannot resolve.
|
|
574
677
|
*
|
|
575
678
|
* `workspace:` is handled separately (it is normal and expected inside this
|
|
@@ -593,6 +696,19 @@ function nonRegistrySpecifier(version) {
|
|
|
593
696
|
if (/^\.{0,2}\//.test(trimmed)) return "a filesystem path";
|
|
594
697
|
return null;
|
|
595
698
|
}
|
|
699
|
+
/** The names this project's own `config`, `backend` and `frontend` packages go by. */
|
|
700
|
+
function localPackageNames(projectRoot) {
|
|
701
|
+
const names = /* @__PURE__ */ new Set();
|
|
702
|
+
for (const dir of [
|
|
703
|
+
"config",
|
|
704
|
+
"backend",
|
|
705
|
+
"frontend"
|
|
706
|
+
]) try {
|
|
707
|
+
const { name } = JSON.parse(fs.readFileSync(path.join(projectRoot, dir, "package.json"), "utf8"));
|
|
708
|
+
if (name) names.add(name);
|
|
709
|
+
} catch {}
|
|
710
|
+
return names;
|
|
711
|
+
}
|
|
596
712
|
/**
|
|
597
713
|
* Collect the runtime dependencies a bundle needs installed beside it.
|
|
598
714
|
*
|
|
@@ -619,6 +735,7 @@ function collectDeclaredDependencies(projectRoot) {
|
|
|
619
735
|
}).join("; ");
|
|
620
736
|
throw new Error(`No single version satisfies every range this project declares — ${described}. The bundle installs one of them and the rest of the project was built against the other. Declare one range, in the app that uses it.`);
|
|
621
737
|
}
|
|
738
|
+
const localPackages = localPackageNames(projectRoot);
|
|
622
739
|
for (const relative of BUNDLE_DEP_MANIFESTS) {
|
|
623
740
|
const file = path.join(projectRoot, relative);
|
|
624
741
|
if (!fs.existsSync(file)) continue;
|
|
@@ -632,6 +749,7 @@ function collectDeclaredDependencies(projectRoot) {
|
|
|
632
749
|
if (RUNTIME_PROVIDED.has(name)) continue;
|
|
633
750
|
if (typeof version === "string" && version.startsWith("workspace:")) continue;
|
|
634
751
|
if (resolvesToWorkspacePackage(projectRoot, name)) continue;
|
|
752
|
+
if (localPackages.has(name)) continue;
|
|
635
753
|
const protocol = typeof version === "string" ? nonRegistrySpecifier(version) : null;
|
|
636
754
|
if (protocol && parseEnvBoolean(process.env.REBASE_E2E) === true && protocol === "file:") {
|
|
637
755
|
declared[name] = version;
|
|
@@ -940,8 +1058,19 @@ function normalizeEsmSpecifiers(outDir, options = {}) {
|
|
|
940
1058
|
const inComment = (at) => comments.some(([start, end]) => at >= start && at < end);
|
|
941
1059
|
const updated = original.replace(SPECIFIER, (match, prefix, quote, specifier, offset) => {
|
|
942
1060
|
if (inComment(offset)) return match;
|
|
943
|
-
if (/\.(js|mjs|cjs|json|node)$/.test(specifier)) return match;
|
|
944
1061
|
const target = path.resolve(dir, specifier);
|
|
1062
|
+
if (/\.(js|mjs|cjs|json|node)$/.test(specifier)) {
|
|
1063
|
+
if (!fs.existsSync(target)) {
|
|
1064
|
+
unresolved.push(`${path.basename(file)} → ${specifier}`);
|
|
1065
|
+
return match;
|
|
1066
|
+
}
|
|
1067
|
+
if (!specifier.endsWith(".json")) return match;
|
|
1068
|
+
const after = original.slice(offset + match.length);
|
|
1069
|
+
const dynamic = prefix.includes("(");
|
|
1070
|
+
if (dynamic ? /^\s*,/.test(after) : /^\s*(with|assert)\b/.test(after)) return match;
|
|
1071
|
+
rewritten++;
|
|
1072
|
+
return dynamic ? `${match}, { with: { type: "json" } }` : `${match} with { type: "json" }`;
|
|
1073
|
+
}
|
|
945
1074
|
if (fs.existsSync(`${target}.js`)) {
|
|
946
1075
|
rewritten++;
|
|
947
1076
|
return `${prefix}${quote}${specifier}.js${quote}`;
|
|
@@ -1097,6 +1226,7 @@ async function buildBundle(options) {
|
|
|
1097
1226
|
const { projectRoot, app, appName } = options;
|
|
1098
1227
|
const conflicts = detectDeclaredDepConflicts(projectRoot);
|
|
1099
1228
|
if (conflicts.length > 0) throw new Error(describeDepConflicts(conflicts));
|
|
1229
|
+
const release = lockBundleBuild(projectRoot);
|
|
1100
1230
|
const paths = resolveBackendPaths(app, projectRoot);
|
|
1101
1231
|
const outDir = path.resolve(projectRoot, options.outDir ?? "dist-bundle");
|
|
1102
1232
|
const includes = [];
|
|
@@ -1109,6 +1239,11 @@ async function buildBundle(options) {
|
|
|
1109
1239
|
if (fs.existsSync(path.join(projectRoot, paths.schema))) includes.push(paths.schema);
|
|
1110
1240
|
if (includes.length === 0) throw new Error(`Nothing to build for app "${appName}". Expected a config directory at "${paths.config}" or functions at "${paths.functions}".`);
|
|
1111
1241
|
if (paths.hasCollections && options.skipSchema !== true) await regenerateSchema(projectRoot, paths.config, options);
|
|
1242
|
+
if (paths.hasCollections) {
|
|
1243
|
+
const { writeRegistrationForBuild } = await import("./generate_sdk-BvcWvoUh.js");
|
|
1244
|
+
const registered = await writeRegistrationForBuild(path.join(projectRoot, paths.config, "collections"), app.registerDatabase === true);
|
|
1245
|
+
if (registered) log(options, chalk.dim(` registered the Database for server-side code in ${path.relative(projectRoot, registered)}/`));
|
|
1246
|
+
}
|
|
1112
1247
|
const unusedEntry = findUnusedServerEntry(projectRoot, paths.functions);
|
|
1113
1248
|
if (unusedEntry) {
|
|
1114
1249
|
const parts = [
|
|
@@ -1206,6 +1341,8 @@ async function buildBundle(options) {
|
|
|
1206
1341
|
}
|
|
1207
1342
|
});
|
|
1208
1343
|
fs.writeFileSync(path.join(outDir, "manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
1344
|
+
const npmrc = bundledNpmrc(projectRoot);
|
|
1345
|
+
if (npmrc) fs.writeFileSync(path.join(outDir, ".npmrc"), npmrc, "utf8");
|
|
1209
1346
|
fs.writeFileSync(path.join(outDir, "package.json"), `${JSON.stringify({
|
|
1210
1347
|
name: "rebase-bundle",
|
|
1211
1348
|
private: true,
|
|
@@ -1228,27 +1365,39 @@ async function buildBundle(options) {
|
|
|
1228
1365
|
outDir,
|
|
1229
1366
|
manifest,
|
|
1230
1367
|
collectionCount: collections.length,
|
|
1231
|
-
vendor
|
|
1368
|
+
vendor,
|
|
1369
|
+
release
|
|
1232
1370
|
};
|
|
1233
1371
|
}
|
|
1234
1372
|
/** Default install target: what the published runtime image runs. */
|
|
1235
1373
|
var VENDOR_TARGET_OS = "linux";
|
|
1236
1374
|
var VENDOR_TARGET_CPU = "x64";
|
|
1375
|
+
/** What a bundle that installs at boot costs, for whoever says why it does. */
|
|
1376
|
+
var UNVENDORED_COST = "They install on every pod start instead, which is ~40-60s of cold start.";
|
|
1237
1377
|
/**
|
|
1238
|
-
*
|
|
1378
|
+
* Why a built bundle's dependencies will install at boot, if they will.
|
|
1239
1379
|
*
|
|
1240
|
-
*
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1244
|
-
*
|
|
1380
|
+
* Both commands that build a bundle read this, because a deploy that skipped
|
|
1381
|
+
* vendoring looks exactly like one that did not: it goes live, it is healthy, and
|
|
1382
|
+
* only every later pod start is a minute slower. A bundle with nothing to install
|
|
1383
|
+
* answers `undefined`: it already starts as fast as a vendored one, and warning
|
|
1384
|
+
* about it would train people to ignore the warning that matters.
|
|
1385
|
+
*/
|
|
1386
|
+
function unvendoredReason(result) {
|
|
1387
|
+
if (Object.keys(result.manifest.deps.declared).length === 0) return void 0;
|
|
1388
|
+
return result.vendor.skipped;
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Where a vendored bundle starts being too big to upload.
|
|
1245
1392
|
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1393
|
+
* The control plane refuses a bundle over 1 GB, and vendoring is the one thing
|
|
1394
|
+
* that can push a bundle near it. So the warning is here, at build time, where
|
|
1395
|
+
* the remedy is one flag away, rather than at deploy time as a 413 nobody can
|
|
1396
|
+
* act on without rebuilding. The threshold sits below the real cap's 2x floor
|
|
1397
|
+
* because this measures the tree on disk and the upload is compressed: crossing
|
|
1398
|
+
* it means "getting close", not "will fail".
|
|
1250
1399
|
*/
|
|
1251
|
-
var VENDOR_SIZE_WARN_BYTES =
|
|
1400
|
+
var VENDOR_SIZE_WARN_BYTES = 1536 * 1024 * 1024;
|
|
1252
1401
|
/**
|
|
1253
1402
|
* Where vendoring stops being an optimisation and becomes a bundle nobody can
|
|
1254
1403
|
* deploy.
|
|
@@ -1259,7 +1408,7 @@ var VENDOR_SIZE_WARN_BYTES = 150 * 1024 * 1024;
|
|
|
1259
1408
|
* 40–60s of cold start and produces a bundle that uploads; that is the better
|
|
1260
1409
|
* side of the trade to be on by default.
|
|
1261
1410
|
*
|
|
1262
|
-
*
|
|
1411
|
+
* 2 GB assumes a **2x** floor on compression, which is pessimistic for a tree
|
|
1263
1412
|
* of JavaScript (3–5x is typical) and deliberately so: source maps and prebuilt
|
|
1264
1413
|
* binaries compress far worse than source, and the failure this prevents is
|
|
1265
1414
|
* asymmetric — a bundle refused at the door versus a minute of cold start.
|
|
@@ -1267,7 +1416,7 @@ var VENDOR_SIZE_WARN_BYTES = 150 * 1024 * 1024;
|
|
|
1267
1416
|
* built from source, where the tree is copied into an image and the control
|
|
1268
1417
|
* plane never sees it).
|
|
1269
1418
|
*/
|
|
1270
|
-
var VENDOR_SIZE_MAX_BYTES =
|
|
1419
|
+
var VENDOR_SIZE_MAX_BYTES = 2048 * 1024 * 1024;
|
|
1271
1420
|
/** Bytes on disk under `dir`. Bounded so a pathological tree cannot hang a build. */
|
|
1272
1421
|
function directorySize(dir, budget = 2e5) {
|
|
1273
1422
|
let total = 0;
|
|
@@ -1387,7 +1536,7 @@ function vendorDependencies(options) {
|
|
|
1387
1536
|
};
|
|
1388
1537
|
}
|
|
1389
1538
|
const bytes = directorySize(installed);
|
|
1390
|
-
if (bytes >
|
|
1539
|
+
if (bytes > 2147483648 && options.requested !== true) {
|
|
1391
1540
|
fs.rmSync(installed, {
|
|
1392
1541
|
recursive: true,
|
|
1393
1542
|
force: true
|
|
@@ -1395,7 +1544,7 @@ function vendorDependencies(options) {
|
|
|
1395
1544
|
fs.rmSync(path.join(options.outDir, "package-lock.json"), { force: true });
|
|
1396
1545
|
return {
|
|
1397
1546
|
vendored: false,
|
|
1398
|
-
skipped: `the installed tree is ${Math.round(bytes / (1024 * 1024))} MB, past the point where the upload can be expected to fit under the control plane's
|
|
1547
|
+
skipped: `the installed tree is ${Math.round(bytes / (1024 * 1024))} MB, past the point where the upload can be expected to fit under the control plane's 1 GB limit — a bundle that is refused at the door is worse than one that installs at boot. Pass --vendor to keep it anyway (a deploy that builds from source never uploads the tree), or shrink the declared dependencies`
|
|
1399
1548
|
};
|
|
1400
1549
|
}
|
|
1401
1550
|
return {
|
|
@@ -1601,6 +1750,6 @@ function resolveServerVersion(projectRoot) {
|
|
|
1601
1750
|
return "unknown";
|
|
1602
1751
|
}
|
|
1603
1752
|
//#endregion
|
|
1604
|
-
export {
|
|
1753
|
+
export { toolStdio as C, vendorDependencies as S, detectStorageAuthorize as _, VENDOR_TARGET_CPU as a, normalizeEsmSpecifiers as b, buildStaticBundle as c, commentSpans as d, composeBundleManifest as f, detectNativeDependencies as g, detectFrameworkDepDrift as h, VENDOR_SIZE_WARN_BYTES as i, bundledNpmrc as l, detectDeclaredDepConflicts as m, UNVENDORED_COST as n, VENDOR_TARGET_OS as o, describeDepConflicts as p, VENDOR_SIZE_MAX_BYTES as r, buildBundle as s, DEFAULT_BUNDLE_DIR as t, collectDeclaredDependencies as u, findUnusedServerEntry as v, unvendoredReason as x, foldStaticIntoBundle as y };
|
|
1605
1754
|
|
|
1606
|
-
//# sourceMappingURL=bundle-
|
|
1755
|
+
//# sourceMappingURL=bundle-CrAWbpbG.js.map
|