Code Monkey home page Code Monkey logo

rahulh25 / generate_component_angulardart Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 5.22 MB

This python script helps you generate a component for your angulardart project (instead of using the traditional ngdart generate component command). This will create the html, css and the dart file with some general boilerplate for the dart and the html file. This will also create a folder in the lib/src folder of your project for the component with all the files instead of just generally creating the html and dart file in the lib/src folder as done by the ngdart generate component command.

Python 100.00%

generate_component_angulardart's Introduction

Generate Angular Components for Angular Dart

This python script helps you generate a component for your angulardart project (instead of using the traditional ngdart generate component command). This will create the html, css and the dart file with some general boilerplate for the dart and the html file. This also creates a folder in the lib/src folder of your project for the component with all the files, instead of just generally creating the html and dart file in the lib/src folder as done by the ngdart generate component command.

Although you can change the folder name by using -p in the ngdart command it does not create the css file and you also have to manually create the subfolder inside the main folder where you wish to create the component. This file is more in line with what the ng generate component command for Angular with typescript feels like. If in future there are any changes in the ngdart generate component command please refer to that. This code will howerver work in any case.
If you wish to use the command directly just copy the compiled folder to your C drive and add the path to the folder in your environment variables

Steps to use the script

  1. Clone or download the repository on your local machine.
  2. Once the you have downloaded the project go into the project folder and open your bash terminal(for MAC/UNIX/LINUX users) or open git bash (for Windows users).
  3. Once you open the terminal run the following command:
cp create-component ~/bin

Note: If you get an error in the above command run the below command first:

mkdir -p ~/bin
  1. Once you have copied the script to your bin folder run the following command to bin to your path:
export PATH=$PATH":$HOME/bin"
  1. Once all the above steps have been executed successfully you can run the following command in your AngularDart project folder tp create a component:
create-component <component_name> [<subfolder_name>]

You will see that it creates a component folder under /lib/src or under /lib/src/subfolder_name with all your html, dart and css files.

Examples of using the command

(For Windows make sure you are still running the commands using git bash)
  1. Using it with just the component_name:
create-component home
  1. Creating inside a subfolder
create-component home main
  1. Creating the component within multiple subfolders
create-component home main/page

If the above steps do not work

In case the other steps do not work for you follow the following steps (Make sure to run these steps you have the .py extension of your file added):

  1. Install pyinstaller using pip by running the following command:
pip install pyinstaller

NOTE: Make sure you have python version below 3.9 installed on your system as 3.9 gives issues in pip install (This is during the time of the writing of this document).

  1. Run the following command inside the folder with the python file:
pyinstaller --onefile create-component
  1. Once you run the command it will create the following file structure:
│   ngdartgc.py
│   ngdartgc.spec
│
├───build
│   └───ngdartgc
├───dist
│       ngdartgc.exe
└───__pycache__
        ngdartgc.cpython-37.pyc
  1. Copy over all the files mentioned above in a folder inside the C drive or if you wish to keep the file where it is then move forward to the next step
  2. Add the path to your dist folder to your environment variables.
  3. Now you can run the following command:
create-component.exe <component_name> [<subfolder_name>]

Examples of using the command with above steps

(For Windows make sure you are still running the commands using git bash)
  1. Using it with just the component_name:
create-component.exe home
  1. Creating inside a subfolder
create-component.exe home main
  1. Creating the component within multiple subfolders
create-component.exe home main/page

Note

If you wish to create your own name for the command instead of create-component command then once you clone/download the repository you can change the python(create-component) file name and give it whatever name you like and you can call that command(file name) when creating the components

Reference

  1. Making command line python script
    https://dbader.org/blog/how-to-make-command-line-commands-with-python

  2. Download git bash for windows
    https://git-scm.com/downloads

  3. Create Python Executable file
    https://datatofish.com/executable-pyinstaller/

generate_component_angulardart's People

Contributors

rahulh25 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.