@trypattern/sdk 0.1.18 → 0.1.19
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/publishing.js
CHANGED
|
@@ -6,7 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
import { DASHBOARD_URL, UPLOAD, appSummary, isPrivatePath, loginPoll, loginStarted, mediaRow, nameProblem, publishMessage, publishSummary, setupCodeExchanged, sourcePathProblem } from "../publishWire.js";
|
|
7
7
|
import { appInfo } from "../appTitle.js";
|
|
8
8
|
import { SESSION_COOKIE } from "../auth/user.js";
|
|
9
|
-
import { PROJECT_FILE, blueprintOf, readProjectFile } from "../vite/projectFile.js";
|
|
9
|
+
import { PROJECT_FILE, blueprintOf, readProjectFile, rememberVersion } from "../vite/projectFile.js";
|
|
10
10
|
const CONFIG_DIR = join(homedir(), '.config', 'pattern');
|
|
11
11
|
const CREDENTIALS_FILE = join(CONFIG_DIR, 'credentials.json');
|
|
12
12
|
const PENDING_FILE = join(CONFIG_DIR, 'pending-login.json');
|
|
@@ -324,7 +324,8 @@ export async function pull(io, name, cwd, setupCode) {
|
|
|
324
324
|
if (existsSync(join(target, LAUNCHER)))
|
|
325
325
|
chmodSync(join(target, LAUNCHER), 0o755);
|
|
326
326
|
const blueprint = blueprintOf(target);
|
|
327
|
-
|
|
327
|
+
const version = Number(result.number);
|
|
328
|
+
writeFileSync(join(target, PROJECT_FILE), `${JSON.stringify({ name, title: result.title, ...(blueprint === undefined ? {} : { blueprint }), ...(Number.isInteger(version) ? { version } : {}) }, null, 2)}\n`);
|
|
328
329
|
io.say(`✓ Downloaded ${files} files of version ${result.number}`);
|
|
329
330
|
if (!(await ensurePnpm(io, target))) {
|
|
330
331
|
return {
|
|
@@ -491,7 +492,7 @@ async function followPublish(io, name, started) {
|
|
|
491
492
|
export async function publish(io, root, isStarter, message, starter) {
|
|
492
493
|
try {
|
|
493
494
|
sayHost(io);
|
|
494
|
-
const { name, blueprint } = readProjectFile(root);
|
|
495
|
+
const { name, blueprint, version } = readProjectFile(root);
|
|
495
496
|
if (isStarter && blueprint === undefined) {
|
|
496
497
|
throw new Error(`${PROJECT_FILE} needs "blueprint" ("website" or "web-app") to publish the starter for it`);
|
|
497
498
|
}
|
|
@@ -503,6 +504,8 @@ export async function publish(io, root, isStarter, message, starter) {
|
|
|
503
504
|
if (isStarter && blueprint !== undefined) {
|
|
504
505
|
form.append(UPLOAD.blueprint, blueprint);
|
|
505
506
|
}
|
|
507
|
+
if (!isStarter)
|
|
508
|
+
form.append(UPLOAD.version, String(version ?? 0));
|
|
506
509
|
const said = publishMessage(message ?? '');
|
|
507
510
|
if (said !== null)
|
|
508
511
|
form.append(UPLOAD.message, said);
|
|
@@ -530,6 +533,7 @@ export async function publish(io, root, isStarter, message, starter) {
|
|
|
530
533
|
text: `✓ Published the ${blueprint} starter for SDK ${io.sdkVersion}`
|
|
531
534
|
};
|
|
532
535
|
}
|
|
536
|
+
rememberVersion(root, result.number);
|
|
533
537
|
return await followPublish(io, name, result);
|
|
534
538
|
}
|
|
535
539
|
catch (error) {
|
|
@@ -589,6 +593,7 @@ export async function restore(io, root, number) {
|
|
|
589
593
|
const result = await signedIn(io, `app restore ${number}`, () => callJson(`/api/apps/${name}/publishes/${number}/restore`, publishSummary, { method: 'POST' }));
|
|
590
594
|
if (isOutcome(result))
|
|
591
595
|
return result;
|
|
596
|
+
rememberVersion(root, result.number);
|
|
592
597
|
return await followPublish(io, name, result);
|
|
593
598
|
}
|
|
594
599
|
catch (error) {
|
package/dist/publishWire.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare const UPLOAD: {
|
|
|
23
23
|
readonly runWorkerFirst: "runWorkerFirst";
|
|
24
24
|
readonly starter: "starter";
|
|
25
25
|
readonly blueprint: "blueprint";
|
|
26
|
+
readonly version: "version";
|
|
26
27
|
};
|
|
27
28
|
export declare const BLUEPRINTS: readonly ["website", "web-app"];
|
|
28
29
|
export declare const blueprintName: z.ZodEnum<{
|
package/dist/publishWire.js
CHANGED
|
@@ -94,7 +94,8 @@ export const UPLOAD = {
|
|
|
94
94
|
message: 'message',
|
|
95
95
|
runWorkerFirst: 'runWorkerFirst',
|
|
96
96
|
starter: 'starter',
|
|
97
|
-
blueprint: 'blueprint'
|
|
97
|
+
blueprint: 'blueprint',
|
|
98
|
+
version: 'version'
|
|
98
99
|
};
|
|
99
100
|
export const BLUEPRINTS = ['website', 'web-app'];
|
|
100
101
|
export const blueprintName = z.enum(BLUEPRINTS);
|
|
@@ -7,8 +7,10 @@ declare const projectFile: z.ZodObject<{
|
|
|
7
7
|
website: "website";
|
|
8
8
|
"web-app": "web-app";
|
|
9
9
|
}>>;
|
|
10
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
10
11
|
}, z.core.$strip>;
|
|
11
12
|
export type ProjectFile = z.output<typeof projectFile>;
|
|
12
13
|
export declare function readProjectFile(root: string): ProjectFile;
|
|
13
14
|
export declare function blueprintOf(root: string): "website" | "web-app" | undefined;
|
|
15
|
+
export declare function rememberVersion(root: string, version: number): void;
|
|
14
16
|
export {};
|
package/dist/vite/projectFile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { appTitle } from "../appTitle.js";
|
|
@@ -7,7 +7,8 @@ export const PROJECT_FILE = 'pattern.json';
|
|
|
7
7
|
const projectFile = z.object({
|
|
8
8
|
name: z.string().min(1),
|
|
9
9
|
title: appTitle,
|
|
10
|
-
blueprint: blueprintName.optional()
|
|
10
|
+
blueprint: blueprintName.optional(),
|
|
11
|
+
version: z.number().int().min(0).optional()
|
|
11
12
|
});
|
|
12
13
|
export function readProjectFile(root) {
|
|
13
14
|
const path = join(root, PROJECT_FILE);
|
|
@@ -33,3 +34,8 @@ export function blueprintOf(root) {
|
|
|
33
34
|
return undefined;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
37
|
+
export function rememberVersion(root, version) {
|
|
38
|
+
const path = join(root, PROJECT_FILE);
|
|
39
|
+
const raw = JSON.parse(readFileSync(path, 'utf8'));
|
|
40
|
+
writeFileSync(path, `${JSON.stringify({ ...Object(raw), version }, null, 2)}\n`);
|
|
41
|
+
}
|