Skip to content

Commit

Permalink
feat(core): switch to PNPM (#274)
Browse files Browse the repository at this point in the history
* feat(core): switch to PNPM

* feat(core): switch to PNPM

* feat(core): switch to PNPM

* feat(core): switch to PNPM

* feat(core): switch to PNPM

* feat(core): switch to PNPM

* feat(core): switch to PNPM
  • Loading branch information
pavankjadda authored Aug 20, 2023
1 parent 8d28a69 commit bbb5467
Show file tree
Hide file tree
Showing 14 changed files with 10,356 additions and 17,538 deletions.
4 changes: 1 addition & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
},
{
"files": ["*.html"],
"extends": [
"plugin:@angular-eslint/template/recommended",
"plugin:@angular-eslint/template/accessibility"],
"extends": ["plugin:@angular-eslint/template/recommended", "plugin:@angular-eslint/template/accessibility"],
"rules": {}
}
]
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ jobs:
os: ['ubuntu-latest']
node: ['18']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm i --legacy-peer-deps
run: pnpm install --frozen-lockfile
- name: Lint
run: npm run lint
run: pnpm lint
- name: Format check
run: npm run format:check
run: pnpm format:check
- name: Build
run: npm run build --configuration=production && npm run build:ngx-cookie-service-ssr --configuration=production
run: pnpm build --configuration=production && pnpm build:ngx-cookie-service-ssr --configuration=production
- name: Test
run: npm run test --configuration=ci
run: pnpm test
env:
CI: true
11 changes: 7 additions & 4 deletions .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Install NPM Dependencies
run: npm i --legacy-peer-deps
run: pnpm install --frozen-lockfile
- name: Build project
run: npm run build --configuration=production
run: pnpm build --configuration=production
- name: Publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/npm_publish_ssr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Install NPM Dependencies
run: npm i --legacy-peer-deps
- name: Install PNPM Dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: npm run build:ngx-cookie-service-ssr
- name: Publish to NPM
run: pnpm build:ngx-cookie-service-ssr
- name: Publish to NPM registry
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
dist
.angular
.github
README.md
pnpm-lock.yaml
19 changes: 12 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# 14.0.1

### New Features
* feat(ssr): adds SSR support by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/237
* feat(deps): updates `angular-eslint` version to 14.0.0 by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/239
* docs: updates README.md by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/238

- feat(ssr): adds SSR support by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/237
- feat(deps): updates `angular-eslint` version to 14.0.0 by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/239
- docs: updates README.md by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/238

# 14.0.0

## What's Changed
* feat(core): adds Angular 14 support by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/234
* chore(cicd): updates github actions to force install deps by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/236

- feat(core): adds Angular 14 support by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/234
- chore(cicd): updates github actions to force install deps by @pavankjadda in https://github.com/stevermeister/ngx-cookie-service/pull/236

# 13.2.1

### What's Changed
* chore(deps): bump ejs from 3.1.6 to 3.1.7 by @dependabot in https://github.com/stevermeister/ngx-cookie-service/pull/226
* chore(deps): bump async from 2.6.3 to 2.6.4 by @dependabot in https://github.com/stevermeister/ngx-cookie-service/pull/227

- chore(deps): bump ejs from 3.1.6 to 3.1.7 by @dependabot in https://github.com/stevermeister/ngx-cookie-service/pull/226
- chore(deps): bump async from 2.6.3 to 2.6.4 by @dependabot in https://github.com/stevermeister/ngx-cookie-service/pull/227

# 13.2.0

Expand Down
109 changes: 56 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,44 @@ That's it!

1. Angular 14 introduced support for standalone components.
If you are using just standalone components, you can import the service directly into the component
```typescript
import {CookieService} from 'ngx-cookie-service';
import {Component} from '@angular/core';

@Component({
selector: 'my-component',
template: `<h1>Hello World</h1>`,
providers: [CookieService]
})

export class HelloComponent {
constructor(private cookieService: CookieService) {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
}
}
```

```typescript
import { CookieService } from 'ngx-cookie-service';
import { Component } from '@angular/core';

@Component({
selector: 'my-component',
template: `<h1>Hello World</h1>`,
providers: [CookieService],
})
export class HelloComponent {
constructor(private cookieService: CookieService) {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
}
}
```

2. You can also use `inject()` method in v14+ to inject the service into the component
```typescript
import {CookieService} from 'ngx-cookie-service';
import {Component,inject} from '@angular/core';
@Component({
selector: 'my-component',
template: `<h1>Hello World</h1>`,
providers: [CookieService]
})
export class HelloComponent {
cookieService=inject(CookieService);
constructor() {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
}
}
```

```typescript
import { CookieService } from 'ngx-cookie-service';
import { Component, inject } from '@angular/core';
@Component({
selector: 'my-component',
template: `<h1>Hello World</h1>`,
providers: [CookieService],
})
export class HelloComponent {
cookieService = inject(CookieService);
constructor() {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
}
}
```

## Server Side Rendering

Expand All @@ -108,23 +109,25 @@ library [ngx-cookie-service-ssr](https://www.npmjs.com/package/ngx-cookie-servic
Only install `ngx-cookie-service-ssr` library (and skip `ngx-cookie-service`) for SSR

1. Install the library using below command
```shell
npm install ngx-cookie-service-ssr --save
# or
yarn add ngx-cookie-service-ssr
```

```shell
npm install ngx-cookie-service-ssr --save
# or
yarn add ngx-cookie-service-ssr
```

2. By default, browser cookies are not
available in SSR because `document` object is not available. To overcome this, navigate to `server.ts` file in your
SSR
project, and replace the following code

```typescript
server.get('*', (req, res) => {
res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
});
```
```typescript
server.get('*', (req, res) => {
res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
});
```

with this

Expand All @@ -133,9 +136,9 @@ server.get('*', (req, res) => {
res.render(indexHtml, {
req,
providers: [
{provide: APP_BASE_HREF, useValue: req.baseUrl},
{provide: 'REQUEST', useValue: req},
{provide: 'RESPONSE', useValue: res},
{ provide: APP_BASE_HREF, useValue: req.baseUrl },
{ provide: 'REQUEST', useValue: req },
{ provide: 'RESPONSE', useValue: res },
],
});
});
Expand All @@ -156,7 +159,7 @@ https://stackblitz.com/edit/angular-ivy-1lrgdt?file=src%2Fapp%2Fapp.component.ts
library. For versions <=12.x.x, use 12.0.3 version

| Angular Version | Supported Version |
|------------------------|-------------------|
| ---------------------- | ----------------- |
| 16.x.x | 16.x.x |
| 15.x.x | 15.x.x |
| 14.x.x | 14.x.x |
Expand Down Expand Up @@ -195,7 +198,7 @@ Returns a map of key-value pairs for cookies that can be accessed.

```typescript
cookieService.set('test', 'Hello World');
cookieService.set('test', 'Hello World', {expires: 2, sameSite: 'Lax'});
cookieService.set('test', 'Hello World', { expires: 2, sameSite: 'Lax' });
```

Sets a cookie with the specified `name` and `value`. It is good practice to specify a path. If you are unsure about the
Expand Down
5 changes: 1 addition & 4 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"projects/ngx-cookie-service/**/*.ts",
"projects/ngx-cookie-service/**/*.html"
]
"lintFilePatterns": ["projects/ngx-cookie-service/**/*.ts", "projects/ngx-cookie-service/**/*.html"]
}
}
}
Expand Down
Loading

0 comments on commit bbb5467

Please sign in to comment.