First commit
This commit is contained in:
parent
ddde9315ca
commit
47381c696b
60
angular.json
60
angular.json
@ -30,10 +30,12 @@
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": [],
|
||||
"es5BrowserSupport": true
|
||||
"es5BrowserSupport": true,
|
||||
"i18nFormat": "xlf",
|
||||
"i18nMissingTranslation": "error"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"production_it": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
@ -55,7 +57,51 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -67,6 +113,14 @@
|
||||
"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
|
||||
}
|
||||
}
|
||||
},
|
||||
|
73
build.js
Normal file
73
build.js
Normal 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
163
buildconfig.json
Normal 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"
|
||||
}
|
||||
}
|
@ -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",
|
||||
|
@ -3,6 +3,7 @@
|
||||
<h1>
|
||||
Welcome to {{ title }}!
|
||||
</h1>
|
||||
<p>Welcome to</p>
|
||||
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
|
||||
</div>
|
||||
<h2>Here are some links to help you start: </h2>
|
||||
|
@ -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,
|
||||
|
3
src/app/gui/footer/footer.component.html
Normal file
3
src/app/gui/footer/footer.component.html
Normal file
@ -0,0 +1,3 @@
|
||||
<p>
|
||||
footer works!
|
||||
</p>
|
0
src/app/gui/footer/footer.component.scss
Normal file
0
src/app/gui/footer/footer.component.scss
Normal file
25
src/app/gui/footer/footer.component.spec.ts
Normal file
25
src/app/gui/footer/footer.component.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
15
src/app/gui/footer/footer.component.ts
Normal file
15
src/app/gui/footer/footer.component.ts
Normal 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() {
|
||||
}
|
||||
|
||||
}
|
3
src/app/gui/navbar/navbar.component.html
Normal file
3
src/app/gui/navbar/navbar.component.html
Normal file
@ -0,0 +1,3 @@
|
||||
<p>
|
||||
navbar works!
|
||||
</p>
|
0
src/app/gui/navbar/navbar.component.scss
Normal file
0
src/app/gui/navbar/navbar.component.scss
Normal file
25
src/app/gui/navbar/navbar.component.spec.ts
Normal file
25
src/app/gui/navbar/navbar.component.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
15
src/app/gui/navbar/navbar.component.ts
Normal file
15
src/app/gui/navbar/navbar.component.ts
Normal 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() {
|
||||
}
|
||||
|
||||
}
|
3
src/app/pages/home/home.component.html
Normal file
3
src/app/pages/home/home.component.html
Normal file
@ -0,0 +1,3 @@
|
||||
<p>
|
||||
home works!
|
||||
</p>
|
0
src/app/pages/home/home.component.scss
Normal file
0
src/app/pages/home/home.component.scss
Normal file
25
src/app/pages/home/home.component.spec.ts
Normal file
25
src/app/pages/home/home.component.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
15
src/app/pages/home/home.component.ts
Normal file
15
src/app/pages/home/home.component.ts
Normal 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() {
|
||||
}
|
||||
|
||||
}
|
11
src/locale/messages.en.xlf
Normal file
11
src/locale/messages.en.xlf
Normal 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>
|
11
src/locale/messages.it.xlf
Normal file
11
src/locale/messages.it.xlf
Normal 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>
|
Loading…
Reference in New Issue
Block a user