Add DEPS, eleventy, and firebase configs.
This adds the DEPS entries needed to pull depot_tools in
plus the Node, Eleventy, and Firebase configs that we'll
use. These are all copied over from the development repo
in experimental/website.
Bug: 1260171
Change-Id: I26a5a4eb33f8caf79e756c908f38d6d99739d6ab
Reviewed-on: https://chromium-review.googlesource.com/c/website/+/3258089
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Struan Shrimpton <sshrimp@google.com>
diff --git a/scripts/fetch_node_modules.py b/scripts/fetch_node_modules.py
new file mode 100755
index 0000000..b08c35f
--- /dev/null
+++ b/scripts/fetch_node_modules.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Simple script to download the pinned Node modules from GCS.
+
+This script exists because the node_modules archive currently contains
+a node_modules/.bin directory with a bunch of symlinked files in it,
+and download_from_google_storage.py won't let you have archives with
+symlinks.
+
+In theory we should probably rebuild the node_modules distro without
+the ./bin directory (using `npm install --no-bin-lnks`) but that would
+cause the build scripts to fail and we'd have to replace `npmw` with
+something else.
+"""
+
+import argparse
+import hashlib
+import os
+import subprocess
+import sys
+import tarfile
+
+SRC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.parse_args()
+
+ with open(os.path.join(SRC_ROOT, 'node_modules.tar.gz.sha1')) as fp:
+ expected_sha1 = fp.read().strip()
+
+ actual_sha1 = None
+ tgz = os.path.join(SRC_ROOT, 'node_modules.tar.gz')
+ if os.path.exists(tgz):
+ with open(tgz, 'rb') as fp:
+ s = hashlib.sha1()
+ s.update(fp.read())
+ actual_sha1 = s.hexdigest()
+
+ # TODO(dpranke): Consider whether we should validate that node_modules/
+ # and all of the expected files exist as well.
+ if actual_sha1 == expected_sha1:
+ return 0
+
+ retcode = subprocess.call([
+ sys.executable,
+ os.path.join(SRC_ROOT, 'third_party', 'depot_tools', 'gsutil.py'),
+ 'cp',
+ 'gs://chromium-website-lob-storage/%s' % expected_sha1,
+ tgz
+ ])
+ if retcode:
+ return retcode
+
+ try:
+ # TODO(dpranke): download_from_google_storage puts in a fair amount
+ # of effort to not clobber an existing directory until it is sure it
+ # can extract the archive completely. Consider whether we should do
+ # the same.
+ with tarfile.open(tgz, 'r:gz') as tar:
+ tar.extractall(path=SRC_ROOT)
+ return 0
+ except Exception as e:
+ print(e)
+ return 1
+
+if __name__ == '__main__':
+ sys.exit(main())