Skip to content

Commit

Permalink
fix(pod): acknowledge cli args for publish pod (#2352)
Browse files Browse the repository at this point in the history
* fix(pod): acknowledge cli args for publish pod

* fix: resolved PR comments
  • Loading branch information
Harshita-mindfire committed Feb 9, 2022
1 parent 562f2bd commit b5d1f15
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
21 changes: 9 additions & 12 deletions packages/dendron-cli/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,25 @@
{
"label": "export-pod",
"type": "shell",
"command": "node --inspect /usr/local/bin/dendron-cli exportPod --wsRoot ~/Dendron --podId dendron.airtable --podPkg @dendronhq/airtable-pod --podSource remote --showConfig",
"options": {
"cwd": "/Users/kevinlin/Dendron"
},
"command": "node --inspect ${workspaceFolder}/lib/bin/dendron-cli exportPod --wsRoot ${workspaceFolder}/../../test-workspace --podId dendron.airtable --podPkg @dendronhq/airtable-pod --showConfig",
"problemMatcher": []
},
{
"label": "gdoc-import-pod",
"type": "shell",
"command": "node --inspect dendron_setup/dendron/packages/dendron-cli/lib/bin/dendron-cli importPod --wsRoot ~/Dendron --podId dendron.gdoc --podSource builtin",
"options": {
"cwd": "D:/"
},
"command": "node --inspect ${workspaceFolder}/lib/bin/dendron-cli importPod --wsRoot ${workspaceFolder}/../../test-workspace --podId dendron.gdoc --podSource builtin",
"problemMatcher": []
},
{
"label": "orbit-import-pod",
"type": "shell",
"command": "node --inspect packages/dendron-cli/lib/bin/dendron-cli importPod --wsRoot ${workspaceFolder}/../test-workspace --podId dendron.orbit --podSource builtin",
"options": {
"cwd": "D:/dendron_setup/dendron/"
},
"command": "node --inspect ${workspaceFolder}/lib/bin/dendron-cli importPod --wsRoot ${workspaceFolder}/../../test-workspace --podId dendron.orbit --podSource builtin",
"problemMatcher": []
},
{
"label": "publish-pod",
"type": "shell",
"command": "node --inspect ${workspaceFolder}/lib/bin/dendron-cli publishPod --wsRoot ${workspaceFolder}/../../test-workspace --podId dendron.markdown --vault vault --query root --podSource builtin",
"problemMatcher": []
}
]
Expand Down
37 changes: 27 additions & 10 deletions packages/dendron-cli/src/commands/pod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import {
PodConflictResolveOpts,
RespV3,
} from "@dendronhq/common-all";
import { PodClassEntryV4, PodKind, PodUtils } from "@dendronhq/pods-core";
import {
HTMLPublishPod,
JSONPublishPod,
MarkdownPublishPod,
PodClassEntryV4,
PodKind,
PodUtils,
} from "@dendronhq/pods-core";
import _ from "lodash";
import path from "path";
import prompts from "prompts";
Expand All @@ -21,6 +28,7 @@ export type PodCLIOpts = {
config?: string;
configPath?: string;
query?: string;
vault?: string;
};

export type PodCommandCLIOpts = {} & SetupEngineCLIOpts & PodCLIOpts;
Expand Down Expand Up @@ -151,7 +159,7 @@ export function enrichPodArgs(opts: {
podsDir,
podClass,
});
if (resp.error && !config) {
if (resp.error && !config && PodUtils.hasRequiredOpts(podClass)) {
return {
error: resp.error,
};
Expand All @@ -169,16 +177,25 @@ export function enrichPodArgs(opts: {
});
}

// if query is specified, then override config to pass in query
if (args.query) {
if (podType === "publish") {
if (podType === "publish") {
switch (podId) {
case MarkdownPublishPod.id:
case JSONPublishPod.id:
case HTMLPublishPod.id:
cleanConfig["dest"] = "stdout";
}
// if vault is specified, then override config to pass in
if (args.vault) {
cleanConfig["vaultName"] = args.vault;
}
if (args.query) {
cleanConfig["fname"] = args.query;
} else {
// eslint-disable-next-line no-console
console.log(
`WARN: --query parameter not implemented for podType ${podType}`
);
}
} else {
// eslint-disable-next-line no-console
console.log(
`WARN: --query and --vault parameter not implemented for podType ${podType}`
);
}

// error checking, config shouldn't be empty
Expand Down
3 changes: 1 addition & 2 deletions packages/dendron-cli/src/commands/publishPod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export class PublishPodCLICommand extends CLICommand<
const pod = new PodClass() as PublishPod;
const resp = await pod.execute({ wsRoot, config, engine, vaults });
if (config.dest === "stdout") {
// eslint-disable-next-line no-console
console.log(resp);
this.print(resp);
}
return new Promise((resolve) => {
server.close((err: any) => {
Expand Down

0 comments on commit b5d1f15

Please sign in to comment.