Skip to content

Commit 457b8d0

Browse files
committed
add 'code' to publish record
1 parent e63fa37 commit 457b8d0

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

src/publish/common/publish.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { PublishFiles } from "../provider.ts";
2222
export interface PublishSite {
2323
id?: string;
2424
url?: string;
25+
code?: boolean;
2526
}
2627

2728
export interface PublishDeploy {
@@ -69,6 +70,7 @@ export async function handlePublish<
6970
target = {
7071
id: site.id!,
7172
url: site.url!,
73+
code: !!site.code,
7274
};
7375
});
7476
info("");

src/publish/config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { stringify } from "encoding/yaml.ts";
1010
import { basename, dirname, join } from "path/mod.ts";
1111
import { existsSync } from "fs/mod.ts";
1212

13+
import * as ld from "../core/lodash.ts";
14+
1315
import { Metadata } from "../config/types.ts";
1416
import { readYaml, readYamlFromString } from "../core/yaml.ts";
1517
import { ProjectContext } from "../project/types.ts";
@@ -29,6 +31,15 @@ export function readPublishDeployments(
2931
);
3032
if (sourceDeployments) {
3133
delete (sourceDeployments as { source?: string }).source;
34+
// provide 'code' field
35+
Object.values(sourceDeployments).forEach((deployment) => {
36+
if (Array.isArray(deployment)) {
37+
deployment = deployment.map((d) => {
38+
d.code = !!d.code;
39+
return d;
40+
});
41+
}
42+
});
3243
return sourceDeployments as PublishDeployments;
3344
}
3445
} else {
@@ -47,6 +58,12 @@ export function writePublishDeployment(
4758
provider: string,
4859
publish: PublishRecord,
4960
) {
61+
// don't write 'code' field if false
62+
publish = ld.cloneDeep(publish) as PublishRecord;
63+
if (publish.code === false) {
64+
delete (publish as Record<string, unknown>).code;
65+
}
66+
5067
// read base config
5168
let indent = 2;
5269
const [deployDir, deploySource] = resolveDeploymentSource(source);

src/publish/rsconnect/rsconnect.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,15 @@ async function publish(
214214
if (!target) {
215215
const content = await createContent(account, type, title);
216216
if (content) {
217+
target = { id: content.guid, url: content.content_url, code: false };
217218
console.log(content);
218219
} else {
219220
throw new Error();
220221
}
221222
}
222223

224+
// see rsconnect::writeManifest function
225+
223226
return Promise.resolve([target!, new URL("https://example.com")]);
224227
}
225228

src/publish/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type PublishDeployments = Record<string, Array<PublishRecord>>;
1212
export type PublishRecord = {
1313
id: string;
1414
url: string;
15+
code: boolean;
1516
};
1617

1718
export type PublishOptions = {

0 commit comments

Comments
 (0)