1.0.10 • Published 1 year ago

@relab/node-manifest v1.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@relab/node-manifest

The package allows storing the application manifest for the project and using it as needed.

Requirements

  • Node 18+
  • Zod 3+

Installation

NPM

npm install --save @relab/node-manifest

PNPM

npm add @relab/node-manifest

Default project schema

{
  "name": "<project name>", // Project name
  "description": "<project description>", // Description of the project
  "service": "<service name>", // (optional) Service name - useful, for example, when your app is part of Kubernetes app
  "package": { // (optional) Package description
    "name": "", // Package name
    "description": "", // (optional) Package description
    "version": "", // Package version
  }
}

Usage

Default schema

./manifest.json

{
  "name": "Test",
  "description": "Test app",
  "service": "test",
  "package": {
    "name": "@company/test",
    "description": "Package for test app",
    "version": "1.1.0"
  }
}

./manifest.ts

import { DefaultManifestSchema, manifest as parse } from '@relab/node-manifest'
export const manifest = parse(DefaultManifestSchema)()

Somewhere in your app:

import manifest from './manifest'

console.log(manifest.name)
console.log(manifest.description)
// ...

Custom schema

./manifest.json

{
  "name": "Test",
  "description": "Test app",
  "service": "test",
  "package": {
    "name": "@company/test",
    "description": "Package for test app",
    "version": "1.1.0"
  }
}

./manifest.ts

import { DefaultManifestSchema, manifest as parse } from '@relab/node-manifest'
export const manifest = parse(DefaultManifestSchema)()

Somewhere in your app:

import manifest from './manifest'

console.log(manifest.name)
console.log(manifest.description)
// ...

Custom manifest file name

./manifest.json

{
  "title": "Test",
  "version": "1.1.0"
}

./manifest.ts

import { manifest as parse } from '@relab/node-manifest'
import { z } from 'zod'

const MyManifestSchema = z.object({
    title: z.string(),
    version: z.string(),
})

export const manifest = parse(MyManifestSchema)()

Somewhere in your app:

import manifest from './manifest'

console.log(manifest.title)
console.log(manifest.version)

License

Released under MIT by Sergey Zwezdin.

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago