Skip to content

Commit

Permalink
build: bump angualr 17 (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Nov 9, 2023
1 parent 93d8ff9 commit 1d77ac7
Show file tree
Hide file tree
Showing 27 changed files with 2,881 additions and 2,615 deletions.
6 changes: 2 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
],
"parserOptions": {
"project": [
"tsconfig.json"
"tsconfig.json",
"e2e/tsconfig.json"
],
"createDefaultProgram": true
},
Expand All @@ -37,9 +38,6 @@
],
"@angular-eslint/no-host-metadata-property": [
"off"
],
"@angular-eslint/no-output-native": [
"off"
]
}
},
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ jobs:
uses: actions/checkout@master

- uses: borales/actions-yarn@v4
name: install
with:
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 @@ -60,12 +66,12 @@ jobs:

- name: build
run: |
node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --base-href /ngx-filesaver/
cp ./dist/index.html ./dist/404.html
ls ./dist
node ./node_modules/@angular/cli/bin/ng build --base-href /ngx-filesaver/
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
/package-lock.json
/.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 .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ make.js
protractor.conf.js
test-main.js
tsconfig.json
tslint.json
typedoc.json
typings.json
webpack.config.js
*.yml
.jshintrc
.editorconfig
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Simple file save with FileSaver.js

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

[中文版](README.zh-CN.md)

Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Simple file save with FileSaver.js

[![NPM version](https://img.shields.io/npm/v/ngx-filesaver.svg)](https://www.npmjs.com/package/ngx-filesaver)
![Ci](https://github.com/cipchk/ngx-filesaver/workflows/Ci/badge.svg)
[![codecov](https://codecov.io/gh/cipchk/ngx-filesaver/graph/badge.svg?token=vnk2alNB8D)](https://codecov.io/gh/cipchk/ngx-filesaver)

## 示例

Expand Down
32 changes: 8 additions & 24 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-filesaver:build:production"
"buildTarget": "ngx-filesaver:build:production"
},
"development": {
"browserTarget": "ngx-filesaver:build:development"
"buildTarget": "ngx-filesaver:build:development"
}
},
"defaultConfiguration": "development"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "lib/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"include": [
"../lib/test.ts",
"../lib/**/*.spec.ts"
"lib/**/*.spec.ts"
]
}
},
Expand All @@ -109,10 +98,5 @@
}
}
}
},
"cli": {
"schematicCollections": [
"@angular-eslint/schematics"
]
}
}
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ module.exports = function (config) {
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
{ type: 'text-summary' },
{ type: 'cobertura' },
]
},
reporters: ['progress', 'kjhtml'],
Expand Down
4 changes: 1 addition & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export * from './src/filesaver.service';
export * from './src/filesaver.directive';
export * from './src/filesaver.module';
export * from './public-api';
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": "index.ts"
"entryFile": "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-filesaver",
"version": "16.0.0",
"version": "17.0.0",
"description": "Simple file save with FileSaver.js",
"keywords": [
"angular",
Expand Down
3 changes: 3 additions & 0 deletions lib/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './src/filesaver.service';
export * from './src/filesaver.directive';
export * from './src/filesaver.module';
43 changes: 43 additions & 0 deletions lib/spec/filesaver.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { TestBed } from '@angular/core/testing';
import * as fs from 'file-saver';
import { FileSaverService } from '../src/filesaver.service';

describe('ngx-filesaver:', () => {
let srv: FileSaverService;

beforeEach(() => {
srv = TestBed.inject(FileSaverService);
});

it('#genType', () => {
[
{ name: null, ret: 'text/plain' },
{ name: '1.txt', ret: 'text/plain' },
{ name: '1.xml', ret: 'text/xml' },
{ name: '1.html', ret: 'text/html' },
{ name: '1.json', ret: 'octet/stream' },
{ name: '1.apk', ret: 'application/apk' },
].forEach(({ name, ret }) => {
expect(srv.genType(name)).toBe(ret);
});
});

describe('#save', () => {
it('should be error when is ', () => {
expect(() => srv.save(null)).toThrowError('Data argument should be a blob instance');
});

it('should be use default filename: download', () => {
const blob = new Blob();
const spy = spyOn(fs, 'saveAs');
srv.save(blob);
expect(spy.calls.first().args[1] as string).toBe('download');
});
});

it('#saveText', () => {
const spy = spyOn(fs, 'saveAs');
srv.saveText('a');
expect((spy.calls.first().args[0] as Blob).size).toBe(1);
});
});
1 change: 1 addition & 0 deletions lib/src/filesaver.directive.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @angular-eslint/no-output-native */
import { Directive, ElementRef, Input, EventEmitter, Output, NgZone, OnDestroy, OnInit } from '@angular/core';
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
import { filter, fromEvent, Observable, Subject, takeUntil } from 'rxjs';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/filesaver.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class FileSaverService {
return isFileSaverSupported;
}

genType(fileName?: string): string {
genType(fileName?: string | null): string {
if (!fileName || fileName.lastIndexOf('.') === -1) {
return 'text/plain';
}
Expand Down
4 changes: 0 additions & 4 deletions lib/test.ts

This file was deleted.

5 changes: 2 additions & 3 deletions lib/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"alwaysStrict": true,
"inlineSources": true,
"strictFunctionTypes": true,
"stripInternal": true
"stripInternal": true,
"declarationMap": false
},
"files": ["./src/filesaver.module.ts"],
"include": ["**/*.ts"],
"angularCompilerOptions": {
"enableIvy": true,
"compilationMode": "partial"
}
}
Loading

0 comments on commit 1d77ac7

Please sign in to comment.