Skip to content
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

feat: Angular 12, combine all providers, drop ui-router #430

Merged
merged 6 commits into from
Oct 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major version
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 9-11 # For IE 9-11 support, remove 'not'.
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
28 changes: 28 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"root": true,
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["tsconfig.json"],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/directive-selector": "off",
"@angular-eslint/directive-class-suffix": "off",
"@angular-eslint/component-selector": "off",
"@angular-eslint/component-class-suffix": "off"
}
},
{
"files": ["*.html"],
"extends": ["plugin:@angular-eslint/template/recommended"],
"rules": {}
}
]
}
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: CI

on: [push, pull_request]

on:
- push
- pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: setup node
uses: actions/setup-node@v2
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
cache: 'yarn'
Expand Down
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"printWidth": 100,
"arrowParens": "avoid"
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020 angulartics
Copyright (c) 2021 angulartics

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ Latest version available for each version of Angular

| Angulartics2 | Angular |
| ------------ | --------- |
| 5.4.0 | 4.x |
| 6.3.1 | 5.x |
| 7.5.2 | 6.x - 7.x |
| 8.3.0 | 8.x |
| 9.1.0 | 9.x |
| latest | 10.x |
| 10.1.0 | 10.x |
| latest | 12.x |

## Installation

Expand All @@ -54,7 +52,7 @@ import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes } from '@angular/router';

import { Angulartics2Module } from 'angulartics2';
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
import { Angulartics2GoogleAnalytics } from 'angulartics2';

const ROUTES: Routes = [
{ path: '', component: HomeComponent },
Expand All @@ -78,7 +76,7 @@ const ROUTES: Routes = [
2. __Required__: Import your providers in the root component. Call `startTracking()` to start the tracking of route changes.
```ts
// component
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
import { Angulartics2GoogleAnalytics } from 'angulartics2';

@Component({ ... })
export class AppComponent {
Expand Down Expand Up @@ -231,7 +229,7 @@ Angulartics2Module.forRoot({
__Warning:__ this support is still experiemental
`@angular/router` must still be installed! However, it will not be used.
````ts
import { Angulartics2RouterlessModule } from 'angulartics2/routerlessmodule';
import { Angulartics2RouterlessModule } from 'angulartics2';
@NgModule({
// ...
imports: [
Expand All @@ -246,7 +244,7 @@ import { Angulartics2RouterlessModule } from 'angulartics2/routerlessmodule';
__Warning:__ this support is still experiemental
`@angular/router` must still be installed! However, it will not be used.
````ts
import { Angulartics2UirouterModule } from 'angulartics2/uiroutermodule';
import { Angulartics2UirouterModule } from 'angulartics2';
@NgModule({
// ...
imports: [
Expand Down
66 changes: 33 additions & 33 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"angulartics2": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
},
"@schematics/angular:application": {
"strict": true
}
Expand All @@ -25,7 +22,6 @@
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
Expand All @@ -37,20 +33,6 @@
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
Expand All @@ -62,20 +44,37 @@
"maximumWarning": "2kb",
"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
}
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "angulartics2:build"
},
"configurations": {
"production": {
"browserTarget": "angulartics2:build:production"
},
"development": {
"browserTarget": "angulartics2:build:development"
}
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
Expand All @@ -101,18 +100,19 @@
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
}
}
}
}},
"defaultProject": "angulartics2"
}
},
"defaultProject": "angulartics2",
"cli": {
"defaultCollection": "@angular-eslint/schematics"
}
}
55 changes: 1 addition & 54 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,15 @@ import { ngPackagr } from 'ng-packagr';
import { join } from 'path';
import * as del from 'del';

const CORE_MODULE_NAMES = ['uiroutermodule', 'routerlessmodule'];

// Rollup globals
const MODULE_NAMES = [
'adobeanalytics',
'appinsights',
'baidu',
'facebook',
'ga',
'ga-enhanced-ecom',
'gtm',
'gst',
'hubspot',
'kissmetrics',
'launch',
'mixpanel',
'pyze',
'matomo',
'segment',
'intercom',
'woopra',
'clicky',
'amplitude',
'splunk',
'ibm-digital-analytics',
'gosquared',
];


async function main() {
// cleanup dist
del.sync(join(process.cwd(), '/dist'));
del.sync(join(process.cwd(), '/node_modules/angulartics2'));

await ngPackagr()
.forProject(join(process.cwd(), 'src/lib/core/package.json'))
.forProject(join(process.cwd(), 'src/lib/package.json'))
.build();

// put it in node modules so the path resolves
// proper path support eventually
copySync(
join(process.cwd(), '/dist/core'),
join(process.cwd(), '/node_modules/angulartics2'),
);
copySync(
join(process.cwd(), '/dist/core'),
join(process.cwd(), '/dist/packages-dist'),
);

for (const m of CORE_MODULE_NAMES) {
await ngPackagr()
.forProject(join(process.cwd(), `src/lib/${m}/package.json`))
.build();
}

// build each provider
for (const m of MODULE_NAMES) {
await ngPackagr()
.forProject(join(process.cwd(), `src/lib/providers/${m}/package.json`))
.build();
}

copySync('README.md', join(process.cwd(), 'dist/packages-dist/README.md'));
copySync('LICENSE', join(process.cwd(), 'dist/packages-dist/LICENSE'));
}
Expand Down
26 changes: 13 additions & 13 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@

module.exports = function (config) {
config.set({
basePath: "",
frameworks: ["jasmine", "@angular-devkit/build-angular"],
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require("karma-jasmine"),
require("karma-chrome-launcher"),
require("karma-jasmine-html-reporter"),
require("karma-coverage-istanbul-reporter"),
require("@angular-devkit/build-angular/plugins/karma"),
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require("path").join(__dirname, "./coverage/zzz"),
reports: ["html", "lcovonly", "text-summary"],
dir: require('path').join(__dirname, './coverage/zzz'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true,
},
reporters: ["progress", "kjhtml"],
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ["Chrome"],
browsers: ['Chrome'],
customLaunchers: {
ChromeCI: {
base: "ChromeHeadless",
flags: ["--no-sandbox", "--disable-gpu"],
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--disable-gpu'],
},
},
singleRun: false,
Expand Down