|
| 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); |
0 commit comments