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

Create CLI that can convert sb3 to leopard or leopard-zip #129

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
86 changes: 53 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,49 +28,24 @@ sb-edit can also be used to modify Scratch projects. A few things you can/will b
| Scripts | 🕒 Planned | 🕒 Planned | 🕒 Planned |
| Costumes and sounds | 🕒 Planned | 🕒 Planned | 🕒 Planned |

## Development
## CLI Examples

If you want to help develop the sb-edit package, you'll need to follow these steps:
To use the sb-edit CLI, first install it globally using the following command:

### Step 1: Download sb-edit and prepare to use

```shell
> git clone https://github.com/PullJosh/sb-edit.git
> cd sb-edit
> npm link # Allow using sb-edit in another local project
```

### Step 2: Add sb-edit as dependency in another project

```shell
> cd my-cool-project
> npm init # This should be a node project
> npm link sb-edit # Similar to `npm install` but uses local version
$ npm i -g sb-edit
```

### Step 3: Modify sb-edit

If you make any changes to the sb-edit source code, you'll have to rebuild the package. Here's how:
### Convert .sb3 project to Leopard

```shell
> cd sb-edit # Cloned from Github and then edited
> npm run build # Build the new version!
> npm run watch # Watch files and rebuild automatically when code is changed
```

You can also run the [Jest](https://jestjs.io/) tests to make sure you didn't break anything:

```shell
> cd sb-edit # You're probably already here ;)
> npm test # Run Jest tests
> npm run lint # Check code for style problems
$ sb-edit --input path/to/project.sb3 --output path/to/output-folder
```

And finally, make sure everything is pretty:
### Convert .sb3 project to Leopard .zip

```shell
> cd sb-edit
> npm run format # Format code to look nice with Prettier
```
$ sb-edit --input path/to/project.sb3 --output path/to/output-folder.zip
```

## Code Examples
Expand Down Expand Up @@ -110,3 +85,48 @@ const project = /* Get yourself a `Project`... */;

console.log(project.toLeopard({ printWidth: 100 })); // Optionally pass a Prettier config object!
```

## Development

If you want to help develop the sb-edit package, you'll need to follow these steps:

### Step 1: Download sb-edit and prepare to use

```shell
> git clone https://github.com/PullJosh/sb-edit.git
> cd sb-edit
> npm link # Allow using sb-edit in another local project
```

### Step 2: Add sb-edit as dependency in another project

```shell
> cd my-cool-project
> npm init # This should be a node project
> npm link sb-edit # Similar to `npm install` but uses local version
```

### Step 3: Modify sb-edit

If you make any changes to the sb-edit source code, you'll have to rebuild the package. Here's how:

```shell
> cd sb-edit # Cloned from Github and then edited
> npm run build # Build the new version!
> npm run watch # Watch files and rebuild automatically when code is changed
```

You can also run the [Jest](https://jestjs.io/) tests to make sure you didn't break anything:

```shell
> cd sb-edit # You're probably already here ;)
> npm test # Run Jest tests
> npm run lint # Check code for style problems
```

And finally, make sure everything is pretty:

```shell
> cd sb-edit
> npm run format # Format code to look nice with Prettier
```
21 changes: 14 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"files": [
"lib/**/*"
],
"bin": {
"sb-edit": "lib/cli/index.js"
},
"scripts": {
"build": "tsc",
"format": "prettier --write \"src/**/*.ts\"",
Expand All @@ -37,6 +40,8 @@
"watch": "tsc -w"
},
"dependencies": {
"chalk": "^4.1.2",
"commander": "^12.0.0",
"jszip": "^3.10.1",
"prettier": "^2.8.8"
},
Expand Down
Loading
Loading