components-helper
Advanced tools
Comparing version 2.1.1 to 2.1.2
# Changelog | ||
### 2.1.2 | ||
feat | ||
- support filter options from type ([view instructions for use](./test/mult.md)) | ||
- export utils functions | ||
fix | ||
- miss type boolean | ||
- partial separator not replaced | ||
### 2.1.1 | ||
@@ -4,0 +16,0 @@ |
@@ -9,3 +9,4 @@ import { main } from './main'; | ||
export * from './write'; | ||
export * from './utils'; | ||
export * from './type'; | ||
export default main; |
@@ -47,2 +47,3 @@ import fg from'fast-glob';import {readFileSync,mkdir,writeFileSync}from'fs';import {resolve}from'path';var config = { | ||
'number', | ||
'boolean', | ||
'object', | ||
@@ -52,2 +53,3 @@ 'array', | ||
'Number', | ||
'Boolean', | ||
'Object', | ||
@@ -87,2 +89,8 @@ 'Array(<.*>)?', | ||
} | ||
function isEnumType(type) { | ||
return /^'\w*'$/.test(type) || /^"\w*"$/.test(type); | ||
} | ||
function isUnionType(type) { | ||
return /(\||&)/.test(type); | ||
} | ||
function arrayToRegExp(arr, flags) { | ||
@@ -141,5 +149,9 @@ return new RegExp("^(".concat(arr.join('|'), ")$"), flags); | ||
function getType(type) { | ||
var isEnum = isEnumType(type); | ||
var isPublicType = isCommonType(type); | ||
var symbol = getTypeSymbol(type); | ||
return isPublicType || !symbol ? type : { name: type, source: { symbol: symbol } }; | ||
var isUnion = isUnionType(symbol); | ||
return isEnum || isPublicType || !symbol || isUnion | ||
? type | ||
: { name: type, source: { symbol: symbol } }; | ||
} | ||
@@ -163,2 +175,18 @@ function getWebTypesType(options, type) { | ||
} | ||
} | ||
function filterVeturOptions(options, type) { | ||
var list = splitString(options, type); | ||
if (list === null || list === void 0 ? void 0 : list.length) { | ||
var result = []; | ||
for (var i = 0; i < list.length; i++) { | ||
var item = list[i]; | ||
var isEnum = isEnumType(item); | ||
var len = item.length; | ||
isEnum && result.push(item.slice(1, len - 1)); | ||
} | ||
return result; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
}function parse(options, file) { | ||
@@ -359,7 +387,6 @@ var _file = normalizeFile(file); | ||
var _name = name + '/' + _item; | ||
var _type = (item[propsType] || '').replace(separator, '|'); | ||
var _type = (item[propsType] || '').replaceAll(separator, '|'); | ||
var _options = item[propsOptions]; | ||
var _optionsList = /string/i.test(_type) && _options | ||
? splitString(options, _options) | ||
: undefined; | ||
var _optionsList = splitString(options, _options); | ||
var _typeOptionsList = filterVeturOptions({ separator: '|' }, _type); | ||
var _description_1 = getVeturDescription(options, item[propsDescription], item[propsDefault], docUrl_1); | ||
@@ -369,3 +396,3 @@ tagsProps.push(_item); | ||
type: _type || undefined, | ||
options: _optionsList, | ||
options: checkArray(_optionsList || _typeOptionsList), | ||
description: _description_1, | ||
@@ -550,2 +577,2 @@ }; | ||
write(_options, 'webTypes', webTypesData); | ||
}export{main as default,getWebTypes,main,normalize,parse,parseColumns,parseRow,parseTable,parseTitle,read,vetur,webTypes,write}; | ||
}export{arrayToRegExp,checkArray,main as default,filterVeturOptions,getComponentsName,getDocUrl,getTypeSymbol,getVeturDescription,getWebTypes,getWebTypesSource,getWebTypesType,hyphenate,isCommonType,isEnumType,isFunction,isString,isUnionType,main,normalize,normalizeFile,parse,parseColumns,parseRow,parseTable,parseTitle,read,splitString,vetur,webTypes,write}; |
@@ -47,2 +47,3 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var fg=require('fast-glob'),fs=require('fs'),path=require('path');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var fg__default=/*#__PURE__*/_interopDefaultLegacy(fg);var config = { | ||
'number', | ||
'boolean', | ||
'object', | ||
@@ -52,2 +53,3 @@ 'array', | ||
'Number', | ||
'Boolean', | ||
'Object', | ||
@@ -87,2 +89,8 @@ 'Array(<.*>)?', | ||
} | ||
function isEnumType(type) { | ||
return /^'\w*'$/.test(type) || /^"\w*"$/.test(type); | ||
} | ||
function isUnionType(type) { | ||
return /(\||&)/.test(type); | ||
} | ||
function arrayToRegExp(arr, flags) { | ||
@@ -141,5 +149,9 @@ return new RegExp("^(".concat(arr.join('|'), ")$"), flags); | ||
function getType(type) { | ||
var isEnum = isEnumType(type); | ||
var isPublicType = isCommonType(type); | ||
var symbol = getTypeSymbol(type); | ||
return isPublicType || !symbol ? type : { name: type, source: { symbol: symbol } }; | ||
var isUnion = isUnionType(symbol); | ||
return isEnum || isPublicType || !symbol || isUnion | ||
? type | ||
: { name: type, source: { symbol: symbol } }; | ||
} | ||
@@ -163,2 +175,18 @@ function getWebTypesType(options, type) { | ||
} | ||
} | ||
function filterVeturOptions(options, type) { | ||
var list = splitString(options, type); | ||
if (list === null || list === void 0 ? void 0 : list.length) { | ||
var result = []; | ||
for (var i = 0; i < list.length; i++) { | ||
var item = list[i]; | ||
var isEnum = isEnumType(item); | ||
var len = item.length; | ||
isEnum && result.push(item.slice(1, len - 1)); | ||
} | ||
return result; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
}function parse(options, file) { | ||
@@ -359,7 +387,6 @@ var _file = normalizeFile(file); | ||
var _name = name + '/' + _item; | ||
var _type = (item[propsType] || '').replace(separator, '|'); | ||
var _type = (item[propsType] || '').replaceAll(separator, '|'); | ||
var _options = item[propsOptions]; | ||
var _optionsList = /string/i.test(_type) && _options | ||
? splitString(options, _options) | ||
: undefined; | ||
var _optionsList = splitString(options, _options); | ||
var _typeOptionsList = filterVeturOptions({ separator: '|' }, _type); | ||
var _description_1 = getVeturDescription(options, item[propsDescription], item[propsDefault], docUrl_1); | ||
@@ -369,3 +396,3 @@ tagsProps.push(_item); | ||
type: _type || undefined, | ||
options: _optionsList, | ||
options: checkArray(_optionsList || _typeOptionsList), | ||
description: _description_1, | ||
@@ -550,2 +577,2 @@ }; | ||
write(_options, 'webTypes', webTypesData); | ||
}exports["default"]=main;exports.getWebTypes=getWebTypes;exports.main=main;exports.normalize=normalize;exports.parse=parse;exports.parseColumns=parseColumns;exports.parseRow=parseRow;exports.parseTable=parseTable;exports.parseTitle=parseTitle;exports.read=read;exports.vetur=vetur;exports.webTypes=webTypes;exports.write=write; | ||
}exports.arrayToRegExp=arrayToRegExp;exports.checkArray=checkArray;exports["default"]=main;exports.filterVeturOptions=filterVeturOptions;exports.getComponentsName=getComponentsName;exports.getDocUrl=getDocUrl;exports.getTypeSymbol=getTypeSymbol;exports.getVeturDescription=getVeturDescription;exports.getWebTypes=getWebTypes;exports.getWebTypesSource=getWebTypesSource;exports.getWebTypesType=getWebTypesType;exports.hyphenate=hyphenate;exports.isCommonType=isCommonType;exports.isEnumType=isEnumType;exports.isFunction=isFunction;exports.isString=isString;exports.isUnionType=isUnionType;exports.main=main;exports.normalize=normalize;exports.normalizeFile=normalizeFile;exports.parse=parse;exports.parseColumns=parseColumns;exports.parseRow=parseRow;exports.parseTable=parseTable;exports.parseTitle=parseTitle;exports.read=read;exports.splitString=splitString;exports.vetur=vetur;exports.webTypes=webTypes;exports.write=write; |
@@ -7,10 +7,13 @@ import type { Options, Source, BaseContribution } from './type'; | ||
export declare function isCommonType(type: string): boolean; | ||
export declare function isEnumType(type: string): boolean; | ||
export declare function isUnionType(type: string): boolean; | ||
export declare function arrayToRegExp(arr: string[], flags?: string): RegExp; | ||
export declare function getTypeSymbol(type: string): string; | ||
export declare function normalizeFile(file: string): string; | ||
export declare function splitString(options: Options, str?: string): string[] | undefined; | ||
export declare function getComponentsName(options: Options, title: string | undefined, fileName: string, path: string): string; | ||
export declare function getDocUrl(options: Options, fileName: string, header?: string, path?: string): string | undefined; | ||
export declare function getVeturDescription(options: Options, description?: string, defaultVal?: string, docUrl?: string): string | undefined; | ||
export declare function getWebTypesSource(options: Options, title: string | undefined, fileName: string, path: string): Source; | ||
export declare function getWebTypesType(options: Options, type?: string): undefined | Array<string | BaseContribution>; | ||
export declare function splitString(options: Pick<Options, 'separator'>, str?: string): string[] | undefined; | ||
export declare function getComponentsName(options: Pick<Options, 'reComponentName'>, title: string | undefined, fileName: string, path: string): string; | ||
export declare function getDocUrl(options: Pick<Options, 'reDocUrl'>, fileName: string, header?: string, path?: string): string | undefined; | ||
export declare function getVeturDescription(options: Pick<Options, 'reVeturDescription'>, description?: string, defaultVal?: string, docUrl?: string): string | undefined; | ||
export declare function getWebTypesSource(options: Pick<Options, 'reWebTypesSource'>, title: string | undefined, fileName: string, path: string): Source; | ||
export declare function getWebTypesType(options: Pick<Options, 'reWebTypesType' | 'separator'>, type?: string): undefined | Array<string | BaseContribution>; | ||
export declare function filterVeturOptions(options: Pick<Options, 'separator'>, type?: string): string[] | undefined; |
{ | ||
"name": "components-helper", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Based on the docs to provide code prompt files for vue component library", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -48,2 +48,3 @@ # components-helper | ||
<summary>TOC</summary> | ||
- [entry (required)](#entry) | ||
@@ -84,2 +85,3 @@ - [outDir (required)](#outdir) | ||
- [fileNameRegExp](#filenameregexp) | ||
</details> | ||
@@ -192,3 +194,3 @@ | ||
name for attributes of the vetur | ||
name for attributes of the Vetur | ||
@@ -200,3 +202,3 @@ ### webTypes | ||
name for web-types of the webstrom | ||
name for web-types of the WebStorm | ||
@@ -203,0 +205,0 @@ ### props |
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
78846
1608
422