eas-cli 0.33.0 → 0.35.0

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 (170) hide show
  1. package/README.md +27 -27
  2. package/build/analytics.js +3 -9
  3. package/build/api.js +3 -3
  4. package/build/build/android/UpdatesModule.js +4 -15
  5. package/build/build/android/configure.js +2 -2
  6. package/build/build/android/graphql.js +2 -4
  7. package/build/build/android/prepareJob.js +4 -3
  8. package/build/build/build.js +2 -2
  9. package/build/build/configure.js +14 -7
  10. package/build/build/ios/UpdatesModule.js +6 -18
  11. package/build/build/ios/graphql.js +2 -23
  12. package/build/build/ios/prepareJob.js +4 -6
  13. package/build/build/metadata.js +5 -10
  14. package/build/build/utils/devClient.js +8 -5
  15. package/build/build/utils/formatBuild.js +1 -9
  16. package/build/build/utils/repository.js +10 -7
  17. package/build/build/utils/url.js +1 -1
  18. package/build/build/validate.js +4 -4
  19. package/build/commandUtils/EasCommand.d.ts +1 -0
  20. package/build/commandUtils/EasCommand.js +21 -0
  21. package/build/commands/branch/create.js +3 -2
  22. package/build/commands/branch/delete.js +1 -1
  23. package/build/commands/branch/list.js +1 -1
  24. package/build/commands/branch/publish.js +20 -48
  25. package/build/commands/branch/view.js +1 -1
  26. package/build/commands/build/index.js +43 -24
  27. package/build/commands/channel/edit.js +1 -1
  28. package/build/commands/channel/list.js +1 -1
  29. package/build/commands/channel/view.js +1 -1
  30. package/build/commands/diagnostics.js +2 -2
  31. package/build/commands/project/info.js +1 -1
  32. package/build/commands/secret/delete.js +1 -1
  33. package/build/commands/update/view.js +1 -1
  34. package/build/credentials/android/AndroidCredentialsProvider.js +2 -2
  35. package/build/credentials/android/actions/{SetupBuildCredentials.d.ts → SetUpBuildCredentials.d.ts} +1 -1
  36. package/build/credentials/android/actions/{SetupBuildCredentials.js → SetUpBuildCredentials.js} +3 -3
  37. package/build/credentials/android/actions/{SetupBuildCredentialsFromCredentialsJson.d.ts → SetUpBuildCredentialsFromCredentialsJson.d.ts} +1 -1
  38. package/build/credentials/android/actions/{SetupBuildCredentialsFromCredentialsJson.js → SetUpBuildCredentialsFromCredentialsJson.js} +3 -3
  39. package/build/credentials/android/actions/{SetupGoogleServiceAccountKey.d.ts → SetUpGoogleServiceAccountKey.d.ts} +1 -1
  40. package/build/credentials/android/actions/{SetupGoogleServiceAccountKey.js → SetUpGoogleServiceAccountKey.js} +3 -3
  41. package/build/credentials/android/api/graphql/queries/GoogleServiceAccountKeyQuery.js +2 -0
  42. package/build/credentials/credentialsJson/update.js +5 -4
  43. package/build/credentials/errors.d.ts +4 -0
  44. package/build/credentials/errors.js +8 -1
  45. package/build/credentials/ios/IosCredentialsProvider.js +4 -4
  46. package/build/credentials/ios/actions/AscApiKeyUtils.d.ts +17 -1
  47. package/build/credentials/ios/actions/AscApiKeyUtils.js +156 -23
  48. package/build/credentials/ios/actions/AssignAscApiKey.d.ts +9 -0
  49. package/build/credentials/ios/actions/AssignAscApiKey.js +29 -0
  50. package/build/credentials/ios/actions/CreateAscApiKey.d.ts +9 -0
  51. package/build/credentials/ios/actions/CreateAscApiKey.js +21 -0
  52. package/build/credentials/ios/actions/CreateDistributionCertificate.js +1 -1
  53. package/build/credentials/ios/actions/CreatePushKey.js +1 -1
  54. package/build/credentials/ios/actions/DistributionCertificateUtils.d.ts +1 -1
  55. package/build/credentials/ios/actions/DistributionCertificateUtils.js +6 -8
  56. package/build/credentials/ios/actions/PushKeyUtils.d.ts +1 -1
  57. package/build/credentials/ios/actions/PushKeyUtils.js +6 -6
  58. package/build/credentials/ios/actions/RemoveAscApiKey.d.ts +14 -0
  59. package/build/credentials/ios/actions/RemoveAscApiKey.js +55 -0
  60. package/build/credentials/ios/actions/{SetupAdhocProvisioningProfile.d.ts → SetUpAdhocProvisioningProfile.d.ts} +1 -1
  61. package/build/credentials/ios/actions/{SetupAdhocProvisioningProfile.js → SetUpAdhocProvisioningProfile.js} +5 -5
  62. package/build/credentials/ios/actions/SetUpAscApiKey.d.ts +21 -0
  63. package/build/credentials/ios/actions/SetUpAscApiKey.js +114 -0
  64. package/build/credentials/ios/actions/{SetupBuildCredentials.d.ts → SetUpBuildCredentials.d.ts} +1 -1
  65. package/build/credentials/ios/actions/{SetupBuildCredentials.js → SetUpBuildCredentials.js} +5 -5
  66. package/build/credentials/ios/actions/{SetupBuildCredentialsFromCredentialsJson.d.ts → SetUpBuildCredentialsFromCredentialsJson.d.ts} +1 -1
  67. package/build/credentials/ios/actions/{SetupBuildCredentialsFromCredentialsJson.js → SetUpBuildCredentialsFromCredentialsJson.js} +5 -5
  68. package/build/credentials/ios/actions/{SetupDistributionCertificate.d.ts → SetUpDistributionCertificate.d.ts} +1 -1
  69. package/build/credentials/ios/actions/{SetupDistributionCertificate.js → SetUpDistributionCertificate.js} +3 -3
  70. package/build/credentials/ios/actions/{SetupInternalProvisioningProfile.d.ts → SetUpInternalProvisioningProfile.d.ts} +1 -1
  71. package/build/credentials/ios/actions/{SetupInternalProvisioningProfile.js → SetUpInternalProvisioningProfile.js} +7 -7
  72. package/build/credentials/ios/actions/{SetupProvisioningProfile.d.ts → SetUpProvisioningProfile.d.ts} +1 -1
  73. package/build/credentials/ios/actions/{SetupProvisioningProfile.js → SetUpProvisioningProfile.js} +5 -5
  74. package/build/credentials/ios/actions/{SetupPushKey.d.ts → SetUpPushKey.d.ts} +1 -1
  75. package/build/credentials/ios/actions/{SetupPushKey.js → SetUpPushKey.js} +3 -3
  76. package/build/credentials/ios/actions/SetUpSubmissionCredentials.d.ts +10 -0
  77. package/build/credentials/ios/actions/SetUpSubmissionCredentials.js +53 -0
  78. package/build/credentials/ios/actions/{SetupTargetBuildCredentials.d.ts → SetUpTargetBuildCredentials.d.ts} +1 -1
  79. package/build/credentials/ios/actions/{SetupTargetBuildCredentials.js → SetUpTargetBuildCredentials.js} +10 -10
  80. package/build/credentials/ios/actions/{SetupTargetBuildCredentialsFromCredentialsJson.d.ts → SetUpTargetBuildCredentialsFromCredentialsJson.d.ts} +1 -1
  81. package/build/credentials/ios/actions/{SetupTargetBuildCredentialsFromCredentialsJson.js → SetUpTargetBuildCredentialsFromCredentialsJson.js} +3 -3
  82. package/build/credentials/ios/api/GraphqlClient.d.ts +8 -2
  83. package/build/credentials/ios/api/GraphqlClient.js +74 -2
  84. package/build/credentials/ios/api/graphql/mutations/AppStoreConnectApiKeyMutation.d.ts +5 -0
  85. package/build/credentials/ios/api/graphql/mutations/AppStoreConnectApiKeyMutation.js +54 -0
  86. package/build/credentials/ios/api/graphql/mutations/IosAppCredentialsMutation.d.ts +1 -0
  87. package/build/credentials/ios/api/graphql/mutations/IosAppCredentialsMutation.js +25 -0
  88. package/build/credentials/ios/api/graphql/queries/AppQuery.js +3 -1
  89. package/build/credentials/ios/api/graphql/queries/AppStoreConnectApiKeyQuery.d.ts +4 -0
  90. package/build/credentials/ios/api/graphql/queries/AppStoreConnectApiKeyQuery.js +33 -0
  91. package/build/credentials/ios/api/graphql/queries/AppleDeviceQuery.js +6 -2
  92. package/build/credentials/ios/api/graphql/queries/AppleDistributionCertificateQuery.js +7 -1
  93. package/build/credentials/ios/api/graphql/queries/AppleProvisioningProfileQuery.js +5 -1
  94. package/build/credentials/ios/api/graphql/queries/ApplePushKeyQuery.js +2 -0
  95. package/build/credentials/ios/api/graphql/queries/AppleTeamQuery.js +5 -1
  96. package/build/credentials/ios/appstore/AppStoreApi.d.ts +1 -1
  97. package/build/credentials/ios/appstore/Credentials.types.d.ts +1 -0
  98. package/build/credentials/ios/appstore/ascApiKey.d.ts +1 -1
  99. package/build/credentials/ios/appstore/ascApiKey.js +22 -12
  100. package/build/credentials/ios/credentials.d.ts +2 -1
  101. package/build/credentials/ios/credentials.js +8 -3
  102. package/build/credentials/ios/utils/printCredentials.js +30 -1
  103. package/build/credentials/ios/validators/validateAscApiKey.d.ts +5 -0
  104. package/build/credentials/ios/validators/validateAscApiKey.js +21 -0
  105. package/build/credentials/manager/Actions.d.ts +52 -0
  106. package/build/credentials/manager/Actions.js +53 -0
  107. package/build/credentials/manager/AndroidActions.d.ts +6 -0
  108. package/build/credentials/manager/AndroidActions.js +114 -0
  109. package/build/credentials/manager/IosActions.d.ts +7 -0
  110. package/build/credentials/manager/IosActions.js +145 -0
  111. package/build/credentials/manager/ManageAndroid.d.ts +1 -29
  112. package/build/credentials/manager/ManageAndroid.js +30 -163
  113. package/build/credentials/manager/ManageIos.d.ts +1 -29
  114. package/build/credentials/manager/ManageIos.js +78 -166
  115. package/build/credentials/utils/promptForCredentials.d.ts +2 -1
  116. package/build/credentials/utils/promptForCredentials.js +3 -2
  117. package/build/graphql/client.d.ts +8 -2
  118. package/build/graphql/client.js +1 -1
  119. package/build/graphql/generated.d.ts +170 -33
  120. package/build/graphql/generated.js +23 -1
  121. package/build/graphql/queries/BuildQuery.js +4 -1
  122. package/build/graphql/queries/EnvironmentSecretsQuery.js +4 -2
  123. package/build/graphql/queries/ProjectQuery.js +3 -1
  124. package/build/graphql/queries/PublishQuery.js +4 -1
  125. package/build/graphql/queries/SubmissionQuery.js +5 -2
  126. package/build/graphql/queries/UserQuery.js +4 -1
  127. package/build/graphql/queries/WebhookQuery.js +6 -2
  128. package/build/graphql/types/Build.js +1 -6
  129. package/build/graphql/types/credentials/AppStoreConnectApiKey.d.ts +1 -0
  130. package/build/graphql/types/credentials/AppStoreConnectApiKey.js +23 -0
  131. package/build/graphql/types/credentials/IosAppCredentials.js +6 -0
  132. package/build/log.d.ts +0 -2
  133. package/build/log.js +2 -12
  134. package/build/project/projectUtils.js +1 -1
  135. package/build/project/publish.js +2 -2
  136. package/build/project/workflow.js +2 -2
  137. package/build/submit/ArchiveSource.js +6 -5
  138. package/build/submit/android/ServiceAccountSource.js +2 -2
  139. package/build/submit/ios/AppSpecificPasswordSource.d.ts +2 -6
  140. package/build/submit/ios/AppSpecificPasswordSource.js +0 -18
  141. package/build/submit/ios/AscApiKeySource.d.ts +9 -3
  142. package/build/submit/ios/AscApiKeySource.js +10 -10
  143. package/build/submit/ios/CredentialsServiceSource.d.ts +14 -0
  144. package/build/submit/ios/CredentialsServiceSource.js +46 -0
  145. package/build/submit/ios/IosSubmitCommand.js +22 -14
  146. package/build/submit/ios/IosSubmitter.d.ts +3 -0
  147. package/build/submit/ios/IosSubmitter.js +30 -20
  148. package/build/submit/utils/errors.js +2 -0
  149. package/build/user/User.js +1 -0
  150. package/build/utils/easCli.d.ts +1 -0
  151. package/build/utils/easCli.js +5 -0
  152. package/build/utils/{expoCommand.d.ts → expoCli.d.ts} +0 -0
  153. package/build/utils/{expoCommand.js → expoCli.js} +0 -0
  154. package/build/utils/profiles.js +9 -2
  155. package/build/vcs/clients/git.d.ts +26 -0
  156. package/build/vcs/clients/git.js +184 -0
  157. package/build/vcs/clients/gitNoCommit.d.ts +7 -0
  158. package/build/vcs/clients/gitNoCommit.js +27 -0
  159. package/build/vcs/clients/noVcs.d.ts +6 -0
  160. package/build/vcs/clients/noVcs.js +19 -0
  161. package/build/vcs/git.d.ts +10 -17
  162. package/build/vcs/git.js +7 -175
  163. package/build/vcs/index.d.ts +2 -2
  164. package/build/vcs/index.js +15 -6
  165. package/build/vcs/local.d.ts +18 -5
  166. package/build/vcs/local.js +61 -32
  167. package/build/vcs/vcs.d.ts +2 -1
  168. package/build/vcs/vcs.js +8 -4
  169. package/oclif.manifest.json +1 -1
  170. package/package.json +10 -10
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProfilesAsync = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const eas_json_1 = require("@expo/eas-json");
5
6
  const log_1 = (0, tslib_1.__importDefault)(require("../log"));
