Skip to content

Commit

Permalink
Merge branch 'TurboWarp:master' into midi
Browse files Browse the repository at this point in the history
  • Loading branch information
Brackets-Coder authored Jan 28, 2025
2 parents bbff7de + 238344a commit a5c6aee
Show file tree
Hide file tree
Showing 82 changed files with 853 additions and 339 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: 20.x
node-version: 22
- name: Install dependencies
run: npm ci
- name: Build for production
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/download-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Download translations

on:
workflow_dispatch:
schedule:
# Time 10:44 was chosen at random to avoid periods of high load.
- cron: "44 10 * * WED,SAT"

concurrency:
group: "download-translations"
Expand Down Expand Up @@ -34,7 +37,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: 20.x
node-version: 22
- name: Install dependencies
run: npm ci
- name: Download translations
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: 20.x
node-version: 22
- name: Install dependencies
run: npm ci
- name: Format
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: 20.x
node-version: 22
- name: Install dependencies
run: npm ci
- name: Format
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Autolaber

on:
# pull_request_target is dangerous but necessary to assign labels to the pull request.
pull_request_target:
# Only label on initial open so as to not trigger a whole lot unnecessarily
# and also allow humans to override without their changes getting overwritten
# on the next commit.
types: [opened]

jobs:
label-pull-request:
runs-on: ubuntu-latest

# Disabled by default for forks since this is probably not useful.
if: ${{ github.repository == 'TurboWarp/extensions' }}

permissions:
pull-requests: write

steps:
# This is a sensitive workflow because we have write permissions for pull-requests but we are
# processing remote code that we can't trust. Be careful not to place any trust in the contents
# of the pull request.
- name: Assign labels
run: |
LABEL_NEW_EXTENSION="pr: new extension"
LABEL_CHANGE_EXTENSION="pr: change existing extension"
LABEL_OTHER="pr: other"
# grep doesn't have good multiline support and installing pcregrep through apt is slow, so
# make our own tiny regex checker tool.
cat > matches <<EOF
#!/usr/bin/env python3
import sys
import re
pattern = sys.argv[1]
file = sys.argv[2]
with open(file, 'r') as f:
contents = f.read()
if re.search(pattern, contents, re.MULTILINE):
sys.exit(0)
else:
sys.exit(1)
EOF
chmod +x matches
got_any_specific_label=false
if [[ "$BASE_REF" == "master" ]]; then
echo "Downloading pull request diff"
# Download just the diff so it is harder to accidentally run any code from the pull request.
gh pr diff --repo "$GH_REPO" "$PR_NUMBER" | tee pr.diff
if ./matches "^--- /dev/null\n\+\+\+ b/extensions/" pr.diff; then
# Example:
# --- /dev/null
# +++ b/extensions/DangoCat/extension.js
echo "Adding label: $LABEL_NEW_EXTENSION"
gh pr edit --repo "$GH_REPO" "$PR_NUMBER" --add-label "$LABEL_NEW_EXTENSION"
got_any_specific_label=true
elif ./matches "^\+\+\+ b/extensions/" pr.diff; then
# Example:
# --- a/extensions/DangoCat/extension.js
# +++ b/extensions/DangoCat/extension.js
echo "Adding label: $LABEL_CHANGE_EXTENSION"
gh pr edit --repo "$GH_REPO" "$PR_NUMBER" --add-label "$LABEL_CHANGE_EXTENSION"
got_any_specific_label=true
fi
else
echo "Unusual base ref: $BASE_REF"
fi
# Any PR that didn't get a specific label will go into other, for a human to look at.
if [[ "$got_any_specific_label" == "false" ]]; then
echo "Adding label: $LABEL_OTHER"
gh pr edit --repo "$GH_REPO" "$PR_NUMBER" --add-label "$LABEL_OTHER"
fi
env:
PR_NUMBER: "${{ github.event.number }}"
BASE_REF: "${{ github.base_ref }}"
GH_TOKEN: "${{ github.token }}"
GH_REPO: "${{ github.repository }}"
2 changes: 1 addition & 1 deletion .github/workflows/upload-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: 20.x
node-version: 22
- name: Install dependencies
run: npm ci
- name: Upload translations
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: 20.x
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: 20.x
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: 20.x
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ build
images
licenses
website
eslint.config.js
*.json
*.yml
*.md
Expand Down
3 changes: 3 additions & 0 deletions development/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ class JSONMetadataFile extends BuildFile {
if (samples) {
extension.samples = samples.map((i) => i.getTitle());
}
if (metadata.scratchCompatible) {
extension.scratchCompatible = true;
}

extensions.push(extension);
}
Expand Down
11 changes: 9 additions & 2 deletions development/homepage-template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,15 @@
<h2><%= metadata.name %></h2>
<p>
<%= metadata.description %>
<%- metadata.by.length ? `Created by ${peopleToHTML(metadata.by)}.` : '' %>
<%- metadata.original.length ? `Originally created by ${peopleToHTML(metadata.original)}.` : '' %>
<%-
(metadata.original.length && metadata.by.length) ? (
`Created by ${peopleToHTML(metadata.original)}. Updated by ${peopleToHTML(metadata.by)}.`
) : metadata.by.length ? (
`Created by ${peopleToHTML(metadata.by)}.`
) : metadata.original.length ? (
`Created by ${peopleToHTML(metadata.original)}.`
) : ''
%>
</p>
</div>
<% } %>
Expand Down
4 changes: 4 additions & 0 deletions development/parse-extension-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Extension {
/** @type {Person[]} */
this.original = [];
this.context = "";
this.scratchCompatible = false;
}
}

