diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 35a112c..bcd79cf 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dcae027..0c2874f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..a23e760 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,7 @@ +{ + "arrowParens": "always", + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "all" +} diff --git a/package.json b/package.json index 619cf23..ffd0f64 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } } diff --git a/providers/ReactProvider.ts b/providers/ReactProvider.ts index 9af5eb7..4d94100 100644 --- a/providers/ReactProvider.ts +++ b/providers/ReactProvider.ts @@ -16,7 +16,7 @@ export default class ReactProvider { } public boot() { - this.app.container.with( + this.app.container.withBindings( [ 'Adonis/Core/HttpContext', 'Adonis/Core/Application', diff --git a/src/React.tsx b/src/React.tsx index cba9b30..219373c 100644 --- a/src/React.tsx +++ b/src/React.tsx @@ -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'; @@ -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) { + 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) => { + return Route.makeSignedUrl(...args); }, }); return instance; @@ -61,9 +41,9 @@ class ReactInstance { props?: ComponentPropsWithoutRef>, ): string { const html = renderToStaticMarkup( - // @ts-ignore + // @ts-expect-error Context is filled outside of this class - {/* @ts-ignore */} + {/* @ts-expect-error Unsure why this errors */} , );