Automation layout start
Hello, reader!
If you create websites on a stream, the start of a project turns into a routine. Earlier, in order to create a site layout from scratch, I had to manually do the following operations:
- Creation of the main project folder in a certain place on the principle of
site_number_of the site (site_name)
, for examplesite_49 (dota)
- The clone of the start template with github in the site subfolder
- Deleting the git folder (to safely upload the project to a new repository)
- Creating a folder for customer files (fonts, layouts, TR)
- Link of globally installed npm packages for automation (in your case it can be npm install)
- Opening a project in the editor (in my case IDE PhpStorm)
- Starting gulp (or some npm run start)
But now I’m just opening the console and write:
And now, after a moment, a project with the necessary structure is open in the editor, and in the browser, browsersync has opened to me localhost with the main page of the project. Exactly automation will be discussed in this article.
Console installation
- Install git
- Download cmder (mini-version) and unpack it in
C:/cmder
. RunC:/cmder/Cmder.exe
as administrator, press Win+Alt+P to go to the settings. - Go to Startup → Tasks. Click the Add default tasks… to add default tasks. In the list of Predefined tasks, you should see {Bash :: Git bash}.
- In the settings: Startup → select the Auto save/restore opened task. Now, when you open cmder, you will see tabs with the same consoles that you worked with before closing. Save.
- Press Ctrl+T in the main window of the program to create a new tab with the console and in the Create new console section select {Bash :: Git bash}. If necessary, you can check the box “run as Administrator”.
- Close the initially open tab (the very first, almost certainly, powershell.exe) by clicking the middle mouse button or from the tab context menu.
Editing .bashrc
In order to write aliases and functions for automation, we need to create a .bashrc file at C:/Users/USER_NAME/.bashrc (perhaps the file has already been created). Let’s write the first alias in this file:
Now when you run the pro command, we will go to the folder I specified (in it I store projects, you set yours). Next, let’s write an alias for running the project in phpstorm, pay attention to the escaping character
After the path, we specify $* to substitute the path that needs to be opened in the editor. After this, let’s write a function to create a new project:
After we have done this, we write an alias and assign it a function:
The final file looks like this:
We use
After each editing of .bashrc
, you must restart the cmder
. After restarting we need to write:
And here we are - you get the desired result. In this article, I have described the automation of my routine, but your path may be different. If you have a lot of cases of the beginning of work, then it is better to deal with generators, for example, Yeoman.
That’s all. See you.