bamboohr-cli 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +33 -7
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -64,6 +64,28 @@ function getMetaFields(client) {
64
64
 
65
65
  // src/utils/client.ts
66
66
  import { BambooHRClient } from "bamboohr-client";
67
+
68
+ // src/utils/credentials.ts
69
+ function getCredentialInfo() {
70
+ const companyDomain = process.env.BAMBOO_COMPANY_DOMAIN;
71
+ const token = process.env.BAMBOO_TOKEN;
72
+ return {
73
+ environment: {
74
+ BAMBOO_COMPANY_DOMAIN: {
75
+ value: companyDomain ?? null,
76
+ description: 'Company subdomain (e.g., "mycompany" for mycompany.bamboohr.com)'
77
+ },
78
+ BAMBOO_TOKEN: {
79
+ value: token ? "<set>" : null,
80
+ description: "BambooHR API token"
81
+ }
82
+ },
83
+ tokenUrl: `https://${companyDomain ?? "<companyDomain>"}.bamboohr.com/app/settings/permissions/api_keys`,
84
+ hint: "Export environment variables in your shell profile (e.g., ~/.zshrc)."
85
+ };
86
+ }
87
+
88
+ // src/utils/client.ts
67
89
  function getClient() {
68
90
  const apiToken = process.env.BAMBOO_TOKEN;
69
91
  const companyDomain = process.env.BAMBOO_COMPANY_DOMAIN;
@@ -72,11 +94,7 @@ function getClient() {
72
94
  process.stderr.write(
73
95
  `${JSON.stringify({
74
96
  error: `Missing required environment variables: ${missing.join(", ")}`,
75
- setup: {
76
- BAMBOO_TOKEN: "BambooHR API token \u2014 generate in BambooHR > Settings > API Keys",
77
- BAMBOO_COMPANY_DOMAIN: 'Company subdomain (e.g., "mycompany" for mycompany.bamboohr.com)'
78
- },
79
- hint: "Export these in your shell profile (e.g., ~/.zshrc)."
97
+ ...getCredentialInfo()
80
98
  })}
81
99
  `
82
100
  );
@@ -105,8 +123,12 @@ function stripResponse(obj) {
105
123
  }
106
124
 
107
125
  // src/utils/output.ts
126
+ var prettyPrint = false;
127
+ function setPretty(value) {
128
+ prettyPrint = value;
129
+ }
108
130
  function output(data) {
109
- process.stdout.write(`${JSON.stringify(stripResponse(data), null, 2)}
131
+ process.stdout.write(`${JSON.stringify(stripResponse(data), null, prettyPrint ? 2 : void 0)}
110
132
  `);
111
133
  }
112
134
  function handleError(err) {
@@ -127,7 +149,7 @@ function handleError(err) {
127
149
  process.stderr.write(
128
150
  `${JSON.stringify({
129
151
  error: "Authentication failed (HTTP 401)",
130
- hint: "Verify that BAMBOO_TOKEN and BAMBOO_COMPANY_DOMAIN are set correctly. The token may be expired or invalid."
152
+ ...getCredentialInfo()
131
153
  })}
132
154
  `
133
155
  );
@@ -612,6 +634,10 @@ ${styleText("bold", "Examples:")}
612
634
  ${DIM}$${RESET} bamboohr meta fields
613
635
  `
614
636
  );
637
+ program.option("--pretty", "Pretty-print JSON output");
638
+ program.hook("preAction", (thisCommand) => {
639
+ if (thisCommand.optsWithGlobals().pretty) setPretty(true);
640
+ });
615
641
  registerEmployeeCommands(program);
616
642
  registerTimeoffCommands(program);
617
643
  registerFileCommands(program);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bamboohr-cli",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "publish": true,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,9 +22,9 @@
22
22
  "tsx": "^4.19.2",
23
23
  "typescript": "^5.7.2",
24
24
  "vitest": "^4.0.16",
25
- "config-eslint": "0.0.0",
25
+ "cli-utils": "1.0.0",
26
26
  "config-typescript": "0.0.0",
27
- "cli-utils": "1.0.0"
27
+ "config-eslint": "0.0.0"
28
28
  },
29
29
  "engines": {
30
30
  "node": ">=22.0.0"