@kubernetesjs/cli 0.0.3 → 0.1.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.
Files changed (59) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +54 -55
  3. package/commands/apply.d.ts +4 -0
  4. package/commands/apply.js +171 -0
  5. package/commands/cluster-info.d.ts +4 -0
  6. package/commands/cluster-info.js +26 -0
  7. package/commands/config-handler.d.ts +11 -0
  8. package/commands/config-handler.js +81 -0
  9. package/commands/config.d.ts +4 -0
  10. package/commands/config.js +72 -0
  11. package/commands/delete.d.ts +4 -0
  12. package/commands/delete.js +256 -0
  13. package/commands/deploy.d.ts +6 -0
  14. package/commands/deploy.js +209 -0
  15. package/commands/describe.d.ts +4 -0
  16. package/commands/describe.js +216 -0
  17. package/commands/exec.d.ts +4 -0
  18. package/commands/exec.js +145 -0
  19. package/commands/get.d.ts +4 -0
  20. package/commands/get.js +164 -0
  21. package/commands/logs.d.ts +4 -0
  22. package/commands/logs.js +110 -0
  23. package/commands/port-forward.d.ts +4 -0
  24. package/commands/port-forward.js +143 -0
  25. package/commands.d.ts +3 -0
  26. package/commands.js +93 -0
  27. package/config.d.ts +22 -0
  28. package/config.js +113 -0
  29. package/esm/commands/apply.js +133 -0
  30. package/esm/commands/cluster-info.js +21 -0
  31. package/esm/commands/config-handler.js +43 -0
  32. package/esm/commands/config.js +67 -0
  33. package/esm/commands/delete.js +218 -0
  34. package/esm/commands/deploy.js +207 -0
  35. package/esm/commands/describe.js +211 -0
  36. package/esm/commands/exec.js +140 -0
  37. package/esm/commands/get.js +159 -0
  38. package/esm/commands/logs.js +105 -0
  39. package/esm/commands/port-forward.js +138 -0
  40. package/esm/commands.js +86 -0
  41. package/esm/config.js +74 -0
  42. package/esm/index.js +19 -0
  43. package/esm/package.js +26 -0
  44. package/esm/utils.js +49 -0
  45. package/index.d.ts +3 -0
  46. package/index.js +22 -0
  47. package/package.d.ts +1 -0
  48. package/package.js +29 -0
  49. package/package.json +37 -61
  50. package/utils.d.ts +11 -0
  51. package/utils.js +58 -0
  52. package/main/client.js +0 -156
  53. package/main/index.js +0 -2598
  54. package/module/client.js +0 -129
  55. package/module/index.js +0 -2594
  56. package/src/client.ts +0 -156
  57. package/src/index.ts +0 -14187
  58. package/types/client.d.ts +0 -31
  59. package/types/index.d.ts +0 -11331
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022 Dan Lynch <pyramation@gmail.com>
3
+ Copyright (c) 2024 Dan Lynch <pyramation@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,65 +1,64 @@
1
- # KubernetesJS
1
+ # @kubernetesjs/cli
2
2
 
3
- KubernetesJS is a **fully-typed**, zero-dependency TypeScript library designed to simplify interactions with Kubernetes APIs. With comprehensive TypeScript support, it provides a strongly-typed interface that makes managing Kubernetes resources clear and predictable, ideal for TypeScript developers looking to integrate Kubernetes management into their applications.
3
+ <p align="center">
4
+ <img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"><br />
5
+ KubernetesJS CLI
6
+ </p>
4
7
 
5
- ## Features
8
+ ## install
6
9
 
7
- - **🔒 Fully Typed**: Complete TypeScript definitions for all functions and models for an enhanced development experience.
8
- - **🚀 Zero Dependencies**: Works out of the box without the need for additional installations.
9
- - **📡 Full Kubernetes API Coverage**: Supports all Kubernetes API endpoints with detailed TypeScript types.
10
- - **🌐 Cross-Platform**: Works with both Node.js and browser environments.
10
+ ```sh
11
+ npm install cli
12
+ ```
13
+ ## Table of contents
11
14
 