6
7
  async function getProfilesAsync({ platforms, profileName: profileNameArg,
7
8
  // eslint-disable-next-line async-protect/async-suffix
@@ -14,13 +15,19 @@ readProfileAsync, }) {
14
15
  profile = await readProfileAsync(platform, 'production');
15
16
  profileName = 'production';
16
17
  }
17
- catch (error) {
18
+ catch (errorOuter) {
19
+ if (errorOuter instanceof eas_json_1.errors.InvalidEasJsonError) {
20
+ throw errorOuter;
21
+ }
18
22
  try {
19
23
  profile = await readProfileAsync(platform, 'release');
20
24
  profileName = 'release';
21
25
  log_1.default.warn('The default profile changed from "release" to "production". We detected that you still have a "release" build profile, so we are using it. Update eas.json to have a profile named "production" under the `build` key, or specify which profile you\'d like to use with the --profile flag. This fallback behavior will be removed in the next major version of EAS CLI.');
22
26
  }
23
- catch (error) {
27
+ catch (errorInner) {
28
+ if (errorInner instanceof eas_json_1.errors.InvalidEasJsonError) {
29
+ throw errorInner;
30
+ }
24
31
  throw new Error('There is no profile named "production" in eas.json');
25
32
  }
26
33
  }
@@ -0,0 +1,26 @@
1
+ import { Client } from '../vcs';
2
+ export default class GitClient extends Client {
3
+ ensureRepoExistsAsync(): Promise<void>;
4
+ commitAsync({ commitMessage, commitAllFiles, }: {
5
+ commitMessage: string;
6
+ commitAllFiles?: boolean;
7
+ }): Promise<void>;
8
+ isCommitRequiredAsync(): Promise<boolean>;
9
+ hasUncommittedChangesAsync(): Promise<boolean>;
10
+ getRootPathAsync(): Promise<string>;
11
+ makeShallowCopyAsync(destinationPath: string): Promise<void>;
12
+ getCommitHashAsync(): Promise<string | undefined>;
13
+ trackFileAsync(file: string): Promise<void>;
14
+ getBranchNameAsync(): Promise<string | null>;
15
+ getLastCommitMessageAsync(): Promise<string | null>;
16
+ showDiffAsync(): Promise<void>;
17
+ isFileUntrackedAsync(path: string): Promise<boolean>;
18
+ isFileIgnoredAsync(filePath: string): Promise<boolean>;
19
+ }
20
+ /**
21
+ * Checks if git is configured to be case sensitive
22
+ * @returns {boolean | undefined}
23
+ * - boolean - is git case sensitive
24
+ * - undefined - case sensitivity is not configured and git is using default behavior
25
+ */
26
+ export declare function isGitCaseSensitiveAsync(): Promise<boolean | undefined>;
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isGitCaseSensitiveAsync = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const spawn_async_1 = (0, tslib_1.__importDefault)(require("@expo/spawn-async"));
6
+ const log_1 = (0, tslib_1.__importStar)(require("../../log"));
7
+ const prompts_1 = require("../../prompts");
8
+ const git_1 = require("../git");
9
+ const vcs_1 = require("../vcs");
10
+ class GitClient extends vcs_1.Client {
11
+ async ensureRepoExistsAsync() {
12
+ if (!(await (0, git_1.isGitInstalledAsync)())) {
13
+ throw new Error('git command not found, install it before proceeding');
14
+ }
15
+ if (await (0, git_1.doesGitRepoExistAsync)()) {
16
+ return;
17
+ }
18
+ log_1.default.warn("It looks like you haven't initialized the git repository yet.");
19
+ log_1.default.warn('EAS Build requires you to use a git repository for your project.');
20
+ const confirmInit = await (0, prompts_1.confirmAsync)({
21
+ message: `Would you like us to run 'git init' in the current directory for you?`,
22
+ });
23
+ if (!confirmInit) {
24
+ throw new Error('A git repository is required for building your project. Initialize it and run this command again.');
25
+ }
26
+ await (0, spawn_async_1.default)('git', ['init']);
27
+ log_1.default.log("We're going to make an initial commit for your repository.");
28
+ const { message } = await (0, prompts_1.promptAsync)({
29
+ type: 'text',
30
+ name: 'message',
31
+ message: 'Commit message:',
32
+ initial: 'Initial commit',
33
+ validate: (input) => input !== '',
34
+ });
35
+ await this.commitAsync({ commitAllFiles: true, commitMessage: message });
36
+ }
37
+ async commitAsync({ commitMessage, commitAllFiles, }) {
38
+ if (commitAllFiles) {
39
+ await (0, spawn_async_1.default)('git', ['add', '-A']);
40
+ }
41
+ await (0, spawn_async_1.default)('git', ['add', '-u']);
42
+ await (0, spawn_async_1.default)('git', ['commit', '-m', commitMessage]);
43
+ }
44
+ async isCommitRequiredAsync() {
45
+ return await this.hasUncommittedChangesAsync();
46
+ }
47
+ async hasUncommittedChangesAsync() {
48
+ const changes = await (0, git_1.gitStatusAsync)({ showUntracked: true });
49
+ return changes.length > 0;
50
+ }
51
+ async getRootPathAsync() {
52
+ return (await (0, spawn_async_1.default)('git', ['rev-parse', '--show-toplevel'])).stdout.trim();
53
+ }
54
+ async makeShallowCopyAsync(destinationPath) {
55
+ if (await this.hasUncommittedChangesAsync()) {
56
+ // it should already be checked before this function is called, but in case it wasn't
57
+ // we want to ensure that any changes were introduced by call to `setGitCaseSensitivityAsync`
58
+ throw new Error('You have some uncommitted changes in your repository.');
59
+ }
60
+ let gitRepoUri;
61
+ if (process.platform === 'win32') {
62
+ // getRootDirectoryAsync() will return C:/path/to/repo on Windows and path
63
+ // prefix should be file:///
64
+ gitRepoUri = `file:///${await this.getRootPathAsync()}`;
65
+ }
66
+ else {
67
+ // getRootDirectoryAsync() will /path/to/repo, and path prefix should be
68
+ // file:/// so only file:// needs to be prepended
69
+ gitRepoUri = `file://${await this.getRootPathAsync()}`;
70
+ }
71
+ const isCaseSensitive = await isGitCaseSensitiveAsync();
72
+ await setGitCaseSensitivityAsync(true);
73
+ try {
74
+ if (await this.hasUncommittedChangesAsync()) {
75
+ log_1.default.error('Detected inconsistent filename casing between your local filesystem and git.');
76
+ log_1.default.error('This will likely cause your build to fail. Impacted files:');
77
+ await (0, spawn_async_1.default)('git', ['status', '--short'], { stdio: 'inherit' });
78
+ log_1.default.newLine();
79
+ log_1.default.error(`Error: Resolve filename casing inconsistencies before proceeding. ${(0, log_1.learnMore)('https://expo.fyi/macos-ignorecase')}`);
80
+ throw new Error('You have some uncommitted changes in your repository.');
81
+ }
82
+ await (0, spawn_async_1.default)('git', [
83
+ 'clone',
84
+ '--no-hardlinks',
85
+ '--depth',
86
+ '1',
87
+ gitRepoUri,
88
+ destinationPath,
89
+ ]);
90
+ }
91
+ finally {
92
+ await setGitCaseSensitivityAsync(isCaseSensitive);
93
+ }
94
+ }
95
+ async getCommitHashAsync() {
96
+ try {
97
+ return (await (0, spawn_async_1.default)('git', ['rev-parse', 'HEAD'])).stdout.trim();
98
+ }
99
+ catch (err) {
100
+ return undefined;
101
+ }
102
+ }
103
+ async trackFileAsync(file) {
104
+ await (0, spawn_async_1.default)('git', ['add', '--intent-to-add', file]);
105
+ }
106
+ async getBranchNameAsync() {
107
+ try {
108
+ return (await (0, spawn_async_1.default)('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).stdout.trim();
109
+ }
110
+ catch (e) {
111
+ return null;
112
+ }
113
+ }
114
+ async getLastCommitMessageAsync() {
115
+ try {
116
+ return (await (0, spawn_async_1.default)('git', ['--no-pager', 'log', '-1', '--pretty=%B'])).stdout.trim();
117
+ }
118
+ catch (e) {
119
+ return null;
120
+ }
121
+ }
122
+ async showDiffAsync() {
123
+ const outputTooLarge = (await (0, git_1.getGitDiffOutputAsync)()).split(/\r\n|\r|\n/).length > 100;
124
+ await (0, git_1.gitDiffAsync)({ withPager: outputTooLarge });
125
+ }
126
+ async isFileUntrackedAsync(path) {
127
+ const withUntrackedFiles = await (0, git_1.gitStatusAsync)({ showUntracked: true });
128
+ const trackedFiles = await (0, git_1.gitStatusAsync)({ showUntracked: false });
129
+ const pathWithoutLeadingDot = path.replace(/^\.\//, ''); // remove leading './' from path
130
+ return (withUntrackedFiles.includes(pathWithoutLeadingDot) &&
131
+ !trackedFiles.includes(pathWithoutLeadingDot));
132
+ }
133
+ async isFileIgnoredAsync(filePath) {
134
+ try {
135
+ await (0, spawn_async_1.default)('git', ['check-ignore', '-q', filePath]);
136
+ return true;
137
+ }
138
+ catch (e) {
139
+ return false;
140
+ }
141
+ }
142
+ }
143
+ exports.default = GitClient;
144
+ /**
145
+ * Checks if git is configured to be case sensitive
146
+ * @returns {boolean | undefined}
147
+ * - boolean - is git case sensitive
148
+ * - undefined - case sensitivity is not configured and git is using default behavior
149
+ */
150
+ async function isGitCaseSensitiveAsync() {
151
+ if (process.platform !== 'darwin') {
152
+ return undefined;
153
+ }
154
+ try {
155
+ const result = await (0, spawn_async_1.default)('git', ['config', '--get', 'core.ignorecase']);
156
+ const isIgnoreCaseEnabled = result.stdout.trim();
157
+ if (isIgnoreCaseEnabled === '') {
158
+ return undefined;
159
+ }
160
+ else if (isIgnoreCaseEnabled === 'true') {
161
+ return false;
162
+ }
163
+ else {
164
+ return true;
165
+ }
166
+ }
167
+ catch (e) {
168
+ return undefined;
169
+ }
170
+ }
171
+ exports.isGitCaseSensitiveAsync = isGitCaseSensitiveAsync;
172
+ async function setGitCaseSensitivityAsync(enable) {
173
+ // we are assuming that if someone sets that on non-macos device then
174
+ // they know what they are doing
175
+ if (process.platform !== 'darwin') {
176
+ return;
177
+ }
178
+ if (enable === undefined) {
179
+ await (0, spawn_async_1.default)('git', ['config', '--unset', 'core.ignorecase']);
180
+ }
181
+ else {
182
+ await (0, spawn_async_1.default)('git', ['config', 'core.ignorecase', String(!enable)]);
183
+ }
184
+ }
@@ -0,0 +1,7 @@
1
+ import GitClient from './git';
2
+ export default class GitNoCommitClient extends GitClient {
3
+ isCommitRequiredAsync(): Promise<boolean>;
4
+ getRootPathAsync(): Promise<string>;
5
+ makeShallowCopyAsync(destinationPath: string): Promise<void>;
6
+ isFileIgnoredAsync(filePath: string): Promise<boolean>;
7
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const spawn_async_1 = (0, tslib_1.__importDefault)(require("@expo/spawn-async"));
5
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
6
+ const local_1 = require("../local");
7
+ const git_1 = (0, tslib_1.__importDefault)(require("./git"));
8
+ class GitNoCommitClient extends git_1.default {
9
+ async isCommitRequiredAsync() {
10
+ return false;
11
+ }
12
+ async getRootPathAsync() {
13
+ return (await (0, spawn_async_1.default)('git', ['rev-parse', '--show-toplevel'])).stdout.trim();
14
+ }
15
+ async makeShallowCopyAsync(destinationPath) {
16
+ // normalize converts C:/some/path to C:\some\path on windows
17
+ const srcPath = path_1.default.normalize(await this.getRootPathAsync());
18
+ await (0, local_1.makeShallowCopyAsync)(srcPath, destinationPath);
19
+ }
20
+ async isFileIgnoredAsync(filePath) {
21
+ // normalize converts C:/some/path to C:\some\path on windows
22
+ const ignore = new local_1.Ignore(await this.getRootPathAsync());
23
+ await ignore.initIgnoreAsync();
24
+ return ignore.ignores(filePath);
25
+ }
26
+ }
27
+ exports.default = GitNoCommitClient;
@@ -0,0 +1,6 @@
1
+ import { Client } from '../vcs';
2
+ export default class NoVcsClient extends Client {
3
+ getRootPathAsync(): Promise<string>;
4
+ makeShallowCopyAsync(destinationPath: string): Promise<void>;
5
+ isFileIgnoredAsync(filePath: string): Promise<boolean>;
6
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const local_1 = require("../local");
4
+ const vcs_1 = require("../vcs");
5
+ class NoVcsClient extends vcs_1.Client {
6
+ async getRootPathAsync() {
7
+ return (0, local_1.getRootPath)();
8
+ }
9
+ async makeShallowCopyAsync(destinationPath) {
10
+ const srcPath = (0, local_1.getRootPath)();
11
+ await (0, local_1.makeShallowCopyAsync)(srcPath, destinationPath);
12
+ }
13
+ async isFileIgnoredAsync(filePath) {
14
+ const ignore = new local_1.Ignore((0, local_1.getRootPath)());
15
+ await ignore.initIgnoreAsync();
16
+ return ignore.ignores(filePath);
17
+ }
18
+ }
19
+ exports.default = NoVcsClient;
@@ -1,18 +1,11 @@
1
- import { Client } from './vcs';
2
- export default class GitClient extends Client {
3
- ensureRepoExistsAsync(): Promise<void>;
4
- commitAsync({ commitMessage, commitAllFiles, }: {
5
- commitMessage: string;
6
- commitAllFiles?: boolean;
7
- }): Promise<void>;
8
- hasUncommittedChangesAsync(): Promise<boolean>;
9
- getRootPathAsync(): Promise<string>;
10
- makeShallowCopyAsync(destinationPath: string): Promise<void>;
11
- getCommitHashAsync(): Promise<string | undefined>;
12
- trackFileAsync(file: string): Promise<void>;
13
- getBranchNameAsync(): Promise<string | null>;
14
- getLastCommitMessageAsync(): Promise<string | null>;
15
- showDiffAsync(): Promise<void>;
16
- isFileUntrackedAsync(path: string): Promise<boolean>;
17
- isFileIgnoredAsync(filePath: string): Promise<boolean>;
1
+ export declare function isGitInstalledAsync(): Promise<boolean>;
2
+ export declare function doesGitRepoExistAsync(): Promise<boolean>;
3
+ interface GitStatusOptions {
4
+ showUntracked?: boolean;
18
5
  }
6
+ export declare function gitStatusAsync({ showUntracked }?: GitStatusOptions): Promise<string>;
7
+ export declare function getGitDiffOutputAsync(): Promise<string>;
8
+ export declare function gitDiffAsync({ withPager, }?: {
9
+ withPager?: boolean;
10
+ }): Promise<void>;
11
+ export {};
package/build/vcs/git.js CHANGED
@@ -1,141 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gitDiffAsync = exports.getGitDiffOutputAsync = exports.gitStatusAsync = exports.doesGitRepoExistAsync = exports.isGitInstalledAsync = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const spawn_async_1 = (0, tslib_1.__importDefault)(require("@expo/spawn-async"));
5
- const log_1 = (0, tslib_1.__importStar)(require("../log"));
6
- const prompts_1 = require("../prompts");
7
- const vcs_1 = require("./vcs");
8
- class GitClient extends vcs_1.Client {
9
- async ensureRepoExistsAsync() {
10
- if (!(await isGitInstalledAsync())) {
11
- throw new Error('git command not found, install it before proceeding');
12
- }
13
- if (await doesGitRepoExistAsync()) {
14
- return;
15
- }
16
- log_1.default.warn("It looks like you haven't initialized the git repository yet.");
17
- log_1.default.warn('EAS Build requires you to use a git repository for your project.');
18
- const confirmInit = await (0, prompts_1.confirmAsync)({
19
- message: `Would you like to run 'git init' in the current directory?`,
20
- });
21
- if (!confirmInit) {
22
- throw new Error('A git repository is required for building your project. Initialize it and run this command again.');
23
- }
24
- await (0, spawn_async_1.default)('git', ['init']);
25
- log_1.default.log("We're going to make an initial commit for you repository.");
26
- const { message } = await (0, prompts_1.promptAsync)({
27
- type: 'text',
28
- name: 'message',
29
- message: 'Commit message:',
30
- initial: 'Initial commit',
31
- validate: (input) => input !== '',
32
- });
33
- await this.commitAsync({ commitAllFiles: true, commitMessage: message });
34
- }
35
- async commitAsync({ commitMessage, commitAllFiles, }) {
36
- if (commitAllFiles) {
37
- await (0, spawn_async_1.default)('git', ['add', '-A']);
38
- }
39
- await (0, spawn_async_1.default)('git', ['add', '-u']);
40
- await (0, spawn_async_1.default)('git', ['commit', '-m', commitMessage]);
41
- }
42
- async hasUncommittedChangesAsync() {
43
- const changes = await gitStatusAsync({ showUntracked: true });
44
- return changes.length > 0;
45
- }
46
- async getRootPathAsync() {
47
- return (await (0, spawn_async_1.default)('git', ['rev-parse', '--show-toplevel'])).stdout.trim();
48
- }
49
- async makeShallowCopyAsync(destinationPath) {
50
- if (await this.hasUncommittedChangesAsync()) {
51
- // it should not happen, we need that to make sure that check before clone
52
- // is always caused by case sensitivity
53
- throw new Error('You have some uncommitted changes in your repository.');
54
- }
55
- let gitRepoUri;
56
- if (process.platform === 'win32') {
57
- // getRootDirectoryAsync() will return C:/path/to/repo on Windows and path
58
- // prefix should be file:///
59
- gitRepoUri = `file:///${await this.getRootPathAsync()}`;
60
- }
61
- else {
62
- // getRootDirectoryAsync() will /path/to/repo, and path prefix should be
63
- // file:/// so only file:// needs to be prepended
64
- gitRepoUri = `file://${await this.getRootPathAsync()}`;
65
- }
66
- const isCaseSensitive = await isGitCaseSensitiveAsync();
67
- await setGitCaseSensitivityAsync(true);
68
- try {
69
- if (await this.hasUncommittedChangesAsync()) {
70
- log_1.default.error('Detected inconsistent filename casing between your local filesystem and git.');
71
- log_1.default.error('This will likely cause your build to fail. Impacted files:');
72
- await (0, spawn_async_1.default)('git', ['status', '--short'], { stdio: 'inherit' });
73
- log_1.default.newLine();
74
- log_1.default.error(`Error: Resolve filename casing inconsistencies before proceeding. ${(0, log_1.learnMore)('https://expo.fyi/macos-ignorecase')}`);
75
- throw new Error('You have some uncommitted changes in your repository.');
76
- }
77
- await (0, spawn_async_1.default)('git', [
78
- 'clone',
79
- '--no-hardlinks',
80
- '--depth',
81
- '1',
82
- gitRepoUri,
83
- destinationPath,
84
- ]);
85
- }
86
- finally {
87
- await setGitCaseSensitivityAsync(isCaseSensitive);
88
- }
89
- }
90
- async getCommitHashAsync() {
91
- try {
92
- return (await (0, spawn_async_1.default)('git', ['rev-parse', 'HEAD'])).stdout.trim();
93
- }
94
- catch (err) {
95
- return undefined;
96
- }
97
- }
98
- async trackFileAsync(file) {
99
- await (0, spawn_async_1.default)('git', ['add', '--intent-to-add', file]);
100
- }
101
- async getBranchNameAsync() {
102
- try {
103
- return (await (0, spawn_async_1.default)('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).stdout.trim();
104
- }
105
- catch (e) {
106
- return null;
107
- }
108
- }
109
- async getLastCommitMessageAsync() {
110
- try {
111
- return (await (0, spawn_async_1.default)('git', ['--no-pager', 'log', '-1', '--pretty=%B'])).stdout.trim();
112
- }
113
- catch (e) {
114
- return null;
115
- }
116
- }
117
- async showDiffAsync() {
118
- const outputTooLarge = (await getGitDiffOutputAsync()).split(/\r\n|\r|\n/).length > 100;
119
- await gitDiffAsync({ withPager: outputTooLarge });
120
- }
121
- async isFileUntrackedAsync(path) {
122
- const withUntrackedFiles = await gitStatusAsync({ showUntracked: true });
123
- const trackedFiles = await gitStatusAsync({ showUntracked: false });
124
- const pathWithoutLeadingDot = path.replace(/^\.\//, ''); // remove leading './' from path
125
- return (withUntrackedFiles.includes(pathWithoutLeadingDot) &&
126
- !trackedFiles.includes(pathWithoutLeadingDot));
127
- }
128
- async isFileIgnoredAsync(filePath) {
129
- try {
130
- await (0, spawn_async_1.default)('git', ['check-ignore', '-q', filePath]);
131
- return true;
132
- }
133
- catch (e) {
134
- return false;
135
- }
136
- }
137
- }
138
- exports.default = GitClient;
139
6
  async function isGitInstalledAsync() {
140
7
  try {
141
8
  await (0, spawn_async_1.default)('git', ['--help']);
@@ -148,6 +15,7 @@ async function isGitInstalledAsync() {
148
15
  }
149
16
  return true;
150
17
  }
18
+ exports.isGitInstalledAsync = isGitInstalledAsync;
151
19
  async function doesGitRepoExistAsync() {
152
20
  try {
153
21
  await (0, spawn_async_1.default)('git', ['rev-parse', '--git-dir']);
@@ -157,53 +25,17 @@ async function doesGitRepoExistAsync() {
157
25
  return false;
158
26
  }
159
27
  }
28
+ exports.doesGitRepoExistAsync = doesGitRepoExistAsync;
160
29
  async function gitStatusAsync({ showUntracked } = {}) {
161
30
  return (await (0, spawn_async_1.default)('git', ['status', '-s', showUntracked ? '-uall' : '-uno'])).stdout;
162
31
  }
32
+ exports.gitStatusAsync = gitStatusAsync;
163
33
  async function getGitDiffOutputAsync() {
164
34
  return (await (0, spawn_async_1.default)('git', ['--no-pager', 'diff'])).stdout;
165
35
  }
166
- async function gitDiffAsync({ withPager = false } = {}) {
36
+ exports.getGitDiffOutputAsync = getGitDiffOutputAsync;
37
+ async function gitDiffAsync({ withPager = false, } = {}) {
167
38
  const options = withPager ? [] : ['--no-pager'];
168
39
  await (0, spawn_async_1.default)('git', [...options, 'diff'], { stdio: ['ignore', 'inherit', 'inherit'] });
169
40
  }
170
- /**
171
- * Checks if git is configured to be case sensitive
172
- * @returns {boolean | undefined}
173
- * - boolean - is git case senstive
174
- * - undefined - case sensitivity is not configured and git is using default behavior
175
- */
176
- async function isGitCaseSensitiveAsync() {
177
- if (process.platform !== 'darwin') {
178
- return undefined;
179
- }
180
- try {
181
- const result = await (0, spawn_async_1.default)('git', ['config', '--get', 'core.ignorecase']);
182
- const isIgnoreCaseEnabled = result.stdout.trim();
183
- if (isIgnoreCaseEnabled === '') {
184
- return undefined;
185
- }
186
- else if (isIgnoreCaseEnabled === 'true') {
187
- return false;
188
- }
189
- else {
190
- return true;
191
- }
192
- }
193
- catch (e) {
194
- return undefined;
195
- }
196
- }
197
- async function setGitCaseSensitivityAsync(enable) {
198
- // we are assuming that if someone sets that on non-macos device then
199
- // they know what they are doing
200
- if (process.platform !== 'darwin') {
201
- return;
202
- }
203
- if (enable === undefined) {
204
- await (0, spawn_async_1.default)('git', ['config', '--unset', 'core.ignorecase']);
205
- }
206
- else {
207
- await (0, spawn_async_1.default)('git', ['config', 'core.ignorecase', String(!enable)]);
208
- }
209
- }
41
+ exports.gitDiffAsync = gitDiffAsync;
@@ -1,3 +1,3 @@
1
1
  import { Client } from './vcs';
2
- declare const _default: Client;
3
- export default _default;
2
+ export declare function setVcsClient(client: Client): void;
3
+ export declare function getVcsClient(): Client;
@@ -1,17 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVcsClient = exports.setVcsClient = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const log_1 = (0, tslib_1.__importDefault)(require("../log"));
5
- const git_1 = (0, tslib_1.__importDefault)(require("./git"));
6
- const local_1 = (0, tslib_1.__importDefault)(require("./local"));
6
+ const gitNoCommit_1 = (0, tslib_1.__importDefault)(require("./clients/gitNoCommit"));
7
+ const noVcs_1 = (0, tslib_1.__importDefault)(require("./clients/noVcs"));
7
8
  const NO_VCS_WARNING = `Using EAS CLI without version control system is not recommended, use this mode only if you know what you are doing.`;
8
- function resolveVcsClient() {
9
+ let vcsClient = resolveDefaultVcsClient();
10
+ function resolveDefaultVcsClient() {
9
11
  if (process.env.EAS_NO_VCS) {
10
12
  if (process.env.NODE_ENV !== 'test') {
11
13
  log_1.default.warn(NO_VCS_WARNING);
12
14
  }
13
- return new local_1.default();
15
+ return new noVcs_1.default();
14
16
  }
15
- return new git_1.default();
17
+ return new gitNoCommit_1.default();
16
18
  }
17
- exports.default = resolveVcsClient();
19
+ function setVcsClient(client) {
20
+ vcsClient = client;
21
+ }
22
+ exports.setVcsClient = setVcsClient;
23
+ function getVcsClient() {
24
+ return vcsClient;
25
+ }
26
+ exports.getVcsClient = getVcsClient;
@@ -1,6 +1,19 @@
1
- import { Client } from './vcs';
2
- export default class LocalClient extends Client {
3
- getRootPathAsync(): Promise<string>;
4
- makeShallowCopyAsync(destinationPath: string): Promise<void>;
5
- isFileIgnoredAsync(filePath: string): Promise<boolean>;
1
+ export declare function getRootPath(): string;
2
+ /**
3
+ * Ignore wraps the 'ignore' package to support multiple .gitignore files
4
+ * in subdirectories.
5
+ *
6
+ * Inconsistencies with git behavior:
7
+ * - if parent .gitignore has ignore rule and child has exception to that rule,
8
+ * file will still be ignored,
9
+ * - node_modules is always ignored,
10
+ * - if .easignore exists, .gitignore files are not used.
11
+ */
12
+ export declare class Ignore {
13
+ private rootDir;
14
+ private ignoreMapping;
15
+ constructor(rootDir: string);
16
+ initIgnoreAsync(): Promise<void>;
17
+ ignores(relativePath: string): boolean;
6
18
  }
19
+ export declare function makeShallowCopyAsync(src: string, dst: string): Promise<void>;