First commit

This commit is contained in:
Andrea Cavalli 2019-04-12 00:16:56 +02:00
parent ddde9315ca
commit 47381c696b
20 changed files with 591 additions and 142 deletions

View File

@ -1,140 +1,194 @@
{ {
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1, "version": 1,
"newProjectRoot": "projects", "newProjectRoot": "projects",
"projects": { "projects": {
"cavallium-website": { "cavallium-website": {
"root": "", "root": "",
"sourceRoot": "src", "sourceRoot": "src",
"projectType": "application", "projectType": "application",
"prefix": "app", "prefix": "app",
"schematics": { "schematics": {
"@schematics/angular:component": { "@schematics/angular:component": {
"style": "scss" "style": "scss"
} }
}, },
"architect": { "architect": {
"build": { "build": {
"builder": "@angular-devkit/build-angular:browser", "builder": "@angular-devkit/build-angular:browser",
"options": { "options": {
"outputPath": "dist/cavallium-website", "outputPath": "dist/cavallium-website",
"index": "src/index.html", "index": "src/index.html",
"main": "src/main.ts", "main": "src/main.ts",
"polyfills": "src/polyfills.ts", "polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json", "tsConfig": "src/tsconfig.app.json",
"assets": [ "assets": [
"src/favicon.ico", "src/favicon.ico",
"src/assets" "src/assets"
], ],
"styles": [ "styles": [
"src/styles.scss" "src/styles.scss"
], ],
"scripts": [], "scripts": [],
"es5BrowserSupport": true "es5BrowserSupport": true,
}, "i18nFormat": "xlf",
"configurations": { "i18nMissingTranslation": "error"
"production": { },
"fileReplacements": [ "configurations": {
{ "production_it": {
"replace": "src/environments/environment.ts", "fileReplacements": [
"with": "src/environments/environment.prod.ts" {
} "replace": "src/environments/environment.ts",
], "with": "src/environments/environment.prod.ts"
"optimization": true, }
"outputHashing": "all", ],
"sourceMap": false, "optimization": true,
"extractCss": true, "outputHashing": "all",
"namedChunks": false, "sourceMap": false,
"aot": true, "extractCss": true,
"extractLicenses": true, "namedChunks": false,
"vendorChunk": false, "aot": true,
"buildOptimizer": true, "extractLicenses": true,
"budgets": [ "vendorChunk": false,
{ "buildOptimizer": true,
"type": "initial", "budgets": [
"maximumWarning": "2mb", {
"maximumError": "5mb" "type": "initial",
} "maximumWarning": "2mb",
] "maximumError": "5mb"
} }
} ],
}, "outputPath": "dist/italian/",
"serve": { "i18nFile": "src/locale/messages.it.xlf",
"builder": "@angular-devkit/build-angular:dev-server", "i18nLocale": "it"
"options": { },
"browserTarget": "cavallium-website:build" "serve_it": {
}, "aot": true,
"configurations": { "baseHref": "/it/",
"production": { "outputPath": "dist/italian/",
"browserTarget": "cavallium-website:build:production" "i18nFile": "src/locale/messages.it.xlf",
} "i18nLocale": "it"
} },
}, "production_en": {
"extract-i18n": { "fileReplacements": [
"builder": "@angular-devkit/build-angular:extract-i18n", {
"options": { "replace": "src/environments/environment.ts",
"browserTarget": "cavallium-website:build" "with": "src/environments/environment.prod.ts"
} }
}, ],
"test": { "optimization": true,
"builder": "@angular-devkit/build-angular:karma", "outputHashing": "all",
"options": { "sourceMap": false,
"main": "src/test.ts", "extractCss": true,
"polyfills": "src/polyfills.ts", "namedChunks": false,
"tsConfig": "src/tsconfig.spec.json", "aot": true,
"karmaConfig": "src/karma.conf.js", "extractLicenses": true,
"styles": [ "vendorChunk": false,
"src/styles.scss" "buildOptimizer": true,
], "budgets": [
"scripts": [], {
"assets": [ "type": "initial",
"src/favicon.ico", "maximumWarning": "2mb",
"src/assets" "maximumError": "5mb"
] }
} ],
}, "outputPath": "dist/english/",
"lint": { "i18nFile": "src/locale/messages.en.xlf",
"builder": "@angular-devkit/build-angular:tslint", "i18nLocale": "en"
"options": { },
"tsConfig": [ "serve_en": {
"src/tsconfig.app.json", "aot": true,
"src/tsconfig.spec.json" "baseHref": "/en/",
], "outputPath": "dist/english/",
"exclude": [ "i18nFile": "src/locale/messages.en.xlf",
"**/node_modules/**" "i18nLocale": "en"
] }
} }
} },
} "serve": {
}, "builder": "@angular-devkit/build-angular:dev-server",
"cavallium-website-e2e": { "options": {
"root": "e2e/", "browserTarget": "cavallium-website:build"
"projectType": "application", },
"prefix": "", "configurations": {
"architect": { "production": {
"e2e": { "browserTarget": "cavallium-website:build:production"
"builder": "@angular-devkit/build-angular:protractor", },
"options": { "en": {
"protractorConfig": "e2e/protractor.conf.js", "browserTarget": "cavallium-website:build:serve_en",
"devServerTarget": "cavallium-website:serve" "port": 4201
}, },
"configurations": { "it": {
"production": { "browserTarget": "cavallium-website:build:serve_it",
"devServerTarget": "cavallium-website:serve:production" "port": 4200
} }
} }
}, },
"lint": { "extract-i18n": {
"builder": "@angular-devkit/build-angular:tslint", "builder": "@angular-devkit/build-angular:extract-i18n",
"options": { "options": {
"tsConfig": "e2e/tsconfig.e2e.json", "browserTarget": "cavallium-website:build"
"exclude": [ }
"**/node_modules/**" },
] "test": {
} "builder": "@angular-devkit/build-angular:karma",
} "options": {
} "main": "src/test.ts",
} "polyfills": "src/polyfills.ts",
}, "tsConfig": "src/tsconfig.spec.json",
"defaultProject": "cavallium-website" "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"
} }

73
build.js Normal file
View File

@ -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);
});
});
}

