Skip to content

Commit 441cfa0

Browse files
Auto generation of version file and fix review comments
1 parent 5803f2c commit 441cfa0

File tree

13 files changed

+2075
-53
lines changed

13 files changed

+2075
-53
lines changed

.huskyrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"hooks": {
3-
"pre-commit": "lint-staged && npm run lint && npm run test"
3+
"pre-commit": "npm run pre-build && lint-staged && npm run lint && npm run test"
44
}
55
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Register your application to use Microsoft Graph API using one of the following
5757

5858
The Microsoft Graph JavaScript Client Library has an adapter implementation ([ImplicitMSALAuthenticationProvider](src/ImplicitMSALAuthenticationProvider.ts)) for [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core) (Microsoft Authentication Library) which takes care of getting the `accessToken`. MSAL library does not ship with this library, user has to include it externally (For including MSAL, refer [this](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core#installation)).
5959

60-
> **Important Note:** MSAL is supported only for frontend applications, for server-side authentication you have to implement your own AuthenticationProvider. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
60+
> **Important Note:** MSAL is supported only for frontend applications, for server-side authentication you have to implement your own AuthenticationProvider. Learn how you can create a [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
6161
6262
#### Creating an instance of ImplicitMSALAuthenticationProvider in browser environment
6363

@@ -101,7 +101,7 @@ import { ImplicitMSALAuthenticationProvider } from "./node_modules/@microsoft/mi
101101
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
102102
const msalConfig = {
103103
auth: {
104-
clientId: "your_client_id"; // Client Id of the registered application
104+
clientId: "your_client_id", // Client Id of the registered application
105105
redirectUri: "your_redirect_uri",
106106
},
107107
};

docs/CreatingClientInstance.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,20 @@ Library is shipped with one such authentication provider named [ImplicitMSALAuth
1414

1515
```typescript
1616
// Instantiating Client with ImplicitMSALAuthenticationProvider
17+
18+
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
19+
const msalConfig = {
20+
auth: {
21+
clientId: <CLIENT_ID> // Client Id of the registered application
22+
},
23+
};
24+
25+
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
26+
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
27+
const msalInstance = new UserAgentApplication(msalConfig);
28+
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(<SCOPES>); // An array of graph scopes
1729
let clientOptions: ClientOptions = {
18-
authProvider: new ImplicitMSALAuthenticationProvider(<CLIENT_ID>, <SCOPES>, <OPTIONS>)
30+
authProvider: new ImplicitMSALAuthenticationProvider(msalInstance, options)
1931
};
2032
const client = Client.initWithMiddleware(clientOptions);
2133
```

gulpfile.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const { series } = require("gulp");
2+
3+
const licenseStr = `/**
4+
* -------------------------------------------------------------------------------------------
5+
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
6+
* See License in the project root for license information.
7+
* -------------------------------------------------------------------------------------------
8+
*/
9+
`;
10+
11+
const moduleHeader = `/**
12+
* @module Version
13+
*/
14+
`;
15+
16+
const versionFile = `${licenseStr}
17+
// THIS FILE IS AUTO GENERATED
18+
// ANY CHANGES WILL BE LOST DURING BUILD
19+
20+
${moduleHeader}
21+
export const PACKAGE_VERSION = "[VERSION]";
22+
`;
23+
24+
async function setVersion() {
25+
var pkg = require("./package.json");
26+
var fs = require("fs");
27+
fs.writeFileSync("src/Version.ts", versionFile.replace("[VERSION]", pkg.version));
28+
}
29+
30+
exports.setVersion = series(setVersion);

0 commit comments

Comments
 (0)