@adonisjs/ally 5.0.0-1 → 5.0.0-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/configure.js +20 -2
- package/build/stubs/config.stub +17 -2
- package/package.json +1 -1
- package/build/stubs/types.stub +0 -12
package/build/configure.js
CHANGED
|
@@ -10,9 +10,27 @@
|
|
|
10
10
|
* Configures the package
|
|
11
11
|
*/
|
|
12
12
|
export async function configure(command) {
|
|
13
|
-
await command.
|
|
14
|
-
|
|
13
|
+
const providers = await command.prompt.multiple('Select the social auth providers you plan to use', ['discord', 'facebook', 'github', 'google', 'linkedin', 'spotify', 'twitter']);
|
|
14
|
+
/**
|
|
15
|
+
* Publish config file
|
|
16
|
+
*/
|
|
17
|
+
await command.publishStub('config.stub', {
|
|
18
|
+
providers: providers.map((provider) => {
|
|
19
|
+
return { provider, envPrefix: provider.toUpperCase() };
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Publish provider
|
|
24
|
+
*/
|
|
15
25
|
await command.updateRcFile((rcFile) => {
|
|
16
26
|
rcFile.addProvider('@adonisjs/ally/ally_provider');
|
|
17
27
|
});
|
|
28
|
+
/**
|
|
29
|
+
* Define env variables for the selected providers
|
|
30
|
+
*/
|
|
31
|
+
await command.defineEnvVariables(providers.reduce((result, provider) => {
|
|
32
|
+
result[`${provider.toUpperCase()}_CLIENT_ID`] = '';
|
|
33
|
+
result[`${provider.toUpperCase()}_CLIENT_SECRET`] = '';
|
|
34
|
+
return result;
|
|
35
|
+
}, {}));
|
|
18
36
|
}
|
package/build/stubs/config.stub
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
to: {{ app.configPath('ally.ts') }}
|
|
3
3
|
---
|
|
4
|
-
import { defineConfig } from '@adonisjs/ally'
|
|
5
4
|
import env from '#start/env'
|
|
5
|
+
import { defineConfig } from '@adonisjs/ally'
|
|
6
|
+
|
|
7
|
+
const allyConfig = defineConfig({
|
|
8
|
+
{{#each providers as provider}}
|
|
9
|
+
{{provider.provider}}: {
|
|
10
|
+
driver: '{{provider.provider}}',
|
|
11
|
+
clientId: env.get('{{provider.envPrefix}}_CLIENT_ID'),
|
|
12
|
+
clientSecret: env.get('{{provider.envPrefix}}_CLIENT_SECRET'),
|
|
13
|
+
callbackUrl: '',
|
|
14
|
+
},
|
|
15
|
+
{{/each}}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export default allyConfig
|
|
6
19
|
|
|
7
|
-
|
|
20
|
+
declare module '@adonisjs/ally/types' {
|
|
21
|
+
interface SocialProviders extends InferSocialProviders<typeof allyConfig> {}
|
|
22
|
+
}
|
package/package.json
CHANGED
package/build/stubs/types.stub
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: {{ app.contractsPath('ally.ts') }}
|
|
3
|
-
---
|
|
4
|
-
import allyConfig from '#config/ally'
|
|
5
|
-
|
|
6
|
-
declare module '@adonisjs/ally/types' {
|
|
7
|
-
/**
|
|
8
|
-
* Here we get a list of social providers you have configured inside
|
|
9
|
-
* the config/ally.ts file.
|
|
10
|
-
*/
|
|
11
|
-
interface SocialProviders extends InferSocialProviders<typeof allyConfig> {}
|
|
12
|
-
}
|