Skip to content

Commit 6415be1

Browse files
committed
ADD new angular example
1 parent 35fa171 commit 6415be1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1429
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
env: LABEL=docs
8080

8181
- stage: examples
82-
script: npm run build && (cd ./examples/angular2 && npm install > "/dev/null" 2>&1 && npm run build && travis_retry npm run test:build)
82+
script: npm run build && (cd ./examples/angular && npm install > "/dev/null" 2>&1 && npm run lint && npm run build && travis_retry npm run test:build)
8383
env: LABEL=angular
8484
- stage: examples
8585
script: npm run build && (cd ./examples/vue && npm install > "/dev/null" 2>&1 && npm run lint && npm run build && travis_retry npm run test)

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ electron | [done](./electron)
1919
Framework | Status
2020
---------------- | ------------------
2121
plain javascript | [done](./vanilla)
22-
angular2 | [done](./angular2)
22+
angular | [done](./angular)
2323
react | [done](./react)
2424
vuejs | [done](./vue)

examples/angular/.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events*.json
15+
speed-measure-plugin*.json
16+
17+
# IDEs and editors
18+
/.idea
19+
.project
20+
.classpath
21+
.c9/
22+
*.launch
23+
.settings/
24+
*.sublime-workspace
25+
26+
# IDE - VSCode
27+
.vscode/*
28+
!.vscode/settings.json
29+
!.vscode/tasks.json
30+
!.vscode/launch.json
31+
!.vscode/extensions.json
32+
.history/*
33+
34+
# misc
35+
/.sass-cache
36+
/connect.lock
37+
/coverage
38+
/libpeerconnection.log
39+
npm-debug.log
40+
yarn-error.log
41+
testem.log
42+
/typings
43+
44+
# System Files
45+
.DS_Store
46+
Thumbs.db
47+
48+
# own
49+
/rxdb-local.tgz
50+
/config.json

examples/angular/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

examples/angular/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# RxDB Angular2 example
2+
3+
This is an example usage of RxDB with Angular2. It implements a simple heroes-list which can be filled by the user.
4+
5+
# Try it out
6+
1. clone the whole [RxDB-repo](https://github.com/pubkey/rxdb)
7+
2. go into project `cd rxdb`
8+
3. run `npm install`
9+
4. go to this folder `cd examples/angular2`
10+
5. run `npm install`
11+
6. run `npm start`
12+
7. Open [http://127.0.0.1:4200/](http://127.0.0.1:4200/) **IMPORTANT: do not use localhost**
13+
14+
15+
# Screenshot
16+
17+
![angular2](docfiles/angular2.gif)

examples/angular/angular.json

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"angular": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:component": {
10+
"style": "less"
11+
}
12+
},
13+
"root": "",
14+
"sourceRoot": "src",
15+
"prefix": "app",
16+
"architect": {
17+
"build": {
18+
"builder": "@angular-devkit/build-angular:browser",
19+
"options": {
20+
"outputPath": "dist/angular",
21+
"index": "src/index.html",
22+
"main": "src/main.ts",
23+
"polyfills": "src/polyfills.ts",
24+
"tsConfig": "tsconfig.app.json",
25+
"aot": false,
26+
"assets": [
27+
"src/favicon.ico",
28+
"src/assets",
29+
"src/manifest.webmanifest"
30+
],
31+
"styles": [
32+
"src/styles.less"
33+
],
34+
"scripts": []
35+
},
36+
"configurations": {
37+
"production": {
38+
"fileReplacements": [
39+
{
40+
"replace": "src/environments/environment.ts",
41+
"with": "src/environments/environment.prod.ts"
42+
}
43+
],
44+
"optimization": true,
45+
"outputHashing": "all",
46+
"sourceMap": false,
47+
"extractCss": true,
48+
"namedChunks": false,
49+
"aot": true,
50+
"extractLicenses": true,
51+
"vendorChunk": false,
52+
"buildOptimizer": true,
53+
"budgets": [
54+
{
55+
"type": "initial",
56+
"maximumWarning": "2mb",
57+
"maximumError": "5mb"
58+
},
59+
{
60+
"type": "anyComponentStyle",
61+
"maximumWarning": "6kb",
62+
"maximumError": "10kb"
63+
}
64+
],
65+
"serviceWorker": true,
66+
"ngswConfigPath": "ngsw-config.json"
67+
}
68+
}
69+
},
70+
"serve": {
71+
"builder": "@angular-devkit/build-angular:dev-server",
72+
"options": {
73+
"browserTarget": "angular:build"
74+
},
75+
"configurations": {
76+
"production": {
77+
"browserTarget": "angular:build:production"
78+
}
79+
}
80+
},
81+
"extract-i18n": {
82+
"builder": "@angular-devkit/build-angular:extract-i18n",
83+
"options": {
84+
"browserTarget": "angular:build"
85+
}
86+
}
87+
}
88+
}},
89+
"defaultProject": "angular"
90+
}

examples/angular/browserslist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# You can see what browsers were selected by your queries by running:
6+
# npx browserslist
7+
8+
> 0.5%
9+
last 2 versions
10+
Firefox ESR
11+
not dead
12+
not IE 9-11 # For IE 9-11 support, remove 'not'.

examples/angular/ngsw-config.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
3+
"index": "/index.html",
4+
"assetGroups": [
5+
{
6+
"name": "app",
7+
"installMode": "prefetch",
8+
"resources": {
9+
"files": [
10+
"/favicon.ico",
11+
"/index.html",
12+
"/manifest.webmanifest",
13+
"/*.css",
14+
"/*.js"
15+
]
16+
}
17+
}, {
18+
"name": "assets",
19+
"installMode": "lazy",
20+
"updateMode": "prefetch",
21+
"resources": {
22+
"files": [
23+
"/assets/**",
24+
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
25+
]
26+
}
27+
}
28+
]
29+
}

examples/angular/package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "angular",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"preinstall": "npm run preinstall:rxdb && npm run preinstall:versions",
6+
"preinstall:rxdb": "(cd ../../ && npx [email protected] pack ../../ --filename ./examples/angular/rxdb-local.tgz)",
7+
"preinstall:versions": "node ./scripts/ensure-equal-versions.js",
8+
"start": "concurrently \"npm run server\" \"npm run dev\"",
9+
"server": "pouchdb-server --host 0.0.0.0 -p 10101 -m -d /tmp/pouchdb-server/ -n true",
10+
"server:show": "node server.js",
11+
"ng": "ng",
12+
"dev": "ng serve",
13+
"build": "ng build --prod --aot && npm run build:copy && echo \"BUILD SUCCESS\"",
14+
"build:serve": "ws -p 8888 -d dist/angular/",
15+
"build:serve9000": "ws -p 9000 -d dist/angular/",
16+
"build:copy": "cp test/multitab.html dist/angular/multitab.html",
17+
"test": "testcafe chrome test/ --selector-timeout 30000",
18+
"test:build": "concurrently \"npm run build:serve\" \"npm run test\" --kill-others --success first",
19+
"lint": "tslint app/src/**/*.ts"
20+
},
21+
"private": true,
22+
"author": "pubkey",
23+
"license": "MIT",
24+
"dependencies": {
25+
"@angular/animations": "8.2.12",
26+
"@angular/cdk": "8.2.3",
27+
"@angular/common": "8.2.12",
28+
"@angular/compiler": "8.2.12",
29+
"@angular/core": "8.2.12",
30+
"@angular/forms": "8.2.12",
31+
"@angular/material": "8.2.3",
32+
"@angular/platform-browser": "8.2.12",
33+
"@angular/platform-browser-dynamic": "8.2.12",
34+
"@angular/pwa": "0.803.14",
35+
"@angular/router": "8.2.12",
36+
"@angular/service-worker": "8.2.12",
37+
"font-awesome": "4.7.0",
38+
"pouchdb-adapter-http": "7.1.1",
39+
"pouchdb-adapter-idb": "7.1.1",
40+
"roboto-npm-webfont": "1.0.1",
41+
"rxdb": "file:rxdb-local.tgz",
42+
"rxjs": "6.4.0",
43+
"tslib": "1.10.0",
44+
"zone.js": "0.10.2"
45+
},
46+
"devDependencies": {
47+
"@angular-devkit/build-angular": "0.803.14",
48+
"@angular/cli": "8.3.14",
49+
"@angular/compiler-cli": "8.2.12",
50+
"@angular/language-service": "8.2.12",
51+
"@types/node": "12.11.7",
52+
"async-test-util": "^1.7.3",
53+
"concurrently": "^5.0.0",
54+
"pouchdb-server": "^4.2.0",
55+
"testcafe": "^1.6.0",
56+
"ts-node": "7.0.0",
57+
"tslint": "5.20.0",
58+
"typescript": "3.5.3"
59+
}
60+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @preinstall
3+
* this script ensures all pouchdb-dependencies
4+
* have the same version as pouchdb ins the root-folder
5+
*/
6+
const fs = require('fs');
7+
const path = require('path');
8+
const parentPackage = require('../../../package.json');
9+
const pouchVersion = parentPackage.dependencies['pouchdb-core'];
10+
const ownPath = path.join(__dirname, '../package.json');
11+
const ownPackage = require(ownPath);
12+
console.log('pouchdb version: ' + pouchVersion);
13+
Object.keys(ownPackage.dependencies)
14+
.filter(dep => dep.startsWith('pouchdb-adapter-'))
15+
.forEach(dep => {
16+
ownPackage.dependencies[dep] = pouchVersion;
17+
});
18+
const newJson = JSON.stringify(ownPackage, null, 2);
19+
fs.writeFileSync(ownPath, newJson, {
20+
encoding: 'utf8',
21+
flag: 'w'
22+
});
23+
console.log('ensure-equal-version.js: done');

0 commit comments

Comments
 (0)