@jakubmazanec/cli 0.5.4-next.fac374fa → 0.5.4-unstable.2468857d

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 (86) hide show
  1. package/build/_virtual/rolldown_runtime.js +18 -0
  2. package/build/constants.js +7 -5
  3. package/build/main.js +18 -4
  4. package/build/program/Command.js +54 -70
  5. package/build/program/Program.js +153 -188
  6. package/build/program/ProgramError.js +9 -5
  7. package/build/program/getProgramDetail.js +21 -24
  8. package/build/ui/Failure.js +61 -17
  9. package/build/ui/Header.js +18 -17
  10. package/build/ui/Help.js +44 -35
  11. package/build/ui/Spinner.js +35 -19
  12. package/build/ui/colors.js +28 -12
  13. package/build/ui/form/FormRow.js +42 -72
  14. package/build/ui/form/SelectInput.js +91 -83
  15. package/build/ui/form/TextInput.js +115 -126
  16. package/build/ui/form/createForm.js +57 -70
  17. package/build/ui/getErrorDetail.js +47 -62
  18. package/build/ui/icons.js +27 -12
  19. package/build/ui/internals/Wrapper.js +45 -44
  20. package/build/ui/internals/programContext.js +9 -3
  21. package/build/ui/internals/rotate.js +14 -5
  22. package/build/ui/useProgram.js +21 -16
  23. package/package.json +9 -9
  24. package/build/constants.js.map +0 -7
  25. package/build/main.js.map +0 -7
  26. package/build/program/Command.js.map +0 -7
  27. package/build/program/CommandAction.js +0 -2
  28. package/build/program/CommandAction.js.map +0 -7
  29. package/build/program/CommandArguments.js +0 -2
  30. package/build/program/CommandArguments.js.map +0 -7
  31. package/build/program/CommandOptions.js +0 -2
  32. package/build/program/CommandOptions.js.map +0 -7
  33. package/build/program/Program.js.map +0 -7
  34. package/build/program/ProgramCreateOptions.js +0 -2
  35. package/build/program/ProgramCreateOptions.js.map +0 -7
  36. package/build/program/ProgramDetail.js +0 -2
  37. package/build/program/ProgramDetail.js.map +0 -7
  38. package/build/program/ProgramError.js.map +0 -7
  39. package/build/program/ProgramOptions.js +0 -2
  40. package/build/program/ProgramOptions.js.map +0 -7
  41. package/build/program/ProgramStreams.js +0 -2
  42. package/build/program/ProgramStreams.js.map +0 -7
  43. package/build/program/getProgramDetail.js.map +0 -7
  44. package/build/program.js +0 -6
  45. package/build/program.js.map +0 -7
  46. package/build/ui/ErrorDetail.js +0 -2
  47. package/build/ui/ErrorDetail.js.map +0 -7
  48. package/build/ui/Failure.js.map +0 -7
  49. package/build/ui/Header.js.map +0 -7
  50. package/build/ui/Help.js.map +0 -7
  51. package/build/ui/Spinner.js.map +0 -7
  52. package/build/ui/colors.js.map +0 -7
  53. package/build/ui/form/Form.js +0 -2
  54. package/build/ui/form/Form.js.map +0 -7
  55. package/build/ui/form/FormConfig.js +0 -2
  56. package/build/ui/form/FormConfig.js.map +0 -7
  57. package/build/ui/form/FormProps.js +0 -2
  58. package/build/ui/form/FormProps.js.map +0 -7
  59. package/build/ui/form/FormResult.js +0 -2
  60. package/build/ui/form/FormResult.js.map +0 -7
  61. package/build/ui/form/FormRow.js.map +0 -7
  62. package/build/ui/form/FormRowConfig.js +0 -2
  63. package/build/ui/form/FormRowConfig.js.map +0 -7
  64. package/build/ui/form/FormRowsConfig.js +0 -2
  65. package/build/ui/form/FormRowsConfig.js.map +0 -7
  66. package/build/ui/form/FormValue.js +0 -2
  67. package/build/ui/form/FormValue.js.map +0 -7
  68. package/build/ui/form/FormValues.js +0 -2
  69. package/build/ui/form/FormValues.js.map +0 -7
  70. package/build/ui/form/SelectInput.js.map +0 -7
  71. package/build/ui/form/SelectInputItem.js +0 -2
  72. package/build/ui/form/SelectInputItem.js.map +0 -7
  73. package/build/ui/form/TextInput.js.map +0 -7
  74. package/build/ui/form/createForm.js.map +0 -7
  75. package/build/ui/form.js +0 -6
  76. package/build/ui/form.js.map +0 -7
  77. package/build/ui/getErrorDetail.js.map +0 -7
  78. package/build/ui/icons.js.map +0 -7
  79. package/build/ui/internals/Wrapper.js.map +0 -7
  80. package/build/ui/internals/programContext.js.map +0 -7
  81. package/build/ui/internals/rotate.js.map +0 -7
  82. package/build/ui/internals.js +0 -5
  83. package/build/ui/internals.js.map +0 -7
  84. package/build/ui/useProgram.js.map +0 -7
  85. package/build/ui.js +0 -11
  86. package/build/ui.js.map +0 -7
