#!/usr/bin/env node 'use strict' const fs = require('fs') const path = require('path') const root = path.resolve(__dirname, '..') const dist = path.join(root, 'dist') function fail(reason) { console.log('FAIL ' + reason) process.exit(1) } function pass(msg) { console.log('PASS ' + msg) } const versionJsonPath = path.join(dist, 'version.json') if (!fs.existsSync(versionJsonPath)) fail('dist/version.json 不存在') let meta try { meta = JSON.parse(fs.readFileSync(versionJsonPath, 'utf8')) } catch (e) { fail('dist/version.json 解析失败: ' + e.message) } // 1. dist/app.js 以 banner `/*! IWB */` 开头,且 与 version.json.version 一致 const appPath = path.join(dist, 'app.js') if (!fs.existsSync(appPath)) fail('dist/app.js 不存在') const app = fs.readFileSync(appPath, 'utf8') const expectedBanner = '/*! IWB ' + meta.version + ' */' if (!app.startsWith(expectedBanner)) { fail('dist/app.js 未以 banner 开头(期望: ' + JSON.stringify(expectedBanner) + ',实际前 48 字符: ' + JSON.stringify(app.slice(0, 48)) + ')') } pass('dist/app.js banner 与 version.json.version 一致: ' + expectedBanner) // 2. dist/index.html 含 `app.js?v=`,恰好 3 个