bernova 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/bin/buildstyle.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed the const name
|
|
8
|
+
|
|
9
|
+
Pull Request
|
|
10
|
+
|
|
11
|
+
## 1.5.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Fixed the error behaviour in build style script
|
|
16
|
+
|
|
17
|
+
Pull Request
|
|
18
|
+
|
|
3
19
|
## 1.5.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/bin/buildstyle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const e=require("fs").promises,
|
|
2
|
+
const e=require("fs").promises,t=require("path"),s=require("@babel/core"),{minify:a}=require("terser"),{extractDocFragment:n,writeDoc:r,fileExists:o,readConfigData:i}=require("../src/lib");async function c({baseOutPath:s,jsFile:a,rootDir:i,customOutDirs:c,dir:l,minifyJS:m,preventMoveJS:d,provider:h,type:v="",embedCss:y,cssFiles:b}){const g=a.name.endsWith(".d.ts"),P=t.resolve(l,a.path,a.name);if(!o(l,P))return void console.error(`File not found: ${P}`);let j=await e.readFile(P,"utf8");const D=!!c?.css||y&&b.length>0;if("cssTheme.js"===a.name&&D){const s=j.replace("export default","").replaceAll(";","").trim(),a=new Function(`return (${s})`)();if(c?.css)j=`export default {\n${f({cssThemes:a,cssOutPath:c.css})}};\n`;else if(y&&b.length>0){const s=Object.keys(a)[0],n=b.find(e=>e.name===`${s}.css`||e.name===`${s}.min.css`);if(n){const{name:a,path:r}=n,i=t.resolve(l,r,a),c=o(l,i)?(await e.readFile(i,"utf8")).replace(/\s+/g,""):"",m={before:"",after:""};for(const a of b){const{name:n,path:r,parent:i}=a;if(i)for(const{name:a,position:c}of i)if(a===s){const s=t.resolve(l,r,n);if(o(l,s)){const t=(await e.readFile(s,"utf8")).replace(/\s+/g,"");m[c]+=t}}}const p=m.before+c+m.after;j=`export default {'${s}':{css:\`${p}\`}};`}}}if(a.name===`${h.name.toLocaleLowerCase()}.js`&&y&&b.length>0){const s="\n #linkBuilder = (css, id) => {\n if (typeof document === 'undefined') return;\n let styleElement = document.getElementById(id);\n if (!styleElement) {\n styleElement = document.createElement('style');\n styleElement.id = id;\n styleElement.type = 'text/css';\n document.head.appendChild(styleElement);\n }\n styleElement.innerHTML = css;\n };\n #handlerThemes = (data) => {\n const { css } = data;\n this.#linkBuilder(css, this.#linkId);\n };\n #cleanUpLinks = () => {\n if (typeof document === 'undefined') return;\n const style = document.getElementById(this.#linkId);\n if (style) style.remove();\n };\n ",a="../src/lib/generateProvider/template/providerTemplate.js";let r=await e.readFile(t.resolve(__dirname,a),"utf8");r=r.replace(/\$_Provider_\$/g,h.name);const o=n({section:"Bernova provider methods",doc:r});j=r.replace(o,s.trim())}if(a.name===`${h.name.toLocaleLowerCase()}.d.ts`&&y&&b.length>0){const s="\n #linkBuilder(css: string, id: string): void;\n #handlerThemes(data: { css: string }): void;\n #cleanUpLinks(): void;\n ",a="../src/lib/generateProvider/template/providerTemplate.d.ts";let r=await e.readFile(t.resolve(__dirname,a),"utf8");r=r.replace(/\$_Provider_\$/g,h.name);const o=n({section:"Bernova provider methods",doc:r});j=r.replace(o,s.trim())}"cjs"!==v||g||(j=await p(j,P,!0)),"esm"!==v||g||(j=await p(j,P)),m&&!g&&(j=await u(j));const C=t.relative(i||"",a.outPath),w=d?P:t.resolve(s,C,a.name);await r(w,j,a.name)}async function l({baseOutPath:s,cssFiles:a,rootDir:n,customOutDirs:i,dir:c}){for(const l of a){const a=(()=>n&&!i?.css?t.relative(n,l.path):i?.css?i.css:l.path)(),m=t.resolve(c,l.path,l.name);if(o(c,m)){const n=await e.readFile(m,"utf8"),o=l.name.replace(".min","");await r(t.resolve(s,a,o),n,o)}}}function m({baseOutDir:e,type:s="-"}){const a=(()=>{switch(s){case"cjs":return"cjs";case"esm":return"esm";default:return""}})();return t.join(e,a)}async function p(e,t,a=!1){const n=!!a&&"commonjs";return(await s.transformAsync(e,{filename:t,presets:[["@babel/preset-env",{modules:n,targets:{node:"current"}}]]})).code}async function u(e){return(await a(e,{compress:{dead_code:!0,drop_console:!1,drop_debugger:!0,keep_classnames:!1,keep_fargs:!0,keep_fnames:!1,keep_infinity:!1},mangle:{toplevel:!1},format:{comments:!1}})).code}function d({themes:e,minifyCss:s}){return e&&Array.isArray(e)&&e.length>0?e.reduce((e,a)=>{const{name:n,stylesPath:r,foreignThemes:o}=a;return n&&r&&v(e,{name:s?`${n}.min.css`:`${n}.css`,path:r}),o&&Array.isArray(o)&&o.length>0&&o.forEach(s=>{const a=t.basename(s.path),r=s.path.replace(a,"").trim(),o=e.findIndex(e=>e.name===a&&e.path===r);o>=0?e[o].parent.push({name:n,position:s.position}):e.push({name:a,path:r,parent:[{name:n,position:s.position}]})}),e},[]):[]}async function h({dir:s,customOutDirs:a,provider:n,themes:r,preventMoveDTS:o=!1}){const i=r&&r.bvTools?r.reduce((e,{bvTools:t})=>{const{path:s,declarationHelp:n,cssVariables:r,cssClassNames:i,cssMediaQueries:c,cssGlobalStyles:l,availableComponents:m}=t,p=n&&!o,u=a?.tools?a.tools:s;return r&&(v(e,{name:"cssVars.js",path:s,outPath:u}),p&&v(e,{name:"cssVars.d.ts",path:s,outPath:u})),i&&(v(e,{name:"cssClasses.js",path:s,outPath:u}),p&&v(e,{name:"cssClasses.d.ts",path:s,outPath:u})),c&&(v(e,{name:"cssMediaQueries.js",path:s,outPath:u}),p&&v(e,{name:"cssMediaQueries.d.ts",path:s,outPath:u})),l&&(v(e,{name:"cssGlobalStyles.js",path:s,outPath:u}),p&&v(e,{name:"cssGlobalStyles.d.ts",path:s,outPath:u})),m&&(v(e,{name:"cssAvailableComponents.js",path:s,outPath:u}),p&&v(e,{name:"cssAvailableComponents.d.js",path:s,outPath:u})),e},[]):[];if(n){const r=`${n.name.toLocaleLowerCase()}.js`,c=a?.provider?a.provider:n.path;v(i,{name:r,path:n.path,outPath:c});const l=t.join(n.path,"stats"),m=a?.provider?t.join(a.provider,"stats"):l;v(i,{name:"stats.js",path:l,outPath:m});const p=t.resolve(s,l),u=await e.readdir(p,{withFileTypes:!0});if(u.forEach(e=>{if(e.isDirectory()){const s=t.join(l,e.name),a=t.join(m,e.name);v(i,{name:"cssAvailableComponents.js",path:s,outPath:a}),v(i,{name:"cssClassNames.js",path:s,outPath:a}),v(i,{name:"cssGlobalStyles.js",path:s,outPath:a}),v(i,{name:"cssMediaQueries.js",path:s,outPath:a}),v(i,{name:"cssTheme.js",path:s,outPath:a}),v(i,{name:"cssVars.js",path:s,outPath:a})}}),n.declarationHelp&&!o){const e=`${n.name.toLocaleLowerCase()}.d.ts`;v(i,{name:e,path:n.path,outPath:c}),v(i,{name:"stats.d.ts",path:l,outPath:m}),u.forEach(e=>{if(e.isDirectory()){const s=t.join(l,e.name),a=t.join(m,e.name);v(i,{name:"cssAvailableComponents.d.ts",path:s,outPath:a}),v(i,{name:"cssClassNames.d.ts",path:s,outPath:a}),v(i,{name:"cssGlobalStyles.d.ts",path:s,outPath:a}),v(i,{name:"cssMediaQueries.d.ts",path:s,outPath:a}),v(i,{name:"cssTheme.d.ts",path:s,outPath:a}),v(i,{name:"cssVars.d.ts",path:s,outPath:a})}})}}return i}function f({cssThemes:e,cssOutPath:s}){return Object.entries(e).reduce((e,[a,{foreign:n}])=>{const{before:r,after:o}=n,i=r&&Array.isArray(r)&&r.length>0?r.reduce((e,a,n)=>{const r=t.basename(a);return n>0&&(e+=", "),e+`'${s}/${r}'`},""):"",c=o&&Array.isArray(o)&&o.length>0?o.reduce((e,a,n)=>{const r=t.basename(a);return n>0&&(e+=", "),e+`'${s}/${r}'`},""):"";return e+`'${a}':{css:'${s}/${a}.css',foreign:{before: [${i}],after: [${c}]}}`},"")}function v(e,t){e.some(e=>e.name===t.name&&e.path===t.path)||e.push(t)}function y(){const e=["--base-out-dir","--root-dir","--prevent-process-js","--prevent-move-js","--prevent-move-dts","--types","--css","--tools","--provider","--embed-css"],t={};for(let s=0;s<process.argv.length;s++)if(e.includes(process.argv[s])){const a=process.argv[s].replace("--","").replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),n=process.argv[s+1];t[a]=(()=>!(n&&!e.includes(n))||("none"===n.toLocaleLowerCase()?"":n))()}return t}function b({jsonCustomOutDirs:e,cliCustomOutDirs:t}){let s={};return e&&(s={...e}),t&&(s={...s,...t}),Object.keys(s).length>0?s:void 0}(async()=>{const e=process.cwd(),s=await i(t.resolve(e,"bernova.config.json")),{compilerOptions:a,provider:n,themes:r}=s;a&&n&&r||(console.error("Invalid configuration: Missing compilerOptions, themes or provider"),process.exit(1));const{baseOutDir:o,rootDir:p,minifyCss:u,minifyJS:f,preventMoveJS:v,preventMoveDTS:g,types:P,embedCss:j,customOutDirs:D}=a,{baseOutDir:C,rootDir:w,types:O,preventMoveJs:$,preventMoveDts:F,preventProcessJs:T=!1,embedCss:A,...M}=y(),S=C??o??"",_=w??p??void 0,E=$??v??!1,k=F??g??!1,L=O??P??void 0,J=A??j??!1,x=b({jsonCustomOutDirs:D,cliCustomOutDirs:M}),B=d({themes:r,minifyCss:u}),I=T?[]:await h({dir:e,customOutDirs:x,provider:n,themes:r,preventMoveDTS:k}),q=m({baseOutDir:S});if(B&&B.length>0&&!J&&await l({baseOutPath:q,cssFiles:B,rootDir:_,customOutDirs:x,dir:e}),I&&I.length>0)if(L&&Array.isArray(L)&&L.length>0)for(const t of L){const s=m({baseOutDir:S,type:t});for(const a of I)await c({baseOutPath:s,jsFile:a,rootDir:_,customOutDirs:x,dir:e,minifyJS:f,preventMoveJS:E,provider:n,type:t,embedCss:J,cssFiles:B})}else for(const t of I)await c({baseOutPath:q,jsFile:t,rootDir:_,customOutDirs:x,dir:e,minifyJS:f,preventMoveJS:E,provider:n,embedCss:J,cssFiles:B})})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bernova",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "The best way to write CSS with Javascript syntax",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -116,8 +116,8 @@
|
|
|
116
116
|
"build:remove-docs": "find dist/src -name '*.md' -delete 2>/dev/null || true && echo 'Documentation files removed from build'",
|
|
117
117
|
"build:minify-cli": "node scripts/minify-all.js",
|
|
118
118
|
"start": "node ./bin/bernova.js",
|
|
119
|
-
"start:foundation": "node ./bin/bernova.js --
|
|
120
|
-
"start:component": "node ./bin/bernova.js --
|
|
119
|
+
"start:foundation": "node ./bin/bernova.js --foundation-only",
|
|
120
|
+
"start:component": "node ./bin/bernova.js --component-only",
|
|
121
121
|
"dev": "pnpm run start",
|
|
122
122
|
"config": "node ./bin/createConfigFile.js",
|
|
123
123
|
"typing": "node ./bin/declareCssType.js",
|