@@ -0,0 +1,18 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (all, symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __export };
@@ -1,8 +1,10 @@
1
- "use strict";
2
1
  import path from "node:path";
3
2
  import url from "node:url";
3
+
4
+ //#region source/constants.ts
4
5
  let directory = path.dirname(url.fileURLToPath(import.meta.url));
5
- export const PACKAGE_PATH = path.resolve(directory, "..");
6
- export const CACHE_PATH = path.resolve(PACKAGE_PATH, "node_modules/.cache");
7
- export const DELIMITER = "$ ";
8
- //# sourceMappingURL=constants.js.map
6
+ const PACKAGE_PATH = path.resolve(directory, "..");
7
+ const CACHE_PATH = path.resolve(PACKAGE_PATH, "node_modules/.cache");
8
+
9
+ //#endregion
10
+ export { CACHE_PATH };
package/build/main.js CHANGED
@@ -1,4 +1,18 @@
1
- "use strict";
2
- export * from "./program.js";
3
- export * from "./ui.js";
4
- //# sourceMappingURL=main.js.map
1
+ import { Command } from "./program/Command.js";
2
+ import { getProgramDetail } from "./program/getProgramDetail.js";
3
+ import { colors_exports } from "./ui/colors.js";
4
+ import { getErrorDetail } from "./ui/getErrorDetail.js";
5
+ import { Spinner } from "./ui/Spinner.js";
6
+ import { Header } from "./ui/Header.js";
7
+ import { icons_exports } from "./ui/icons.js";
8
+ import { Failure } from "./ui/Failure.js";
9
+ import { SelectInput } from "./ui/form/SelectInput.js";
10
+ import { TextInput } from "./ui/form/TextInput.js";
11
+ import { FormRow } from "./ui/form/FormRow.js";
12
+ import { createForm } from "./ui/form/createForm.js";
13
+ import { Help } from "./ui/Help.js";
14
+ import { useProgram } from "./ui/useProgram.js";
15
+ import { ProgramError } from "./program/ProgramError.js";
16
+ import { Program } from "./program/Program.js";
17
+
18
+ export { Command, Failure, FormRow, Header, Help, Program, ProgramError, SelectInput, Spinner, TextInput, colors_exports as colors, createForm, getErrorDetail, getProgramDetail, icons_exports as icons, useProgram };
@@ -1,70 +1,54 @@
1
- "use strict";
2
- import {
3
- parseArguments
4
- } from "@jakubmazanec/args";
5
- export class Command {
6
- name;
7
- description;
8
- parameters;
9
- options;
10
- allowUnknownOptions;
11
- allowUnknownParameters;
12
- action;
13
- /**
14
- * @param name Command name, ie. space-separated words consisting only of letters, numbers (but not at the start of the word) or dashes.
15
- * @param action Function that runs when command is executed.
16
- * @param options Additionl command options.
17
- */
18
- constructor(name, action, {
19
- description,
20
- parameters,
21
- options,
22
- allowUnknownOptions,
23
- allowUnknownParameters
24
- }) {
25
- this.name = name;
26
- this.action = action;
27
- if (description) {
28
- this.description = description;
29
- }
30
- if (parameters) {
31
- this.parameters = parameters;
32
- } else {
33
- this.parameters = null;
34
- }
35
- if (options) {
36
- this.options = options;
37
- } else {
38
- this.options = null;
39
- }
40
- if (allowUnknownOptions) {
41
- this.allowUnknownOptions = allowUnknownOptions;
42
- } else {
43
- this.allowUnknownOptions = false;
44
- }
45
- if (allowUnknownParameters) {
46
- this.allowUnknownParameters = allowUnknownParameters;
47
- } else {
48
- this.allowUnknownParameters = false;
49
- }
50
- }
51
- /**
52
- * Parses a list of command line arguments into an arguments object. Parser is pre-configured based on this command.
53
- */
54
- parseArguments(argv) {
55
- return parseArguments(argv, {
56
- commands: [this.name],
57
- parameters: this.parameters ?? void 0,
58
- options: this.options ?? void 0,
59
- allowUnknownOptions: this.allowUnknownOptions,
60
- allowUnknownParameters: this.allowUnknownParameters
61
- });
62
- }
63
- /**
64
- * Executes command action with provided parsed arguments and {@link Program} instance.
65
- */
66
- async run(parsedArgs, program) {
67
- await this.action(parsedArgs, program);
68
- }
69
- }
70
- //# sourceMappingURL=Command.js.map
1
+ import { parseArguments } from "@jakubmazanec/args";
2
+
3
+ //#region source/program/Command.ts
4
+ /**
5
+ * Command encapsulates piece of a CLI's logic and is executed when {@link Program} instance parses that command from the command line arguments.
6
+ */
7
+ var Command = class {
8
+ name;
9
+ description;
10
+ parameters;
11
+ options;
12
+ allowUnknownOptions;
13
+ allowUnknownParameters;
14
+ action;
15
+ /**
16
+ * @param name Command name, ie. space-separated words consisting only of letters, numbers (but not at the start of the word) or dashes.
17
+ * @param action Function that runs when command is executed.
18
+ * @param options Additionl command options.
19
+ */
20
+ constructor(name, action, { description, parameters, options, allowUnknownOptions, allowUnknownParameters }) {
21
+ this.name = name;
22
+ this.action = action;
23
+ if (description) this.description = description;
24
+ if (parameters) this.parameters = parameters;
25
+ else this.parameters = null;
26
+ if (options) this.options = options;
27
+ else this.options = null;
28
+ if (allowUnknownOptions) this.allowUnknownOptions = allowUnknownOptions;
29
+ else this.allowUnknownOptions = false;
30
+ if (allowUnknownParameters) this.allowUnknownParameters = allowUnknownParameters;
31
+ else this.allowUnknownParameters = false;
32
+ }
33
+ /**
34
+ * Parses a list of command line arguments into an arguments object. Parser is pre-configured based on this command.
35
+ */
36
+ parseArguments(argv) {
37
+ return parseArguments(argv, {
38
+ commands: [this.name],
39
+ parameters: this.parameters ?? void 0,
40
+ options: this.options ?? void 0,
41
+ allowUnknownOptions: this.allowUnknownOptions,
42
+ allowUnknownParameters: this.allowUnknownParameters
43
+ });
44
+ }
45
+ /**
46
+ * Executes command action with provided parsed arguments and {@link Program} instance.
47
+ */
48
+ async run(parsedArgs, program) {
49
+ await this.action(parsedArgs, program);
50
+ }
51
+ };
52
+
53
+ //#endregion
54
+ export { Command };
@@ -1,191 +1,156 @@
1
- "use strict";
1
+ import { CACHE_PATH } from "../constants.js";
2
+ import { Failure } from "../ui/Failure.js";
3
+ import { Wrapper } from "../ui/internals/Wrapper.js";
4
+ import { Help } from "../ui/Help.js";
5
+ import { ProgramError } from "./ProgramError.js";
2
6
  import fs from "fs-extra";
