Skip to content

Commit 1a836e7

Browse files
committed
feat(lib): added src files of the lib
1 parent bded5a3 commit 1a836e7

17 files changed

+398
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Algolia
2+
3+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.2.
4+
5+
## Code scaffolding
6+
7+
Run `ng generate component component-name --project algolia` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project algolia`.
8+
> Note: Don't forget to add `--project algolia` or else it will be added to the default project in your `angular.json` file.
9+
10+
## Build
11+
12+
Run `ng build algolia` to build the project. The build artifacts will be stored in the `dist/` directory.
13+
14+
## Publishing
15+
16+
After building your library with `ng build algolia`, go to the dist folder `cd dist/algolia` and run `npm publish`.
17+
18+
## Running unit tests
19+
20+
Run `ng test algolia` to execute the unit tests via [Karma](https://karma-runner.github.io).
21+
22+
## Further help
23+
24+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage-istanbul-reporter'),
13+
require('@angular-devkit/build-angular/plugins/karma')
14+
],
15+
client: {
16+
clearContext: false // leave Jasmine Spec Runner output visible in browser
17+
},
18+
coverageIstanbulReporter: {
19+
dir: require('path').join(__dirname, '../../../coverage/angular-material-extensions/algolia'),
20+
reports: ['html', 'lcovonly', 'text-summary'],
21+
fixWebpackSourcePaths: true
22+
},
23+
reporters: ['progress', 'kjhtml'],
24+
port: 9876,
25+
colors: true,
26+
logLevel: config.LOG_INFO,
27+
autoWatch: true,
28+
browsers: ['Chrome'],
29+
singleRun: false,
30+
restartOnFileChange: true
31+
});
32+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../../dist/angular-material-extensions/algolia",
4+
"lib": {
5+
"entryFile": "src/public-api.ts"
6+
}
7+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"name": "@angular-material-extensions/algolia",
3+
"description": "Angular Library that enhanced algolia instant search library - Material UI component and general services and directives",
4+
"version": "0.0.1",
5+
"homepage": "https://angular-material-extensions.github.io/algolia",
6+
"author": {
7+
"name": "anthonynahas",
8+
"url": "https://github.com/anthonynahas"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/angular-material-extensions/algolia.git"
13+
},
14+
"license": "MIT",
15+
"schematics": "./schematics/collection.json",
16+
"keywords": [
17+
"ng",
18+
"library",
19+
"angular",
20+
"material",
21+
"material design",
22+
"ssr",
23+
"select country",
24+
"countries",
25+
"nationality",
26+
"languages"
27+
],
28+
"bugs": {
29+
"url": "https://github.com/angular-material-extensions/algolia/issues"
30+
},
31+
"scripts": {
32+
"build": "../../../node_modules/.bin/ng build @angular-material-extensions/algolia --prod",
33+
"build:schematics": "../../../node_modules/.bin/tsc -p tsconfig.schematics.json",
34+
"clean": "rm -rf ../../../dist",
35+
"lint": "../../../node_modules/.bin/ng lint @angular-material-extensions/algolia",
36+
"resync:schematics": "rsync -a schematics/collection.json ../../../dist/angular-material-extensions/algolia/schematics/",
37+
"resync:readme": "rsync -a ../../../README.md ../../../dist/angular-material-extensions/algolia/",
38+
"postbuild": "npm run build:schematics && npm run resync:readme && npm run resync:schematics",
39+
"prepublish": "npm run build",
40+
"release:patch": "../../../node_modules/.bin/release-it --patch --ci ",
41+
"release:minor": "../../../node_modules/.bin/release-it --minor --ci",
42+
"release:major": "../../../node_modules/.bin/release-it --major --ci --no-git.requireCleanWorkingDir",
43+
"release:version": "../../../node_modules/.bin/release-it 1.3.0 --ci --no-git.requireCleanWorkingDir",
44+
"ng:test": "../../../node_modules/.bin/ng test @angular-material-extensions/algolia",
45+
"test": "../../../node_modules/.bin/jest --coverage",
46+
"test:watch": "../../../node_modules/.bin/jest --coverage --watch"
47+
},
48+
"peerDependencies": {
49+
"@angular/common": "^9.0.2",
50+
"@angular/core": "^9.0.2",
51+
"angular-instantsearch": "^3.0.0-beta.5",
52+
"@angular/cdk": "~9.2.4",
53+
"@angular/material": "~9.2.4",
54+
"instantsearch.js": "^4.7.0",
55+
"algoliasearch": "^3.35.1",
56+
"tslib": "^1.10.0"
57+
},
58+
"engines": {
59+
"node": ">=10.13"
60+
},
61+
"release-it": {
62+
"github": {
63+
"release": true
64+
},
65+
"npm": {
66+
"publish": true,
67+
"publishPath": "../../../dist/angular-material-extensions/algolia"
68+
},
69+
"publishConfig": {
70+
"access": "public"
71+
},
72+
"plugins": {
73+
"@release-it/conventional-changelog": {
74+
"preset": "angular",
75+
"infile": "../../../CHANGELOG.md"
76+
}
77+
},
78+
"hooks": {
79+
"before:init": [
80+
"npm run clean"
81+
],
82+
"after:bump": "echo \"building lib v${version}... \" && npm run build",
83+
"before:git:release": "echo \"Updating CHANGELOG.md for v${version} \" && git commit -m \"Updating CHANGELOG.md for v${version} \" ../../../CHANGELOG.md",
84+
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}.",
85+
"before:npm": "echo building the library..."
86+
}
87+
},
88+
"jest": {
89+
"preset": "jest-preset-angular",
90+
"setupFilesAfterEnv": [
91+
"<rootDir>/../../../src/setup-jest.ts"
92+
]
93+
},
94+
"globals": {
95+
"ts-jest": {
96+
"tsConfig": "<rootDir>/tsconfig.spec.json",
97+
"stringifyContentPathRegex": "\\.html$",
98+
"astTransformers": [
99+
"jest-preset-angular/build/InlineFilesTransformer",
100+
"jest-preset-angular/build/StripStylesTransformer"
101+
]
102+
}
103+
}
104+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { AlgoliaComponent } from './algolia.component';
4+
5+
describe('AlgoliaComponent', () => {
6+
let component: AlgoliaComponent;
7+
let fixture: ComponentFixture<AlgoliaComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ AlgoliaComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(AlgoliaComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'lib-algolia',
5+
template: `
6+
<p>
7+
algolia works!
8+
</p>
9+
`,
10+
styles: []
11+
})
12+
export class AlgoliaComponent implements OnInit {
13+
14+
constructor() { }
15+
16+
ngOnInit(): void {
17+
}
18+
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { NgModule } from '@angular/core';
2+
import { AlgoliaComponent } from './algolia.component';
3+
import { MatAlgoliaRefreshDirective } from './mat-algolia-refresh.directive';
4+
5+
6+
7+
@NgModule({
8+
declarations: [AlgoliaComponent, MatAlgoliaRefreshDirective],
9+
imports: [
10+
],
11+
exports: [AlgoliaComponent]
12+
})
13+
export class AlgoliaModule { }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { AlgoliaService } from './algolia.service';
4+
5+
describe('AlgoliaService', () => {
6+
let service: AlgoliaService;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({});
10+
service = TestBed.inject(AlgoliaService);
11+
});
12+
13+
it('should be created', () => {
14+
expect(service).toBeTruthy();
15+
});
16+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Injectable } from '@angular/core';
2+
3+
@Injectable({
4+
providedIn: 'root'
5+
})
6+
export class AlgoliaService {
7+
8+
constructor() { }
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { MatAlgoliaRefreshDirective } from './mat-algolia-refresh.directive';
2+
3+
describe('MatAlgoliaRefreshDirective', () => {
4+
it('should create an instance', () => {
5+
const directive = new MatAlgoliaRefreshDirective();
6+
expect(directive).toBeTruthy();
7+
});
8+
});
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Directive, forwardRef, HostListener, Inject, OnInit } from '@angular/core';
2+
import { BaseWidget, NgAisInstantSearch } from 'angular-instantsearch';
3+
4+
const connectRefresh = (renderFn, unmountFn) => (widgetParams = {}) => ({
5+
init() {
6+
renderFn({
7+
refresh() {
8+
}
9+
}, true);
10+
},
11+
render({ instantSearchInstance }) {
12+
const refresh = instantSearchInstance.refresh.bind(instantSearchInstance);
13+
renderFn({ refresh }, false);
14+
},
15+
dispose() {
16+
unmountFn();
17+
}
18+
});
19+
20+
@Directive({
21+
selector: '[matAlgoliaRefresh]'
22+
})
23+
export class MatAlgoliaRefreshDirective extends BaseWidget implements OnInit {
24+
25+
state: {
26+
refresh: Function;
27+
};
28+
29+
constructor(
30+
@Inject(forwardRef(() => NgAisInstantSearch))
31+
public instantSearchParent: NgAisInstantSearch
32+
) {
33+
super('Refresh');
34+
}
35+
36+
public ngOnInit() {
37+
this.createWidget(connectRefresh as any, {});
38+
super.ngOnInit();
39+
}
40+
41+
@HostListener('click') onClick() {
42+
console.log('click');
43+
this.state.refresh();
44+
}
45+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Public API Surface of algolia
3+
*/
4+
5+
export * from './lib/algolia.service';
6+
export * from './lib/algolia.component';
7+
export * from './lib/algolia.module';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
2+
3+
import 'zone.js/dist/zone';
4+
import 'zone.js/dist/zone-testing';
5+
import { getTestBed } from '@angular/core/testing';
6+
import {
7+
BrowserDynamicTestingModule,
8+
platformBrowserDynamicTesting
9+
} from '@angular/platform-browser-dynamic/testing';
10+
11+
declare const require: {
12+
context(path: string, deep?: boolean, filter?: RegExp): {
13+
keys(): string[];
14+
<T>(id: string): T;
15+
};
16+
};
17+
18+
// First, initialize the Angular testing environment.
19+
getTestBed().initTestEnvironment(
20+
BrowserDynamicTestingModule,
21+
platformBrowserDynamicTesting()
22+
);
23+
// Then we find all the tests.
24+
const context = require.context('./', true, /\.spec\.ts$/);
25+
// And load the modules.
26+
context.keys().map(context);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"extends": "../../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../../out-tsc/lib",
5+
"target": "es2015",
6+
"declaration": true,
7+
"inlineSources": true,
8+
"types": [],
9+
"lib": [
10+
"dom",
11+
"es2018"
12+
]
13+
},
14+
"angularCompilerOptions": {
15+
"skipTemplateCodegen": true,
16+
"strictMetadataEmit": true,
17+
"enableResourceInlining": true
18+
},
19+
"exclude": [
20+
"src/test.ts",
21+
"**/*.spec.ts"
22+
]
23+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.lib.json",
3+
"angularCompilerOptions": {
4+
"enableIvy": false
5+
}
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "../../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../../out-tsc/spec",
5+
"types": [
6+
"jasmine",
7+
"node"
8+
]
9+
},
10+
"files": [
11+
"src/test.ts"
12+
],
13+
"include": [
14+
"**/*.spec.ts",
15+
"**/*.d.ts"
16+
]
17+
}

0 commit comments

Comments
 (0)