Skip to content

Commit

Permalink
2.1.0 (#110)
Browse files Browse the repository at this point in the history
* add custom event polyfill

* enable polyfills by default (#103)

* fix overlay viewer in templates (#104)

* [ADF-2125] Removed 'ng2-' from generator instructions (#105)

* [ADF-2125] Removed 'ng2-' from generator instructions

* [ADF-2125] Fixed link that was displayed badly

* [ADF-2125] Fixed small grammar and display glitches

* [ADF-2125] Fixed generator names

* fix style issues

* [ADF-2164] Add docker support to the generated app (#107)

* Add docker support to the generated app

* added the travis configuration for the DOCKER pipeline

* docker publish instructions

* fix docker target folder

* [ADF-2145] Add the app routes files in the generator 2 (#108)

* add route file

* fix module

* travis conf

* [hackathon] command line mode support (#106)

* command line mode support

* code cleanup

* update travis settings

* Update dependencies 2.1.0 (#109)

* update depenccies 2.1.0
* fix import pdfjs
  • Loading branch information
eromano authored Jan 26, 2018
1 parent 036eea2 commit b735fa3
Show file tree
Hide file tree
Showing 47 changed files with 950 additions and 336 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
sudo: required
dist: trusty
addons:
chrome: stable
before_script:
- "sudo chown root /opt/google/chrome/chrome-sandbox"
- "sudo chmod 4755 /opt/google/chrome/chrome-sandbox"
language: node_js
sudo: required
node_js:
- "8"

Expand Down
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ npm install -g yo
Then the Alfresco Application Generator:

```sh
npm install -g generator-ng2-alfresco-app
npm install -g generator-alfresco-adf-app
```

## Generating a new application project

First, move in the folder where you want create your project.

```sh
yo ng2-alfresco-app
yo alfresco-adf-app
```

You will need to run the following scripts in the generated folder:
Expand All @@ -48,21 +48,43 @@ Commands above install all project dependencies, start the project and watch for
Alternatively you can use generator with install switch to trigger automatic installation of dependencies via npm install script:

```sh
yo ng2-alfresco-app --install
yo alfresco-adf-app --install
```

### Using from the command line

You can use the generator in the unattended mode by providing all necessary options from the command line:

```sh
yo ng2-alfresco-app -n app2 -b adf-cli-aps-template -i
```

Options:

| Name | Alias | Type | Description |
| --- | --- | --- | --- |
| --name=\<value> | -n \<value> | string | Application name |
| --blueprint=\<value> | -b \<value> | string | Blueprint name |
| --install | -i | boolean | Install dependencies upon generation |

Default blueprint names:

- adf-cli-acs-aps-template
- adf-cli-acs-template
- adf-cli-aps-template

## Updating generator

```sh
npm update -g generator-ng2-alfresco-app
npm update -g generator-alfresco-adf-app
```

## Getting current version

* Show current version generator-ng2-alfresco-app installed
* Show current version generator-alfresco-adf-app installed

```sh
yo ng2-alfresco-app --version
yo alfresco-adf-app --version
```

## Contributing to the generator
Expand All @@ -75,7 +97,7 @@ yo ng2-alfresco-app --version
6. Push to the branch: `git push origin my-new-feature`
7. Submit a pull request

> to Contribute to the existing code base Add test cases to cover the new behaviour, and make sure all the existing tests are still green.
To Contribute to the existing code base, add test cases to cover the new behaviour, and make sure all the existing tests are still green.

To test the generator:

Expand All @@ -96,10 +118,10 @@ Requirements for new projects:

```sh
# OS X / Linux
DEBUG=yeoman:generator yo ng2-alfresco-app
DEBUG=yeoman:generator yo alfresco-adf-app

# Windows
set DEBUG=yeoman:generator & yo ng2-alfresco-app
set DEBUG=yeoman:generator & yo alfresco-adf-app
```

More on [debugging generators](http://yeoman.io/authoring/debugging.html).
Expand Down
6 changes: 3 additions & 3 deletions __tests__/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Alfresco component generator', () => {
return helpers.run(path.join(__dirname, '../app'))
.withPrompts({
name: 'adf-cli-acs-template',
blueprint: 'Content Services'
blueprint: 'adf-cli-acs-template'
});
});

Expand Down Expand Up @@ -65,7 +65,7 @@ describe('Alfresco component generator', () => {
return helpers.run(path.join(__dirname, '../app'))
.withPrompts({
name: 'adf-cli-aps-template',
blueprint: 'Process Services'
blueprint: 'adf-cli-aps-template'
});
});

Expand Down Expand Up @@ -124,7 +124,7 @@ describe('Alfresco component generator', () => {
return helpers.run(path.join(__dirname, '../app'))
.withPrompts({
name: 'adf-cli-acs-aps-template',
blueprint: 'Process and Content Services'
blueprint: 'adf-cli-acs-aps-template'
});
});

Expand Down
92 changes: 66 additions & 26 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,101 @@
const Generator = require('yeoman-generator');
const utils = require('./utils');
const alflogo = require('alfresco-logo');
const CLIGenerator = require('generator-alfresco-common').cli_generator;
const filters = require('generator-alfresco-common').prompt_filters;

module.exports = class extends Generator {
module.exports = class extends CLIGenerator {
constructor(args, opts) {
super(args, opts);
}

async initializing() {
this.blueprints = await utils.getBluprints();
}

prompting() {
this.log(alflogo(
'ADF Angular app generator for Alfresco\n Version ' + this.rootGeneratorVersion() + '\n',
{'left-pad': ' '}));
this.state = {};
this.blueprints = await utils.getBlueprints();

return this.prompt([
this.prompts = [
{
type: 'input',
name: 'name',
message: 'Your project name',
default: this.appname // Default to current folder name
default: this.appname, // Default to current folder name
option: {
name: 'name',
config: {
name: 'name',
alias: 'n',
required: true,
type: String
}
},
commonFilter: filters.requiredTextFilter
},
{
type: 'list',
name: 'blueprint',
message: 'Application blueprint',
choices: this.blueprints.map(bp => {
return bp.displayName;
})
return {
name: bp.displayName,
value: bp.name
};
}),
option: {
name: 'blueprint',
config: {
alias: 'b',
required: true,
type: String
}
},
commonFilter: filters.chooseOneFilterFactory(this.blueprints.map(bp => bp.name))
},
{
type: 'confirm',
name: 'performInstall',
message: 'Would you like to install dependencies now?'
}])
.then((answers) => {
if (answers.name !== this.appname) {
this.destinationRoot(this.destinationPath(answers.name));
}

this.targetBlueprint = this.blueprints.find(bp => bp.displayName === answers.blueprint);
this.performInstall = answers.performInstall;
});
name: 'install',
message: 'Would you like to install dependencies now?',
option: {
name: 'install',
config: {
alias: 'i',
required: false,
type: Boolean,
default: false
}
},
commonFilter: filters.booleanFilter
}
];

this.setupArgumentsAndOptions(this.prompts);
}

prompting() {
this.log(alflogo(
'ADF Angular app generator for Alfresco\n Version ' + this.rootGeneratorVersion() + '\n',
{'left-pad': ' '}));

return this.subgeneratorPrompt(this.prompts, '', props => {
this.state.name = props.name;
console.log(props.blueprint);
this.state.blueprint = this.blueprints.find(bp => bp.name === props.blueprint);
this.state.install = props.install;

if (props.name !== this.appname) {
this.destinationRoot(this.destinationPath(props.name));
}
});
}

writing() {
this.fs.copy(
this.targetBlueprint.path + '/**/*',
this.state.blueprint.path + '/**/*',
this.destinationPath(),
{ globOptions: { dot: true } }
);
}

install() {
if (this.options.install || this.performInstall) {
if (this.options.install || this.state.install) {
this.npmInstall();
}
}
Expand Down
12 changes: 12 additions & 0 deletions app/templates/adf-cli-acs-aps-template/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ script:
- export CHROME_BIN=chromium-browser
- xvfb-run -a npm run test -- --single-run --no-progress --browser=ChromeNoSandbox
#- xvfb-run -a npm run e2e -- --no-progress --config=protractor-ci.conf.js

after_success:
- bash <(curl -s https://codecov.io/bash) -X gcov
#Uncomment this part if you want publish your docker image
# - export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
# - echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH"
# - export TAG=`if [ "$BRANCH" == "master" ]; then echo "latest"; else echo $BRANCH ; fi`
# - docker build -t $DOCKER_REPO:$TAG .
# # Publish extra image based on Travis build number
# - docker tag $DOCKER_REPO:$TAG $DOCKER_REPO:travis-$TRAVIS_BUILD_NUMBER
# - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
# - docker push $DOCKER_REPO
6 changes: 6 additions & 0 deletions app/templates/adf-cli-acs-aps-template/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM nginx

COPY nginx.conf /etc/nginx/nginx.conf

WORKDIR /usr/share/nginx/html
COPY dist/ .
41 changes: 41 additions & 0 deletions app/templates/adf-cli-acs-aps-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,44 @@ Before running the tests make sure you are serving the app via `ng serve`.
## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

# Docker

You can create a Docker image to run your generated app in the container.

## Building from source code

You need to run the following commands to build the project from the source code:

```sh
npm run build
```

That produces a build in the "dist" folder that you can use with a Docker image.

<p class="tip">
Also, you may need to update the `dist/app.config.json` file with the settings relevant to your scenario.
</p>

## Creating an image

The generated app provides a "Dockerfile" file in the repository root.
You can build the image with the following command:

```sh
docker image build -t YOUR_NAME_APP .
```

## Running image in a container

To run the image locally, you can use the following command:

```sh
docker container run -p 80:80 --rm YOUR_NAME_APP
```

Navigate to "http://localhost" to access the running application.

<p class="tip">
(For more information about docker see also)[docker.md]
</p>
62 changes: 62 additions & 0 deletions app/templates/adf-cli-acs-aps-template/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

## Publishing to Docker Hub

First of all, if you do not have a Docker Hub account, you can register here: https://hub.docker.com/, the registration is absolutely free.

Next, it is recommended that you get a clean build of the application:

```sh
npm install
npm run build
```

The commands above are going to produce a fresh build that is stored in the `dist` folder.
At this point, you can make modifications to the final code in the `dist` folder if needed.
For example you may want to change the `app.config.json` file content.

Now you can build your first version of the image:

```sh
docker image build -t myaccount/my_app_name:1.0 .
```

Where `myaccount` is usually your Docker Hub account name.

<p class="warning">
Please note the ending "." symbol at the end of the command. It instructs the Docker to take current folder where the `Dockerfile` is located.
</p>

To publish the newly created image use the next command:

```sh
docker push myaccount/my_app_name:1.0
```

## Running from Docker Hub

To quickly test the published image, or run it on another machine, use the following command:

```sh
docker container run -p 80:80 --rm myaccount/my_app_name:1.0
```

The `--rm` switch means the Docker will cleanup the container and image data once you stop the process.

<p class="tip">
You may also want to remove your local image before trying out the Docker Hub:<br>
`docker image rm myaccount/my_app_name:1.0`
</p>

## Travis

In order to let Travis publish the image to a registry for you uncomment the relative part in the `.travis.yml`.
The email, username, and password used for login should be stored in the repository settings environment variables, which may be set up through the web or locally via the Travis CLI, e.g.:

```
travis env set DOCKER_USERNAME myusername
travis env set DOCKER_PASSWORD secretsecr
```

For more information [see also Pushing a Docker Image to a Registry ](https://docs.travis-ci.com/user/docker/)


Loading

0 comments on commit b735fa3

Please sign in to comment.