-
Notifications
You must be signed in to change notification settings - Fork 67
/
install.sh
42 lines (38 loc) · 2.31 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
LF=$(printf '\\\012_')
LF=${LF%_}
EXTENSION_NAME=ML2Scratch
EXTENSION_ID=ml2scratch
COLLABORATOR=champierre
EXTENSION_DESCRIPTION="ML2Scratch Blocks."
cd node_modules/scratch-vm
npm install [email protected]
cd ../../
mkdir -p node_modules/scratch-vm/src/extensions/scratch3_${EXTENSION_ID}
cp ${EXTENSION_ID}/scratch-vm/src/extensions/scratch3_${EXTENSION_ID}/index.js node_modules/scratch-vm/src/extensions/scratch3_${EXTENSION_ID}/
mv node_modules/scratch-vm/src/extension-support/extension-manager.js node_modules/scratch-vm/src/extension-support/extension-manager.js_orig
sed -e "s|class ExtensionManager {$|builtinExtensions['${EXTENSION_ID}'] = () => require('../extensions/scratch3_${EXTENSION_ID}');${LF}${LF}class ExtensionManager {|g" node_modules/scratch-vm/src/extension-support/extension-manager.js_orig > node_modules/scratch-vm/src/extension-support/extension-manager.js
mkdir -p src/lib/libraries/extensions/${EXTENSION_ID}
cp ${EXTENSION_ID}/scratch-gui/src/lib/libraries/extensions/${EXTENSION_ID}/${EXTENSION_ID}.png src/lib/libraries/extensions/${EXTENSION_ID}/
cp ${EXTENSION_ID}/scratch-gui/src/lib/libraries/extensions/${EXTENSION_ID}/${EXTENSION_ID}-small.png src/lib/libraries/extensions/${EXTENSION_ID}/
mv src/lib/libraries/extensions/index.jsx src/lib/libraries/extensions/index.jsx_orig
DESCRIPTION="\
{${LF}\
name: '${EXTENSION_NAME}',${LF}\
extensionId: '${EXTENSION_ID}',${LF}\
collaborator: '${COLLABORATOR}',${LF}\
iconURL: ${EXTENSION_ID}IconURL,${LF}\
insetIconURL: ${EXTENSION_ID}InsetIconURL,${LF}\
description: (${LF}\
<FormattedMessage${LF}\
defaultMessage='${EXTENSION_DESCRIPTION}'${LF}\
description='${EXTENSION_DESCRIPTION}'${LF}\
id='gui.extension.${EXTENSION_ID}blocks.description'${LF}\
/>${LF}\
),${LF}\
featured: true,${LF}\
disabled: false,${LF}\
internetConnectionRequired: true,${LF}\
bluetoothRequired: false${LF}\
},"
sed -e "s|^export default \[$|import ${EXTENSION_ID}IconURL from './${EXTENSION_ID}/${EXTENSION_ID}.png';${LF}import ${EXTENSION_ID}InsetIconURL from './ml2scratch/ml2scratch-small.png';${LF}${LF}export default [${LF}${DESCRIPTION}|g" src/lib/libraries/extensions/index.jsx_orig > src/lib/libraries/extensions/index.jsx