更新
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { createRequire } from 'node:module'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
|
||||
const root = 'D:/web/zyt'
|
||||
const require = createRequire(path.join(root, 'admin/package.json'))
|
||||
const { parse, compileScript, compileTemplate, compileStyleAsync } = require('@vue/compiler-sfc')
|
||||
const changed = execFileSync('git', ['diff', '--name-only', '--', 'admin/src'], { cwd: root, encoding: 'utf8' })
|
||||
const files = changed.trim().split(/\r?\n/).filter((file) => file.endsWith('.vue'))
|
||||
files.push('admin/src/views/consumer/prescription/components/PrescriptionOrderTimeDialog.vue')
|
||||
const results = []
|
||||
for (const file of [...new Set(files)]) {
|
||||
const filename = path.join(root, file)
|
||||
const { descriptor, errors } = parse(fs.readFileSync(filename, 'utf8'), { filename })
|
||||
const diagnostics = [...errors]
|
||||
try {
|
||||
const script = compileScript(descriptor, { id: file })
|
||||
if (descriptor.template) {
|
||||
diagnostics.push(...compileTemplate({
|
||||
id: file, filename, source: descriptor.template.content,
|
||||
compilerOptions: { bindingMetadata: script.bindings }
|
||||
}).errors)
|
||||
}
|
||||
for (const style of descriptor.styles) {
|
||||
const output = await compileStyleAsync({
|
||||
id: file, filename, source: style.content, scoped: style.scoped,
|
||||
preprocessLang: style.lang, preprocessCustomRequire: require
|
||||
})
|
||||
diagnostics.push(...output.errors)
|
||||
}
|
||||
} catch (error) {
|
||||
diagnostics.push(error)
|
||||
}
|
||||
results.push({ file, errors: diagnostics.map(String) })
|
||||
}
|
||||
fs.writeFileSync(path.join(root, 'artifacts/prescription-enhancements/vue-compile.json'), JSON.stringify(results, null, 2))
|
||||
console.log(JSON.stringify(results, null, 2))
|
||||
process.exitCode = results.some((result) => result.errors.length) ? 1 : 0
|
||||
Reference in New Issue
Block a user