puter-cli 1.8.6 → 2.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/.github/workflows/npm-build.yml +4 -3
- package/CHANGELOG.md +29 -0
- package/README.md +10 -2
- package/bin/index.js +184 -30
- package/package.json +12 -12
- package/src/commands/apps.js +53 -139
- package/src/commands/auth.js +113 -115
- package/src/commands/deploy.js +29 -27
- package/src/commands/files.js +151 -512
- package/src/commands/shell.js +13 -25
- package/src/commands/sites.js +25 -83
- package/src/commands/subdomains.js +46 -55
- package/src/commons.js +2 -2
- package/src/executor.js +26 -26
- package/src/modules/ErrorModule.js +18 -31
- package/src/modules/ProfileModule.js +183 -123
- package/src/modules/PuterModule.js +30 -0
- package/tests/ErrorModule.test.js +42 -0
- package/tests/ProfileModule.test.js +274 -0
- package/tests/PuterModule.test.js +56 -0
- package/tests/apps.test.js +194 -0
- package/tests/commons.test.js +380 -0
- package/tests/deploy.test.js +84 -0
- package/tests/executor.test.js +52 -0
- package/tests/files.test.js +640 -0
- package/tests/login.test.js +69 -51
- package/tests/shell.test.js +184 -0
- package/tests/sites.test.js +67 -0
- package/tests/subdomains.test.js +90 -0
- package/src/modules/SetContextModule.js +0 -5
- package/src/temporary/context_helpers.js +0 -17
package/src/commands/deploy.js
CHANGED
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { generateAppName
|
|
2
|
+
import { generateAppName } from '../commons.js';
|
|
3
3
|
import { syncDirectory } from './files.js';
|
|
4
4
|
import { createSite } from './sites.js';
|
|
5
|
-
import {
|
|
6
|
-
import { getSubdomains } from './subdomains.js';
|
|
5
|
+
import { getPuter } from '../modules/PuterModule.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Deploy a local web project to Puter.
|
|
10
|
-
* @param {string[]} args - Command-line arguments (e.g.,
|
|
9
|
+
* @param {string[]} args - Command-line arguments (e.g., <local_dir> [--subdomain=<subdomain>]).
|
|
11
10
|
*/
|
|
12
11
|
export async function deploy(args = []) {
|
|
13
|
-
if (args.length
|
|
14
|
-
console.log(chalk.red('Usage: site:deploy
|
|
15
|
-
console.log(chalk.yellow('Example: site:deploy'));
|
|
16
|
-
console.log(chalk.yellow('Example: site:deploy'));
|
|
17
|
-
console.log(chalk.yellow('Example: site:deploy ./my-app'));
|
|
18
|
-
console.log(chalk.yellow('Example: site:deploy ./my-app --subdomain=my-app-new'));
|
|
12
|
+
if (args.length < 1) {
|
|
13
|
+
console.log(chalk.red('Usage: site:deploy <local_dir> [--subdomain=<subdomain>]'));
|
|
14
|
+
console.log(chalk.yellow('Example: site:deploy .'));
|
|
15
|
+
console.log(chalk.yellow('Example: site:deploy ./dist'));
|
|
16
|
+
console.log(chalk.yellow('Example: site:deploy ./dist --subdomain=my-app-new'));
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
|
-
const
|
|
22
|
-
const remoteDirArg = args.find(arg => !arg.startsWith('--'));
|
|
23
|
-
const remoteDir = remoteDirArg || '.';
|
|
24
|
-
const subdomain = args.find(arg => arg.startsWith('--subdomain='))?.split('=')[1] || appName;
|
|
25
|
-
const sourceDir = '.'; // Deploy from the current directory
|
|
19
|
+
const puter = getPuter();
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
const sourceDirArg = args.find(arg => !arg.startsWith('--'));
|
|
22
|
+
const sourceDir = sourceDirArg || '.';
|
|
23
|
+
|
|
24
|
+
let subdomain = args.find(arg => arg.startsWith('--subdomain='))?.split('=')[1];
|
|
25
|
+
if (!subdomain) {
|
|
26
|
+
subdomain = generateAppName();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const remoteDir = `~/sites/${subdomain}/deployment`;
|
|
30
|
+
|
|
31
|
+
// this will handle the increments
|
|
32
|
+
const directory = await puter.fs.mkdir(remoteDir, {
|
|
33
|
+
dedupeName: true,
|
|
34
|
+
createMissingParents: true
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
console.log(chalk.cyan(`Deploying '${sourceDir}' to '${subdomain}.puter.site'...`));
|
|
28
38
|
|
|
29
39
|
try {
|
|
30
40
|
// 1. Upload files
|
|
31
|
-
|
|
32
|
-
await syncDirectory([sourceDir, remoteDir, '--delete', '-r', '--overwrite']);
|
|
41
|
+
await syncDirectory([sourceDir, directory.path, '--delete', '-r', '--overwrite']);
|
|
33
42
|
|
|
34
43
|
// 2. Create the site
|
|
35
|
-
|
|
36
|
-
const site = await createSite([appName, remoteDir, `--subdomain=${subdomain}`]);
|
|
44
|
+
const site = await createSite([subdomain, directory.path, `--subdomain=${subdomain}`]);
|
|
37
45
|
|
|
38
46
|
if (site) {
|
|
39
|
-
console.log(chalk.green('Deployment successful!'));
|
|
47
|
+
console.log(chalk.green('Deployment successful!'));
|
|
40
48
|
} else {
|
|
41
49
|
console.log(chalk.yellow('Deployment successfuly updated!'));
|
|
42
50
|
}
|
|
43
|
-
if (subdomain){
|
|
44
|
-
console.log(chalk.cyan('Your site is live at:'));
|
|
45
|
-
console.log(chalk.green(`https://${subdomain}.puter.site`));
|
|
46
|
-
} else {
|
|
47
|
-
console.log(chalk.red('Deployment failed. Subdomain cannot be reserved!'));
|
|
48
|
-
}
|
|
49
51
|
} catch (error) {
|
|
50
52
|
console.error(chalk.red(`Deployment failed: ${error.message}`));
|
|
51
53
|
}
|