Reland "Updates node_modules and update script"
This is a reland of 4df552c6524c91c8d94ed318eedcf288a72a064f
Original change's description:
> Updates node_modules and update script
>
> Change-Id: I3fcf49bc416301a030d298cfc48c448bfeba4335
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1878808
> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Paul Lewis <aerotwist@chromium.org>
Change-Id: I97d1442c21420488fadde3f17f67cd4e3b959be6
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1880030
Commit-Queue: Paul Lewis <aerotwist@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
diff --git a/scripts/manage_node_deps.py b/scripts/manage_node_deps.py
index b4762f5..f6cd44b 100644
--- a/scripts/manage_node_deps.py
+++ b/scripts/manage_node_deps.py
@@ -17,15 +17,19 @@
"@types/chai": "4.2.0",
"@types/mocha": "5.2.7",
"chai": "4.2.0",
+ "escodegen": "1.12.0",
"eslint": "6.0.1",
+ "esprima": "git+https://git@github.com/ChromeDevTools/esprima.git#4d0f0e18bd8d3731e5f931bf573af3394cbf7cbe",
+ "handlebars": "^4.3.1",
"karma": "4.2.0",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "3.1.0",
+ "karma-coverage-istanbul-instrumenter": "^1.0.1",
+ "karma-coverage-istanbul-reporter": "^2.1.0",
"karma-mocha": "1.3.0",
"karma-typescript": "4.1.1",
"mocha": "6.2.0",
- "escodegen": "1.12.0",
- "esprima": "git+https://git@github.com/jquery/esprima.git#fe13460e646a0adc3c434ca8c478264ca2e78cec",
+ "rollup": "^1.23.1",
"typescript": "3.5.3"
}
@@ -75,12 +79,37 @@
return False
+def remove_package_json_entries():
+ with open(devtools_paths.package_json_path(), 'r+') as pkg_file:
+ try:
+ pkg_data = json.load(pkg_file)
+
+ # Remove the dependencies and devDependencies from the root package.json
+ # so that they can't be used to overwrite the node_modules managed by this file.
+ for key in pkg_data.keys():
+ if key.find(u'dependencies') == 0 or key.find(u'devDependencies') == 0:
+ pkg_data.pop(key)
+
+ pkg_file.truncate(0)
+ pkg_file.seek(0)
+ json.dump(pkg_data, pkg_file, indent=2, sort_keys=True)
+ except:
+ print('Unable to fix: %s' % pkg)
+ return True
+ return False
+
+
def install_deps():
clean_node_modules()
- exec_command = ['npm', 'install', '--no-save']
+ exec_command = ['npm', 'install', '--save-dev']
for pkg, version in DEPS.items():
- exec_command.append('%s@%s' % (pkg, version))
+ # For git URLs we append the url rather than package@version, since the package@version
+ # formulation doesn't work.
+ if version.find(u'git+') == 0:
+ exec_command.append('%s' % version)
+ else:
+ exec_command.append('%s@%s' % (pkg, version))
errors_found = False
npm_proc_result = subprocess.check_call(exec_command, cwd=devtools_paths.root_path())
@@ -92,6 +121,10 @@
return True
errors_found = strip_private_fields()
+ if errors_found:
+ return True
+
+ errors_found = remove_package_json_entries()
return errors_found