@serve.zone/cli 4.1.2 → 4.1.3

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 (3) hide show
  1. package/license +19 -0
  2. package/package.json +1 -1
  3. package/readme.md +262 -0
package/license ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Task Venture Capital GmbH (hello@task.vc)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serve.zone/cli",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "exports": {
package/readme.md ADDED
@@ -0,0 +1,262 @@
1
+ # @serve.zone/cli
2
+
3
+ A comprehensive command-line interface (CLI) tool for managing multi-cloud environments, leveraging the features of the @serve.zone/cloudly platform. This CLI is crafted to facilitate seamless interactions with complex cloud configurations and deployments, utilizing Docker Swarmkit orchestration.
4
+
5
+ ## Install
6
+
7
+ To begin using the `@serve.zone/cli` in your projects, install it via npm by running:
8
+
9
+ ```bash
10
+ npm install @serve.zone/cli --save
11
+ ```
12
+
13
+ This command will download the package and integrate it into your project's `node_modules` directory, reflecting the dependency in your `package.json`.
14
+
15
+ ## Usage
16
+
17
+ The `@serve.zone/cli` is a powerful command-line tool aimed at developers and system administrators who are managing containerized applications across various cloud platforms. Through this CLI, users can interact with their cloud infrastructure efficiently, enabling and extending `Cloudly’s` capabilities directly from the terminal.
18
+
19
+ ### Prerequisites
20
+
21
+ Before proceeding to use the `@serve.zone/cli`, ensure your system meets the following prerequisites:
22
+ - Latest Node.js LTS version installed.
23
+ - Familiarity with basic command-line operations.
24
+ - Properly configured cloud service accounts (like Cloudflare, Hetzner), necessary for managing respective services.
25
+
26
+ ### Setting Up the CLI
27
+
28
+ Begin setting up the `Cloudly` instance for CLI usage:
29
+ ```typescript
30
+ // Import required modules
31
+ import { Cloudly } from '@serve.zone/cloudly';
32
+ import * as path from 'path';
33
+
34
+ // Define the configuration needed for cloud operations
35
+ const cloudlyConfig = {
36
+ cfToken: 'your-cloudflare-token',
37
+ hetznerToken: 'your-hetzner-token',
38
+ environment: 'production',
39
+ publicUrl: 'your-public-url',
40
+ };
41
+
42
+ // Instantiate and start the Cloudly instance
43
+ const cloudlyInstance = new Cloudly(cloudlyConfig);
44
+ await cloudlyInstance.start();
45
+
46
+ // Log the setup information to ensure it’s correct
47
+ console.log(`Cloudly is set up at ${cloudlyInstance.config.data.publicUrl}`);
48
+ ```
49
+
50
+ This snippet initializes a Cloudly instance with necessary environment configuration, setting the groundwork for all subsequent CLI operations.
51
+
52
+ ### Core Operations with the CLI
53
+
54
+ Here's how you leverage various operational commands within the CLI feature:
55
+
56
+ #### Managing Clusters
57
+
58
+ To create, list, and delete clusters, you’ll require invoking the `Cloudly` class with its cluster management logic:
59
+
60
+ ```typescript
61
+ // Module imports
62
+ import { Cloudly } from '@serve.zone/cloudly';
63
+
64
+ // Async function for cluster management
65
+ async function manageCluster() {
66
+ // Prepare configuration
67
+ const config = {
68
+ cfToken: 'YOUR_CLOUDFLARE_TOKEN',
69
+ hetznerToken: 'YOUR_HETZNER_TOKEN',
70
+ };
71
+
72
+ // Initialize Cloudly
73
+ const cloudlyInstance = new Cloudly(config);
74
+ await cloudlyInstance.start();
75
+
76
+ // Example: Creating a new cluster
77
+ const cluster = await cloudlyInstance.clusterManager.createCluster({
78
+ id: 'example_cluster_id',
79
+ data: {
80
+ name: 'example_cluster',
81
+ servers: [],
82
+ sshKeys: [],
83
+ }
84
+ });
85
+
86
+ // Log cluster details
87
+ console.log('Cluster created:', cluster);
88
+ }
89
+ ```
90
+ With the above example, you can dynamically manage cluster configurations, ensuring your application components are effectively orchestrated across cloud environments.
91
+
92
+ #### Deploying Services
93
+
94
+ Deploying cloud-native services within your clusters can be achieved through the CLI:
95
+
96
+ ```typescript
97
+ import { Cloudly } from '@serve.zone/cloudly';
98
+
99
+ // Function to handle service deployment
100
+ async function deployService() {
101
+ const config = {
102
+ cfToken: 'YOUR_CLOUDFLARE_TOKEN',
103
+ hetznerToken: 'YOUR_HETZNER_TOKEN',
104
+ };
105
+
106
+ const cloudlyInstance = new Cloudly(config);
107
+ await cloudlyInstance.start();
108
+
109
+ // Deploy a new service to a specified cluster
110
+ const newService = {
111
+ id: 'example_service_id',
112
+ data: {
113
+ name: 'example_service',
114
+ imageId: 'example_image_id',
115
+ imageVersion: '1.0.0',
116
+ environment: {},
117
+ ports: { web: 80 }
118
+ }
119
+ };
120
+
121
+ // Store service into database and deploy
122
+ console.log('Deploying service:', newService)
123
+ await cloudlyInstance.serverManager.deployService(newService);
124
+ }
125
+
126
+ deployService();
127
+ ```
128
+
129
+ By streamlining your service deployments through CLI, you ensure reproducibility and clarity in development operations.
130
+
131
+ #### Managing Certificates
132
+
133
+ Ensuring secure connections by managing SSL certificates is essential. The CLI aids in this through Let's Encrypt integration:
134
+
135
+ ```typescript
136
+ import { Cloudly } from '@serve.zone/cloudly';
137
+
138
+ // Function to acquire a certificate
139
+ async function getCertificate() {
140
+ const config = {
141
+ cfToken: 'YOUR_CLOUDFLARE_TOKEN',
142
+ hetznerToken: 'YOUR_HETZNER_TOKEN',
143
+ };
144
+
145
+ const cloudlyInstance = new Cloudly(config);
146
+ await cloudlyInstance.start();
147
+
148
+ // Fetch certificate using Let's Encrypt
149
+ const domainName = 'example.com';
150
+ const cert = await cloudlyInstance.letsencryptConnector.getCertificateForDomain(domainName);
151
+ console.log(`Obtained certificate for domain ${domainName}:`, cert);
152
+ }
153
+
154
+ getCertificate();
155
+ ```
156
+
157
+ This process facilitates the automation of SSL certificates provisioning, ensuring high security in your apps.
158
+
159
+ ### Automating Tasks with the CLI
160
+
161
+ Task scheduling is a feature you can utilize to automate recurring processes. Here’s an example of how `@serve.zone/cli` accomplishes task scheduling:
162
+
163
+ ```typescript
164
+ import { TaskBuffer } from '@push.rocks/taskbuffer';
165
+
166
+ // Schedule a task to run every day
167
+ const dailyTask = new TaskBuffer({
168
+ schedule: '0 0 * * *', // Using cron schedule
169
+ taskFunction: async () => {
170
+ console.log('Performing daily backup check...');
171
+ // Include backup logic here
172
+ },
173
+ });
174
+
175
+ // Initiate task scheduling
176
+ dailyTask.start();
177
+ ```
178
+
179
+ Scheduled tasks like periodic maintenance, data synchronization, or backups ensure you keep your cloud environment robust and reliable.
180
+
181
+ ### Integrating Third-Party APIs
182
+
183
+ Expand the scope of your applications with API integrations offered via `@serve.zone/cli`:
184
+
185
+ ```typescript
186
+ import { Cloudly } from '@serve.zone/cloudly';
187
+
188
+ // Function to send notifications
189
+ async function sendNotification() {
190
+ const cloudlyConfig = {
191
+ cfToken: 'your-cloudflare-token',
192
+ hetznerToken: 'your-hetzner-token',
193
+ };
194
+
195
+ const cloudly = new Cloudly(cloudlyConfig);
196
+ await cloudly.start();
197
+
198
+ // Configure and send push notification
199
+ await cloudly.externalApiManager.sendPushMessage({
200
+ deviceToken: 'some_device_token',
201
+ message: 'Hello from Cloudly!',
202
+ });
203
+ }
204
+
205
+ sendNotification();
206
+ ```
207
+
208
+ API integrations via the CLI extend Cloudly’s reach, enabling comprehensive service interconnections.
209
+
210
+ ### Security and Access Management
211
+
212
+ Effective identity management is possible through `@serve.zone/cli`. Manage user roles, token validations, and more:
213
+
214
+ ```typescript
215
+ import { Cloudly } from '@serve.zone/cloudly';
216
+
217
+ // Configuring and verifying identity
218
+ async function authenticateUser() {
219
+ const cloudlyConfig = {
220
+ cfToken: 'your-cloudflare-token',
221
+ hetznerToken: 'your-hetzner-token',
222
+ };
223
+
224
+ const cloudly = new Cloudly(cloudlyConfig);
225
+ await cloudly.start();
226
+
227
+ // Sample user credentials
228
+ const userIdentity = {
229
+ userId: 'unique_user_id',
230
+ jwt: 'user_jwt_token',
231
+ };
232
+
233
+ // Validate identity
234
+ const isValid = cloudly.authManager.validateIdentity(userIdentity);
235
+ console.log(`Is user identity valid? ${isValid}`);
236
+ }
237
+
238
+ authenticateUser();
239
+ ```
240
+
241
+ The applications of identity validation streamline operational security and enforce access controls across your systems.
242
+
243
+ These examples offer a glimpse into the vast potential of @serve.zone/cli, which combines automation, security, and flexibility for state-of-the-art cloud management. You are encouraged to build upon this documentation to harness Cloudly's full capabilities in your infrastructure and process ecosystems. Let the CLI transform your cloud management experience with precision and adaptability.
244
+
245
+ ## License and Legal Information
246
+
247
+ This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
248
+
249
+ **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
250
+
251
+ ### Trademarks
252
+
253
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
254
+
255
+ ### Company Information
256
+
257
+ Task Venture Capital GmbH
258
+ Registered at District court Bremen HRB 35230 HB, Germany
259
+
260
+ For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
261
+
262
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.