@trypattern/sdk 0.1.5 → 0.1.6

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/cli/app.js CHANGED
@@ -74,7 +74,13 @@ const CONTACT_SHEET = join(SCREENSHOTS_DIR, 'contact-sheet.png');
74
74
  const SCREENSHOT_WORKER = join(SDK_SOURCE, 'cli', `screenshot${SDK_EXTENSION}`);
75
75
  const VISUAL_URL_ENV = 'PATTERN_VISUAL_URL';
76
76
  const GLOBAL_FLAGS = ['--json', '--help', '-h'];
77
- const VALUE_FLAGS = new Set(['--commands', '--name', '--as', '--code']);
77
+ const VALUE_FLAGS = new Set([
78
+ '--commands',
79
+ '--name',
80
+ '--as',
81
+ '--code',
82
+ '--message'
83
+ ]);
78
84
  const SHIM_SOURCE = `#!/bin/sh
79
85
  ${SHIM_MARKER_LINE}
80
86
  dir=$PWD
@@ -284,9 +290,14 @@ git would keep, never .dev.vars, .env, node_modules, dist or .dev) to onpattern.
284
290
  until the new version answers at https://<name>.onpattern.app, printing each step. The database
285
291
  moves forward with any new migrations; nothing is ever deleted from it. If a step fails, the site
286
292
  keeps running the previous version and the error says why. Run app check first.
293
+ --message '…' says what changed in a few plain words for the owner ("Pink brand colour and a welcome
294
+ line"); onpattern.app and app versions show it beside the version.
287
295
  --starter (Pattern's admins only) publishes this project as the starter every new site begins from.`,
288
- run: (_argument, options) => publish(publishingIo(), ROOT, options.has('--starter')),
289
- flags: ['--starter']
296
+ run: (_argument, options) => {
297
+ const message = options.get('--message');
298
+ return publish(publishingIo(), ROOT, options.has('--starter'), typeof message === 'string' ? message : undefined);
299
+ },
300
+ flags: ['--starter', '--message']
290
301
  },
