Skip to content

Commit

Permalink
refactor: setup stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jul 17, 2023
1 parent f092b8f commit 76e20ad
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 180 deletions.
21 changes: 21 additions & 0 deletions configure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* @adonisjs/ally
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import type Configure from '@adonisjs/core/commands/configure'

/**
* Configures the package
*/
export async function configure(command: Configure) {
await command.publishStub('config.stub')
await command.publishStub('types.stub')
await command.updateRcFile((rcFile) => {
rcFile.addProvider('@adonisjs/ally/ally_provider')
})
}
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ export { RedirectRequest } from './src/redirect_request.js'
export { Oauth1Driver } from './src/abstract_drivers/oauth1.js'
export { Oauth2Driver } from './src/abstract_drivers/oauth2.js'
export { default as driversList } from './src/drivers_collection.js'
export { stubsRoot } from './stubs/main.js'
export { configure } from './configure.js'
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
"main": "build/index.js",
"files": [
"build/src",
"build/stubs",
"build/providers",
"build/index.d.ts",
"build/index.js"
"build/index.js",
"build/configure.d.ts",
"build/configure.js"
],
"exports": {
".": "./build/index.js",
"./types": "./build/src/types.js"
"./types": "./build/src/types.js",
"./ally_provider": "./build/providers/ally_provider.js"
},
"engines": {
"node": ">=18.16.0"
Expand All @@ -21,10 +26,10 @@
"test": "c8 npm run quick:test",
"clean": "del-cli build",
"typecheck": "tsc --noEmit",
"start": "node -r @adonisjs/assembler/build/register examples/app.ts",
"copyfiles": "copyfiles \"templates/**/*.txt\" \"instructions.md\" build",
"start": "node --loader=ts-node/esm examples/app.ts",
"copy:templates": "copyfiles \"stubs/**/*.stub\" build",
"compile": "npm run lint && npm run clean && tsc",
"build": "npm run compile && npm run copyfiles",
"build": "npm run compile && npm run copy:templates",
"prepublishOnly": "npm run build",
"lint": "eslint . --ext=.ts",
"format": "prettier --write .",
Expand Down
7 changes: 7 additions & 0 deletions stubs/config.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
to: {{ app.configPath('ally.ts') }}
---
import { defineConfig } from '@adonisjs/ally'
import env from '#start/env'

export default defineConfig({})
12 changes: 12 additions & 0 deletions stubs/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* @adonisjs/ally
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import { getDirname } from '@poppinss/utils'

export const stubsRoot = getDirname(import.meta.url)
12 changes: 12 additions & 0 deletions stubs/types.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
to: {{ app.contractsPath('ally.ts') }}
---
import allyConfig from '#config/ally'

declare module '@adonisjs/ally/types' {
/**
* Here we get a list of social providers you have configured inside
* the config/ally.ts file.
*/
interface SocialProviders extends InferSocialProviders<typeof allyConfig> {}
}
44 changes: 0 additions & 44 deletions templates/config/ally.txt

This file was deleted.

11 changes: 0 additions & 11 deletions templates/config/partials/discord.txt

This file was deleted.

11 changes: 0 additions & 11 deletions templates/config/partials/facebook.txt

This file was deleted.

11 changes: 0 additions & 11 deletions templates/config/partials/github.txt

This file was deleted.

11 changes: 0 additions & 11 deletions templates/config/partials/google.txt

This file was deleted.

11 changes: 0 additions & 11 deletions templates/config/partials/linkedin.txt

This file was deleted.

12 changes: 0 additions & 12 deletions templates/config/partials/spotify.txt

This file was deleted.

11 changes: 0 additions & 11 deletions templates/config/partials/twitter.txt

This file was deleted.

53 changes: 0 additions & 53 deletions templates/contracts/ally.txt

This file was deleted.

0 comments on commit 76e20ad

Please sign in to comment.