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

Promote circle ci changes to master #63

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
95ff4a6
Setup circle remove travis
meyerhot95 Sep 21, 2022
7befdde
Merge pull request #62 from LLK/tsm/circle-ci
meyerhot95 Sep 26, 2022
929146c
Merge branch 'master' into develop
meyerhot95 Oct 4, 2022
7132208
Config fixes
meyerhot95 Oct 4, 2022
db4d830
Cleanup
meyerhot95 Oct 4, 2022
6007f14
Quick test
meyerhot95 Oct 4, 2022
fe8ee93
Correct branch filtering
meyerhot95 Oct 4, 2022
8daab1b
Test new logic
meyerhot95 Oct 5, 2022
ffd1869
Test new logic 2
meyerhot95 Oct 5, 2022
2b131ff
Revert new logic
meyerhot95 Oct 5, 2022
7571f3a
No unnecessary and
meyerhot95 Oct 5, 2022
e0b6d49
Merge pull request #64 from meyerhot95/tsm/circleci-updates
meyerhot95 Oct 6, 2022
b393107
chore: add github directory and associated files
Dec 8, 2023
1b9a9b3
ci: add build steps and bump node version
Dec 8, 2023
0859d89
chore: delete circle config
Dec 8, 2023
0f4220d
Merge pull request #65 from scratchfoundation/rd/ENG-50/transition-sc…
Dec 14, 2023
0493a1f
Construct costume hash using assetId and dataFormat when md5ext is mi…
rfronczyk Oct 3, 2024
fb0d6a4
Add backdrops data to analysis output for sb3 projects
rfronczyk Oct 3, 2024
e0fce50
Add backdrops data to analysis output for sb2 projects
rfronczyk Oct 3, 2024
15a9463
Fix handling of primitive blocks: list and variable.
rfronczyk Oct 8, 2024
99b29f8
Change list block name
rfronczyk Oct 9, 2024
7570cb7
Merge pull request #68 from rfronczyk/DPR-428-handle-costumes-without…
colbygk Oct 10, 2024
c4a89d9
Merge pull request #70 from rfronczyk/DPR-429-handle-list-and-variabl…
colbygk Oct 10, 2024
2dc7d35
Add check if stage costumes is an array
rfronczyk Oct 11, 2024
e43d2a4
Merge pull request #69 from rfronczyk/DPR-430-add-backdrops
colbygk Oct 11, 2024
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@scratchfoundation/scratch-engineering
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build-scratch-analysis
on:
push:
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install Dependencies
run: npm ci
- name: Run Tests
run: npm test
- name: Semantic Release
if: github.ref_name == 'master'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx --no -- semantic-release



1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
## NPM
/node_modules
npm-*
package-lock.json

## Code Coverage
.nyc_output/
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

24 changes: 24 additions & 0 deletions lib/sb2.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ const extract = function (project, attribute, id, hash) {
return result;
};

/**
* Extract summary information about backdrops including
* count, list of backdrop names and list of backdrop hashes.
* Backdrops are a subset of all costumes.
* Backdrops are a costumes from the stage object.
* @param {object} project Project object (SB2 format)
* @return {object} Summary information
*/
const backdrops = function (project) {
let stageCostumes = project.costumes;

if (!Array.isArray(stageCostumes)) {
return {count: 0, id: [], hash: []};
}

return {
count: stageCostumes.length,
id: stageCostumes.map((sc) => sc.costumeName),
hash: stageCostumes.map((sc) => sc.baseLayerMD5)
};
};

/**
* Extract number of sprites from a project object. Will attempt to ignore
* "children" which are not sprites.
Expand Down Expand Up @@ -227,6 +249,8 @@ module.exports = function (project, callback) {
costumes: extract(project, 'costumes', 'costumeName', 'baseLayerMD5')
};

meta.backdrops = backdrops(project);

meta.cloud = cloud(project, meta.variables.id);

// Sprites
Expand Down
47 changes: 45 additions & 2 deletions lib/sb3.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@ const scripts = function (targets) {
};
};

const costumes = function (targets) {
// Storage objects
let occurrences = 0;
let nameList = [];
let hashList = [];

for (let t in targets) {
for (let a in targets[t].costumes) {
const costume = targets[t].costumes[a];
occurrences++;
nameList.push(costume.name);

let hash = costume.md5ext || `${costume.assetId}.${costume.dataFormat}`;
hashList.push(hash);
}
}

// field are named this way to keep backward compatibility
return {
count: occurrences,
id: nameList,
hash: hashList
};
};

const variables = function (targets, attribute) {
// Storage objects
let occurrences = 0;
Expand Down Expand Up @@ -92,10 +117,22 @@ const blocks = function (targets) {
for (let t in targets) {
for (let a in targets[t].blocks) {
const block = targets[t].blocks[a];
let opcode = block.opcode;

// Check for primitive blocks which don't have the opcode field
if (typeof opcode === 'undefined') {
switch (block[0]) {
case (12):
opcode = 'data_variable';
break;
case (13):
opcode = 'data_listcontents';
break;
}
}

// Get opcode and check variable manipulation for the presence of
// cloud variables
let opcode = block.opcode;
if (opcode === 'data_setvariableto' || opcode === 'data_changevariableby') {
if (isArgCloudVar(block.fields.VARIABLE[1])) {
opcode += '_cloud';
Expand Down Expand Up @@ -133,6 +170,10 @@ const metadata = function (meta) {
return obj;
};

const stageTargets = function (targets) {
return targets.filter((target) => target.isStage);
};

module.exports = function (project, callback) {
const meta = {
scripts: scripts(project.targets),
Expand All @@ -141,7 +182,9 @@ module.exports = function (project, callback) {
lists: variables(project.targets, 'lists'),
comments: extract(project.targets, 'comments'),
sounds: extract(project.targets, 'sounds', 'name', 'md5ext'),
costumes: extract(project.targets, 'costumes', 'name', 'md5ext'),
costumes: costumes(project.targets),
// backdrops are costumes on the stage target
backdrops: costumes(stageTargets(project.targets)),
sprites: sprites(project.targets),
blocks: blocks(project.targets),
extensions: extensions(project.extensions),
Expand Down
Loading
Loading