Skip to content

Commit

Permalink
feat: update to adonis 5.0.5-canary-rc-2
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Feb 20, 2021
1 parent c720df9 commit 8ce0121
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 57 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,31 @@ on:
branches: main
pull_request:

env:
NODE_VERSION: 14.x

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install
- name: Run ESLint
run: npm run eslint
- name: Check types
run: npm run check-types
# test:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# node-version: [12.x, 14.x]
# node-version: [14.x, 15.x]
# fail-fast: false
# steps:
# - uses: actions/checkout@v2
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v2-beta
# uses: actions/setup-node@v2
# with:
# node-version: ${{ matrix.node-version }}
# - name: Install dependencies
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,33 @@ on:
branches:
- main

env:
NODE_VERSION: 14.x

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2.6.0
- name: Get package name
run: echo "PACKAGE_NAME=$(jq .name package.json | tr -d '"')" >> $GITHUB_ENV
- uses: GoogleCloudPlatform/release-please-action@v2
id: release
with:
token: ${{ secrets.BOT_TOKEN }}
release-type: node
package-name: 'adonis-react'
package-name: ${{ env.PACKAGE_NAME }}
bump-minor-pre-major: Yes
- uses: actions/checkout@v2
# These if statements ensure that a publication only occurs when a new release is created
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v2-beta
- uses: actions/setup-node@v2
with:
node-version: 14
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}
- run: npm install
if: ${{ steps.release.outputs.release_created }}
- run: npm publish
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_BOT_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "always",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
29 changes: 11 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"clean": "rimraf lib",
"check-types": "tsc --noEmit",
"eslint": "eslint providers src --ext ts",
"eslint": "eslint providers src",
"eslint-fix": "npm run eslint -- --fix",
"prepublishOnly": "npm run tsc",
"test-only": "jest",
Expand All @@ -45,31 +45,24 @@
"preset": "ts-jest",
"testEnvironment": "node"
},
"prettier": {
"arrowParens": "always",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
},
"peerDependencies": {
"@adonisjs/core": "^5.0.4-preview-rc-2",
"@adonisjs/core": "*",
"react": "*",
"react-dom": "*"
},
"devDependencies": {
"@adonisjs/core": "^5.0.4-preview-rc-2",
"@types/jest": "^26.0.15",
"@types/react": "^16.9.56",
"@types/react-dom": "^16.9.9",
"@zakodium/eslint-config": "^2.1.4",
"eslint": "^7.13.0",
"@adonisjs/core": "^5.0.5-canary-rc-2",
"@types/jest": "^26.0.20",
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.1",
"@zakodium/eslint-config": "^3.0.0",
"eslint": "^7.20.0",
"jest": "^26.6.3",
"prettier": "^2.1.2",
"prettier": "^2.2.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.4.4",
"typescript": "^4.0.5"
"ts-jest": "^26.5.1",
"typescript": "^4.1.5"
}
}
2 changes: 1 addition & 1 deletion providers/ReactProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class ReactProvider {
}

public boot() {
this.app.container.with(
this.app.container.withBindings(
[
'Adonis/Core/HttpContext',
'Adonis/Core/Application',
Expand Down
34 changes: 7 additions & 27 deletions src/React.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { renderToStaticMarkup } from 'react-dom/server';

import { ApplicationContract } from '@ioc:Adonis/Core/Application';
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
import {
RouterContract,
MakeUrlOptions,
MakeSignedUrlOptions,
} from '@ioc:Adonis/Core/Route';
import { RouterContract } from '@ioc:Adonis/Core/Route';

import { AdonisContextProvider } from './adonisContext';

Expand All @@ -23,27 +19,11 @@ export function prepareReact(
request: ctx.request,
params: ctx.params,
route: ctx.route,
makeUrl: (
routeIdentifier: string,
options?: MakeUrlOptions,
domain?: string,
) => {
const url = Route.makeUrl(routeIdentifier, options, domain);
if (!url) {
throw new Error(`Route ${routeIdentifier} does not exist`);
}
return url;
makeUrl(...args: Parameters<typeof Route.makeUrl>) {
return Route.makeUrl(...args);
},
makeSignedUrl: (
routeIdentifier: string,
options?: MakeSignedUrlOptions,
domain?: string,
) => {
const url = Route.makeSignedUrl(routeIdentifier, options, domain);
if (!url) {
throw new Error(`Route ${routeIdentifier} does not exist`);
}
return url;
makeSignedUrl: (...args: Parameters<typeof Route.makeSignedUrl>) => {
return Route.makeSignedUrl(...args);
},
});
return instance;
Expand All @@ -61,9 +41,9 @@ class ReactInstance {
props?: ComponentPropsWithoutRef<ComponentType<T>>,
): string {
const html = renderToStaticMarkup(
// @ts-ignore
// @ts-expect-error Context is filled outside of this class
<AdonisContextProvider value={this.context}>
{/* @ts-ignore */}
{/* @ts-expect-error Unsure why this errors */}
<Component {...props} />
</AdonisContextProvider>,
);
Expand Down

0 comments on commit 8ce0121

Please sign in to comment.