mechanica 2.0.2 → 2.0.3

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.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The bundle `mechanica push` uploads: the built `dist/` for one commit, as one
3
+ * request body.
4
+ *
5
+ * "MCHB" | u32 LE header length | header JSON | the files' bytes, in header order
6
+ * header = { format: 1, commit, engine, files: [ { path, size } ] }
7
+ *
8
+ * `commit` ties the bundle to the source it was built from; `engine` (this
9
+ * package's version) tells the platform which export code to render it with.
10
+ * Paths are relative to `dist/`, forward-slashed, sorted — the same build always
11
+ * produces the same header.
12
+ */
13
+ export declare const BUNDLE_MAGIC = "MCHB";
14
+ export declare const BUNDLE_FORMAT = 1;
15
+ export interface BundleHeader {
16
+ format: typeof BUNDLE_FORMAT;
17
+ /** The full id of the commit the bundle was built from. */
18
+ commit: string;
19
+ /** The mechanica version that built it. */
20
+ engine: string;
21
+ files: {
22
+ path: string;
23
+ size: number;
24
+ }[];
25
+ }
26
+ /** Every file under `dir`, as forward-slashed paths relative to it, sorted. */
27
+ export declare function listBundleFiles(dir: string): Promise<string[]>;
28
+ /** Serialize already-read files into a bundle body. */
29
+ export declare function encodeBundle(meta: {
30
+ commit: string;
31
+ engine: string;
32
+ }, files: {
33
+ path: string;
34
+ data: Uint8Array;
35
+ }[]): Uint8Array;
36
+ /** Read a built `dist/` and pack it for upload. */
37
+ export declare function packBundle(distDir: string, meta: {
38
+ commit: string;
39
+ engine: string;
40
+ }): Promise<Uint8Array>;
@@ -0,0 +1,11 @@
1
+ /** The hosted platform `mechanica login` / `link` / `push` talk to by default. */
2
+ export declare const DEFAULT_HOST = "https://mechanica.jt3.ru";
3
+ /** Normalize a host argument to an origin (`https://example.com`, no trailing slash or path). */
4
+ export declare function hostOrigin(host: string | undefined): string;
5
+ /**
6
+ * The access token for a platform origin: `MECHANICA_TOKEN` (CI) wins over the
7
+ * one `mechanica login` saved.
8
+ */
9
+ export declare function getToken(origin: string): Promise<string | null>;
10
+ /** Remember the token for an origin, in a file only the user can read. */
11
+ export declare function saveToken(origin: string, token: string): Promise<string>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This package's version, read from its own `package.json` — found by walking
3
+ * up from this module, which sits at a different depth in `src/` and in the
4
+ * built `dist/` (and its chunks).
5
+ */
6
+ export declare function engineVersion(): string;
@@ -0,0 +1,15 @@
1
+ export interface GitResult {
2
+ code: number;
3
+ stdout: string;
4
+ stderr: string;
5
+ }
6
+ /**
7
+ * Environment that makes git send the access token to one origin only, as HTTP
8
+ * Basic credentials. Passed through `GIT_CONFIG_*` variables so the token never
9
+ * appears on a command line (visible to other processes) or in the repo config.
10
+ */
11
+ export declare function gitAuthEnv(origin: string, token: string): Record<string, string>;
12
+ /** Run git in `cwd` and collect its output; never throws on a non-zero exit. */
13
+ export declare function git(cwd: string, args: string[], env?: Record<string, string>): Promise<GitResult>;
14
+ /** Like {@link git}, but a non-zero exit throws with git's own message. */
15
+ export declare function gitOk(cwd: string, args: string[], env?: Record<string, string>): Promise<string>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `mechanica link <slug>`: attach this project to a site on the platform by
3
+ * pointing the `mechanica` git remote at it. With `--create` the site is made
4
+ * first. The remote is the whole link — `mechanica push` reads the platform
5
+ * origin and the site from its URL, so there is no extra config file.
6
+ */
7
+ export declare function runLink(slug: string | undefined, options: {
8
+ host?: string;
9
+ create?: boolean;
10
+ name?: string;
11
+ }): Promise<void>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * `mechanica login`: sign in to the platform and keep an access token for this
3
+ * machine. With `--token` the given token is stored as is (CI, or a token made
4
+ * in the dashboard); otherwise it asks for email + password and creates one.
5
+ */
6
+ export declare function runLogin(options: {
7
+ host?: string;
8
+ token?: string;
9
+ }): Promise<void>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `mechanica push`: publish the committed project to the platform.
3
+ *
4
+ * 1. bring in what was published online since the last pull (`pull --rebase`),
5
+ * 2. `git push` the commits to the site's repository,
6
+ * 3. if the code changed, build locally and upload the bundle for that commit
7
+ * (content-only pushes reuse the bundle already there — no build at all),
8
+ * 4. wait for the deploy and report it.
9
+ *
10
+ * The build runs on this machine; the platform only ever renders the bundle.
11
+ */
12
+ export declare function runPush(): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import { type ExportOptions } from './export';
2
+ /**
3
+ * `mechanica export`: build the project, then statically render every page
4
+ * into `export/`. Kept apart from `export.ts` so that module never imports
5
+ * Vite — `mechanica/export` runs where only a built bundle exists.
6
+ */
7
+ export declare function runExport(options?: ExportOptions): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mechanica",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Build Vue 3 websites with a visual block editor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -37,6 +37,10 @@
37
37
  "types": "./dist/types/vite/index.d.ts",
38
38
  "import": "./dist/plugin.js"
39
39
  },
40
+ "./export": {
41
+ "types": "./dist/types/cli/export.d.ts",
42
+ "import": "./dist/export.js"
43
+ },
40
44
  "./editor": {
41
45
  "import": "./dist/editor.js"
42
46
  },
@@ -58,7 +62,7 @@
58
62
  "prepublishOnly": "bun ../../scripts/ensure-bun-publish.js && bun run build"
59
63
  },
60
64
  "dependencies": {
61
- "mechanica-shared": "2.0.2",
65
+ "mechanica-shared": "2.0.3",
62
66
  "@vue/compiler-sfc": "^3.5.38",
63
67
  "compact-json-schema": "^0.1.5",
64
68
  "estree-walker": "^3.0.3",
@@ -1,10 +0,0 @@
1
- /**
2
- * Upload a built project to a backend. Preserves v1's binary body format
3
- * (a JSON tree header + concatenated file buffers) so the existing backend
4
- * keeps working; the contract is redesigned later with the SAAS service.
5
- */
6
- export declare function runPush(options: {
7
- key?: string;
8
- host?: string;
9
- dir?: string;
10
- }): Promise<void>;