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

components-helper

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

components-helper - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

CHANGELOG.md

61

lib/index.es.js

@@ -11,2 +11,3 @@ import { readFileSync, mkdir, writeFileSync } from 'fs';

fileNameRegExp: '\\/((\\w|-)+)\\.\\w+$',
separator: '/',
props: 'props',

@@ -18,3 +19,2 @@ propsName: 'Name',

propsDefault: 'Default',
separator: '/',
events: 'events',

@@ -57,2 +57,25 @@ eventsName: 'Name',

}
function getVeturDescription(options, description, defaultVal, docUrl) {
var reVeturDescription = options.reVeturDescription;
if (isFunction(reVeturDescription)) {
return reVeturDescription(description, defaultVal, docUrl);
}
else {
var str = description || '';
if (defaultVal) {
str += (str ? ', ' : '') + "default: " + defaultVal + ".";
}
if (docUrl) {
str += (str ? '\n\n' : '') + "[Docs](" + docUrl + ")";
}
return str ? str : undefined;
}
}
function getWebTypesSource(options, title, fileName, path) {
if (title === void 0) { title = ''; }
var name = options.name, reWebTypesSource = options.reWebTypesSource;
return isFunction(reWebTypesSource)
? reWebTypesSource(title, fileName, path)
: { module: name, symbol: title };
}

