puter-cli 1.5.7 → 1.6.1
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/.github/workflows/npm-build.yml +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +6 -6
- package/package.json +4 -4
- package/src/commands/files.js +17 -7
- package/src/commands/init.js +38 -8
- package/src/commands/sites.js +10 -6
- package/src/commands/subdomains.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v1.6.1](https://github.com/HeyPuter/puter-cli/compare/v1.6.0...v1.6.1)
|
|
8
|
+
|
|
9
|
+
- fix: set subdomain when creating a site [`6329ed1`](https://github.com/HeyPuter/puter-cli/commit/6329ed1c766b8eb722ac8c03c9ffe61dbba4a66c)
|
|
10
|
+
|
|
11
|
+
#### [v1.6.0](https://github.com/HeyPuter/puter-cli/compare/v1.5.7...v1.6.0)
|
|
12
|
+
|
|
13
|
+
> 16 February 2025
|
|
14
|
+
|
|
15
|
+
- feat: improve init command [`2bd51ee`](https://github.com/HeyPuter/puter-cli/commit/2bd51ee01d0636b7979a9f55d3c746287c3b512a)
|
|
16
|
+
- chore: improve error message [`46fb3b0`](https://github.com/HeyPuter/puter-cli/commit/46fb3b063c1c74d0006138cd400b6ad207e784d9)
|
|
17
|
+
- chore: update package repo [`f6960ed`](https://github.com/HeyPuter/puter-cli/commit/f6960ed6f8e6fb793a6b8340476ab22778b44c14)
|
|
18
|
+
|
|
7
19
|
#### [v1.5.7](https://github.com/HeyPuter/puter-cli/compare/v1.5.6...v1.5.7)
|
|
8
20
|
|
|
21
|
+
> 16 February 2025
|
|
22
|
+
|
|
9
23
|
- chore: clean unused [`8477dc2`](https://github.com/HeyPuter/puter-cli/commit/8477dc294773c99270a83dc22ae602abe92621cf)
|
|
10
24
|
|
|
11
25
|
#### [v1.5.6](https://github.com/HeyPuter/puter-cli/compare/v1.5.5...v1.5.6)
|
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Puter-CLI
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<img alt="test" src="https://github.com/
|
|
5
|
-
<a href="https://codecov.io/github/
|
|
6
|
-
<img src="https://codecov.io/github/
|
|
4
|
+
<img alt="test" src="https://github.com/HeyPuter/puter-cli/actions/workflows/npm-build.yml/badge.svg">
|
|
5
|
+
<a href="https://codecov.io/github/HeyPuter/puter-cli" >
|
|
6
|
+
<img src="https://codecov.io/github/HeyPuter/puter-cli/graph/badge.svg?token=TFPCdwdFxF"/>
|
|
7
7
|
</a>
|
|
8
|
-
<img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/
|
|
8
|
+
<img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/HeyPuter/puter-cli">
|
|
9
9
|
<a href="https://opensource.org/licenses/MIT" >
|
|
10
10
|
<img alt="License" src="https://img.shields.io/badge/License-MIT-yellow.svg">
|
|
11
11
|
</a>
|
|
@@ -266,7 +266,7 @@ If you want to customize this tool you can follow these steps:
|
|
|
266
266
|
### Steps
|
|
267
267
|
1. Clone the repository:
|
|
268
268
|
```bash
|
|
269
|
-
git clone https://github.com/
|
|
269
|
+
git clone https://github.com/HeyPuter/puter-cli.git
|
|
270
270
|
cd puter-cli
|
|
271
271
|
```
|
|
272
272
|
2. Install dependencies:
|
|
@@ -339,7 +339,7 @@ This project was previously licensed under the "NoHarm" license to explicitly pr
|
|
|
339
339
|
|
|
340
340
|
## Support
|
|
341
341
|
|
|
342
|
-
For issues or questions, please open an issue on [GitHub](https://github.com/
|
|
342
|
+
For issues or questions, please open an issue on [GitHub](https://github.com/HeyPuter/puter-cli/issues) or contact [puter's team](mailto:hey@puter.com) if you found an issue related to Puter's APIs.
|
|
343
343
|
|
|
344
344
|
---
|
|
345
345
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "puter-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Command line interface for Puter cloud platform",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
},
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
51
|
-
"url": "git+https://github.com/
|
|
51
|
+
"url": "git+https://github.com/HeyPuter/puter-cli.git"
|
|
52
52
|
},
|
|
53
53
|
"bugs": {
|
|
54
|
-
"url": "https://github.com/
|
|
54
|
+
"url": "https://github.com/HeyPuter/puter-cli/issues"
|
|
55
55
|
},
|
|
56
|
-
"homepage": "https://github.com/
|
|
56
|
+
"homepage": "https://github.com/HeyPuter/puter-cli"
|
|
57
57
|
}
|
package/src/commands/files.js
CHANGED
|
@@ -402,8 +402,8 @@ export async function deleteFolder(folderPath, skipConfirmation = false) {
|
|
|
402
402
|
});
|
|
403
403
|
|
|
404
404
|
const deleteData = await deleteResponse.json();
|
|
405
|
-
if (deleteResponse.ok) {
|
|
406
|
-
console.log(chalk.green(`Successfully deleted all contents
|
|
405
|
+
if (deleteResponse.ok && Object.keys(deleteData).length == 0) {
|
|
406
|
+
console.log(chalk.green(`Successfully deleted all contents from: ${chalk.cyan(folderPath)}`));
|
|
407
407
|
} else {
|
|
408
408
|
console.log(chalk.red('Failed to delete folder. Please check your input.'));
|
|
409
409
|
}
|
|
@@ -1195,16 +1195,26 @@ async function resolveLocalDirectory(localPath) {
|
|
|
1195
1195
|
* @param {string[]} args - Command-line arguments (e.g., [localDir, remoteDir]).
|
|
1196
1196
|
*/
|
|
1197
1197
|
export async function syncDirectory(args = []) {
|
|
1198
|
+
const usageMessage = 'Usage: update <local_directory> <remote_directory> [--delete]';
|
|
1198
1199
|
if (args.length < 2) {
|
|
1199
|
-
console.log(chalk.red(
|
|
1200
|
+
console.log(chalk.red(usageMessage));
|
|
1200
1201
|
return;
|
|
1201
1202
|
}
|
|
1202
1203
|
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1204
|
+
let localDir = '';
|
|
1205
|
+
let remoteDir = '';
|
|
1206
|
+
let deleteFlag = '';
|
|
1207
|
+
try {
|
|
1208
|
+
localDir = await resolveLocalDirectory(args[0]);
|
|
1209
|
+
remoteDir = resolvePath(getCurrentDirectory(), args[1]);
|
|
1210
|
+
deleteFlag = args.includes('--delete'); // Whether to delete extra files
|
|
1211
|
+
} catch (error) {
|
|
1212
|
+
console.error(chalk.red(error.message));
|
|
1213
|
+
console.log(chalk.green(usageMessage));
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1206
1216
|
|
|
1207
|
-
console.log(chalk.green(`Syncing local directory
|
|
1217
|
+
console.log(chalk.green(`Syncing local directory ${chalk.cyan(localDir)}" with remote directory ${chalk.cyan(remoteDir)}"...\n`));
|
|
1208
1218
|
|
|
1209
1219
|
try {
|
|
1210
1220
|
// Step 1: Validate local directory
|
package/src/commands/init.js
CHANGED
|
@@ -26,8 +26,10 @@ export async function init() {
|
|
|
26
26
|
}
|
|
27
27
|
]);
|
|
28
28
|
|
|
29
|
-
let jsFiles = [];
|
|
29
|
+
let jsFiles = ['puter-sdk'];
|
|
30
|
+
let jsDevFiles = [];
|
|
30
31
|
let cssFiles = [];
|
|
32
|
+
let jsExtraLibraries = [];
|
|
31
33
|
let extraFiles = [];
|
|
32
34
|
let bundlerAnswers = null;
|
|
33
35
|
let frameworkAnswers = null;
|
|
@@ -73,14 +75,14 @@ export async function init() {
|
|
|
73
75
|
content: `<template><h1>${answers.name}</h1></template>`
|
|
74
76
|
});
|
|
75
77
|
break;
|
|
76
|
-
|
|
78
|
+
case FULLSTACK_FRAMEWORKS[2]:
|
|
77
79
|
jsFiles.push('svelte@latest', 'sveltekit@latest');
|
|
78
80
|
extraFiles.push({
|
|
79
81
|
path: 'src/app.vue',
|
|
80
82
|
content: `<template><h1>${answers.name}</h1></template>`
|
|
81
83
|
});
|
|
82
84
|
break;
|
|
83
|
-
|
|
85
|
+
case FULLSTACK_FRAMEWORKS[3]:
|
|
84
86
|
jsFiles.push('astro@latest', 'astro@latest');
|
|
85
87
|
extraFiles.push({
|
|
86
88
|
path: 'src/pages/index.astro',
|
|
@@ -117,6 +119,7 @@ export async function init() {
|
|
|
117
119
|
break;
|
|
118
120
|
case JS_LIBRARIES[1]:
|
|
119
121
|
jsFiles.push('vue@latest');
|
|
122
|
+
jsDevFiles.push('@vitejs/plugin-vue');
|
|
120
123
|
const vueLibs = await inquirer.prompt([
|
|
121
124
|
{
|
|
122
125
|
type: 'checkbox',
|
|
@@ -126,10 +129,30 @@ export async function init() {
|
|
|
126
129
|
}
|
|
127
130
|
]);
|
|
128
131
|
jsFiles.push(...vueLibs.vueLibraries);
|
|
129
|
-
extraFiles.push(
|
|
132
|
+
extraFiles.push(
|
|
133
|
+
{
|
|
130
134
|
path: 'src/App.vue',
|
|
131
135
|
content: `<template><h1>${answers.name}</h1></template>`
|
|
132
|
-
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
path: 'vite.config.js',
|
|
139
|
+
content: `import { defineConfig } from 'vite';
|
|
140
|
+
import vue from '@vitejs/plugin-vue';
|
|
141
|
+
|
|
142
|
+
export default defineConfig({
|
|
143
|
+
plugins: [vue()]
|
|
144
|
+
})
|
|
145
|
+
`},
|
|
146
|
+
{
|
|
147
|
+
path: 'main.js',
|
|
148
|
+
content: `import { createApp } from 'vue'
|
|
149
|
+
import './style.css';
|
|
150
|
+
import App from './App.vue';
|
|
151
|
+
|
|
152
|
+
const app = createApp(App);
|
|
153
|
+
app.mount('#app');
|
|
154
|
+
`},
|
|
155
|
+
);
|
|
133
156
|
break;
|
|
134
157
|
case JS_LIBRARIES[2]:
|
|
135
158
|
jsFiles.push('@angular/core@latest');
|
|
@@ -196,15 +219,16 @@ export async function init() {
|
|
|
196
219
|
case CSS_LIBRARIES[2]:
|
|
197
220
|
cssFiles.push('https://cdn.tailwindcss.com');
|
|
198
221
|
break;
|
|
199
|
-
}
|
|
222
|
+
}
|
|
200
223
|
}
|
|
201
224
|
|
|
225
|
+
|
|
202
226
|
const spinner = ora('Creating Puter app...').start();
|
|
203
227
|
|
|
204
228
|
try {
|
|
205
229
|
const useBundler = answers.useBundler === 'Yes';
|
|
206
230
|
// Create basic app structure
|
|
207
|
-
await createAppStructure(answers.name, useBundler, bundlerAnswers, frameworkAnswers, jsFiles, cssFiles, extraFiles);
|
|
231
|
+
await createAppStructure(answers.name, useBundler, bundlerAnswers, frameworkAnswers, jsFiles, jsDevFiles, cssFiles, extraFiles);
|
|
208
232
|
spinner.succeed(chalk.green('Successfully created Puter app!'));
|
|
209
233
|
|
|
210
234
|
console.log('\nNext steps:');
|
|
@@ -221,7 +245,7 @@ export async function init() {
|
|
|
221
245
|
}
|
|
222
246
|
}
|
|
223
247
|
|
|
224
|
-
async function createAppStructure(name, useBundler, bundlerAnswers, frameworkAnswers, jsFiles, cssFiles, extraFiles) {
|
|
248
|
+
async function createAppStructure(name, useBundler, bundlerAnswers, frameworkAnswers, jsFiles, jsDevFiles, cssFiles, extraFiles) {
|
|
225
249
|
// Create project directory
|
|
226
250
|
await fs.mkdir(name, { recursive: true });
|
|
227
251
|
|
|
@@ -262,17 +286,23 @@ console.log('Puter app initialized!');`,
|
|
|
262
286
|
const packageJson = {
|
|
263
287
|
name: name,
|
|
264
288
|
version: '1.0.0',
|
|
289
|
+
type: 'module',
|
|
265
290
|
scripts,
|
|
266
291
|
dependencies: {},
|
|
267
292
|
devDependencies: {}
|
|
268
293
|
};
|
|
269
294
|
|
|
295
|
+
|
|
270
296
|
jsFiles.forEach(lib => {
|
|
271
297
|
if (!lib.startsWith('http')) {
|
|
272
298
|
packageJson.dependencies[lib.split('@')[0].toString().toLowerCase()] = lib.split('@')[1] || 'latest';
|
|
273
299
|
}
|
|
274
300
|
});
|
|
275
301
|
|
|
302
|
+
jsDevFiles.forEach(lib => {
|
|
303
|
+
packageJson.devDependencies[lib] = 'latest';
|
|
304
|
+
});
|
|
305
|
+
|
|
276
306
|
packageJson.devDependencies[bundler] = 'latest';
|
|
277
307
|
|
|
278
308
|
await fs.writeFile(path.join(name, 'package.json'), JSON.stringify(packageJson, null, 2));
|
package/src/commands/sites.js
CHANGED
|
@@ -192,12 +192,16 @@ export async function infoSite(args = []) {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
subdomain
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
195
|
+
}
|
|
196
|
+
// else {
|
|
197
|
+
// console.log(chalk.yellow(`The subdomain: "${subdomain}" is already taken, so let's generate a new random one:`));
|
|
198
|
+
// subdomain = generateAppName(); // Generate a random subdomain
|
|
199
|
+
// console.log(chalk.cyan(`New generated subdomain: "${subdomain}" will be used.`));
|
|
200
|
+
// }
|
|
201
|
+
|
|
202
|
+
// Use the chosen "subdomain"
|
|
203
|
+
console.log(chalk.cyan(`New generated subdomain: "${subdomain}" will be used if its not already in use.`));
|
|
204
|
+
|
|
201
205
|
// Step 3: Host the current directory under the subdomain
|
|
202
206
|
console.log(chalk.cyan(`Hosting app "${appName}" under subdomain "${subdomain}"...`));
|
|
203
207
|
const site = await createSubdomain(subdomain, remoteDir);
|
|
@@ -93,6 +93,7 @@ export async function createSubdomain(subdomain, remoteDir) {
|
|
|
93
93
|
const data = await response.json();
|
|
94
94
|
if (!data.success || !data.result) {
|
|
95
95
|
if (data.error?.code === 'already_in_use') {
|
|
96
|
+
// data.error?.status===409
|
|
96
97
|
console.log(chalk.yellow(`Subdomain already taken!\nMessage: ${data?.error?.message}`));
|
|
97
98
|
return false;
|
|
98
99
|
}
|