Do you like angular-cli-skeleton? Please, add a 'star' to support this library
This project is not dead, I'm simply waiting for IVY render (RENDER 3) + runtime i18n support. When Google will release this (I hope this summer as first public beta), I'll update the repo with many new features. So I suggest to star and watch this project, if you are interested
A simple ready to use skeleton project with angular-cli (optionally also angular-universal), Angular 6, Bootstrap 4, ng-bootstrap, ngrx-store and so on.
This project my previous older skeleton project called angular-webpack-skeleton.
If you like it, please add a star. It will be really apprecieted.
- Typescript >= 2.7
- Angular 6
- Ahead of Time (AOT) enabled by default for Angular >= 5
- Lazy loading
- The new HttpClient of Angular >= 4.3
- RxJS 6 with lettable operators and
rxjs-compat
for legacy libraries
- Bootstrap 4 with a custom theme (check
./src/_variables.scss
), ng-bootstrap - FontAwesome 5
- jQuery
- Web App Manifest support to add it as a standalone app on mobile devices (see
manifest.json
) - Service Workers to create an offline application (see
./src/ngsw-config.json
) - socket.io (still work in progress and TEMPORARY DISABLED. Check this issue
- Reactive storage based on Redux
- @ngrx/store >= 4
- @ngrx/store-devtools >= 4
- angular-cli
- different profiles: 'development', 'development with HMR', 'production', 'production with SSR'
- Hot Module Replacement (HMR)
- Tree shaking
- SASS support
- UglifyJs and build-optimizer for production builds
- Bundle Analyzer
- Proxying support (optional to proxy your rest services with webpack-dev-server)
- Server Side Rendering with angular-universal
- AppShell (still work in progress and TEMPORARY DISABLED. Check this issue
- Testing
- Unit testing with Karma and Jasmine
- Custom advanced configuration to specify different browsers on CIs (check 'getBrowsers()' in
./karma.conf.js
) - Multiple launcher for browsers (Chrome, Firefox, IE, Edge, Safari). See
karma.conf.js
- Chrome Headless support to run unit tests (better than PhantomJS)
- Multiple coverage reporters:
json
,html
,lcovonly
,mocha
, SonarQube and also in your console
- Custom advanced configuration to specify different browsers on CIs (check 'getBrowsers()' in
- End to end (E2E) testing with Protractor and WebDriver JS
- Code coverage with IstanbulJs
- Unit testing with Karma and Jasmine
- Code analysis and quality
- TSLint
- Codelyzer
- Sass-lint
- Prettier triggered by pre-commit hook
- Documentation
- Docker
- Docker with the production build (no ssr at the moment) and ngnix
- See all my public repos here Docker Hub
- Continous Integration
- Multiple server-side implementations with NodeJS
- NodeJS + Express in Javascript (see
./servers/node-express-js
) - NodeJS + Express in Typescript (see
./servers/node-express-ts
) - NodeJS + Koa in Javascript (see
./servers/node-koa-js
)
- NodeJS + Express in Javascript (see
- and many more...
- ??/??/2018 - 1.0.0-beta.3 - Check HERE
- 04/03/2018 - 1.0.0-beta.2 - Check HERE
- 01/06/2018 - 1.0.0-beta.1 - Check HERE
Full changelog HERE
This reduced structure is based on Angular style-guide and on my personal experience. For the full file structure check HERE.
angular-cli-skeleton/
├─e2e/ * end-to-end tests with Protractor
│ ├─app.e2e-spec.ts * e2e test for the main page
│ ├─app.po.ts * e2e page oject for home page
│ └─tsconfig.e2e.ts * config file for typescript when running e2e tests
│
├─servers/ * server-side implementations to manage authentication
│ ├─node-express-js * NodeJS with ExpressJS Javascript implementation
│ ├─node-express-js * NodeJS with ExpressJS Typescript implementation
│ └─node-koa-js * NodeJS with KoaJS Javascript implementation
│
├─src/ * main source folder
│ ├─app/ * source folder of 'app' SPA
│ │ ├─app-shell/ * app-shell folder (STILL UNUSED)
│ │ ├─core/ * CoreModule provides services. You can import this module only on time in the root module
│ │ │ ├─actions/ * folder of ngrx actions
│ │ │ │ └─hello.example.ts * hello-example ngrx action
│ │ │ ├─reducers/ * folder of ngrx reducers
│ │ │ │ └─hello.example.ts * hello-example ngrx reducer
│ │ │ ├─services/ * services of the CoreModule
│ │ │ │ ├─example.service.ts * example of a synchronous service
│ │ │ │ ├─github.service.ts * example of an asynchronous service with HttpClient
│ │ │ │ └─services.ts * export an array of services to easely import into the module's definition
│ │ │ ├─core.module.ts * definition of the CoreModule
│ │ │ └─module-import-guard.ts * guard to prevent multiple import of the CoreModule
│ │ │
│ │ ├─pages/ * pages/features of the 'app' SPA
│ │ │ ├─404/
│ │ │ │ └─not-found.component.ts * 404 component shown for route '**'
│ │ │ ├─home/
│ │ │ │ ├─home.component.ts * homepage component shown for route '/'
│ │ │ │ ├─home.html * homepage template
│ │ │ │ └─home.scss * homepage scss file with local styles
│ │ │ ├─lazy/ * lazy loaded module shown for route 'lazy'
│ │ │ │ ├─actions/ * ngrx actions only for this lazy loaded module
│ │ │ │ │ └─page-num.ts * page-num ngrx action
│ │ │ │ ├─reducers/ * ngrx reducers only for this lazy loaded module
│ │ │ │ │ ├─index.ts * main file of all reducers of this lazy loaded module
│ │ │ │ │ └─page-num.ts * page-num ngrx reducer
│ │ │ │ ├─lazy.component.spec.ts * unit test of lazy loaded component
│ │ │ │ ├─lazy.component.ts * lazy loaded component
│ │ │ │ ├─lazy.html * template of the lazy loaded component
│ │ │ │ ├─lazy.module.ts * definition of the lazy loaded module
│ │ │ │ ├─lazy.routes.ts * local routes for the lazy loaded module
│ │ │ │ └─lazy.scss * lazy loaded module's scss file with local styles
│ │ │ ├─sw/
│ │ │ │ ├─sw.component.ts * service-worker component shown for route '/sw'
│ │ │ │ ├─sw.html * service-worker template
│ │ │ │ └─sw.scss * service-worker scss file with local styles
│ │ │ └─components.ts * export an array of components to easely import into the module's definition
│ │ │
│ │ ├─reducers/ * define main ngrx reducer for the app SPA
│ │ │
│ │ ├─shared/ * SharedModule provides common components, directives... It can be imported more times also by sub-modules
│ │ │ ├─components/ * components of the SharedModule
│ │ │ │ ├─footer/ * footer component
│ │ │ │ ├─navbar/ * navbar componet
│ │ │ │ ├─page-header/ * page header component
│ │ │ │ └─components.ts * export an array of components to easely import into the module's definition
│ │ │ └─shared.module.ts * definition of the SharedModule
│ │ │
│ │ ├─app.component.html * main template's component of the application
│ │ ├─app.component.scss * scss file for the main component of the application
│ │ ├─app.component.spec.ts * main component's unit test
│ │ ├─app.component.ts * main component of the application
│ │ ├─app.module.ts * root module of the application (browser-side)
│ │ ├─app.server.module.ts * root module of the application (server-side)
│ │ └─app-routing.module.ts * routes module of the app SPA
│ │
│ ├─styles/ * root styles (CSS/SCSS) for the entire application (all SPAs)
│ │ ├─headings.css * css file (to show that you can use both css and scss)
│ │ ├─loading.scss * SCSS loading spinner
│ │ ├─styles.scss * main SCSS that imports all other SCSS in this directory (loading ad variables)
│ │ └─variables.scss * SCSS variables
│ │
│ ├─assets/ * images, icons and other stuff
│ │
│ ├─environments/ * folder loaded by angular cli depending on dev, prod...
│ │ ├─environment.hmr.ts * environment file for development with hmr
│ │ ├─environment.prod.ts * environment file for production
│ │ └─environment.ts * environment file for development without hmr
│ │
│ ├─_variables.scss * file with scss variables to customize bootstrap and to import fonts from third-party deps
│ ├─favicon.ico * application's icon
│ ├─hmr.ts * file to init HMR ir running with hrm enabled
│ ├─index.html * index file of this application
│ ├─main.server.ts * main file to boot this applcation on server-side with angular-universal
│ ├─main.ts * main file to boot this applcation on browser-side (client)
│ ├─manifest.json * web manifest
│ ├─ngsw-config.json * config file for service workers
│ ├─polyfills.ts * polyfills used by Angular to support older browsers
│ ├─styles.scss * main scss file to define global styles
│ ├─test.ts * test config file to load .spec.ts files
│ ├─tsconfig.app.json * typescript's config file for the application (browser-side)
│ ├─tsconfig.server.json * typescript's config file for the application (server-side)
│ ├─tsconfig.spec.json * typescript's config file for unit testing
│ └─typings.d.ts * typescript's custom types
│
├─.angular-cli.json * angular-cli config file
├─karma.conf.js * karma config file for unit testing
├─protractor.config.js * protractor config file for e2e testing
├─protractor-ci.config.js * protractor config file for e2e testing in Continous Integration
├─proxy.conf.json * proxy configuration for angular-cli when using 'npm start'
├─server.ts * NodeJs server to enable Server Side Rendering
├─tsconfig.json * typescript's config file
├─tslit.json * TSLint config file
└─webpack.server.conf.js * webpack config file to build server-side (angular-universal)
- Nodejs >= 8.0.0 (please use always the latest version)
- npm >= 5.2.0 (please use always the latest version)
- build and run the front-end of this project with angular-cli, but authentication won't work (obviously, because It needs a server)
- build this project and run it with one of the two servers in
./servers
(authentication is working!!!) - build and run this project with angular-universal (authentication still not supported - COMING SOON)
This is a 'work in progress' project, so if you need other info, please open an issue. At the moment, documentation and README are minimalistic.
npm install -g lite-server
npm install
(from the folder of this project)cd servers/node-express-js && npm install
cd servers/node-express-ts && npm install
cd servers/node-koa-js && npm install
npm run build:dev
cd dist
lite-server
npm run build:prod
cd dist
lite-server
Build both client and server apps in 'dist' folder (production mode + AOT + build-optimizer + angular-universal)
npm run build:ssr
npm start
npm start:prod
cd dist/browser
lite-server
cd dist/browser
lite-server
npm run serve:ssr
npm run build:dev
cd servers/node-express-js && npm start
npm run build:prod
cd servers/node-express-js && npm start
or
npm run build:dev
cd servers/node-express-ts && npm run build && npm start
npm run build:prod
cd servers/node-express-ts && npm run build && npm start
npm test
npm run webdriver:update
(if you have problems, try again removing./node_modules
and executingnpm install
again)npm run e2e
npm run docs:typedoc
To generate the really cool compodoc's documentation (check documentation/index.html for the result)
npm run docs:compodoc
or
npm run docs:compodoc:serve
to navigate the resulting documentation in your browser
npm run clean
- Run either
npm run build:dev:stats
ornpm run build:prod:stats
- Open analyzer with
npm run analyze:bundle
to see the result
With this tutorial, you'll configure Jenkins to build your project from GitHub, where the Pipeline's script is in the remote repository.
- Install java and define all necessary env variables for your OS
- Download the latest version of Jenkins 2 HERE. If you are using macOS, I suggest to use Homebrew
- Install Jenkins following this instruction
- Run it (if installed with HomeBrew, run
jenkins
in your terminal) - Navigate to
http://localhost:8080
and unlock Jenkins (for more info check HERE) - Install all suggested plugins
- Create a new admin user (please, you shouldn't skip this step) as explained HERE
- Navigate to
http://localhost:8080/pluginManager/available
and installNodeJS Plugin
- Restart Jenkins and log in with the new admin user created at step 7
- Navigate to
http://localhost:8080/configureTools/
and add a new NodeJS installation (remember to save all changes at the end) with these parameters:- Name: node-8.4.0 (this name must match
tool name
in your pipeline's script. If you are a beginner, please don't change it) - Install automatically: checked
- Version: NodeJS 8.4.0
- Name: node-8.4.0 (this name must match
- Create a new PIPELINE at
http://localhost:8080/view/all/newJob
called for instanceangular-cli-skeleton
- Check both
GitHub project
(use this url:https://github.com/Ks89/angular-cli-skeleton/
) andGitHub hook trigger for GIT Scm polling
- In the Pipeline section, choose
Pipeline script from SCM
, with SCMGit
and URLhttps://github.com/Ks89/angular-cli-skeleton
to get the pipeline's script from./Jenkinsfile
via git - Script Path must match the Jenkins file name in your repository (i.e.
Jenkinsfile-local-macOS
) - Save and build
PS: if you want to use Jenkins on a remote server, you should add these two env variables:
- CI=true
- JENKINS=true
COMING SOON a tutorial to install and configure Jenkins in a VPS at OVH.com
- Install java and define all necessary env variables for your OS
- Download and install SonarQube on your pc/mac HERE
- Start SonarQube running the right script (make sure to run it with execution privileges) in
INSTALL_FOLDER/bin/YOUR_OS/SCRIPT_NAME start
(for instance on macOS I'm using./INSTALL_FOLDER/bin/macosx-universal-64/sonar.sh start
) - Navigate with your browser to
http://localhost:9000
to see if everything is working - If you need to login ad administrator to SonarQube use (user:
admin
, password:admin
) - Install the right TypeScript plugin HERE downloading the latest jar binary
- Copy that .jar into
INSTALL_FOLDER/extensions/plugins
(in necessary remove the other TypeScript plugin in this folder) - Restart SonarQube running
INSTALL_FOLDER/bin/YOUR_OS/SCRIPT_NAME stop
andINSTALL_FOLDER/bin/YOUR_OS/SCRIPT_NAME start
- Login as admin at
http://localhost:9000
- At
http://localhost:9000
find the TypeScript tab (in the sidebar), paste in the TsLint path (for instance, on macOS I'm using my global installation of TsLint/usr/local/lib/node_modules/tslint/bin/tslint
). If you are a Windows user useC:\Users\[Username]\AppData\Roaming\npm\node_modules\tslint\bin\tslint
- Download and install sonar-scanner on your pc/mac HERE
- Define a new unique
project key
. I used the name of the repoangular-cli-skeleton
for this project - Create an account of sonarcloud
- Go to account security to generate a new token with your
project key
:angular-cli-skeleton
- Clean all your useless folders running
npm run clean
inside the root of your project - Modify this script with your info and run it from the root of your project
For instance, I used this:
-Dsonar.projectKey=your_project_key_that_must_be_unique \ -Dsonar.sources=. \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.organization=your_organization_key \ -Dsonar.login=abcdef0123456789
sonar-scanner \ -Dsonar.projectKey=angular-cli-skeleton \ -Dsonar.sources=. \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.organization=ks89-github \ -Dsonar.login=SONARCLOUDIO_SECRET_TOKEN
- Navigate to
https://sonarcloud.io/dashboard?id=YOUR_PROJECT_NAME (The path of this project is
https://sonarcloud.io/dashboard?id=angular-cli-skeleton`) - If everything is ok, then I suggest to modify both 'analyze:sonar' and 'analyze:sonar:ci' scripts into
package.json
based on step 6, omitting-Dsonar.login=
, because this is a secret key and you shouldn't commit it - Now try to run sonar analysis with 'npm run analyze:sonar -- -Dsonar.login=SONARCLOUDIO_SECRET_TOKEN'
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.
To deploy with a custom path, please check here: https://angular.io/guide/deployment
For other questions, please feel free to open an issue.
MIT License
Copyright (c) 2017-2018 Stefano Cappa
This license is valid to all my files in this repo
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
If you like my projects you can do a free donation here
Created by Stefano Cappa