scratch-storage 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +70 -0
- package/README.md +2 -1
- package/dist/node/scratch-storage.js.map +1 -1
- package/dist/web/scratch-storage.js.map +1 -1
- package/dist/web/scratch-storage.min.js.map +1 -1
- package/package.json +2 -2
- package/test/integration/download-known-assets.js +27 -30
- package/.travis.yml +0 -24
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scratch-storage",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Load and store project and asset files for Scratch 3.0",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"homepage": "https://github.com/LLK/scratch-storage#readme",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/LLK/scratch-storage.git",
|
|
10
|
-
"sha": "
|
|
10
|
+
"sha": "2f6a562d46c4393cc70ab8c1b4350beaf6c07675"
|
|
11
11
|
},
|
|
12
12
|
"main": "./dist/node/scratch-storage.js",
|
|
13
13
|
"browser": "./src/index.js",
|
|
@@ -20,16 +20,17 @@ test('constructor', t => {
|
|
|
20
20
|
* @property {DataFormat} [ext] - Optional: the asset's data format / file extension.
|
|
21
21
|
*/
|
|
22
22
|
const testAssets = [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
// TODO: mock project download, since we can no longer download projects directly
|
|
24
|
+
// {
|
|
25
|
+
// type: storage.AssetType.Project,
|
|
26
|
+
// id: '117504922',
|
|
27
|
+
// md5: null // don't check MD5 for project without revision ID
|
|
28
|
+
// },
|
|
29
|
+
// {
|
|
30
|
+
// type: storage.AssetType.Project,
|
|
31
|
+
// id: '117504922.d6ae1ffb76f2bc83421cd3f40fc4fd57',
|
|
32
|
+
// md5: '1225460702e149727de28bff4cfd9e23'
|
|
33
|
+
// },
|
|
33
34
|
{
|
|
34
35
|
type: storage.AssetType.ImageVector,
|
|
35
36
|
id: 'f88bf1935daea28f8ca098462a31dbb0', // cat1-a
|
|
@@ -65,9 +66,9 @@ const testAssets = [
|
|
|
65
66
|
}
|
|
66
67
|
];
|
|
67
68
|
|
|
68
|
-
test('
|
|
69
|
+
test('addWebStore', t => {
|
|
69
70
|
t.doesNotThrow(() => {
|
|
70
|
-
storage.
|
|
71
|
+
storage.addWebStore(
|
|
71
72
|
[storage.AssetType.Project],
|
|
72
73
|
asset => {
|
|
73
74
|
const idParts = asset.assetId.split('.');
|
|
@@ -77,7 +78,7 @@ test('addWebSource', t => {
|
|
|
77
78
|
});
|
|
78
79
|
});
|
|
79
80
|
t.doesNotThrow(() => {
|
|
80
|
-
storage.
|
|
81
|
+
storage.addWebStore(
|
|
81
82
|
[storage.AssetType.ImageVector, storage.AssetType.ImageBitmap, storage.AssetType.Sound],
|
|
82
83
|
asset => `https://cdn.assets.scratch.mit.edu/internalapi/asset/${asset.assetId}.${asset.dataFormat}/get/`
|
|
83
84
|
);
|
|
@@ -86,29 +87,25 @@ test('addWebSource', t => {
|
|
|
86
87
|
});
|
|
87
88
|
|
|
88
89
|
test('load', t => {
|
|
89
|
-
const
|
|
90
|
-
|
|
90
|
+
const assetChecks = testAssets.map(async assetInfo => {
|
|
91
|
+
const asset = await storage.load(assetInfo.type, assetInfo.id, assetInfo.ext)
|
|
92
|
+
.catch(e => {
|
|
93
|
+
// tap's output isn't great if we just let it catch the unhandled promise rejection
|
|
94
|
+
// wrapping it like this makes a failure much easier to read in the test output
|
|
95
|
+
throw new Error(`failed to load ${assetInfo.type.name} asset with id=${assetInfo.id} (e=${e})`);
|
|
96
|
+
});
|
|
91
97
|
t.type(asset, storage.Asset);
|
|
92
|
-
t.
|
|
93
|
-
t.
|
|
98
|
+
t.equal(asset.assetId, assetInfo.id);
|
|
99
|
+
t.equal(asset.assetType, assetInfo.type);
|
|
94
100
|
t.ok(asset.data.length);
|
|
95
101
|
|
|
96
102
|
// Web assets should come back as clean
|
|
97
|
-
t.
|
|
103
|
+
t.ok(asset.clean);
|
|
98
104
|
|
|
99
105
|
if (assetInfo.md5) {
|
|
100
|
-
t.
|
|
106
|
+
t.equal(md5(asset.data), assetInfo.md5);
|
|
101
107
|
}
|
|
102
|
-
};
|
|
103
|
-
for (let i = 0; i < testAssets.length; ++i) {
|
|
104
|
-
const assetInfo = testAssets[i];
|
|
105
|
-
|
|
106
|
-
let promise = storage.load(assetInfo.type, assetInfo.id, assetInfo.ext);
|
|
107
|
-
t.type(promise, 'Promise');
|
|
108
|
-
|
|
109
|
-
promise = promise.then(asset => checkAsset(assetInfo, asset));
|
|
110
|
-
promises.push(promise);
|
|
111
|
-
}
|
|
108
|
+
});
|
|
112
109
|
|
|
113
|
-
return Promise.all(
|
|
110
|
+
return Promise.all(assetChecks);
|
|
114
111
|
});
|
package/.travis.yml
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
sudo: false
|
|
2
|
-
language: node_js
|
|
3
|
-
cache:
|
|
4
|
-
directories:
|
|
5
|
-
- node_modules
|
|
6
|
-
node_js:
|
|
7
|
-
- "10"
|
|
8
|
-
install:
|
|
9
|
-
- npm install
|
|
10
|
-
- npm update
|
|
11
|
-
- npm prune
|
|
12
|
-
script:
|
|
13
|
-
- commitlint-travis
|
|
14
|
-
- npm run lint
|
|
15
|
-
- npm run build
|
|
16
|
-
- npm run tap
|
|
17
|
-
deploy:
|
|
18
|
-
- provider: script
|
|
19
|
-
on:
|
|
20
|
-
branch:
|
|
21
|
-
- master
|
|
22
|
-
- develop
|
|
23
|
-
skip_cleanup: true
|
|
24
|
-
script: npm run semantic-release
|