meanjs / generator-meanjs

MEAN.JS Official Yeoman Generator
http://meanjs.org/
472 stars 178 forks source link

0.4.0 $ yo meanjs:crud-module <module-name> RUNS $ yo meanjs #79

Closed metasean closed 9 years ago

metasean commented 9 years ago

I've got a new 0.4.0 MEAN.js app.

When I try to generate a new crud-module named "meets" by running:

yo meanjs:crud-module meets

I am greeted by:

CompName:AppName metasean$ yo meanjs:crud-module meets

     _-----_
    |       |
    |--(o)--|   .--------------------------.
   `---------´  |    Welcome to Yeoman,    |
    ( _´U`_ )   |   ladies and gentlemen!  |
    /___A___\   '__________________________'
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

You're using the official MEAN.JS 0.4 generator.
? What would you like to call your application? (MEAN) 

Moved from https://github.com/meanjs/mean/issues/437

ilanbiala commented 8 years ago

@UndeadBaneGitHub can you provide some info and maybe even create PRs for some docs of the new subgenerators?

UndeadBaneGitHub commented 8 years ago

@ilanbiala Sure!

benobab commented 8 years ago

@junit38 this version works properly (the actual version of meanjs contains also some /admin folders etc) -> that means we have to go 1 level deeper for the rm and the rename of files ;-)

Thanks for your original script, it saves me a lot of time every day!

var=$1
if [ -n "$var" ]; then
    CRUDNAME=$1
    CRUDNAMEUPPERCASE=`echo ${CRUDNAME:0:1} | tr  '[a-z]' '[A-Z]'`${CRUDNAME:1}
    FOLDERNAME=$CRUDNAME's'
    # Create new folder
    cp -R modules/articles modules/$FOLDERNAME
    # Do the find/replace in all the files
    find modules/$FOLDERNAME -type f -print0 | xargs -0 sed -i -e 's/Article/'$CRUDNAMEUPPERCASE'/g'
    find modules/$FOLDERNAME -type f -print0 | xargs -0 sed -i -e 's/article/'$CRUDNAME'/g'
    # Delete useless files due to sed
    rm modules/$FOLDERNAME/**/*-e
    rm modules/$FOLDERNAME/**/**/*-e
    rm modules/$FOLDERNAME/**/**/**/*-e
    # Rename all the files
    for file in modules/$FOLDERNAME/**/*article* ; do mv $file ${file//article/$CRUDNAME} ; done
    for file in modules/$FOLDERNAME/**/**/*article* ; do mv $file ${file//article/$CRUDNAME} ; done
    for file in modules/$FOLDERNAME/**/**/**/*article* ; do mv $file ${file//article/$CRUDNAME} ; done
else
    echo "Usage: sh rename-module.sh [crud-name]"
fi
junit38 commented 8 years ago

@benobab You'r welcome !

Thanks for the improvement.

sanjeet05 commented 8 years ago

Easy way to do this in ubuntu: Please follow these instructions....

# copy the **article** module and rename as **customers**
# open terminal inside your project(meanjs)
# modify these two variables as like below
# copy all the below code and paste it to the terminal

CRUDNAME="customer"
CRUDNAMEUPPERCASE="Customer"
FOLDERNAME=$CRUDNAME's'

# Do the find/replace in all the files
find modules/$FOLDERNAME -type f -print0 | xargs -0 sed -i -e 's/Article/'$CRUDNAMEUPPERCASE'/g'
find modules/$FOLDERNAME -type f -print0 | xargs -0 sed -i -e 's/article/'$CRUDNAME'/g'

# Rename all the files
for file in modules/$FOLDERNAME/**/*article* ; do mv $file ${file//article/$CRUDNAME} ; done
for file in modules/$FOLDERNAME/**/**/*article* ; do mv $file ${file//article/$CRUDNAME} ; done
for file in modules/$FOLDERNAME/**/**/**/*article* ; do mv $file ${file//article/$CRUDNAME} ; done