From 4998ed6de1d384bf0dba9fb3fd17094dbb11ebd9 Mon Sep 17 00:00:00 2001 From: atanasster Date: Sat, 7 Mar 2020 19:56:49 -0500 Subject: [PATCH] feat: instrument options what to collect --- core/instrument/README.md | 96 +++++++++++++++++-- core/instrument/package.json | 1 + .../instrument/src/babel/extract-component.ts | 18 ++-- core/instrument/src/babel/follow-imports.ts | 6 +- core/instrument/src/index.ts | 42 +++++--- core/instrument/src/project/packageInfo.ts | 31 +++--- core/instrument/src/types.ts | 96 ++++++++++++++++++- .../instrument/test/extract-component.test.ts | 10 +- core/instrument/test/follow-imports.test.ts | 9 +- core/specification/src/utility.ts | 6 +- examples/storybook-5/.storybook/main.js | 9 +- 11 files changed, 269 insertions(+), 55 deletions(-) diff --git a/core/instrument/README.md b/core/instrument/README.md index 566c42e8a..8e8a82c9f 100644 --- a/core/instrument/README.md +++ b/core/instrument/README.md @@ -67,7 +67,7 @@ Name | Type | Description | *Defined in [core/instrument/src/types.ts](https://github.com/atanasster/component-controls/blob/ab703a5/core/instrument/src/types.ts)* -### **defaultParserOptions**: ParserOptions +### **defaultParserOptions**: *[ParserOptions](#parseroptions)* • **plugins**: *"typescript" | "jsx"[]* = ['jsx', 'typescript'] @@ -75,12 +75,23 @@ Name | Type | Description | ___ -### **defaultResolveOptions**: ResolverOptions +### **defaultResolveOptions**: *[ResolverOptions](#resolveroptions)* • **extensions**: *string[]* = ['.js', '.jsx', '.ts', '.tsx', '.vue', '.mjs', '.es', '.es6'] ___ +### **defaultComponentOptions**: *[ComponentOptions](#componentoptions)* + +• **storeSourceFile**: *boolean* = true; + +___ + +### **defaultStoriesOptions**: *[StoriesOptions](#storiesoptions)* + +• **storeSourceFile**: *boolean* = true; + +___ # Interfaces @@ -92,13 +103,18 @@ Options that can control the parsing and instrumentation process ### Properties -• **component**? : *[ComponentOptions](#componentoptions)* +• **components**? : *[ComponentOptions](#componentoptions)* + +Options for extracting stories information. + +• **stories**? : *[StoriesOptions](#storiesoptions)* Options for extracting component information. + • **parser**? : *[ParserOptions](#parseroptions)* -Options to control the babel parser. +Options to control babel parser. • **prettier**? : *[PrettierOptions](#prettieroptions) | false* @@ -106,7 +122,7 @@ prettier options are used to prettify the code at the end of the process this is useful for "story" code, where the story is extracted from the full file passing a value of false as prettier option will disabled prettifying -• **resolve**? : *[ResolverOptions](#resolveroptions)* +• **resolver**? : *[ResolverOptions](#resolveroptions)* Options to control resolving filenames. @@ -122,7 +138,37 @@ Options for extracting component information. • **resolveFile**? : *undefined | `(componentName: string, filePath: string) => string | undefined;`* -Callback function toresolve the source file name of a component. +Callback function to resolve the source file name of a component. +Return false if this file should not be processed. + + +• **storeSourceFile**? : *boolean* + +If set to false, will not save the component's source file. + + +• **package**? : *[PackageInfoOptions](#packageinfooptions) | false* + +Otions for extracting repository information from the component's package,json file. + +___ + +## StoriesOptions + +Options for extracting stories information. + +*Defined in [core/instrument/src/types.ts](https://github.com/atanasster/component-controls/blob/ab703a5/core/instrument/src/types.ts)* + +### Properties + +• **storeSourceFile**? : *boolean* + +If set to false, will not save the stories's source file, only the source of each individual story. + + +• **package**? : *[PackageInfoOptions](#packageinfooptions) | false* + +Options for extracting repository information from the component's package,json file. ___ @@ -201,6 +247,7 @@ Defaults to true if sourceType === 'module'. Otherwise, false. Adds all parsed tokens to a tokens property on the File node. +___ # PrettierOptions @@ -315,6 +362,7 @@ Whether or not to indent the code inside