diff --git a/angular.json b/angular.json index 81eb232..7da03cc 100644 --- a/angular.json +++ b/angular.json @@ -1,140 +1,194 @@ { - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "cavallium-website": { - "root": "", - "sourceRoot": "src", - "projectType": "application", - "prefix": "app", - "schematics": { - "@schematics/angular:component": { - "style": "scss" - } - }, - "architect": { - "build": { - "builder": "@angular-devkit/build-angular:browser", - "options": { - "outputPath": "dist/cavallium-website", - "index": "src/index.html", - "main": "src/main.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "src/tsconfig.app.json", - "assets": [ - "src/favicon.ico", - "src/assets" - ], - "styles": [ - "src/styles.scss" - ], - "scripts": [], - "es5BrowserSupport": true - }, - "configurations": { - "production": { - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" - } - ], - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "extractCss": true, - "namedChunks": false, - "aot": true, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true, - "budgets": [ - { - "type": "initial", - "maximumWarning": "2mb", - "maximumError": "5mb" - } - ] - } - } - }, - "serve": { - "builder": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "cavallium-website:build" - }, - "configurations": { - "production": { - "browserTarget": "cavallium-website:build:production" - } - } - }, - "extract-i18n": { - "builder": "@angular-devkit/build-angular:extract-i18n", - "options": { - "browserTarget": "cavallium-website:build" - } - }, - "test": { - "builder": "@angular-devkit/build-angular:karma", - "options": { - "main": "src/test.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "src/tsconfig.spec.json", - "karmaConfig": "src/karma.conf.js", - "styles": [ - "src/styles.scss" - ], - "scripts": [], - "assets": [ - "src/favicon.ico", - "src/assets" - ] - } - }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": [ - "src/tsconfig.app.json", - "src/tsconfig.spec.json" - ], - "exclude": [ - "**/node_modules/**" - ] - } - } - } - }, - "cavallium-website-e2e": { - "root": "e2e/", - "projectType": "application", - "prefix": "", - "architect": { - "e2e": { - "builder": "@angular-devkit/build-angular:protractor", - "options": { - "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "cavallium-website:serve" - }, - "configurations": { - "production": { - "devServerTarget": "cavallium-website:serve:production" - } - } - }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": "e2e/tsconfig.e2e.json", - "exclude": [ - "**/node_modules/**" - ] - } - } - } - } - }, - "defaultProject": "cavallium-website" + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "cavallium-website": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": { + "@schematics/angular:component": { + "style": "scss" + } + }, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/cavallium-website", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.app.json", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.scss" + ], + "scripts": [], + "es5BrowserSupport": true, + "i18nFormat": "xlf", + "i18nMissingTranslation": "error" + }, + "configurations": { + "production_it": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + } + ], + "outputPath": "dist/italian/", + "i18nFile": "src/locale/messages.it.xlf", + "i18nLocale": "it" + }, + "serve_it": { + "aot": true, + "baseHref": "/it/", + "outputPath": "dist/italian/", + "i18nFile": "src/locale/messages.it.xlf", + "i18nLocale": "it" + }, + "production_en": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + } + ], + "outputPath": "dist/english/", + "i18nFile": "src/locale/messages.en.xlf", + "i18nLocale": "en" + }, + "serve_en": { + "aot": true, + "baseHref": "/en/", + "outputPath": "dist/english/", + "i18nFile": "src/locale/messages.en.xlf", + "i18nLocale": "en" + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "cavallium-website:build" + }, + "configurations": { + "production": { + "browserTarget": "cavallium-website:build:production" + }, + "en": { + "browserTarget": "cavallium-website:build:serve_en", + "port": 4201 + }, + "it": { + "browserTarget": "cavallium-website:build:serve_it", + "port": 4200 + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "cavallium-website:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.spec.json", + "karmaConfig": "src/karma.conf.js", + "styles": [ + "src/styles.scss" + ], + "scripts": [], + "assets": [ + "src/favicon.ico", + "src/assets" + ] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "src/tsconfig.app.json", + "src/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + } + } + }, + "cavallium-website-e2e": { + "root": "e2e/", + "projectType": "application", + "prefix": "", + "architect": { + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "cavallium-website:serve" + }, + "configurations": { + "production": { + "devServerTarget": "cavallium-website:serve:production" + } + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": "e2e/tsconfig.e2e.json", + "exclude": [ + "**/node_modules/**" + ] + } + } + } + } + }, + "defaultProject": "cavallium-website" } \ No newline at end of file diff --git a/build.js b/build.js new file mode 100644 index 0000000..0338459 --- /dev/null +++ b/build.js @@ -0,0 +1,73 @@ +const fs = require("fs"); +const { spawn } = require('cross-spawn'); +var execOptions = { + encoding: "utf8", + shell: "", +}; +const argument0 = process.argv[2]; + +async function main(runMode) { + const angularSourceText = fs.readFileSync("buildconfig.json"); + const angularSource = JSON.parse(angularSourceText); + const productionConfiguration = angularSource.angular.projects[angularSource.projectName].architect.build.configurations["production"]; + delete angularSource.angular.projects[angularSource.projectName].architect.build.configurations["production"]; + angularSource.languages.forEach((language, languageIndex) => { + const languageConfiguration = angularSource.angular.projects[angularSource.projectName].architect.build.configurations[language]; + delete angularSource.angular.projects[angularSource.projectName].architect.build.configurations[language]; + angularSource.angular.projects[angularSource.projectName].architect.build.configurations["production_" + language] = { + ...productionConfiguration, + ...languageConfiguration + }; + angularSource.angular.projects[angularSource.projectName].architect.build.configurations["serve_" + language] = { + "aot": true, + "baseHref": "/"+language+"/", + ...languageConfiguration, + }; + angularSource.angular.projects[angularSource.projectName].architect.serve.configurations[language] = { + "browserTarget": "cavallium-website:build:serve_"+language, + "port": 4200 + languageIndex + }; + }); + + fs.writeFileSync("angular.json", JSON.stringify(angularSource.angular, null, "\t"), "utf8"); + console.log("Angular source built"); + + switch (runMode) { + case "build": { + await Promise.all(angularSource.languages.map((language, index) => { + console.log("Building for language " + JSON.stringify(language) + (index > 0 ? " (hidden)" : "")); + const childProcess = spawn("ng", ["build", "--configuration=production_" + language], + { stdio: [process.stdin, index == 0 ? process.stdout : null, process.stderr] }); + return onExit(childProcess); + })); + } + break; + case "serve": + await Promise.all(angularSource.languages.map((language, index) => { + console.log("Building for language " + JSON.stringify(language) + (index > 0 ? " (hidden)" : "")); + const childProcess = spawn("ng", ["serve", "--configuration=" + language], + { stdio: [process.stdin, index == 0 ? process.stdout : null, process.stderr] }); + return onExit(childProcess); + })); + break; + default: + console.error("Error! Only Build and Serve commands are accepted!"); + return; + } +} +main(argument0); + +function onExit(childProcess) { + return new Promise((resolve, reject) => { + childProcess.once('exit', (code, signal) => { + if (code === 0) { + resolve(undefined); + } else { + reject(new Error('Exit with error code: ' + code)); + } + }); + childProcess.once('error', (err) => { + reject(err); + }); + }); +} \ No newline at end of file diff --git a/buildconfig.json b/buildconfig.json new file mode 100644 index 0000000..670ab55 --- /dev/null +++ b/buildconfig.json @@ -0,0 +1,163 @@ +{ + "version": 1, + "projectName": "cavallium-website", + "languages": ["it", "en"], + "angular": { + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "cavallium-website": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": { + "@schematics/angular:component": { + "style": "scss" + } + }, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/cavallium-website", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.app.json", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.scss" + ], + "scripts": [], + "es5BrowserSupport": true, + "i18nFormat": "xlf", + "i18nMissingTranslation": "error" + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + } + ] + }, + "en": { + "outputPath": "dist/english/", + "i18nFile": "src/locale/messages.en.xlf", + "i18nLocale": "en" + }, + "it": { + "outputPath": "dist/italian/", + "i18nFile": "src/locale/messages.it.xlf", + "i18nLocale": "it" + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "cavallium-website:build" + }, + "configurations": { + "production": { + "browserTarget": "cavallium-website:build:production" + }, + "en": { + "browserTarget": "my-project:build:it" + }, + "it": { + "browserTarget": "my-project:build:it" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "cavallium-website:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.spec.json", + "karmaConfig": "src/karma.conf.js", + "styles": [ + "src/styles.scss" + ], + "scripts": [], + "assets": [ + "src/favicon.ico", + "src/assets" + ] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "src/tsconfig.app.json", + "src/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + } + } + }, + "cavallium-website-e2e": { + "root": "e2e/", + "projectType": "application", + "prefix": "", + "architect": { + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "cavallium-website:serve" + }, + "configurations": { + "production": { + "devServerTarget": "cavallium-website:serve:production" + } + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": "e2e/tsconfig.e2e.json", + "exclude": [ + "**/node_modules/**" + ] + } + } + } + } + }, + "defaultProject": "cavallium-website" + } +} \ No newline at end of file diff --git a/package.json b/package.json index edb3e88..3a0eb5f 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "scripts": { "ng": "ng", "postinstall": "ivy-ngcc", - "start": "ng serve", - "build": "ng build", + "start": "node build.js serve", + "build": "node build.js build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" @@ -17,6 +17,7 @@ "@angular/compiler": "~7.2.0", "@angular/core": "~7.2.0", "@angular/forms": "~7.2.0", + "@angular/http": "~7.2.0", "@angular/platform-browser": "~7.2.0", "@angular/platform-browser-dynamic": "~7.2.0", "@angular/router": "~7.2.0", diff --git a/src/app/app.component.html b/src/app/app.component.html index 0f3d9d8..f66b25a 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -2,7 +2,8 @@

Welcome to {{ title }}! -

+ +

Welcome to

Angular Logo

Here are some links to help you start:

diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2c3ba29..c2d9935 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -3,10 +3,16 @@ import { NgModule } from '@angular/core'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; +import { HomeComponent } from './pages/home/home.component'; +import { NavbarComponent } from './gui/navbar/navbar.component'; +import { FooterComponent } from './gui/footer/footer.component'; @NgModule({ declarations: [ - AppComponent + AppComponent, + HomeComponent, + NavbarComponent, + FooterComponent ], imports: [ BrowserModule, diff --git a/src/app/gui/footer/footer.component.html b/src/app/gui/footer/footer.component.html new file mode 100644 index 0000000..6800e0e --- /dev/null +++ b/src/app/gui/footer/footer.component.html @@ -0,0 +1,3 @@ +

+ footer works! +

diff --git a/src/app/gui/footer/footer.component.scss b/src/app/gui/footer/footer.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/gui/footer/footer.component.spec.ts b/src/app/gui/footer/footer.component.spec.ts new file mode 100644 index 0000000..2ca6c45 --- /dev/null +++ b/src/app/gui/footer/footer.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FooterComponent } from './footer.component'; + +describe('FooterComponent', () => { + let component: FooterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FooterComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FooterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/gui/footer/footer.component.ts b/src/app/gui/footer/footer.component.ts new file mode 100644 index 0000000..da17d82 --- /dev/null +++ b/src/app/gui/footer/footer.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-footer', + templateUrl: './footer.component.html', + styleUrls: ['./footer.component.scss'] +}) +export class FooterComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/src/app/gui/navbar/navbar.component.html b/src/app/gui/navbar/navbar.component.html new file mode 100644 index 0000000..387751c --- /dev/null +++ b/src/app/gui/navbar/navbar.component.html @@ -0,0 +1,3 @@ +

+ navbar works! +

diff --git a/src/app/gui/navbar/navbar.component.scss b/src/app/gui/navbar/navbar.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/gui/navbar/navbar.component.spec.ts b/src/app/gui/navbar/navbar.component.spec.ts new file mode 100644 index 0000000..9032ad2 --- /dev/null +++ b/src/app/gui/navbar/navbar.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NavbarComponent } from './navbar.component'; + +describe('NavbarComponent', () => { + let component: NavbarComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ NavbarComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(NavbarComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/gui/navbar/navbar.component.ts b/src/app/gui/navbar/navbar.component.ts new file mode 100644 index 0000000..a1b4d25 --- /dev/null +++ b/src/app/gui/navbar/navbar.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-navbar', + templateUrl: './navbar.component.html', + styleUrls: ['./navbar.component.scss'] +}) +export class NavbarComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/src/app/pages/home/home.component.html b/src/app/pages/home/home.component.html new file mode 100644 index 0000000..afc16a3 --- /dev/null +++ b/src/app/pages/home/home.component.html @@ -0,0 +1,3 @@ +

+ home works! +

diff --git a/src/app/pages/home/home.component.scss b/src/app/pages/home/home.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/home/home.component.spec.ts b/src/app/pages/home/home.component.spec.ts new file mode 100644 index 0000000..490e81b --- /dev/null +++ b/src/app/pages/home/home.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HomeComponent } from './home.component'; + +describe('HomeComponent', () => { + let component: HomeComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ HomeComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(HomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts new file mode 100644 index 0000000..f56c8c1 --- /dev/null +++ b/src/app/pages/home/home.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-home', + templateUrl: './home.component.html', + styleUrls: ['./home.component.scss'] +}) +export class HomeComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/src/locale/messages.en.xlf b/src/locale/messages.en.xlf new file mode 100644 index 0000000..af2ad6a --- /dev/null +++ b/src/locale/messages.en.xlf @@ -0,0 +1,11 @@ + + + + + + Welcome to + Welcome to + + + + \ No newline at end of file diff --git a/src/locale/messages.it.xlf b/src/locale/messages.it.xlf new file mode 100644 index 0000000..f3d87bb --- /dev/null +++ b/src/locale/messages.it.xlf @@ -0,0 +1,11 @@ + + + + + + Welcome to + Benvenuto in + + + + \ No newline at end of file