diff --git a/.gitignore b/.gitignore index 24d5788003525f864748d0714b6ae80152122a8e..a556e41097bac6949842f2906a553797bc629bbb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ /resources/static/build /resources/static/production /resources/static/i18n +/resources/static/common/js/lib/bidbundle.js +/resources/static/dialog/views/site .DS_Store Thumbs.db /locale @@ -18,4 +20,4 @@ Thumbs.db /automation-tests/credentials.yaml /automation-tests/sauce.yaml automation-tests/persona_server/results/* -/automation-tests/chromedriver.log \ No newline at end of file +/automation-tests/chromedriver.log diff --git a/package.json b/package.json index f4be9a5a99f4cb15cd86ca72d797f8c99aad56a6..4cede433881efdc792c437a889f0ae8d2d0fe0f7 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ }, "scripts": { "preinstall": "./scripts/lockdown", - "postinstall": "node ./scripts/generate_ephemeral_keys.js", + "postinstall": "node ./scripts/postinstall.js", "test": "./scripts/test", "start": "node ./scripts/run_locally.js" }, diff --git a/resources/static/common/js/lib/bidbundle.js b/resources/static/common/js/lib/bidbundle.js deleted file mode 120000 index 00c7194bcdfbd8c359d6471c712c07c53bf442b0..0000000000000000000000000000000000000000 --- a/resources/static/common/js/lib/bidbundle.js +++ /dev/null @@ -1 +0,0 @@ -../../../../../node_modules/jwcrypto/bidbundle.js \ No newline at end of file diff --git a/resources/static/dialog/views/site b/resources/static/dialog/views/site deleted file mode 120000 index f5a3723db214a8e9676c1dbf727502ecb94bce16..0000000000000000000000000000000000000000 --- a/resources/static/dialog/views/site +++ /dev/null @@ -1 +0,0 @@ -../../../views/ \ No newline at end of file diff --git a/scripts/awsbox/post_deploy.sh b/scripts/awsbox/post_deploy.sh index 766cc41a06822f9d9a07f9661997867e55dcc657..ef422034083e008593539d9c9fa5197c9098185b 100755 --- a/scripts/awsbox/post_deploy.sh +++ b/scripts/awsbox/post_deploy.sh @@ -2,7 +2,7 @@ if [ ! -f $HOME/var/root.cert ] ; then echo ">> generating keypair" - scripts/generate_ephemeral_keys.js + scripts/postinstall.js mv var/root.{cert,secretkey} $HOME/var else echo ">> no keypair needed. you gots one" diff --git a/scripts/postinstall.js b/scripts/postinstall.js new file mode 100644 index 0000000000000000000000000000000000000000..9af5bec429e8dd82748b8a95b986d203adc4a619 --- /dev/null +++ b/scripts/postinstall.js @@ -0,0 +1,42 @@ +// make symlinks +var fs = require('fs'); +var path = require('path'); +var existsSync = fs.existsSync || path.existsSync; + +// symlink'ed directories work fine in both *nix and Windows +function relativeLink(src, dest) { + src = path.join(__dirname, src); + dest = path.join(__dirname, dest); + var destParent = path.dirname(dest); + var cwd = process.cwd(); + process.chdir(destParent); + + if (existsSync(dest)) { + fs.unlinkSync(dest); + } + var relSrc = path.relative(destParent, src); + fs.symlinkSync(relSrc, dest, 'junction'); + process.chdir(cwd); +} + +// Windows requires Administrator cmd prompt to make file links, +// so just make a copy instead. +function copy(src, dest) { + src = path.join(__dirname, src); + dest = path.join(__dirname, dest); + fs.writeFileSync(dest, fs.readFileSync(src)); +} + +copy('../node_modules/jwcrypto/bidbundle.js', '../resources/static/common/js/lib/bidbundle.js'); +relativeLink('../resources/views', '../resources/static/dialog/views/site'); + + +// generate ephemeral keys +var child_process = require('child_process'); +function node(script) { + var cp = child_process.spawn('node', [path.join(__dirname, script)]); + cp.stdout.pipe(process.stdout); + cp.stderr.pipe(process.stderr); +} + +node('./generate_ephemeral_keys.js');