163
buildconfig.json Normal file
View File

@ -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"
}
}

View File

@ -4,8 +4,8 @@
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"postinstall": "ivy-ngcc", "postinstall": "ivy-ngcc",
"start": "ng serve", "start": "node build.js serve",
"build": "ng build", "build": "node build.js build",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e" "e2e": "ng e2e"
@ -17,6 +17,7 @@
"@angular/compiler": "~7.2.0", "@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0", "@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0", "@angular/forms": "~7.2.0",
"@angular/http": "~7.2.0",
"@angular/platform-browser": "~7.2.0", "@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0", "@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0", "@angular/router": "~7.2.0",

View File

@ -2,7 +2,8 @@
<div style="text-align:center"> <div style="text-align:center">
<h1> <h1>
Welcome to {{ title }}! Welcome to {{ title }}!
</h1> </h1>
<p>Welcome to</p>
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="> <img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
</div> </div>
<h2>Here are some links to help you start: </h2> <h2>Here are some links to help you start: </h2>

View File

@ -3,10 +3,16 @@ import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component'; 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({ @NgModule({
declarations: [ declarations: [
AppComponent AppComponent,
HomeComponent,
NavbarComponent,
FooterComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View File

@ -0,0 +1,3 @@
<p>
footer works!
</p>

View File

View File

@ -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<FooterComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FooterComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(FooterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -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() {
}
}

View File

@ -0,0 +1,3 @@
<p>
navbar works!
</p>

View File

View File

@ -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<NavbarComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NavbarComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NavbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -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() {
}
}

View File

@ -0,0 +1,3 @@
<p>
home works!
</p>

View File

View File

@ -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<HomeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomeComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -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() {
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="introductionHeader" datatype="html">
<source>Welcome to</source>
<target>Welcome to</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="introductionHeader" datatype="html">
<source>Welcome to</source>
<target>Benvenuto in</target>
</trans-unit>
</body>
</file>
</xliff>