agora-appbuilder-core 1.0.9 → 1.0.10

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.
Files changed (50) hide show
  1. package/package.json +4 -2
  2. package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +30 -20
  3. package/template/agora-rn-uikit/src/Controls/Local/EndCall.tsx +1 -0
  4. package/template/agora-rn-uikit/src/Controls/Local/LocalAudioMute.tsx +1 -0
  5. package/template/agora-rn-uikit/src/Controls/Local/LocalVideoMute.tsx +1 -0
  6. package/template/agora-rn-uikit/src/Controls/Local/SwitchCamera.tsx +1 -0
  7. package/template/agora-rn-uikit/src/RTCConfigure.tsx +4 -49
  8. package/template/src/components/Precall.tsx +2 -1
  9. package/template/src/pages/Authenticate.tsx +5 -4
  10. package/template/src/pages/Create.tsx +2 -1
  11. package/template/src/pages/Join.tsx +2 -1
  12. package/template/src/pages/VideoCall.tsx +2 -3
  13. package/template/src/subComponents/ScreenshareButton.tsx +7 -5
  14. package/template/src/subComponents/SelectOAuth.tsx +25 -12
  15. package/template/src/utils/hasBrandLogo.tsx +3 -0
  16. package/template/agora-rn-uikit/.git/HEAD +0 -1
  17. package/template/agora-rn-uikit/.git/config +0 -16
  18. package/template/agora-rn-uikit/.git/description +0 -1
  19. package/template/agora-rn-uikit/.git/hooks/applypatch-msg.sample +0 -15
  20. package/template/agora-rn-uikit/.git/hooks/commit-msg.sample +0 -24
  21. package/template/agora-rn-uikit/.git/hooks/fsmonitor-watchman.sample +0 -173
  22. package/template/agora-rn-uikit/.git/hooks/post-update.sample +0 -8
  23. package/template/agora-rn-uikit/.git/hooks/pre-applypatch.sample +0 -14
  24. package/template/agora-rn-uikit/.git/hooks/pre-commit.sample +0 -49
  25. package/template/agora-rn-uikit/.git/hooks/pre-merge-commit.sample +0 -13
  26. package/template/agora-rn-uikit/.git/hooks/pre-push.sample +0 -53
  27. package/template/agora-rn-uikit/.git/hooks/pre-rebase.sample +0 -169
  28. package/template/agora-rn-uikit/.git/hooks/pre-receive.sample +0 -24
  29. package/template/agora-rn-uikit/.git/hooks/prepare-commit-msg.sample +0 -42
  30. package/template/agora-rn-uikit/.git/hooks/push-to-checkout.sample +0 -78
  31. package/template/agora-rn-uikit/.git/hooks/update.sample +0 -128
  32. package/template/agora-rn-uikit/.git/index +0 -0
  33. package/template/agora-rn-uikit/.git/info/exclude +0 -6
  34. package/template/agora-rn-uikit/.git/logs/HEAD +0 -2
  35. package/template/agora-rn-uikit/.git/logs/refs/heads/ab-dev-auto +0 -1
  36. package/template/agora-rn-uikit/.git/logs/refs/heads/master +0 -1
  37. package/template/agora-rn-uikit/.git/logs/refs/remotes/origin/HEAD +0 -1
  38. package/template/agora-rn-uikit/.git/objects/pack/pack-eb3b4c374d6e79553b5bbcc78b4399cc766e97cf.idx +0 -0
  39. package/template/agora-rn-uikit/.git/objects/pack/pack-eb3b4c374d6e79553b5bbcc78b4399cc766e97cf.pack +0 -0
  40. package/template/agora-rn-uikit/.git/packed-refs +0 -12
  41. package/template/agora-rn-uikit/.git/refs/heads/ab-dev-auto +0 -1
  42. package/template/agora-rn-uikit/.git/refs/heads/master +0 -1
  43. package/template/agora-rn-uikit/.git/refs/remotes/origin/HEAD +0 -1
  44. package/template/agora-rn-uikit/.gitignore +0 -63
  45. package/template/agora-rn-uikit/package-lock.json +0 -7612
  46. package/template/react-native-toast-message/.gitignore +0 -5
  47. package/template/react-native-toast-message/.npmignore +0 -5
  48. package/template/react-native-toast-message/package-lock.json +0 -10553
  49. package/template/src/.DS_Store +0 -0
  50. package/template/src/subComponents/.DS_Store +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-appbuilder-core",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "React Native template for RTE app builder",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -10,7 +10,9 @@
