feat #6
@@ -3,21 +3,31 @@ import globals from 'globals'
|
|||||||
import reactHooks from 'eslint-plugin-react-hooks'
|
import reactHooks from 'eslint-plugin-react-hooks'
|
||||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||||
import tseslint from 'typescript-eslint'
|
import tseslint from 'typescript-eslint'
|
||||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
|
||||||
|
|
||||||
export default defineConfig([
|
export default tseslint.config(
|
||||||
globalIgnores(['dist']),
|
{
|
||||||
|
ignores: ['dist'],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
files: ['**/*.{ts,tsx}'],
|
|
||||||
extends: [
|
extends: [
|
||||||
js.configs.recommended,
|
js.configs.recommended,
|
||||||
tseslint.configs.recommended,
|
tseslint.configs.recommended,
|
||||||
reactHooks.configs.flat.recommended,
|
|
||||||
reactRefresh.configs.vite,
|
|
||||||
],
|
],
|
||||||
|
files: ['**/*.{ts,tsx}'],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
ecmaVersion: 2020,
|
ecmaVersion: 2020,
|
||||||
globals: globals.browser,
|
globals: globals.browser,
|
||||||
},
|
},
|
||||||
|
plugins: {
|
||||||
|
'react-hooks': reactHooks,
|
||||||
|
'react-refresh': reactRefresh,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...reactHooks.configs.recommended.rules,
|
||||||
|
'react-refresh/only-export-components': [
|
||||||
|
'warn',
|
||||||
|
{ allowConstantExport: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
])
|
)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export class EnvBuilder implements IBuilder<Env> {
|
|||||||
|
|
||||||
private params(): this {
|
private params(): this {
|
||||||
const tag = `<parameter name="{name}" value="{val}" />`;
|
const tag = `<parameter name="{name}" value="{val}" />`;
|
||||||
for (let p of this.src.params) {
|
for (const p of this.src.params) {
|
||||||
this.stack.push(this.ident);
|
this.stack.push(this.ident);
|
||||||
this.stack.push(tag
|
this.stack.push(tag
|
||||||
.replace("{name}", p.name ?? "!ERR!")
|
.replace("{name}", p.name ?? "!ERR!")
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export interface IBuilder<T> {
|
|||||||
|
|
||||||
export class Builder {
|
export class Builder {
|
||||||
public static getEnv(env: Env): IBuilder<Env> {
|
public static getEnv(env: Env): IBuilder<Env> {
|
||||||
let b = new EnvBuilder();
|
const b = new EnvBuilder();
|
||||||
b.src = env;
|
b.src = env;
|
||||||
return b;
|
return b;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|||||||
variant?: ButtonVariant;
|
variant?: ButtonVariant;
|
||||||
size?: ButtonSize;
|
size?: ButtonSize;
|
||||||
icon?: LucideIcon;
|
icon?: LucideIcon;
|
||||||
iconPosition?: 'left' | 'right';
|
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +32,6 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
variant = 'primary',
|
variant = 'primary',
|
||||||
size = 'md',
|
size = 'md',
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
iconPosition = 'left',
|
|
||||||
isLoading = false,
|
isLoading = false,
|
||||||
disabled,
|
disabled,
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const Card = forwardRef<HTMLDivElement, CardProps>(
|
|||||||
|
|
||||||
Card.displayName = 'Card';
|
Card.displayName = 'Card';
|
||||||
|
|
||||||
interface CardHeaderProps extends HTMLAttributes<HTMLDivElement> {}
|
type CardHeaderProps = HTMLAttributes<HTMLDivElement>;
|
||||||
|
|
||||||
export const CardHeader = forwardRef<HTMLDivElement, CardHeaderProps>(
|
export const CardHeader = forwardRef<HTMLDivElement, CardHeaderProps>(
|
||||||
({ className = '', children, ...props }, ref) => {
|
({ className = '', children, ...props }, ref) => {
|
||||||
@@ -52,7 +52,7 @@ export const CardHeader = forwardRef<HTMLDivElement, CardHeaderProps>(
|
|||||||
|
|
||||||
CardHeader.displayName = 'CardHeader';
|
CardHeader.displayName = 'CardHeader';
|
||||||
|
|
||||||
interface CardBodyProps extends HTMLAttributes<HTMLDivElement> {}
|
type CardBodyProps = HTMLAttributes<HTMLDivElement>;
|
||||||
|
|
||||||
export const CardBody = forwardRef<HTMLDivElement, CardBodyProps>(
|
export const CardBody = forwardRef<HTMLDivElement, CardBodyProps>(
|
||||||
({ className = '', children, ...props }, ref) => {
|
({ className = '', children, ...props }, ref) => {
|
||||||
@@ -66,7 +66,7 @@ export const CardBody = forwardRef<HTMLDivElement, CardBodyProps>(
|
|||||||
|
|
||||||
CardBody.displayName = 'CardBody';
|
CardBody.displayName = 'CardBody';
|
||||||
|
|
||||||
interface CardFooterProps extends HTMLAttributes<HTMLDivElement> {}
|
type CardFooterProps = HTMLAttributes<HTMLDivElement>;
|
||||||
|
|
||||||
export const CardFooter = forwardRef<HTMLDivElement, CardFooterProps>(
|
export const CardFooter = forwardRef<HTMLDivElement, CardFooterProps>(
|
||||||
({ className = '', children, ...props }, ref) => {
|
({ className = '', children, ...props }, ref) => {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export class Config {
|
|||||||
* Updates template by adding placeholders for environment params
|
* Updates template by adding placeholders for environment params
|
||||||
*/
|
*/
|
||||||
public updateTemplateFromEnv(env: Env): void {
|
public updateTemplateFromEnv(env: Env): void {
|
||||||
let templateObj: Record<string, any> = {};
|
let templateObj: Record<string, string> = {};
|
||||||
|
|
||||||
// Try to parse existing template
|
// Try to parse existing template
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ const cfgTemplate = `
|
|||||||
|
|
||||||
|
|
||||||
test("read from a file", async ({expect})=>{
|
test("read from a file", async ({expect})=>{
|
||||||
let sut = new ConfigReader();
|
const sut = new ConfigReader();
|
||||||
let file = new File([cfgTemplate],'cfg.json.xml',{type:'application/xml'});
|
const file = new File([cfgTemplate],'cfg.json.xml',{type:'application/xml'});
|
||||||
|
|
||||||
// define a missing jsdom text() function,
|
// define a missing jsdom text() function,
|
||||||
// that presents in the real DOM
|
// that presents in the real DOM
|
||||||
@@ -46,15 +46,15 @@ test("read from a file", async ({expect})=>{
|
|||||||
writable: true
|
writable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
let cfg = await sut.parseFromFile(file);
|
const cfg = await sut.parseFromFile(file);
|
||||||
|
|
||||||
expect(cfg).not.toBeUndefined();
|
expect(cfg).not.toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("load environments and params", ({expect})=>{
|
test("load environments and params", ({expect})=>{
|
||||||
let sut = new ConfigReader();
|
const sut = new ConfigReader();
|
||||||
|
|
||||||
let cfg = sut.parseFromString(cfgTemplate);
|
const cfg = sut.parseFromString(cfgTemplate);
|
||||||
|
|
||||||
expect(cfg?.envs).toHaveLength(3);
|
expect(cfg?.envs).toHaveLength(3);
|
||||||
expect(cfg?.envs.map(x=>x.name))
|
expect(cfg?.envs.map(x=>x.name))
|
||||||
@@ -64,9 +64,9 @@ test("load environments and params", ({expect})=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("load template", ({expect})=>{
|
test("load template", ({expect})=>{
|
||||||
let sut = new ConfigReader();
|
const sut = new ConfigReader();
|
||||||
|
|
||||||
let cfg = sut.parseFromString(cfgTemplate);
|
const cfg = sut.parseFromString(cfgTemplate);
|
||||||
|
|
||||||
expect(cfg?.template).toBeDefined();
|
expect(cfg?.template).toBeDefined();
|
||||||
expect(cfg?.template.content.length).toBeGreaterThan(20);
|
expect(cfg?.template.content.length).toBeGreaterThan(20);
|
||||||
|
|||||||
Reference in New Issue
Block a user