Skip to content

Commit 155157a

Browse files
authored
Merge pull request #25 from reynaldichernando/deploy-local-dir
Site deploy from local dir
2 parents b5d2027 + 2102add commit 155157a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/commands/deploy.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,26 @@ import { syncDirectory } from './files.js';
44
import { createSite } from './sites.js';
55
import { getCurrentDirectory } from './auth.js';
66
import { getSubdomains } from './subdomains.js';
7+
import crypto from '../crypto.js';
78

89
/**
910
* Deploy a local web project to Puter.
10-
* @param {string[]} args - Command-line arguments (e.g., [<remote_dir>] [--subdomain=<subdomain>]).
11+
* @param {string[]} args - Command-line arguments (e.g., <local_dir> [--subdomain=<subdomain>]).
1112
*/
1213
export async function deploy(args = []) {
13-
if (args.length > 2 || args.some(arg => arg.startsWith('--') && !arg.startsWith('--subdomain='))) {
14-
console.log(chalk.red('Usage: site:deploy [<remote_dir>] [--subdomain=<subdomain>]'));
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'));
14+
if (args.length < 1) {
15+
console.log(chalk.red('Usage: site:deploy <local_dir> [--subdomain=<subdomain>]'));
16+
console.log(chalk.yellow('Example: site:deploy .'));
17+
console.log(chalk.yellow('Example: site:deploy ./dist'));
18+
console.log(chalk.yellow('Example: site:deploy ./dist --subdomain=my-app-new'));
1919
return;
2020
}
2121
const appName = generateAppName();
22-
const remoteDirArg = args.find(arg => !arg.startsWith('--'));
23-
const remoteDir = remoteDirArg || '.';
22+
const sourceDirArg = args.find(arg => !arg.startsWith('--'));
23+
const sourceDir = sourceDirArg || '.';
2424
const subdomain = args.find(arg => arg.startsWith('--subdomain='))?.split('=')[1] || appName;
25-
const sourceDir = '.'; // Deploy from the current directory
25+
26+
const remoteDir = `deployments/site-${crypto.randomUUID()}`;
2627

2728
console.log(chalk.cyan(`Deploying '${appName}' from local '${sourceDir}' to remote '${remoteDir}' at '${subdomain}.puter.site'...`));
2829

0 commit comments

Comments
 (0)