Skip to content

Commit 5269567

Browse files
committed
Fixed eslint and format issues
1 parent f15b14d commit 5269567

File tree

3 files changed

+52
-60
lines changed

3 files changed

+52
-60
lines changed
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
const fs = require('node:fs');
1+
const fs = require('fs');
22

33
const { AndroidConfig, withDangerousMod } = require('@expo/config-plugins');
44
const codeModAndroid = require('@expo/config-plugins/build/android/codeMod');
55

66
const withAppAuthAppBuildGradle = (rootConfig, props) =>
7-
withDangerousMod(rootConfig, [
8-
'android',
9-
config => {
10-
// find the app/build.gradle file and checks its format
11-
const appBuildGradlePath = AndroidConfig.Paths.getAppBuildGradleFilePath(
12-
config.modRequest.projectRoot,
13-
);
14-
15-
// BEWARE: we update the app/build.gradle file *outside* of the standard Expo config procedure !
16-
let contents = fs.readFileSync(appBuildGradlePath, 'utf8');
17-
18-
if (contents.includes('manifestPlaceholders')) {
19-
throw new Error(
20-
'app/build.gradle already contains manifestPlaceholders, cannot update automatically !',
21-
);
22-
}
23-
24-
contents = codeModAndroid.appendContentsInsideDeclarationBlock(
25-
contents,
26-
'defaultConfig',
27-
` manifestPlaceholders = [
7+
withDangerousMod(rootConfig, [
8+
'android',
9+
config => {
10+
// find the app/build.gradle file and checks its format
11+
const appBuildGradlePath = AndroidConfig.Paths.getAppBuildGradleFilePath(
12+
config.modRequest.projectRoot
13+
);
14+
15+
// BEWARE: we update the app/build.gradle file *outside* of the standard Expo config procedure !
16+
let contents = fs.readFileSync(appBuildGradlePath, 'utf8');
17+
18+
if (contents.includes('manifestPlaceholders')) {
19+
throw new Error(
20+
'app/build.gradle already contains manifestPlaceholders, cannot update automatically !'
21+
);
22+
}
23+
24+
contents = codeModAndroid.appendContentsInsideDeclarationBlock(
25+
contents,
26+
'defaultConfig',
27+
` manifestPlaceholders = [
2828
appAuthRedirectScheme: '${props?.android?.appAuthRedirectScheme}',
2929
]
30-
`,
31-
);
30+
`
31+
);
3232

33-
// and finally we write the file back to the disk
34-
fs.writeFileSync(appBuildGradlePath, contents, 'utf8');
33+
// and finally we write the file back to the disk
34+
fs.writeFileSync(appBuildGradlePath, contents, 'utf8');
3535

36-
return config;
37-
},
38-
]);
36+
return config;
37+
},
38+
]);
3939

4040
module.exports = { withAppAuthAppBuildGradle };

packages/react-native-app-auth/plugin/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ const withAppAuth = (config, props) => {
1717
withBridgingHeader,
1818
withXcodeBuildSettings,
1919
withAppAuthAppDelegate,
20-
withAppAuthAppDelegateHeader, // 👈 ️this one uses withDangerousMod !
20+
withAppAuthAppDelegateHeader,
2121
[withUrlSchemes, props],
2222

2323
// Android
24-
[withAppAuthAppBuildGradle, props], // 👈 ️this one uses withDangerousMod !
24+
[withAppAuthAppBuildGradle, props],
2525
]);
2626
};
2727

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
1-
/**
2-
* Inserts a protocol into an Objective-C class interface declaration.
3-
* @param {string} source source code of the file
4-
* @param {string} interfaceName Name of the interface to insert the protocol into (ex: AppDelegate)
5-
* @param {string} protocolName Name of the protocol to add to the list of protocols (ex: RNAppAuthAuthorizationFlowManagerDelegate)
6-
* @param {string|undefined} baseClassName Base class name of the interface (ex: NSObject)
7-
* @returns {string} the patched source code
8-
*/
91
const insertProtocolDeclaration = ({
10-
source,
11-
interfaceName,
12-
protocolName,
13-
baseClassName = 'NSObject',
2+
source,
3+
interfaceName,
4+
protocolName,
5+
baseClassName = 'NSObject',
146
}) => {
15-
const matchInterfaceDeclarationRegexp = new RegExp(
16-
`(@interface\\s+${interfaceName}\\s*:\\s*${baseClassName})(\\s*\\<(.*)\\>)?`,
17-
);
18-
const match = source.match(matchInterfaceDeclarationRegexp);
19-
if (match) {
20-
const [line, interfaceDeclaration, , existingProtocols] = match;
21-
if (!existingProtocols || !existingProtocols.includes(protocolName)) {
22-
source = source.replace(
23-
line,
24-
`${interfaceDeclaration} <${
25-
existingProtocols ? `${existingProtocols},` : ''
26-
}${protocolName}>`,
27-
);
28-
}
29-
}
7+
const matchInterfaceDeclarationRegexp = new RegExp(
8+
`(@interface\\s+${interfaceName}\\s*:\\s*${baseClassName})(\\s*\\<(.*)\\>)?`
9+
);
10+
const match = source.match(matchInterfaceDeclarationRegexp);
11+
if (match) {
12+
const [line, interfaceDeclaration, , existingProtocols] = match;
13+
if (!existingProtocols || !existingProtocols.includes(protocolName)) {
14+
source = source.replace(
15+
line,
16+
`${interfaceDeclaration} <${
17+
existingProtocols ? `${existingProtocols},` : ''
18+
}${protocolName}>`
19+
);
20+
}
21+
}
3022

31-
return source;
23+
return source;
3224
};
3325

3426
module.exports = {
35-
insertProtocolDeclaration,
27+
insertProtocolDeclaration,
3628
};

0 commit comments

Comments
 (0)