npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mussonindustrial/pyro-resource

v2.1.0

Published

Ignition project resource builder.

Downloads

9

Readme

pyro-resource

NPM Version

pyro-resource lets you build Ignition-compatible project resource files in JavaScript.

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)

Usage

  1. Add pyro-resource to your build tool:
npm install @mussonindustrial/pyro-resource
  1. Create a new project and include your desired modules.
import {
    alarmNotification,
    newProject,
    perspective,
    reporting,
    sfc,
    sqlBridge,
    vision,
    webdev,
} from '@mussonindustrial/pyro-resource'

const project = newProject({
    alarmNotification,
    perspective,
    reporting,
    sfc,
    sqlBridge,
    vision,
    webdev,
})
  1. Add your resource content.
const pageConfig = project.perspective.resources.pageConfig
// Setting node content.
pageConfig.set({
    'config.json': '{}',
})

const styleClasses = project.perspective.resources.styleClasses
// Creating a node.
styleClasses.node('MyStyleClass', {
    'style.json': '{ base: { style: {} } }',
})

// Creating a node in a folder.
styleClasses.node('Folder/StyleClass', {
    'style.json': '{ base: { style: {} } }',
})

// Creating a folder.
const folder = styleClasses.folder('Folder2')
folder.node('InAFolder', {
    'style.json': '{ base: { style: {} } }',
})
  1. Zip the project and write to disk.
const zip = await project.zip()
fs.writeFileSync('./projectImport.zip', zip)

resource.json Files

The required resource.json files are generated and signed using pyro-resource-signature.

Type Hints

Each module comes with resource definitions and type hints for the required files.

project.perspective.resources
// (property) resources: {
//     generalProperties: NodeResource<readonly ["data.bin"]>;
//     pageConfig: NodeResource<readonly ["config.json"]>;
//     sessionProperties: NodeResource<readonly ["props.json"]>;
//     sessionScripts: NodeResource<...>;
//     styleClasses: FolderResource<...>;
//     views: FolderResource<...>;
// }

Custom Modules and Resources

Custom module definitions can be created in order to support 3rd party modules (with complete type hinting).

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"]>;
// }

Copyright and Licensing

Copyright (C) 2023 Musson Industrial

Free use of this software is granted under the terms of the MIT License.