12
- ## Installation
15
+ - [cli](#cli)
16
+ - [Install](#install)
17
+ - [Table of contents](#table-of-contents)
18
+ - [Developing](#developing)
19
+ - [Credits](#credits)
13
20
 
14
- To install KubernetesJS, you can use npm or yarn:
21
+ ## Developing
15
22
 
16
- ```bash
17
- npm install kubernetesjs
18
- # or
19
- yarn add kubernetesjs
23
+ When first cloning the repo:
20
24
 
25
+ ```sh
26
+ yarn
27
+ # build the prod packages. When devs would like to navigate to the source code, this will only navigate from references to their definitions (.d.ts files) between packages.
28
+ yarn build
21
29
  ```
22
30
 
23
- ## Example (WIP)
24
-
25
- ```js
26
- import { KubernetesClient } from "kubernetesjs";
27
-
28
- const client = new KubernetesClient({
29
- restEndpoint: 'http://127.0.0.1:8001'
30
- });
31
-
32
- client.listCoreV1NamespacedPod({
33
- path: {
34
- namespace: 'default'
35
- },
36
- query: {
37
- // Add any necessary query parameters here
38
- }
39
- }).then(result => {
40
- if (result.items && result.items.length) {
41
- result.items.forEach(item => {
42
- console.log('NODE:', item.spec.nodeName);
43
-
44
- const initContainers = item.status.initContainerStatuses?.map(ic => ({
45
- image: ic.image,
46
- name: ic.name,
47
- ready: ic.ready,
48
- state: ic.state
49
- }));
50
-
51
- const containers = item.status.containerStatuses?.map(c => ({
52
- image: c.image,
53
- name: c.name,
54
- ready: c.ready,
55
- state: c.state
56
- }));
57
-
58
- console.log({ containers });
59
- console.log({ initContainers });
60
- });
61
- }
62
- }).catch(reason => {
63
- console.error('Failed to fetch pods:', reason);
64
- });
31
+ Or if you want to make your dev process smoother, you can run:
32
+
33
+ ```sh
34
+ yarn
35
+ # build the dev packages with .map files, this enables navigation from references to their source code between packages.
36
+ yarn build:dev
65
37
  ```
38
+
39
+ ## Interchain JavaScript Stack
40
+
41
+ A unified toolkit for building applications and smart contracts in the Interchain ecosystem ⚛️
42
+
43
+ | Category | Tools | Description |
44
+ |----------------------|------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
45
+ | **Chain Information** | [**Chain Registry**](https://github.com/hyperweb-io/chain-registry), [**Utils**](https://www.npmjs.com/package/@chain-registry/utils), [**Client**](https://www.npmjs.com/package/@chain-registry/client) | Everything from token symbols, logos, and IBC denominations for all assets you want to support in your application. |
46
+ | **Wallet Connectors**| [**Interchain Kit**](https://github.com/hyperweb-io/interchain-kit)<sup>beta</sup>, [**Cosmos Kit**](https://github.com/hyperweb-io/cosmos-kit) | Experience the convenience of connecting with a variety of web3 wallets through a single, streamlined interface. |
47
+ | **Signing Clients** | [**InterchainJS**](https://github.com/hyperweb-io/interchainjs)<sup>beta</sup>, [**CosmJS**](https://github.com/cosmos/cosmjs) | A single, universal signing interface for any network |
48
+ | **SDK Clients** | [**Telescope**](https://github.com/hyperweb-io/telescope) | Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules. |
49
+ | **Starter Kits** | [**Create Interchain App**](https://github.com/hyperweb-io/create-interchain-app)<sup>beta</sup>, [**Create Cosmos App**](https://github.com/hyperweb-io/create-cosmos-app) | Set up a modern Interchain app by running one command. |
50
+ | **UI Kits** | [**Interchain UI**](https://github.com/hyperweb-io/interchain-ui) | The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit. |
51
+ | **Testing Frameworks** | [**Starship**](https://github.com/hyperweb-io/starship) | Unified Testing and Development for the Interchain. |
52
+ | **TypeScript Smart Contracts** | [**Create Hyperweb App**](https://github.com/hyperweb-io/create-hyperweb-app) | Build and deploy full-stack blockchain applications with TypeScript |
53
+ | **CosmWasm Contracts** | [**CosmWasm TS Codegen**](https://github.com/CosmWasm/ts-codegen) | Convert your CosmWasm smart contracts into dev-friendly TypeScript classes. |
54
+
55
+ ## Credits
56
+
57
+ 🛠 Built by Hyperweb (formerly Cosmology) — if you like our tools, please checkout and contribute to [our github ⚛️](https://github.com/hyperweb-io)
58
+
59
+
60
+ ## Disclaimer
61
+
62
+ AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
63
+
64
+ No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
@@ -0,0 +1,4 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ declare const _default: (argv: Partial<ParsedArgs>, prompter: Inquirerer, _options: CLIOptions) => Promise<void>;
4
+ export default _default;
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const chalk_1 = __importDefault(require("chalk"));
40
+ const kubernetesjs_1 = require("kubernetesjs");
41
+ const config_1 = require("../config");
42
+ const fs = __importStar(require("fs"));
43
+ async function promptYamlFilePath(prompter, argv) {
44
+ const question = {
45
+ type: 'text',
46
+ name: 'filePath',
47
+ message: 'Enter path to YAML file',
48
+ required: true
49
+ };
50
+ const { filePath } = await prompter.prompt(argv, [question]);
51
+ return filePath;
52
+ }
53
+ async function applyResource(client, resource, namespace) {
54
+ const kind = resource.kind.toLowerCase();
55
+ const name = resource.metadata?.name;
56
+ if (!name) {
57
+ throw new Error('Resource must have a name');
58
+ }
59
+ console.log(chalk_1.default.blue(`Applying ${kind} "${name}" in namespace ${namespace}...`));
60
+ try {
61
+ switch (kind) {
62
+ case 'deployment':
63
+ await client.createAppsV1NamespacedDeployment({
64
+ path: { namespace },
65
+ query: {
66
+ pretty: 'true',
67
+ fieldManager: 'kubernetesjs-cli'
68
+ },
69
+ body: resource
70
+ });
71
+ console.log(chalk_1.default.green(`Deployment "${name}" created/updated successfully`));
72
+ break;
73
+ case 'service':
74
+ await client.createCoreV1NamespacedService({
75
+ path: { namespace },
76
+ query: {
77
+ pretty: 'true',
78
+ fieldManager: 'kubernetesjs-cli'
79
+ },
80
+ body: resource
81
+ });
82
+ console.log(chalk_1.default.green(`Service "${name}" created/updated successfully`));
83
+ break;
84
+ case 'pod':
85
+ await client.createCoreV1NamespacedPod({
86
+ path: { namespace },
87
+ query: {
88
+ pretty: 'true',
89
+ fieldManager: 'kubernetesjs-cli'
90
+ },
91
+ body: resource
92
+ });
93
+ console.log(chalk_1.default.green(`Pod "${name}" created/updated successfully`));
94
+ break;
95
+ case 'configmap':
96
+ await client.createCoreV1NamespacedConfigMap({
97
+ path: { namespace },
98
+ query: {
99
+ pretty: 'true',
100
+ fieldManager: 'kubernetesjs-cli'
101
+ },
102
+ body: resource
103
+ });
104
+ console.log(chalk_1.default.green(`ConfigMap "${name}" created/updated successfully`));
105
+ break;
106
+ case 'secret':
107
+ await client.createCoreV1NamespacedSecret({
108
+ path: { namespace },
109
+ query: {
110
+ pretty: 'true',
111
+ fieldManager: 'kubernetesjs-cli'
112
+ },
113
+ body: resource
114
+ });
115
+ console.log(chalk_1.default.green(`Secret "${name}" created/updated successfully`));
116
+ break;
117
+ default:
118
+ console.log(chalk_1.default.yellow(`Resource kind "${kind}" not implemented yet`));
119
+ }
120
+ }
121
+ catch (error) {
122
+ console.error(chalk_1.default.red(`Error applying ${kind} "${name}": ${error}`));
123
+ throw error;
124
+ }
125
+ }
126
+ exports.default = async (argv, prompter, _options) => {
127
+ try {
128
+ const client = new kubernetesjs_1.KubernetesClient({
129
+ restEndpoint: argv.clientUrl
130
+ });
131
+ const filePath = argv.f || argv._?.[0] || await promptYamlFilePath(prompter, argv);
132
+ if (!filePath) {
133
+ console.error(chalk_1.default.red('No file path provided'));
134
+ return;
135
+ }
136
+ if (!fs.existsSync(filePath)) {
137
+ console.error(chalk_1.default.red(`File not found: ${filePath}`));
138
+ return;
139
+ }
140
+ let resources;
141
+ try {
142
+ const content = (0, config_1.readYamlFile)(filePath);
143
+ if (Array.isArray(content)) {
144
+ resources = content;
145
+ }
146
+ else if (content.kind === 'List' && Array.isArray(content.items)) {
147
+ resources = content.items;
148
+ }
149
+ else {
150
+ resources = [content];
151
+ }
152
+ }
153
+ catch (error) {
154
+ console.error(chalk_1.default.red(`Error parsing YAML file: ${error}`));
155
+ return;
156
+ }
157
+ for (const resource of resources) {
158
+ try {
159
+ const namespace = resource.metadata?.namespace || argv.n || argv.namespace || 'default';
160
+ await applyResource(client, resource, namespace);
161
+ }
162
+ catch (error) {
163
+ console.error(chalk_1.default.red(`Failed to apply resource: ${error}`));
164
+ }
165
+ }
166
+ console.log(chalk_1.default.green('Apply completed'));
167
+ }
168
+ catch (error) {
169
+ console.error(chalk_1.default.red(`Error: ${error}`));
170
+ }
171
+ };
@@ -0,0 +1,4 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ declare const _default: (_argv: Partial<ParsedArgs>, _prompter: Inquirerer, _options: CLIOptions) => Promise<void>;
4
+ export default _default;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const chalk_1 = __importDefault(require("chalk"));
7
+ const kubernetesjs_1 = require("kubernetesjs");
8
+ exports.default = async (_argv, _prompter, _options) => {
9
+ try {
10
+ const client = new kubernetesjs_1.KubernetesClient({
11
+ restEndpoint: _argv.clientUrl
12
+ });
13
+ console.log(chalk_1.default.blue('Kubernetes cluster info:'));
14
+ const apiVersions = await client.getAPIVersions({
15
+ params: {},
16
+ query: {}
17
+ });
18
+ console.log(chalk_1.default.bold('\nAPI Versions:'));
19
+ if (apiVersions.apiVersion) {
20
+ console.log(apiVersions.apiVersion);
21
+ }
22
+ }
23
+ catch (error) {
24
+ console.error(chalk_1.default.red(`Error: ${error}`));
25
+ }
26
+ };
@@ -0,0 +1,11 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ /**
4
+ * Handle the --config flag by parsing the YAML file and executing the appropriate command
5
+ * @param argv Command line arguments
6
+ * @param prompter Inquirerer instance
7
+ * @param options CLI options
8
+ * @param commandMap Map of available commands
9
+ */
10
+ declare const _default: (argv: Partial<ParsedArgs>, prompter: Inquirerer, options: CLIOptions, commandMap: Record<string, Function>) => Promise<boolean>;
11
+ export default _default;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const chalk_1 = __importDefault(require("chalk"));
40
+ const fs = __importStar(require("fs"));
41
+ const config_1 = require("../config");
42
+ /**
43
+ * Handle the --config flag by parsing the YAML file and executing the appropriate command
44
+ * @param argv Command line arguments
45
+ * @param prompter Inquirerer instance
46
+ * @param options CLI options
47
+ * @param commandMap Map of available commands
48
+ */
49
+ exports.default = async (argv, prompter, options, commandMap) => {
50
+ if (!argv.config) {
51
+ return false;
52
+ }
53
+ const configPath = argv.config;
54
+ if (!fs.existsSync(configPath)) {
55
+ console.error(chalk_1.default.red(`Config file not found: ${configPath}`));
56
+ return true;
57
+ }
58
+ try {
59
+ const resource = (0, config_1.readYamlFile)(configPath);
60
+ const resourceType = (0, config_1.inferResourceType)(resource);
61
+ console.log(chalk_1.default.blue(`Detected resource type: ${resourceType}`));
62
+ let command;
63
+ command = 'apply';
64
+ const newArgv = {
65
+ ...argv,
66
+ _: [configPath],
67
+ f: configPath
68
+ };
69
+ if (commandMap[command]) {
70
+ await commandMap[command](newArgv, prompter, options);
71
+ }
72
+ else {
73
+ console.error(chalk_1.default.red(`No command found for resource type: ${resourceType}`));
74
+ }
75
+ return true;
76
+ }
77
+ catch (error) {
78
+ console.error(chalk_1.default.red(`Error processing config file: ${error}`));
79
+ return true;
80
+ }
81
+ };
@@ -0,0 +1,4 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ declare const _default: (argv: Partial<ParsedArgs>, prompter: Inquirerer, _options: CLIOptions) => Promise<void>;
4
+ export default _default;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const chalk_1 = __importDefault(require("chalk"));
7
+ const kubernetesjs_1 = require("kubernetesjs");
8
+ const config_1 = require("../config");
9
+ async function promptNamespace(prompter, argv, client) {
10
+ try {
11
+ const namespaces = await client.listCoreV1Namespace({
12
+ query: {}
13
+ });
14
+ if (!namespaces.items || namespaces.items.length === 0) {
15
+ console.log(chalk_1.default.yellow('No namespaces found'));
16
+ return '';
17
+ }
18
+ const options = namespaces.items.map(ns => ({
19
+ name: ns.metadata.name,
20
+ value: ns.metadata.name
21
+ }));
22
+ const question = {
23
+ type: 'autocomplete',
24
+ name: 'namespace',
25
+ message: 'Select namespace',
26
+ options,
27
+ maxDisplayLines: 10,
28
+ required: true
29
+ };
30
+ const { namespace } = await prompter.prompt(argv, [question]);
31
+ return namespace;
32
+ }
33
+ catch (error) {
34
+ console.error(chalk_1.default.red(`Error getting namespaces: ${error}`));
35
+ return '';
36
+ }
37
+ }
38
+ exports.default = async (argv, prompter, _options) => {
39
+ try {
40
+ const client = new kubernetesjs_1.KubernetesClient({
41
+ restEndpoint: argv.clientUrl
42
+ });
43
+ const subcommand = argv._?.[0];
44
+ if (subcommand === 'get-context') {
45
+ const namespace = (0, config_1.getCurrentNamespace)();
46
+ console.log(chalk_1.default.green(`Current namespace: ${namespace}`));
47
+ return;
48
+ }
49
+ if (subcommand === 'set-context') {
50
+ if (argv.current !== true) {
51
+ console.error(chalk_1.default.red('Missing --current flag'));
52
+ return;
53
+ }
54
+ let namespace = argv.namespace;
55
+ if (!namespace) {
56
+ namespace = await promptNamespace(prompter, argv, client);
57
+ if (!namespace) {
58
+ return;
59
+ }
60
+ }
61
+ (0, config_1.setCurrentNamespace)(namespace);
62
+ console.log(chalk_1.default.green(`Namespace set to "${namespace}"`));
63
+ return;
64
+ }
65
+ console.log(chalk_1.default.blue('Available config commands:'));
66
+ console.log(' get-context Display the current context');
67
+ console.log(' set-context --current --namespace=<namespace> Set the current namespace');
68
+ }
69
+ catch (error) {
70
+ console.error(chalk_1.default.red(`Error: ${error}`));
71
+ }
72
+ };
@@ -0,0 +1,4 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ declare const _default: (argv: Partial<ParsedArgs>, prompter: Inquirerer, _options: CLIOptions) => Promise<void>;
4
+ export default _default;