Skip to content

Commit

Permalink
build: bump angular to 17 (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Nov 9, 2023
1 parent a7f394d commit efba9e6
Show file tree
Hide file tree
Showing 49 changed files with 347 additions and 304 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ jobs:
cmd: install

- name: run
run: |
yarn run test
cat ./coverage/lcov.info | ./node_modules/.bin/codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: yarn run test

- uses: codecov/codecov-action@v3
name: upload
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
files: ./coverage/cobertura-coverage.xml
fail_ci_if_error: true
verbose: true

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -61,11 +66,11 @@ jobs:
- name: build
run: |
node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --base-href /ngx-countdown/
cp ./dist/index.html ./dist/404.html
ls ./dist
cp ./dist/browser/index.html ./dist/browser/404.html
ls ./dist/browser
- name: deploy-to-gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
publish_dir: ./dist/browser
27 changes: 15 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
# Compiled output
/dist
/tmp
/out-tsc
/publish
/yarn.lock
/.angular/cache
/bazel-out

# dependencies
# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
/.idea
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
# System files
.DS_Store
Thumbs.db

/publish
/yarn.lock
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.16.1
18.12.0
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Simple, easy and performance countdown for angular

[![NPM version](https://img.shields.io/npm/v/ngx-countdown.svg)](https://www.npmjs.com/package/ngx-countdown)
[![Ci](https://github.com/cipchk/ngx-countdown/workflows/Ci/badge.svg)](https://github.com/cipchk/ngx-countdown/actions?query=workflow%3ACi)
[![codecov](https://codecov.io/github/cipchk/ngx-countdown/graph/badge.svg?token=SPQeYvppgH)](https://codecov.io/github/cipchk/ngx-countdown)

## Demo

Expand Down Expand Up @@ -34,7 +35,7 @@ export class AppModule { }
### 2、Template

```html
<countdown #cd [config]="config" (event)="handleEvent($event)"></countdown>
<countdown #cd [config]="config" (event)="handleEvent($event)" />
```

**Method**
Expand All @@ -54,6 +55,17 @@ export class AppModule { }
this.countdown.begin();
```

### Standalone

```ts
@Component({
template: `<countdown />`,
standalone: true,
imports: [CountdownComponent],
})
export class App
```

## API

### countdown
Expand Down
35 changes: 9 additions & 26 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
}
},
"root": "",
"sourceRoot": "src",
"sourceRoot": "",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
Expand All @@ -49,21 +49,12 @@
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
"sourceMap": true
}
},
"defaultConfiguration": "production"
Expand All @@ -72,27 +63,25 @@
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "ngx-countdown:build:production"
"buildTarget": "ngx-countdown:build:production"
},
"development": {
"browserTarget": "ngx-countdown:build:development"
"buildTarget": "ngx-countdown:build:development"
}
},
"defaultConfiguration": "development"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "lib/test.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"karmaConfig": "./karma.conf.js",
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"include": [
"../lib/test.ts",
"../lib/**/*.spec.ts"
"lib/**/*.spec.ts"
]
}
},
Expand All @@ -109,11 +98,5 @@
}
}
}
},
"defaultProject": "ngx-countdown",
"cli": {
"schematicCollections": [
"@angular-eslint/schematics"
]
}
}
101 changes: 51 additions & 50 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
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
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true,
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox'],
},
}
});
};
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
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
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' },
{ type: 'cobertura' },
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true,
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox'],
},
}
});
};
2 changes: 1 addition & 1 deletion lib/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"dest": "../publish",
"deleteDestPath": true,
"lib": {
"entryFile": "src/public_api.ts"
"entryFile": "src/public-api.ts"
}
}
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-countdown",
"version": "16.0.0",
"version": "17.0.0",
"description": "Simple, easy and performance countdown for angular",
"keywords": [
"ngx-countdown",
Expand Down
25 changes: 25 additions & 0 deletions lib/spec/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ describe('Component: ngx-countdown', () => {
expect(context.comp.i.text).toBe(`0`);
tick(2000);
}));
it('Support fractional seconds', fakeAsync(() => {
context.config = { leftTime: 2, format: 'S' };
fixture.detectChanges();
tick(250);
fixture.detectChanges();
expect(context.comp.i.value).toBeGreaterThan(1001);
tick(2000);
}));
it('Pretty text', fakeAsync(() => {
context.config = { leftTime: 2, prettyText: jasmine.createSpy() };
fixture.detectChanges();
tick(250);
fixture.detectChanges();
expect(context.config.prettyText).toHaveBeenCalled();
tick(2000);
}));
describe('#stopTime', () => {
it('should be working', fakeAsync(() => {
context.config = { stopTime: new Date().getTime() + 1000 * 2 };
fixture.detectChanges();
tick(1001);
expect(context.comp.left).toBe(1000);
tick(3000);
}));
});
});

describe('[actions]', () => {
Expand Down
Loading

0 comments on commit efba9e6

Please sign in to comment.