From d9ad2f1bad34fe703ab612f134c6a26bc022b7bd Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Tue, 2 Aug 2016 12:49:21 +0100 Subject: [PATCH] Merge pull request #490 from Alfresco/dev-wabson-480 Improve scripts and script docs (reverted from commit 0bd56034181a34a128acbd7e3a58f83ece434d96) --- .../ng2-activiti-processlist/package.json | 5 +- .../ng2-activiti-tasklist/package.json | 5 +- scripts/README.md | 40 ++---- scripts/npm-build-all.sh | 13 -- scripts/npm-clean.sh | 22 +++- scripts/npm-link-demo-shell.sh | 120 ++++++++++++++---- scripts/npm-publish.sh | 26 +++- scripts/start-linked.sh | 18 ++- 8 files changed, 157 insertions(+), 92 deletions(-) delete mode 100755 scripts/npm-build-all.sh diff --git a/ng2-components/ng2-activiti-processlist/package.json b/ng2-components/ng2-activiti-processlist/package.json index 57ae7e3288..56d9f49c9f 100644 --- a/ng2-components/ng2-activiti-processlist/package.json +++ b/ng2-components/ng2-activiti-processlist/package.json @@ -11,12 +11,11 @@ "version": "0.2.0", "author": "Alfresco Software, Ltd.", "scripts": { - "postinstall": "typings install", "clean": "rimraf dist node_modules typings", "typings": "typings install", "server": "http-server -c-1 -o -p 8875 .", - "build": "npm run tslint && rimraf dist && tsc && npm run copytemplates && license-check", - "build:w": "npm run tslint && rimraf dist && npm run watch-task", + "build": "npm run tslint && typings install && rimraf dist && tsc && npm run copytemplates && license-check", + "build:w": "npm run tslint && typings install && rimraf dist && npm run watch-task", "watch-task": "concurrently \"npm run tsc:w\" \"npm run copytemplates:w\" \"license-check\"", "tslint": "npm run tslint-src && npm run tslint-root", "tslint-src": "tslint -c tslint.json src/{,**/}**.ts", diff --git a/ng2-components/ng2-activiti-tasklist/package.json b/ng2-components/ng2-activiti-tasklist/package.json index 554cb86957..dda05ee92a 100644 --- a/ng2-components/ng2-activiti-tasklist/package.json +++ b/ng2-components/ng2-activiti-tasklist/package.json @@ -4,11 +4,10 @@ "version": "0.2.0", "author": "Alfresco Software, Ltd.", "scripts": { - "postinstall": "typings install", "clean": "rimraf dist node_modules typings", "typings": "typings install", - "build": "npm run tslint && rimraf dist && tsc && npm run copytemplates && license-check", - "build:w": "npm run tslint && rimraf dist && npm run watch-task", + "build": "npm run tslint && typings install && rimraf dist && tsc && npm run copytemplates && license-check", + "build:w": "npm run tslint && typings install && rimraf dist && npm run watch-task", "watch-task": "concurrently \"npm run tsc:w\" \"npm run copytemplates:w\" \"license-check\"", "tslint": "npm run tslint-src && npm run tslint-root", "tslint-src": "tslint -c tslint.json src/{,**/}**.ts", diff --git a/scripts/README.md b/scripts/README.md index f9381dc58b..a3a4f48b7b 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -3,64 +3,42 @@ The Alfresco application development framework comes with a demo project that you can run to get a feel for what's available. -Start by navigating into the app development framework source folder, and then the script folder: +* Start by navigating into the app development framework source folder, and then the script folder: ```ssh cd alfresco-ng2-components cd scripts ``` -Start using published components ---- - -This is recommended if you are running from the `master` branch. - -Start the demo-shell app after installing all the dependencies from npm (*Note. do it this way only the first time, and be aware, it will take some time*) +* Start the demo and Install all the dependencies (*Note. do it this way only the first time, and be aware, it will take some time*) ```sh ./start.sh -install ``` -Or, if you have previously run `-install` but want to update the dependencies, use `-update` - -```sh -./start.sh -update -``` - -If there are no big changes in the demo-shell since you last started then you can start without `-install` and `-update` to skip fetching packages, which should be much quicker +* Start the demo (*the standard way of starting the demo after first initialization*): ```sh ./start.sh ``` -If you get errors when starting which do not go away with `-update` or `-install,` or if you want to test starting the demo shell from a clean environment, then use the `-cleanInstall` option - -This will remove previous versions of all packages, before running `npm install` again +* Start the demo, install all the dependencies, and remove the previous version of the npm packages (*Note. do this only after big changes*): ```sh ./start.sh -cleanInstall ``` -Start using linked components ---- - -This is recommended if you are using the `development` branch or a feature branch off `development` - -If you want to use your local components use the following script with any of the previous options. It will npm link all the components -in the demo shell before starting up the demo-shell. - -For a new environment, use `-install` +* Start the demo and update the dependencies: ```sh -./start-linked.sh -install +./start.sh -update ``` -When you are restarting, you can skip `-install` +* If you want to use your local components use the following script with any of the previous option. It will npm link all the components +in the demo shell: ```sh ./start-linked.sh ``` -The parameters `-update` and `-cleanInstall` work as described above for `start.sh` - -For development environment configuration please refer to [project docs](demo-shell-ng2/README.md). +For development environment configuration please refer to [project docs](demo-shell-ng2/README.md). \ No newline at end of file diff --git a/scripts/npm-build-all.sh b/scripts/npm-build-all.sh deleted file mode 100755 index a7ea0c224d..0000000000 --- a/scripts/npm-build-all.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -components_dir="$DIR/../ng2-components" - -for comp_dir in $( ls "$components_dir" ); do - echo $comp_dir - test -f "$components_dir/$comp_dir/package.json" && \ - cd "$components_dir/$comp_dir" && \ - npm run build -done - -cd ${DIR} diff --git a/scripts/npm-clean.sh b/scripts/npm-clean.sh index ccb842e61b..c1d492be4c 100755 --- a/scripts/npm-clean.sh +++ b/scripts/npm-clean.sh @@ -1,13 +1,23 @@ #!/usr/bin/env bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -components_dir="$DIR/../ng2-components" -for comp_dir in $( ls "$components_dir" ); do - test -f "$components_dir/$comp_dir/package.json" && \ - cd "$components_dir/$comp_dir" && \ - echo "====== clean component: ${$comp_dir} =====" && \ - npm run clean +for PACKAGE in \ + ng2-activiti-form \ + ng2-activiti-processlist \ + ng2-activiti-tasklist \ + ng2-alfresco-core \ + ng2-alfresco-datatable \ + ng2-alfresco-documentlist \ + ng2-alfresco-login \ + ng2-alfresco-search \ + ng2-alfresco-upload \ + ng2-alfresco-viewer \ + ng2-alfresco-webscript +do + echo "====== clean component: ${PACKAGE} =====" + cd "$DIR/../ng2-components/${PACKAGE}" + npm run clean done cd "$DIR/../demo-shell-ng2" diff --git a/scripts/npm-link-demo-shell.sh b/scripts/npm-link-demo-shell.sh index 1d4eb5845c..a0ba56f46b 100755 --- a/scripts/npm-link-demo-shell.sh +++ b/scripts/npm-link-demo-shell.sh @@ -1,37 +1,103 @@ #!/usr/bin/env bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -components_dir="$DIR/../ng2-components" -npm_opts="--loglevel=silent" +npm install -g typings -function link_alfresco_ng2_deps() { - cd $1 - for dep in $( list-dependencies '^ng2-(alfresco|activiti)-' ); do - npm link --ignore-scripts $npm_opts "$dep" - done -} +#LINK CORE +echo "====== linking component: ng2-alfresco-core =====" +cd "$DIR/../ng2-components/ng2-alfresco-core" +npm link +npm run typings +npm run build -npm install $npm_opts -g typings -npm install $npm_opts -g @wabson/list-dependencies +#LINK FORM +echo "====== linking component: ng2-activiti-form =====" +cd "$DIR/../ng2-components/ng2-activiti-form" +npm link ng2-alfresco-core +npm link +npm run typings +npm run build -# First link each component into /usr/local/lib/node_modules -for comp_dir in $( ls "$components_dir" ); do - echo "Link $components_dir/$comp_dir" - test -f "$components_dir/$comp_dir/package.json" && cd "$components_dir/$comp_dir" && npm link --ignore-scripts +#LINK DATATABLE +echo "====== linking component: ng2-alfresco-datatable =====" +cd "$DIR/../ng2-components/ng2-alfresco-datatable" +npm link ng2-alfresco-core +npm link +npm run typings +npm run build + +#LINK DOCUMENTLIST +echo "====== linking component: ng2-alfresco-documentlist =====" +cd "$DIR/../ng2-components/ng2-alfresco-documentlist" +npm link ng2-alfresco-core +npm link ng2-alfresco-datatable +npm link +npm run typings +npm run build + +#LINK WEBSCRIPT +echo "====== linking component: ng2-alfresco-webscript =====" +cd "$DIR/../ng2-components/ng2-alfresco-webscript" +npm link ng2-alfresco-core +npm link ng2-alfresco-datatable +npm link +npm run typings +npm run build + +#LINK TASKLIST +echo "====== linking component: ng2-activiti-tasklist =====" +cd "$DIR/../ng2-components/ng2-activiti-tasklist" +npm link ng2-alfresco-core +npm link ng2-alfresco-datatable +npm link ng2-activiti-form +npm link +npm run typings +npm run build + +#LINK PROCESSLIST +echo "====== linking component: ng2-activiti-processlist =====" +cd "$DIR/../ng2-components/ng2-activiti-processlist" +npm link ng2-alfresco-core +npm link ng2-alfresco-datatable +npm link +npm run typings +npm run build + +#LINK ALL THE OTHERS COMPONENTS +for PACKAGE in \ + ng2-alfresco-login \ + ng2-alfresco-search \ + ng2-alfresco-upload \ + ng2-alfresco-viewer \ + ng2-alfresco-webscript +do + DESTDIR="$DIR/../ng2-components/${PACKAGE}" + echo "====== linking component: ${PACKAGE} =====" + cd "$DESTDIR" + npm link ng2-alfresco-core + npm link + npm run typings + npm run build done -# Now link inter-dependencies between components -for comp_dir in $( ls "$components_dir" ); do - echo "Link dependencies of $components_dir/$comp_dir" - test -f "$components_dir/$comp_dir/package.json" && link_alfresco_ng2_deps "$components_dir/$comp_dir" -done -# Now run postinstall scripts -for comp_dir in $( ls "$components_dir" ); do - echo "Postinstall $components_dir/$comp_dir" - test -f "$components_dir/$comp_dir/package.json" && cd "$components_dir/$comp_dir" && npm run postinstall -done - -# LINK ALL THE COMPONENTS INSIDE THE DEMOSHELL -link_alfresco_ng2_deps "$DIR/../demo-shell-ng2" +#LINK ALL THE COMPONENTS INSIDE THE DEMOSHELL +cd "$DIR/../demo-shell-ng2" +for PACKAGE in \ + ng2-activiti-form \ + ng2-activiti-processlist \ + ng2-activiti-tasklist \ + ng2-alfresco-core \ + ng2-alfresco-datatable \ + ng2-alfresco-documentlist \ + ng2-alfresco-login \ + ng2-alfresco-search \ + ng2-alfresco-upload \ + ng2-alfresco-viewer \ + ng2-alfresco-webscript +do + DESTDIR="$DIR/../ng2-components/${PACKAGE}" + echo "====== demo shell linking: ${PACKAGE} =====" + npm link ${PACKAGE} +done \ No newline at end of file diff --git a/scripts/npm-publish.sh b/scripts/npm-publish.sh index 17d1b7e80b..98f4954326 100755 --- a/scripts/npm-publish.sh +++ b/scripts/npm-publish.sh @@ -1,14 +1,26 @@ #!/usr/bin/env bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -components_dir="$DIR/../ng2-components" "$DIR/npm-clean.sh" -for comp_dir in $( ls "$components_dir" ); do - test -f "$components_dir/$comp_dir/package.json" && \ - cd "$components_dir/$comp_dir" && \ - echo "====== PUBLISHING: ${$comp_dir} =====" && \ - npm install && \ - npm publish +for PACKAGE in \ + ng2-activiti-form \ + ng2-activiti-processlist \ + ng2-activiti-tasklist \ + ng2-alfresco-core \ + ng2-alfresco-datatable \ + ng2-alfresco-documentlist \ + ng2-alfresco-login \ + ng2-alfresco-search \ + ng2-alfresco-upload \ + ng2-alfresco-viewer \ + ng2-alfresco-webscript +do + DESTDIR="$DIR/../ng2-components/${PACKAGE}" + echo "====== PUBLISHING: ${DESTDIR} =====" + cd ${DESTDIR} + npm install + npm publish + cd ${DIR} done diff --git a/scripts/start-linked.sh b/scripts/start-linked.sh index 24fe13d5f1..1c0529c063 100755 --- a/scripts/start-linked.sh +++ b/scripts/start-linked.sh @@ -3,5 +3,19 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" "$DIR/npm-link-demo-shell.sh" -"$DIR/npm-build-all.sh" -"$DIR/start.sh" $@ + +cd "$DIR/../demo-shell-ng2" + +if [[ $1 = "-install" ]]; then + npm install + npm run start +elif [[ $1 = "-update " ]]; then + npm run update + npm run start +elif [[ $1 = "-cleanInstall" ]]; then + npm run clean + npm install + npm run start +else + npm run start +fi