Skip to content

Commit

Permalink
build: bump angualr 17
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Nov 1, 2023
1 parent 93d8ff9 commit 63d4259
Show file tree
Hide file tree
Showing 21 changed files with 2,755 additions and 2,411 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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,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
31 changes: 7 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,24 @@
"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",
"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 +97,5 @@
}
}
}
},
"cli": {
"schematicCollections": [
"@angular-eslint/schematics"
]
}
}
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.

57 changes: 28 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,47 @@
},
"homepage": "https://github.com/cipchk/ngx-filesaver#readme",
"scripts": {
"analyze": "ng b --stats-json --source-map",
"lint": "ng lint",
"test": "ng t --no-progress --browsers=ChromeHeadlessCI --code-coverage --no-watch",
"test": "ng t --no-progress --code-coverage --no-watch --browsers=ChromeHeadless",
"build": "node scripts/build.js",
"release:next": "npm run build && cd publish && npm publish --access public --tag next",
"release": "npm run build && cd publish && npm publish --access public"
"release": "npm run build && cd publish && npm publish --access public",
"release:next": "npm run build && cd publish && npm publish --access public --tag next"
},
"dependencies": {
"@angular/animations": "^16.0.0",
"@angular/common": "^16.0.0",
"@angular/compiler": "^16.0.0",
"@angular/core": "^16.0.0",
"@angular/forms": "^16.0.0",
"@angular/platform-browser": "^16.0.0",
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"@angular/animations": "^17.0.0-next.0",
"@angular/common": "^17.0.0-next.0",
"@angular/compiler": "^17.0.0-next.0",
"@angular/core": "^17.0.0-next.0",
"@angular/forms": "^17.0.0-next.0",
"@angular/platform-browser": "^17.0.0-next.0",
"@angular/platform-browser-dynamic": "^17.0.0-next.0",
"@angular/router": "^17.0.0-next.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
"zone.js": "~0.14.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.0.3",
"@angular/cli": "~16.0.3",
"@angular/compiler-cli": "^16.0.0",
"@types/jasmine": "~4.3.0",
"jasmine-core": "~4.6.0",
"@angular-devkit/build-angular": "^17.0.0-rc.2",
"@angular/cli": "^17.0.0-rc.2",
"@angular/compiler-cli": "^17.0.0-next.0",
"@types/jasmine": "~5.1.0",
"jasmine-core": "~5.1.0",
"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.0.0",
"typescript": "~5.0.2",
"@angular-eslint/builder": "^16.0.3",
"@angular-eslint/eslint-plugin": "^16.0.3",
"@angular-eslint/eslint-plugin-template": "^16.0.3",
"@angular-eslint/schematics": "^16.0.3",
"@angular-eslint/template-parser": "^16.0.3",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.2.2",
"@angular-eslint/builder": "^16.2.0",
"@angular-eslint/eslint-plugin": "^16.2.0",
"@angular-eslint/eslint-plugin-template": "^16.2.0",
"@angular-eslint/schematics": "^16.2.0",
"@angular-eslint/template-parser": "^16.2.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"codecov": "^3.8.3",
"eslint": "^8.42.0",
"ng-packagr": "^16.0.1",
"eslint": "^8.52.0",
"ng-packagr": "^17.0.0-rc.1",
"@types/file-saver": "^2.0.5",
"file-saver": "^2.0.5"
}
Expand Down
3 changes: 0 additions & 3 deletions src/environments/environment.prod.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/environments/environment.ts

This file was deleted.

7 changes: 4 additions & 3 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
</head>

<body>
<a href="//github.com/cipchk/ngx-filesaver"
><img
<a href="//github.com/cipchk/ngx-filesaver">
<img
style="position: absolute; top: 0; right: 0; border: 0"
src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"
/></a>
/>
</a>
<div class="container-fluid"><app-root>Loading...</app-root></div>
</body>
</html>
12 changes: 4 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';

import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { provideHttpClient } from '@angular/common/http';

if (environment.production) {
enableProdMode();
}

bootstrapApplication(AppComponent).catch((err) => console.error(err));
bootstrapApplication(AppComponent, {
providers: [provideHttpClient()],
}).catch((err) => console.error(err));
Loading

0 comments on commit 63d4259

Please sign in to comment.