@sketch-hq/sketch-assistant-utils
Advanced tools
Comparing version 5.0.0-next.0 to 5.0.0-next.1
# @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 @@ |
@@ -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, |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158677
2117
+ Added@sketch-hq/sketch-assistant-types@3.0.0-next.1(transitive)
- Removed@sketch-hq/sketch-assistant-types@3.0.0-next.0(transitive)