10
10
  "scripts": {
11
11
  "uikit": "rm -rf template/agora-rn-uikit && git clone https://github.com/AgoraIO-Community/ReactNative-UIKit template/agora-rn-uikit && cd template/agora-rn-uikit && git checkout ab-dev-auto",
12
12
  "deps": "cd template && npm i",
13
- "dev-setup": "npm run uikit && npm run deps && node devSetup.js"
13
+ "dev-setup": "npm run uikit && npm run deps && node devSetup.js",
14
+ "web-build": "cd template && npm run web:build && cd .. && npm run copy-vercel",
15
+ "copy-vercel": "cp vercel.json template/dist"
14
16
  },
15
17
  "author": {
16
18
  "email": "svineth.face@gmail.com",
@@ -5,6 +5,8 @@ import {
5
5
  StyleProp,
6
6
  TouchableOpacityProps,
7
7
  ViewStyle,
8
+ Text,
9
+ View,
8
10
  } from 'react-native';
9
11
  import PropsContext from './../PropsContext';
10
12
  import styles from '../Style';
@@ -15,6 +17,7 @@ interface BtnTemplateInterface {
15
17
  color?: string;
16
18
  onPress?: TouchableOpacityProps['onPress'];
17
19
  style?: StyleProp<ViewStyle>;
20
+ btnText?: string;
18
21
  }
19
22
 
20
23
  const BtnTemplate: React.FC<BtnTemplateInterface> = (props) => {
@@ -22,30 +25,37 @@ const BtnTemplate: React.FC<BtnTemplateInterface> = (props) => {
22
25
  const {BtnTemplateStyles, theme} = styleProps || {};
23
26
 
24
27
  return (
25
- <TouchableOpacity
26
- style={{
27
- ...styles.controlBtn,
28
- ...(BtnTemplateStyles as object),
29
- ...(props.style as object),
30
- }}
31
- // onPress={props.onPress}
32
- onPress={() => {
33
- console.log('pressed mute')
34
- props.onPress()
35
- }}
36
- >
37
- <Image
28
+ <TouchableOpacity onPress={props.onPress}>
29
+ <View
38
30
  style={{
39
- width: '100%',
40
- height: '100%',
41
- tintColor:
31
+ ...styles.controlBtn,
32
+ ...(BtnTemplateStyles as object),
33
+ ...(props.style as object),
34
+ }}>
35
+ <Image
36
+ style={{
37
+ width: '100%',
38
+ height: '100%',
39
+ tintColor:
40
+ props.name !== 'callEnd'
41
+ ? theme || props.color || '#fff'
42
+ : '#FD0845',
43
+ }}
44
+ resizeMode={'contain'}
45
+ source={{uri: icons[props.name]}}
46
+ />
47
+ </View>
48
+ <Text
49
+ style={{
50
+ textAlign: 'center',
51
+ marginTop: 5,
52
+ color:
42
53
  props.name !== 'callEnd'
43
54
  ? theme || props.color || '#fff'
44
55
  : '#FD0845',
45
- }}
46
- resizeMode={'contain'}
47
- source={{uri: icons[props.name]}}
48
- />
56
+ }}>
57
+ {props.btnText}
58
+ </Text>
49
59
  </TouchableOpacity>
50
60
  );
51
61
  };
