Skip to content

Commit 172cad4

Browse files
authored
Load embeddable from extension, increase load speed (#34)
1 parent 4f1cf19 commit 172cad4

File tree

10 files changed

+1833
-273
lines changed

10 files changed

+1833
-273
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ npm-debug.log*
3737

3838
docs/esdoc
3939
yarn.lock
40+
*.txt
41+
*.pem

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ Created with [ringcentral-embeddable-extension-factory](https://github.com/ringc
5050
# install dependencies, requires nodejs8.10+
5151
npm i
5252

53+
# download embeddable
54+
npm run down
55+
5356
# create config file, and set proper thirdPartyConfigs.serviceName
5457
cp config.sample.js config.js
5558

bin/deploy-key.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* edit manifest.json's key prop to generate static extension id
3+
*/
4+
5+
const { readFileSync, writeFileSync } = require('fs')
6+
const { resolve } = require('path')
7+
const p = resolve(__dirname, '..', 'dist', 'manifest.json')
8+
const conf = require('../config.default')
9+
10+
function run () {
11+
const js = JSON.parse(readFileSync(p).toString())
12+
js.key = conf.extensionKey
13+
writeFileSync(p, JSON.stringify(js, null, 2))
14+
}
15+
16+
run()

bin/download-adapter.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* download adapter.js of embeddable
3+
*/
4+
5+
const {
6+
exec,
7+
cp,
8+
rm
9+
} = require('shelljs')
10+
// const replace = require('replace-in-file')
11+
// const _ = require('lodash')
12+
// const from = 'https://ringcentral.github.io/ringcentral-embeddable'
13+
// const id = 'mghgakfckjffpapcfagahoabncnoajpi'
14+
// const options = {
15+
// files: 'dist/embeddable/*.*',
16+
// from: new RegExp(_.escapeRegExp(from), 'gm'),
17+
// to: `chrome-extension://${id}`
18+
// }
19+
20+
async function run () {
21+
rm('-rf', 'dist/embeddable')
22+
rm('-rf', 'extension-build.zip')
23+
exec('wget https://github.com/ringcentral/ringcentral-embeddable/archive/extension-build.zip')
24+
exec('unzip -a extension-build.zip')
25+
cp('-r', 'ringcentral-embeddable-extension-build', 'dist/embeddable')
26+
rm('-rf', 'ringcentral-embeddable-extension-build')
27+
// const r = await replace(options)
28+
// console.log(r)
29+
}
30+
31+
run()

bin/key-generate.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const {
2+
exec,
3+
cd,
4+
echo
5+
} = require('shelljs')
6+
7+
function run () {
8+
cd('bin')
9+
echo('creating key.pem')
10+
exec('2>/dev/null openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -out key.pem')
11+
echo('creating key')
12+
exec('2>/dev/null openssl rsa -in key.pem -pubout -outform DER | openssl base64 -A > key.txt')
13+
echo('creating extension id')
14+
exec('2>/dev/null openssl rsa -in key.pem -pubout -outform DER | shasum -a 256 | head -c32 | tr 0-9a-f a-p')
15+
echo('')
16+
echo('done')
17+
}
18+
19+
run()

0 commit comments

Comments
 (0)