Expand Down Expand Up @@ -102,6 +103,9 @@ const parseMetadata = (extensionCode) => {
case "context":
metadata.context = value;
break;
case "scratch-compatible":
metadata.scratchCompatible = value === "true";
break;
default:
// TODO
break;
Expand Down
14 changes: 8 additions & 6 deletions development/upload-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const Builder = require("./builder");

const uploadRuntimeStrings = async (strings) => {
if (
typeof strings["lab/text@_Animated Text"].string !== "string" ||
typeof strings["lab/text@_Animated Text"].developer_comment !== "string" ||
Object.keys(strings).length < 500
strings["lab/text@_Animated Text"].string !== "Animated Text" ||
strings["lab/text@_Animated Text"].developer_comment !==
"Part of the 'Animated Text' extension." ||
Object.keys(strings).length < 1500
) {
throw new Error("Sanity check failed.");
}
Expand All @@ -29,9 +30,10 @@ const uploadRuntimeStrings = async (strings) => {

const uploadMetadataStrings = async (strings) => {
if (
typeof strings["lab/text@name"].string !== "string" ||
typeof strings["lab/text@name"].developer_comment !== "string" ||
Object.keys(strings).length < 100
strings["lab/text@name"].string !== "Animated Text" ||
strings["lab/text@name"].developer_comment !==
"Name of the 'Animated Text' extension in the extension gallery." ||
Object.keys(strings).length < 150
) {
throw new Error("Sanity check failed.");
}
Expand Down
24 changes: 12 additions & 12 deletions docs/CST1229/zip.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Creates and opens an empty archive with nothing in it. The name is used for deal
---

```scratch
open zip from (URL v) [https://extensions.turbowarp.org] named [archive] :: #a49a3a
open archive from zip from (URL v) [https://extensions.turbowarp.org] named [archive] :: #a49a3a
```
Opens a .zip (or .sb3 or .sprite3...) file.
Creates and opens an archive from a .zip (or .sb3 or .sprite3...) file.

The type can be one of the following:

Expand All @@ -45,7 +45,7 @@ The type can be one of the following:

The name is used for dealing with multiple archives at time; it can be any non-empty string and does *not* have to be the archive's filename.

If the file is not of zip format (e.g RAR or 7z) or is password-protected, it won't be opened. Make sure to check if it loaded successfully with the `error opening archive?` block.
If the file is not of zip format (like RAR or 7z) or is password-protected, it won't be opened. Make sure to check if it loaded successfully with the `error opening archive?` block.

---

Expand Down Expand Up @@ -97,14 +97,14 @@ Multiple archives can be open at a time, but there is one "current archive" that
```scratch
(current archive name :: #a49a3a)
```
Returns the name of the currently open archive (or an empty string if there isn't one).
Returns the name of the currently open archive, or an empty string if there isn't one.

---

```scratch
(currently open archives :: #a49a3a)
```
Returns the list of currently open archives, as a JSON array (which you can parse with the JSON extension).
Returns the list of currently open archives as a JSON array, which you can parse with the JSON extension.

---

Expand All @@ -122,14 +122,14 @@ Removes all archives that are currently open.

## File blocks

Blocks for working with files (and blocks that are general to both files and folders/directories.)
Blocks for working with files, and blocks that are general to both files and folders/directories.

---

```scratch
<folder [folder/] exists? :: #a49a3a>
<[folder/] exists? :: #a49a3a>
```
Returns if a file or directory exists or not. The slash at the end matters! If a directory named `folder` exists, `[folder] exists?` will return false, but `[folder/] exists?` will return true.
Returns whether a file or directory exists or not. The slash at the end matters! If a directory named `folder` exists, `[folder] exists?` will return false, but `[folder/] exists?` will return true.

---

Expand Down Expand Up @@ -218,9 +218,9 @@ Available options:

Available options:

- **name**: Just the name of this file (without the directories it's in). For example, the name of `/folder1/folder2/dango.png` would be `dango.png`.
- **path**: The full absolute path of this file (its name and any directories it's in).
- **folder**: Just the folders this file is in (without its filename). For example, the folder of `/folder1/folder2/dango.png` would be `/folder1/folder2/`.
- **name**: Just the name of this file, without the directories it's in. For example, the name of `/folder1/folder2/dango.png` would be `dango.png`.
- **path**: The full absolute path of this file; its name and any directories it's in.
- **folder**: Just the folders this file is in, without its filename. For example, the folder of `/folder1/folder2/dango.png` would be `/folder1/folder2/`.
- **modification date**: A human-readable version of the file's modification date. The output of this depends on the browser's language and possibly other factors.
- **long modification date**: A longer human-readable version of the file's modification date. The output of this depends on the browser's language and possibly other factors.
- **modified days since 2000**: The modification date of the file, as days since 2000.
Expand Down Expand Up @@ -250,7 +250,7 @@ Moves the current directory (the default origin of most file operations) to the
```scratch
(contents of directory [.] :: #a49a3a)
```
Returns a list of files in a directory, as a JSON array (which you can parse with the JSON extension).
Returns a list of files in a directory as a JSON array, which you can parse with the JSON extension.

---

Expand Down
2 changes: 1 addition & 1 deletion docs/DNin/wake-lock.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Wake Lock feature allows you to keep your computer's screen on while a proje
## Activating and Releasing Wake Lock

```scratch
set wake lock to [on v] :: #0FBD8C
set wake lock to (on v) :: #0FBD8C
```
This block will activate wake lock.

Expand Down
2 changes: 1 addition & 1 deletion docs/Lily/Skins.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Check whether a skin is actually loaded. This becomes true **after** the block h
---

```scratch
((width v) of [my skin] :: #6b56ff)
((width v) of skin [my skin] :: #6b56ff)
```
Get the width/height of a skin. The values are rounded.

Expand Down
Loading

0 comments on commit a5c6aee

Please sign in to comment.