This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@specifyapp/node-utils
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.1 • Public • Published

Specify Node utils

Overview

This package aims to provide NodeJS utilities for the Specify SDK.

Getting Started

Prerequisites

  • Javascript ESM compatible runtime (browser or NodeJS)
  • [Optional] Typescript >= 4.9

Installation

npm install @specifyapp/node-utils @specifyapp/sdk

File System Helper

The createSpecifyFileSystemHelper function allows you to write the files generated by the Specify Pipe Engine API to disk.

import {createSpecifyClient} from '@specifyapp/sdk';
import {createSpecifyFileSystemHelper} from '@specifyapp/node-utils';

const specifyClient = createSpecifyClient();

await specifyClient.authenticate('your-personal-access-token');

const repositoryTokenTree = await specifyClient.getRepositoryTokenTreeByName('your-repository');

const pipeEngineRuleResponseBody = await repositoryTokenTree.transformWithRemoteParsers([
  {
    name: 'to-css-custom-properties',
    output: {type: 'file', filePath: 'tokens.css'},
  },
]);

const fileSystemHelper = createSpecifyFileSystemHelper({
  pipeEngineRuleResponseBody
});

const writtenFiles = await fileSystemHelper.writeToDisk('./public');

console.log(writtenFiles); // ['public/tokens.css']

Manipulate the files before writing them to disk

The mapFiles method allows you to manipulate the files before writing them to disk. Any post-process like minification, formatting, etc. can be done here.

const writtenFiles = await fileSystemHelper
  .mapFiles(file => {
    if (file.path === 'colors.css' && file.content.type === 'text') {
      return {
        ...file,
        content: {
          type: 'text',
          text: file.content.text.replaceAll(';', ' !important;'),
        },
      };
    }
  })
  .writeToDisk('./public');

Readme

Keywords

none

Package Sidebar

Install

npm i @specifyapp/node-utils

Weekly Downloads

646

Version

1.0.0-beta.1

License

none

Unpacked Size

23.6 kB

Total Files

27

Last publish

Collaborators

  • allanmichay
  • amoreaux
  • nico-specify