Skip to content

feat: Upgrade Angular from v5 to v19 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions .angular-cli.json

This file was deleted.

105 changes: 105 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular4-services": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/angular4-services",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"src/polyfills.ts"
],
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "angular4-services:build:production"
},
"development": {
"buildTarget": "angular4-services:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "angular4-services:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"src/polyfills.ts"
],
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
}
}
}
}
},
"cli": {
"analytics": false
}
}
9 changes: 4 additions & 5 deletions e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
},
"include": [
"**/*.ts"
]
}
45 changes: 32 additions & 13 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
// https://karma-runner.github.io/latest/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
frameworks: ['jasmine', '@angular-devkit/build-angular'], // Updated framework plugin name
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
require('karma-coverage'), // Updated from karma-coverage-istanbul-reporter
require('@angular-devkit/build-angular/plugins/karma') // Updated plugin name
],
client:{
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
angularCli: {
environment: 'dev'
coverageReporter: { // Updated reporter name and config
dir: require('path').join(__dirname, './coverage/angular4-services'), // Adjusted path
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' },
{ type: 'lcovonly' } // Added lcovonly for better integration
],
check: { // Optional coverage thresholds
global: {
statements: 80,
branches: 80,
functions: 80,
lines: 80
}
}
},
reporters: ['progress', 'kjhtml'],
reporters: ['progress', 'kjhtml', 'coverage'], // Added coverage reporter
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
browsers: ['ChromeHeadless'], // Changed to ChromeHeadless for potential CI use
singleRun: false // Keep false for local dev, set true for CI
});
};
55 changes: 26 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,35 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.0",
"@angular/animations": "~19.2.8",
"@angular/common": "~19.2.8",
"@angular/compiler": "~19.2.8",
"@angular/core": "~19.2.8",
"@angular/forms": "~19.2.8",
"@angular/platform-browser": "~19.2.8",
"@angular/platform-browser-dynamic": "~19.2.8",
"@angular/router": "~19.2.8",
"@ng-bootstrap/ng-bootstrap": "^18.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
"rxjs": "^7.8.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular/cli": "1.6.7",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"@angular-devkit/build-angular": "~19.2.8",
"@angular/cli": "~19.2.8",
"@angular/compiler-cli": "~19.2.8",
"@angular/language-service": "~19.2.8",
"@types/jasmine": "~5.1.0",
"@types/node": "~18.18.0",
"jasmine-core": "~5.1.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "^2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.1.0",
"protractor": "~7.0.0",
"ts-node": "~10.9.0",
"typescript": "~5.7.5"
}
}
9 changes: 6 additions & 3 deletions protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
'./e2e/**/*.e2e-spec.ts' // Confirmed path based on project structure
],
capabilities: {
'browserName': 'chrome'
browserName: 'chrome', // Keep 'chrome'
chromeOptions: { // Add chromeOptions for headless execution if needed
args: ["--headless", "--disable-gpu", "--window-size=800,600"]
}
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
Expand All @@ -21,7 +24,7 @@ exports.config = {
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
project: require('path').join(__dirname, './e2e/tsconfig.e2e.json') // Use path.join for robustness
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
Expand Down
45 changes: 26 additions & 19 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
import { TestBed, async } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing'; // Removed async
import { AppComponent } from './app.component';
import { ServiceService } from './service.service'; // Import ServiceService
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; // Import NgbModule
import { FormsModule } from '@angular/forms'; // Import FormsModule

describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
beforeEach(async () => { // Use async/await
// Mock ServiceService or provide the real one
// Mock NgbModal or import NgbModule
await TestBed.configureTestingModule({ // Use await
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', async(() => {
imports: [
NgbModule, // Import NgbModule for NgbModal
FormsModule // Import FormsModule
],
providers: [
ServiceService // Provide ServiceService
// Alternatively, use a mock: { provide: ServiceService, useValue: mockServiceService }
// Alternatively, use a mock: { provide: NgbModal, useValue: mockNgbModal }
]
}).compileComponents(); // Keep compileComponents for safety with templateUrl/styleUrls
});

it('should create the app', () => { // Removed async wrapper
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const app = fixture.componentInstance; // Use componentInstance directly
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
});

// Removed the incorrect tests for 'title' property and 'h1' content
});
Loading