frets-styles-generator
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -32,21 +32,28 @@ #! /usr/bin/env node | ||
const importer = require("postcss-import"); | ||
const program = require("commander"); | ||
const walk = require("walk"); | ||
const normalize = require("normalize-path"); | ||
program.version("0.2.0").usage("inputPath [options]").option("-w, --watch", "watch the file for changes").option("-o, --overwrite", "overwrite the css files that are parsed with the PostCSS processed result", false).option("-t, --template <path>", "specify a custom template file [path to a js module]").option("-r, --react", "use the react template by default").option("-p, --purge", `Allow purgecss in your custom postcss.config.js to purge the output files. | ||
Default is to skip purgecss plugin if it's in your project postcss.config`, false).parse(process.argv); | ||
const inputPath = normalize(program.args[0] || "./src"); | ||
const [opts] = import_estrella.cliopts.parse(["input", "Input File or Directory", "<input>"], [ | ||
"o, overwrite", | ||
"overwrite the css files that are parsed with the PostCSS processed result" | ||
], [ | ||
"template", | ||
"specify a custom template file [path to a js module]", | ||
"<template>" | ||
], ["react", "use the react template by default"], ["watchmode", "watch for changes in the found css files"], [ | ||
"purge", | ||
`Allow purgecss in your custom postcss.config.js to purge the output files. (Default is to skip purgecss plugin if it's in your project postcss.config)` | ||
]); | ||
console.log("Parsing arguments..."); | ||
console.log("options: ", JSON.stringify(opts)); | ||
const inputPath = normalize(opts.input || "./src"); | ||
let cliTemplatePath = __dirname + "/templates/maquette.js"; | ||
if (program.react) { | ||
if (opts.react) { | ||
cliTemplatePath = __dirname + "/templates/react.js"; | ||
} | ||
if (program.template) { | ||
cliTemplatePath = normalize(process.cwd() + "/" + program.template); | ||
if (opts.template) { | ||
cliTemplatePath = normalize(process.cwd() + "/" + opts.template); | ||
} | ||
console.log("Using Template", cliTemplatePath); | ||
const watchMode = program.watch; | ||
console.log("reading directory " + inputPath); | ||
const walker = walk.walk(inputPath, { | ||
filters: ["node_modules"] | ||
}); | ||
console.log("watch?", opts.watchmode); | ||
const watchMode = opts.watchmode; | ||
let customPlugins = []; | ||
@@ -57,2 +64,6 @@ let postCssConfigPath = process.cwd() + "/postcss.config.js"; | ||
} | ||
if (!fs.existsSync(postCssConfigPath)) { | ||
console.error(`postcss.config.js file is missing in root directory`); | ||
process.exit(1); | ||
} | ||
customPlugins = [ | ||
@@ -63,3 +74,3 @@ importer({root: inputPath}), | ||
const removeThesePlugins = ["postcss-import"]; | ||
if (!program.purge) { | ||
if (!opts.purge) { | ||
removeThesePlugins.push("postcss-plugin-purgecss"); | ||
@@ -74,20 +85,38 @@ } | ||
}); | ||
walker.on("file", (root, stat, next) => { | ||
if (!stat.isDirectory()) { | ||
const extension = stat.name.split(".")[1]; | ||
if (extension === "css") { | ||
const inputFile = stat.name.split(".")[0]; | ||
(0, import_processFile.default)({ | ||
input: root + "/" + stat.name, | ||
output: root + `/${(0, import_estrella.basename)(inputFile, ".css")}-styles.ts`, | ||
templatePath: cliTemplatePath, | ||
customPlugins, | ||
inputPath, | ||
watchMode, | ||
overwrite: program.overwrite | ||
}); | ||
if (!fs.statSync(inputPath).isDirectory()) { | ||
console.log("Read File", inputPath); | ||
const root = (0, import_estrella.dirname)(inputPath); | ||
(0, import_processFile.default)({ | ||
input: inputPath, | ||
output: root + `/${(0, import_estrella.basename)(inputPath, ".css")}-styles.ts`, | ||
templatePath: cliTemplatePath, | ||
customPlugins, | ||
inputPath, | ||
watchMode, | ||
overwrite: opts.overwrite | ||
}); | ||
} else { | ||
console.log("reading directory " + inputPath); | ||
const walker = walk.walk(inputPath, { | ||
filters: ["node_modules"] | ||
}); | ||
walker.on("file", (root, stat, next) => { | ||
if (!stat.isDirectory()) { | ||
const extension = stat.name.split(".")[1]; | ||
if (extension === "css") { | ||
const inputFile = stat.name.split(".")[0]; | ||
(0, import_processFile.default)({ | ||
input: root + "/" + stat.name, | ||
output: root + `/${(0, import_estrella.basename)(inputFile, ".css")}-styles.ts`, | ||
templatePath: cliTemplatePath, | ||
customPlugins, | ||
inputPath, | ||
watchMode, | ||
overwrite: opts.overwrite | ||
}); | ||
} | ||
} | ||
} | ||
next(); | ||
}); | ||
next(); | ||
}); | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -94,0 +123,0 @@ 0 && (module.exports = { |
@@ -14,7 +14,8 @@ var __defProp = Object.defineProperty; | ||
import React, { | ||
ReactNode, | ||
ReactElement, | ||
AllHTMLAttributes, | ||
MouseEventHandler, | ||
Props, | ||
PropsWithChildren, | ||
ReactElement, | ||
ReactNode, | ||
} from "react"; | ||
@@ -33,4 +34,4 @@ | ||
public chain: string[]; | ||
public overrideDisplayNone: boolean; | ||
public overrideDisplayInherit: boolean; | ||
public overrideDisplayNone: boolean = false; | ||
public overrideDisplayInherit: boolean = false; | ||
public conditions: boolean[] = []; | ||
@@ -271,3 +272,3 @@ public classProps: any = {}; | ||
let newClick | ||
let newClick: MouseEventHandler<T> | (() => void) | undefined | ||
if ( | ||
@@ -274,0 +275,0 @@ firstChildIsProps && |
{ | ||
"name": "frets-styles-generator", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Tool that generates a Typescript class for hyperscript functions based on a CSS file", | ||
@@ -116,9 +116,9 @@ "main": "build/main/index.js", | ||
"camel-case": "^3.0.0", | ||
"commander": "^2.19.0", | ||
"commander": "^9.4.0", | ||
"normalize-path": "^3.0.0", | ||
"postcss": "^8.3.6", | ||
"postcss": "^8.4.14", | ||
"postcss-import": "^13.0.0", | ||
"tslib": "^1.9.3", | ||
"walk": "^2.3.14" | ||
"tslib": "^2.4.0", | ||
"walk": "^2.3.15" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8268765
293971
1
+ Addedcommander@9.5.0(transitive)
+ Addedtslib@2.8.1(transitive)
- Removedcommander@2.20.3(transitive)
- Removedtslib@1.14.1(transitive)
Updatedcommander@^9.4.0
Updatedpostcss@^8.4.14
Updatedtslib@^2.4.0
Updatedwalk@^2.3.15