Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 1 | NODE_VERSION = "v8.11.1" |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 2 | |
| 3 | COMPILE_DEPS = [ |
| 4 | '//lib:CORE_DEPS', |
| 5 | '//lib:JACKSON', |
| 6 | '//lib:KRYO', |
| 7 | '//lib:javax.ws.rs-api', |
| 8 | '//lib:servlet-api', |
| 9 | '//lib:jetty-websocket', |
| 10 | '//lib:jetty-util', |
| 11 | '//lib:jersey-media-multipart', |
| 12 | '//lib:org.apache.karaf.shell.console', |
| 13 | '//cli:onos-cli', |
| 14 | '//lib:jersey-server', |
| 15 | '//incubator/api:onos-incubator-api', |
| 16 | '//incubator/net:onos-incubator-net', |
| 17 | '//utils/rest:onlab-rest', |
| 18 | '//core/store/serializers:onos-core-serializers', |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 19 | ':node-release-' + NODE_VERSION, |
| 20 | ':node-bin-' + NODE_VERSION, |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 21 | '//web/gui2:onos-web-gui2-build', |
| 22 | ] |
| 23 | |
| 24 | TEST_DEPS = [ |
| 25 | '//lib:TEST', |
| 26 | '//core/api:onos-api-tests', |
| 27 | '//drivers/default:onos-drivers-default', |
| 28 | ] |
| 29 | |
| 30 | include_defs('//bucklets/node.bucklet') |
| 31 | |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 32 | fetch_node(version = NODE_VERSION) |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 33 | |
| 34 | genrule( |
| 35 | name = 'onos-web-gui2-build', |
| 36 | srcs = glob([ |
Yuta HIGUCHI | 2ff911b | 2018-05-22 14:33:43 -0700 | [diff] [blame] | 37 | '**/*.json', |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 38 | 'src/main/webapp/**/*.ts', |
| 39 | 'src/main/webapp/**/*.html', |
| 40 | 'src/main/webapp/**/*.css', |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 41 | 'src/main/webapp/**/*.png', |
| 42 | '*.js', |
| 43 | 'e2e/**/*' |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 44 | ], excludes = [ |
| 45 | 'dist/**/*', |
| 46 | 'node_modules/**/*', |
| 47 | 'src/main/webapp/dist/**/*' |
| 48 | ]), |
| 49 | bash = |
| 50 | #To avoid any older 'NodeJS' installations it is necessary to use only the one |
| 51 | # associated with this project - Angular 6 won't work on older releases |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 52 | 'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; ' |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 53 | + 'echo $PATH;' |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 54 | + '$(location :node-bin-' + NODE_VERSION + ')/bin/node -v;' |
| 55 | + 'ORIGPATH="$SRCDIR";' |
| 56 | + 'cd $(location :node-bin-' + NODE_VERSION + ')/bin &&' |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 57 | + 'ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm5 &&' |
| 58 | + 'cd $ORIGPATH &&' |
| 59 | # The symlink to npm is not always created properly by the BUCK job that |
| 60 | # untars it. It's safer to have our own symlink 'npm5' |
| 61 | + 'npm5 -v;' |
| 62 | + 'npm5 install -g @angular/cli@6.0.0 2>&1;' |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 63 | + 'npm5 install 2>&1;' |
| 64 | + 'ng -v;' |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 65 | + 'ng build --preserve-symlinks --base-href /onos/ui2/dist/ --deploy-url /onos/ui2/dist/ --output-path="$OUT" 2>&1', |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 66 | out = 'dist', |
| 67 | visibility = [ 'PUBLIC' ], |
| 68 | ) |
| 69 | |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 70 | genrule( |
| 71 | name = 'onos-web-gui2-test', |
| 72 | srcs = [], |
| 73 | bash = |
| 74 | 'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; ' |
| 75 | + 'ORIGPATH="$SRCDIR";' |
| 76 | + 'ORIGOUTPUT=\$(echo $ORIGPATH|cut -d\'_\' -f 1 );' |
| 77 | + 'cd $(location :onos-web-gui2-build)/../../onos-web-gui2-build__srcs;' |
| 78 | # The sym linked karma.conf.js will mean that 'karma-jasmine' won't be found |
| 79 | + 'cp karma.conf.js karma.conflocal.js;' |
| 80 | + 'pwd > "$OUT";' |
| 81 | + 'npm5 -v >> "$OUT";' |
| 82 | + 'ng -v >> "$OUT";' |
| 83 | + 'if [ -f /usr/bin/chromium-browser ]; then export CHROME_BIN=/usr/bin/chromium-browser; fi;' |
| 84 | + 'echo $CHROME_BIN >> "$OUT";' |
| 85 | # No point using PhantonJS as the browser because it's not compatible with ES6 |
| 86 | # Install either chrome or chromium-browser on the machine |
| 87 | + 'ng test --preserve-symlinks --karma-config=karma.conflocal.js --code-coverage --browsers=ChromeHeadless --watch=false >> "$OUT" 2>&1 || ' |
| 88 | + 'if [ $? -eq 0 ]; then echo "Successfully ran tests";' |
Sean Condon | 8377568 | 2018-05-27 18:59:59 +0100 | [diff] [blame] | 89 | + 'else ' |
| 90 | + ' if grep -q CHROME_BIN $ORIGOUTPUT/onos-web-gui2-test-log.txt ; then ' |
| 91 | + ' echo "Warning: Step onos-web-gui2-test (test of Angular code) skipped because no binary for ChromeHeadless browser was found on your platform." >&2;' |
| 92 | + ' echo "Install Google Chrome or Chromium Browser to allow this step to run." >&2;' |
| 93 | + ' else ' |
| 94 | + ' echo "Error running \'ng test\' on \'//web/gui2:onos-web-gui2-test\'. See $ORIGOUTPUT/onos-web-gui2-test-log.txt for more details" >&2;' |
| 95 | + ' tail -n 100 $ORIGOUTPUT/onos-web-gui2-test-log.txt >&2;' |
| 96 | + ' fi;' |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 97 | + 'fi;', |
| 98 | out = 'onos-web-gui2-test-log.txt', |
| 99 | ) |
| 100 | |
| 101 | genrule( |
| 102 | name = 'onos-web-gui2-lint', |
| 103 | srcs = [], |
| 104 | bash = |
| 105 | 'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; ' |
| 106 | + 'cd $(location :onos-web-gui2-build)/../../onos-web-gui2-build__srcs;' |
| 107 | + 'pwd > "$OUT";' |
| 108 | + 'npm5 -v >> "$OUT";' |
| 109 | + 'ng -v >> "$OUT";' |
| 110 | + 'ng lint >> "$OUT"', |
| 111 | out = 'onos-web-gui2-lint-log.txt', |
| 112 | ) |
| 113 | |
| 114 | genrule( |
| 115 | name = 'onos-web-gui2-compodoc', |
| 116 | srcs = [], |
| 117 | bash = |
| 118 | 'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; ' |
| 119 | + 'cd $(location :onos-web-gui2-build) && cd ../.. && cd onos-web-gui2-build__srcs;' |
| 120 | + 'pwd;' |
| 121 | + 'npm5 -v;' |
| 122 | + 'npm5 install -g @compodoc/compodoc 2>&1;' |
| 123 | + 'npm5 run compodoc -- -V;' |
| 124 | # TODO This does not pick up on sym linked files - issue raised with authors |
| 125 | + 'npm5 run compodoc -- -d "$OUT"', |
| 126 | out = 'documentation', |
| 127 | ) |
| 128 | |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 129 | osgi_jar_with_tests ( |
| 130 | name = 'onos-gui2', |
| 131 | deps = COMPILE_DEPS, |
| 132 | test_deps = TEST_DEPS, |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 133 | resources = [ |
| 134 | ':onos-web-gui2-build' |
| 135 | ], |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 136 | resources_root = '.', |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 137 | test_resources = [ |
| 138 | ':onos-web-gui2-test', |
| 139 | ':onos-web-gui2-lint' |
| 140 | ], |
| 141 | test_resources_root = '.', |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 142 | web_context = '/onos/ui2', |
| 143 | do_javadocs = False, |
| 144 | ) |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 145 | |
| 146 | onos_app ( |
| 147 | title = 'ONOS GUI v2 Application', |
| 148 | category = 'GUI', |
| 149 | url = 'http://onosproject.org', |
| 150 | description = 'ONOS GUI v2 based on Angular 6', |
| 151 | included_bundles = ['//web/gui2:onos-gui2'], |
| 152 | ) |