YARN-6458. Use yarn package manager to lock down dependency versions for new web UI. Contributed by Sreenath Somarajapuram.

This commit is contained in:
Sunil G 2017-06-04 22:05:14 +05:30
parent 367da9b7b8
commit 46f7e91980
8 changed files with 5253 additions and 52 deletions

View File

@ -0,0 +1,64 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
# Yarn UI
The Yarn UI is an Ember based web-app that provides visualization of the applications running on the Apache Hadoop YARN framework.
## Configurations
* You can point the UI to custom locations by setting the environment variables in `src/main/webapp/config/configs.env`
## Development
All the following commands must be run inside `src/main/webapp`.
### Prerequisites
You will need the following things properly installed on your computer.
* Install [Yarn](https://yarnpkg.com) v0.21.3
* Install [Bower](http://bower.io/) v1.7.7
* Install all dependencies by running `yarn install` & `bower install`
### Running UI
* `yarn start`
* Visit your app at [http://localhost:4200](http://localhost:4200).
### Building
* `yarn run build` (production)
* Files would be stored in "dist/"
### Adding new dependencies
**Warning: Do not edit the _package.json_ or _bower.json_ files manually. This could make them out-of-sync with the respective lock or shrinkwrap files.**
Yarn UI has replaced NPM with Yarn package manager. And hence Yarn would be used to manage dependencies defined in package.json.
* Please use the Yarn and Bower command-line tools to add new dependencies. And the tool version must be same as those defined in Prerequisites section.
* Once any dependency is added:
* If it's in package.json. Make sure that the respective, and only those changes are reflected in yarn.lock file.
* If it's in bower.json. Make sure that the respective, and only those changes are reflected in bower-shrinkwrap.json file.
* Commands to add using CLI tools:
* Yarn: yarn add [package-name]
* Bower: bower install --save [package-name]
### Adding new routes (pages), controllers, components etc.
* Use ember-cli blueprint generator - [Ember CLI](http://ember-cli.com/extending/#generators-and-blueprints)

View File

@ -26,15 +26,16 @@
<artifactId>hadoop-yarn-ui</artifactId> <artifactId>hadoop-yarn-ui</artifactId>
<version>3.0.0-alpha4-SNAPSHOT</version> <version>3.0.0-alpha4-SNAPSHOT</version>
<name>Apache Hadoop YARN UI</name> <name>Apache Hadoop YARN UI</name>
<packaging>${packaging.type}</packaging> <packaging>${packagingType}</packaging>
<properties> <properties>
<packaging.type>pom</packaging.type> <packagingType>pom</packagingType>
<webappTgtDir>${basedir}/target/src/main/webapp</webappTgtDir>
<node.executable>${basedir}/target/src/main/webapp/node/node</node.executable> <webappDir>${basedir}/target/webapp</webappDir>
<nodeVersion>v5.7.1</nodeVersion> <nodeExecutable>${basedir}/target/webapp/node/node</nodeExecutable>
<npmVersion>3.6.0</npmVersion> <packageManagerScript>node/yarn/dist/bin/yarn.js</packageManagerScript>
<keep-ui-build-cache>false</keep-ui-build-cache>
<keepUIBuildCache>false</keepUIBuildCache>
</properties> </properties>
<build> <build>
@ -47,7 +48,9 @@
<excludes> <excludes>
<exclude>src/main/webapp/jsconfig.json</exclude> <exclude>src/main/webapp/jsconfig.json</exclude>
<exclude>src/main/webapp/bower.json</exclude> <exclude>src/main/webapp/bower.json</exclude>
<exclude>src/main/webapp/bower-shrinkwrap.json</exclude>
<exclude>src/main/webapp/package.json</exclude> <exclude>src/main/webapp/package.json</exclude>
<exclude>src/main/webapp/yarn.lock</exclude>
<exclude>src/main/webapp/testem.json</exclude> <exclude>src/main/webapp/testem.json</exclude>
<exclude>src/main/webapp/public/assets/images/**/*</exclude> <exclude>src/main/webapp/public/assets/images/**/*</exclude>
<exclude>src/main/webapp/public/assets/images/*</exclude> <exclude>src/main/webapp/public/assets/images/*</exclude>
@ -57,6 +60,7 @@
<exclude>src/main/webapp/.ember-cli</exclude> <exclude>src/main/webapp/.ember-cli</exclude>
<exclude>src/main/webapp/.jshintrc</exclude> <exclude>src/main/webapp/.jshintrc</exclude>
<exclude>src/main/webapp/.watchmanconfig</exclude> <exclude>src/main/webapp/.watchmanconfig</exclude>
<exclude>src/main/webapp/WEB-INF/wro.xml</exclude>
</excludes> </excludes>
</configuration> </configuration>
</plugin> </plugin>
@ -65,14 +69,14 @@
<artifactId>maven-clean-plugin</artifactId> <artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version> <version>3.0.0</version>
<configuration> <configuration>
<skip>${keep-ui-build-cache}</skip> <skip>${keepUIBuildCache}</skip>
<followSymLinks>false</followSymLinks> <followSymLinks>false</followSymLinks>
<filesets> <filesets>
<fileset> <fileset>
<directory>${webappTgtDir}/bower_components</directory> <directory>${webappDir}/bower_components</directory>
</fileset> </fileset>
<fileset> <fileset>
<directory>${webappTgtDir}/node_modules</directory> <directory>${webappDir}/node_modules</directory>
</fileset> </fileset>
</filesets> </filesets>
</configuration> </configuration>
@ -89,66 +93,79 @@
</activation> </activation>
<properties> <properties>
<packaging.type>war</packaging.type> <packagingType>war</packagingType>
</properties> </properties>
<build> <build>
<plugins> <plugins>
<!-- prepare source code --> <!-- Copy files into target for build -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId>
<artifactId>maven-antrun-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>prepare-source-code</id> <id>copy-resources</id>
<phase>generate-sources</phase> <!-- here the phase you need -->
<phase>validate</phase>
<goals> <goals>
<goal>run</goal> <goal>copy-resources</goal>
</goals> </goals>
<configuration> <configuration>
<target> <outputDirectory>${webappDir}</outputDirectory>
<copy toDir="${basedir}/target/src/main/webapp"> <resources>
<fileset dir="${basedir}/src/main/webapp"/> <resource>
</copy> <directory>${basedir}/src/main/webapp</directory>
<filtering>true</filtering>
<copy toDir="${basedir}/target/src/public"> <excludes>
<fileset dir="${basedir}/public"/> <exclude>node_modules/**/*</exclude>
</copy> <exclude>bower_components/**/*</exclude>
</target> <exclude>tmp/**/*</exclude>
<exclude>dist/**/*</exclude>
</excludes>
</resource>
</resources>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- Install Node, Yarn, Bower & dependencies -->
<plugin> <plugin>
<groupId>com.github.eirslett</groupId> <groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId> <artifactId>frontend-maven-plugin</artifactId>
<version>1.1</version> <version>1.2</version>
<configuration> <configuration>
<workingDirectory>${webappTgtDir}</workingDirectory> <workingDirectory>${webappDir}</workingDirectory>
</configuration> </configuration>
<executions> <executions>
<!-- Install all dependencies -->
<execution> <execution>
<phase>generate-sources</phase> <phase>generate-resources</phase>
<id>install node and npm</id> <id>install node and yarn</id>
<goals> <goals>
<goal>install-node-and-npm</goal> <goal>install-node-and-yarn</goal>
</goals> </goals>
<configuration> <configuration>
<nodeVersion>${nodeVersion}</nodeVersion> <nodeVersion>v5.12.0</nodeVersion>
<npmVersion>${npmVersion}</npmVersion> <yarnVersion>v0.21.3</yarnVersion>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
<phase>generate-sources</phase> <phase>generate-resources</phase>
<id>npm install</id> <id>yarn install</id>
<goals> <goals>
<goal>npm</goal> <goal>yarn</goal>
</goals> </goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution> </execution>
<execution> <execution>
<phase>generate-sources</phase> <phase>generate-resources</phase>
<id>bower install</id> <id>bower install</id>
<configuration>
<arguments>install</arguments>
</configuration>
<goals> <goals>
<goal>bower</goal> <goal>bower</goal>
</goals> </goals>
@ -156,38 +173,80 @@
</executions> </executions>
</plugin> </plugin>
<!-- Bower install & grunt build-->
<plugin> <plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions> <executions>
<!-- Build -->
<execution> <execution>
<id>ember build</id> <id>ember build</id>
<phase>generate-sources</phase> <phase>generate-resources</phase>
<goals> <goals>
<goal>exec</goal> <goal>exec</goal>
</goals> </goals>
<configuration> <configuration>
<workingDirectory>${webappTgtDir}</workingDirectory> <workingDirectory>${webappDir}</workingDirectory>
<executable>${node.executable}</executable> <executable>${nodeExecutable}</executable>
<arguments> <arguments>
<argument>node/node_modules/npm/bin/npm-cli</argument> <argument>${packageManagerScript}</argument>
<argument>run</argument> <argument>run</argument>
<argument>build:mvn</argument> <argument>build:mvn</argument>
</arguments> </arguments>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- Asset minifier -->
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>1.7.9</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<minimize>true</minimize>
<targetGroups>yarn-ui,vendor</targetGroups>
<destinationFolder>${basedir}/target/minified-resources/assets</destinationFolder>
<contextFolder>${webappDir}/dist/assets</contextFolder>
<wroFile>${webappDir}/WEB-INF/wro.xml</wroFile>
</configuration>
</plugin>
<!-- Package into war --> <!-- Package into war -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
</execution>
</executions>
<configuration> <configuration>
<webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml> <webXml>${webappDir}/WEB-INF/web.xml</webXml>
<warSourceDirectory>${webappTgtDir}/dist</warSourceDirectory> <warSourceDirectory>${webappDir}/dist</warSourceDirectory>
<webResources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/target/minified-resources</directory>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<skipIfEmpty>true</skipIfEmpty>
</configuration> </configuration>
</plugin> </plugin>
@ -195,4 +254,5 @@
</build> </build>
</profile> </profile>
</profiles> </profiles>
</project> </project>

View File

@ -1,4 +1,7 @@
{ {
"directory": "bower_components", "directory": "bower_components",
"analytics": false "analytics": false,
"resolvers": [
"bower-shrinkwrap-resolver-ext"
]
} }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<groups xmlns="http://www.isdc.ro/wro">
<group name='vendor'>
<js>/vendor.js</js>
</group>
<group name='yarn-ui'>
<js>/yarn-ui.js</js>
</group>
</groups>

View File

@ -0,0 +1,66 @@
{
"https://github.com/DataTables/DataTables.git": {
"1.10.15": "1.10.15"
},
"https://github.com/components/ember-data.git": {
"2.1.0": "d8b4d3092f67afe22d9d374c40d719d557915fa3"
},
"https://github.com/components/ember.git": {
"2.2.0": "49e042ca89922ed96b27488c2a98add280ae7123"
},
"https://github.com/components/jqueryui.git": {
"1.11.4": "c34f8dbf3ba57b3784b93f26119f436c0e8288e1"
},
"https://github.com/dockyard/ember-qunit-notifications.git": {
"0.1.0": "a83277aa7a1c0545c66e6d133caebb9a620e71ad"
},
"https://github.com/dockyard/qunit-notifications.git": {
"0.1.1": "7a13f6dba5a340e1cb9e0b64c1c711e4d7edaca1"
},
"https://github.com/ember-cli/ember-cli-shims.git": {
"0.0.6": "dcab43b58d5698690050bb9a46ead5c8663c7da1"
},
"https://github.com/ember-cli/ember-cli-test-loader.git": {
"0.2.1": "3348d801089279296c38f31ae14d9c4d115ce154"
},
"https://github.com/ember-cli/ember-load-initializers.git": {
"0.1.7": "7bb21488563bd1bba23e903a812bf5815beddd1a"
},
"https://github.com/fgnass/spin.js.git": {
"2.3.2": "2.3.2"
},
"https://github.com/ivaynberg/select2.git": {
"4.0.0": "4.0.0"
},
"https://github.com/jquery/jquery-dist.git": {
"2.1.4": "7751e69b615c6eca6f783a81e292a55725af6b85"
},
"https://github.com/jquery/qunit.git": {
"1.19.0": "467e7e34652ad7d5883ce9c568461cf8c5e172a8"
},
"https://github.com/mbostock-bower/d3-bower.git": {
"3.5.17": "3.5.17"
},
"https://github.com/moment/moment-timezone.git": {
"0.5.0": "74a2e9378ecf4a31a168f3049f086565c8d66814"
},
"https://github.com/moment/moment.git": {
"2.10.6": "2.10.6",
"2.12.0": "d3d7488b4d60632854181cb0a9af325d57fb3d51"
},
"https://github.com/rwjblue/ember-qunit-builds.git": {
"0.4.16": "142c4066a5458bef9dfcb92b70152b9c01d79188"
},
"https://github.com/sreenaths/more-js.git": {
"0.8.2": "0.8.2"
},
"https://github.com/sreenaths/snippet-ss.git": {
"1.11.0": "c1abc566f4e001b7f1939b6dbdd911eadc969cf9"
},
"https://github.com/stefanpenner/loader.js.git": {
"3.3.0": "ac909550c9544325632542bbea97531cc60bc628"
},
"https://github.com/twbs/bootstrap.git": {
"3.3.6": "81df608a40bf0629a1dc08e584849bb1e43e0b7a"
}
}

View File

@ -21,8 +21,22 @@ var Funnel = require("broccoli-funnel");
var EmberApp = require('ember-cli/lib/broccoli/ember-app'); var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) { module.exports = function(defaults) {
var isProd = EmberApp.env() === 'production';
var app = new EmberApp(defaults, { var app = new EmberApp(defaults, {
hinting: true storeConfigInMeta: false,
minifyCSS: {
enabled: isProd
},
minifyJS: {
// Will be minified by wro4j-maven-plugin for performance
enabled: false,
},
fingerprint: {
enabled: false
},
sourcemaps: {
enabled: !isProd
}
}); });
app.import("bower_components/datatables/media/css/jquery.dataTables.min.css"); app.import("bower_components/datatables/media/css/jquery.dataTables.min.css");

View File

@ -10,7 +10,6 @@
"scripts": { "scripts": {
"build": "TMPDIR=tmp node ./node_modules/ember-cli/bin/ember build", "build": "TMPDIR=tmp node ./node_modules/ember-cli/bin/ember build",
"start": "TMPDIR=tmp node ./node_modules/ember-cli/bin/ember server", "start": "TMPDIR=tmp node ./node_modules/ember-cli/bin/ember server",
"build:mvn": "TMPDIR=tmp node/node ./node_modules/ember-cli/bin/ember build -prod" "build:mvn": "TMPDIR=tmp node/node ./node_modules/ember-cli/bin/ember build -prod"
}, },
"repository": "", "repository": "",
@ -21,12 +20,13 @@
"license": "Apache", "license": "Apache",
"devDependencies": { "devDependencies": {
"bower": "1.7.7", "bower": "1.7.7",
"bower-shrinkwrap-resolver-ext": "0.1.0",
"broccoli-asset-rev": "2.4.2", "broccoli-asset-rev": "2.4.2",
"broccoli-funnel": "1.0.1", "broccoli-funnel": "1.0.1",
"broccoli-merge-trees": "1.1.1", "broccoli-merge-trees": "1.1.1",
"ember-array-contains-helper": "1.0.2", "ember-array-contains-helper": "1.0.2",
"ember-bootstrap": "0.5.1", "ember-bootstrap": "0.5.1",
"ember-cli": "^1.13.13", "ember-cli": "1.13.14",
"ember-cli-app-version": "1.0.0", "ember-cli-app-version": "1.0.0",
"ember-cli-babel": "5.1.6", "ember-cli-babel": "5.1.6",
"ember-cli-content-security-policy": "0.4.0", "ember-cli-content-security-policy": "0.4.0",
@ -49,8 +49,10 @@
"ember-lodash": "0.0.10", "ember-lodash": "0.0.10",
"ember-resolver": "2.0.3", "ember-resolver": "2.0.3",
"ember-spin-spinner": "0.2.3", "ember-spin-spinner": "0.2.3",
"ember-truth-helpers": "1.2.0", "ember-truth-helpers": "1.3.0",
"select2": "4.0.0" "loader.js": "4.2.3",
"select2": "4.0.0",
"testem": "0.9.11"
}, },
"dependencies": { "dependencies": {
"em-helpers": "^0.8.0", "em-helpers": "^0.8.0",

File diff suppressed because it is too large Load Diff