Delete and recreate view folder on deploy to force Ignition detection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
igurielidze 2026-03-30 23:10:42 +04:00
parent 0d4075d126
commit 8e2f837fb9

View File

@ -266,12 +266,14 @@ export default defineConfig({
const { projectName, viewName, viewJson, resourceJson } = JSON.parse(body); const { projectName, viewName, viewJson, resourceJson } = JSON.parse(body);
const ignitionBase = 'C:/Program Files/Inductive Automation/Ignition/data/projects'; const ignitionBase = 'C:/Program Files/Inductive Automation/Ignition/data/projects';
const viewDir = path.join(ignitionBase, projectName, 'com.inductiveautomation.perspective/views', viewName); const viewDir = path.join(ignitionBase, projectName, 'com.inductiveautomation.perspective/views', viewName);
// Delete existing view folder first to force Ignition to detect the change
if (fs.existsSync(viewDir)) {
fs.rmSync(viewDir, { recursive: true, force: true });
}
// Small delay then recreate
fs.mkdirSync(viewDir, { recursive: true }); fs.mkdirSync(viewDir, { recursive: true });
fs.writeFileSync(path.join(viewDir, 'view.json'), viewJson); fs.writeFileSync(path.join(viewDir, 'view.json'), viewJson);
fs.writeFileSync(path.join(viewDir, 'resource.json'), resourceJson); fs.writeFileSync(path.join(viewDir, 'resource.json'), resourceJson);
// Write a scan-trigger script that a gateway timer can pick up
const triggerFile = path.join(ignitionBase, projectName, '.scan-trigger');
fs.writeFileSync(triggerFile, new Date().toISOString());
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({ ok: true, path: viewDir })); res.end(JSON.stringify({ ok: true, path: viewDir }));