How to refactor configuration files together? - refactoring

I was working on a small project. My file structure looks like this -
MyProject
|
|_ package.json
|
|_ package-lock.json
|
|_ .eslintrc.json
|
|_ .babelrc
|
|_ tsconfig.json
|
|_ webpack.dev.config
|
|_ webpack.prod.config
|
|_ *some other files*
|
|_ src
|
|_ *source code files*
As you can see I have a number of configuration files. This makes the MyProject directory too cluttered up. Is there anyway to refactor these configuration files. Maybe like so -
MyProject
|
|_ package.json
|
|_ package-lock.json
|
|_ *some other files*
|
|_ configurations
| |
| |_ .eslintrc.json
| |
| |_ .babelrc
| |
| |_ tsconfig.json
| |
| |_ webpack.dev.config
| |
| |_ webpack.prod.config
|
|_ src
|
|_ *source code files*
such that everything still works. I was able to refactor the Webpack files successfully (but not the others). How can I achieve this?

Related

Is it possible to have your live sass compiler to read from multiple input source and compile into their respective output directories

I am using django and I have this directory setup
/project
/apps
| /app1
| | /templates
| | /app1
| | app1.html
| | /static
| | /app1
| | /css (desired)
| | app1.css(desired)
| | /scss
| | _app1-partial.scss
| | app1.scss
| /app2
| /templates
| /app2
| app2.html
| /static
| /app2
| /css (desired)
| app2.css(desired)
| /scss
| _app2-partial.scss
| app2.scss
/templates
base.html
navbar.html
/static
| /images
| /css (desired)
| style.css(desired)
| /scss
| _partial.scss
| style.scss
/project
settings.py
manage.py
Is it possible that I can have a live sass compiler extension to compile multiple source scss inputs into multiple css output files?
I think I had it figure it out but I appreciate corrections for me to learn.
This is what I had before
"liveSassCompile.settings.formats": [
{
"format": "compressed",
"extensionName": ".css",
"savePath": "~/css",
"savePathReplacementPairs": null
}
],
"liveSassCompile.settings.includeItems": [
"/static/*.scss",
"/static/**/*.scss"
],
Changes I made
"liveSassCompile.settings.includeItems": [
"/static/*.scss", // for root static scss file
"/apps/**/static/**/*.scss" // for app specific scss file
],

How to print ASCII picture/logo in console using bash

I have a logo which I want to print/echo using bash in console, through scripts, but I can't even paste here properly(looks good inside .txt file):
___ _____ _ _ _____ _ _ ___
| _| / ___| | | || ___| \ | | |_ |
| | \ `--.| |_| || |__ | \| | | |
| | `--. \ _ || __|| . | | |
| | /\__/ / | | || |___| |\ | | |
| |_ \____/\_| |_/\____/\_| \_/ _| |
|___| |___|
How I can do that properly and make it colour without 3rd party extensions?
Also, is it possible to print it from the file?
You may use tput:
tput setaf 2; cat logo.txt
2 is the color code here (red). These are the available codes:
Value Color
0 Black
1 Red
2 Green
3 Yellow
4 Blue
5 Magenta
6 Cyan
7 White
8 Not used
9 Reset to default color

Does Jekyll provide a method for extending a master Sass file without importing it?

I am referencing a master base.scss for global styles while working on multiple sites in a single Jekyll project. My project directory looks like this:
project
|
+--_sass
| |
| +--base.scss
|
+--_site
| |
| +--apple
| | |
| | +--css
| | |
| | +--style.css
| |
| +--banana
| |
| +--css
| |
| +--style.css
|
+--apple
| |
| +--css
| |
| +--style.scss
|
|--banana
| |
| +--css
| |
| +--style.scss
This works well because each of the style.scss files uses #import to import the base.scss file, which allows me to #extend the base styles in turn. This of course duplicates the content of base.scss across each file that imports it.
I'm wondering if there's a way to compile base.scss to say _site/css/base.css, which I would reference from my shared header, while retaining access to its classes when editing my site-specific Sass.
Does Jekyll provide a method for referencing and extending Sass files without duplicating their contents in the build?
If I understand your question properly, the following arrangement should work just as fine:
project
|
+--_sass
| |
| +--base.scss
|
+--_css
| |
| +--main.scss
|
+--apples
| |
| +--css
| | |
| | +--style.css
/* css/main.scss */
---
---
#import "base";
/* apples/css/style.css */
/* No need of front matter dashes here if its not a sass file */
.my_class { color: blue; }
<!-- _site/index.html -->
<head>
[...]
<link rel="stylesheet" href="/css/main.css" />
<link rel="stylesheet" href="/apples/css/style.css" />
</head>

lftp upload files inside different folders

I need to upload files in different folders with same name, recursively to a remote folder. Here a example.
Local
|-app1-1
| |-src
| |-img
| |-static
| |-app1-2 <------Upload from this
| |-file1-1
| |-file1-2
|-app2-1
| |-src
| |-img
| |-static
| |-app2-2 <------Upload from this
| |-file2-1
| |-file2-2
Here the remote result I need.
Remote Result
|-folder1
|-folder2
|-folder3
|-static
| |-app1-2 <------Upload from this
| | |-file1-1
| | |-file1-2
| |
| |-app2-2 <------Upload from this
| | |-file2-1
| | |-file2-1
I have testing with scripts like this:
- >
lftp
-e "mirror
--include ^static/
--exclude ^\.git.*
-eRv $CI_PROJECT_DIR Remote Result/static; quit;"
sftp://$CREDENTIALS
But this generate a output not desired:
Remote Result
|-folder1
|-folder2
|-folder3
|-static
| |-app1-1 <------Upload from this
| | |-static
| | |-app1-2
| | |-file1
| | |-file2
...... (Same other folder)

Listing the contents of .tgz within a .tgz

I have 300 directories with the following structure
Directory
|-- zipfile.tgz
| |-- anotherzip.tgz
| | |-- afurtherzip.tgz
| | | |-- ethernet1.txt
| | | |-- ethernet2.txt
| | | |-- ethernet3.txt
| | |-- files.txt
| |-- files.txt
|-- zipfile2.tgz
| |-- anotherzip.tgz
| | |-- afurtherzip.tgz
| | | |-- ethernet1.txt
| | | |-- ethernet2.txt
| | | |-- ethernet3.txt
| | |-- files.txt
| |-- files.txt
I need to grep the contents of the ethernetx.txt files and for any files containing 'abc=n' have it tell me the file path of the containing zipfile.tgz so i know where to find it.
Can anyone suggest a decent script / one liner i can use to achieve this? I dont want to have to recursively extrace every .tgz if i can avoid it but please let me know what you think.

Resources