puter-cli 1.0.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.
- package/.idx/dev.nix +53 -0
- package/LICENSE.md +209 -0
- package/README.md +292 -0
- package/bin/index.js +38 -0
- package/commands/apps.js +421 -0
- package/commands/auth.js +233 -0
- package/commands/commons.js +296 -0
- package/commands/executor.js +306 -0
- package/commands/files.js +1290 -0
- package/commands/init.js +67 -0
- package/commands/shell.js +56 -0
- package/commands/sites.js +214 -0
- package/commands/subdomains.js +103 -0
- package/commands/utils.js +92 -0
- package/package.json +37 -0
- package/tests/login.test.js +268 -0
package/.idx/dev.nix
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# To learn more about how to use Nix to configure your environment
|
|
2
|
+
# see: https://developers.google.com/idx/guides/customize-idx-env
|
|
3
|
+
{ pkgs, ... }: {
|
|
4
|
+
# Which nixpkgs channel to use.
|
|
5
|
+
channel = "stable-24.05"; # or "unstable"
|
|
6
|
+
# Use https://search.nixos.org/packages to find packages
|
|
7
|
+
packages = [
|
|
8
|
+
# pkgs.go
|
|
9
|
+
# pkgs.python311
|
|
10
|
+
# pkgs.python311Packages.pip
|
|
11
|
+
pkgs.nodejs_20
|
|
12
|
+
pkgs.nodePackages.nodemon
|
|
13
|
+
];
|
|
14
|
+
# Sets environment variables in the workspace
|
|
15
|
+
env = {};
|
|
16
|
+
idx = {
|
|
17
|
+
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
|
|
18
|
+
extensions = [
|
|
19
|
+
# "vscodevim.vim"
|
|
20
|
+
];
|
|
21
|
+
# Enable previews
|
|
22
|
+
previews = {
|
|
23
|
+
enable = true;
|
|
24
|
+
previews = {
|
|
25
|
+
# web = {
|
|
26
|
+
# # Example: run "npm run dev" with PORT set to IDX's defined port for previews,
|
|
27
|
+
# # and show it in IDX's web preview panel
|
|
28
|
+
# command = ["npm" "run" "dev"];
|
|
29
|
+
# manager = "web";
|
|
30
|
+
# env = {
|
|
31
|
+
# # Environment variables to set for your server
|
|
32
|
+
# PORT = "$PORT";
|
|
33
|
+
# };
|
|
34
|
+
# };
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
# Workspace lifecycle hooks
|
|
38
|
+
workspace = {
|
|
39
|
+
# Runs when a workspace is first created
|
|
40
|
+
onCreate = {
|
|
41
|
+
# Example: install JS dependencies from NPM
|
|
42
|
+
# npm-install = "npm install";
|
|
43
|
+
# Open editors for the following files by default, if they exist:
|
|
44
|
+
default.openFiles = [ ".idx/dev.nix" "README.md" ];
|
|
45
|
+
};
|
|
46
|
+
# Runs when the workspace is (re)started
|
|
47
|
+
onStart = {
|
|
48
|
+
# Example: start a background task to watch and re-build backend code
|
|
49
|
+
# watch-backend = "npm run watch-backend";
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Do No Harm License
|
|
2
|
+
|
|
3
|
+
## 1. Preamble
|
|
4
|
+
|
|
5
|
+
Most software today is developed with little to no thought of how it will be used, or the
|
|
6
|
+
consequences for our society and planet.
|
|
7
|
+
|
|
8
|
+
As software developers, we engineer the infrastructure of the 21st century. We recognise that our
|
|
9
|
+
infrastructure has great power to shape the world and the lives of those we share it with, and we
|
|
10
|
+
choose to consciously take responsibility for the social and environmental impacts of what we build.
|
|
11
|
+
|
|
12
|
+
We envisage a world free from injustice, inequality, and the reckless destruction of lives and our
|
|
13
|
+
planet. We reject slavery in all its forms, whether by force, indebtedness, or by algorithms that
|
|
14
|
+
hack human vulnerabilities. We seek a world where humankind is at peace with our neighbours, nature,
|
|
15
|
+
and ourselves. We want our work to enrich the physical, mental and spiritual wellbeing of all
|
|
16
|
+
society.
|
|
17
|
+
|
|
18
|
+
We build software to further this vision of a just world, or at the very least, to not put that
|
|
19
|
+
vision further from reach.
|
|
20
|
+
|
|
21
|
+
## 2. Definitions
|
|
22
|
+
|
|
23
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by
|
|
24
|
+
Sections 1 through 9 of this document.
|
|
25
|
+
|
|
26
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is
|
|
27
|
+
granting the License.
|
|
28
|
+
|
|
29
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are
|
|
30
|
+
controlled by, or are under common control with that entity. For the purposes of this definition,
|
|
31
|
+
"control" means (i) the power, direct or indirect, to cause the direction or management of such
|
|
32
|
+
entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
33
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
34
|
+
|
|
35
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this
|
|
36
|
+
License.
|
|
37
|
+
|
|
38
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to
|
|
39
|
+
software source code, documentation source, and configuration files.
|
|
40
|
+
|
|
41
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a
|
|
42
|
+
Source form, including but not limited to compiled object code, generated documentation, and
|
|
43
|
+
conversions to other media types.
|
|
44
|
+
|
|
45
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the
|
|
46
|
+
License, as indicated by a copyright notice that is included in or attached to the work (an example
|
|
47
|
+
is provided in the Appendix below).
|
|
48
|
+
|
|
49
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or
|
|
50
|
+
derived from) the Work and for which the editorial revisions, annotations, elaborations, or other
|
|
51
|
+
modifications represent, as a whole, an original work of authorship. For the purposes of this
|
|
52
|
+
License, Derivative Works shall not include works that remain separable from, or merely link (or
|
|
53
|
+
bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
54
|
+
|
|
55
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any
|
|
56
|
+
modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted
|
|
57
|
+
to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity
|
|
58
|
+
authorized to submit on behalf of the copyright owner. For the purposes of this definition,
|
|
59
|
+
"submitted" means any form of electronic, verbal, or written communication sent to the Licensor or
|
|
60
|
+
its representatives, including but not limited to communication on electronic mailing lists, source
|
|
61
|
+
code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor
|
|
62
|
+
for the purpose of discussing and improving the Work, but excluding communication that is
|
|
63
|
+
conspicuously marked or otherwise designated in writing by the copyright owner as "Not a
|
|
64
|
+
Contribution."
|
|
65
|
+
|
|
66
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a
|
|
67
|
+
Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
68
|
+
|
|
69
|
+
"Forests" shall mean 0.5 or more hectares of trees that were either planted more than 50 years ago
|
|
70
|
+
or were not planted by humans or human made equipment.
|
|
71
|
+
|
|
72
|
+
"Deforestation" shall mean the clearing, burning or destruction of 0.5 or more hectares of forests
|
|
73
|
+
within a 1 year period.
|
|
74
|
+
|
|
75
|
+
## 3. Grant of Copyright License
|
|
76
|
+
|
|
77
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
|
78
|
+
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
79
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and
|
|
80
|
+
distribute the Work and such Derivative Works in Source or Object form.
|
|
81
|
+
|
|
82
|
+
## 4. Grant of Patent License
|
|
83
|
+
|
|
84
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
|
85
|
+
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
|
86
|
+
section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer
|
|
87
|
+
the Work, where such license applies only to those patent claims licensable by such Contributor that
|
|
88
|
+
are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s)
|
|
89
|
+
with the Work to which such Contribution(s) was submitted. If You institute patent litigation
|
|
90
|
+
against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or
|
|
91
|
+
a Contribution incorporated within the Work constitutes direct or contributory patent infringement,
|
|
92
|
+
then any patent licenses granted to You under this License for that Work shall terminate as of the
|
|
93
|
+
date such litigation is filed.
|
|
94
|
+
|
|
95
|
+
## 5. Redistribution
|
|
96
|
+
|
|
97
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
|
|
98
|
+
or without modifications, and in Source or Object form, provided that You meet the following
|
|
99
|
+
conditions:
|
|
100
|
+
|
|
101
|
+
1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
102
|
+
|
|
103
|
+
2. You must cause any modified files to carry prominent notices stating that You changed the
|
|
104
|
+
files; and
|
|
105
|
+
|
|
106
|
+
3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
|
|
107
|
+
patent, trademark, and attribution notices from the Source form of the Work, excluding those
|
|
108
|
+
notices that do not pertain to any part of the Derivative Works; and
|
|
109
|
+
|
|
110
|
+
4. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
|
|
111
|
+
or promote products derived from this software without specific prior written permission; and
|
|
112
|
+
|
|
113
|
+
5. This software must not be used by any organisation, website, product, or service that:
|
|
114
|
+
1. promotes, lobbies for or derives a majority of income from:
|
|
115
|
+
1. **abuses of human rights**:
|
|
116
|
+
* human trafficking
|
|
117
|
+
* sex trafficking
|
|
118
|
+
* slavery or indentured servitude
|
|
119
|
+
* discrimination based on age, gender, gender identity, race, sexuality, religion, nationality
|
|
120
|
+
* hate speech
|
|
121
|
+
2. **environmental destruction**:
|
|
122
|
+
* the extraction or sale of fossil fuels
|
|
123
|
+
* the destruction of habitats for threatened or endangered species, including through deforestation or burning of forests
|
|
124
|
+
* the abuse, inhumane killing or neglect of animals under human control
|
|
125
|
+
* industrial processes that generate waste products that threaten life
|
|
126
|
+
3. **conflict and war**:
|
|
127
|
+
* warfare
|
|
128
|
+
* war crimes
|
|
129
|
+
* weapons manufacturing
|
|
130
|
+
* violence (except when required to protect public safety)
|
|
131
|
+
4. **addictive or destructive products and services**:
|
|
132
|
+
* gambling
|
|
133
|
+
* tobacco
|
|
134
|
+
* products that encourage adversely addictive behaviours
|
|
135
|
+
|
|
136
|
+
2. dissuades, lobbies against, or derives a majority of income from actions that discourage or frustrate:
|
|
137
|
+
* peace
|
|
138
|
+
* access to the rights set out in the [Universal Declaration of Human Rights](./documents/UDHR.md) and the [Convention on the Rights of the Child](./documents/CRC.md)
|
|
139
|
+
* democratic processes
|
|
140
|
+
* peaceful assembly and association (including worker associations)
|
|
141
|
+
* a sustainable environment
|
|
142
|
+
; and
|
|
143
|
+
|
|
144
|
+
5. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative
|
|
145
|
+
Works that You distribute must include a readable copy of the attribution notices contained
|
|
146
|
+
within such NOTICE file, excluding those notices that do not pertain to any part of the
|
|
147
|
+
Derivative Works, in at least one of the following places: within a NOTICE text file
|
|
148
|
+
distributed as part of the Derivative Works; within the Source form or documentation, if
|
|
149
|
+
provided along with the Derivative Works; or, within a display generated by the Derivative
|
|
150
|
+
Works, if and wherever such third-party notices normally appear. The contents of the NOTICE
|
|
151
|
+
file are for informational purposes only and do not modify the License. You may add Your own
|
|
152
|
+
attribution notices within Derivative Works that You distribute, alongside or as an addendum to
|
|
153
|
+
the NOTICE text from the Work, provided that such additional attribution notices cannot be
|
|
154
|
+
construed as modifying the License.
|
|
155
|
+
|
|
156
|
+
You may add Your own copyright statement to Your modifications and may provide additional or
|
|
157
|
+
different license terms and conditions for use, reproduction, or distribution of Your modifications,
|
|
158
|
+
or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of
|
|
159
|
+
the Work otherwise complies with the conditions stated in this License.
|
|
160
|
+
|
|
161
|
+
## 6. Submission of Contributions
|
|
162
|
+
|
|
163
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
|
|
164
|
+
Work by You to the Licensor shall be under the terms and conditions of this License, without any
|
|
165
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify
|
|
166
|
+
the terms of any separate license agreement you may have executed with Licensor regarding such
|
|
167
|
+
Contributions.
|
|
168
|
+
|
|
169
|
+
## 7. Trademarks
|
|
170
|
+
|
|
171
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product
|
|
172
|
+
names of the Licensor, except as required for reasonable and customary use in describing the origin
|
|
173
|
+
of the Work and reproducing the content of the NOTICE file.
|
|
174
|
+
|
|
175
|
+
## 8. Disclaimer of Warranty
|
|
176
|
+
|
|
177
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
|
|
178
|
+
Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
179
|
+
KIND, either express or implied, including, without limitation, any warranties or conditions of
|
|
180
|
+
TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
|
|
181
|
+
responsible for determining the appropriateness of using or redistributing the Work and assume any
|
|
182
|
+
risks associated with Your exercise of permissions under this License.
|
|
183
|
+
|
|
184
|
+
## 9. Limitation of Liability
|
|
185
|
+
|
|
186
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or
|
|
187
|
+
otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or
|
|
188
|
+
agreed to in writing, shall any Contributor be liable to You for damages, including any direct,
|
|
189
|
+
indirect, special, incidental, or consequential damages of any character arising as a result of this
|
|
190
|
+
License or out of the use or inability to use the Work (including but not limited to damages for
|
|
191
|
+
loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial
|
|
192
|
+
damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
193
|
+
|
|
194
|
+
## 10. Accepting Warranty or Additional Liability
|
|
195
|
+
|
|
196
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee
|
|
197
|
+
for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights
|
|
198
|
+
consistent with this License. However, in accepting such obligations, You may act only on Your own
|
|
199
|
+
behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You
|
|
200
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or
|
|
201
|
+
claims asserted against, such Contributor by reason of your accepting any such warranty or
|
|
202
|
+
additional liability.
|
|
203
|
+
|
|
204
|
+
## Attribution
|
|
205
|
+
|
|
206
|
+
Do No Harm License [Contributor Covenant][homepage], (pre 1.0),
|
|
207
|
+
available at https://github.com/raisely/NoHarm
|
|
208
|
+
|
|
209
|
+
[homepage]: https://github.com/raisely/NoHarm
|
package/README.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# Puter-CLI
|
|
2
|
+
|
|
3
|
+
The **Puter CLI** is a command-line interface tool designed to interact with the **Puter Cloud Platform**. It allows users to manage files, directories, applications, and other resources directly from the terminal. This tool is ideal for developers and power users who prefer working with command-line utilities.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **File Management**: Upload, download, list, and manage files and directories.
|
|
10
|
+
- **Authentication**: Log in and log out of your Puter account.
|
|
11
|
+
- **User Information**: Retrieve user details, such as username, email, and account status.
|
|
12
|
+
- **Disk Usage**: Check disk usage and storage limits.
|
|
13
|
+
- **Application Management**: Create, delete, and list applications hosted on Puter.
|
|
14
|
+
- **Static Site Hosting**: Deploy static websites from directories.
|
|
15
|
+
- **Interactive Shell**: Use an interactive shell for seamless command execution.
|
|
16
|
+
- **Cross-Platform**: Works on Windows, macOS, and Linux.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### Prerequisites
|
|
23
|
+
- Node.js (v16 or higher)
|
|
24
|
+
- npm (v7 or higher)
|
|
25
|
+
|
|
26
|
+
### Steps
|
|
27
|
+
1. Clone the repository:
|
|
28
|
+
```bash
|
|
29
|
+
git clone https://github.com/bitsnaps/puter-cli.git
|
|
30
|
+
cd puter-cli
|
|
31
|
+
```
|
|
32
|
+
2. Install dependencies:
|
|
33
|
+
```bash
|
|
34
|
+
npm install
|
|
35
|
+
```
|
|
36
|
+
3. Link the CLI globally:
|
|
37
|
+
```bash
|
|
38
|
+
npm link
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### Commands
|
|
46
|
+
|
|
47
|
+
#### Authentication
|
|
48
|
+
- **Login**: Log in to your Puter account.
|
|
49
|
+
```bash
|
|
50
|
+
puter login
|
|
51
|
+
```
|
|
52
|
+
- **Logout**: Log out of your Puter account.
|
|
53
|
+
```bash
|
|
54
|
+
puter logout
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### File Management
|
|
58
|
+
|
|
59
|
+
We've adopted the most basic popluar linux system command line for daily file manipulation with some extra features, not out of the box though, we want to keep it simple.
|
|
60
|
+
|
|
61
|
+
- **List Files**: List files and directories.
|
|
62
|
+
```bash
|
|
63
|
+
puter> ls [dir]
|
|
64
|
+
```
|
|
65
|
+
- **Change Directory**: Navigate to a directory:
|
|
66
|
+
```bash
|
|
67
|
+
puter> cd [dir]
|
|
68
|
+
```
|
|
69
|
+
It works with wildcards as you would expect in any OS for basic navigation with insensitive case: `cd ..`, `cd ../myapp`...etc.
|
|
70
|
+
|
|
71
|
+
- **Create Directory**: Create a new directory.
|
|
72
|
+
```bash
|
|
73
|
+
puter> mkdir <dir>
|
|
74
|
+
```
|
|
75
|
+
- **Copy Files**: Copy files or directories.
|
|
76
|
+
```bash
|
|
77
|
+
puter> cp <src> <dest>
|
|
78
|
+
```
|
|
79
|
+
- **Move Files**: Move or rename files or directories.
|
|
80
|
+
```bash
|
|
81
|
+
puter> mv <src> <dest>
|
|
82
|
+
```
|
|
83
|
+
- **Delete Files/Directories**: Move files or directories to the trash.
|
|
84
|
+
```bash
|
|
85
|
+
puter> rm [-f] <file>
|
|
86
|
+
```
|
|
87
|
+
- **Empty Trash**: Empty the system's trash.
|
|
88
|
+
```bash
|
|
89
|
+
puter> clean
|
|
90
|
+
```
|
|
91
|
+
##### Extra commands:
|
|
92
|
+
|
|
93
|
+
Think of it as `git [push|pull]` commands, they're basically simplified equivalents.
|
|
94
|
+
|
|
95
|
+
- **Push Files**: Copy files from host machine to the remote cloud instance.
|
|
96
|
+
```bash
|
|
97
|
+
puter> push <host_src>
|
|
98
|
+
```
|
|
99
|
+
- **Pull Files**: Copy files from remote cloud instance to the host machine.
|
|
100
|
+
```bash
|
|
101
|
+
puter> pull <remote_src>
|
|
102
|
+
```
|
|
103
|
+
P.S. These commands consider the current directory as the base path for every operation, basic wildcards are supported: e.g. `push myapp/*.html`.
|
|
104
|
+
|
|
105
|
+
#### User Information
|
|
106
|
+
- **Get User Info**: Display user information.
|
|
107
|
+
```bash
|
|
108
|
+
puter whoami
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Disk Usage
|
|
112
|
+
- **Check Disk Usage**: Display disk usage information.
|
|
113
|
+
```bash
|
|
114
|
+
puter df
|
|
115
|
+
```
|
|
116
|
+
- **Get Usage Info**: Fetch usage information for services.
|
|
117
|
+
```bash
|
|
118
|
+
puter usage
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Application Management
|
|
122
|
+
|
|
123
|
+
The **Application** are sepcial type of hosted web app, they're served from the special directory at: `<USERNAME>/AppData/<UUID>...`, more details at **app:create** in the section below.
|
|
124
|
+
|
|
125
|
+
- **List Applications**: List all applications.
|
|
126
|
+
```bash
|
|
127
|
+
puter apps [period]
|
|
128
|
+
```
|
|
129
|
+
P.S. Please check the help command `help apps` for more details about any argument.
|
|
130
|
+
|
|
131
|
+
- **Create Application**: Create a new application.
|
|
132
|
+
```bash
|
|
133
|
+
puter app:create <name> [<remote_dir>] [--description=<description>] [--url=<url>]
|
|
134
|
+
```
|
|
135
|
+
P.S. By default a new `index.html` with basic content will be created, but you can set a directory when you create a new application as follows: `app:create nameOfApp ./appDir`, so all files will be copied to the `AppData` directoy, you can then update your app using `app:update <name> <remote_dir>`. This command will attempt to create a subdomain with a random `uid` prefixed with the name of the app.
|
|
136
|
+
|
|
137
|
+
- **Update Application**: Update an application.
|
|
138
|
+
```bash
|
|
139
|
+
puter app:update <name> <remote_dir>
|
|
140
|
+
```
|
|
141
|
+
**IMPORTANT** All existing files will be overwritten, new files are copied, other files are just ignored.
|
|
142
|
+
|
|
143
|
+
- **Delete Application**: Delete an application.
|
|
144
|
+
```bash
|
|
145
|
+
puter app:delete [-f] <name>
|
|
146
|
+
```
|
|
147
|
+
P.S. This command will lookup for the allocated `subdomain` and attempt to delete it if it exists.
|
|
148
|
+
|
|
149
|
+
#### Static Sites
|
|
150
|
+
|
|
151
|
+
The static sites are served from the selected directory (or the current directory if none is specified).
|
|
152
|
+
|
|
153
|
+
- **Deploy Site**: Deploy a static website from a directory.
|
|
154
|
+
```bash
|
|
155
|
+
puter site:create <dir> [--subdomain=<name>]
|
|
156
|
+
```
|
|
157
|
+
P.S. If the subdomain already exists, it will generate a new random one can set your own subdomain using `--subdomain` argument.
|
|
158
|
+
|
|
159
|
+
- **List Sites**: List all hosted sites.
|
|
160
|
+
```bash
|
|
161
|
+
puter sites
|
|
162
|
+
```
|
|
163
|
+
- **Delete Site**: Delete a hosted site.
|
|
164
|
+
```bash
|
|
165
|
+
puter site:delete <uid>
|
|
166
|
+
```
|
|
167
|
+
P.S. You can find the `<uid>` in the list of `sites`.
|
|
168
|
+
|
|
169
|
+
#### Interactive Shell
|
|
170
|
+
- **Start Shell**: Launch an interactive shell.
|
|
171
|
+
```bash
|
|
172
|
+
puter [shell]
|
|
173
|
+
```
|
|
174
|
+
or just type (you'll need to login):
|
|
175
|
+
```bash
|
|
176
|
+
puter
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### Help
|
|
180
|
+
- **General Help**: Display a list of available commands.
|
|
181
|
+
```bash
|
|
182
|
+
puter help
|
|
183
|
+
```
|
|
184
|
+
- **Command Help**: Display detailed help for a specific command.
|
|
185
|
+
```bash
|
|
186
|
+
puter help <command>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Examples
|
|
192
|
+
|
|
193
|
+
1. **Log in and List Files**:
|
|
194
|
+
```bash
|
|
195
|
+
puter login
|
|
196
|
+
puter> ls
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
2. **Create and Deploy a Static Site**:
|
|
200
|
+
```bash
|
|
201
|
+
puter> mkdir my-site
|
|
202
|
+
puter> site:create my-site --subdomain=myapp
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
3. **Check Disk Usage**:
|
|
206
|
+
```bash
|
|
207
|
+
puter> df
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
4. **Delete a File**:
|
|
211
|
+
```bash
|
|
212
|
+
puter> rm /path/to/file
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
5. **Display statistics**:
|
|
216
|
+
```bash
|
|
217
|
+
puter> stat /path/to/file/or/directory
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Known issues:
|
|
223
|
+
|
|
224
|
+
Most of the functionalities are just working fine, however some APIs related to Puter's SDK have some known issues. We tried to fix most them but some of them are not related to us, so we let you about that in case it'll be fixed by Puter's in the future:
|
|
225
|
+
|
|
226
|
+
## Delete a subdomain
|
|
227
|
+
When you try to delete a subdomain which you own, you'll get `Permission denied`:
|
|
228
|
+
```bash
|
|
229
|
+
Failed to delete subdomain: Permission denied.
|
|
230
|
+
Site ID: "sd-b019b654-e06f-48a8-917e-ae1e83825ab7" may already be deleted!
|
|
231
|
+
```
|
|
232
|
+
However, the query is executed successfully at the cloud and the subdomain is actually deleted.
|
|
233
|
+
|
|
234
|
+
## Interactive Shell prompt:
|
|
235
|
+
If you want to stay in the interactive shell you should provide "-f" (aka: force delete) argument, when want to delete any object:
|
|
236
|
+
```bash
|
|
237
|
+
puter@username/myapp> rm README.md
|
|
238
|
+
The following items will be moved to Trash:
|
|
239
|
+
- /username/myapp/README.md
|
|
240
|
+
? Are you sure you want to move these 1 item(s) to Trash? (y/N) n
|
|
241
|
+
puter@username/myapp> Operation canceled.
|
|
242
|
+
username:~/home$ puter
|
|
243
|
+
puter@username/myapp> rm -f README.md
|
|
244
|
+
Successfully moved "/username/myapp/README.md" to Trash!
|
|
245
|
+
```
|
|
246
|
+
Otherwise, the Interactive Shell mode will be terminated.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Notes
|
|
251
|
+
|
|
252
|
+
This project is not equivalent [phoenix](https://github.com/HeyPuter/puter/blob/main/src/phoenix/README.md), niether an attempt to mimic some it's features, it's rather a CLI tool to do most the Puter's API from command line.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Configuration
|
|
257
|
+
|
|
258
|
+
The CLI uses a configuration file to store user credentials and settings. By default, this file is located at `~/.config/puter-cli/config.json`. You can manually edit this file or use the `puter logout` to empty the file settings.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Contributing
|
|
263
|
+
|
|
264
|
+
We welcome contributions! Please follow these steps:
|
|
265
|
+
1. Fork the repository.
|
|
266
|
+
2. Create a new branch for your feature or bugfix with a reproducible steps.
|
|
267
|
+
3. Submit a pull request with a detailed description of your changes.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
This project is licensed under the **[NoHarm License](https://github.com/raisely/NoHarm/blob/publish/LICENSE.md)**. See the [LICENSE](LICENSE.md) file for details.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Support
|
|
278
|
+
|
|
279
|
+
For issues or questions, please open an issue on [GitHub](https://github.com/bitsnaps/puter-cli/issues) or contact [puter's team](hey@puter.com) if you found an issue related to Puter's APIs.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Acknowledgments
|
|
284
|
+
|
|
285
|
+
- **Puter Cloud Platform** for providing the backend infrastructure.
|
|
286
|
+
- **Node.js** and **npm** for enabling this project.
|
|
287
|
+
- The open-source community for their invaluable contributions.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
Happy deploing with **Puter CLI**! 🚀
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { login, logout } from '../commands/auth.js';
|
|
4
|
+
import { init } from '../commands/init.js';
|
|
5
|
+
import { startShell } from '../commands/shell.js';
|
|
6
|
+
|
|
7
|
+
const program = new Command();
|
|
8
|
+
|
|
9
|
+
program
|
|
10
|
+
.name('puter')
|
|
11
|
+
.description('CLI tool for Puter cloud platform')
|
|
12
|
+
.version('1.0.0');
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.command('login')
|
|
16
|
+
.description('Login to Puter account')
|
|
17
|
+
.action(login);
|
|
18
|
+
|
|
19
|
+
program
|
|
20
|
+
.command('logout')
|
|
21
|
+
.description('Logout from Puter account')
|
|
22
|
+
.action(logout);
|
|
23
|
+
|
|
24
|
+
program
|
|
25
|
+
.command('init')
|
|
26
|
+
.description('Initialize a new Puter app')
|
|
27
|
+
.action(init);
|
|
28
|
+
|
|
29
|
+
program
|
|
30
|
+
.command('shell')
|
|
31
|
+
.description('Start interactive shell')
|
|
32
|
+
.action(startShell);
|
|
33
|
+
|
|
34
|
+
if (process.argv.length === 2) {
|
|
35
|
+
startShell();
|
|
36
|
+
} else {
|
|
37
|
+
program.parse();
|
|
38
|
+
}
|