How to ignore specific bower javascript library in gulp (regex issue maybe)? - gulp

I am using the "main-bower-files" gulp plugin. There is a bower library that is huge... I want to ignore it in my list called "fatjslib.js". My current regex filter is as follows:
var listOfBower = mainBowerFiles({filter: (/.*\.js$/i)});
This picks up "fatjslib.js" and when I print out the above variable, I see:
"\\User\\kmichaels\\storage\\app\\bower_components\\fatjslib\FatJsLib\FatJsLib.js"
How can I specify the filter or change regex, or do something such that the "listOfBower" can ignore the "FatJsLib.js" file? I don't want to specify the whole path if possible, if there is a way to wildcard ignore anything regardless of pathstructure with "FatJsLib", that may be best, but I am open to suggestions. Is the solution flexible to add "AnotherBigLib.js" (should there be a second library under some path structure) to the regex or ignore list?

One way for the "main-bower-files" plugin to stop reading specific bower library is to pass the overrides option in the param or to set the overrides property in bower.json
METHOD 1: To pass the overrides param:
Pass the overrides option to the mainBowerFiles()and set the ignore property to true for the library you wish to ignore.
var listOfBower = mainBowerFiles({"overrides":{"fatjslib":{"ignore":true}}});
METHOD 2: Specify overrides property in bower.json
You can also specify overrides property in bower.json and then there will be no need to pass overrides option as a param. When main-bower-files plugin will read the bower.json file, it will ignore the libraries that are set in overrides property with ignore flag to true.
in bower.json add an overrides property:
"overrides": {
"fatjslib": {
"ignore": true
}
}

in case fatjslib contains multiple js files, and you just want to ignore one while as include another, then you can override main section of the package.
Every package comes with its own bower.json which has a main section. This section contains the file to be injected.
What you can do is, in overrides - override the main section just to keep the files you want to be injected
"overrides": {
"fatjslib": {
"main": ["./dist/another-file.js"]
}
}
and then provide these overrides to mainBowerFiles

How about modifying the regex as follows:
/^(?!.*FatJsLib\.js$).*\.js$/i
And to add more libraries:
/^(?!.*(?:FatJsLib|AnotherBigLib)\.js$).*\.js$/i
Also, if you want to filter anything with FatJsLib in its path try with:
/^(?!.*\\(?:FatJsLib|AnotherBigLib)\\.*$).*\.js$/i
Source: I wrote the regex, you can try it here. Also the main-bower-files documentation states that filter can use any regex.

Related

How to exclude paths when using GroupedOpenAPI with SpringDoc

I have recently swopped out SpringFox for SpringDoc.
Previously I was able to exclude paths to be used for the Swagger UI like so:
new Docket(DocumentationType.SWAGGER_2).paths(Predicates.not(PathSelectors.regex("/path1/.*|/path2/.*|/path4/.*")))
In the case above, the Swagger UI would display for path3 and path5.
Making use of the GroupedOpenAPI when using SpringDoc, I have only seen a way to explicitly set which paths should be allowed e.g.
GroupedOpenApi.builder()
.pathsToMatch("/path3/**", "/path5/**")
I would prefer to have a more generic way, whereby I can specify which paths NOT to allow, so if I add further paths they will be allowed by default. Something like:
GroupedOpenApi.builder()
.pathsToMatch("!/path1/**", "!/path2/**", "!/path4/**")
Not sure if there is any functionality like this supported. Any help would be appreciated. Thank you.
You can use the follwoing property, to exclude paths (Tested with v1.2.32)
springdoc.paths-to-exclude= /test
Or:
GroupedOpenApi.builder()
.pathsToExclude("!/path1/**", "!/path2/**", "!/path4/**")

How do I stop prettier from formatting HTML files?

So the problem is that prettier does not format html very well.
for instance if I have this angular template:
<some-component
some-attribute
[ang-binding1]='someExpr'
[ang-binding2]='someExpr'
(someEvent)='someFunc($event)'>
</some-component>
prettier will format it to something like this:
<some-component some-attribute [ang-binding1]='someExpr' [ang-binding2]='someExpr' (someEvent)='someFunc($event)'>
</some-component>
how do I disable prettier formating for html templates ?
If you are using VS Code, you can prevent Prettier from running on HTML (or other specific languages) by adding the following to your settings:
"prettier.disableLanguages": ["html"]
You can find other VS Code specific options at the prettier/prettier-vscode GitHub page.
If you use prettier with pre-commit hook (for example, with husky), changing the editor settings will not help you.
You need to add file .prettierignore with the following content:
*.html
File format is similar to .gitignore. You can read more here: https://prettier.io/docs/en/ignore.html
If you would like to retain vscodes html formatter for html files, but leverage prettier for other files you can set the following in settings.json.
"editor.formatOnSave": true,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
}
As of March 2021, you can no longer disable HTML in the Prettier extension settings.
Now, you can either use a .prettierignore file or use VS Code's editor.defaultFormatter settings, as detailed in the Default Formatter section of the Prettier docs.
I was able to disable Prettier (and any formatter) in HTML files by going into settings.json and changing this:
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
to this:
"[html]": {
"editor.defaultFormatter": null
},
Or, you can use VS Code's default HTML formatting with this (my preferred option because forward slashes aren't added at the end of self-closing/void tags):
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
And in case you want to ignore a specific line to be formatted inside file you can do that via adding prettier-ignore before the code.
<!-- prettier-ignore -->
<div class="x" >hello world</div >
Complete documentation: https://prettier.io/docs/en/ignore.html
If you are using VSCode, click File > Preferences > Settings and add "html.format.enable": false,
html.format.enable will turn off the default VS Code formatter. To exclude all html files in a project from being formatted you can add a .prettierignore file to the project root and ignore all html files.
*.html
in addition to what was already written you can also disable formatting on save. then you would need to explicitly format the document via CMD/CTRL + P > Format document
"[html]": {
"editor.formatOnSave": true
},
Prettier's inline ignoring syntax
For HTML,
<!-- prettier-ignore -->
or for JSX,
{/* prettier-ignore */}
or for Javascript,
// prettier-ignore
or for CSS,
/* prettier-ignore */
Note: Not a direct answer to OP's question, but sometimes when one is looking to just ignore inline for specific lines, Prettier's comment syntax is quite helpful.
Adding more information to what above mentioned:
Press Ctrl + ,
Type "prettier"
Go to "Prettier: Disable Languages" option
Add "html" to it
You can try on your ./package.json:
"scripts": {
"format": "prettier --write .js src !**.html",
...
}
If you are using VSCode, click Command + P (for Mac) to open the command palette.
Then type:
> settings
The > lets you enter VSCode commands.
From the results you can select Preferences: Open Settings (JSON) and this will open the settings JSON file so you can configure the settings fully. The Settings UI offers limited options.
In the settings file, add:
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
}
That will use the VSCode formatter for html files instead of Prettier, without disabling Prettier for other files.