@@ -82,3 +105,3 @@ function parse(options, file) {

var title = tableContent ? tableContent[1] : '';
var header = tableContent ? parseColumn(tableContent[2]) : undefined;
var header = tableContent ? parseRow(tableContent[2]) : undefined;
var columns = tableContent ? tableContent[3] : undefined;

@@ -94,3 +117,3 @@ var content = [];

}
function parseColumn(str) {
function parseRow(str) {
return str

@@ -112,3 +135,3 @@ .replace(/^\|/, '')

var column_1 = {};
var list_1 = parseColumn(item);
var list_1 = parseRow(item);
list_1.forEach(function (value, index) {

@@ -241,3 +264,3 @@ var key = header[index];

function vetur(options, list) {
var propsName = options.propsName, propsType = options.propsType, propsDescription = options.propsDescription, propsOptions = options.propsOptions, propsDefault = options.propsDefault, separator = options.separator, eventsName = options.eventsName, eventsDescription = options.eventsDescription, slotsSubtags = options.slotsSubtags, reVeturDescription = options.reVeturDescription;
var propsName = options.propsName, propsType = options.propsType, propsDescription = options.propsDescription, propsOptions = options.propsOptions, propsDefault = options.propsDefault, separator = options.separator, eventsName = options.eventsName, eventsDescription = options.eventsDescription, slotsSubtags = options.slotsSubtags;
var tagsList = {};

@@ -270,5 +293,3 @@ var propsList = {};

: undefined;
var _description_1 = isFunction(reVeturDescription)
? reVeturDescription(item[propsDescription], item[propsDefault], docUrl_1)
: reDescription(item[propsDescription], item[propsDefault], docUrl_1);
var _description_1 = getVeturDescription(options, item[propsDescription], item[propsDefault], docUrl_1);
tagsProps.push(_item);

@@ -287,5 +308,3 @@ propsList[_name] = {

var _name = name + '/' + _item;
var _description_2 = isFunction(reVeturDescription)
? reVeturDescription(item[eventsDescription], undefined, docUrl_2)
: reDescription(item[eventsDescription], undefined, docUrl_2);
var _description_2 = getVeturDescription(options, item[eventsDescription], undefined, docUrl_2);
tagsProps.push(_item);

@@ -307,6 +326,4 @@ propsList[_name] = {

});
var docUrl = getDocUrl(options, fileName, events === null || events === void 0 ? void 0 : events.title, path);
var _description = isFunction(reVeturDescription)
? reVeturDescription(description, undefined, docUrl)
: reDescription(description, undefined, docUrl);
var docUrl = getDocUrl(options, fileName, title, path);
var _description = getVeturDescription(options, description, undefined, docUrl);
tagsList[name] = {

@@ -323,12 +340,2 @@ attributes: checkArray(tagsProps),

}
function reDescription(description, defaultVal, docUrl) {
var str = description || '';
if (defaultVal) {
str += (str ? ', ' : '') + "default: " + defaultVal + ".";
}
if (docUrl) {
str += (str ? '\n\n' : '') + "[Docs](" + docUrl + ")";
}
return str ? str : undefined;
}

@@ -339,3 +346,3 @@ function webTypes(options, list) {

return {
$schema: 'http://json.schemastore.org/web-types',
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
framework: 'vue',

@@ -373,2 +380,3 @@ name: name,

name: _item,
source: getWebTypesSource(options, title, fileName, path),
description: item[directivesDescription],

@@ -435,2 +443,3 @@ 'doc-url': getDocUrl(options, fileName, directives === null || directives === void 0 ? void 0 : directives.title, path),

name: name,
source: getWebTypesSource(options, title, fileName, path),
description: description,

@@ -437,0 +446,0 @@ 'doc-url': getDocUrl(options, fileName, title, path),

@@ -8,2 +8,3 @@ (function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('fs'),require('path')):typeof define==='function'&&define.amd?define(['exports','fs','path'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.ComponentsHelper={},g.fs,g.path));}(this,(function(exports, fs, path){'use strict';var config = {

fileNameRegExp: '\\/((\\w|-)+)\\.\\w+$',
separator: '/',
props: 'props',

@@ -15,3 +16,2 @@ propsName: 'Name',

propsDefault: 'Default',
separator: '/',
events: 'events',

@@ -49,2 +49,25 @@ eventsName: 'Name',

return isFunction(reDocUrl) ? reDocUrl(fileName, header, path) : undefined;
}
function getVeturDescription(options, description, defaultVal, docUrl) {
var reVeturDescription = options.reVeturDescription;
if (isFunction(reVeturDescription)) {
return reVeturDescription(description, defaultVal, docUrl);
}
else {
var str = description || '';
if (defaultVal) {
str += (str ? ', ' : '') + "default: " + defaultVal + ".";
}
if (docUrl) {
str += (str ? '\n\n' : '') + "[Docs](" + docUrl + ")";
}
return str ? str : undefined;
}
}
function getWebTypesSource(options, title, fileName, path) {
if (title === void 0) { title = ''; }
var name = options.name, reWebTypesSource = options.reWebTypesSource;
return isFunction(reWebTypesSource)
? reWebTypesSource(title, fileName, path)
: { module: name, symbol: title };
}function parse(options, file) {

@@ -73,3 +96,3 @@ var titleRegExp = options.titleRegExp, tableRegExp = options.tableRegExp;

var title = tableContent ? tableContent[1] : '';
var header = tableContent ? parseColumn(tableContent[2]) : undefined;
var header = tableContent ? parseRow(tableContent[2]) : undefined;
var columns = tableContent ? tableContent[3] : undefined;

@@ -85,3 +108,3 @@ var content = [];

}
function parseColumn(str) {
function parseRow(str) {
return str

@@ -103,3 +126,3 @@ .replace(/^\|/, '')

var column_1 = {};
var list_1 = parseColumn(item);
var list_1 = parseRow(item);
list_1.forEach(function (value, index) {

@@ -228,3 +251,3 @@ var key = header[index];

}function vetur(options, list) {
var propsName = options.propsName, propsType = options.propsType, propsDescription = options.propsDescription, propsOptions = options.propsOptions, propsDefault = options.propsDefault, separator = options.separator, eventsName = options.eventsName, eventsDescription = options.eventsDescription, slotsSubtags = options.slotsSubtags, reVeturDescription = options.reVeturDescription;
var propsName = options.propsName, propsType = options.propsType, propsDescription = options.propsDescription, propsOptions = options.propsOptions, propsDefault = options.propsDefault, separator = options.separator, eventsName = options.eventsName, eventsDescription = options.eventsDescription, slotsSubtags = options.slotsSubtags;
var tagsList = {};

@@ -257,5 +280,3 @@ var propsList = {};

: undefined;
var _description_1 = isFunction(reVeturDescription)
? reVeturDescription(item[propsDescription], item[propsDefault], docUrl_1)
: reDescription(item[propsDescription], item[propsDefault], docUrl_1);
var _description_1 = getVeturDescription(options, item[propsDescription], item[propsDefault], docUrl_1);
tagsProps.push(_item);

@@ -274,5 +295,3 @@ propsList[_name] = {

var _name = name + '/' + _item;
var _description_2 = isFunction(reVeturDescription)
? reVeturDescription(item[eventsDescription], undefined, docUrl_2)
: reDescription(item[eventsDescription], undefined, docUrl_2);
var _description_2 = getVeturDescription(options, item[eventsDescription], undefined, docUrl_2);
tagsProps.push(_item);

@@ -294,6 +313,4 @@ propsList[_name] = {

});
var docUrl = getDocUrl(options, fileName, events === null || events === void 0 ? void 0 : events.title, path);
var _description = isFunction(reVeturDescription)
? reVeturDescription(description, undefined, docUrl)
: reDescription(description, undefined, docUrl);
var docUrl = getDocUrl(options, fileName, title, path);
var _description = getVeturDescription(options, description, undefined, docUrl);
tagsList[name] = {

@@ -309,12 +326,2 @@ attributes: checkArray(tagsProps),

return { tags: tagsList, attributes: propsList };
}
function reDescription(description, defaultVal, docUrl) {
var str = description || '';
if (defaultVal) {
str += (str ? ', ' : '') + "default: " + defaultVal + ".";
}
if (docUrl) {
str += (str ? '\n\n' : '') + "[Docs](" + docUrl + ")";
}
return str ? str : undefined;
}function webTypes(options, list) {

@@ -324,3 +331,3 @@ var name = options.name, version = options.version;

return {
$schema: 'http://json.schemastore.org/web-types',
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
framework: 'vue',

@@ -358,2 +365,3 @@ name: name,

name: _item,
source: getWebTypesSource(options, title, fileName, path),
description: item[directivesDescription],

@@ -420,2 +428,3 @@ 'doc-url': getDocUrl(options, fileName, directives === null || directives === void 0 ? void 0 : directives.title, path),

name: name,
source: getWebTypesSource(options, title, fileName, path),
description: description,

@@ -422,0 +431,0 @@ 'doc-url': getDocUrl(options, fileName, title, path),

declare type ReComponentName = (title: string, fileName: string, path: string) => string;
declare type ReDocUrl = (fileName: string, header?: string, path?: string) => string;
declare type ReDocUrl = (fileName: string, header?: string, path?: string) => string | undefined;
declare type ReAttribute = (value: string, key: string, columns: string[], title: string) => string | undefined;
declare type ReVeturDescription = (description?: string, defaultValue?: string, docUrl?: string) => string;
declare type ReVeturDescription = (description?: string, defaultValue?: string, docUrl?: string) => string | undefined;
declare type ReWebTypesSource = (title: string, fileName: string, path: string) => Source;
interface OptionsConfig {

@@ -15,2 +16,3 @@ entry: string;

reVeturDescription?: ReVeturDescription;
reWebTypesSource?: ReWebTypesSource;
}

@@ -24,2 +26,3 @@ export interface Config {

fileNameRegExp: string;
separator: string;
props: string;

@@ -31,3 +34,2 @@ propsName: string;

propsDefault: string;
separator: string;
events: string;

@@ -105,4 +107,12 @@ eventsName: string;

}
export declare type Source = {
module?: string;
symbol: string;
} | {
file: string;
offset: number;
};
export interface WebTag {
name: string;
source: Source;
description?: string;

@@ -116,2 +126,3 @@ 'doc-url'?: string;

name: string;
source: Source;
description?: string;

@@ -118,0 +129,0 @@ 'doc-url'?: string;

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

import type { Options } from './type';
import type { Options, Source } from './type';
export declare function hyphenate(str: string): string;

@@ -7,1 +7,3 @@ export declare function checkArray<T extends Array<unknown>>(item: T): T | undefined;

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;
{
"name": "components-helper",
"version": "1.0.3",
"version": "1.0.4",
"description": "Based on the docs to provide code prompt files for vue component library",

@@ -45,2 +45,5 @@ "main": "lib/index.js",

"homepage": "https://github.com/tolking/components-helper#readme",
"engines": {
"node": ">10.0.0"
},
"dependencies": {

@@ -47,0 +50,0 @@ "fast-glob": "^3.2.5"

# components-helper
> Based on the docs to provide code prompt files for vue component library
> Based on the documents to provide code prompt files for vue component library
nodejs ^10
Reference documents format reference test files
[Changelog](./CHANGELOG.md)
## Installation

@@ -44,4 +46,40 @@

### entry (required)
- [entry (required)](#entry)
- [outDir (required)](#outdir)
- [name (required)](#name)
- [version (required)](#version)
- [space](#space)
- [separator](#separator)
- [reComponentName](#recomponentname)
- [reDocUrl](#redocurl)
- [reAttribute](#reattribute)
- [reVeturDescription](#reveturdescription)
- [reWebTypesSource](#rewebtypessource)
- [tags](#tags)
- [attributes](#attributes)
- [webTypes](#webtypes)
- [props](#props)
- [propsName](#propsname)
- [propsDescription](#propsdescription)
- [propsType](#propstype)
- [propsOptions](#propsoptions)
- [propsDefault](#propsdefault)
- [events](#events)
- [eventsName](#eventsname)
- [eventsDescription](#eventsdescription)
- [slots](#slots)
- [slotsName](#slotsname)
- [slotsDescription](#slotsdescription)
- [slotsSubtags](#slotssubtags)
- [directives](#directives)
- [directivesName](#directivesname)
- [directivesDescription](#directivesdescription)
- [directivesType](#directivestype)
- [titleRegExp](#titleregexp)
- [tableRegExp](#tableregexp)
- [fileNameRegExp](#filenameregexp)
### entry
- Required: `true`
- Type: `string`

@@ -51,3 +89,3 @@

For example:
for example:
- `docs/*.md` -- matches all files in the docs

@@ -57,4 +95,5 @@ - `docs/(a|b).md` -- matches files `a.md` and `b.md`

### outDir (required)
### outDir
- Required: `true`
- Type: `string`

@@ -68,23 +107,39 @@

- Required: `true`
- Type: `string`
name of the component library
name of the component library.
### version
- Required: `true`
- Type: `string`
version of the component library
version of the component library.
### space
- Type: `number` | `string`
Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read
### separator
- Type: `string`
- Default: `/`
the separator for propsOptions, slotsSubtags, type ...
### reComponentName
- Type: `(title: string, fileName: string, path: string) => string`
- Defult: `hyphenate(title || fileName)`
rewriting the name of the component
For example: `(title) => 'prefix-' + title.replace(/\B([A-Z])/g, '-$1').toLowerCase()`
for example: `(title) => 'prefix-' + title.replace(/\B([A-Z])/g, '-$1').toLowerCase()`
### reDocUrl
- Type: `(fileName: string, header?: string) => string`
- Type: `(fileName: string, header?: string, path: string) => string | undefind`

@@ -95,4 +150,11 @@ rewriting the doc url of the component

- Type: `(value: string, key: string, columns: string[], title: string) => string | undefined`
- Type: `(value: string, key: string, row: string[], title: string) => string | undefined`
##### arg
- value: current value
- key: the key value of the current column
- row: all values of the current row
- title: the title of current tabel
rewriting the attribute of the component

@@ -107,7 +169,8 @@

### space
### reWebTypesSource
- Type: `number` | `string`
- Type: `(title: string, fileName: string, path: string) => { module?: string; symbol: string } | { file: string; offset: number }`
- Default: `{ symbol: title }`
Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read
rewriting the source of web-types. (the name of export from conmonents library)

@@ -135,9 +198,2 @@ ### tags

### separator
- Type: `string`
- Default: `/`
the separator for propsOptions and slotsSubtags
### props

@@ -144,0 +200,0 @@

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