Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "--leopard-url" CLI option #148

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

towerofnix
Copy link
Member

Enables testing a custom Leopard build locally, or providing any other alternate Leopard library host.

The default value is the same one that is used by default in toLeopard.ts. It would be nice not to duplicate this definition, but unless toLeopard defined it as an export (this would probably be awkward) or stops providing a default at all, it is what it is.

This option is used in both leopard and leopard-zip output formats, and ignored in other formats.

Only fully qualified URLs are supported, i.e. you can't just do /leopard/dist. This is to make the output folder work regardless where it's hosted (provided the specified URL is accessible there), and to avoid confusing a path on a hypothetical file server with a path on your own system.

There's no magic about e.g. taking a specified path to Leopard and copying out the dist/ files at time of sb-edit run (to make a self-contained folder/zip). That's out of scope for this PR, and may require adjustments to toLeopard internals (e.g. supporting relative imports there).

Typical development setup 1:

# terminal 1
cd leopard
npm run dev

# terminal 2
cd leopard/dist
npx vite --port 6201

# terminal 3
npx vite --port 6200

# terminal 4
sb-edit -i /path/to/proj.sb3 -o demo \
  --leopard-url http://localhost:6201/

# in browser, navigate to:
# http://localhost:6200/demo/

Typical development setup 2:

# terminal 1
cd leopard
npm run dev

# terminal 2
npx vite --port 6200

# terminal 3
rm -rf demo
sb-edit -i /path/to/proj.sb3 -o demo \
  --leopard-url http://localhost:6200/leopard/dist/

# in browser, navigate to:
# http://localhost:6200/demo/

@towerofnix towerofnix added fmt: Leopard Pertains to Leopard format (JavaScript) command-line Features or improvements for sb-edit CLI labels Jul 1, 2024
@towerofnix towerofnix requested a review from PullJosh July 1, 2024 22:20
Copy link
Collaborator

@PullJosh PullJosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from one tiny comment, I love it!

src/cli/index.ts Show resolved Hide resolved
@towerofnix towerofnix merged commit b763a27 into leopard-js:master Jul 2, 2024
1 check passed
@towerofnix towerofnix deleted the custom-leopard branch July 2, 2024 16:02
@towerofnix
Copy link
Member Author

Merged, thanks! I'm going to push 0.15.0 with this and other recent merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-line Features or improvements for sb-edit CLI fmt: Leopard Pertains to Leopard format (JavaScript)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants