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

feat(cli): add resvg-js CLI to @resvg/resvg-js #349

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Zhengqbbb
Copy link

@Zhengqbbb Zhengqbbb commented Jul 17, 2024

#348

I'm glad you can let me feel free do this work.

After some consideration, I think it would be more straightforward to directly include the CLI bundle file in the @resvg/resvg-js project and add a bin file. This way, CLI can directly use the core functions in ./index.js with the transform options:

  1. It's like adding a bin entry file in @resvg/resvg-js. bin => cli.js => parse options => index.js
  2. The CLI bundle file size is 24.6KB. View npm:publish-code.
  3. After downloading @resvg/resvg-js, users can directly call the CLI in their projects using yarn resvg-js or pnpm resvg-js.

I would like to hear your opinion. If you have any other ideas, feel free to tell me.
monorepo or create a new repo. IMO, placing it in the project as a separate file that can be called will not impact the main program's operation, and it will maintain uniformity in future maintenance and version control.


Next plan:

  • js or ts (I would like to hear your opinion. Initially, I found that index.js was written in JavaScript, but later the wasm was written in TypeScript.🫣)
  • Add test for cli/option.js. ensure CLI options can be transform ResvgOptions
  • README add usage

I released a pre-release version for testing, welcome to experience it

bunx @qbbsh/resvg-js -h
# or
npx @qbbsh/resvg-js -h

Base usage

base-usage.mp4

Advanced Usage pipeline

Use imagemagick to convert directly to webp format via pipeline. It can be used with other CLI tools for image cropping, conversion, editing ...

curl https://raw.githubusercontent.com/yisibl/resvg-js/main/example/text.svg | \
    npx @qbbsh/resvg-js --background "#fff" - | \
    magick  - webp:output.webp

magick output.webp -verbose info: | head
with-imagemagick.mp4

Copy link

vercel bot commented Jul 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
resvg-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2024 3:57pm

@yisibl
Copy link
Owner

yisibl commented Aug 12, 2024

I sincerely appreciate your contribution to the resvg-js ecosystem, but since this is a rust-oriented project, I'd like the CLI to be in a separate repository.

I can add you to the @resvg npm group and if you want, we can release @resvg/resvg-js-cli.

@Zhengqbbb
Copy link
Author

I sincerely appreciate your contribution to the resvg-js ecosystem, but since this is a rust-oriented project, I'd like the CLI to be in a separate repository.

I can add you to the @resvg npm group and if you want, we can release @resvg/resvg-js-cli.

Thanks !!! and how do I publish to @resvg org or add @resvg team?
My npm: https://www.npmjs.com/~qbb.sh

Zhengqbbb added a commit to Zhengqbbb/resvg-js-cli that referenced this pull request Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants