Skip to content

Commit 9336ee4

Browse files
committed
bind to server account for rsconnect re-publish
1 parent adde635 commit 9336ee4

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/command/publish/account.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,26 @@ import {
1515
kPublishProviders,
1616
PublishProvider,
1717
} from "../../publish/provider.ts";
18+
import { PublishRecord } from "../../publish/types.ts";
1819

1920
export type AccountPrompt = "always" | "never" | "multiple";
2021

2122
export async function resolveAccount(
2223
provider: PublishProvider,
2324
prompt: AccountPrompt,
25+
target?: PublishRecord,
2426
) {
2527
// see what tyep of token we are going to use
2628
let token: AccountToken | undefined;
2729

2830
// build list of account options
29-
const accounts = await provider.accountTokens();
31+
const accounts = (await provider.accountTokens()).filter((account) => {
32+
if (account.server && target?.url) {
33+
return target.url.startsWith(account.server);
34+
} else {
35+
return true;
36+
}
37+
});
3038

3139
// if we aren't prompting then we need to have one at the ready
3240
if (prompt === "never") {

src/command/publish/cmd.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async function publishAction(
110110
const account = await resolveAccount(
111111
publishProvider,
112112
publishOptions.prompt ? accountPrompt : "never",
113+
publishTarget,
113114
);
114115
if (account) {
115116
await publish(

src/publish/rsconnect/rsconnect.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { pandocAutoIdentifier } from "../../core/pandoc/pandoc-id.ts";
3131
import { contentName } from "../publish.ts";
3232
import { createTempContext } from "../../core/temp.ts";
3333
import { createBundle } from "./bundle.ts";
34-
import { sleep } from "../../core/wait.ts";
3534

3635
export const kRSConnect = "rsconnect";
3736
const kRSConnectDescription = "RS Connect";
@@ -227,7 +226,6 @@ async function publish(
227226
content = await createContent(client, type, title);
228227
if (content) {
229228
target = { id: content.guid, url: content.content_url, code: false };
230-
console.log(content);
231229
} else {
232230
throw new Error();
233231
}

0 commit comments

Comments
 (0)