Convert php or phtml file to css

i develop a admin panel for manage colors in frontend. I don't want to add all color variables in theme files ( like header.phtml, footer.phtml, etc ) but i want to generate a file with all css class and color variables.
Ex.
<?php
$color = Mage::getStoreConfig('themeadmin/frontend/general_color');
echo '.top-header-container { background-color : #'.$color.'; } .menu { background-color : #'.$color.'; }';
?>
How i can do this without add this in theme file ? Can i generate a Css file ? what is the best way ?
Thanks
You can very easily simply call a .php file (or a controller action) as the actual stylesheet to be used.
ref: Include: css with php file extension?
So, considering that possibility you can do the following:
Create a controller action in your module.
Code for this action to simply output a valid formatted stylesheet
Add that action to your layout, via xml, or programatically inject the sheet into the layout, potentially via an observer event/model/controller action
example:
Mage::app()->getLayout()->getBlock('head')->addCss(
'dyncatprod/adminhtml.css'
);
Another possibility is to hook into the adminhtml save functionality (event should do) and generate one specific .css file form the admin options selected. The end result is one file, statically named, that you woudl then include normally. Make sure you provide a default base file for pre-saved instances.
This way would always ensure one file with the correct values, as a flat stylesheet.

TYPO3: Write a ViewHelper in an extension with vendor namespace

I have created an extension with plugins in a vendor namespace. Everything works fine so far. All the classes start with a namespace declaration namespace \VENDOR\ExtensionName\... and typo3 autoloads them just fine.
However, the problem starts when I add a ViewHelper. I put this in the \VENDOR\ExtensionName\ViewHelpers namespace. I added the namespace in my Fluid template like so: {namespace ns=VENDOR\ExtensionName\ViewHelpers}. When I call it in the template with <ns:myViewHelper />, I just get an 'Oops ...' error message:
Could not analyse class:VENDOR\ExtensionName\ViewHelpers\MyViewHelperViewHelper maybe not loaded or no autoloader?
The same happens, when I put the ViewHelper in a \TYPO3\... namespace.
How do I correctly implement a ViewHelper in an extension with a vendor namespace?
The namespace declaration must not have a leading backslash.
Instead having \Vendor\ExtensionName\ViewHelpers; it has to be Vendor\ExtensionName\ViewHelpers;
http://www.php.net/manual/en/language.namespaces.nested.php

Alternative for getDefinitionByName

In the past, there was a simple trick, to include the flex mxmlc module by adding the following line to the flash-cs4 makefile:
-include-libraries “/absolute/path/to/my/assets/assets.swc”
This gave you the ability to use getDefinitionByName, an helper function to access the embedded swc asset-library (instead of creating hand-written classes all assets).
Unfortunately, this has stopped working since flash-cs4. Does anybody know another solution?
Unfortunately, the only workaround I have found is to explicitly refer each of asset classes somewhere in the code. You may create dummy class like this:
public class AssetsExporter extends Sprite
{
public static function export()
{
AssetClass1;
AssetClass2;
//etc
trace( "DEBUG AssetsExporter.export()" );
}
}
Specify this class as Document class in Flash IDE, so it will be compiled into the resulting swc. Then in the main code of your application call
AssetsExporter.export();
After doing this you will be able to use getDefinitionByName().
You can add them to the libraries in the publish settings.
(Image from http://wiki.gigya.com/ via Google Images)
By the way, if you use SWC files, you can also do
new somepackage.SomeClass();
instead of
new getDefinitionByName("somepackage.SomeClass")
where applicable. This is because SWC files are included at compile time, not runtime.
Even though you can change a compiler setting manually, its easy if you are using FlashDevelop as this is very simple to fix.
Right click your included swc from the Project list. Choose options then "include library (complete library)".
..you can now use getDefinitionByName to get an unreferenced class from your swc file.