/** * @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. */ import * as fs from "fs"; import * as parse5 from "parse5"; import * as dom5 from "dom5"; import * as path from "path"; import {Node} from 'dom5'; import {fail, unexpectedSwitchValue} from "../utils/common"; import {readMultilineParamFile} from "../utils/command-line"; import { HtmlSrcFilePath, JsSrcFilePath, HtmlTargetFilePath, JsTargetFilePath, FileUtils, FilePath } from "../utils/file-utils"; import { AbsoluteWebPath, getRelativeImport, NodeModuleImportPath, SrcWebSite } from "../utils/web-site-utils"; /** * Update source code by moving all scripts out of HTML files. * Input: * input_output_html_param_file - list of file paths, each file path on a separate line * The first 3 line contains the path to the first input HTML file and 2 output paths * (for HTML and JS files) * The second 3 line contains paths for the second HTML file, and so on. * * input_output_js_param_file - similar to input_output_html_param_file, but has only 2 lines * per file (input JS file and output JS file) * * input_web_root_path - path (in filesystem) which should be treated as a web-site root path. * For each HTML file it creates 2 output files - HTML and JS file. * HTML file contains everything from HTML input file, except