UNPKG

@scriptables/manifest

Version:

Utilities to generate, parse, and update manifest headers in Scriptable scripts.

21 lines (17 loc) 928 B
import {normalizeManifest} from './normalizeManifest'; import {CompatibleScriptableManifest, ScriptableBannerManifest} from './types'; import {validateManifest} from './validateManifest'; export function generateManifestText(manifest: CompatibleScriptableManifest = {}, noDefaults = false): string { const normalizedManifest = normalizeManifest(manifest); validateManifest(normalizedManifest, true); const bannerManifest: ScriptableBannerManifest = { 'always-run-in-app': normalizedManifest.alwaysRunInApp, 'share-sheet-inputs': normalizedManifest.shareSheetInputs?.join(', '), 'icon-color': normalizedManifest.iconColor ?? (noDefaults ? '' : 'blue'), 'icon-glyph': normalizedManifest.iconGlyph ?? (noDefaults ? '' : 'circle'), }; return Object.entries(bannerManifest) .filter(([, value]) => value !== undefined && value !== '') .map(([key, value]) => `${key}: ${value};`) .join(' '); }