@driggsby/deploy 0.2.2 → 0.2.4

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/dist/client.d.ts CHANGED
@@ -45,7 +45,7 @@ export interface CreatedApp {
45
45
  url: string;
46
46
  }
47
47
  export declare function createApp(api: DeployApi, baseName: string, appName?: string): Promise<CreatedApp>;
48
- export declare function createVersion(api: DeployApi, slug: string, files: ManifestFile[], appName?: string): Promise<CreatedVersion>;
48
+ export declare function createVersion(api: DeployApi, slug: string, files: ManifestFile[], appName?: string, background?: string): Promise<CreatedVersion>;
49
49
  export declare function uploadBlob(api: DeployApi, sha256: string, bytes: Uint8Array, signal?: AbortSignal): Promise<void>;
50
50
  export declare function finalizeVersion(api: DeployApi, versionId: string, live: boolean): Promise<FinalizedVersion | BlobsMissing>;
51
51
  export declare function listVersions(api: DeployApi, slug: string): Promise<VersionList>;
package/dist/client.js CHANGED
@@ -43,13 +43,16 @@ export async function createApp(api, baseName, appName) {
43
43
  // app_name here is NOT a leftover of the old create-by-deploy flow: the
44
44
  // server intentionally keeps rename-on-redeploy, applying a sent app_name
45
45
  // to the existing app once the deploy is accepted.
46
- export async function createVersion(api, slug, files, appName) {
46
+ export async function createVersion(api, slug, files, appName, background) {
47
47
  const body = {
48
48
  files: files.map((file) => ({ path: file.path, sha256: file.sha256, byte_size: file.byteSize })),
49
49
  };
50
50
  if (appName !== undefined) {
51
51
  body.app_name = appName;
52
52
  }
53
+ if (background !== undefined) {
54
+ body.background = background;
55
+ }
53
56
  const parsed = await requestJson(api, "POST", `/deploy/apps/${encodeURIComponent(slug)}/versions`, {
54
57
  json: body,
55
58
  expectedStatus: 201,
package/dist/deploy.d.ts CHANGED
@@ -4,6 +4,7 @@ import { type CollectedDeploy } from "./manifest.ts";
4
4
  export interface DeployOptions {
5
5
  live: boolean;
6
6
  appName?: string;
7
+ background?: string;
7
8
  }
8
9
  export interface DeployOutcome {
9
10
  appSlug: string;
package/dist/deploy.js CHANGED
@@ -33,7 +33,7 @@ export async function deployProjectFiles(api, projectDirectory, slug, collected,
33
33
  return { outcome, createdApp: created };
34
34
  }
35
35
  export async function deployCollectedFiles(api, slug, collected, options) {
36
- const created = await createVersion(api, slug, collected.files, options.appName);
36
+ const created = await createVersion(api, slug, collected.files, options.appName, options.background);
37
37
  const fileBySha = new Map();
38
38
  for (const file of collected.files) {
39
39
  if (!fileBySha.has(file.sha256)) {
@@ -55,7 +55,7 @@ export async function runDeployEntrypoint(io) {
55
55
  const baseUrl = resolveBaseUrl(io.env);
56
56
  const config = await readProjectConfig(io.cwd);
57
57
  const collected = await collectDeployFiles(config.serveDirectory);
58
- const { outcome, createdApp } = await deployProjectFiles({ baseUrl, token }, io.cwd, config.slug, collected, { live: true });
58
+ const { outcome, createdApp } = await deployProjectFiles({ baseUrl, token }, io.cwd, config.slug, collected, { live: true, ...(config.background !== null ? { background: config.background } : {}) });
59
59
  if (createdApp !== null) {
60
60
  // The assigned slug is server text, so it prints quoted and bounded
61
61
  // like every other string this bin did not author; the whole sentence
@@ -3,6 +3,7 @@ export interface ProjectConfig {
3
3
  serveDirectory: string;
4
4
  serve: string;
5
5
  devCommand: string | null;
6
+ background: string | null;
6
7
  }
7
8
  export declare function readProjectConfig(projectDirectory: string): Promise<ProjectConfig>;
8
9
  export declare function writeAssignedSlug(projectDirectory: string, assignedSlug: string): Promise<void>;
@@ -7,6 +7,9 @@ import { join, relative, resolve, isAbsolute } from "node:path";
7
7
  import { DeployError } from "./errors.js";
8
8
  import { slugProblem } from "./limits.js";
9
9
  import { quotedForTerminal } from "./terminal-text.js";
10
+ // Exactly a bare lowercase hex color — the same shape the deploy API
11
+ // enforces, checked locally so a typo fails fast with the fix.
12
+ const BACKGROUND_PATTERN = /^#[0-9a-f]{6}$/;
10
13
  const MISSING_CONFIG_MESSAGE = "No driggsby.json found in this directory. Create one next to the files you\n" +
11
14
  "want to deploy:\n\n" +
12
15
  ' { "slug": "your-app-name", "serve": "." }\n\n' +
@@ -53,6 +56,20 @@ export async function readProjectConfig(projectDirectory) {
53
56
  'driggsby.json, like "." or "dist".');
54
57
  }
55
58
  const serveDirectory = await resolveServeDirectory(projectDirectory, serve);
59
+ // A declared background must be exactly the shape the server accepts;
60
+ // anything else fails here, locally, instead of as a refused deploy.
61
+ // Friendly slop (case, whitespace) normalizes rather than failing.
62
+ const rawBackground = config.background;
63
+ let background = null;
64
+ if (rawBackground !== undefined && rawBackground !== null) {
65
+ const normalized = typeof rawBackground === "string" ? rawBackground.trim().toLowerCase() : "";
66
+ if (!BACKGROUND_PATTERN.test(normalized)) {
67
+ throw new DeployError('The "background" field in driggsby.json must be a plain lowercase hex\n' +
68
+ 'color like "#0b0c0f" — your app\'s own page background, so Driggsby can\n' +
69
+ "paint it while the app loads. Remove the field if you don't want one.");
70
+ }
71
+ background = normalized;
72
+ }
56
73
  // dev_command is attacker-controlled text from a cloned or generated
57
74
  // driggsby.json. Nothing executes it today; any future consumer must spawn
58
75
  // it without a shell and never let it reach one.
@@ -62,6 +79,7 @@ export async function readProjectConfig(projectDirectory) {
62
79
  serveDirectory,
63
80
  serve,
64
81
  devCommand: typeof devCommand === "string" && devCommand !== "" ? devCommand : null,
82
+ background,
65
83
  };
66
84
  }
67
85
  // Persists the server-assigned slug into driggsby.json, keeping every other
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driggsby/deploy",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Deploy static Driggsby apps: the deploy protocol client used by the driggsby CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {