Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sketch-hq/sketch-assistant-utils

Package Overview
Dependencies
Maintainers
3
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sketch-hq/sketch-assistant-utils - npm Package Compare versions

Comparing version 5.0.0-next.0 to 5.0.0-next.1

10

CHANGELOG.md
# @sketch-hq/sketch-assistant-utils
## 5.0.0-next.1
### Major Changes
- e986bed: Adjust `testRule` function signature to favour testing rules in isolation
### Patch Changes
- 4a60dae: Update to `next.1` types
## 5.0.0-next.0

@@ -4,0 +14,0 @@

1

dist/cjs/run-assistant/index.js

@@ -52,2 +52,3 @@ "use strict";

return Object.assign(Object.assign({}, acc), { [curr.name]: {
name: curr.name,
title: curr.title,

@@ -54,0 +55,0 @@ description: curr.description,

10

dist/cjs/test-helpers/index.d.ts

@@ -1,2 +0,2 @@

import { FileFormat, Assistant, RuleOptionsCreator, RuleFunction, RuleDefinition, AssistantDefinition, AssistantConfig, ViolationSeverity, RuleConfigGroup, AssistantEnv, RunResult } from '@sketch-hq/sketch-assistant-types';
import { FileFormat, Assistant, RuleOptionsCreator, RuleFunction, RuleDefinition, AssistantDefinition, AssistantConfig, ViolationSeverity, RuleConfigGroup, AssistantEnv, RunResult, RuleConfig } from '@sketch-hq/sketch-assistant-types';
/**

@@ -44,10 +44,4 @@ * Create a dummy rule definition.

};
/**
* Test an individual rule within the context of a specific assistant. The assistant has its config
* overwritten by the passed in value to enable testing rules in isolation.
*
* If the rule referenced in the config isn't available in the Assistant an error is thrown.
*/
export declare const testRule: (filepath: string, ruleConfig: RuleConfigGroup, assistant: Assistant, env?: AssistantEnv) => Promise<RunResult>;
export declare const testRule: (filepath: string, assistant: Assistant, ruleName: string, ruleConfig?: RuleConfig, env?: AssistantEnv) => Promise<RunResult>;
export { createRule, createDummyRectNode, createAssistantConfig, createAssistant, createAssistantDefinition, };
//# sourceMappingURL=index.d.ts.map

@@ -59,9 +59,3 @@ "use strict";

exports.createDummyRectNode = createDummyRectNode;
/**
* Test an individual rule within the context of a specific assistant. The assistant has its config
* overwritten by the passed in value to enable testing rules in isolation.
*
* If the rule referenced in the config isn't available in the Assistant an error is thrown.
*/
exports.testRule = (filepath, ruleConfig, assistant, env = { locale: 'en', platform: 'node' }) => __awaiter(void 0, void 0, void 0, function* () {
exports.testRule = (filepath, assistant, ruleName, ruleConfig = { active: true }, env = { locale: 'en', platform: 'node' }) => __awaiter(void 0, void 0, void 0, function* () {
const file = yield from_file_1.fromFile(filepath);

@@ -72,11 +66,11 @@ const op = { cancelled: false };

assistantDefinition.config = {
rules: ruleConfig,
rules: {
[ruleName]: ruleConfig,
},
};
Object.keys(ruleConfig).forEach((ruleName) => {
if (!assistant_1.getRuleDefinition(assistantDefinition, ruleName)) {
throw new Error(`Rule "${ruleName}" not found on Assistant "${assistantDefinition.name}"`);
}
});
if (!assistant_1.getRuleDefinition(assistantDefinition, ruleName)) {
throw new Error(`Rule "${ruleName}" not found on Assistant "${assistantDefinition.name}"`);
}
return yield run_assistant_1.runAssistant(processedFile, assistantDefinition, env, op, get_image_metadata_1.getImageMetadata);
});
//# sourceMappingURL=index.js.map

@@ -46,2 +46,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return Object.assign(Object.assign({}, acc), { [curr.name]: {
name: curr.name,
title: curr.title,

@@ -48,0 +49,0 @@ description: curr.description,

@@ -1,2 +0,2 @@

import { FileFormat, Assistant, RuleOptionsCreator, RuleFunction, RuleDefinition, AssistantDefinition, AssistantConfig, ViolationSeverity, RuleConfigGroup, AssistantEnv, RunResult } from '@sketch-hq/sketch-assistant-types';
import { FileFormat, Assistant, RuleOptionsCreator, RuleFunction, RuleDefinition, AssistantDefinition, AssistantConfig, ViolationSeverity, RuleConfigGroup, AssistantEnv, RunResult, RuleConfig } from '@sketch-hq/sketch-assistant-types';
/**

@@ -44,10 +44,4 @@ * Create a dummy rule definition.

};
/**
* Test an individual rule within the context of a specific assistant. The assistant has its config
* overwritten by the passed in value to enable testing rules in isolation.
*
* If the rule referenced in the config isn't available in the Assistant an error is thrown.
*/
export declare const testRule: (filepath: string, ruleConfig: RuleConfigGroup, assistant: Assistant, env?: AssistantEnv) => Promise<RunResult>;
export declare const testRule: (filepath: string, assistant: Assistant, ruleName: string, ruleConfig?: RuleConfig, env?: AssistantEnv) => Promise<RunResult>;
export { createRule, createDummyRectNode, createAssistantConfig, createAssistant, createAssistantDefinition, };
//# sourceMappingURL=index.d.ts.map

@@ -52,9 +52,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

});
/**
* Test an individual rule within the context of a specific assistant. The assistant has its config
* overwritten by the passed in value to enable testing rules in isolation.
*
* If the rule referenced in the config isn't available in the Assistant an error is thrown.
*/
export const testRule = (filepath, ruleConfig, assistant, env = { locale: 'en', platform: 'node' }) => __awaiter(void 0, void 0, void 0, function* () {
export const testRule = (filepath, assistant, ruleName, ruleConfig = { active: true }, env = { locale: 'en', platform: 'node' }) => __awaiter(void 0, void 0, void 0, function* () {
const file = yield fromFile(filepath);

@@ -65,9 +59,9 @@ const op = { cancelled: false };

assistantDefinition.config = {
rules: ruleConfig,
rules: {
[ruleName]: ruleConfig,
},
};
Object.keys(ruleConfig).forEach((ruleName) => {
if (!getRuleDefinition(assistantDefinition, ruleName)) {
throw new Error(`Rule "${ruleName}" not found on Assistant "${assistantDefinition.name}"`);
}
});
if (!getRuleDefinition(assistantDefinition, ruleName)) {
throw new Error(`Rule "${ruleName}" not found on Assistant "${assistantDefinition.name}"`);
}
return yield runAssistant(processedFile, assistantDefinition, env, op, getImageMetadata);

@@ -74,0 +68,0 @@ });

{
"name": "@sketch-hq/sketch-assistant-utils",
"version": "5.0.0-next.0",
"version": "5.0.0-next.1",
"module": "dist/esm/index",

@@ -30,3 +30,3 @@ "main": "dist/cjs/index",

"@json-schema-spec/json-pointer": "0.1.2",
"@sketch-hq/sketch-assistant-types": "3.0.0-next.0",
"@sketch-hq/sketch-assistant-types": "3.0.0-next.1",
"ajv": "6.12.0",

@@ -33,0 +33,0 @@ "humps": "2.0.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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