Skip to content

Commit

Permalink
Downloading Node and NPM deps via gclient sync.
Browse files Browse the repository at this point in the history
This is necessary for WebUI to harness several Node based tools
to speed up performance, as well as remove generated code that is
currently checked in as source code.

Discussion occurred at:
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/H2IqgqwdUqs/yn_6_z0cDwAJ

BUG=673825

Review-Url: https://codereview.chromium.org/2574033002
Cr-Commit-Position: refs/heads/master@{#443777}
  • Loading branch information
freshp86 authored and Commit bot committed Jan 14, 2017
1 parent 8599012 commit cbee6ab
Show file tree
Hide file tree
Showing 13 changed files with 1,427 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ vs-chromium-project.txt
/third_party/nacl_sdk_binaries/
/third_party/netty-tcnative/src
/third_party/netty4/src
/third_party/node/linux
/third_party/node/mac
/third_party/node/node_modules
/third_party/node/*.tar.gz
/third_party/node/win
/third_party/nss
/third_party/objenesis/lib/*.jar
/third_party/omaha/src/omaha
Expand Down
50 changes: 50 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,56 @@ hooks = [
'--version',
],
},

# Pull down Node binaries for WebUI toolchain.
{
'name': 'node_linux64',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=linux*',
'--extract',
'--no_auth',
'--bucket', 'chromium-nodejs/6.9.4',
'-s', 'src/third_party/node/linux/node-linux-x64.tar.gz.sha1',
],
},
{
'name': 'node_mac',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=darwin',
'--extract',
'--no_auth',
'--bucket', 'chromium-nodejs/6.9.4',
'-s', 'src/third_party/node/mac/node-darwin-x64.tar.gz.sha1',
],
},
{
'name': 'node_win',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=win32',
'--no_auth',
'--bucket', 'chromium-nodejs/6.9.4',
'-s', 'src/third_party/node/win/node.exe.sha1',
],
},

# Pull down NPM dependencies for WebUI toolchain.
{
'name': 'webui_node_modules',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--extract',
'--no_auth',
'--bucket', 'chromium-nodejs',
'-s', 'src/third_party/node/node_modules.tar.gz.sha1',
],
},
]

recursedeps = [
Expand Down
1,192 changes: 1,192 additions & 0 deletions third_party/node/LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions third_party/node/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dbeam@chromium.org
dpapad@chromium.org
17 changes: 17 additions & 0 deletions third_party/node/README.chromium
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Name: Node JS
Short Name: node
URL: https://github.com/nodejs/node
Version: 6.9.4
Revision: f098f8295c407e5a5126b501ed5f1aa80bd86106
Date: Tue Dec 06 2016 18:07:35 GMT-0800 (PST)
License: NodeJS
License File: NOT_SHIPPED
Security Critical: no

Description:
Node binaries and NPM modules necessary for buliding Chrome's WebUI.
Use update_node_binaries to update Node binaries and update_npm_deps to
update NPM dependencies.

Local Modifications:
No modifications.
1 change: 1 addition & 0 deletions third_party/node/linux/node-linux-x64.tar.gz.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eb63c12c3b19b96b9142e572c3c2cfaa27e13191
1 change: 1 addition & 0 deletions third_party/node/mac/node-darwin-x64.tar.gz.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b5ac19fd2f8afaa20f698972d2b0bb1056dc258a
1 change: 1 addition & 0 deletions third_party/node/node_modules.tar.gz.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ce62710ad9f651016248574ecd7b07e86dd01f2b
15 changes: 15 additions & 0 deletions third_party/node/npm_exclude.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*/.*
*/example/
*/examples/
*.html
hydrolysis/hydrolysis.js
*/jsdoc2md/
*.md
*.png
*.sh
*.svg
*/test/
*.ts
*/@types/
*.woff
*.yml
11 changes: 11 additions & 0 deletions third_party/node/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "webui-node-modules",
"version": "1.0.0",
"author": "dpapad@chromium.org",
"dependencies": {
"crisper": "2.0.2",
"polymer-css-build": "0.0.7",
"uglifyjs": "2.4.10",
"vulcanize": "1.15.2"
}
}
93 changes: 93 additions & 0 deletions third_party/node/update_node_binaries
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash

# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Script for updating Node binaries.
# 1) Update NODE_VERSION variable below to the desired version.
# 2) Run this script.
# 3) Upload the binaries to the Google Storage bucket (commands to upload
# binaries are printed at step 2, look for "gsutil.py").
# 4) Land a CL with the changes generated by this script.

set -eu
cd "$(dirname "$0")"

BASE_URL="https://nodejs.org/dist"
NODE_VERSION="v6.9.4"

update_unix() {
local SUFFIX="$1"
local FOLDER="$2"
local FILENAME="node-${NODE_VERSION}-${SUFFIX}.tar.gz"
local URL="${BASE_URL}/${NODE_VERSION}/${FILENAME}"

rm -f "${FOLDER}/${FILENAME}"
wget -P "${FOLDER}/" "${URL}"

# Check SHASUMS256 of downloaded binary.
local sha256_expected
sha256_expected="$(grep "$FILENAME" SHASUMS256.txt | cut -d ' ' -f1)"
local sha256_actual
sha256_actual="$(sha256sum "${FOLDER}/${FILENAME}" | cut -d ' ' -f1)"

if [ "${sha256_expected}" != "${sha256_actual}" ]; then
echo "SHA256 mismatch. Exiting..."
exit 1
fi

# Unpack temporarily, delete NPM symlink and re-pack.
tar xfz "${FOLDER}/${FILENAME}" -C "${FOLDER}/"
rm "${FOLDER}/${FILENAME}"
rm "${FOLDER}/node-${NODE_VERSION}-${SUFFIX}/bin/npm"

# Drop the version info from the name, since it is redundant and would make
# rolling new versions more involved.
rm -rf "${FOLDER}/node-${SUFFIX}/"
mv "${FOLDER}/node-${NODE_VERSION}-${SUFFIX}/" "${FOLDER}/node-${SUFFIX}/"
tar cfz "${FOLDER}/node-${SUFFIX}.tar.gz" -C "${FOLDER}" "node-${SUFFIX}/"
local sha1
sha1="$(sha1sum ${FOLDER}/node-${SUFFIX}.tar.gz | cut -d ' ' -f1)"
echo "${sha1}" > "${FOLDER}/node-${SUFFIX}.tar.gz.sha1"
echo "Please execute manually the following:"
echo "> gsutil.py cp ${FOLDER}/node-${SUFFIX}.tar.gz gs://chromium-nodejs/${NODE_VERSION:1}/${sha1}"
echo "DONE updating for ${SUFFIX}."
}

update_win() {
local FILENAME="node.exe"
local FOLDER="win"
local WINDOWS_URL="${BASE_URL}/${NODE_VERSION}/win-x64/${FILENAME}"
rm -f "${FOLDER}/${FILENAME}"
wget -P "${FOLDER}/" "${WINDOWS_URL}"

# Check SHASUMS256 of downloaded binary.
local sha256_expected
sha256_expected="$(grep "win-x64/$FILENAME" SHASUMS256.txt | cut -d ' ' -f1)"
local sha256_actual
sha256_actual="$(sha256sum "${FOLDER}/${FILENAME}" | cut -d ' ' -f1)"

if [ "${sha256_expected}" != "${sha256_actual}" ]; then
echo "SHA256 mismatch. Exiting..."
exit 1
fi

local sha1
sha1="$(sha1sum ${FOLDER}/node.exe | cut -d ' ' -f1)"
echo "${sha1}" > "${FOLDER}/node.exe.sha1"
echo "Please execute manually the following:"
echo "> gsutil.py cp ${FOLDER}/node.exe gs://chromium-nodejs/${NODE_VERSION:1}/${sha1}"
echo "DONE updating Windows."
}

# First download checksum file.
rm "SHASUMS256.txt"
wget "https://nodejs.org/dist/latest-v6.x/SHASUMS256.txt"

update_unix "darwin-x64" "mac"
update_unix "linux-x64" "linux"
update_win

# Update DEPS to point to the new Google Storage bucket subfolder.
sed -i "s@\(chromium-nodejs/\)\([0-9\.]\)\+@\1${NODE_VERSION:1}@" ../../DEPS
38 changes: 38 additions & 0 deletions third_party/node/update_npm_deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Script for updating WebUI's NPM deps.
# 1) Update package.json file to point to the desired version.
# 2) Run this script.
# 3) Upload the compressed node_modules.tar.gz file to the Google Storage
# bucket (commands to upload binaries are printed at step 2).
# 4) Land a CL with the changes generated by this script.

set -eu
cd "$(dirname "$0")"

rm -rf node_modules

npm install --no-bin-links --only=prod
rsync -c --delete -r -q --exclude-from="npm_exclude.txt" \
--prune-empty-dirs "node_modules/" "node_modules_filtered/"

echo -e "\n---------------------------------------------------------"
echo "Before filtering:" size: $(du -h node_modules/ | tail -n1 | cut -f1) ", files: " $(find node_modules/ -type f | wc -l)
rm -r node_modules
mv node_modules_filtered node_modules

echo "After filtering:" size: $(du -h node_modules/ | tail -n1 | cut -f1) ", files: " $(find node_modules/ -type f | wc -l)

tar cfz node_modules.tar.gz node_modules
echo "After compressing:" size: $(du -h node_modules.tar.gz | tail -n1 | cut -f1)

sha1="$(sha1sum node_modules.tar.gz | cut -d ' ' -f1)"
echo "${sha1}" > node_modules.tar.gz.sha1
echo "Please run the following manually to update Google Storage bucket:"
echo "> gsutil.py cp node_modules.tar.gz gs://chromium-nodejs/${sha1}"
echo "DONE"
echo -e "---------------------------------------------------------"
1 change: 1 addition & 0 deletions third_party/node/win/node.exe.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a5217c3b78a04dd8da80d4ee145577ea536a6cfc

0 comments on commit cbee6ab

Please sign in to comment.