Angular Workspace中`/ apps`中的应用程序的选择器命名约定是什么?

时间:2019-02-25 20:42:55

标签: angular naming-conventions

files:"/opt/elasticbeanstalk/hooks/appdeploy/post/run_supervised_daemon.sh": mode: "000755" owner: root group: root content: | #!/usr/bin/env bash # Get django environment variables djangoenv=`cat /opt/python/current/env | tr '\n' ',' | sed 's/%/%%/g' | sed 's/export //g' | sed 's/$PATH/%(ENV_PATH)s/g' | sed 's/$PYTHONPATH//g' | sed 's/$LD_LIBRARY_PATH//g'` djangoenv=${djangoenv%?} # Create daemon configuraiton script daemonconf="[program:daphne] ; Set full path to channels program if using virtualenv command=/opt/python/run/venv/bin/daphne -b 0.0.0.0 -p 5000 <your_project>.asgi:channel_layer directory=/opt/python/current/app user=ec2-user numprocs=1 stdout_logfile=/var/log/stdout_daphne.log stderr_logfile=/var/log/stderr_daphne.log autostart=true autorestart=true startsecs=10 ; Need to wait for currently executing tasks to finish at shutdown. ; Increase this if you have very long running tasks. stopwaitsecs = 600 ; When resorting to send SIGKILL to the program to terminate it ; send SIGKILL to its whole process group instead, ; taking care of its children as well. killasgroup=true ; if rabbitmq is supervised, set its priority higher ; so it starts first priority=998 environment=$djangoenv [program:worker] ; Set full path to program if using virtualenv command=/opt/python/run/venv/bin/python manage.py runworker directory=/opt/python/current/app user=ec2-user numprocs=1 stdout_logfile=/var/log/stdout_worker.log stderr_logfile=/var/log/stderr_worker.log autostart=true autorestart=true startsecs=10 ; Need to wait for currently executing tasks to finish at shutdown. ; Increase this if you have very long running tasks. stopwaitsecs = 600 ; When resorting to send SIGKILL to the program to terminate it ; send SIGKILL to its whole process group instead, ; taking care of its children as well. killasgroup=true ; if rabbitmq is supervised, set its priority higher ; so it starts first priority=998 environment=$djangoenv" # Create the supervisord conf script echo "$daemonconf" | sudo tee /opt/python/etc/daemon.conf # Add configuration script to supervisord conf (if not there already) if ! grep -Fxq "[include]" /opt/python/etc/supervisord.conf then echo "[include]" | sudo tee -a /opt/python/etc/supervisord.conf echo "files: daemon.conf" | sudo tee -a /opt/python/etc/supervisord.conf fi # Reread the supervisord config sudo /usr/local/bin/supervisorctl -c /opt/python/etc/supervisord.conf reread # Update supervisord in cache without restarting all services sudo /usr/local/bin/supervisorctl -c /opt/python/etc/supervisord.conf update # Start/Restart processes through supervisord sudo /usr/local/bin/supervisorctl -c /opt/python/etc/supervisord.conf restart daphne sudo /usr/local/bin/supervisorctl -c /opt/python/etc/supervisord.conf restart worker 文件夹中大约有10个应用程序。

/apps的选择器是否应加上@Component前缀?

例如app-

还是应该都以应用名称作为前缀?

例如如果我的一个应用程序称为app-root,那么我将有一个名为FooBar的组件吗?而另一个项目称为fb-root,那么我将有一个名为HelloWorld

的组件

2 个答案:

答案 0 :(得分:1)

我宁愿选择第二个fb-root,因为它显示了此组件来自哪个应用程序。另外,如果您不仅在/apps文件夹中有应用程序,或者还具有库,则可以组合诸如app-fb-root之类的前缀。但同样,如果您不这样做,最好只使用fb-root

答案 1 :(得分:1)

前缀有助于防止组件库之间的名称冲突。您可以给它提供任何想要的前缀,但是我首先会检查该前缀是否已被将来可能要使用的任何库使用。

Angular Material使用“ mat”作为示例,Bootstrap库使用“ ngx”,还有很多。

“ app”是应用程序使用的保留前缀是一种非正式的标准,它可以确保不会有两个组件尝试使用同一选择器。

在您的示例中,您说“ FooBar”将具有前缀“ fb”,但这很可能与Facebook组件库使用的前缀相同。

此外,当Angular 2首次发布时,前缀“ ng”是许多开源库使用的流行前缀。作为前缀,它的流行一直持续到今天,我不建议您使用它。

因此,“应用”很安全,其他任何事情基本上都由您决定。