回退 H5 SDK 引擎强制同步
This commit is contained in:
@@ -8,14 +8,11 @@
|
||||
"node": ">=20 <25"
|
||||
},
|
||||
"scripts": {
|
||||
"sync:sdk-engine": "node scripts/sync-sdk-engine.cjs",
|
||||
"predev:h5": "npm run sync:sdk-engine",
|
||||
"dev:h5": "uni -p h5 --mode development",
|
||||
"predev:test:h5": "npm run sync:sdk-engine",
|
||||
"dev:test:h5": "uni -p h5 --mode test",
|
||||
"build:test:h5": "npm run sync:sdk-engine && uni build -p h5 --mode test && node scripts/finalize-h5-build.cjs --allow-placeholder",
|
||||
"build:h5": "npm run sync:sdk-engine && uni build -p h5 --mode production && node scripts/finalize-h5-build.cjs --require-tencent-map-key",
|
||||
"build:h5:no-minify": "npm run sync:sdk-engine && uni build -p h5 --mode production --minify false && node scripts/finalize-h5-build.cjs --require-tencent-map-key",
|
||||
"build:test:h5": "uni build -p h5 --mode test && node scripts/finalize-h5-build.cjs --allow-placeholder",
|
||||
"build:h5": "uni build -p h5 --mode production && node scripts/finalize-h5-build.cjs --require-tencent-map-key",
|
||||
"build:h5:no-minify": "uni build -p h5 --mode production --minify false && node scripts/finalize-h5-build.cjs --require-tencent-map-key",
|
||||
"dev:mp-weixin": "uni -p mp-weixin --mode development",
|
||||
"dev:test:mp-weixin": "uni -p mp-weixin --mode test",
|
||||
"build:test:mp-weixin": "uni build -p mp-weixin --mode test",
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const projectRoot = path.resolve(__dirname, '..')
|
||||
const repoRoot = path.resolve(projectRoot, '..')
|
||||
const sourceDir = path.join(repoRoot, 'sgs-map-sdk-release', 'engine')
|
||||
const targetDir = path.join(projectRoot, 'public', 'engine')
|
||||
|
||||
if (!fs.existsSync(sourceDir)) {
|
||||
throw new Error(`SDK Engine source not found: ${sourceDir}`)
|
||||
}
|
||||
|
||||
const publicDir = path.join(projectRoot, 'public')
|
||||
const resolvedTarget = path.resolve(targetDir)
|
||||
if (!resolvedTarget.startsWith(path.resolve(publicDir) + path.sep)) {
|
||||
throw new Error(`Refusing to write outside public directory: ${resolvedTarget}`)
|
||||
}
|
||||
|
||||
const rewriteTextFiles = (dir) => {
|
||||
const replacements = [
|
||||
['http://1.92.206.90:9000/museum-assets', '/museum-assets'],
|
||||
['http://1.92.206.90:9000/tts-audio', '/tts-audio'],
|
||||
['http://1.92.206.90:9000', 'http://legacy-minio.local:9000'],
|
||||
['https://1.92.206.90:9000', 'https://legacy-minio.local:9000'],
|
||||
['https://guide.whaoyue.com/museum-assets', '/museum-assets'],
|
||||
['https://guide.whaoyue.com/tts-audio', '/tts-audio'],
|
||||
['https://guide.whaoyue.com/app-api', '/app-api']
|
||||
]
|
||||
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const filePath = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) {
|
||||
rewriteTextFiles(filePath)
|
||||
continue
|
||||
}
|
||||
if (!entry.isFile() || !/\.(?:html|js|mjs|json|css|map)$/i.test(entry.name)) continue
|
||||
|
||||
let text = fs.readFileSync(filePath, 'utf8')
|
||||
const original = text
|
||||
for (const [from, to] of replacements) {
|
||||
text = text.split(from).join(to)
|
||||
}
|
||||
if (text !== original) fs.writeFileSync(filePath, text, 'utf8')
|
||||
}
|
||||
}
|
||||
|
||||
fs.rmSync(targetDir, { recursive: true, force: true })
|
||||
fs.mkdirSync(path.dirname(targetDir), { recursive: true })
|
||||
fs.cpSync(sourceDir, targetDir, { recursive: true })
|
||||
rewriteTextFiles(targetDir)
|
||||
|
||||
console.log(`Synced SDK Engine: ${sourceDir} -> ${targetDir}`)
|
||||
Reference in New Issue
Block a user