Remove es6 module converter
This change is a revert for https://gerrit-review.googlesource.com/c/gerrit/+/256510 After conversion the tool can be safely removed. Change-Id: I31680f7096315c0d3b45bb7fd853ddba1290d254
This commit is contained in:
parent
daf0ec9543
commit
0e9f2cab38
@ -1,249 +0,0 @@
|
||||
# Temporary file - needed only for es6 module conversion
|
||||
# This is the main script to convert polygerrit to es6 modules.
|
||||
# Script makes a conversion, commit 2 changes and then remove all temporary changes in local folder.
|
||||
# Before run this script you must commit/rollback all changes.
|
||||
|
||||
# Script supports the following options options:
|
||||
# --rename-change-id - if specified, this ChangeId is used for renaming change
|
||||
# --convert-change-id - if specified, this ChangeId is used for convertion change
|
||||
|
||||
# Additional options (can be useful in case of problems/for debuging):
|
||||
# --clean-only - clean all changes made by this script. Use this option if the script fails
|
||||
# and you want to remove all changes made by this script
|
||||
# --force - run the script even if there are uncommited changes.
|
||||
# Warning: be careful. --clean-only and --force removes all uncommited changes in polygerrit-ui/app
|
||||
# directory + remove all uncommited changes in package.json and yarn.lock files
|
||||
|
||||
clean_temporary_changes() {
|
||||
git restore -- package.json
|
||||
git restore -- yarn.lock
|
||||
git restore --staged polygerrit-ui/app/
|
||||
git restore polygerrit-ui/app/
|
||||
git clean -f polygerrit-ui/app
|
||||
rm -rf polygerrit-ui/app/node_modules
|
||||
rm -rf polygerrit-ui/app/bower_components
|
||||
rm -rf polygerrit-ui/app/modulizer_out
|
||||
rm -rf polygerrit-ui/app/components
|
||||
bazel fetch @ui_npm//:node_modules
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
opts=$(getopt --long clean-only,force,rename-change-id:,convert-change-id: -- opt "$@")
|
||||
|
||||
eval set -- "$opts"
|
||||
|
||||
RENAME_COMMIT_MESSAGE_SUFFIX=""
|
||||
CONVERT_COMMIT_MESSAGE_SUFFIX=""
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
--clean-only)
|
||||
CLEAN_ONLY=1
|
||||
;;
|
||||
--force)
|
||||
FORCE=1
|
||||
;;
|
||||
--rename-change-id)
|
||||
shift
|
||||
RENAME_COMMIT_MESSAGE_SUFFIX=$'\n'"Change-Id: $1"
|
||||
;;
|
||||
--convert-change-id)
|
||||
shift
|
||||
CONVERT_COMMIT_MESSAGE_SUFFIX=$'\n'"Change-Id: $1"
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ "$CLEAN_ONLY" == "1" ]]; then
|
||||
clean_temporary_changes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ `git status --porcelain` && "$FORCE" != "1" ]]; then
|
||||
echo "Please commit your changes before continue or run the tool with --force flag"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Revert all changes made by this script, so script can be run with --force multiple times
|
||||
clean_temporary_changes
|
||||
|
||||
# Temporary install the polymer-modulizer tool
|
||||
bazel run @nodejs//:yarn add polymer-modulizer
|
||||
|
||||
# Update some links before run polymer-modulizer (--force to ignore already changed files)
|
||||
./polygerrit-links-updater.sh --force
|
||||
|
||||
# Updates inside polygerrit-ui/app directory
|
||||
DIR=$(pwd)
|
||||
cd polygerrit-ui/app
|
||||
|
||||
# Update link in tests
|
||||
|
||||
# Update html files - replace <script src=...> with <link rel="..."> and generate
|
||||
# .html files with a single tag <script src="...">
|
||||
# Without this update polymer-modulizer merges some .js files in other files.
|
||||
html_files=$(mktemp)
|
||||
generated_html_files=$(mktemp)
|
||||
find ./ -name '*.html' -type f \
|
||||
-not -path "*/node_modules/*" \
|
||||
-not -path "*/samples/*" \
|
||||
-not -path "*/gr-diff/gr-diff-root.html" \
|
||||
-not -path "*/embed/gr-diff.html" \
|
||||
-not -path "*/elements/change/gr-change-metadata/test/plugin.html" \
|
||||
-not -path "*/elements/change/gr-reply-dialog/test/plugin.html" \
|
||||
-not -path "*/elements/test/plugin.html" \
|
||||
-not -path "*/test/index.html" \
|
||||
-exec sh -c 'echo {}' \n \; >$html_files
|
||||
bazel run //tools/node_tools/polygerrit_app_preprocessor:script-tag-replacer-bin -- $DIR/polygerrit-ui/app $html_files $generated_html_files
|
||||
|
||||
# Temporary install bower component, so polymer-modulizer can find them
|
||||
bower install
|
||||
|
||||
# Create temporary files, so polymer-modulizer can find them
|
||||
mkdir -p components/web-component-tester/data
|
||||
cp bower_components/web-component-tester/data/a11ySuite.js components/web-component-tester/data
|
||||
mkdir -p components/wct-browser-legacy
|
||||
echo "" >components/wct-browser-legacy/browser.js
|
||||
|
||||
# The gr-embed-dashboard.html is not included in any other file.
|
||||
# Temporary add it to gr-app, so polymer-modulizer can find it
|
||||
echo "<link rel='import' href='./change-list/gr-embed-dashboard/gr-embed-dashboard.html'>" >>elements/gr-app.html
|
||||
|
||||
# Run polymer-modulizer, manually create the new gr-app.html entrypoint
|
||||
bazel run @npm//polymer-modulizer/bin:modulizer --run_under="cd $PWD && " -- --npm-version 1.0.0 --npm-name polygerrit-ui-dependencies --force --import-style name --package-type application
|
||||
echo "<script src='./gr-app.js' type='module'></script>" >modulizer_out/elements/gr-app.html
|
||||
|
||||
# Postprocessing after the polymer-modulizer tool
|
||||
find ./modulizer_out -name '*_test.html' -type f -not -path "*/node_modules/*" -exec sh -c 'sed -i "s/<script src=\"\/node_modules\/%40webcomponents/<script src=\"\/node_modules\/@webcomponents/g" {}' \n \;
|
||||
find ./modulizer_out -name '*_test.html' -type f -not -path "*/node_modules/*" -exec sh -c 'sed -i "s/<script src=\"\/node_modules\/@webcomponents\/webcomponentsjs\/webcomponents-bundle.js\"/<script src=\"\/node_modules\/@webcomponents\/webcomponentsjs\/webcomponents-lite.js\"/g" {}' \n \;
|
||||
|
||||
find ./modulizer_out -name '*_test.html' -type f -not -path "*/node_modules/*" -exec sh -c 'sed -i "/await readyToTest();/d" {}' \n \;
|
||||
find ./modulizer_out -name '*_test.html' -type f -not -path "*/node_modules/*" -exec sh -c 'sed -i "/import { a11ySuite } from/d" {}' \n \;
|
||||
find ./modulizer_out -name '*_test.html' -type f -not -path "*/node_modules/*" -exec sh -c 'sed -E -i "s/suite\(('.*'), async/suite(\1,/g" {}' \n \;
|
||||
sed -i '/import { Polymer } from /d' ./modulizer_out/elements/plugins/gr-external-style/gr-external-style_test.html
|
||||
|
||||
# Remove reference to gr-embed-dashboard.html
|
||||
sed -i "/import '.\/change-list\/gr-embed-dashboard\/gr-embed-dashboard.js';/d" modulizer_out/elements/gr-app.html
|
||||
|
||||
# Fix incorrect imports in gr-reply-dialog_test.html
|
||||
sed -i '/<script type="module" src="\/node_modules\/@polymer\/iron-overlay-behavior\/iron-overlay-manager.js"><\/script>/d' modulizer_out/elements/change/gr-reply-dialog/gr-reply-dialog_test.html
|
||||
sed -i "/import '\/node_modules\/@polymer\/iron-overlay-behavior\/iron-overlay-manager.js';/d" modulizer_out/elements/change/gr-reply-dialog/gr-reply-dialog_test.html
|
||||
sed -i "s/'\/node_modules\/@polymer\/iron-overlay-behavior\/iron-overlay-manager.js'/'@polymer\/iron-overlay-behavior\/iron-overlay-manager.js'/g" modulizer_out/elements/change/gr-reply-dialog/gr-reply-dialog_test.html
|
||||
|
||||
# Remove some generated directories
|
||||
rm -rf modulizer_out/node_modules
|
||||
rm -rf modulizer_out/polymer
|
||||
rm -rf modulizer_out/polymer-resin
|
||||
|
||||
# Remove temporary files which doesn't need for the next actions
|
||||
rm -rf components
|
||||
rm -rf bower_components
|
||||
cat $generated_html_files | xargs -n1 -d '\n' rm
|
||||
|
||||
# Undo all changes made to polygerrit-ui/app source code (the modulizer_out folder is not deleted)
|
||||
cd $DIR
|
||||
git restore polygerrit-ui/app/
|
||||
|
||||
# Remove files with empty templates (eslint and/or build will report an error if this list is not valid/full)
|
||||
rm polygerrit-ui/app/behaviors/gr-tooltip-behavior/gr-tooltip-behavior.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-admin-api/gr-admin-api.html \
|
||||
polygerrit-ui/app/elements/core/gr-reporting/gr-reporting.html \
|
||||
polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api.html \
|
||||
polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api.html \
|
||||
polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.html \
|
||||
polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-etag-decorator.html \
|
||||
polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.html \
|
||||
polygerrit-ui/app/elements/shared/gr-storage/gr-storage.html \
|
||||
polygerrit-ui/app/elements/shared/gr-select/gr-select.html \
|
||||
polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface-element.html
|
||||
|
||||
# To prevent history, renames manuall .html files to .js files and commit them as a separate change.
|
||||
find ./polygerrit-ui/app -name '*.html' -type f \
|
||||
-not -path "*/node_modules/*" \
|
||||
-not -path "*_test.html" \
|
||||
-not -path "*/modulizer_out/*" \
|
||||
-not -path "*/styles/themes/dark-theme.html" \
|
||||
-not -path "*/samples/*" \
|
||||
-not -path "*/gr-diff/gr-diff-root.html" \
|
||||
-not -path "*/embed/gr-diff.html" \
|
||||
-not -path "*/elements/change/gr-change-metadata/test/plugin.html" \
|
||||
-not -path "*/elements/change/gr-reply-dialog/test/plugin.html" \
|
||||
-not -path "*/elements/test/plugin.html" \
|
||||
-not -path "*/test/index.html" \
|
||||
-exec sh -c './rename-html.sh {}' \;
|
||||
|
||||
git commit -m "Rename .html files to .js files
|
||||
|
||||
Git doesn't track renaming if a file has too much changes. The change renames
|
||||
.html files to .js files. This change must be submitted together with es6
|
||||
modules conversion.
|
||||
|
||||
The build and tests fail on this change - this is expected and must be
|
||||
overwritten manually.
|
||||
|
||||
This change was produced automatically by ./es6-modules-converter.sh script.
|
||||
No manual changes were made.
|
||||
$RENAME_COMMIT_MESSAGE_SUFFIX"
|
||||
|
||||
# Postprocess the result of the polymer-modulizer tool:
|
||||
# The modulizer-postprocessor fixes import paths, makes minor changes and extracts templates
|
||||
# to a separate file.
|
||||
temp_file=$(mktemp)
|
||||
(cd $DIR/polygerrit-ui/app/modulizer_out && find ./ -name '*.js' -type f -not -path "*/node_modules/*" -exec sh -c 'echo {}' \n \; >$temp_file)
|
||||
bazel run //tools/node_tools/polygerrit_app_preprocessor:modulizer-postprocessor-bin -- $DIR/polygerrit-ui/app $temp_file
|
||||
|
||||
# Copy updated files from modulizer_out folder to the polygerrit-ui/app folder
|
||||
(cd $DIR/polygerrit-ui/app/modulizer_out && find ./ -name '*_test.html' -type f -not -path "*/node_modules/*" -exec sh -c "cp '{}' '$DIR/polygerrit-ui/app/{}'" \n \;)
|
||||
cp polygerrit-ui/app/modulizer_out/elements/gr-app.html polygerrit-ui/app/elements/gr-app.html
|
||||
|
||||
# Remove all temporary changes
|
||||
rm -rf polygerrit-ui/app/modulizer_out
|
||||
|
||||
git restore -- polygerrit-ui/app/package.json
|
||||
git restore -- polygerrit-ui/app/yarn.lock
|
||||
git restore -- package.json
|
||||
git restore -- yarn.lock
|
||||
|
||||
rm -rf polygerrit-ui/app/node_modules
|
||||
bazel fetch @ui_npm//:node_modules
|
||||
|
||||
rm -rf node_modules
|
||||
|
||||
# Sometimes the first fetch fails.
|
||||
# Do it twice
|
||||
set +e
|
||||
bazel fetch @npm//:node_modules
|
||||
set -e
|
||||
bazel fetch @npm//:node_modules
|
||||
npm run eslintfix
|
||||
|
||||
git add polygerrit-ui/app
|
||||
git commit -m "Convert polygerrit to es6-modules
|
||||
|
||||
This change replace all HTML imports with es6-modules. The only exceptions are:
|
||||
* gr-app.html file, which can be deleted only after updating the
|
||||
gerrit/httpd/raw/PolyGerritIndexHtml.soy file.
|
||||
* dark-theme.html which is loaded via importHref. Must be updated manually
|
||||
later in a separate change.
|
||||
|
||||
This change was produced automatically by ./es6-modules-converter.sh script.
|
||||
No manual changes were made.
|
||||
$CONVERT_COMMIT_MESSAGE_SUFFIX"
|
||||
|
||||
|
||||
echo "Conversion complete. You can push your changes."
|
@ -1,21 +0,0 @@
|
||||
# Temporary file - needed only for es6 module conversion
|
||||
|
||||
# The script updates some links according to the
|
||||
# polygerrit-ui/app/partial-redirects.json rules
|
||||
|
||||
set -e
|
||||
|
||||
if [[ `git status --porcelain` && "$1" != "--force" ]]; then
|
||||
echo "Please commit your changes before continue or run the polygerrit-links-updater.sh with --force flag"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DIR=$(pwd)
|
||||
html_files_list=$(mktemp)
|
||||
find $DIR/polygerrit-ui/app/ -name *.html -type f -not -path "*/node_modules/*" -exec sh -c 'echo {} && echo {}' \n \; >$html_files_list
|
||||
bazel run tools/node_tools/polygerrit_app_preprocessor:links-updater-bin -- $html_files_list $DIR/polygerrit-ui/app/partial-redirects.json
|
||||
|
||||
find polygerrit-ui/app/ -name '*.html' -type f -not -path "*/node_modules/*" -exec sh -c 'sed -i "s/href=\"\/bower_components\/polymer-resin\/standalone\/polymer-resin.html\"/href=\"\/node_modules\/polymer-bridges\/polymer-resin\/standalone\/polymer-resin.html\"/g" {}' \n \;
|
||||
sed -i '/<link rel="import" href="\/node_modules\/polymer-bridges\/polymer-resin\/standalone\/polymer-resin.html"/i <link rel="import" href="\/bower_components\/polymer\/polymer.html">' polygerrit-ui/app/test/common-test-setup.html
|
||||
|
||||
rm $html_files_list
|
@ -1,55 +0,0 @@
|
||||
{
|
||||
"name": "polygerrit-ui-dependencies",
|
||||
"description": "Gerrit Code Review - Polygerrit dependencies",
|
||||
"main": "",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"accessibility-developer-tools": "2.12.0",
|
||||
"chai": "3.5.0",
|
||||
"iron-a11y-announcer": "PolymerElements/iron-a11y-announcer#2.1.0",
|
||||
"font-roboto-local": "PolymerElements/font-roboto-local#1.1.0",
|
||||
"iron-behaviors": "PolymerElements/iron-behaviors#2.1.1",
|
||||
"iron-checked-element-behavior": "PolymerElements/iron-checked-element-behavior#2.1.1",
|
||||
"iron-fit-behavior": "PolymerElements/iron-fit-behavior#2.2.1",
|
||||
"iron-a11y-keys-behavior": "PolymerElements/iron-a11y-keys-behavior#2.1.1",
|
||||
"iron-menu-behavior": "PolymerElements/iron-menu-behavior#2.1.1",
|
||||
"iron-meta": "PolymerElements/iron-meta#2.1.1",
|
||||
"iron-form-element-behavior": "PolymerElements/iron-form-element-behavior#2.1.3",
|
||||
"iron-flex-layout": "PolymerElements/iron-flex-layout#2.0.3",
|
||||
"iron-resizable-behavior": "PolymerElements/iron-resizable-behavior#2.1.1",
|
||||
"lodash": "3.10.1",
|
||||
"mocha": "3.5.3",
|
||||
"paper-behaviors": "PolymerElements/paper-behaviors#2.1.1",
|
||||
"neon-animation": "PolymerElements/neon-animation#2.2.1",
|
||||
"paper-ripple": "PolymerElements/paper-ripple#2.1.1",
|
||||
"paper-icon-button": "PolymerElements/paper-icon-button#2.2.1",
|
||||
"paper-styles": "PolymerElements/paper-styles#2.1.0",
|
||||
"shadycss": "webcomponents/shadycss#1.9.1",
|
||||
"sinon-chai": "2.14.0",
|
||||
"stacky": "1.3.2",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#1.3.3",
|
||||
"sinonjs": "Polymer/sinon.js#1.17.1",
|
||||
"web-component-tester": "^6.5.1",
|
||||
"page": "^1.11.5",
|
||||
"iron-input": "2.1.3",
|
||||
"paper-tabs": "2.1.1",
|
||||
"iron-overlay-behavior": "2.3.4",
|
||||
"paper-input": "2",
|
||||
"iron-dropdown": "2",
|
||||
"paper-toggle-button": "2",
|
||||
"fetch": "^3.0.0",
|
||||
"polymer-resin": "2.0.1",
|
||||
"paper-button": "2",
|
||||
"paper-listbox": "2",
|
||||
"iron-test-helpers": "2",
|
||||
"moment": "^2.24.0",
|
||||
"paper-item": "2",
|
||||
"polymer": "2.8.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"webcomponentsjs": "1.3.3",
|
||||
"polymer": "2.8.0"
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
{
|
||||
"description": "See tools/node_tools/polygerrit_app_preprocessor/redirects.ts",
|
||||
"redirects": [
|
||||
{
|
||||
"from": "/bower_components/ba-linkify",
|
||||
"to": {
|
||||
"npm_module": "ba-linkify"
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": "/bower_components/es6-promise",
|
||||
"to": {
|
||||
"npm_module": "es6-promise"
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": "/bower_components/fetch",
|
||||
"to": {
|
||||
"npm_module": "whatwg-fetch",
|
||||
"files": {
|
||||
"fetch.js": "dist/fetch.umd.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": "/bower_components/moment",
|
||||
"to": {
|
||||
"npm_module": "moment"
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": "/bower_components/webcomponentsjs",
|
||||
"to": {
|
||||
"npm_module": "@webcomponents/webcomponentsjs"
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": "/bower_components/page",
|
||||
"to": {
|
||||
"npm_module": "page"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
html_filepath=$1
|
||||
|
||||
base_name=$(basename $1 ".html")
|
||||
base_dir=$(dirname $1)
|
||||
|
||||
js_filename="${base_name}.js"
|
||||
js_filepath="${base_dir}/${js_filename}"
|
||||
|
||||
template_filename="${base_name}_html.js"
|
||||
template_filepath="${base_dir}/${template_filename}"
|
||||
|
||||
if test -f "$js_filepath"; then
|
||||
git mv $html_filepath $template_filepath
|
||||
else
|
||||
git mv $html_filepath $js_filepath
|
||||
fi
|
@ -16,7 +16,6 @@
|
||||
"rollup": "^1.27.5",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-terser": "^5.1.3",
|
||||
"ts-morph": "^7.0.0",
|
||||
"typescript": "^3.7.4"
|
||||
},
|
||||
"devDependencies": {},
|
||||
|
@ -40,30 +40,6 @@ rollup_bundle(
|
||||
],
|
||||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "modulizer-postprocessor-bundle",
|
||||
config_file = "rollup.config.js",
|
||||
entry_point = "modulizer-postprocessor.ts",
|
||||
format = "cjs",
|
||||
rollup_bin = "//tools/node_tools:rollup-bin",
|
||||
deps = [
|
||||
":preprocessor",
|
||||
"@tools_npm//rollup-plugin-node-resolve",
|
||||
],
|
||||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "script-tag-replacer-bundle",
|
||||
config_file = "rollup.config.js",
|
||||
entry_point = "script-tag-replacer.ts",
|
||||
format = "cjs",
|
||||
rollup_bin = "//tools/node_tools:rollup-bin",
|
||||
deps = [
|
||||
":preprocessor",
|
||||
"@tools_npm//rollup-plugin-node-resolve",
|
||||
],
|
||||
)
|
||||
|
||||
nodejs_binary(
|
||||
name = "preprocessor-bin",
|
||||
data = ["@tools_npm//:node_modules"],
|
||||
@ -76,18 +52,6 @@ nodejs_binary(
|
||||
entry_point = "links-updater-bundle.js",
|
||||
)
|
||||
|
||||
nodejs_binary(
|
||||
name = "script-tag-replacer-bin",
|
||||
data = ["@tools_npm//:node_modules"],
|
||||
entry_point = "script-tag-replacer-bundle.js",
|
||||
)
|
||||
|
||||
nodejs_binary(
|
||||
name = "modulizer-postprocessor-bin",
|
||||
data = ["@tools_npm//:node_modules"],
|
||||
entry_point = "modulizer-postprocessor-bundle.js",
|
||||
)
|
||||
|
||||
# TODO(dmfilippov): Find a better way to fix it (another workaround or submit a bug to
|
||||
# Bazel IJ plugin's) authors or to a ts_config rule author).
|
||||
# The following genrule is a workaround for a bazel intellij plugin's bug.
|
||||
|
@ -1,431 +0,0 @@
|
||||
// Copyright (C) 2020 The Android Open Source Project
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// http://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.
|
||||
|
||||
// This script is used to postprocess files after the polymer-modulizer.
|
||||
// The script:
|
||||
// - fixes some import paths
|
||||
// - extract templates to a separate files
|
||||
// - makes some other minor changes (see TsFileUpdater.SimpleTransformers)
|
||||
|
||||
import {
|
||||
CommentRange,
|
||||
ImportDeclaration,
|
||||
Project,
|
||||
QuoteKind,
|
||||
SourceFile, Statement,
|
||||
ts,
|
||||
VariableDeclarationKind
|
||||
} from "ts-morph";
|
||||
import {fail} from "../utils/common";
|
||||
import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
import {readMultilineParamFile} from "../utils/command-line";
|
||||
|
||||
const root = path.normalize(process.argv[2]);
|
||||
const modulizedFiles = readMultilineParamFile(process.argv[3]);
|
||||
|
||||
const modulizerOutRoot = path.join(root, "modulizer_out");
|
||||
|
||||
interface NodeTransformer {
|
||||
transformNode(node: ts.Node, relativePathToSourceFile: string): ts.Node | undefined;
|
||||
}
|
||||
|
||||
class ImportHrefDeclarationTransformer implements NodeTransformer{
|
||||
// Transforms
|
||||
// import { importHref as importHref$0 } from "...";
|
||||
// to
|
||||
// import { importHref } from "../relative_path/scripts/import_href.js";
|
||||
|
||||
private static readonly importHrefPath = path.join(root, "scripts/import-href.js");
|
||||
|
||||
private isSupportedImportHrefDeclaration(node: ts.ImportDeclaration): boolean {
|
||||
// Returns true if import has one of the following forms:
|
||||
// import { importHref as importHref$0 } from "....";
|
||||
// import { importHref } from "....";
|
||||
// (path is not important)
|
||||
|
||||
if(!node.importClause) {
|
||||
return false;
|
||||
}
|
||||
if(!node.importClause.namedBindings|| !ts.isNamedImports(node.importClause.namedBindings)) {
|
||||
return false;
|
||||
}
|
||||
const namedImports = node.importClause.namedBindings;
|
||||
if (namedImports.elements.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
if(namedImports.elements.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
const firstNamedImport = namedImports.elements[0];
|
||||
if(!firstNamedImport.propertyName) {
|
||||
// import { importHref } from "....";
|
||||
return firstNamedImport.name.text === "importHref";
|
||||
}
|
||||
// import { importHref as importHref$0 } from "....";
|
||||
return (firstNamedImport.name.text === "importHref$0" && firstNamedImport.propertyName.text === "importHref");
|
||||
}
|
||||
|
||||
public transformNode(node: ts.Node, relativePathToSourceFile: string): ts.ImportDeclaration | undefined {
|
||||
if(!ts.isImportDeclaration(node)) {
|
||||
return undefined;
|
||||
}
|
||||
if (!ts.isStringLiteral(node.moduleSpecifier)) {
|
||||
fail(`Internal error`);
|
||||
}
|
||||
|
||||
const moduleSpecifierText = node.moduleSpecifier.text;
|
||||
if(moduleSpecifierText !== "@polymer/polymer/lib/utils/import-href.js") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if(!this.isSupportedImportHrefDeclaration(node)) {
|
||||
fail(`Unsupported import. Expected:
|
||||
import { importHref as importHref$0 } from "...";
|
||||
or
|
||||
import { importHref } from "...";
|
||||
Actual:
|
||||
${node.getText()}`);
|
||||
}
|
||||
|
||||
const relativePath = path.relative(path.dirname(path.join(root, relativePathToSourceFile)), ImportHrefDeclarationTransformer.importHrefPath);
|
||||
const namedBindings = ts.createNamedImports([ts.createImportSpecifier(undefined, ts.createIdentifier("importHref"))]);
|
||||
return ts.updateImportDeclaration(node, node.decorators, node.modifiers, ts.createImportClause(undefined, namedBindings), ts.createStringLiteral(relativePath));
|
||||
}
|
||||
}
|
||||
|
||||
class ImportHrefCallExpressionTransformer implements NodeTransformer {
|
||||
// Transforms
|
||||
// (this.importHref || importHref$0)(...arguments..)
|
||||
// to
|
||||
// importHref(...arguments...)
|
||||
|
||||
private isImportHrefCallExpression(node: ts.CallExpression): boolean {
|
||||
// Return true if call has one of the following forms:
|
||||
// (this.importHref || importHref$0)(.....)
|
||||
// (this.importHref || Base.importHref$0)(.....)
|
||||
// (arguments are not important)
|
||||
|
||||
if(!ts.isParenthesizedExpression(node.expression)) {
|
||||
return false;
|
||||
}
|
||||
if(!ts.isBinaryExpression(node.expression.expression)) {
|
||||
return false;
|
||||
}
|
||||
const binareExprNode = node.expression.expression;
|
||||
|
||||
if(binareExprNode.operatorToken.kind !== ts.SyntaxKind.BarBarToken) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!ts.isPropertyAccessExpression(binareExprNode.left) ||
|
||||
!ts.isIdentifier(binareExprNode.right)) {
|
||||
return false;
|
||||
}
|
||||
if(binareExprNode.left.getText() !== "this.importHref") {
|
||||
return false;
|
||||
}
|
||||
if(binareExprNode.right.getText() !== "importHref$0") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public transformNode(node: ts.Node): ts.CallExpression | undefined {
|
||||
if(!ts.isCallExpression(node) || !this.isImportHrefCallExpression(node)) {
|
||||
return undefined;
|
||||
}
|
||||
return ts.updateCall(node, ts.createIdentifier("importHref"),
|
||||
node.typeArguments, node.arguments);
|
||||
}
|
||||
}
|
||||
|
||||
class ImportPolymerLegacyDeclarationTransformer implements NodeTransformer {
|
||||
// Transforms
|
||||
// import '/node_modules/@polymer/polymer/polymer-legacy.js';
|
||||
// to
|
||||
// import '"../relative_path/scripts/bundled-polymer.js"'
|
||||
|
||||
private static readonly bundledPolymerPath = path.join(root, "scripts/bundled-polymer.js");
|
||||
|
||||
public transformNode(node: ts.Node, relativePathToSourceFile: string): ts.ImportDeclaration | undefined {
|
||||
if(!ts.isImportDeclaration(node)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if(node.getText() !== "import '/node_modules/@polymer/polymer/polymer-legacy.js';") {
|
||||
return undefined;
|
||||
}
|
||||
const relativePath = path.relative(path.dirname(path.join(root, relativePathToSourceFile)), ImportPolymerLegacyDeclarationTransformer.bundledPolymerPath);
|
||||
return ts.updateImportDeclaration(node, node.decorators, node.modifiers, node.importClause, ts.createStringLiteral(relativePath));
|
||||
}
|
||||
}
|
||||
|
||||
class ExtractTemplateTransformer implements NodeTransformer {
|
||||
// ExtractTemplateTransformer must be created for each file
|
||||
|
||||
private hasHtmlTemplate: boolean = false;
|
||||
private importRelativePath: string = "";
|
||||
private templateFileAbsPath: string = "";
|
||||
private taggedTemplateText: string = "";
|
||||
|
||||
private isGetTemplateAccessorDeclaration(node: ts.Node): node is ts.GetAccessorDeclaration {
|
||||
// Returns true if node is a get accessor of the form:
|
||||
// static get template() { ... }
|
||||
if(!ts.isGetAccessorDeclaration(node)) {
|
||||
return false;
|
||||
}
|
||||
if(!ts.isIdentifier(node.name) || node.name.text !== 'template') {
|
||||
return false;
|
||||
}
|
||||
const modifiers = node.modifiers;
|
||||
if(!modifiers || modifiers.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
const firstModifier = modifiers[0];
|
||||
return firstModifier.kind === ts.SyntaxKind.StaticKeyword;
|
||||
|
||||
}
|
||||
private getTaggedTemplateExpression(node: ts.GetAccessorDeclaration): ts.TaggedTemplateExpression | undefined {
|
||||
// Returns taggedTemplateExpression (i.e. html`...`) if node has exactly the following form
|
||||
// static get template() {return html`...`;}
|
||||
// Otherwise returns undefined
|
||||
// Assumes that isGetTemplateAccessorDeclaration(node) returns true
|
||||
if(!node.body || !ts.isBlock(node.body)) {
|
||||
return undefined;
|
||||
}
|
||||
const statements = node.body.statements;
|
||||
if(statements.length !== 1) {
|
||||
return undefined;
|
||||
}
|
||||
const firstStatement = statements[0];
|
||||
if(!ts.isReturnStatement(firstStatement)) {
|
||||
return undefined;
|
||||
}
|
||||
const returnExpression = firstStatement.expression;
|
||||
if(!returnExpression || !ts.isTaggedTemplateExpression(returnExpression)) {
|
||||
return undefined;
|
||||
}
|
||||
if(!ts.isIdentifier(returnExpression.tag) || returnExpression.tag.text !== "html") {
|
||||
return undefined;
|
||||
}
|
||||
if(returnExpression.typeArguments) {
|
||||
return undefined;
|
||||
}
|
||||
if(!ts.isNoSubstitutionTemplateLiteral(returnExpression.template)) {
|
||||
return undefined;
|
||||
}
|
||||
return returnExpression;
|
||||
}
|
||||
|
||||
public transformNode(node: ts.Node, relativePathToSourceFile: string): ts.Node | undefined {
|
||||
if(!this.isGetTemplateAccessorDeclaration(node)) {
|
||||
return undefined;
|
||||
}
|
||||
const taggedTemplateExpression = this.getTaggedTemplateExpression(node);
|
||||
if(!taggedTemplateExpression) {
|
||||
fail(`Not supported. Expected template method in the form 'static get template() {return html\`...\`;}'`);
|
||||
}
|
||||
if(this.hasHtmlTemplate) {
|
||||
fail(`More than one template in the file. Not Supported!`);
|
||||
}
|
||||
const returnStatement = ts.createReturn(ts.createIdentifier("htmlTemplate"));
|
||||
this.importRelativePath = "./" + path.parse(relativePathToSourceFile).name + "_html.js";
|
||||
this.hasHtmlTemplate = true;
|
||||
this.templateFileAbsPath = path.join(modulizerOutRoot, path.dirname(relativePathToSourceFile), this.importRelativePath);
|
||||
this.taggedTemplateText = taggedTemplateExpression.getText();
|
||||
return ts.updateGetAccessor(node, undefined, node.modifiers, node.name, node.parameters, node.type, ts.createBlock([returnStatement]));
|
||||
}
|
||||
|
||||
public updateTemplates(file: SourceFile, project: Project): Set<string> | undefined {
|
||||
// Extracts template to separate file
|
||||
// Returns set of relative paths
|
||||
if(!this.hasHtmlTemplate) {
|
||||
return;
|
||||
}
|
||||
const htmlTagModuleSpecifier = "@polymer/polymer/lib/utils/html-tag.js";
|
||||
const htmlTagImportDecl = file.getImportDeclaration(htmlTagModuleSpecifier);
|
||||
if(!htmlTagImportDecl) {
|
||||
fail(`Internal error. It is expected that file has import from '@polymer/polymer/lib/utils/html-tag.js'`);
|
||||
}
|
||||
htmlTagImportDecl.remove();
|
||||
file.addImportDeclaration({
|
||||
namedImports: ["htmlTemplate"],
|
||||
moduleSpecifier: this.importRelativePath,
|
||||
});
|
||||
|
||||
const templateSourceFile = project.createSourceFile(this.templateFileAbsPath);
|
||||
templateSourceFile.addImportDeclaration({
|
||||
namedImports: ["html"],
|
||||
moduleSpecifier: htmlTagModuleSpecifier,
|
||||
});
|
||||
templateSourceFile.addVariableStatement({
|
||||
declarationKind: VariableDeclarationKind.Const,
|
||||
isExported: true,
|
||||
declarations: [
|
||||
{
|
||||
name: "htmlTemplate",
|
||||
initializer: this.taggedTemplateText,
|
||||
}
|
||||
]
|
||||
});
|
||||
templateSourceFile.insertStatements(0, `/**
|
||||
* @license
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
`);
|
||||
templateSourceFile.saveSync();
|
||||
return new Set([path.relative(modulizerOutRoot, this.templateFileAbsPath)]);
|
||||
}
|
||||
}
|
||||
|
||||
class TsFileUpdater {
|
||||
private static readonly SimpleTransformers = [
|
||||
new ImportHrefCallExpressionTransformer(),
|
||||
new ImportHrefDeclarationTransformer(),
|
||||
new ImportHrefCallExpressionTransformer(),
|
||||
new ImportPolymerLegacyDeclarationTransformer(),
|
||||
];
|
||||
|
||||
private replaceImportPath(file: SourceFile, oldPath: string, newPath: string): ImportDeclaration | undefined {
|
||||
const importDecl = file.getImportDeclaration(oldPath);
|
||||
if(!importDecl) {
|
||||
return importDecl;
|
||||
}
|
||||
importDecl.setModuleSpecifier(newPath);
|
||||
return importDecl;
|
||||
}
|
||||
|
||||
private replaceImportAndSetGlobalValue(file: SourceFile, oldPath: string, newPath: string, globalVarName: string): ImportDeclaration | undefined {
|
||||
const importDecl = this.replaceImportPath(file, oldPath, newPath);
|
||||
if(!importDecl) {
|
||||
return undefined;
|
||||
}
|
||||
importDecl.setDefaultImport(globalVarName);
|
||||
file.insertStatements(importDecl.getChildIndex() + 1, `self.${globalVarName} = ${globalVarName};`);
|
||||
}
|
||||
|
||||
private replaceAbsolutNodeModulesPathWithPackageName(file: SourceFile) {
|
||||
const nodeModulesPrefix = "/node_modules/";
|
||||
const importDeclarations = file.getImportDeclarations();
|
||||
for(const imp of importDeclarations) {
|
||||
const moduleSpecifier = imp.getModuleSpecifierValue();
|
||||
if(moduleSpecifier.startsWith(nodeModulesPrefix)) {
|
||||
imp.setModuleSpecifier(moduleSpecifier.substr(nodeModulesPrefix.length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getFileLicensesComments(file: SourceFile): CommentRange[] {
|
||||
let licenseCommentsRanges = [];
|
||||
for(const statement of file.getStatementsWithComments()) {
|
||||
const commentRanges = statement.getLeadingCommentRanges();
|
||||
for(const commentRange of commentRanges) {
|
||||
const licenseComment = commentRange.getText();
|
||||
if(licenseComment.indexOf('@license') >= 0) {
|
||||
licenseCommentsRanges.push(commentRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
return licenseCommentsRanges;
|
||||
}
|
||||
|
||||
private fixJsLicenseComment(file: SourceFile) {
|
||||
const licenseCommentRanges = this.getFileLicensesComments(file);
|
||||
if(licenseCommentRanges.length === 0) {
|
||||
fail('Error. The file must have at least @license comment');
|
||||
}
|
||||
const firstLicenseComment = licenseCommentRanges[0];
|
||||
const commentLines = firstLicenseComment.getText().split('\n');
|
||||
for(let i = 1; i < commentLines.length; i++) {
|
||||
if(!commentLines[i].trim().startsWith('*')) {
|
||||
commentLines[i] = ' *' + (commentLines[i].length > 0 ? ' ': '') + commentLines[i];
|
||||
} else if(commentLines[i].startsWith('*')){
|
||||
commentLines[i] = ' ' + commentLines[i];
|
||||
}
|
||||
}
|
||||
let newCommentText = commentLines.join('\n');
|
||||
if(firstLicenseComment.getPos() !== 0) {
|
||||
newCommentText += '\n';
|
||||
}
|
||||
const ranges = licenseCommentRanges
|
||||
.map(range => {
|
||||
return {
|
||||
pos: range.getPos(),
|
||||
end: range.getEnd()
|
||||
}
|
||||
});
|
||||
ranges.sort((a, b) => b.pos - a.pos);
|
||||
for(const range of ranges) {
|
||||
file.removeText(range.pos, range.end);
|
||||
}
|
||||
file.insertText(0, newCommentText);
|
||||
}
|
||||
|
||||
|
||||
public updateFile(relativePath: string): Set<string> {
|
||||
const newFiles = new Set<string>([relativePath]);
|
||||
const project = new Project({manipulationSettings: {quoteKind: QuoteKind.Single }});
|
||||
const sourceFile = project.addSourceFileAtPath(path.join(modulizerOutRoot, relativePath));
|
||||
const extractTemplateTransformer = new ExtractTemplateTransformer();
|
||||
const updatedSourceFile = sourceFile.transform(traversal => {
|
||||
const node = traversal.visitChildren();
|
||||
for (const transformer of TsFileUpdater.SimpleTransformers) {
|
||||
const transformedNode = transformer.transformNode(node, relativePath);
|
||||
if (transformedNode) {
|
||||
return transformedNode;
|
||||
}
|
||||
const transformedTemplateNode = extractTemplateTransformer.transformNode(node, relativePath);
|
||||
if(transformedTemplateNode) {
|
||||
return transformedTemplateNode;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
});
|
||||
const newTemplateFiles = extractTemplateTransformer.updateTemplates(updatedSourceFile, project);
|
||||
if(newTemplateFiles) {
|
||||
newTemplateFiles.forEach((f) => newFiles.add(f));
|
||||
}
|
||||
this.replaceImportPath(updatedSourceFile, 'es6-promise/dist/es6-promise.min.js', 'es6-promise/lib/es6-promise.js');
|
||||
this.replaceImportPath(updatedSourceFile, 'whatwg-fetch/dist/fetch.umd.js', 'whatwg-fetch/fetch.js');
|
||||
this.replaceImportPath(updatedSourceFile, '/node_modules/polymer-bridges/polymer-resin/standalone/polymer-resin.js', 'polymer-resin/standalone/polymer-resin.js');
|
||||
this.replaceImportAndSetGlobalValue(updatedSourceFile, 'page/page.js', 'page/page.mjs', 'page');
|
||||
this.replaceImportAndSetGlobalValue(updatedSourceFile, 'moment/moment.js', 'moment/src/moment.js', 'moment');
|
||||
this.replaceAbsolutNodeModulesPathWithPackageName(updatedSourceFile);
|
||||
this.fixJsLicenseComment(updatedSourceFile);
|
||||
updatedSourceFile.saveSync();
|
||||
return newFiles;
|
||||
}
|
||||
}
|
||||
|
||||
const tsFileUpdater = new TsFileUpdater();
|
||||
for(const file of modulizedFiles) {
|
||||
console.log(`Updating ${file}`);
|
||||
const allFiles = tsFileUpdater.updateFile(file);
|
||||
allFiles.forEach(f =>
|
||||
fs.copyFileSync(path.join(modulizerOutRoot, f), path.join(root, f))
|
||||
);
|
||||
}
|
@ -17,8 +17,7 @@
|
||||
|
||||
|
||||
export default {
|
||||
external: ['fs', 'path', 'parse5', 'dom5', 'parse5-html-rewriting-stream',
|
||||
'ts-morph', "stream"],
|
||||
external: ['fs', 'path', 'parse5', 'dom5', 'parse5-html-rewriting-stream'],
|
||||
onwarn: warn => {
|
||||
// Typescript adds helper methods for await and promise which look like
|
||||
// var __awaiter = (this && this.__awaiter)
|
||||
|
@ -1,237 +0,0 @@
|
||||
// Copyright (C) 2020 The Android Open Source Project
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// http://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.
|
||||
|
||||
// The tool to update source code before run the polymer-modulizer
|
||||
// The tool:
|
||||
// - Converts <script src="some_script.js"> to <link rel="some_script.html">
|
||||
// and creates the some_script.html file with the single
|
||||
// <script src="some_script.js"></script> (otherwise, the polymer-modulizer can inline
|
||||
// some_script.js to other files)
|
||||
// - Checks that .html files have a valid structure (see checkJsFileSafeToConvert)
|
||||
|
||||
import * as fs from "fs";
|
||||
import RewritingStream from "parse5-html-rewriting-stream";
|
||||
import * as dom5 from "dom5";
|
||||
import {HtmlFileUtils} from "./utils";
|
||||
import {Node} from 'dom5';
|
||||
import {readMultilineParamFile} from "../utils/command-line";
|
||||
import { fail } from "../utils/common";
|
||||
import * as path from "path";
|
||||
import * as parse5 from "parse5";
|
||||
|
||||
async function main() {
|
||||
if (process.argv.length < 5) {
|
||||
console.info("Usage:\n\tnode script-tag-replacer.js root_dir html_files_param_file output_list_file_name\n");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const root = path.normalize(process.argv[2]);
|
||||
const htmlFiles = readMultilineParamFile(process.argv[3]);
|
||||
const updater = new HtmlFileUpdater();
|
||||
for(const htmlFile of htmlFiles) {
|
||||
await updater.updateFile(root, htmlFile);
|
||||
}
|
||||
updater.writeListOfGeneratedHtmlFiles(process.argv[4]);
|
||||
const errors = updater.getErrors();
|
||||
if(errors.length > 0) {
|
||||
fail(errors.join("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/** Update all links in HTML file based on redirects.
|
||||
* Additionally, update references to web-component-tester */
|
||||
class HtmlFileUpdater {
|
||||
private static readonly Predicates = {
|
||||
isScriptWithSrcTag: (node: Node) => node.tagName === "script" && dom5.hasAttribute(node, "src"),
|
||||
isNonEmptyNode: (node: Node) => node.tagName || (node.data && node.data.trim() !== ""),
|
||||
};
|
||||
|
||||
private readonly jsToGeneratedHtmlFileMap = new Map<string, string>();
|
||||
private readonly errors: string[] = [];
|
||||
|
||||
public async updateFile(root: string, srcFile: string) {
|
||||
const srcFilePath = path.join(root, srcFile);
|
||||
const html = fs.readFileSync(srcFilePath, "utf-8");
|
||||
const readStream = fs.createReadStream(srcFilePath, {encoding: "utf-8"});
|
||||
const rewriterOutput = srcFilePath + ".tmp";
|
||||
const writeStream = fs.createWriteStream(rewriterOutput, {encoding: "utf-8"});
|
||||
const rewriter = new RewritingStream();
|
||||
(rewriter as any).tokenizer.preprocessor.bufferWaterline = Infinity;
|
||||
const initialErrorsCount = this.errors.length;
|
||||
|
||||
rewriter.on("startTag", (tag: any) => {
|
||||
if (HtmlFileUpdater.Predicates.isScriptWithSrcTag(tag)) {
|
||||
const htmlImportPath = this.getHtmlImportPathForScript(tag, root, srcFile);
|
||||
if(htmlImportPath) {
|
||||
rewriter.emitRaw(`<link rel="import" href="${htmlImportPath}"/>`);
|
||||
// Ignore script close tag
|
||||
if(!tag.selfClosing) {
|
||||
rewriter.once("endTag", (tag: any) => {
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
const location = tag.sourceCodeLocation;
|
||||
const raw = html.substring(location.startOffset, location.endOffset);
|
||||
rewriter.emitRaw(raw);
|
||||
return;
|
||||
});
|
||||
if(!srcFile.endsWith("_test.html")) {
|
||||
// /gr-js-api-interface-element.html was created manually
|
||||
const html = fs.readFileSync(srcFilePath, {encoding: "utf-8"});
|
||||
const ast = parse5.parseFragment(html) as Node;
|
||||
this.checkJsFileSafeToConvert(ast, srcFile);
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve) => {
|
||||
writeStream.on("close", () => {
|
||||
writeStream.close();
|
||||
if(this.errors.length === initialErrorsCount) {
|
||||
fs.renameSync(rewriterOutput, srcFilePath);
|
||||
} else {
|
||||
// Errors during conversion - do not overwrite file
|
||||
fs.unlinkSync(rewriterOutput);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
readStream.pipe(rewriter).pipe(writeStream);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the html file meets the following properties:
|
||||
* 1. The file either has one dom-module element or doesn't have dom-module at all
|
||||
* 2. There is exactly only one script tag inside dom-module and this tag is a direct child
|
||||
* of dom-module (i.e. it is not a child of a child, etc..)
|
||||
* 4. The script tag inside dom-module refers to the appropriate script file
|
||||
* (see the isAllowedSrcInDomModule method) or contains element declaration
|
||||
* (code starts with "Polymer(")
|
||||
* 4. The dom-module is the last element in the html file.
|
||||
* @param ast - ast tree of an html file
|
||||
* @param srcFile - relative path to the html file
|
||||
*
|
||||
* Method fails if it is not safe to convert the html file with polymer-modulizer
|
||||
*/
|
||||
private checkJsFileSafeToConvert(ast: Node, srcFile: string) {
|
||||
let domModuleFound: boolean = false;
|
||||
if(!ast.childNodes) {
|
||||
return;
|
||||
}
|
||||
for(const node of this.getNonEmptyChildNodes(ast)) {
|
||||
if(domModuleFound) {
|
||||
this.reportError(srcFile, `No content allowed after the <dom-module> tag`);
|
||||
}
|
||||
if(node.tagName === 'dom-module') {
|
||||
if(domModuleFound) {
|
||||
this.reportError(srcFile, `Only one <dom-module> is allowed per html file`);
|
||||
}
|
||||
this.checkDomModuleSafeToConvert(node, srcFile);
|
||||
domModuleFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private checkDomModuleSafeToConvert(domModuleNode: Node, srcFile: string) {
|
||||
let scriptTagFound = false;
|
||||
let templateTagFound = false;
|
||||
for(const node of this.getNonEmptyChildNodes(domModuleNode)) {
|
||||
if(node.tagName === "script") {
|
||||
if(scriptTagFound) {
|
||||
this.reportError(srcFile, `<dom-module> can contain only one script tag`);
|
||||
}
|
||||
scriptTagFound = true;
|
||||
if(HtmlFileUpdater.Predicates.isScriptWithSrcTag(node)) {
|
||||
const src = dom5.getAttribute(node, "src")!;
|
||||
if(!this.isAllowedSrcInDomModule(srcFile, src)) {
|
||||
this.reportError(srcFile, `Script src='${src}' is not valid inside dom-module. Move script tag outside of dom-module`);
|
||||
}
|
||||
} else {
|
||||
const script = dom5.getTextContent(node);
|
||||
if(!script.trimLeft().startsWith("Polymer(")) {
|
||||
this.reportError(srcFile, 'File can contain only one element script tag inside dom-module! Move all other scripts outside of dom-module');
|
||||
}
|
||||
}
|
||||
} else if(node.tagName === "template") {
|
||||
if (templateTagFound) {
|
||||
this.reportError(srcFile, `<dom-module> can contain only one template tag`);
|
||||
}
|
||||
if (node.attrs.length > 0) {
|
||||
this.reportError(srcFile, `<tempalte> must not have an attribute`)
|
||||
}
|
||||
templateTagFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getNonEmptyChildNodes(node: Node): Node[] {
|
||||
if(!node.childNodes) {
|
||||
return [];
|
||||
}
|
||||
return node.childNodes.filter(HtmlFileUpdater.Predicates.isNonEmptyNode);
|
||||
}
|
||||
|
||||
private isAllowedSrcInDomModule(srcFile: string, scriptSrc: string) {
|
||||
return path.basename(srcFile, ".html") + ".js" === scriptSrc;
|
||||
}
|
||||
private reportError(fileName: string, errorText: string): void {
|
||||
this.errors.push(`${fileName}: ${errorText}`);
|
||||
}
|
||||
|
||||
public getErrors(): string[] {
|
||||
return this.errors;
|
||||
}
|
||||
|
||||
private getHtmlImportPathForScript(node: Node, root: string, parentHtml: string): string | undefined {
|
||||
const ref = dom5.getAttribute(node, "src");
|
||||
if (!ref) {
|
||||
fail(`Internal error - ${node} in ${parentHtml} doesn't have attribute 'src'`);
|
||||
}
|
||||
if(ref.startsWith("/")) {
|
||||
return undefined;
|
||||
}
|
||||
const originalPath = path.join(root, HtmlFileUtils.getPathRelativeToRoot(parentHtml, ref));
|
||||
const pathRelativeToRoot = path.relative(root, originalPath);
|
||||
if(pathRelativeToRoot.startsWith('bower_components/') || pathRelativeToRoot.startsWith('node_modules/') || pathRelativeToRoot.startsWith('components')) {
|
||||
return undefined;
|
||||
}
|
||||
const parsedPath = path.parse(originalPath);
|
||||
parsedPath.base = path.basename(parsedPath.base, ".js") + ".html";
|
||||
const htmlFilePath = path.format(parsedPath);
|
||||
const parentHtmlFullPath = path.join(root, parentHtml);
|
||||
if(!this.jsToGeneratedHtmlFileMap.has(originalPath)) {
|
||||
if (fs.existsSync(htmlFilePath)) {
|
||||
if (parentHtmlFullPath !== htmlFilePath) {
|
||||
if(htmlFilePath.endsWith('/gr-etag-decorator.html')) {
|
||||
// Has reference from test to .js; ignore this error
|
||||
return undefined;
|
||||
}
|
||||
fail(`Can't create html for the ${originalPath} file. The html file already exists`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
const scriptFileName = path.basename(originalPath);
|
||||
fs.writeFileSync(htmlFilePath, `<script src="${scriptFileName}"></script>`);
|
||||
this.jsToGeneratedHtmlFileMap.set(originalPath, htmlFilePath)
|
||||
}
|
||||
return path.relative(path.dirname(parentHtmlFullPath), this.jsToGeneratedHtmlFileMap.get(originalPath)!);
|
||||
}
|
||||
|
||||
public writeListOfGeneratedHtmlFiles(fileName: string) {
|
||||
const allFiles = new Array(...this.jsToGeneratedHtmlFileMap.values()).join('\n');
|
||||
fs.writeFileSync(fileName, allFiles);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
@ -507,14 +507,6 @@
|
||||
source-map-support "0.5.9"
|
||||
tsutils "2.27.2"
|
||||
|
||||
"@dsherret/to-absolute-glob@^2.0.2":
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@dsherret/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz#1f6475dc8bd974cea07a2daf3864b317b1dd332c"
|
||||
integrity sha1-H2R13IvZdM6gei2vOGSzF7HdMyw=
|
||||
dependencies:
|
||||
is-absolute "^1.0.0"
|
||||
is-negated-glob "^1.0.0"
|
||||
|
||||
"@mrmlnc/readdir-enhanced@^2.2.1":
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
|
||||
@ -523,32 +515,11 @@
|
||||
call-me-maybe "^1.0.1"
|
||||
glob-to-regexp "^0.3.0"
|
||||
|
||||
"@nodelib/fs.scandir@2.1.3":
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b"
|
||||
integrity sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==
|
||||
dependencies:
|
||||
"@nodelib/fs.stat" "2.0.3"
|
||||
run-parallel "^1.1.9"
|
||||
|
||||
"@nodelib/fs.stat@2.0.3", "@nodelib/fs.stat@^2.0.2":
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz#34dc5f4cabbc720f4e60f75a747e7ecd6c175bd3"
|
||||
integrity sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==
|
||||
|
||||
"@nodelib/fs.stat@^1.1.2":
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
|
||||
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==
|
||||
|
||||
"@nodelib/fs.walk@^1.2.3":
|
||||
version "1.2.4"
|
||||
resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz#011b9202a70a6366e436ca5c065844528ab04976"
|
||||
integrity sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==
|
||||
dependencies:
|
||||
"@nodelib/fs.scandir" "2.1.3"
|
||||
fastq "^1.6.0"
|
||||
|
||||
"@octokit/auth-token@^2.4.0":
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.0.tgz#b64178975218b99e4dfe948253f0673cbbb59d9f"
|
||||
@ -682,18 +653,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
|
||||
integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=
|
||||
|
||||
"@ts-morph/common@~0.4.0":
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.4.0.tgz#c8fdb870692b16a80ca0722af7d12d6bb7c78ed7"
|
||||
integrity sha512-VV5/F8k/9RnSZnNpnaOarKb7LOzYhITjHB9JIcpl1l+zlt99H1HeZH/yI2Xs6BtAV4WjPX+SjjRVybdEm6IOEQ==
|
||||
dependencies:
|
||||
"@dsherret/to-absolute-glob" "^2.0.2"
|
||||
fast-glob "^3.1.1"
|
||||
fs-extra "^8.1.0"
|
||||
is-negated-glob "^1.0.0"
|
||||
multimatch "^4.0.0"
|
||||
typescript "~3.8.2"
|
||||
|
||||
"@types/babel-generator@^6.25.1":
|
||||
version "6.25.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/babel-generator/-/babel-generator-6.25.3.tgz#8f06caa12d0595a0538560abe771966d77d29286"
|
||||
@ -960,7 +919,7 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d"
|
||||
integrity sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==
|
||||
|
||||
"@types/minimatch@*", "@types/minimatch@^3.0.1", "@types/minimatch@^3.0.3":
|
||||
"@types/minimatch@*", "@types/minimatch@^3.0.1":
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
|
||||
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
|
||||
@ -1547,11 +1506,6 @@ array-differ@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031"
|
||||
integrity sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=
|
||||
|
||||
array-differ@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b"
|
||||
integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==
|
||||
|
||||
array-find-index@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1"
|
||||
@ -1569,11 +1523,6 @@ array-union@^1.0.1:
|
||||
dependencies:
|
||||
array-uniq "^1.0.1"
|
||||
|
||||
array-union@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
|
||||
integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==
|
||||
|
||||
array-uniq@^1.0.1:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6"
|
||||
@ -1599,11 +1548,6 @@ arrify@^1.0.0, arrify@^1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
|
||||
integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=
|
||||
|
||||
arrify@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa"
|
||||
integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==
|
||||
|
||||
asn1@~0.2.3:
|
||||
version "0.2.4"
|
||||
resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136"
|
||||
@ -2162,13 +2106,6 @@ braces@^2.3.1:
|
||||
split-string "^3.0.2"
|
||||
to-regex "^3.0.1"
|
||||
|
||||
braces@^3.0.1:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
|
||||
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
|
||||
dependencies:
|
||||
fill-range "^7.0.1"
|
||||
|
||||
browser-capabilities@^1.0.0:
|
||||
version "1.1.4"
|
||||
resolved "https://registry.yarnpkg.com/browser-capabilities/-/browser-capabilities-1.1.4.tgz#a6bd657a07a134532ad66c722b8949904478b973"
|
||||
@ -2483,11 +2420,6 @@ cloneable-readable@^1.0.0:
|
||||
process-nextick-args "^2.0.0"
|
||||
readable-stream "^2.3.5"
|
||||
|
||||
code-block-writer@^10.1.0:
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-10.1.0.tgz#54fc410ebef2af836d9c2314ac40af7d7b37eee9"
|
||||
integrity sha512-RG9hpXtWFeUWhuUav1YuP/vGcyncW+t90yJLk9fNZs1De2OuHTHKAKThVCokt29PYq5RoJ0QSZaIZ+rvPO23hA==
|
||||
|
||||
code-point-at@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
|
||||
@ -3529,18 +3461,6 @@ fast-glob@^2.0.2:
|
||||
merge2 "^1.2.3"
|
||||
micromatch "^3.1.10"
|
||||
|
||||
fast-glob@^3.1.1:
|
||||
version "3.2.2"
|
||||
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.2.tgz#ade1a9d91148965d4bf7c51f72e1ca662d32e63d"
|
||||
integrity sha512-UDV82o4uQyljznxwMxyVRJgZZt3O5wENYojjzbaGEGZgeOxkLFf+V4cnUD+krzb2F72E18RhamkMZ7AdeggF7A==
|
||||
dependencies:
|
||||
"@nodelib/fs.stat" "^2.0.2"
|
||||
"@nodelib/fs.walk" "^1.2.3"
|
||||
glob-parent "^5.1.0"
|
||||
merge2 "^1.3.0"
|
||||
micromatch "^4.0.2"
|
||||
picomatch "^2.2.1"
|
||||
|
||||
fast-json-stable-stringify@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
|
||||
@ -3556,13 +3476,6 @@ fast-safe-stringify@^2.0.4:
|
||||
resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz#124aa885899261f68aedb42a7c080de9da608743"
|
||||
integrity sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==
|
||||
|
||||
fastq@^1.6.0:
|
||||
version "1.6.0"
|
||||
resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.6.0.tgz#4ec8a38f4ac25f21492673adb7eae9cfef47d1c2"
|
||||
integrity sha512-jmxqQ3Z/nXoeyDmWAzF9kH1aGZSis6e/SbfPmJpUnyZ0ogr6iscHQaml4wsEepEWSdtmpy+eVXmCRIMpxaXqOA==
|
||||
dependencies:
|
||||
reusify "^1.0.0"
|
||||
|
||||
fd-slicer@~1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e"
|
||||
@ -3628,13 +3541,6 @@ fill-range@^4.0.0:
|
||||
repeat-string "^1.6.1"
|
||||
to-regex-range "^2.1.0"
|
||||
|
||||
fill-range@^7.0.1:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
|
||||
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
|
||||
dependencies:
|
||||
to-regex-range "^5.0.1"
|
||||
|
||||
filled-array@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/filled-array/-/filled-array-1.1.0.tgz#c3c4f6c663b923459a9aa29912d2d031f1507f84"
|
||||
@ -3808,15 +3714,6 @@ fs-exists-sync@^0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add"
|
||||
integrity sha1-mC1ok6+RjnLQjeyehnP/K1qNat0=
|
||||
|
||||
fs-extra@^8.1.0:
|
||||
version "8.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
|
||||
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
|
||||
dependencies:
|
||||
graceful-fs "^4.2.0"
|
||||
jsonfile "^4.0.0"
|
||||
universalify "^0.1.0"
|
||||
|
||||
fs.realpath@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||
@ -3907,13 +3804,6 @@ glob-parent@^3.0.0, glob-parent@^3.1.0:
|
||||
is-glob "^3.1.0"
|
||||
path-dirname "^1.0.0"
|
||||
|
||||
glob-parent@^5.1.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2"
|
||||
integrity sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==
|
||||
dependencies:
|
||||
is-glob "^4.0.1"
|
||||
|
||||
glob-stream@^5.3.2:
|
||||
version "5.3.5"
|
||||
resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-5.3.5.tgz#a55665a9a8ccdc41915a87c701e32d4e016fad22"
|
||||
@ -4116,7 +4006,7 @@ got@^7.0.0:
|
||||
url-parse-lax "^1.0.0"
|
||||
url-to-options "^1.0.1"
|
||||
|
||||
graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.2.0:
|
||||
graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.2.0:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423"
|
||||
integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
|
||||
@ -4516,14 +4406,6 @@ ipaddr.js@1.9.0:
|
||||
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.0.tgz#37df74e430a0e47550fe54a2defe30d8acd95f65"
|
||||
integrity sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==
|
||||
|
||||
is-absolute@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-1.0.0.tgz#395e1ae84b11f26ad1795e73c17378e48a301576"
|
||||
integrity sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==
|
||||
dependencies:
|
||||
is-relative "^1.0.0"
|
||||
is-windows "^1.0.1"
|
||||
|
||||
is-accessor-descriptor@^0.1.6:
|
||||
version "0.1.6"
|
||||
resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6"
|
||||
@ -4671,7 +4553,7 @@ is-glob@^3.1.0:
|
||||
dependencies:
|
||||
is-extglob "^2.1.0"
|
||||
|
||||
is-glob@^4.0.0, is-glob@^4.0.1:
|
||||
is-glob@^4.0.0:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc"
|
||||
integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==
|
||||
@ -4696,11 +4578,6 @@ is-module@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"
|
||||
integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=
|
||||
|
||||
is-negated-glob@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-negated-glob/-/is-negated-glob-1.0.0.tgz#6910bca5da8c95e784b5751b976cf5a10fee36d2"
|
||||
integrity sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI=
|
||||
|
||||
is-npm@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4"
|
||||
@ -4725,11 +4602,6 @@ is-number@^4.0.0:
|
||||
resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff"
|
||||
integrity sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==
|
||||
|
||||
is-number@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
|
||||
integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
|
||||
|
||||
is-obj@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f"
|
||||
@ -4803,13 +4675,6 @@ is-redirect@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24"
|
||||
integrity sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=
|
||||
|
||||
is-relative@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-1.0.0.tgz#a1bb6935ce8c5dba1e8b9754b9b2dcc020e2260d"
|
||||
integrity sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==
|
||||
dependencies:
|
||||
is-unc-path "^1.0.0"
|
||||
|
||||
is-retry-allowed@^1.0.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4"
|
||||
@ -4832,13 +4697,6 @@ is-typedarray@~1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
|
||||
integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=
|
||||
|
||||
is-unc-path@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-unc-path/-/is-unc-path-1.0.0.tgz#d731e8898ed090a12c352ad2eaed5095ad322c9d"
|
||||
integrity sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==
|
||||
dependencies:
|
||||
unc-path-regex "^0.1.2"
|
||||
|
||||
is-utf8@^0.2.0:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
|
||||
@ -4995,13 +4853,6 @@ json5@^2.1.0:
|
||||
dependencies:
|
||||
minimist "^1.2.0"
|
||||
|
||||
jsonfile@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
|
||||
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
|
||||
optionalDependencies:
|
||||
graceful-fs "^4.1.6"
|
||||
|
||||
jsonschema@^1.1.0, jsonschema@^1.1.1:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.2.5.tgz#bab69d97fa28946aec0a56a9cc266d23fe80ae61"
|
||||
@ -5407,7 +5258,7 @@ merge-stream@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
|
||||
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
|
||||
|
||||
merge2@^1.2.3, merge2@^1.3.0:
|
||||
merge2@^1.2.3:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.3.0.tgz#5b366ee83b2f1582c48f87e47cf1a9352103ca81"
|
||||
integrity sha512-2j4DAdlBOkiSZIsaXk4mTE3sRS02yBHAtfy127xRV3bQUFqXkjHCHLW6Scv7DwNRbIWNHH8zpnz9zMaKXIdvYw==
|
||||
@ -5455,14 +5306,6 @@ micromatch@^3.0.4, micromatch@^3.1.10:
|
||||
snapdragon "^0.8.1"
|
||||
to-regex "^3.0.2"
|
||||
|
||||
micromatch@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
|
||||
integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
|
||||
dependencies:
|
||||
braces "^3.0.1"
|
||||
picomatch "^2.0.5"
|
||||
|
||||
mime-db@1.43.0, "mime-db@>= 1.43.0 < 2", mime-db@^1.28.0:
|
||||
version "1.43.0"
|
||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.43.0.tgz#0a12e0502650e473d735535050e7c8f4eb4fae58"
|
||||
@ -5593,17 +5436,6 @@ multimatch@^2.0.0:
|
||||
arrify "^1.0.0"
|
||||
minimatch "^3.0.0"
|
||||
|
||||
multimatch@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-4.0.0.tgz#8c3c0f6e3e8449ada0af3dd29efb491a375191b3"
|
||||
integrity sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ==
|
||||
dependencies:
|
||||
"@types/minimatch" "^3.0.3"
|
||||
array-differ "^3.0.0"
|
||||
array-union "^2.1.0"
|
||||
arrify "^2.0.1"
|
||||
minimatch "^3.0.4"
|
||||
|
||||
multipipe@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/multipipe/-/multipipe-1.0.2.tgz#cc13efd833c9cda99f224f868461b8e1a3fd939d"
|
||||
@ -6139,11 +5971,6 @@ performance-now@^2.1.0:
|
||||
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
|
||||
|
||||
picomatch@^2.0.5, picomatch@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a"
|
||||
integrity sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==
|
||||
|
||||
pify@^2.0.0, pify@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
|
||||
@ -6945,11 +6772,6 @@ ret@~0.1.10:
|
||||
resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
|
||||
integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==
|
||||
|
||||
reusify@^1.0.0:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
|
||||
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
|
||||
|
||||
rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2:
|
||||
version "2.7.1"
|
||||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"
|
||||
@ -7016,11 +6838,6 @@ run-async@^2.0.0, run-async@^2.2.0:
|
||||
dependencies:
|
||||
is-promise "^2.1.0"
|
||||
|
||||
run-parallel@^1.1.9:
|
||||
version "1.1.9"
|
||||
resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679"
|
||||
integrity sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==
|
||||
|
||||
rx@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782"
|
||||
@ -7967,13 +7784,6 @@ to-regex-range@^2.1.0:
|
||||
is-number "^3.0.0"
|
||||
repeat-string "^1.6.1"
|
||||
|
||||
to-regex-range@^5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
|
||||
integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==
|
||||
dependencies:
|
||||
is-number "^7.0.0"
|
||||
|
||||
to-regex@^3.0.1, to-regex@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce"
|
||||
@ -8019,15 +7829,6 @@ triple-beam@^1.2.0, triple-beam@^1.3.0:
|
||||
resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9"
|
||||
integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==
|
||||
|
||||
ts-morph@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-7.0.0.tgz#8e013a3b1164a01c7de42229538463d0f975043f"
|
||||
integrity sha512-t4FhkXtW0hN9n3/cgalyu3piLn7DIx0DKSQ1hZWZI1/PNet21EZnhdMkKRj+N3cphXn7yz9OWG3xGQtxkCMkKA==
|
||||
dependencies:
|
||||
"@dsherret/to-absolute-glob" "^2.0.2"
|
||||
"@ts-morph/common" "~0.4.0"
|
||||
code-block-writer "^10.1.0"
|
||||
|
||||
tslib@^1.8.1, tslib@^1.9.0:
|
||||
version "1.10.0"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
|
||||
@ -8075,11 +7876,6 @@ typescript@^3.7.4:
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
|
||||
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==
|
||||
|
||||
typescript@~3.8.2:
|
||||
version "3.8.2"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.2.tgz#91d6868aaead7da74f493c553aeff76c0c0b1d5a"
|
||||
integrity sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ==
|
||||
|
||||
typical@^2.6.0, typical@^2.6.1:
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d"
|
||||
@ -8103,11 +7899,6 @@ uglify-js@3.4.x:
|
||||
commander "~2.19.0"
|
||||
source-map "~0.6.1"
|
||||
|
||||
unc-path-regex@^0.1.2:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa"
|
||||
integrity sha1-5z3T17DXxe2G+6xrCufYxqadUPo=
|
||||
|
||||
underscore@^1.8.3:
|
||||
version "1.9.2"
|
||||
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.2.tgz#0c8d6f536d6f378a5af264a72f7bec50feb7cf2f"
|
||||
@ -8173,11 +7964,6 @@ universal-user-agent@^4.0.0:
|
||||
dependencies:
|
||||
os-name "^3.1.0"
|
||||
|
||||
universalify@^0.1.0:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
|
||||
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
||||
|
||||
unpipe@1.0.0, unpipe@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
|
||||
|
Loading…
x
Reference in New Issue
Block a user