refactor(installer): split install scripts into build sources#108
Open
plusls wants to merge 1 commit into
Open
refactor(installer): split install scripts into build sources#108plusls wants to merge 1 commit into
plusls wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor(installer): 将安装脚本拆分为构建源文件
概述
将单体式的
install.sh/install.ps1拆分为src/下的模块化构建源文件,并新增build.js负责把它们渲染成最终的安装脚本。产物零变化:
build.js生成的install.sh/install.ps1与仓库中已提交的版本逐字节一致(git diff为空),不改变任何安装行为。动机
当前的安装脚本存在明显的维护痛点:
install.sh(约 1500 行)和install.ps1(约 1550 行)各自是一个大文件,其中通过 heredoc 内嵌了大量 JS(extractor、patcher、wrapper、repatcher、post-processor 等)。把内嵌逻辑抽成独立源文件后,可以按文件定位、按平台对照,降低同步成本。
改动内容
纯新增,不修改任何已提交文件(14 个新文件,2794 行):
构建流程
src/template/install.sh和install.ps1把原本的 heredoc 正文替换成{{CONTENT:<name>}}占位符。build.js按PLACEHOLDER_MAP把每个占位符映射到对应源文件,查找顺序为<platform>/->generic/(平台目录覆盖通用目录的同名文件)。replaceAll替换,规避$$/$&/$1等特殊模式导致的替换串损坏。build.js直接报错退出,避免生成残缺脚本。运行方式:
验证
node build.js生成后,git diff对install.sh/install.ps1为空 —— 产物与现状逐字节一致。兼容性
src/下的源文件并重新node build.js,而不是直接改install.sh/install.ps1。