Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions js/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ bun run build

This produces a standalone executable at **`release/proton-drive`** with embedded Bun. Add that directory to your `PATH`, or invoke it with a full path.

To build a plain JS bundle using a system-installed Bun instead:

```bash
cd ../sdk && bun install
cd ../cli && bun run build:bundle
```

This produces `release/proton-drive.js`. You are responsible for providing a wrapper to invoke it, e.g. `exec bun /path/to/proton-drive.js "$@"`.

## Authentication

Sign-in uses the browser (no password on the command line):
Expand Down
1 change: 1 addition & 0 deletions js/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"build": "bun ./scripts/build-cli.mjs main",
"build:internal": "bun ./scripts/build-cli.mjs internal",
"build:bundle": "bun ./scripts/build-cli.mjs main bun --no-compile",
"check-types": "tsc --noEmit",
"generate-types": "bunx openapi-typescript ../../api/openapi-core.json -o ./src/api/api-core-types.ts && bunx openapi-typescript ../../api/openapi-auth.json -o ./src/api/api-auth-types.ts",
"generate-metric-schemas": "bun ./scripts/generate-metric-schemas.ts",
Expand Down
12 changes: 8 additions & 4 deletions js/cli/scripts/build-cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@ const GIT_ROOT = path.resolve(import.meta.dir, '../../..');
const mode = process.argv[2] === 'internal' ? 'internal' : 'main';

const target = process.argv[3] || 'bun';
const noCompile = process.argv.includes('--no-compile');
let outfileArchitecture = '';
if (target.startsWith('bun-')) {
outfileArchitecture = '/' + target.slice(4);
}

const entry = mode === 'internal' ? 'src/internal-cli/proton-drive-internal.ts' : 'src/proton-drive.ts';
const outfile = mode === 'internal' ? `release${outfileArchitecture}/proton-drive-internal` : `release${outfileArchitecture}/proton-drive`;
const outfileName = mode === 'internal' ? 'proton-drive-internal' : 'proton-drive';
const outfile = `release${outfileArchitecture}/${outfileName}${noCompile ? '.js' : ''}`;

const args = [
'build',
'--compile',
...(!noCompile ? [
'--compile',
// Slower compile, bigger bundle size, faster execution.
'--bytecode',
] : []),
`--target=${target}`,
// Slower compile, bigger bundle size, faster execution.
'--bytecode',
// Use modern ESM format to allow await syntax in the entry file.
'--format=esm',
// Reduce bundle size (not much, the biggest part is the embedded Bun itself).
Expand Down