This commit is contained in:
Jorge Mario Arita Ramírez 2024-01-21 18:20:18 -06:00
parent 4433dbd5aa
commit 135f6261cc
9 changed files with 54 additions and 31 deletions

View File

@ -0,0 +1,26 @@
const fs = require('fs')
const path = require('path')
const componentsDir = path.resolve(__dirname, 'dist/components')
fs.readdir(componentsDir, { withFileTypes: true }, (err, entries) => {
if (err) {
console.error('Error al leer el directorio de componentes:', err)
process.exit(1)
}
entries.forEach(entry => {
if (entry.isDirectory()) {
const componentDirPath = path.join(componentsDir, entry.name)
const packageJson = {
sideEffects: false,
module: './index.js',
main: './index.js',
types: './index.d.ts'
}
fs.writeFileSync(path.join(componentDirPath, 'package.json'), JSON.stringify(packageJson, null, 2))
console.log(`package.json creado para el componente ${entry.name}`)
}
})
})

View File

@ -1,5 +0,0 @@
import React from 'react';
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
title: string;
onClick?: () => void;
}

View File

@ -1,3 +1,7 @@
import { ButtonProps } from './button.type'; import React from 'react';
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
title: string;
onClick?: () => void;
}
declare const Button: ({ title, onClick }: ButtonProps) => any; declare const Button: ({ title, onClick }: ButtonProps) => any;
export default Button; export default Button;

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import { cn } from '@/lib/utils'\r\nimport React from 'react'\r\nimport { ButtonProps } from './button.type'\r\n\r\nconst Button = ({ title, onClick }: ButtonProps) => {\r\n return (\r\n <div className={cn(\r\n 'bg-blue-500',\r\n 'text-white'\r\n )}\r\n onClick={onClick}\r\n >\r\n {title}\r\n </div>\r\n )\r\n}\r\n\r\nexport default Button"],"names":["Button","_ref","title","onClick","React","createElement","className","cn"],"mappings":"6DAIA,IAAMA,EAAS,SAAHC,GAAuC,IAAjCC,EAAKD,EAALC,MAAOC,EAAOF,EAAPE,QACvB,OACEC,EAAKC,cAAA,MAAA,CAAAC,UAAWC,EACd,cACA,cAEFJ,QAASA,GAEND,EAGP"} {"version":3,"file":"index.js","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import { cn } from '@/lib/utils'\r\nimport React from 'react'\r\ninterface ButtonProps\r\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\r\n title: string\r\n onClick?: () => void\r\n}\r\n\r\nconst Button = ({ title, onClick }: ButtonProps) => {\r\n return (\r\n <div className={cn(\r\n 'bg-blue-500',\r\n 'text-white'\r\n )}\r\n onClick={onClick}\r\n >\r\n {title}\r\n </div>\r\n )\r\n}\r\n\r\nexport default Button"],"names":["Button","_ref","title","onClick","React","createElement","className","cn"],"mappings":"6DAQA,IAAMA,EAAS,SAAHC,GAAuC,IAAjCC,EAAKD,EAALC,MAAOC,EAAOF,EAAPE,QACvB,OACEC,EAAKC,cAAA,MAAA,CAAAC,UAAWC,EACd,cACA,cAEFJ,QAASA,GAEND,EAGP"}

6
dist/components/button/package.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"sideEffects": false,
"module": "./index.js",
"main": "./index.js",
"types": "./index.d.ts"
}

6
dist/components/input/package.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"sideEffects": false,
"module": "./index.js",
"main": "./index.js",
"types": "./index.d.ts"
}

View File

@ -1,21 +1,9 @@
{ {
"name": "library-template", "name": "library-template",
"version": "1.0.3", "version": "1.0.4",
"type": "module", "type": "module",
"exports": { "main": "dist/index.js",
".": { "types": "dist/index.d.ts",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./button": {
"import": "./dist/components/button/index.js",
"types": "./dist/components/button/index.d.ts"
},
"./input": {
"import": "./dist/components/input/index.js",
"types": "./dist/components/input/index.d.ts"
}
},
"files": [ "files": [
"dist" "dist"
], ],
@ -32,7 +20,8 @@
"rollupPrebuild": "rimraf srs && rimraf dist", "rollupPrebuild": "rimraf srs && rimraf dist",
"rollupBuild": "rollup -c --bundleConfigAsCjs", "rollupBuild": "rollup -c --bundleConfigAsCjs",
"rollupBuildProd": "rollup -c --environment NODE_ENV:production", "rollupBuildProd": "rollup -c --environment NODE_ENV:production",
"deploy": "git pull origin main && yarn rollupPrebuild && yarn rollupBuildProd && git add . && yarn version --patch && git push origin dev_ja && git push origin --tags" "postbuild": "node create-component-packages.cjs",
"deploy": "git pull origin main && yarn rollupPrebuild && yarn rollupBuildProd && yarn postbuild && git add . && yarn version --patch && git push origin dev_ja && git push origin --tags"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.23.7", "@babel/core": "^7.23.7",

View File

@ -1,7 +0,0 @@
import React from 'react'
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
title: string
onClick?: () => void
}

View File

@ -1,6 +1,10 @@
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import React from 'react' import React from 'react'
import { ButtonProps } from './button.type' interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
title: string
onClick?: () => void
}
const Button = ({ title, onClick }: ButtonProps) => { const Button = ({ title, onClick }: ButtonProps) => {
return ( return (