Skip to content

Commit

Permalink
fix: Minor UX improvements to the CLI (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeesha authored Mar 30, 2024
1 parent dedd266 commit a9be753
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
5 changes: 3 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test": "exit 0",
"start": "node ./bin/index.js",
"build": "tsc",
"clean": "rm -rf ./bin"
"clean": "rm -rf ./bin",
"dev": "npm run build && npm run start"
},
"author": "",
"license": "ISC",
Expand All @@ -35,4 +36,4 @@
"@types/yargs": "^17.0.32",
"jest": "^29.6.4"
}
}
}
15 changes: 13 additions & 2 deletions cli/src/commands/clusters-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,22 @@ export const ClusterCreate: CommandModule<{}, ClusterCreateArgs> = {
description: description ?? "CLI Created Cluster",
},
});

if (d.status !== 204) {
console.error(`Failed to create cluster: ${d.status}`);
return;
}
} else {
console.log("Cluster created successfully");

const clusters = await client.getClustersForUser();

console.log("Cluster created successfully");
if (clusters.status === 200) {
const cluster = clusters.body.sort((a, b) =>
a.createdAt > b.createdAt ? -1 : 1,
)[0];

console.log(cluster);
}
}
},
};
9 changes: 8 additions & 1 deletion cli/src/commands/clusters-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export const ClusterList: CommandModule<{}, ClusterCreateArgs> = {
return;
}

console.log(d.body);
console.log(
d.body.map((c) => ({
...c,
apiSecret:
c.apiSecret.substring(0, 8) + "*".repeat(c.apiSecret.length - 8),
info: `differential clusters info --cluster ${c.id}`,
})),
);
},
};
6 changes: 3 additions & 3 deletions cli/src/commands/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import * as os from "os";
import { buildProject } from "../lib/package";
import debug from "debug";
import { cloudEnabledCheck } from "../lib/auth";

import repl from "repl";
import { Differential } from "@differentialhq/core";
import { client } from "../lib/client";

const log = debug("differential:cli:repl");
Expand Down Expand Up @@ -73,7 +71,9 @@ export const Repl: CommandModule<{}, ReplArgs> = {

const replServer = repl.start("> ");

replServer.context.d = new Differential(apiSecret);
replServer.context.d = require("@differentialhq/core").Differential(
apiSecret,
);
for (const service of project.serviceRegistrations.keys()) {
replServer.context[service] = replServer.context.d.client(service);
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export const buildClientPackage = async ({
main: "index.d.ts",
version: version,
peerDependencies: {
"@differentialhq/core": "^3.13.1",
"@differentialhq/core": "latest",
},
exports: {
".": {
Expand Down

0 comments on commit a9be753

Please sign in to comment.