291
302
  versions: {
292
303
  summary: 'List the versions that went live, newest first',
@@ -1311,7 +1322,7 @@ async function setup() {
1311
1322
  function help() {
1312
1323
  const width = Math.max(...Object.keys(COMMANDS).map((n) => n.length));
1313
1324
  const lines = Object.entries(COMMANDS).map(([name, cmd]) => `app ${name.padEnd(width)} ${cmd.summary}`);
1314
- lines.push('Flags: --json (machine-readable stdout), <command> --help (details and its own flags: start --no-open, test --visual, screenshot --commands --name --as --signed-out, pull --code)');
1325
+ lines.push('Flags: --json (machine-readable stdout), <command> --help (details and its own flags: start --no-open, test --visual, screenshot --commands --name --as --signed-out, pull --code, publish --message)');
1315
1326
  return {
1316
1327
  code: 0,
1317
1328
  data: {
@@ -15,7 +15,7 @@ export type PublishingIo = {
15
15
  };
16
16
  export declare function login(io: PublishingIo): Promise<Outcome>;
17
17
  export declare function pull(io: PublishingIo, name: string | undefined, cwd: string, setupCode: string | undefined): Promise<Outcome>;
18
- export declare function publish(io: PublishingIo, root: string, isStarter: boolean): Promise<Outcome>;
18
+ export declare function publish(io: PublishingIo, root: string, isStarter: boolean, message: string | undefined): Promise<Outcome>;
19
19
  export declare function versions(io: PublishingIo, root: string): Promise<Outcome>;
20
20
  export declare function restore(io: PublishingIo, root: string, number: string | undefined): Promise<Outcome>;
21
21
  export {};
@@ -3,7 +3,7 @@ import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, st
3
3
  import { homedir, hostname, userInfo } from 'node:os';
4
4
  import { basename, dirname, extname, join, matchesGlob, relative } from 'node:path';
5
5
  import { z } from 'zod';
6
- import { DASHBOARD_URL, UPLOAD, appSummary, isPrivatePath, loginPoll, loginStarted, nameProblem, publishSummary, setupCodeExchanged, sourcePathProblem } from "../publishWire.js";
6
+ import { DASHBOARD_URL, UPLOAD, appSummary, isPrivatePath, loginPoll, loginStarted, nameProblem, publishMessage, publishSummary, setupCodeExchanged, sourcePathProblem } from "../publishWire.js";
7
7
  import { appInfo } from "../appTitle.js";
8
8
  import { PROJECT_FILE, readProjectFile } from "../vite/projectFile.js";
9
9
  const CONFIG_DIR = join(homedir(), '.config', 'pattern');
@@ -424,11 +424,13 @@ async function followPublish(io, name, started) {
424
424
  }
425
425
  const data = { name, version: publish.number, status: publish.status };
426
426
  if (publish.status === 'live') {
427
- return {
428
- code: 0,
429
- data,
430
- text: `✓ Version ${publish.number} is live at https://${name}.onpattern.app`
431
- };
427
+ const lines = [
428
+ `✓ Version ${publish.number} is live at https://${name}.onpattern.app${publish.message === null ? '' : ` · ${publish.message}`}`
429
+ ];
430
+ if (publish.message === null && publish.restoredFrom === null) {
431
+ lines.push(" tip add --message '…' so the owner sees what changed, in plain words");
432
+ }
433
+ return { code: 0, data, text: lines.join('\n') };
432
434
  }
433
435
  if (publish.status === 'failed') {
434
436
  return {
@@ -443,7 +445,7 @@ async function followPublish(io, name, started) {
443
445
  text: `✗ Version ${publish.number} is still publishing after ${PUBLISH_WAIT_MS / 60_000} minutes\n next app versions shows how it ends`
444
446
  };
445
447
  }
446
- export async function publish(io, root, isStarter) {
448
+ export async function publish(io, root, isStarter, message) {
447
449
  try {
448
450
  const { name } = readProjectFile(root);
449
451
  const built = await io.build();
@@ -451,6 +453,9 @@ export async function publish(io, root, isStarter) {
451
453
  return built;
452
454
  io.say('✓ Built');
453
455
  const { form, sources } = uploadForm(root, io, isStarter);
456
+ const said = publishMessage(message ?? '');
457
+ if (said !== null)
458
+ form.append(UPLOAD.message, said);
454
459
  io.say(`✓ Packed the build and ${sources} source files`);
455
460
  const again = isStarter ? 'app publish --starter' : 'app publish';
456
461
  const result = await signedIn(io, again, async () => {
@@ -492,7 +497,7 @@ export async function versions(io, root) {
492
497
  ? `restored version ${item.restoredFrom}`
493
498
  : item.isStarter
494
499
  ? 'starter site'
495
- : `published by ${item.byEmail}`;
500
+ : (item.message ?? `published by ${item.byEmail}`);
496
501
  return ` ${String(item.number).padStart(3)} ${item.status.padEnd(7)} ${item.startedAt.slice(0, 16).replace('T', ' ')} ${what}`;
497
502
  });
498
503
  return {
@@ -17,7 +17,10 @@ export declare const UPLOAD: {
17
17
  readonly source: "source/";
18
18
  readonly compatibilityDate: "compatibilityDate";
19
19
  readonly sdkVersion: "sdkVersion";
20
+ readonly message: "message";
20
21
  };
22
+ export declare const PUBLISH_MESSAGE_LIMIT = 100;
23
+ export declare function publishMessage(text: string): string | null;
21
24
  export declare const publishStep: z.ZodEnum<{
22
25
  publish: "publish";
23
26
  reserve: "reserve";
@@ -47,6 +50,7 @@ export declare const publishSummary: z.ZodObject<{
47
50
  byEmail: z.ZodString;
48
51
  restoredFrom: z.ZodNullable<z.ZodNumber>;
49
52
  isStarter: z.ZodBoolean;
53
+ message: z.ZodNullable<z.ZodString>;
50
54
  startedAt: z.ZodString;
51
55
  finishedAt: z.ZodNullable<z.ZodString>;
52
56
  }, z.core.$strip>;
@@ -73,6 +77,7 @@ export declare const appSummary: z.ZodObject<{
73
77
  byEmail: z.ZodString;
74
78
  restoredFrom: z.ZodNullable<z.ZodNumber>;
75
79
  isStarter: z.ZodBoolean;
80
+ message: z.ZodNullable<z.ZodString>;
76
81
  startedAt: z.ZodString;
77
82
  finishedAt: z.ZodNullable<z.ZodString>;
78
83
  }, z.core.$strip>>;
@@ -135,6 +140,7 @@ export declare const publishServices: {
135
140
  byEmail: z.ZodString;
136
141
  restoredFrom: z.ZodNullable<z.ZodNumber>;
137
142
  isStarter: z.ZodBoolean;
143
+ message: z.ZodNullable<z.ZodString>;
138
144
  startedAt: z.ZodString;
139
145
  finishedAt: z.ZodNullable<z.ZodString>;
140
146
  }, z.core.$strip>>;
@@ -161,6 +167,7 @@ export declare const publishServices: {
161
167
  byEmail: z.ZodString;
162
168
  restoredFrom: z.ZodNullable<z.ZodNumber>;
163
169
  isStarter: z.ZodBoolean;
170
+ message: z.ZodNullable<z.ZodString>;
164
171
  startedAt: z.ZodString;
165
172
  finishedAt: z.ZodNullable<z.ZodString>;
166
173
  }, z.core.$strip>>;
@@ -190,6 +197,7 @@ export declare const publishServices: {
190
197
  byEmail: z.ZodString;
191
198
  restoredFrom: z.ZodNullable<z.ZodNumber>;
192
199
  isStarter: z.ZodBoolean;
200
+ message: z.ZodNullable<z.ZodString>;
193
201
  startedAt: z.ZodString;
194
202
  finishedAt: z.ZodNullable<z.ZodString>;
195
203
  }, z.core.$strip>>;
@@ -227,6 +235,7 @@ export declare const publishServices: {
227
235
  byEmail: z.ZodString;
228
236
  restoredFrom: z.ZodNullable<z.ZodNumber>;
229
237
  isStarter: z.ZodBoolean;
238
+ message: z.ZodNullable<z.ZodString>;
230
239
  startedAt: z.ZodString;
231
240
  finishedAt: z.ZodNullable<z.ZodString>;
232
241
  }, z.core.$strip>>>>;
@@ -247,6 +256,7 @@ export declare const publishServices: {
247
256
  byEmail: z.ZodString;
248
257
  restoredFrom: z.ZodNullable<z.ZodNumber>;
249
258
  isStarter: z.ZodBoolean;
259
+ message: z.ZodNullable<z.ZodString>;
250
260
  startedAt: z.ZodString;
251
261
  finishedAt: z.ZodNullable<z.ZodString>;
252
262
  }, z.core.$strip>>>;
@@ -267,6 +277,7 @@ export declare const publishServices: {
267
277
  byEmail: z.ZodString;
268
278
  restoredFrom: z.ZodNullable<z.ZodNumber>;
269
279
  isStarter: z.ZodBoolean;
280
+ message: z.ZodNullable<z.ZodString>;
270
281
  startedAt: z.ZodString;
271
282
  finishedAt: z.ZodNullable<z.ZodString>;
272
283
  }, z.core.$strip>>>;
@@ -89,8 +89,14 @@ export const UPLOAD = {
89
89
  migrations: 'migrations/',
90
90
  source: 'source/',
91
91
  compatibilityDate: 'compatibilityDate',
92
- sdkVersion: 'sdkVersion'
92
+ sdkVersion: 'sdkVersion',
93
+ message: 'message'
93
94
  };
95
+ export const PUBLISH_MESSAGE_LIMIT = 100;
96
+ export function publishMessage(text) {
97
+ const firstLine = (text.split('\n')[0] ?? '').replaceAll(/\s+/g, ' ').trim();
98
+ return firstLine === '' ? null : firstLine.slice(0, PUBLISH_MESSAGE_LIMIT);
99
+ }
94
100
  export const publishStep = z.enum(['reserve', 'database', 'sign-in', 'publish']);
95
101
  export const publishStatus = z.enum(['running', 'live', 'failed']);
96
102
  export const publishSummary = z.object({
@@ -101,6 +107,7 @@ export const publishSummary = z.object({
101
107
  byEmail: z.string(),
102
108
  restoredFrom: z.number().nullable(),
103
109
  isStarter: z.boolean(),
110
+ message: z.string().nullable(),
104
111
  startedAt: z.string(),
105
112
  finishedAt: z.string().nullable()
106
113
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trypattern/sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",