3
7
  import fetchLatestVersion from "latest-version";
4
8
  import path from "node:path";
5
- import { CACHE_PATH } from "../constants.js";
6
- import { Failure, Help } from "../ui.js";
7
- import { Wrapper } from "../ui/internals.js";
8
- import { ProgramError } from "./ProgramError.js";
9
- export class Program {
10
- /** Program name. */
11
- name;
12
- /** More readable program name. */
13
- displayName;
14
- /** Program version. */
15
- version;
16
- /** Program latest version. */
17
- latestVersion;
18
- /** Program description. */
19
- description;
20
- /** Program executable name. */
21
- bin;
22
- /** Program commands */
23
- commands = [];
24
- isRendering = false;
25
- streams = {
26
- stderr: process.stderr,
27
- stdin: process.stdin,
28
- stdout: process.stdout
29
- };
30
- /** Custom error boundary fallback component */
31
- ErrorBoundaryFallbackComponent;
32
- constructor({
33
- name,
34
- displayName,
35
- version,
36
- latestVersion,
37
- description,
38
- bin,
39
- ErrorBoundaryFallbackComponent
40
- }) {
41
- if (name) {
42
- this.name = name;
43
- }
44
- if (displayName) {
45
- this.displayName = displayName;
46
- }
47
- if (version) {
48
- this.version = version;
49
- }
50
- if (latestVersion) {
51
- this.latestVersion = latestVersion;
52
- }
53
- if (description) {
54
- this.description = description;
55
- }
56
- if (bin) {
57
- this.bin = bin;
58
- }
59
- if (ErrorBoundaryFallbackComponent) {
60
- this.ErrorBoundaryFallbackComponent = ErrorBoundaryFallbackComponent;
61
- } else {
62
- this.ErrorBoundaryFallbackComponent = Failure;
63
- }
64
- }
65
- static async create({
66
- name,
67
- version,
68
- description,
69
- bin,
70
- ErrorBoundaryFallbackComponent,
71
- checkForUpdate
72
- }) {
73
- let latestVersion;
74
- if (checkForUpdate && name) {
75
- let cachePath = path.join(CACHE_PATH, name, "latest-version.json");
76
- let cachedLatestVersion;
77
- try {
78
- cachedLatestVersion = await fs.readJson(cachePath);
79
- } catch {
80
- }
81
- if (!cachedLatestVersion || Date.now() - cachedLatestVersion.datetime > 864e4) {
82
- latestVersion = await fetchLatestVersion(name);
83
- await fs.ensureFile(cachePath);
84
- await fs.writeJson(cachePath, {
85
- value: latestVersion,
86
- datetime: Date.now()
87
- });
88
- }
89
- }
90
- return new this({
91
- name,
92
- version,
93
- latestVersion,
94
- description,
95
- bin,
96
- ErrorBoundaryFallbackComponent
97
- });
98
- }
99
- /**
100
- * Adds command to the program.
101
- *
102
- * @param command Command to add.
103
- * @returns Program instance.
104
- */
105
- addCommand(command) {
106
- this.commands.push(command);
107
- return this;
108
- }
109
- /**
110
- * Renders a React element using Ink and outputs to the configured streams.
111
- *
112
- * @param element The React element to render.
113
- */
114
- async renderElement(element) {
115
- if (this.isRendering) {
116
- throw new ProgramError("NO_NESTED_RENDER");
117
- } else {
118
- this.isRendering = true;
119
- }
120
- let { render } = await import("ink");
121
- let { createElement } = await import("react");
122
- let { stdin, stdout, stderr } = this.streams;
123
- try {
124
- render(createElement(Wrapper, { program: this }, element), {
125
- exitOnCtrlC: true,
126
- patchConsole: true,
127
- stderr,
128
- stdin,
129
- stdout
130
- });
131
- } catch (error) {
132
- if (error instanceof Error) {
133
- await this.renderElement(
134
- createElement(this.ErrorBoundaryFallbackComponent, { error, resetErrorBoundary: () => {
135
- } })
136
- );
137
- }
138
- } finally {
139
- this.isRendering = false;
140
- }
141
- }
142
- /**
143
- * Runs the program.
144
- *
145
- * @param argv Unparsed command line arguments.
146
- */
147
- async run(argv) {
148
- let hasCommandRun = false;
149
- for (let command of this.commands) {
150
- let parsedArgs = command.parseArguments(argv);
151
- if (parsedArgs.command) {
152
- hasCommandRun = true;
153
- if (parsedArgs.errors.length) {
154
- let { createElement } = await import("react");
155
- for (let error of parsedArgs.errors) {
156
- process.exitCode = 1;
157
- await this.renderElement(
158
- createElement(this.ErrorBoundaryFallbackComponent, {
159
- error,
160
- resetErrorBoundary: () => {
161
- }
162
- })
163
- );
164
- }
165
- } else {
166
- try {
167
- await command.run(parsedArgs, this);
168
- } catch (error) {
169
- let { createElement } = await import("react");
170
- if (error instanceof Error) {
171
- process.exitCode = 1;
172
- await this.renderElement(
173
- createElement(this.ErrorBoundaryFallbackComponent, {
174
- error,
175
- resetErrorBoundary: () => {
176
- }
177
- })
178
- );
179
- }
180
- }
181
- break;
182
- }
183
- }
184
- }
185
- if (!hasCommandRun) {
186
- let { createElement } = await import("react");
187
- await this.renderElement(createElement(Help, { program: this }));
188
- }
189
- }
190
- }
191
- //# sourceMappingURL=Program.js.map
9
+
10
+ //#region source/program/Program.ts
11
+ /**
12
+ * Program manages and executes {@link Command} instances attached to it based on parsing command line arguments.
13
+ */
14
+ var Program = class {
15
+ /** Program name. */
16
+ name;
17
+ /** More readable program name. */
18
+ displayName;
19
+ /** Program version. */
20
+ version;
21
+ /** Program latest version. */
22
+ latestVersion;
23
+ /** Program description. */
24
+ description;
25
+ /** Program executable name. */
26
+ bin;
27
+ /** Program commands */
28
+ commands = [];
29
+ isRendering = false;
30
+ streams = {
31
+ stderr: process.stderr,
32
+ stdin: process.stdin,
33
+ stdout: process.stdout
34
+ };
35
+ /** Custom error boundary fallback component */
36
+ ErrorBoundaryFallbackComponent;
37
+ constructor({ name, displayName, version, latestVersion, description, bin, ErrorBoundaryFallbackComponent }) {
38
+ if (name) this.name = name;
39
+ if (displayName) this.displayName = displayName;
40
+ if (version) this.version = version;
41
+ if (latestVersion) this.latestVersion = latestVersion;
42
+ if (description) this.description = description;
43
+ if (bin) this.bin = bin;
44
+ if (ErrorBoundaryFallbackComponent) this.ErrorBoundaryFallbackComponent = ErrorBoundaryFallbackComponent;
45
+ else this.ErrorBoundaryFallbackComponent = Failure;
46
+ }
47
+ static async create({ name, version, description, bin, ErrorBoundaryFallbackComponent, checkForUpdate }) {
48
+ let latestVersion;
49
+ if (checkForUpdate && name) {
50
+ let cachePath = path.join(CACHE_PATH, name, "latest-version.json");
51
+ let cachedLatestVersion;
52
+ try {
53
+ cachedLatestVersion = await fs.readJson(cachePath);
54
+ } catch {}
55
+ if (!cachedLatestVersion || Date.now() - cachedLatestVersion.datetime > 864e4) {
56
+ latestVersion = await fetchLatestVersion(name);
57
+ await fs.ensureFile(cachePath);
58
+ await fs.writeJson(cachePath, {
59
+ value: latestVersion,
60
+ datetime: Date.now()
61
+ });
62
+ }
63
+ }
64
+ return new this({
65
+ name,
66
+ version,
67
+ latestVersion,
68
+ description,
69
+ bin,
70
+ ErrorBoundaryFallbackComponent
71
+ });
72
+ }
73
+ /**
74
+ * Adds command to the program.
75
+ *
76
+ * @param command Command to add.
77
+ * @returns Program instance.
78
+ */
79
+ addCommand(command) {
80
+ this.commands.push(command);
81
+ return this;
82
+ }
83
+ /**
84
+ * Renders a React element using Ink and outputs to the configured streams.
85
+ *
86
+ * @param element The React element to render.
87
+ */
88
+ async renderElement(element) {
89
+ if (this.isRendering) throw new ProgramError("NO_NESTED_RENDER");
90
+ else this.isRendering = true;
91
+ let { render } = await import("ink");
92
+ let { createElement } = await import("react");
93
+ let { stdin, stdout, stderr } = this.streams;
94
+ try {
95
+ render(createElement(Wrapper, { program: this }, element), {
96
+ exitOnCtrlC: true,
97
+ patchConsole: true,
98
+ stderr,
99
+ stdin,
100
+ stdout
101
+ });
102
+ } catch (error) {
103
+ if (error instanceof Error) await this.renderElement(createElement(this.ErrorBoundaryFallbackComponent, {
104
+ error,
105
+ resetErrorBoundary: () => {}
106
+ }));
107
+ } finally {
108
+ this.isRendering = false;
109
+ }
110
+ }
111
+ /**
112
+ * Runs the program.
113
+ *
114
+ * @param argv Unparsed command line arguments.
115
+ */
116
+ async run(argv) {
117
+ let hasCommandRun = false;
118
+ for (let command of this.commands) {
119
+ let parsedArgs = command.parseArguments(argv);
120
+ if (parsedArgs.command) {
121
+ hasCommandRun = true;
122
+ if (parsedArgs.errors.length) {
123
+ let { createElement } = await import("react");
124
+ for (let error of parsedArgs.errors) {
125
+ process.exitCode = 1;
126
+ await this.renderElement(createElement(this.ErrorBoundaryFallbackComponent, {
127
+ error,
128
+ resetErrorBoundary: () => {}
129
+ }));
130
+ }
131
+ } else {
132
+ try {
133
+ await command.run(parsedArgs, this);
134
+ } catch (error) {
135
+ let { createElement } = await import("react");
136
+ if (error instanceof Error) {
137
+ process.exitCode = 1;
138
+ await this.renderElement(createElement(this.ErrorBoundaryFallbackComponent, {
139
+ error,
140
+ resetErrorBoundary: () => {}
141
+ }));
142
+ }
143
+ }
144
+ break;
145
+ }
146
+ }
147
+ }
148
+ if (!hasCommandRun) {
149
+ let { createElement } = await import("react");
150
+ await this.renderElement(createElement(Help, { program: this }));
151
+ }
152
+ }
153
+ };
154
+
155
+ //#endregion
156
+ export { Program };
@@ -1,6 +1,10 @@
1
- "use strict";
2
1
  import { createCustomError } from "@jakubmazanec/error";
