Hello all!
I am pleased to announce the 1.0.0 release of pyro-resource, a TypeScript library for generating project resource import files (.zip). As more and more of Ignition's resource structure is moving to plain JSON, JavaScript is becoming a natural language to use when scripting the creation of resources.
This library allows you easily script the creation of new resources, and provides automatic generation of signed resource.json
files.
- Create a
project
and add your resources - Call
project.zip()
- Write the file to disk
- Import directly into Ignition
import fs from 'fs'
import { newProject, perspective } from '@mussonindustrial/pyro-resource'
const project = newProject({ perspective })
const styleClasses = project.perspective.resources.styleClasses
styleClasses.node('MyStyleClass', {
'style.json': '{ base: { style: {} } }',
})
const zip = await project.zip()
fs.writeFileSync('./project-import.zip', zip)
And for module developers, custom modules and resource types can be created.
import {
newFolderResource,
newModule,
newNodeResource,
newProject,
} from '@mussonindustrial/pyro-resource'
const myFolderResource = newFolderResource('my-resource', ['file.json'])
const mySingletonResource = newNodeResource('my-singleton-resource', [
'file.json',
'image.png',
'another.xml',
])
const myModule = newModule('com.acme.module', {
myFolderResource,
mySingletonResource,
})
const project = newProject({ myModule })
project.myModule.resources
// (property) resources: {
// myFolderResource: FolderResource<readonly ["file.json"]>;
// mySingletonResource: NodeResource<readonly ["file.json", "image.png", "another.xml"]>;
// }
See the GitHub page for full details.
pyro-resource
If you're only interested in the resource.json
signature generation, check out pyro-resource-signature located in the same monorepo; this contains all of the signature generation and verification logic. (Big props to @PGriffith for his modification-updater application, from which the signature generation was borrowed).