@solobrand/cli 0.0.0-stage → 0.1.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 +63 -2
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +5 -0
- package/dist/bin.js.map +1 -0
- package/dist/bundle/build.d.ts +50 -0
- package/dist/bundle/build.d.ts.map +1 -0
- package/dist/bundle/build.js +134 -0
- package/dist/bundle/build.js.map +1 -0
- package/dist/bundle/fingerprint.d.ts +6 -0
- package/dist/bundle/fingerprint.d.ts.map +1 -0
- package/dist/bundle/fingerprint.js +33 -0
- package/dist/bundle/fingerprint.js.map +1 -0
- package/dist/bundle/index.d.ts +13 -0
- package/dist/bundle/index.d.ts.map +1 -0
- package/dist/bundle/index.js +10 -0
- package/dist/bundle/index.js.map +1 -0
- package/dist/bundle/limits.d.ts +15 -0
- package/dist/bundle/limits.d.ts.map +1 -0
- package/dist/bundle/limits.js +10 -0
- package/dist/bundle/limits.js.map +1 -0
- package/dist/bundle/manifest.d.ts +15 -0
- package/dist/bundle/manifest.d.ts.map +1 -0
- package/dist/bundle/manifest.js +56 -0
- package/dist/bundle/manifest.js.map +1 -0
- package/dist/bundle/messages.d.ts +76 -0
- package/dist/bundle/messages.d.ts.map +1 -0
- package/dist/bundle/messages.js +87 -0
- package/dist/bundle/messages.js.map +1 -0
- package/dist/bundle/migrations.d.ts +40 -0
- package/dist/bundle/migrations.d.ts.map +1 -0
- package/dist/bundle/migrations.js +135 -0
- package/dist/bundle/migrations.js.map +1 -0
- package/dist/bundle/upload.d.ts +57 -0
- package/dist/bundle/upload.d.ts.map +1 -0
- package/dist/bundle/upload.js +262 -0
- package/dist/bundle/upload.js.map +1 -0
- package/dist/bundle/web.d.ts +11 -0
- package/dist/bundle/web.d.ts.map +1 -0
- package/dist/bundle/web.js +30 -0
- package/dist/bundle/web.js.map +1 -0
- package/dist/bundle/worker.d.ts +17 -0
- package/dist/bundle/worker.d.ts.map +1 -0
- package/dist/bundle/worker.js +68 -0
- package/dist/bundle/worker.js.map +1 -0
- package/dist/commands/add/index.d.ts +15 -0
- package/dist/commands/add/index.d.ts.map +1 -0
- package/dist/commands/add/index.js +55 -0
- package/dist/commands/add/index.js.map +1 -0
- package/dist/commands/build/index.d.ts +4 -0
- package/dist/commands/build/index.d.ts.map +1 -0
- package/dist/commands/build/index.js +28 -0
- package/dist/commands/build/index.js.map +1 -0
- package/dist/commands/deploy/index.d.ts +10 -0
- package/dist/commands/deploy/index.d.ts.map +1 -0
- package/dist/commands/deploy/index.js +32 -0
- package/dist/commands/deploy/index.js.map +1 -0
- package/dist/commands/dev/index.d.ts +5 -0
- package/dist/commands/dev/index.d.ts.map +1 -0
- package/dist/commands/dev/index.js +23 -0
- package/dist/commands/dev/index.js.map +1 -0
- package/dist/commands/doctor/index.d.ts +20 -0
- package/dist/commands/doctor/index.d.ts.map +1 -0
- package/dist/commands/doctor/index.js +127 -0
- package/dist/commands/doctor/index.js.map +1 -0
- package/dist/commands/generator/index.d.ts +23 -0
- package/dist/commands/generator/index.d.ts.map +1 -0
- package/dist/commands/generator/index.js +125 -0
- package/dist/commands/generator/index.js.map +1 -0
- package/dist/commands/make/index.d.ts +31 -0
- package/dist/commands/make/index.d.ts.map +1 -0
- package/dist/commands/make/index.js +167 -0
- package/dist/commands/make/index.js.map +1 -0
- package/dist/commands/make/naming.d.ts +17 -0
- package/dist/commands/make/naming.d.ts.map +1 -0
- package/dist/commands/make/naming.js +42 -0
- package/dist/commands/make/naming.js.map +1 -0
- package/dist/commands/make/templates.d.ts +9 -0
- package/dist/commands/make/templates.d.ts.map +1 -0
- package/dist/commands/make/templates.js +51 -0
- package/dist/commands/make/templates.js.map +1 -0
- package/dist/commands/migrate/index.d.ts +24 -0
- package/dist/commands/migrate/index.d.ts.map +1 -0
- package/dist/commands/migrate/index.js +182 -0
- package/dist/commands/migrate/index.js.map +1 -0
- package/dist/commands/new/index.d.ts +31 -0
- package/dist/commands/new/index.d.ts.map +1 -0
- package/dist/commands/new/index.js +169 -0
- package/dist/commands/new/index.js.map +1 -0
- package/dist/commands/support/args.d.ts +18 -0
- package/dist/commands/support/args.d.ts.map +1 -0
- package/dist/commands/support/args.js +70 -0
- package/dist/commands/support/args.js.map +1 -0
- package/dist/commands/support/fs.d.ts +20 -0
- package/dist/commands/support/fs.d.ts.map +1 -0
- package/dist/commands/support/fs.js +124 -0
- package/dist/commands/support/fs.js.map +1 -0
- package/dist/commands/support/hooks.d.ts +10 -0
- package/dist/commands/support/hooks.d.ts.map +1 -0
- package/dist/commands/support/hooks.js +47 -0
- package/dist/commands/support/hooks.js.map +1 -0
- package/dist/commands/support/packages.d.ts +23 -0
- package/dist/commands/support/packages.d.ts.map +1 -0
- package/dist/commands/support/packages.js +65 -0
- package/dist/commands/support/packages.js.map +1 -0
- package/dist/commands/support/process.d.ts +26 -0
- package/dist/commands/support/process.d.ts.map +1 -0
- package/dist/commands/support/process.js +44 -0
- package/dist/commands/support/process.js.map +1 -0
- package/dist/commands/support/semver.d.ts +12 -0
- package/dist/commands/support/semver.d.ts.map +1 -0
- package/dist/commands/support/semver.js +49 -0
- package/dist/commands/support/semver.js.map +1 -0
- package/dist/commands/support/tools.d.ts +13 -0
- package/dist/commands/support/tools.d.ts.map +1 -0
- package/dist/commands/support/tools.js +25 -0
- package/dist/commands/support/tools.js.map +1 -0
- package/dist/commands/test/index.d.ts +6 -0
- package/dist/commands/test/index.d.ts.map +1 -0
- package/dist/commands/test/index.js +17 -0
- package/dist/commands/test/index.js.map +1 -0
- package/dist/commands/upgrade/index.d.ts +34 -0
- package/dist/commands/upgrade/index.d.ts.map +1 -0
- package/dist/commands/upgrade/index.js +208 -0
- package/dist/commands/upgrade/index.js.map +1 -0
- package/dist/commands/upgrade/registry.d.ts +15 -0
- package/dist/commands/upgrade/registry.d.ts.map +1 -0
- package/dist/commands/upgrade/registry.js +30 -0
- package/dist/commands/upgrade/registry.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/output/index.d.ts +47 -0
- package/dist/output/index.d.ts.map +1 -0
- package/dist/output/index.js +64 -0
- package/dist/output/index.js.map +1 -0
- package/dist/output/messages.d.ts +261 -0
- package/dist/output/messages.d.ts.map +1 -0
- package/dist/output/messages.js +273 -0
- package/dist/output/messages.js.map +1 -0
- package/dist/registry.d.ts +22 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +91 -0
- package/dist/registry.js.map +1 -0
- package/package.json +53 -4
package/README.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @solobrand/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The sb command line.
|
|
4
|
+
|
|
5
|
+
Part of the [SoloBrand framework](../../README.md). Public API: `src/contracts.ts` (frozen, see CONTRIBUTING.md).
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
|
|
9
|
+
<!-- Each CLI sub-front writes only its own subsection below. -->
|
|
10
|
+
|
|
11
|
+
### `sb build` + `sb deploy` (F5 build/deploy sub-front) — TERMINADO 2026-11-28
|
|
12
|
+
|
|
13
|
+
Implemented and tested; details in [`src/bundle/README.md`](src/bundle/README.md#status).
|
|
14
|
+
- `buildCommand` (`src/commands/build/`) and `deployCommand` (`src/commands/deploy/`), for the
|
|
15
|
+
integrator to register in `src/registry.ts`.
|
|
16
|
+
- `sb build` writes the frozen `DeployBundle` to `.solobrand/build/`; proven over `templates/app`
|
|
17
|
+
(modules, assets manifest with hashes, migrations SQL) and checked against the contract type.
|
|
18
|
+
- `sb deploy` uploads to SoloBrand; with no SoloBrand keys (or `--dry-run`) it only validates the build.
|
|
19
|
+
- `templates/github-actions/solobrand-deploy.yml`: test → build → deploy, hardened per SEC-010.
|
|
20
|
+
- Left: real `@solobrand/react` components (F6) in the template build; the template's Tailwind config
|
|
21
|
+
path (see the bundle README).
|
|
22
|
+
|
|
23
|
+
### Commands (F5 commands sub-front) — TERMINADO 2026-11-28
|
|
24
|
+
|
|
25
|
+
`sb` = `src/bin.ts` → `runCli(argv)` in `src/registry.ts`, every command of the contract registered
|
|
26
|
+
(build/deploy included). No CLI framework: a tiny parser (`src/commands/support/args.ts`).
|
|
27
|
+
|
|
28
|
+
| Command | What it does |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `sb new <name>` | copies `templates/app` (the copy shipped in the package; inside this monorepo, the repo's own; `--template` / `SOLOBRAND_TEMPLATE` override), fills `{{app_name}}`, `{{app_title}}`, `{{framework_version}}`, writes `.dev.vars` with a random `APP_KEY`, prints the next steps; runs nothing |
|
|
31
|
+
| `sb make:model\|request\|policy\|migration\|provider\|middleware\|test <Name>` | one deterministic file with huecos and `// @a-mano`; never overwrites without `--force`; migrations are `YYYY_MM_DD_HHMMSS_<snake>.ts` and get wired into `database/index.ts`, providers into `bootstrap/app.ts`, middleware into `app/http/middleware/index.ts` (otherwise the next step is printed) |
|
|
32
|
+
| `sb generate` (`sb import`), `verify`, `guard`, `audit`, `fix` | `@solobrand/generator` over a Node `FileSystem` (no symlinks followed); findings as `path:line message [kind]`, exit 1 on any; `generate --dry-run` |
|
|
33
|
+
| `sb dev`, `sb test` | `npx --no-install wrangler dev` / `vitest run` (never downloads); a clear install hint when missing; extra flags and args forwarded |
|
|
34
|
+
| `sb migrate [--rollback] [--pretend] [--database DB]` | compiles the TypeScript migrations (same file as `sb build`) to `.solobrand/migrations/*.sql`, then `wrangler d1 migrations apply --local`; `--rollback` runs the last applied `down()` and deletes its `d1_migrations` row |
|
|
35
|
+
| `sb add <pkg>` | `npm install @solobrand/<pkg>@<core version>` then the package's `solobrand.install` module |
|
|
36
|
+
| `sb outdated [--strict]`, `sb upgrade [--to x.y.z] [--dry-run]` | registry (npm_config_registry, https only) vs installed; lockstep to one version (all or nothing), codemods from `solobrand.codemods` in `(installed, target]` in version order, then `sb generate` |
|
|
37
|
+
| `sb doctor` | node ≥ 20, wrangler, @solobrand/* installed and in lockstep, app.json, manifest (`verify`), `.dev.vars` git-ignored, no secret-looking keys in wrangler.jsonc `vars`, deploy token (warn) |
|
|
38
|
+
|
|
39
|
+
Every command takes `--json` (one `{command, ok, exitCode, messages, data}` object on stdout).
|
|
40
|
+
Colors only on a TTY (`NO_COLOR`, `--no-color`, `FORCE_COLOR` respected). Exit codes: 0 ok,
|
|
41
|
+
1 findings/failure, 2 misuse. All text is keys in `src/output/messages.ts` (es + en, same keys —
|
|
42
|
+
tested); locale from `SB_LOCALE` / `LC_ALL` / `LANG`.
|
|
43
|
+
|
|
44
|
+
Package hooks (`solobrand.install`, `solobrand.codemods`): `{ "codemods": [{ "version": "0.2.0", "module": "./dist/codemods/0.2.0.js" }] }`
|
|
45
|
+
(or `{ "0.2.0": "./…" }`); the module exports a default (or `run`) function receiving
|
|
46
|
+
`{ cwd, out, from, to, version }` (install: `{ cwd, out, flags, version }`).
|
|
47
|
+
|
|
48
|
+
**Tested** (temp dirs, fake runner / fake registry, the real template and golden spec), each security
|
|
49
|
+
rule with the test that would break it: names are identifiers, never paths (`new`, `make:*`, `add`);
|
|
50
|
+
`new` never touches a non-empty folder and never copies template symlinks; hook/codemod paths
|
|
51
|
+
outside their package (`../`, absolute, escaping symlinks) are refused and never imported; tools run
|
|
52
|
+
with `npx --no-install` and without a shell; the D1 binding and the rolled-back migration name must
|
|
53
|
+
be identifiers before they reach wrangler/SQL; the registry must be https (http only for localhost);
|
|
54
|
+
`doctor` fails on an un-ignored `.dev.vars` and on secrets in `vars` (printing names, never values).
|
|
55
|
+
Checked by hand too: `sb new` → `sb generate` (golden spec) → verify/guard/audit clean → every
|
|
56
|
+
`make:*` → `tsc --noEmit` clean → `sb test` (template tests and a `make:test` pass).
|
|
57
|
+
|
|
58
|
+
**Publishing**: `prepack` copies `templates/app` into `packages/cli/templates/app` (`.gitignore`
|
|
59
|
+
travels as `gitignore`, `sb new` names it back) and `postpack` removes it; check with
|
|
60
|
+
`npm pack --dry-run -w @solobrand/cli` (AUD-44).
|
|
61
|
+
|
|
62
|
+
**Left**: `sb migrate --remote` is deliberately absent (production D1 is migrated by
|
|
63
|
+
SoloBrand on deploy); `make:*` does not wire policies/requests into the generated
|
|
64
|
+
`app/policies/index.ts` / routes (they are generated files: the next step is printed instead).
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,2BAA2B;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,CAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { DeployBundle } from '../index.js';
|
|
2
|
+
import { type Limits } from './limits.js';
|
|
3
|
+
import { type SchemaFactory } from './migrations.js';
|
|
4
|
+
import { type WebBuilder } from './web.js';
|
|
5
|
+
/** Where `sb build` writes, relative to the app. */
|
|
6
|
+
export declare const BUILD_DIR = ".solobrand/build";
|
|
7
|
+
/** Sidecar next to bundle.json: what the build was made from (not part of DeployBundle). */
|
|
8
|
+
export declare const BUILD_INFO = "build-info.json";
|
|
9
|
+
/**
|
|
10
|
+
* `/auth/*` is the API, but the two pages an e-mail links to (reset password, verify
|
|
11
|
+
* e-mail) are SPA routes: they must reach the static `index.html`, or every link in a
|
|
12
|
+
* reset or verification mail answers 404/405 once deployed. Same list as the
|
|
13
|
+
* template's `wrangler.jsonc` (a test keeps them equal).
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_ASSETS_CONFIG: {
|
|
16
|
+
readonly not_found_handling: "single-page-application";
|
|
17
|
+
readonly run_worker_first: readonly ["/api/*", "/auth/*", "!/auth/reset-password", "!/auth/verify-email"];
|
|
18
|
+
};
|
|
19
|
+
export declare const ENTRY_CANDIDATES: readonly ["src/worker.ts", "app/worker.ts", "worker.ts", "src/index.ts"];
|
|
20
|
+
/** Where the app's migration list lives: `database/index.ts` (allMigrations, the template) first. */
|
|
21
|
+
export declare const MIGRATIONS_FILES: readonly ["database/index.ts", "database/migrations/index.ts"];
|
|
22
|
+
export interface BuildOptions {
|
|
23
|
+
readonly cwd: string;
|
|
24
|
+
/** Worker entry, relative to cwd. Default: package.json `solobrand.main`, then ENTRY_CANDIDATES. */
|
|
25
|
+
readonly entry?: string;
|
|
26
|
+
readonly web?: WebBuilder;
|
|
27
|
+
readonly createSchema?: SchemaFactory;
|
|
28
|
+
readonly limits?: Limits;
|
|
29
|
+
}
|
|
30
|
+
export interface BuildInfo {
|
|
31
|
+
readonly fingerprint: string;
|
|
32
|
+
readonly builtAt: string;
|
|
33
|
+
}
|
|
34
|
+
export interface BuildResult {
|
|
35
|
+
readonly dir: string;
|
|
36
|
+
readonly bundle: DeployBundle;
|
|
37
|
+
readonly info: BuildInfo;
|
|
38
|
+
}
|
|
39
|
+
/** The app's slug: `app` in app.json, else package.json `name` without scope. */
|
|
40
|
+
export declare function appName(cwd: string): Promise<string>;
|
|
41
|
+
/** The installed @solobrand/core version of the app (the framework the bundle was built with). */
|
|
42
|
+
export declare function frameworkVersion(cwd: string): string;
|
|
43
|
+
export declare function resolveEntry(cwd: string, explicit?: string): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* `sb build`: Worker modules + frontend assets + migrations SQL → `.solobrand/build/bundle.json`.
|
|
46
|
+
* Limits are checked before anything is written as bundle.json, so a failed build
|
|
47
|
+
* never leaves a deployable bundle behind.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildApp(options: BuildOptions): Promise<BuildResult>;
|
|
50
|
+
//# sourceMappingURL=build.d.ts.map
|
|
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C,MAAM,CAAC,CAQ1D;AAED,kGAAkG;AAClG,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUpD;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOlF;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA0C1E"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { sourceFingerprint } from './fingerprint.js';
|
|
5
|
+
import { LIMITS } from './limits.js';
|
|
6
|
+
import { buildAssetsManifest } from './manifest.js';
|
|
7
|
+
import { BundleError } from './messages.js';
|
|
8
|
+
import { collectMigrations, compileMigrations, loadMigrationsModule, resolveSchemaFactory } from './migrations.js';
|
|
9
|
+
import { viteBuilder } from './web.js';
|
|
10
|
+
import { bundleWorker } from './worker.js';
|
|
11
|
+
/** Where `sb build` writes, relative to the app. */
|
|
12
|
+
export const BUILD_DIR = '.solobrand/build';
|
|
13
|
+
/** Sidecar next to bundle.json: what the build was made from (not part of DeployBundle). */
|
|
14
|
+
export const BUILD_INFO = 'build-info.json';
|
|
15
|
+
/**
|
|
16
|
+
* `/auth/*` is the API, but the two pages an e-mail links to (reset password, verify
|
|
17
|
+
* e-mail) are SPA routes: they must reach the static `index.html`, or every link in a
|
|
18
|
+
* reset or verification mail answers 404/405 once deployed. Same list as the
|
|
19
|
+
* template's `wrangler.jsonc` (a test keeps them equal).
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_ASSETS_CONFIG = {
|
|
22
|
+
not_found_handling: 'single-page-application',
|
|
23
|
+
run_worker_first: ['/api/*', '/auth/*', '!/auth/reset-password', '!/auth/verify-email'],
|
|
24
|
+
};
|
|
25
|
+
export const ENTRY_CANDIDATES = ['src/worker.ts', 'app/worker.ts', 'worker.ts', 'src/index.ts'];
|
|
26
|
+
/** Where the app's migration list lives: `database/index.ts` (allMigrations, the template) first. */
|
|
27
|
+
export const MIGRATIONS_FILES = ['database/index.ts', 'database/migrations/index.ts'];
|
|
28
|
+
async function exists(file) {
|
|
29
|
+
try {
|
|
30
|
+
await access(file);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function firstExisting(cwd, files) {
|
|
38
|
+
for (const f of files)
|
|
39
|
+
if (await exists(join(cwd, f)))
|
|
40
|
+
return f;
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
async function readJson(file) {
|
|
44
|
+
try {
|
|
45
|
+
const value = JSON.parse(await readFile(file, 'utf8'));
|
|
46
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function str(value) {
|
|
53
|
+
return typeof value === 'string' && value !== '' ? value : null;
|
|
54
|
+
}
|
|
55
|
+
/** The app's slug: `app` in app.json, else package.json `name` without scope. */
|
|
56
|
+
export async function appName(cwd) {
|
|
57
|
+
const spec = await readJson(join(cwd, 'app.json'));
|
|
58
|
+
const fromSpec = str(spec?.['app']);
|
|
59
|
+
if (fromSpec)
|
|
60
|
+
return fromSpec;
|
|
61
|
+
const pkg = await readJson(join(cwd, 'package.json'));
|
|
62
|
+
const fromPkg = str(pkg?.['name']);
|
|
63
|
+
if (fromPkg)
|
|
64
|
+
return fromPkg.replace(/^@[^/]+\//, '');
|
|
65
|
+
throw new BundleError('cli.build.no_app_name');
|
|
66
|
+
}
|
|
67
|
+
/** The installed @solobrand/core version of the app (the framework the bundle was built with). */
|
|
68
|
+
export function frameworkVersion(cwd) {
|
|
69
|
+
for (const base of [join(cwd, 'package.json'), import.meta.url]) {
|
|
70
|
+
try {
|
|
71
|
+
const pkg = createRequire(base)('@solobrand/core/package.json');
|
|
72
|
+
if (typeof pkg.version === 'string')
|
|
73
|
+
return `@solobrand/core@${pkg.version}`;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
/* exports may hide package.json; fall through */
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return '@solobrand/core@0.0.0';
|
|
80
|
+
}
|
|
81
|
+
export async function resolveEntry(cwd, explicit) {
|
|
82
|
+
const pkg = await readJson(join(cwd, 'package.json'));
|
|
83
|
+
const sb = pkg?.['solobrand'];
|
|
84
|
+
const configured = typeof sb === 'object' && sb !== null ? str(sb['main']) : null;
|
|
85
|
+
const tried = explicit ? [explicit] : configured ? [configured] : [...ENTRY_CANDIDATES];
|
|
86
|
+
for (const rel of tried)
|
|
87
|
+
if (await exists(join(cwd, rel)))
|
|
88
|
+
return rel;
|
|
89
|
+
throw new BundleError('cli.build.no_entry', { tried: tried.join(', ') });
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* `sb build`: Worker modules + frontend assets + migrations SQL → `.solobrand/build/bundle.json`.
|
|
93
|
+
* Limits are checked before anything is written as bundle.json, so a failed build
|
|
94
|
+
* never leaves a deployable bundle behind.
|
|
95
|
+
*/
|
|
96
|
+
export async function buildApp(options) {
|
|
97
|
+
const { cwd } = options;
|
|
98
|
+
const limits = options.limits ?? LIMITS;
|
|
99
|
+
const dir = join(cwd, BUILD_DIR);
|
|
100
|
+
const app = await appName(cwd);
|
|
101
|
+
const entry = await resolveEntry(cwd, options.entry);
|
|
102
|
+
const fingerprint = await sourceFingerprint(cwd);
|
|
103
|
+
await rm(dir, { recursive: true, force: true });
|
|
104
|
+
await mkdir(join(dir, 'modules'), { recursive: true });
|
|
105
|
+
const worker = await bundleWorker(cwd, entry, join(dir, 'modules'), limits);
|
|
106
|
+
let assets = null;
|
|
107
|
+
const webDir = join(cwd, 'web');
|
|
108
|
+
if (await exists(join(webDir, 'index.html'))) {
|
|
109
|
+
const outDir = join(dir, 'assets');
|
|
110
|
+
await (options.web ?? viteBuilder)(webDir, outDir);
|
|
111
|
+
assets = { dir: 'assets', manifest: await buildAssetsManifest(outDir, limits) };
|
|
112
|
+
}
|
|
113
|
+
let migrations = [];
|
|
114
|
+
const migrationsFile = await firstExisting(cwd, MIGRATIONS_FILES);
|
|
115
|
+
if (migrationsFile !== null) {
|
|
116
|
+
const mod = await loadMigrationsModule(cwd, migrationsFile, join(cwd, '.solobrand', 'tmp'));
|
|
117
|
+
const list = collectMigrations(mod, migrationsFile);
|
|
118
|
+
migrations = compileMigrations(list, options.createSchema ?? (await resolveSchemaFactory(cwd)));
|
|
119
|
+
}
|
|
120
|
+
const bundle = {
|
|
121
|
+
framework: frameworkVersion(cwd),
|
|
122
|
+
app,
|
|
123
|
+
main: worker.main,
|
|
124
|
+
modules: worker.modules,
|
|
125
|
+
assets,
|
|
126
|
+
migrations,
|
|
127
|
+
assetsConfig: DEFAULT_ASSETS_CONFIG,
|
|
128
|
+
};
|
|
129
|
+
const info = { fingerprint, builtAt: new Date().toISOString() };
|
|
130
|
+
await writeFile(join(dir, BUILD_INFO), JSON.stringify(info, null, 2) + '\n');
|
|
131
|
+
await writeFile(join(dir, 'bundle.json'), JSON.stringify(bundle, null, 2) + '\n');
|
|
132
|
+
return { dir, bundle, info };
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/bundle/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC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AAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sha256 over every source file of the app (path + bytes, sorted). `sb build`
|
|
3
|
+
* stores it; `sb deploy` recomputes it and refuses a stale build.
|
|
4
|
+
*/
|
|
5
|
+
export declare function sourceFingerprint(cwd: string): Promise<string>;
|
|
6
|
+
//# sourceMappingURL=fingerprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../src/bundle/fingerprint.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBpE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
3
|
+
import { join, relative, sep } from 'node:path';
|
|
4
|
+
/** Directories that are output, caches or VCS: never part of the source fingerprint. */
|
|
5
|
+
const IGNORED = new Set(['node_modules', '.solobrand', '.git', 'dist', '.wrangler', 'coverage', '.turbo']);
|
|
6
|
+
/**
|
|
7
|
+
* sha256 over every source file of the app (path + bytes, sorted). `sb build`
|
|
8
|
+
* stores it; `sb deploy` recomputes it and refuses a stale build.
|
|
9
|
+
*/
|
|
10
|
+
export async function sourceFingerprint(cwd) {
|
|
11
|
+
const files = [];
|
|
12
|
+
async function walk(dir) {
|
|
13
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
14
|
+
if (IGNORED.has(entry.name))
|
|
15
|
+
continue;
|
|
16
|
+
const full = join(dir, entry.name);
|
|
17
|
+
if (entry.isDirectory())
|
|
18
|
+
await walk(full);
|
|
19
|
+
else if (entry.isFile())
|
|
20
|
+
files.push(full);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
await walk(cwd);
|
|
24
|
+
const rels = files.map((f) => ({ f, rel: relative(cwd, f).split(sep).join('/') })).sort((a, b) => (a.rel < b.rel ? -1 : 1));
|
|
25
|
+
const hash = createHash('sha256');
|
|
26
|
+
for (const { f, rel } of rels) {
|
|
27
|
+
const bytes = await readFile(f);
|
|
28
|
+
hash.update(`${rel}\u0000${bytes.byteLength}\u0000`);
|
|
29
|
+
hash.update(bytes);
|
|
30
|
+
}
|
|
31
|
+
return hash.digest('hex');
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=fingerprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../src/bundle/fingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhD,wFAAwF;AACxF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE3G;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAW;IACjD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,UAAU,IAAI,CAAC,GAAW;QAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YAChE,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,SAAS;YACtC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,WAAW,EAAE;gBAAE,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;iBACrC,IAAI,KAAK,CAAC,MAAM,EAAE;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5H,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,KAAK,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,KAAK,CAAC,UAAU,QAAQ,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { buildApp, appName, resolveEntry, frameworkVersion, BUILD_DIR, BUILD_INFO, DEFAULT_ASSETS_CONFIG, ENTRY_CANDIDATES, MIGRATIONS_FILES } from './build.js';
|
|
2
|
+
export type { BuildOptions, BuildResult, BuildInfo } from './build.js';
|
|
3
|
+
export { deployApp, verifyBuild, readInside, apiBase, parseBundle, bundleForm, redact } from './upload.js';
|
|
4
|
+
export type { DeployOptions, DeployResult, UploadResult, ValidatedResult } from './upload.js';
|
|
5
|
+
export { buildAssetsManifest, assetHash, listFiles, type AssetsManifest } from './manifest.js';
|
|
6
|
+
export { bundleWorker, type WorkerBuildResult, type WorkerModule } from './worker.js';
|
|
7
|
+
export { viteBuilder, createViteBuilder, type WebBuilder } from './web.js';
|
|
8
|
+
export { collectMigrations, compileMigrations, loadMigrationsModule, resolveSchemaFactory, defaultSchemaFactory } from './migrations.js';
|
|
9
|
+
export type { CompiledMigration, MigrationLike, SchemaFactory, SchemaLike } from './migrations.js';
|
|
10
|
+
export { sourceFingerprint } from './fingerprint.js';
|
|
11
|
+
export { LIMITS, type Limits } from './limits.js';
|
|
12
|
+
export { BundleError, bundleMessages, translate, terminalLocale, type BundleMessageKey, type BundleLocale } from './messages.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACjK,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC3G,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACzI,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { buildApp, appName, resolveEntry, frameworkVersion, BUILD_DIR, BUILD_INFO, DEFAULT_ASSETS_CONFIG, ENTRY_CANDIDATES, MIGRATIONS_FILES } from './build.js';
|
|
2
|
+
export { deployApp, verifyBuild, readInside, apiBase, parseBundle, bundleForm, redact } from './upload.js';
|
|
3
|
+
export { buildAssetsManifest, assetHash, listFiles } from './manifest.js';
|
|
4
|
+
export { bundleWorker } from './worker.js';
|
|
5
|
+
export { viteBuilder, createViteBuilder } from './web.js';
|
|
6
|
+
export { collectMigrations, compileMigrations, loadMigrationsModule, resolveSchemaFactory, defaultSchemaFactory } from './migrations.js';
|
|
7
|
+
export { sourceFingerprint } from './fingerprint.js';
|
|
8
|
+
export { LIMITS } from './limits.js';
|
|
9
|
+
export { BundleError, bundleMessages, translate, terminalLocale } from './messages.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bundle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjK,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE3G,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,SAAS,EAAuB,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,YAAY,EAA6C,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAmB,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEzI,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAe,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAA4C,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Cloudflare Workers (static assets + Workers for Platforms) limits enforced before writing the bundle. */
|
|
2
|
+
export declare const LIMITS: {
|
|
3
|
+
/** Files per asset upload. */
|
|
4
|
+
readonly maxAssetFiles: 100000;
|
|
5
|
+
/** Bytes per asset file: 25 MiB. */
|
|
6
|
+
readonly maxAssetBytes: number;
|
|
7
|
+
/** Total Worker code (all modules, uncompressed upper bound): 64 MiB. */
|
|
8
|
+
readonly maxCodeBytes: number;
|
|
9
|
+
};
|
|
10
|
+
export type Limits = {
|
|
11
|
+
readonly maxAssetFiles: number;
|
|
12
|
+
readonly maxAssetBytes: number;
|
|
13
|
+
readonly maxCodeBytes: number;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/bundle/limits.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,eAAO,MAAM,MAAM;IACjB,8BAA8B;;IAE9B,oCAAoC;;IAEpC,yEAAyE;;CAEjE,CAAC;AAEX,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Cloudflare Workers (static assets + Workers for Platforms) limits enforced before writing the bundle. */
|
|
2
|
+
export const LIMITS = {
|
|
3
|
+
/** Files per asset upload. */
|
|
4
|
+
maxAssetFiles: 100_000,
|
|
5
|
+
/** Bytes per asset file: 25 MiB. */
|
|
6
|
+
maxAssetBytes: 25 * 1024 * 1024,
|
|
7
|
+
/** Total Worker code (all modules, uncompressed upper bound): 64 MiB. */
|
|
8
|
+
maxCodeBytes: 64 * 1024 * 1024,
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/bundle/limits.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,8BAA8B;IAC9B,aAAa,EAAE,OAAO;IACtB,oCAAoC;IACpC,aAAa,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAC/B,yEAAyE;IACzE,YAAY,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;CACtB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Limits } from './limits.js';
|
|
2
|
+
export type AssetsManifest = Record<string, {
|
|
3
|
+
hash: string;
|
|
4
|
+
size: number;
|
|
5
|
+
}>;
|
|
6
|
+
/** First 32 hex chars of sha256 over the file bytes: the hash Cloudflare's direct upload is given. */
|
|
7
|
+
export declare function assetHash(bytes: Uint8Array): string;
|
|
8
|
+
/** Every regular file under `dir`, as POSIX paths relative to it, sorted. Symlinks are refused. */
|
|
9
|
+
export declare function listFiles(dir: string): Promise<string[]>;
|
|
10
|
+
/**
|
|
11
|
+
* The assets manifest exactly as Cloudflare's direct upload wants it:
|
|
12
|
+
* `"/path" → { hash, size }`. Enforces the file-count and per-file limits.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildAssetsManifest(dir: string, limits?: Limits): Promise<AssetsManifest>;
|
|
15
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/bundle/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE5E,sGAAsG;AACtG,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEnD;AAQD,mGAAmG;AACnG,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAe9D;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAcvG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstat, readdir, readFile } from 'node:fs/promises';
|
|
3
|
+
import { join, relative, sep } from 'node:path';
|
|
4
|
+
import { LIMITS } from './limits.js';
|
|
5
|
+
import { BundleError } from './messages.js';
|
|
6
|
+
/** First 32 hex chars of sha256 over the file bytes: the hash Cloudflare's direct upload is given. */
|
|
7
|
+
export function assetHash(bytes) {
|
|
8
|
+
return createHash('sha256').update(bytes).digest('hex').slice(0, 32);
|
|
9
|
+
}
|
|
10
|
+
/** A path segment we refuse to ship: empty, dot segments, control chars or backslashes. */
|
|
11
|
+
function unsafeSegment(segment) {
|
|
12
|
+
// eslint-disable-next-line no-control-regex
|
|
13
|
+
return segment === '' || segment === '.' || segment === '..' || /[\u0000-\u001f\\]/.test(segment);
|
|
14
|
+
}
|
|
15
|
+
/** Every regular file under `dir`, as POSIX paths relative to it, sorted. Symlinks are refused. */
|
|
16
|
+
export async function listFiles(dir) {
|
|
17
|
+
const out = [];
|
|
18
|
+
async function walk(current) {
|
|
19
|
+
const entries = await readdir(current, { withFileTypes: true });
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
const full = join(current, entry.name);
|
|
22
|
+
const rel = relative(dir, full).split(sep).join('/');
|
|
23
|
+
if (entry.isSymbolicLink() || unsafeSegment(entry.name))
|
|
24
|
+
throw new BundleError('cli.build.unsafe_asset', { path: rel });
|
|
25
|
+
if (entry.isDirectory())
|
|
26
|
+
await walk(full);
|
|
27
|
+
else if (entry.isFile())
|
|
28
|
+
out.push(rel);
|
|
29
|
+
else
|
|
30
|
+
throw new BundleError('cli.build.unsafe_asset', { path: rel });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
await walk(dir);
|
|
34
|
+
return out.sort();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The assets manifest exactly as Cloudflare's direct upload wants it:
|
|
38
|
+
* `"/path" → { hash, size }`. Enforces the file-count and per-file limits.
|
|
39
|
+
*/
|
|
40
|
+
export async function buildAssetsManifest(dir, limits = LIMITS) {
|
|
41
|
+
const files = await listFiles(dir);
|
|
42
|
+
if (files.length > limits.maxAssetFiles) {
|
|
43
|
+
throw new BundleError('cli.build.too_many_assets', { count: files.length, max: limits.maxAssetFiles });
|
|
44
|
+
}
|
|
45
|
+
const manifest = {};
|
|
46
|
+
for (const rel of files) {
|
|
47
|
+
const full = join(dir, ...rel.split('/'));
|
|
48
|
+
const { size } = await lstat(full);
|
|
49
|
+
if (size > limits.maxAssetBytes)
|
|
50
|
+
throw new BundleError('cli.build.asset_too_large', { path: rel, size, max: limits.maxAssetBytes });
|
|
51
|
+
const bytes = await readFile(full);
|
|
52
|
+
manifest[`/${rel}`] = { hash: assetHash(bytes), size: bytes.byteLength };
|
|
53
|
+
}
|
|
54
|
+
return manifest;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/bundle/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAe,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,sGAAsG;AACtG,MAAM,UAAU,SAAS,CAAC,KAAiB;IACzC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC;AAED,2FAA2F;AAC3F,SAAS,aAAa,CAAC,OAAe;IACpC,4CAA4C;IAC5C,OAAO,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,IAAI,mBAAmB,CAAC,IAA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AM,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QACxC,MAAM,IAAI,WAAW,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;IACzG,CAAC;IACD,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI,GAAG,MAAM,CAAC,aAAa;YAAE,MAAM,IAAI,WAAW,CAAC,2BAA2B,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;QACpI,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;IAC3E,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Translation keys of `sb build` / `sb deploy` (es + en). Errors carry the key, never the sentence. */
|
|
2
|
+
export declare const bundleMessages: {
|
|
3
|
+
readonly es: {
|
|
4
|
+
readonly 'cli.build.no_entry': "No encuentro la entrada del Worker (probé {tried}). Indícala con --entry o \"solobrand.main\" en package.json.";
|
|
5
|
+
readonly 'cli.build.no_app_name': "No sé cómo se llama la app: falta \"app\" en app.json y \"name\" en package.json.";
|
|
6
|
+
readonly 'cli.build.worker_failed': "esbuild no pudo empaquetar el Worker: {detail}";
|
|
7
|
+
readonly 'cli.build.web_failed': "Vite no pudo construir web/: {detail}";
|
|
8
|
+
readonly 'cli.build.migrations_failed': "No pude cargar las migraciones de {file}: {detail}";
|
|
9
|
+
readonly 'cli.build.migrations_invalid': "{file} debe exportar `migrations` (o `allMigrations`): un arreglo de { name, up, down }.";
|
|
10
|
+
readonly 'cli.build.migration_duplicate': "Dos migraciones distintas se llaman «{name}».";
|
|
11
|
+
readonly 'cli.build.migration_sql_failed': "La migración «{name}» no produce SQL válido: {detail}";
|
|
12
|
+
readonly 'cli.build.too_many_assets': "web/ produce {count} archivos; Cloudflare admite como máximo {max}.";
|
|
13
|
+
readonly 'cli.build.asset_too_large': "«{path}» pesa {size} bytes; el máximo por archivo en Cloudflare es {max} (25 MiB).";
|
|
14
|
+
readonly 'cli.build.code_too_large': "El código del Worker pesa {size} bytes; Cloudflare admite como máximo {max} (64 MiB).";
|
|
15
|
+
readonly 'cli.build.unsafe_asset': "«{path}» es un enlace simbólico o un nombre no permitido; no se sube.";
|
|
16
|
+
readonly 'cli.build.done': "Bundle listo en {dir}: {modules} módulos, {assets} archivos, {migrations} migraciones.";
|
|
17
|
+
readonly 'cli.deploy.no_token': "Falta SOLOBRAND_DEPLOY_TOKEN.";
|
|
18
|
+
readonly 'cli.deploy.no_api_url': "Falta SOLOBRAND_API_URL.";
|
|
19
|
+
readonly 'cli.deploy.insecure_url': "SOLOBRAND_API_URL debe ser https:// (http sólo para localhost); el token no viaja en claro.";
|
|
20
|
+
readonly 'cli.deploy.no_build': "No hay build en {dir}. Corre `sb build` primero.";
|
|
21
|
+
readonly 'cli.deploy.stale_build': "El build es viejo: el código cambió desde `sb build`. Vuelve a construir.";
|
|
22
|
+
readonly 'cli.deploy.bad_bundle': "bundle.json no es válido: {detail}";
|
|
23
|
+
readonly 'cli.deploy.unsafe_path': "bundle.json apunta fuera del build («{path}»); no se sube.";
|
|
24
|
+
readonly 'cli.deploy.rejected': "SoloBrand rechazó el bundle ({status}): {detail}";
|
|
25
|
+
readonly 'cli.deploy.network': "No pude hablar con SoloBrand: {detail}";
|
|
26
|
+
readonly 'cli.deploy.bad_response': "SoloBrand respondió algo que no entiendo.";
|
|
27
|
+
readonly 'cli.deploy.uploading': "Subiendo el bundle a SoloBrand…";
|
|
28
|
+
readonly 'cli.build.description': "Construye el bundle de despliegue en .solobrand/build/.";
|
|
29
|
+
readonly 'cli.deploy.description': "Sube el bundle a SoloBrand y muestra la versión y la URL.";
|
|
30
|
+
readonly 'cli.deploy.done': "Versión {version} desplegada: {url}";
|
|
31
|
+
readonly 'cli.deploy.validated': "Bundle de {app} válido en {dir}; no se subió (sin SOLOBRAND_API_URL ni SOLOBRAND_DEPLOY_TOKEN, o --dry-run).";
|
|
32
|
+
};
|
|
33
|
+
readonly en: {
|
|
34
|
+
readonly 'cli.build.no_entry': "Cannot find the Worker entry (tried {tried}). Pass --entry or set \"solobrand.main\" in package.json.";
|
|
35
|
+
readonly 'cli.build.no_app_name': "Unknown app name: \"app\" is missing in app.json and \"name\" in package.json.";
|
|
36
|
+
readonly 'cli.build.worker_failed': "esbuild could not bundle the Worker: {detail}";
|
|
37
|
+
readonly 'cli.build.web_failed': "Vite could not build web/: {detail}";
|
|
38
|
+
readonly 'cli.build.migrations_failed': "Could not load the migrations from {file}: {detail}";
|
|
39
|
+
readonly 'cli.build.migrations_invalid': "{file} must export `migrations` (or `allMigrations`): an array of { name, up, down }.";
|
|
40
|
+
readonly 'cli.build.migration_duplicate': "Two different migrations are named \"{name}\".";
|
|
41
|
+
readonly 'cli.build.migration_sql_failed': "Migration \"{name}\" does not produce valid SQL: {detail}";
|
|
42
|
+
readonly 'cli.build.too_many_assets': "web/ produces {count} files; Cloudflare allows at most {max}.";
|
|
43
|
+
readonly 'cli.build.asset_too_large': "\"{path}\" is {size} bytes; Cloudflare allows at most {max} per file (25 MiB).";
|
|
44
|
+
readonly 'cli.build.code_too_large': "The Worker code is {size} bytes; Cloudflare allows at most {max} (64 MiB).";
|
|
45
|
+
readonly 'cli.build.unsafe_asset': "\"{path}\" is a symbolic link or a disallowed name; it is not uploaded.";
|
|
46
|
+
readonly 'cli.build.done': "Bundle ready in {dir}: {modules} modules, {assets} files, {migrations} migrations.";
|
|
47
|
+
readonly 'cli.deploy.no_token': "SOLOBRAND_DEPLOY_TOKEN is missing.";
|
|
48
|
+
readonly 'cli.deploy.no_api_url': "SOLOBRAND_API_URL is missing.";
|
|
49
|
+
readonly 'cli.deploy.insecure_url': "SOLOBRAND_API_URL must be https:// (http only for localhost); the token never travels in clear text.";
|
|
50
|
+
readonly 'cli.deploy.no_build': "No build in {dir}. Run `sb build` first.";
|
|
51
|
+
readonly 'cli.deploy.stale_build': "The build is stale: the code changed since `sb build`. Build again.";
|
|
52
|
+
readonly 'cli.deploy.bad_bundle': "bundle.json is not valid: {detail}";
|
|
53
|
+
readonly 'cli.deploy.unsafe_path': "bundle.json points outside the build (\"{path}\"); not uploaded.";
|
|
54
|
+
readonly 'cli.deploy.rejected': "SoloBrand rejected the bundle ({status}): {detail}";
|
|
55
|
+
readonly 'cli.deploy.network': "Could not reach SoloBrand: {detail}";
|
|
56
|
+
readonly 'cli.deploy.bad_response': "SoloBrand answered something I do not understand.";
|
|
57
|
+
readonly 'cli.deploy.uploading': "Uploading the bundle to SoloBrand…";
|
|
58
|
+
readonly 'cli.build.description': "Builds the deploy bundle into .solobrand/build/.";
|
|
59
|
+
readonly 'cli.deploy.description': "Uploads the bundle to SoloBrand and prints the version and URL.";
|
|
60
|
+
readonly 'cli.deploy.done': "Version {version} deployed: {url}";
|
|
61
|
+
readonly 'cli.deploy.validated': "Bundle of {app} is valid in {dir}; not uploaded (no SOLOBRAND_API_URL nor SOLOBRAND_DEPLOY_TOKEN, or --dry-run).";
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export type BundleMessageKey = keyof (typeof bundleMessages)['en'];
|
|
65
|
+
export type BundleLocale = keyof typeof bundleMessages;
|
|
66
|
+
/** The locale of the terminal: `es` when LANG/LC_ALL say so, `en` otherwise. */
|
|
67
|
+
export declare function terminalLocale(env?: Readonly<Record<string, string | undefined>>): BundleLocale;
|
|
68
|
+
export declare function translate(key: BundleMessageKey, params?: Readonly<Record<string, string | number>>, locale?: BundleLocale): string;
|
|
69
|
+
/** A failure of build/deploy: a translation key plus its parameters. */
|
|
70
|
+
export declare class BundleError extends Error {
|
|
71
|
+
readonly key: BundleMessageKey;
|
|
72
|
+
readonly params: Readonly<Record<string, string | number>>;
|
|
73
|
+
constructor(key: BundleMessageKey, params?: Readonly<Record<string, string | number>>);
|
|
74
|
+
translated(locale?: BundleLocale): string;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/bundle/messages.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DjB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC;AACnE,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,cAAc,CAAC;AAEvD,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,GAAG,YAAY,CAG5G;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,gBAAgB,EAAE,MAAM,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAM,EAAE,MAAM,GAAE,YAA+B,GAAG,MAAM,CAGxJ;AAED,wEAAwE;AACxE,qBAAa,WAAY,SAAQ,KAAK;IAElC,QAAQ,CAAC,GAAG,EAAE,gBAAgB;IAC9B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;gBADjD,GAAG,EAAE,gBAAgB,EACrB,MAAM,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAM;IAMjE,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM;CAG1C"}
|