@salty-css/core 0.0.1-alpha.43 → 0.0.1-alpha.44
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/bin/main.cjs +1 -1
- package/bin/main.js +1 -1
- package/package.json +1 -1
package/bin/main.cjs
CHANGED
@@ -5,6 +5,6 @@ saltygen
|
|
5
5
|
`)));const E=["src","public","assets","styles","css","app"],G=["styles","css","app","pages"],V=["index","styles","main","global","globals"],K=[".css",".scss",".sass"],H=await(async()=>{if(f)return f;for(const e of E)for(const p of V)for(const a of K){const h=t.join(n,e,p+a);if(await i.readFile(h,"utf-8").catch(()=>{})!==void 0)return t.relative(n,h);for(const D of G){const I=t.join(n,e,D,p+a);if(await i.readFile(I,"utf-8").catch(()=>{})!==void 0)return t.relative(n,I)}}})();if(H){const e=t.join(n,H),p=await i.readFile(e,"utf-8").catch(()=>{});if(p!==void 0&&!p.includes("saltygen")){const h=t.join(e,".."),D=`@import '${t.relative(h,t.join(n,"saltygen/index.css"))}';`;o.info("Adding global import statement to CSS file: "+e),await i.writeFile(e,D+`
|
6
6
|
`+p),await J(e)}}else o.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");const T=t.join(n,"vite.config.ts"),O=await i.readFile(T,"utf-8").catch(()=>{});if(O!==void 0&&!O.includes("saltyPlugin")){o.info("Edit file: "+T);const p=`import { saltyPlugin } from '@salty-css/vite';
|
7
7
|
`,h=O.replace(/(plugins: \[)/,`$1
|
8
|
-
saltyPlugin(__dirname),`);g||await F(`-D ${k.vite}`),o.info("Adding Salty-CSS plugin to Vite config..."),await i.writeFile(T,p+h),await J(T)}const L=["next.config.js","next.config.cjs","next.config.ts","next.config.mjs"].map(e=>t.join(n,e)).find(e=>M.existsSync(e));if(L){let e=await i.readFile(L,"utf-8").catch(()=>{});if(e!==void 0&&!e.includes("withSaltyCss")){let a=!1;/\splugins([^=]*)=[^[]\[/.test(e)&&!a&&(e=e.replace(/\splugins([^=]*)=[^[]\[/,(I,P)=>`plugins${P}= [withSaltyCss,`),a=!0);const S=e.includes("module.exports"),D=S?`const { withSaltyCss } = require('@salty-css/next');
|
8
|
+
saltyPlugin(__dirname),`);g||await F(`-D ${k.vite}`),o.info("Adding Salty-CSS plugin to Vite config..."),await i.writeFile(T,p+h),await J(T)}const L=["next.config.js","next.config.cjs","next.config.ts","next.config.mjs"].map(e=>t.join(n,e)).find(e=>M.existsSync(e));if(L){let e=await i.readFile(L,"utf-8").catch(()=>{});if(e!==void 0&&!e.includes("withSaltyCss")){let a=!1;/\splugins([^=]*)=[^[]\[/.test(e)&&!a&&(e=e.replace(/\splugins([^=]*)=[^[]\[/,(I,P)=>` plugins${P}= [withSaltyCss,`),a=!0);const S=e.includes("module.exports"),D=S?`const { withSaltyCss } = require('@salty-css/next');
|
9
9
|
`:`import { withSaltyCss } from '@salty-css/next';
|
10
10
|
`;S&&!a?(e=e.replace(/module.exports = ([^;]+)/,(I,P)=>`module.exports = withSaltyCss(${P})`),a=!0):a||(e=e.replace(/export default ([^;]+)/,(I,P)=>`export default withSaltyCss(${P})`)),g||await F(`-D ${k.next}`),o.info("Adding Salty-CSS plugin to Next.js config..."),await i.writeFile(L,D+e),await J(L)}}}),r.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>","Project directory to build the project in.").action(async function(s=z){o.info("Building the Salty-CSS project...");const{dir:c=s}=this.opts();if(!c)return C("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const l=U(c);await Y.generateCss(l)}),r.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>","File to generate.").option("-d, --dir <dir>","Project directory to generate the file in.").option("-t, --tag <tag>","HTML tag of the component.","div").option("-n, --name <name>","Name of the component.").option("-c, --className <className>","CSS class of the component.").action(async function(s,c=z){const{file:l=s,dir:f=c,tag:g,name:m,className:n}=this.opts();if(!l)return C("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!f)return C("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const N=U(f),_=l.split("/").slice(0,-1).join("/");_&&await i.mkdir(t.join(N,_),{recursive:!0});const b=t.join(N,l),d=t.parse(b);d.ext||(d.ext=".ts"),d.name.endsWith(".css")||(d.name=d.name+".css"),d.base=d.name+d.ext;const y=t.format(d);if(await i.readFile(y,"utf-8").catch(()=>{})!==void 0){o.error("File already exists:",y);return}o.info("Generating a new file: "+y);const $=Z.pascalCase(m||d.base.replace(/\.css\.\w+$/,"")),{content:E}=await w("react/react-styled-file.ts",{tag:g,name:$,className:n});await i.writeFile(y,E),await J(y)}),r.command("update").alias("up").description("Update Salty-CSS packages to the latest version.").option("--legacy-peer-deps <legacyPeerDeps>","Use legacy peer dependencies (not recommended).",!1).action(async function(){const{legacyPeerDeps:s}=this.opts(),c=t.join(process.cwd(),"package.json"),l=await x(c).catch(n=>C(n));if(!l)return;const f={...l.dependencies,...l.devDependencies},g=Object.keys(f).filter(n=>n==="salty-css"||n.startsWith("@salty-css/"));if(!g.length)return C("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+c);const m=g.map(n=>`${n}@${v.version}`);s?(o.warn("Using legacy peer dependencies to update packages."),await F(...m,"--legacy-peer-deps")):await F(...m),o.info("Salty-CSS packages updated successfully!")}),r.parseAsync(process.argv)}exports.main=ne;
|
package/bin/main.js
CHANGED
@@ -147,7 +147,7 @@ saltygen
|
|
147
147
|
});
|
148
148
|
if (t !== void 0 && !t.includes("withSaltyCss")) {
|
149
149
|
let s = !1;
|
150
|
-
/\splugins([^=]*)=[^[]\[/.test(t) && !s && (t = t.replace(/\splugins([^=]*)=[^[]\[/, (J, x) => `plugins${x}= [withSaltyCss,`), s = !0);
|
150
|
+
/\splugins([^=]*)=[^[]\[/.test(t) && !s && (t = t.replace(/\splugins([^=]*)=[^[]\[/, (J, x) => ` plugins${x}= [withSaltyCss,`), s = !0);
|
151
151
|
const C = t.includes("module.exports"), I = C ? `const { withSaltyCss } = require('@salty-css/next');
|
152
152
|
` : `import { withSaltyCss } from '@salty-css/next';
|
153
153
|
`;
|