@@ -4,25 +4,26 @@ import { syncDirectory } from './files.js';
44import { createSite } from './sites.js' ;
55import { getCurrentDirectory } from './auth.js' ;
66import { 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 */
1213export 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