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

@ministryofjustice/fb-transformers

v1.0.11

Published

Component transformation functions with a CLI for Form Builder

Downloads

3

Readme

fb-transformers

Functions in this module transform Form Builder fileupload components into upload components and create any page.uploadCheck or page.uploadSummary steps, too.

Each of these functions return a Promise. The promise can be resolved as part of a chain or using await. (The examples below use await syntax.)

All of these functions is exposed to the command line with Commander.

Primary functions

hasFileUploadComponentInForm

Accepts a path to a Form directory as an argument. It walks all the steps and standalone pages looking for fileupload component and returns a boolean:

const directoryPath = '~/Documents/formbuilder/forms/ComponentFileUpload'

await hasFileUploadComponentInForm(directoryPath) // resolves to a boolean

transformFileUploadComponentsInForm

Accepts a path to a Form directory as an argument. It walks all the steps and standalone pages looking for fileupload components and returns an array:

const directoryPath = '~/Documents/formbuilder/forms/ComponentFileUpload'

await transformFileUploadComponentsInForm(directoryPath) // resolves to an array of strings

The resolved array contains a list of all the files that were examined, not all the files that have been changed.

Secondary functions

These functions are exported from the module and are used internally by the module.

hasFileUploadComponent

Accepts a path to a Form JSON file as an argument. It does not walk -- it is only interested in the properties of that Form step.

const filePath = '~/Documents/formbuilder/forms/ComponentFileUpload/metadata/page/page.fileupload.json'

await hasFileUploadComponent(filePath) // resolves to a boolean

hasUploadComponent

Accepts a path to a Form JSON file as an argument. As above, it does not walk.

const filePath = '~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json'

await hasUploadComponent(filePath) // resolves to a boolean

hasUploadCheckStep

Accepts a path to a Form JSON file as an argument. As above, it does not walk.

const filePath = '~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json'

await hasUploadCheckStep(filePath) // resolves to a boolean

hasUploadSummaryStep

Accepts a path to a Form JSON file as an argument. As above, it does not walk.

const filePath = '~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json'

await hasUploadCheckStep(filePath) // resolves to a boolean

Commander and the CLI

These functions are exposed to the command line so that a developer can update a Form cloned to their environment, or run them from the shell in any other environment.

All of these flags should be prefaced with npm start --. The double hyphen indicates that subsequent flags should be passed to the command. For example, assuming you have cloned a Form repository named ComponentFileUpload to your environment:

npm start -- --has-file-upload-in-form ~/Documents/formbuilder/forms/ComponentFileUpload

This will set the DEBUG variable to enable logging in the terminal, and then execute the command:

node app --has-file-upload-in-form ~/Documents/formbuilder/forms/ComponentFileUpload

Simply executing this on its own will invoke the functions silently, which is probably not what you want.

Flags

Each of these flags should be followed either by the path to a Form, or the path to a step JSON file.

Paths starting with the "~" character will be resolved to the user's home directory. (Paths containing whitespace should be provided in quotes.)

An error will be thrown if a path is not provided.

hasFileUploadComponentInForm

  • -h, --has-file-upload-in-form String, path to Form

Determines whether Form has fileupload component(s), invokes hasFileUploadComponentInForm:

npm start -- --has-file-upload-in-form ~/Documents/formbuilder/forms/ComponentFileUpload

--has-file-upload-in-form

transformFileUploadComponentsInForm

  • -t, --transform-file-upload-in-form String, path to Form

Transforms fileupload component(s) in Form, invokes transformFileUploadComponentsInForm:

npm start -- --transform-file-upload-in-form ~/Documents/formbuilder/forms/ComponentFileUpload

--transform-file-upload-in-form

hasFileUploadComponent

  • --has-file-upload String, path to step

Determines whether step has fileupload components(s), invokes hasFileUploadComponent:

npm start -- --has-file-upload ~/Documents/formbuilder/forms/ComponentFileUpload/metadata/page/page.fileupload.json

--has-file-upload

transformFileUploadComponents

  • --transform-file-upload String, path to step

Transforms fileupload components(s) in step_, invokes transformFileUploadComponents:

npm start -- --transform-file-upload ~/Documents/formbuilder/forms/ComponentFileUpload/metadata/page/page.fileupload.json

--transform-file-upload

hasUploadComponent

  • --has-upload String, path to step

Determines whether step has upload components(s), invokes hasUploadComponent:

npm start -- --has-upload ~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json

--has-upload

hasUploadCheckStep

  • --has-upload-check String, path to step

Determines whether step has page.uploadCheck step, invokes hasUploadCheckStep:

npm start -- --has-upload-check ~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json

--has-upload-check

hasUploadSummaryStep

  • --has-upload-summary String, path to step

Determines whether step has page.uploadSummary step, invokes hasUploadSummaryStep:

npm start -- --has-upload-summary ~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json

--has-upload-summary