@@ -13,6 +13,7 @@ function EndCall() {
13
13
  return (
14
14
  <BtnTemplate
15
15
  name={'callEnd'}
16
+ btnText={'Hang Up'}
16
17
  style={{...styles.endCall, ...(endCall as object)}}
17
18
  onPress={() =>
18
19
  (dispatch as DispatchType<'EndCall'>)({
@@ -15,6 +15,7 @@ function LocalAudioMute() {
15
15
  return (
16
16
  <BtnTemplate
17
17
  name={local.audio ? 'mic' : 'micOff'}
18
+ btnText={'Audio'}
18
19
  style={{...styles.localBtn, ...(muteLocalAudio as object)}}
19
20
  onPress={() => {
20
21
  (dispatch as DispatchType<'LocalMuteAudio'>)({
@@ -15,6 +15,7 @@ function LocalVideoMute() {
15
15
  return (
16
16
  <BtnTemplate
17
17
  name={local.video ? 'videocam' : 'videocamOff'}
18
+ btnText={'Video'}
18
19
  style={{...styles.localBtn, ...(muteLocalVideo as object)}}
19
20
  onPress={() => {
20
21
  (dispatch as DispatchType<'LocalMuteVideo'>)({
@@ -13,6 +13,7 @@ function SwitchCamera() {
13
13
  <BtnTemplate
14
14
  name={'switchCamera'}
15
15
  style={{...styles.localBtn, ...(switchCamera as object)}}
16
+ btnText={'Switch'}
16
17
  onPress={() => {
17
18
  // RtcEngine.switchCamera();
18
19
  (dispatch as DispatchType<'SwitchCamera'>)({
@@ -201,7 +201,6 @@ const RtcConfigure: React.FC<Partial<RtcPropsInterface>> = (props) => {
201
201
  };
202
202
  break;
203
203
  case 'LocalMuteVideo':
204
- console.log('Switch: Local mute video', {value: action.value}, {state});
205
204
  (engine.current as RtcEngine).muteLocalVideoStream(
206
205
  (action as ActionType<'LocalMuteAudio'>).value[0],
207
206
  );
@@ -308,49 +307,6 @@ const RtcConfigure: React.FC<Partial<RtcPropsInterface>> = (props) => {
308
307
  },
309
308
  [dualStreamMode],
310
309
  );
311
-
312
- const getRemoteVolume = () => {
313
- console.log('getting remote user track');
314
- // console.log(engine.current.client.remoteUsers);
315
- const client = engine?.current?.client;
316
- if (client) {
317
- const {remoteUsers} = client;
318
-
319
- const userVolume = remoteUsers.map(
320
- (remoteUser: {uid: any; audioTrack: any; hasAudio: boolean}) => {
321
- const {uid, audioTrack, hasAudio} = remoteUser;
322
- console.log({remoteUser}, {hasAudio});
323
- return {
324
- uid,
325
- volumeLevel: hasAudio ? audioTrack.getVolumeLevel() : 0,
326
- };
327
- },
328
- );
329
- console.log({userVolume});
330
- const highestvolumeObj = volumes.reduce(
331
- (highestVolume, volume, index) => {
332
- if (highestVolume === null) {
333
- return volume;
334
- } else {
335
- if (volume.level > highestVolume.level) {
336
- return volume;
337
- }
338
- return highestVolume;
339
- }
340
- // console.log(`${index} UID ${volume.uid} Level ${volume.level}`);
341
- },
342
- null,
343
- );
344
- const activeSpeaker = highestvolumeObj ? highestvolumeObj.uid : undefined;
345
- }
346
- };
347
- // useEffect(() => {
348
- // const timer = setInterval(getRemoteVolume, 1000);
349
- // return () => {
350
- // clearInterval(timer);
351
- // };
352
- // }, []);
353
-
354
310
  const [uidState, dispatch] = useReducer(reducer, initialState);
355
311
 
356
312
  // When mode is updated, reducer is triggered to update the individual states
@@ -504,21 +460,20 @@ const RtcConfigure: React.FC<Partial<RtcPropsInterface>> = (props) => {
504
460
  });
505
461
  }
506
462
  if (engine.current) {
507
- if (uidState.max[0].video) {
508
- console.log('another place 1');
463
+ if(uidState.max[0].video){
509
464
  await engine.current.muteLocalVideoStream(true);
510
465
  }
511
-
466
+
512
467
  await engine.current.joinChannel(
513
468
  rtcProps.token || null,
514
469
  rtcProps.channel,
515
470
  null,
516
471
  rtcProps.uid || 0,
517
472
  );
518
- if (uidState.max[0].video) {
519
- console.log('another place 2');
473
+ if(uidState.max[0].video){
520
474
  await engine.current.muteLocalVideoStream(false);
521
475
  }
476
+
522
477
  } else {
523
478
  console.error('trying to join before RTC Engine was initialized');
524
479
  }
@@ -19,6 +19,7 @@ import {LocalAudioMute, LocalVideoMute} from '../../agora-rn-uikit/Components';
19
19
  import LocalUserContext from '../../agora-rn-uikit/src/LocalUserContext';
20
20
  import SelectDevice from '../subComponents/SelectDevice';
21
21
  import Logo from '../subComponents/Logo';
22
+ import hasBrandLogo from '../utils/hasBrandLogo';
22
23
  // import OpenInNativeButton from '../subComponents/OpenInNativeButton';
23
24
  import ColorContext from './ColorContext';
24
25
  // import {useHistory} from './Router';
@@ -45,7 +46,7 @@ const Precall = (props: any) => {
45
46
  // resizeMode={'cover'}>
46
47
  <View style={style.main} onLayout={onLayout}>
47
48
  <View style={style.nav}>
48
- <Logo />
49
+ {hasBrandLogo && <Logo />}
49
50
  {error ? <Error error={error} showBack={true} /> : <></>}
50
51
  {/* <OpenInNativeButton /> */}
51
52
  </View>
@@ -20,6 +20,7 @@ import {
20
20
  import Logo from '../subComponents/Logo';
21
21
  import OAuth from '../components/OAuth';
22
22
  import Illustration from '../subComponents/Illustration';
23
+ import hasBrandLogo from '../utils/hasBrandLogo';
23
24
 
24
25
  const Authenticate = () => {
25
26
  const [dim, setDim] = useState([
@@ -37,13 +38,13 @@ const Authenticate = () => {
37
38
  style={style.full}
38
39
  resizeMode={'cover'}>
39
40
  <View style={style.main}>
40
- <View style={style.nav}>
41
- <Logo />
42
- </View>
41
+ <View style={style.nav}>{hasBrandLogo && <Logo />}</View>
43
42
  <View style={style.content}>
44
43
  <View style={style.leftContent}>
45
44
  <Text style={style.heading}>Login using OAuth</Text>
46
- <Text style={style.headline}>Please select an OAuth provider to login.</Text>
45
+ <Text style={style.headline}>
46
+ Please select an OAuth provider to login.
47
+ </Text>
47
48
  <OAuth />
48
49
  </View>
49
50
  {dim[0] > dim[1] + 150 ? (
@@ -26,6 +26,7 @@ import HorizontalRule from '../atoms/HorizontalRule';
26
26
  import TextInput from '../atoms/TextInput';
27
27
  import Error from '../subComponents/Error';
28
28
  import Toast from '../../react-native-toast-message';
29
+ import hasBrandLogo from '../utils/hasBrandLogo';
29
30
 
30
31
  type PasswordInput = {
31
32
  host: string;
@@ -116,7 +117,7 @@ const Create = () => {
116
117
  // <KeyboardAvoidingView behavior={'height'} style={style.main}>
117
118
  <ScrollView contentContainerStyle={style.main}>
118
119
  <View style={style.nav}>
119
- <Logo />
120
+ {hasBrandLogo && <Logo />}
120
121
  {error ? <Error error={error} /> : <></>}
121
122
  {/* <OpenInNativeButton /> */}
122
123
  </View>
@@ -15,6 +15,7 @@ import {useHistory} from '../components/Router';
15
15
  import SessionContext from '../components/SessionContext';
16
16
  // import OpenInNativeButton from '../subComponents/OpenInNativeButton';
17
17
  import Logo from '../subComponents/Logo';
18
+ import hasBrandLogo from '../utils/hasBrandLogo';
18
19
  import LogoutButton from '../subComponents/LogoutButton';
19
20
  import ColorContext from '../components/ColorContext';
20
21
  // import Illustration from '../subComponents/Illustration';
@@ -58,7 +59,7 @@ const Join = (props: joinProps) => {
58
59
  return (
59
60
  <ScrollView contentContainerStyle={style.main}>
60
61
  <View style={style.nav}>
61
- <Logo />
62
+ {hasBrandLogo && <Logo />}
62
63
  {error ? <Error error={error} /> : <></>}
63
64
  </View>
64
65
  <View style={style.content}>
@@ -30,6 +30,7 @@ import {gql, useQuery} from '@apollo/client';
30
30
  // import Watermark from '../subComponents/Watermark';
31
31
  import StorageContext from '../components/StorageContext';
32
32
  import Logo from '../subComponents/Logo';
33
+ import hasBrandLogo from '../utils/hasBrandLogo';
33
34
  import ChatContext from '../components/ChatContext';
34
35
  import {SidePanelType} from '../subComponents/SidePanelEnum';
35
36
  import {videoView} from '../../theme.json';
@@ -465,9 +466,7 @@ const VideoCall: React.FC = () => {
465
466
  </>
466
467
  ) : (
467
468
  <View style={style.loader}>
468
- <View style={style.loaderLogo}>
469
- <Logo />
470
- </View>
469
+ <View style={style.loaderLogo}>{hasBrandLogo && <Logo />}</View>
471
470
  <Text style={style.loaderText}>Starting Call. Just a second.</Text>
472
471
  </View>
473
472
  )}
@@ -109,11 +109,13 @@ const ScreenshareButton = (props: ScreenSharingProps) => {
109
109
  value: [joinedUser[0]],
110
110
  });
111
111
  setLayout(Layout.Pinned);
112
- }else if(newUserUid === 1){
113
- dispatch({
114
- type: 'SwapVideo',
115
- value: [joinedUser[0]],
116
- });
112
+ } else if (newUserUid === 1) {
113
+ if (newUserUid !== users[0].uid){
114
+ dispatch({
115
+ type: 'SwapVideo',
116
+ value: [joinedUser[0]],
117
+ });
118
+ }
117
119
  setLayout(Layout.Pinned);
118
120
  }
119
121
  }
@@ -17,56 +17,69 @@ import apple from '../assets/apple.png';
17
17
  import slack from '../assets/slack.png';
18
18
  import microsoft from '../assets/microsoft.png';
19
19
  import Logo from './Logo';
20
+ import hasBrandLogo from '../utils/hasBrandLogo';
20
21
 
21
22
  const SelectOAuth = ({onSelectOAuth}) => {
22
23
  // Linking.openURL(url);
23
24
  const {primaryColor} = useContext(ColorContext);
24
25
  return (
25
26
  <View style={style.main}>
26
- <View style={style.nav}>
27
- <Logo />
28
- </View>
27
+ <View style={style.nav}>{hasBrandLogo && <Logo />}</View>
29
28
  <View style={style.content}>
30
29
  <View style={style.leftContent}>
31
30
  <Text style={style.heading}>{$config.APP_NAME}</Text>
32
31
  <Text style={style.headline}>{$config.LANDING_SUB_HEADING}</Text>
33
32
  <View style={style.inputs}>
34
33
  <View style={style.oAuthContainer}>
35
- <Text style={{fontSize: 16, fontWeight: '500', marginBottom: 20, color: $config.PRIMARY_FONT_COLOR}}>
34
+ <Text
35
+ style={{
36
+ fontSize: 16,
37
+ fontWeight: '500',
38
+ marginBottom: 20,
39
+ color: $config.PRIMARY_FONT_COLOR,
40
+ }}>
36
41
  Login using OAuth
37
42
  </Text>
38
- {$config.ENABLE_GOOGLE_OAUTH ?
43
+ {$config.ENABLE_GOOGLE_OAUTH ? (
39
44
  <TouchableOpacity
40
45
  style={[style.secondaryBtn, {borderColor: primaryColor}]}
41
46
  onPress={() => onSelectOAuth({oAuthSystem: 'google'})}>
42
47
  <Image source={google} style={style.logo} />
43
48
  <Text style={[style.secondaryBtnText]}>Google</Text>
44
49
  </TouchableOpacity>
45
- : <></>}
46
- {$config.ENABLE_MICROSOFT_OAUTH ?
50
+ ) : (
51
+ <></>
52
+ )}
53
+ {$config.ENABLE_MICROSOFT_OAUTH ? (
47
54
  <TouchableOpacity
48
55
  style={[style.secondaryBtn, {borderColor: primaryColor}]}
49
56
  onPress={() => onSelectOAuth({oAuthSystem: 'microsoft'})}>
50
57
  <Image source={microsoft} style={style.logo} />
51
58
  <Text style={[style.secondaryBtnText]}>Microsoft</Text>
52
59
  </TouchableOpacity>
53
- : <></>}
54
- {$config.ENABLE_SLACK_OAUTH ?
60
+ ) : (
61
+ <></>
62
+ )}
63
+ {$config.ENABLE_SLACK_OAUTH ? (
55
64
  <TouchableOpacity
56
65
  style={[style.secondaryBtn, {borderColor: primaryColor}]}
57
66
  onPress={() => onSelectOAuth({oAuthSystem: 'slack'})}>
58
67
  <Image source={slack} style={style.logo} />
59
68
  <Text style={[style.secondaryBtnText]}>Slack</Text>
60
69
  </TouchableOpacity>
61
- : <></>}
62
- {$config.ENABLE_APPLE_OAUTH ?
70
+ ) : (
71
+ <></>
72
+ )}
73
+ {$config.ENABLE_APPLE_OAUTH ? (
63
74
  <TouchableOpacity
64
75
  style={[style.secondaryBtn, {borderColor: primaryColor}]}
65
76
  onPress={() => onSelectOAuth({oAuthSystem: 'apple'})}>
66
77
  <Image source={apple} style={style.logo} />
67
78
  <Text style={[style.secondaryBtnText]}>Apple</Text>
68
79
  </TouchableOpacity>
69
- : <></>}
80
+ ) : (
81
+ <></>
82
+ )}
70
83
  </View>
71
84
  </View>
72
85
  </View>
@@ -0,0 +1,3 @@
1
+ const hasBrandLogo: boolean = !!$config.LOGO;
2
+
3
+ export default hasBrandLogo;
@@ -1 +0,0 @@
1
- ref: refs/heads/ab-dev-auto
@@ -1,16 +0,0 @@
1
- [core]
2
- repositoryformatversion = 0
3
- filemode = true
4
- bare = false
5
- logallrefupdates = true
6
- ignorecase = true
7
- precomposeunicode = true
8
- [remote "origin"]
9
- url = https://github.com/AgoraIO-Community/ReactNative-UIKit
10
- fetch = +refs/heads/*:refs/remotes/origin/*
11
- [branch "master"]
12
- remote = origin
13
- merge = refs/heads/master
14
- [branch "ab-dev-auto"]
15
- remote = origin
16
- merge = refs/heads/ab-dev-auto
@@ -1 +0,0 @@
1
- Unnamed repository; edit this file 'description' to name the repository.
@@ -1,15 +0,0 @@
1
- #!/bin/sh
2
- #
3
- # An example hook script to check the commit log message taken by
4
- # applypatch from an e-mail message.
5
- #
6
- # The hook should exit with non-zero status after issuing an
7
- # appropriate message if it wants to stop the commit. The hook is
8
- # allowed to edit the commit message file.
9
- #
10
- # To enable this hook, rename this file to "applypatch-msg".
11
-
12
- . git-sh-setup
13
- commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
14
- test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
15
- :
@@ -1,24 +0,0 @@
1
- #!/bin/sh
2
- #
3
- # An example hook script to check the commit log message.
4
- # Called by "git commit" with one argument, the name of the file
5
- # that has the commit message. The hook should exit with non-zero
6
- # status after issuing an appropriate message if it wants to stop the
7
- # commit. The hook is allowed to edit the commit message file.
8
- #
9
- # To enable this hook, rename this file to "commit-msg".
10
-
11
- # Uncomment the below to add a Signed-off-by line to the message.
12
- # Doing this in a hook is a bad idea in general, but the prepare-commit-msg
13
- # hook is more suited to it.
14
- #
15
- # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
16
- # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
17
-
18
- # This example catches duplicate Signed-off-by lines.
19
-
20
- test "" = "$(grep '^Signed-off-by: ' "$1" |
21
- sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
22
- echo >&2 Duplicate Signed-off-by lines.
23
- exit 1
24
- }
@@ -1,173 +0,0 @@
1
- #!/usr/bin/perl
2
-
3
- use strict;
4
- use warnings;
5
- use IPC::Open2;
6
-
7
- # An example hook script to integrate Watchman
8
- # (https://facebook.github.io/watchman/) with git to speed up detecting
9
- # new and modified files.
10
- #
11
- # The hook is passed a version (currently 2) and last update token
12
- # formatted as a string and outputs to stdout a new update token and
13
- # all files that have been modified since the update token. Paths must
14
- # be relative to the root of the working tree and separated by a single NUL.
15
- #
16
- # To enable this hook, rename this file to "query-watchman" and set
17
- # 'git config core.fsmonitor .git/hooks/query-watchman'
18
- #
19
- my ($version, $last_update_token) = @ARGV;
20
-
21
- # Uncomment for debugging
22
- # print STDERR "$0 $version $last_update_token\n";
23
-
24
- # Check the hook interface version
25
- if ($version ne 2) {
26
- die "Unsupported query-fsmonitor hook version '$version'.\n" .
27
- "Falling back to scanning...\n";
28
- }
29
-
30
- my $git_work_tree = get_working_dir();
31
-
32
- my $retry = 1;
33
-
34
- my $json_pkg;
35
- eval {
36
- require JSON::XS;
37
- $json_pkg = "JSON::XS";
38
- 1;
39
- } or do {
40
- require JSON::PP;
41
- $json_pkg = "JSON::PP";
42
- };
43
-
44
- launch_watchman();
45
-
46
- sub launch_watchman {
47
- my $o = watchman_query();
48
- if (is_work_tree_watched($o)) {
49
- output_result($o->{clock}, @{$o->{files}});
50
- }
51
- }
52
-
53
- sub output_result {
54
- my ($clockid, @files) = @_;
55
-
56
- # Uncomment for debugging watchman output
57
- # open (my $fh, ">", ".git/watchman-output.out");
58
- # binmode $fh, ":utf8";
59
- # print $fh "$clockid\n@files\n";
60
- # close $fh;
61
-
62
- binmode STDOUT, ":utf8";
63
- print $clockid;
64
- print "\0";
65
- local $, = "\0";
66
- print @files;
67
- }
68
-
69
- sub watchman_clock {
70
- my $response = qx/watchman clock "$git_work_tree"/;
71
- die "Failed to get clock id on '$git_work_tree'.\n" .
72
- "Falling back to scanning...\n" if $? != 0;
73
-
74
- return $json_pkg->new->utf8->decode($response);
75
- }
76
-
77
- sub watchman_query {
78
- my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
79
- or die "open2() failed: $!\n" .
80
- "Falling back to scanning...\n";
81
-
82
- # In the query expression below we're asking for names of files that
83
- # changed since $last_update_token but not from the .git folder.
84
- #
85
- # To accomplish this, we're using the "since" generator to use the
86
- # recency index to select candidate nodes and "fields" to limit the
87
- # output to file names only. Then we're using the "expression" term to
88
- # further constrain the results.
89
- if (substr($last_update_token, 0, 1) eq "c") {
90
- $last_update_token = "\"$last_update_token\"";
91
- }
92
- my $query = <<" END";
93
- ["query", "$git_work_tree", {
94
- "since": $last_update_token,
95
- "fields": ["name"],
96
- "expression": ["not", ["dirname", ".git"]]
97
- }]
98
- END
99
-
100
- # Uncomment for debugging the watchman query
101
- # open (my $fh, ">", ".git/watchman-query.json");
102
- # print $fh $query;
103
- # close $fh;
104
-
105
- print CHLD_IN $query;
106
- close CHLD_IN;
107
- my $response = do {local $/; <CHLD_OUT>};
108
-
109
- # Uncomment for debugging the watch response
110
- # open ($fh, ">", ".git/watchman-response.json");
111
- # print $fh $response;
112
- # close $fh;
113
-
114
- die "Watchman: command returned no output.\n" .
115
- "Falling back to scanning...\n" if $response eq "";
116
- die "Watchman: command returned invalid output: $response\n" .
117
- "Falling back to scanning...\n" unless $response =~ /^\{/;
118
-
119
- return $json_pkg->new->utf8->decode($response);
120
- }
121
-
122
- sub is_work_tree_watched {
123
- my ($output) = @_;
124
- my $error = $output->{error};
125
- if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
126
- $retry--;
127
- my $response = qx/watchman watch "$git_work_tree"/;
128
- die "Failed to make watchman watch '$git_work_tree'.\n" .
129
- "Falling back to scanning...\n" if $? != 0;
130
- $output = $json_pkg->new->utf8->decode($response);
131
- $error = $output->{error};
132
- die "Watchman: $error.\n" .
133
- "Falling back to scanning...\n" if $error;
134
-
135
- # Uncomment for debugging watchman output
136
- # open (my $fh, ">", ".git/watchman-output.out");
137
- # close $fh;
138
-
139
- # Watchman will always return all files on the first query so
140
- # return the fast "everything is dirty" flag to git and do the
141
- # Watchman query just to get it over with now so we won't pay
142
- # the cost in git to look up each individual file.
143
- my $o = watchman_clock();
144
- $error = $output->{error};
145
-
146
- die "Watchman: $error.\n" .
147
- "Falling back to scanning...\n" if $error;
148
-
149
- output_result($o->{clock}, ("/"));
150
- $last_update_token = $o->{clock};
151
-
152
- eval { launch_watchman() };
153
- return 0;
154
- }
155
-
156
- die "Watchman: $error.\n" .
157
- "Falling back to scanning...\n" if $error;
158
-
159
- return 1;
160
- }
161
-
162
- sub get_working_dir {
163
- my $working_dir;
164
- if ($^O =~ 'msys' || $^O =~ 'cygwin') {
165
- $working_dir = Win32::GetCwd();
166
- $working_dir =~ tr/\\/\//;
167
- } else {
168
- require Cwd;
169
- $working_dir = Cwd::cwd();
170
- }
171
-
172
- return $working_dir;
173
- }
@@ -1,8 +0,0 @@
1
- #!/bin/sh
2
- #
3
- # An example hook script to prepare a packed repository for use over
4
- # dumb transports.
5
- #
6
- # To enable this hook, rename this file to "post-update".
7
-
8
- exec git update-server-info