New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@scriptables/manifest

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scriptables/manifest - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

2

dist/index.js

@@ -20,3 +20,3 @@ 'use strict';

exports.matchAllBannerManifest = manifest.matchAllBannerManifest;
exports.updateScriptableManifest = manifest.updateScriptableManifest;
exports.mergeScriptableBanner = manifest.mergeScriptableBanner;
exports.ScriptableBannerManifestKeys = types.ScriptableBannerManifestKeys;

@@ -27,3 +27,3 @@ import { ScriptableBannerManifestKeys, ScriptableManifest } from './types';

* @param script The script to update.
* @param manifest The source manifest.
* @param manifestOrOldScript The manifest to update the script with, or the old script to extract the manifest from.
* @returns The updated script with the manifest text.

@@ -47,6 +47,6 @@ * @example

*
* const [banner, updatedScript] = updateScriptableManifest(manifest, script);
* console.log(updatedScript);
* const [banner, mergedScript] = mergeScriptableBanner(manifest, script);
* console.log(mergedScript);
* ```
*/
export declare function updateScriptableManifest(script: string, manifest: Partial<ScriptableManifest>): [string, string];
export declare function mergeScriptableBanner(script: string, manifestOrOldScript?: Partial<ScriptableManifest> | string): [string, string];

@@ -99,3 +99,3 @@ 'use strict';

* @param script The script to update.
* @param manifest The source manifest.
* @param manifestOrOldScript The manifest to update the script with, or the old script to extract the manifest from.
* @returns The updated script with the manifest text.

@@ -119,7 +119,10 @@ * @example

*
* const [banner, updatedScript] = updateScriptableManifest(manifest, script);
* console.log(updatedScript);
* const [banner, mergedScript] = mergeScriptableBanner(manifest, script);
* console.log(mergedScript);
* ```
*/
function updateScriptableManifest(script, manifest) {
function mergeScriptableBanner(script, manifestOrOldScript) {
const manifest = typeof manifestOrOldScript === 'string'
? extractScriptableManifest(manifestOrOldScript, ['icon-color', 'icon-glyph'])
: manifestOrOldScript;
let banner = '';

@@ -137,19 +140,23 @@ let scriptNew = script;

scriptNew = scriptNew.substring(line.length + 1);
for (const m of matches) {
const [, key, value] = m;
switch (key) {
case 'always-run-in-app':
if (manifest.always_run_in_app !== undefined)
line = line.replace(value, manifest.always_run_in_app ? 'true' : 'false');
break;
case 'share-sheet-inputs':
if (manifest.share_sheet_inputs)
line = line.replace(value, manifest.share_sheet_inputs.join(', '));
break;
case 'icon-color':
line = line.replace(value, manifest.icon?.color || '');
break;
case 'icon-glyph':
line = line.replace(value, manifest.icon?.glyph || '');
break;
if (manifest) {
for (const m of matches) {
const [, key, value] = m;
switch (key) {
case 'always-run-in-app':
if (manifest.always_run_in_app !== undefined)
line = line.replace(value, manifest.always_run_in_app ? 'true' : 'false');
break;
case 'share-sheet-inputs':
if (manifest.share_sheet_inputs)
line = line.replace(value, manifest.share_sheet_inputs.join(', '));
break;
case 'icon-color':
if (manifest.icon?.color)
line = line.replace(value, manifest.icon?.color);
break;
case 'icon-glyph':
if (manifest.icon?.glyph)
line = line.replace(value, manifest.icon?.glyph);
break;
}
}

@@ -180,2 +187,2 @@ }

exports.matchAllBannerManifest = matchAllBannerManifest;
exports.updateScriptableManifest = updateScriptableManifest;
exports.mergeScriptableBanner = mergeScriptableBanner;
{
"name": "@scriptables/manifest",
"description": "An utilities to generate, parse, and update manifest headers in Scriptable scripts.",
"version": "0.2.3",
"version": "0.2.4",
"keywords": [

@@ -52,3 +52,3 @@ "scriptable",

],
"gitHead": "1e4ecf9d7d249001b78135920673aa9c73b6d4b6"
"gitHead": "7bd658a0303be9ba4af1d539659bda51180619f8"
}

@@ -73,8 +73,8 @@ # @scriptables/manifest

#### `updateScriptableManifest(script: string, manifest: Partial<ScriptableManifest>): [string, string]`
#### `mergeScriptableBanner(script: string, manifestOrOldScript?: Partial<ScriptableManifest> | string): [string, string]`
Updates an existing script's manifest with new settings. Returns a tuple of [banner, updatedScript].
Updates an existing script's manifest with new settings. Returns a tuple of [banner, mergedScript].
```typescript
const [banner, updatedScript] = updateScriptableManifest(script, {
const [banner, mergedScript] = mergeScriptableBanner(script, {
icon: {

@@ -121,3 +121,3 @@ color: 'blue',

```typescript
import {generateScriptableBanner, updateScriptableManifest} from '@scriptables/manifest';
import {generateScriptableBanner, mergeScriptableBanner} from '@scriptables/manifest';

@@ -140,3 +140,3 @@ // Generate a new banner

const [newBanner, updatedScript] = updateScriptableManifest(script, manifest);
const [newBanner, mergedScript] = mergeScriptableBanner(script, manifest);
```

@@ -147,3 +147,3 @@

```typescript
import {extractScriptableManifest, updateScriptableManifest} from '@scriptables/manifest';
import {extractScriptableManifest, mergeScriptableBanner} from '@scriptables/manifest';

@@ -163,5 +163,25 @@ // Extract existing manifest

// Update script with modified manifest
const [newBanner, updatedScript] = updateScriptableManifest(script, manifest);
const [newBanner, mergedScript] = mergeScriptableBanner(script, manifest);
```
### Merge with old script
```typescript
import {mergeScriptableBanner} from '@scriptables/manifest';
const oldScript = `// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: circle;
console.log('Hello world');`;
const newScript = `// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: red; icon-glyph: square;
console.log('Hello world');`;
const [newBanner, mergedScript] = mergeScriptableBanner(newScript, oldScript);
```
## Contributing

@@ -168,0 +188,0 @@

@@ -117,3 +117,3 @@ import {SCRIPTABLE_BANNER_STATIC_LINES} from './consts';

* @param script The script to update.
* @param manifest The source manifest.
* @param manifestOrOldScript The manifest to update the script with, or the old script to extract the manifest from.
* @returns The updated script with the manifest text.

@@ -137,7 +137,15 @@ * @example

*
* const [banner, updatedScript] = updateScriptableManifest(manifest, script);
* console.log(updatedScript);
* const [banner, mergedScript] = mergeScriptableBanner(manifest, script);
* console.log(mergedScript);
* ```
*/
export function updateScriptableManifest(script: string, manifest: Partial<ScriptableManifest>): [string, string] {
export function mergeScriptableBanner(
script: string,
manifestOrOldScript?: Partial<ScriptableManifest> | string,
): [string, string] {
const manifest =
typeof manifestOrOldScript === 'string'
? extractScriptableManifest(manifestOrOldScript, ['icon-color', 'icon-glyph'])
: manifestOrOldScript;
let banner = '';

@@ -157,18 +165,20 @@ let scriptNew = script;

for (const m of matches) {
const [, key, value] = m;
switch (key as ScriptableBannerManifestKeys) {
case 'always-run-in-app':
if (manifest.always_run_in_app !== undefined)
line = line.replace(value, manifest.always_run_in_app ? 'true' : 'false');
break;
case 'share-sheet-inputs':
if (manifest.share_sheet_inputs) line = line.replace(value, manifest.share_sheet_inputs.join(', '));
break;
case 'icon-color':
line = line.replace(value, manifest.icon?.color || '');
break;
case 'icon-glyph':
line = line.replace(value, manifest.icon?.glyph || '');
break;
if (manifest) {
for (const m of matches) {
const [, key, value] = m;
switch (key as ScriptableBannerManifestKeys) {
case 'always-run-in-app':
if (manifest.always_run_in_app !== undefined)
line = line.replace(value, manifest.always_run_in_app ? 'true' : 'false');
break;
case 'share-sheet-inputs':
if (manifest.share_sheet_inputs) line = line.replace(value, manifest.share_sheet_inputs.join(', '));
break;
case 'icon-color':
if (manifest.icon?.color) line = line.replace(value, manifest.icon?.color);
break;
case 'icon-glyph':
if (manifest.icon?.glyph) line = line.replace(value, manifest.icon?.glyph);
break;
}
}

@@ -175,0 +185,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc