Skip to content

Commit b3a86a8

Browse files
committed
initial scaffold for publish command
1 parent dabdd33 commit b3a86a8

File tree

8 files changed

+159
-1
lines changed

8 files changed

+159
-1
lines changed

src/command/command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { checkCommand } from "./check/cmd.ts";
1818
import { inspectCommand } from "./inspect/cmd.ts";
1919
import { buildJsCommand } from "./build-js/cmd.ts";
2020
import { installCommand } from "./install/cmd.ts";
21+
import { publishCommand } from "./publish/cmd.ts";
2122

2223
// deno-lint-ignore no-explicit-any
2324
export function commands(): Command<any>[] {
@@ -29,6 +30,7 @@ export function commands(): Command<any>[] {
2930
convertCommand,
3031
checkCommand,
3132
installCommand,
33+
// publishCommand,
3234
capabilitiesCommand,
3335
inspectCommand,
3436
toolsCommand,

src/command/publish/cmd.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* cmd.ts
3+
*
4+
* Copyright (C) 2020 by RStudio, PBC
5+
*
6+
*/
7+
8+
import { Command } from "cliffy/command/mod.ts";
9+
import { Select } from "cliffy/prompt/select.ts";
10+
import { PublishOptions } from "./common.ts";
11+
12+
import { ghpagesCommand, ghpagesPublish, kGhpages } from "./ghpages.ts";
13+
import { kNetlify, netlifyCommand, netlifyPublish } from "./netlify.ts";
14+
15+
export const publishCommand = new Command()
16+
.name("publish")
17+
.arguments("[path:string]")
18+
.option(
19+
"--no-render",
20+
"Do not render before publishing.",
21+
)
22+
.description(
23+
"Publish a document or project to a variety of destinations.",
24+
// deno-lint-ignore no-explicit-any
25+
).action(async (options: any, path?: string) => {
26+
// shared options
27+
const publishOptions: PublishOptions = {
28+
path: path || Deno.cwd(),
29+
render: !!options.render,
30+
};
31+
32+
// select method
33+
const method: string = await Select.prompt({
34+
message: "Select destination:",
35+
options: [
36+
{ name: "Netlify", value: kNetlify },
37+
{ name: "GitHub Pages", value: kGhpages },
38+
],
39+
});
40+
41+
switch (method) {
42+
case kNetlify:
43+
netlifyPublish(publishOptions);
44+
break;
45+
46+
case kGhpages:
47+
ghpagesPublish(publishOptions);
48+
break;
49+
}
50+
})
51+
.command(kNetlify, netlifyCommand)
52+
.command(kGhpages, ghpagesCommand);

src/command/publish/common.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* common.ts
3+
*
4+
* Copyright (C) 2020 by RStudio, PBC
5+
*
6+
*/
7+
8+
import { Command } from "cliffy/command/mod.ts";
9+
10+
export interface PublishOptions {
11+
path: string;
12+
render: boolean;
13+
}
14+
15+
export function publishSubcommand(name: string, description: string) {
16+
return new Command()
17+
.name(name)
18+
.description(description)
19+
.arguments("[path:string]")
20+
.option(
21+
"--no-render",
22+
"Do not render before publishing.",
23+
);
24+
}

src/command/publish/ghpages.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* gh-pages.ts
3+
*
4+
* Copyright (C) 2020 by RStudio, PBC
5+
*
6+
*/
7+
8+
import { PublishOptions, publishSubcommand } from "./common.ts";
9+
10+
export const kGhpages = "ghpages";
11+
12+
export const ghpagesCommand = publishSubcommand(
13+
kGhpages,
14+
"Publish to GitHub Pages",
15+
)
16+
// deno-lint-ignore no-explicit-any
17+
.action((options: any, path?: string) => {
18+
path = path || Deno.cwd();
19+
ghpagesPublish({
20+
path,
21+
render: !!options.render,
22+
});
23+
console.log("ghpages");
24+
console.log(path);
25+
});
26+
27+
export function ghpagesPublish(options: PublishOptions) {
28+
console.log("ghpages");
29+
console.log(options);
30+
}

src/command/publish/netlify.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* netlify.ts
3+
*
4+
* Copyright (C) 2020 by RStudio, PBC
5+
*
6+
*/
7+
8+
import { PublishOptions, publishSubcommand } from "./common.ts";
9+
10+
export const kNetlify = "netlify";
11+
12+
export const netlifyCommand = publishSubcommand(kNetlify, "Publish to netlify")
13+
// deno-lint-ignore no-explicit-any
14+
.action((options: any, path?: string) => {
15+
path = path || Deno.cwd();
16+
netlifyPublish({
17+
path,
18+
render: !!options.render,
19+
});
20+
});
21+
22+
export function netlifyPublish(options: PublishOptions) {
23+
console.log("netlify");
24+
console.log(options);
25+
}

src/command/render/filters.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import {
5858
Extension,
5959
extensionIdString,
6060
} from "../../extension/extension-shared.ts";
61-
import { kTemplatePartials } from "./template.ts";
6261

6362
const kQuartoParams = "quarto-params";
6463

src/pubiish/ghpages.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* ghpages.ts
3+
*
4+
* Copyright (C) 2020 by RStudio, PBC
5+
*
6+
*/
7+
8+
export interface GhpagesOptions {
9+
site: string;
10+
}
11+
12+
export function ghpagesPublish(options: GhpagesOptions) {
13+
}

src/pubiish/netlify.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* netlify.ts
3+
*
4+
* Copyright (C) 2020 by RStudio, PBC
5+
*
6+
*/
7+
8+
export interface NetlifyOptions {
9+
site: string;
10+
}
11+
12+
export function netlifyPublish(options: NetlifyOptions) {
13+
}

0 commit comments

Comments
 (0)