@curviate/cli 0.10.0 → 0.12.0

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.
@@ -1,92 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- slimCompany
4
- } from "./chunk-SSPILTKF.js";
5
- import {
6
- resolveIdentifier
7
- } from "./chunk-DMQZEPQE.js";
8
- import {
9
- createClient,
10
- renderError,
11
- renderSuccess,
12
- renderUnexpectedError,
13
- resolveEffectiveConfig
14
- } from "./chunk-47SYFQRF.js";
15
- import {
16
- GLOBAL_FLAGS
17
- } from "./chunk-TDYIQHQX.js";
18
-
19
- // src/commands/company.ts
20
- import { defineCommand } from "citty";
21
- function buildOutputStreams() {
22
- return {
23
- stdout: { write: (s) => process.stdout.write(s) },
24
- stderr: { write: (s) => process.stderr.write(s) }
25
- };
26
- }
27
- async function runCompanyGet(client, flags, out) {
28
- if (flags.preview) {
29
- out.stderr.write("error: --preview is only valid on write commands (mutations). Reads just run.\n");
30
- process.exit(2);
31
- }
32
- if (flags.all) {
33
- out.stderr.write("error: --all is not supported on non-paginated commands.\n");
34
- process.exit(2);
35
- }
36
- if (flags.sections !== void 0) {
37
- out.stderr.write("error: --sections is not supported on company commands.\n");
38
- process.exit(2);
39
- }
40
- const rawId = flags.id ?? "";
41
- const resolvedId = resolveIdentifier(rawId);
42
- const outOpts = {
43
- json: (flags.json ?? false) || !process.stdout.isTTY,
44
- isTTY: process.stdout.isTTY ?? false,
45
- fields: flags.fields,
46
- verbose: flags.verbose ?? false,
47
- slim: slimCompany
48
- };
49
- try {
50
- const getCompany = flags.account ? client.account(flags.account).profiles.getCompany.bind(client.account(flags.account).profiles) : client.profiles.getCompany.bind(client.profiles);
51
- const result = await getCompany(resolvedId);
52
- renderSuccess(result, outOpts, out);
53
- } catch (err) {
54
- const { CurviateError } = await import("@curviate/sdk");
55
- if (err instanceof CurviateError) {
56
- const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
57
- renderError(err, outOpts, out);
58
- process.exit(getExitCode(err.code));
59
- }
60
- renderUnexpectedError(err, out);
61
- process.exit(1);
62
- }
63
- }
64
- var companyCommand = defineCommand({
65
- meta: { name: "company", description: "Fetch a company profile by URL or slug." },
66
- args: {
67
- ...GLOBAL_FLAGS,
68
- id: { type: "positional", description: "Company identifier (URL, slug, or native id)." },
69
- sections: { type: "string", description: "Not supported on company commands \u2014 usage error (exit 2) if supplied." }
70
- },
71
- async run({ args }) {
72
- const flags = args;
73
- const cfg = await resolveEffectiveConfig({
74
- apiKey: flags["api-key"],
75
- baseUrl: flags["base-url"],
76
- timeout: flags.timeout,
77
- account: flags.account,
78
- profile: flags.profile
79
- });
80
- if (!cfg.apiKey) {
81
- process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
82
- process.exit(3);
83
- }
84
- const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
85
- const out = buildOutputStreams();
86
- await runCompanyGet(client, { ...flags, account: flags.account ?? cfg.account }, out);
87
- }
88
- });
89
- export {
90
- companyCommand,
91
- runCompanyGet
92
- };