3
- export const ProgramError = createCustomError("ProgramError", {
4
- NO_NESTED_RENDER: "A React render process already exists. This usually occurs by triggering nested render calls."
5
- });
6
- //# sourceMappingURL=ProgramError.js.map
2
+
3
+ //#region source/program/ProgramError.ts
4
+ /**
5
+ * A subclass of `Error` that indicates a program failure.
6
+ */
7
+ const ProgramError = createCustomError("ProgramError", { NO_NESTED_RENDER: "A React render process already exists. This usually occurs by triggering nested render calls." });
8
+
9
+ //#endregion
10
+ export { ProgramError };
@@ -1,25 +1,22 @@
1
- "use strict";
2
- export function getProgramDetail(packageJson) {
3
- let programDetail = {};
4
- if (packageJson.name) {
5
- programDetail.name = packageJson.name;
6
- }
7
- if (packageJson.version) {
8
- programDetail.version = packageJson.version;
9
- }
10
- if (packageJson.description) {
11
- programDetail.description = packageJson.description;
12
- }
13
- if (packageJson.bin && typeof packageJson.bin !== "string") {
14
- let bins = Object.entries(packageJson.bin);
15
- if (bins.length === 1) {
16
- let firstBin = bins[0];
17
- [programDetail.bin] = firstBin;
18
- }
19
- }
20
- if (typeof packageJson.bin === "string" && packageJson.name) {
21
- programDetail.bin = packageJson.name;
22
- }
23
- return programDetail;
1
+ //#region source/program/getProgramDetail.ts
2
+ /**
3
+ * Creates detailed information about a {@lincode Program}.
4
+ */
5
+ function getProgramDetail(packageJson) {
6
+ let programDetail = {};
7
+ if (packageJson.name) programDetail.name = packageJson.name;
8
+ if (packageJson.version) programDetail.version = packageJson.version;
9
+ if (packageJson.description) programDetail.description = packageJson.description;
10
+ if (packageJson.bin && typeof packageJson.bin !== "string") {
11
+ let bins = Object.entries(packageJson.bin);
12
+ if (bins.length === 1) {
13
+ let firstBin = bins[0];
14
+ [programDetail.bin] = firstBin;
15
+ }
16
+ }
17
+ if (typeof packageJson.bin === "string" && packageJson.name) programDetail.bin = packageJson.name;
18
+ return programDetail;
24
19
  }
25
- //# sourceMappingURL=getProgramDetail.js.map
20
+
21
+ //#endregion
22
+ export { getProgramDetail };