@datadog/datadog-ci-base 5.7.0 → 5.9.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 (204) hide show
  1. package/dist/cli.d.ts +13 -1
  2. package/dist/cli.js +76 -33
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/aas/common.d.ts +13 -2
  5. package/dist/commands/aas/common.js +46 -24
  6. package/dist/commands/aas/common.js.map +1 -1
  7. package/dist/commands/aas/instrument.js +1 -1
  8. package/dist/commands/aas/instrument.js.map +1 -1
  9. package/dist/commands/aas/uninstrument.js +1 -1
  10. package/dist/commands/aas/uninstrument.js.map +1 -1
  11. package/dist/commands/ci-env/cli.d.ts +2 -0
  12. package/dist/commands/ci-env/cli.js +10 -0
  13. package/dist/commands/ci-env/cli.js.map +1 -0
  14. package/dist/commands/ci-env/read.d.ts +7 -0
  15. package/dist/commands/ci-env/read.js +176 -0
  16. package/dist/commands/ci-env/read.js.map +1 -0
  17. package/dist/commands/cloud-run/constants.js +1 -2
  18. package/dist/commands/cloud-run/constants.js.map +1 -1
  19. package/dist/commands/container-app/common.js +10 -11
  20. package/dist/commands/container-app/common.js.map +1 -1
  21. package/dist/commands/coverage/upload.d.ts +2 -0
  22. package/dist/commands/coverage/upload.js +6 -0
  23. package/dist/commands/coverage/upload.js.map +1 -1
  24. package/dist/commands/elf-symbols/cli.d.ts +2 -0
  25. package/dist/commands/elf-symbols/cli.js +10 -0
  26. package/dist/commands/elf-symbols/cli.js.map +1 -0
  27. package/dist/commands/elf-symbols/elf-constants.d.ts +256 -0
  28. package/dist/commands/elf-symbols/elf-constants.js +465 -0
  29. package/dist/commands/elf-symbols/elf-constants.js.map +1 -0
  30. package/dist/commands/elf-symbols/elf.d.ts +105 -0
  31. package/dist/commands/elf-symbols/elf.js +431 -0
  32. package/dist/commands/elf-symbols/elf.js.map +1 -0
  33. package/dist/commands/elf-symbols/helpers.d.ts +4 -0
  34. package/dist/commands/elf-symbols/helpers.js +29 -0
  35. package/dist/commands/elf-symbols/helpers.js.map +1 -0
  36. package/dist/commands/elf-symbols/interfaces.d.ts +18 -0
  37. package/dist/commands/elf-symbols/interfaces.js +7 -0
  38. package/dist/commands/elf-symbols/interfaces.js.map +1 -0
  39. package/dist/commands/elf-symbols/renderer.d.ts +19 -0
  40. package/dist/commands/elf-symbols/renderer.js +87 -0
  41. package/dist/commands/elf-symbols/renderer.js.map +1 -0
  42. package/dist/commands/elf-symbols/upload.d.ts +31 -0
  43. package/dist/commands/elf-symbols/upload.js +412 -0
  44. package/dist/commands/elf-symbols/upload.js.map +1 -0
  45. package/dist/commands/flutter-symbols/cli.d.ts +2 -0
  46. package/dist/commands/flutter-symbols/cli.js +10 -0
  47. package/dist/commands/flutter-symbols/cli.js.map +1 -0
  48. package/dist/commands/flutter-symbols/helpers.d.ts +8 -0
  49. package/dist/commands/flutter-symbols/helpers.js +51 -0
  50. package/dist/commands/flutter-symbols/helpers.js.map +1 -0
  51. package/dist/commands/flutter-symbols/interfaces.d.ts +17 -0
  52. package/dist/commands/flutter-symbols/interfaces.js +10 -0
  53. package/dist/commands/flutter-symbols/interfaces.js.map +1 -0
  54. package/dist/commands/flutter-symbols/renderer.d.ts +23 -0
  55. package/dist/commands/flutter-symbols/renderer.js +106 -0
  56. package/dist/commands/flutter-symbols/renderer.js.map +1 -0
  57. package/dist/commands/flutter-symbols/upload.d.ts +44 -0
  58. package/dist/commands/flutter-symbols/upload.js +510 -0
  59. package/dist/commands/flutter-symbols/upload.js.map +1 -0
  60. package/dist/commands/lambda/cli.d.ts +2 -1
  61. package/dist/commands/lambda/cli.js +2 -0
  62. package/dist/commands/lambda/cli.js.map +1 -1
  63. package/dist/commands/lambda/cloudwatch.d.ts +15 -0
  64. package/dist/commands/lambda/cloudwatch.js +77 -0
  65. package/dist/commands/lambda/cloudwatch.js.map +1 -0
  66. package/dist/commands/measure/cli.d.ts +2 -0
  67. package/dist/commands/measure/cli.js +10 -0
  68. package/dist/commands/measure/cli.js.map +1 -0
  69. package/dist/commands/measure/measure.d.ts +18 -0
  70. package/dist/commands/measure/measure.js +171 -0
  71. package/dist/commands/measure/measure.js.map +1 -0
  72. package/dist/commands/pe-symbols/breakpad.d.ts +2 -0
  73. package/dist/commands/pe-symbols/breakpad.js +159 -0
  74. package/dist/commands/pe-symbols/breakpad.js.map +1 -0
  75. package/dist/commands/pe-symbols/cli.d.ts +2 -0
  76. package/dist/commands/pe-symbols/cli.js +10 -0
  77. package/dist/commands/pe-symbols/cli.js.map +1 -0
  78. package/dist/commands/pe-symbols/helpers.d.ts +4 -0
  79. package/dist/commands/pe-symbols/helpers.js +30 -0
  80. package/dist/commands/pe-symbols/helpers.js.map +1 -0
  81. package/dist/commands/pe-symbols/interfaces.d.ts +17 -0
  82. package/dist/commands/pe-symbols/interfaces.js +7 -0
  83. package/dist/commands/pe-symbols/interfaces.js.map +1 -0
  84. package/dist/commands/pe-symbols/pe-constants.d.ts +51 -0
  85. package/dist/commands/pe-symbols/pe-constants.js +160 -0
  86. package/dist/commands/pe-symbols/pe-constants.js.map +1 -0
  87. package/dist/commands/pe-symbols/pe.d.ts +40 -0
  88. package/dist/commands/pe-symbols/pe.js +249 -0
  89. package/dist/commands/pe-symbols/pe.js.map +1 -0
  90. package/dist/commands/pe-symbols/renderer.d.ts +19 -0
  91. package/dist/commands/pe-symbols/renderer.js +87 -0
  92. package/dist/commands/pe-symbols/renderer.js.map +1 -0
  93. package/dist/commands/pe-symbols/upload.d.ts +34 -0
  94. package/dist/commands/pe-symbols/upload.js +457 -0
  95. package/dist/commands/pe-symbols/upload.js.map +1 -0
  96. package/dist/commands/react-native/cli.d.ts +5 -0
  97. package/dist/commands/react-native/cli.js +16 -0
  98. package/dist/commands/react-native/cli.js.map +1 -0
  99. package/dist/commands/react-native/codepush.d.ts +29 -0
  100. package/dist/commands/react-native/codepush.js +176 -0
  101. package/dist/commands/react-native/codepush.js.map +1 -0
  102. package/dist/commands/react-native/errors.d.ts +9 -0
  103. package/dist/commands/react-native/errors.js +34 -0
  104. package/dist/commands/react-native/errors.js.map +1 -0
  105. package/dist/commands/react-native/injectDebugId.d.ts +42 -0
  106. package/dist/commands/react-native/injectDebugId.js +252 -0
  107. package/dist/commands/react-native/injectDebugId.js.map +1 -0
  108. package/dist/commands/react-native/interfaces.d.ts +20 -0
  109. package/dist/commands/react-native/interfaces.js +93 -0
  110. package/dist/commands/react-native/interfaces.js.map +1 -0
  111. package/dist/commands/react-native/renderer.d.ts +20 -0
  112. package/dist/commands/react-native/renderer.js +111 -0
  113. package/dist/commands/react-native/renderer.js.map +1 -0
  114. package/dist/commands/react-native/upload.d.ts +30 -0
  115. package/dist/commands/react-native/upload.js +317 -0
  116. package/dist/commands/react-native/upload.js.map +1 -0
  117. package/dist/commands/react-native/utils.d.ts +4 -0
  118. package/dist/commands/react-native/utils.js +35 -0
  119. package/dist/commands/react-native/utils.js.map +1 -0
  120. package/dist/commands/react-native/validation.d.ts +6 -0
  121. package/dist/commands/react-native/validation.js +24 -0
  122. package/dist/commands/react-native/validation.js.map +1 -0
  123. package/dist/commands/react-native/xcode.d.ts +58 -0
  124. package/dist/commands/react-native/xcode.js +561 -0
  125. package/dist/commands/react-native/xcode.js.map +1 -0
  126. package/dist/commands/sourcemaps/cli.d.ts +2 -0
  127. package/dist/commands/sourcemaps/cli.js +10 -0
  128. package/dist/commands/sourcemaps/cli.js.map +1 -0
  129. package/dist/commands/sourcemaps/interfaces.d.ts +18 -0
  130. package/dist/commands/sourcemaps/interfaces.js +59 -0
  131. package/dist/commands/sourcemaps/interfaces.js.map +1 -0
  132. package/dist/commands/sourcemaps/renderer.d.ts +13 -0
  133. package/dist/commands/sourcemaps/renderer.js +93 -0
  134. package/dist/commands/sourcemaps/renderer.js.map +1 -0
  135. package/dist/commands/sourcemaps/upload.d.ts +29 -0
  136. package/dist/commands/sourcemaps/upload.js +342 -0
  137. package/dist/commands/sourcemaps/upload.js.map +1 -0
  138. package/dist/commands/sourcemaps/utils.d.ts +3 -0
  139. package/dist/commands/sourcemaps/utils.js +73 -0
  140. package/dist/commands/sourcemaps/utils.js.map +1 -0
  141. package/dist/commands/sourcemaps/validation.d.ts +7 -0
  142. package/dist/commands/sourcemaps/validation.js +41 -0
  143. package/dist/commands/sourcemaps/validation.js.map +1 -0
  144. package/dist/commands/span/cli.d.ts +2 -0
  145. package/dist/commands/span/cli.js +10 -0
  146. package/dist/commands/span/cli.js.map +1 -0
  147. package/dist/commands/span/span.d.ts +10 -0
  148. package/dist/commands/span/span.js +112 -0
  149. package/dist/commands/span/span.js.map +1 -0
  150. package/dist/commands/terraform/cli.d.ts +2 -0
  151. package/dist/commands/terraform/cli.js +10 -0
  152. package/dist/commands/terraform/cli.js.map +1 -0
  153. package/dist/commands/terraform/upload.d.ts +14 -0
  154. package/dist/commands/terraform/upload.js +93 -0
  155. package/dist/commands/terraform/upload.js.map +1 -0
  156. package/dist/commands/trace/api.d.ts +6 -0
  157. package/dist/commands/trace/api.js +38 -0
  158. package/dist/commands/trace/api.js.map +1 -0
  159. package/dist/commands/trace/cli.d.ts +2 -0
  160. package/dist/commands/trace/cli.js +10 -0
  161. package/dist/commands/trace/cli.js.map +1 -0
  162. package/dist/commands/trace/helper.d.ts +16 -0
  163. package/dist/commands/trace/helper.js +125 -0
  164. package/dist/commands/trace/helper.js.map +1 -0
  165. package/dist/commands/trace/interfaces.d.ts +18 -0
  166. package/dist/commands/trace/interfaces.js +14 -0
  167. package/dist/commands/trace/interfaces.js.map +1 -0
  168. package/dist/commands/trace/test-utils.d.ts +4 -0
  169. package/dist/commands/trace/test-utils.js +156 -0
  170. package/dist/commands/trace/test-utils.js.map +1 -0
  171. package/dist/commands/trace/trace.d.ts +10 -0
  172. package/dist/commands/trace/trace.js +110 -0
  173. package/dist/commands/trace/trace.js.map +1 -0
  174. package/dist/commands/unity-symbols/cli.d.ts +2 -0
  175. package/dist/commands/unity-symbols/cli.js +10 -0
  176. package/dist/commands/unity-symbols/cli.js.map +1 -0
  177. package/dist/commands/unity-symbols/helpers.d.ts +4 -0
  178. package/dist/commands/unity-symbols/helpers.js +29 -0
  179. package/dist/commands/unity-symbols/helpers.js.map +1 -0
  180. package/dist/commands/unity-symbols/interfaces.d.ts +14 -0
  181. package/dist/commands/unity-symbols/interfaces.js +9 -0
  182. package/dist/commands/unity-symbols/interfaces.js.map +1 -0
  183. package/dist/commands/unity-symbols/renderer.d.ts +19 -0
  184. package/dist/commands/unity-symbols/renderer.js +88 -0
  185. package/dist/commands/unity-symbols/renderer.js.map +1 -0
  186. package/dist/commands/unity-symbols/upload.d.ts +32 -0
  187. package/dist/commands/unity-symbols/upload.js +392 -0
  188. package/dist/commands/unity-symbols/upload.js.map +1 -0
  189. package/dist/commands/version/cli.d.ts +2 -0
  190. package/dist/commands/version/cli.js +10 -0
  191. package/dist/commands/version/cli.js.map +1 -0
  192. package/dist/commands/version/version.d.ts +6 -0
  193. package/dist/commands/version/version.js +31 -0
  194. package/dist/commands/version/version.js.map +1 -0
  195. package/dist/helpers/ci.js +50 -5
  196. package/dist/helpers/ci.js.map +1 -1
  197. package/dist/helpers/plugin.js +1 -1
  198. package/dist/helpers/plugin.js.map +1 -1
  199. package/dist/helpers/serverless/azure.d.ts +2 -0
  200. package/dist/helpers/serverless/azure.js +3 -3
  201. package/dist/helpers/serverless/azure.js.map +1 -1
  202. package/dist/helpers/serverless/lambda-layer-versions.d.ts +3 -3
  203. package/dist/helpers/serverless/lambda-layer-versions.js +3 -3
  204. package/package.json +23 -17
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ReactNativeCodepushCommand = void 0;
13
+ const child_process_1 = require("child_process");
14
+ const clipanion_1 = require("clipanion");
15
+ const datadog_ci_base_1 = require("@datadog/datadog-ci-base");
16
+ const constants_1 = require("@datadog/datadog-ci-base/constants");
17
+ const env_1 = require("@datadog/datadog-ci-base/helpers/env");
18
+ const fips_1 = require("@datadog/datadog-ci-base/helpers/fips");
19
+ const errors_1 = require("./errors");
20
+ const interfaces_1 = require("./interfaces");
21
+ const upload_1 = require("./upload");
22
+ const utils_1 = require("./utils");
23
+ class ReactNativeCodepushCommand extends datadog_ci_base_1.BaseCommand {
24
+ constructor() {
25
+ var _a, _b;
26
+ super(...arguments);
27
+ this.appCenterAppName = clipanion_1.Option.String('--app');
28
+ this.appCenterDeployment = clipanion_1.Option.String('--deployment');
29
+ /**
30
+ * There should not be multiple uploads with the same version in the case
31
+ * of codepush, so we can go with a default of "1".
32
+ */
33
+ this.buildVersion = clipanion_1.Option.String('--build-version', '1');
34
+ this.bundle = clipanion_1.Option.String('--bundle');
35
+ this.configPath = clipanion_1.Option.String('--config');
36
+ this.disableGit = clipanion_1.Option.Boolean('--disable-git');
37
+ this.dryRun = clipanion_1.Option.Boolean('--dry-run', false);
38
+ this.maxConcurrency = clipanion_1.Option.String('--max-concurrency', '20');
39
+ this.platform = clipanion_1.Option.String('--platform');
40
+ this.projectPath = clipanion_1.Option.String('--project-path');
41
+ this.removeSourcesContent = clipanion_1.Option.Boolean('--remove-sources-content');
42
+ this.repositoryURL = clipanion_1.Option.String('--repository-url');
43
+ this.service = clipanion_1.Option.String('--service');
44
+ this.sourcemap = clipanion_1.Option.String('--sourcemap');
45
+ this.fips = clipanion_1.Option.Boolean('--fips', false);
46
+ this.fipsIgnoreError = clipanion_1.Option.Boolean('--fips-ignore-error', false);
47
+ this.config = {
48
+ fips: (_a = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _a !== void 0 ? _a : false,
49
+ fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
50
+ };
51
+ this.getReleaseVersionFromCodepushHistory = (appCenterAppName, appCenterDeployment) => __awaiter(this, void 0, void 0, function* () {
52
+ const command = `appcenter codepush deployment history ${appCenterDeployment} --app ${appCenterAppName} --output json`;
53
+ return new Promise((resolve, reject) => {
54
+ (0, child_process_1.exec)(command, (error, stdout, stderr) => {
55
+ if (error) {
56
+ reject(new errors_1.CodepushHistoryCommandError(stderr, command));
57
+ return;
58
+ }
59
+ try {
60
+ const history = JSON.parse(stdout);
61
+ if (history.length === 0) {
62
+ reject(new errors_1.NoCodepushReleaseError(appCenterAppName, appCenterDeployment));
63
+ }
64
+ const lastDeployment = history[history.length - 1];
65
+ const [lastCodePushLabel, _, lastVersion] = lastDeployment;
66
+ const version = (0, utils_1.sanitizeReleaseVersion)(lastVersion);
67
+ if (/^[^\d]/.test(version)) {
68
+ reject(new errors_1.CodepushHistoryParseError(`Error parsing codepush history: invalid version string '${lastVersion}'`));
69
+ }
70
+ resolve(`${version}-codepush.${lastCodePushLabel}`);
71
+ }
72
+ catch (parseError) {
73
+ reject(new errors_1.CodepushHistoryParseError(`Error parsing codepush history: \n${String(parseError)}\n${stdout}`));
74
+ }
75
+ });
76
+ });
77
+ });
78
+ }
79
+ execute() {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ (0, fips_1.enableFips)(this.fips || this.config.fips, this.fipsIgnoreError || this.config.fipsIgnoreError);
82
+ if (!this.service) {
83
+ this.context.stderr.write('Missing service\n');
84
+ return 1;
85
+ }
86
+ if (!this.platform) {
87
+ this.context.stderr.write('Missing platform\n');
88
+ return 1;
89
+ }
90
+ if (!interfaces_1.RN_SUPPORTED_PLATFORMS.includes(this.platform)) {
91
+ this.context.stderr.write(`Platform ${this.platform} is not supported.\nSupported platforms are ios and android.\n`);
92
+ return 1;
93
+ }
94
+ if (!this.sourcemap) {
95
+ this.context.stderr.write('Missing sourcemap file path\n');
96
+ return 1;
97
+ }
98
+ if (!this.appCenterAppName) {
99
+ this.context.stderr.write('Missing AppCenter app name\n');
100
+ return 1;
101
+ }
102
+ if (!this.appCenterDeployment) {
103
+ this.context.stderr.write('Missing AppCenter deployment\n');
104
+ return 1;
105
+ }
106
+ this.releaseVersion = yield this.getReleaseVersionFromCodepushHistory(this.appCenterAppName, this.appCenterDeployment);
107
+ // Run upload script in the background
108
+ const cli = new clipanion_1.Cli();
109
+ cli.register(upload_1.ReactNativeUploadCommand);
110
+ const uploadCommand = [
111
+ 'react-native',
112
+ 'upload',
113
+ '--platform',
114
+ this.platform,
115
+ '--release-version',
116
+ this.releaseVersion,
117
+ '--build-version',
118
+ this.buildVersion,
119
+ '--service',
120
+ this.service,
121
+ '--sourcemap',
122
+ this.sourcemap,
123
+ ];
124
+ if (this.bundle) {
125
+ uploadCommand.push('--bundle', this.bundle);
126
+ }
127
+ if (this.configPath) {
128
+ uploadCommand.push('--config');
129
+ uploadCommand.push(this.configPath);
130
+ }
131
+ if (this.maxConcurrency) {
132
+ uploadCommand.push('--max-concurrency');
133
+ uploadCommand.push(this.maxConcurrency.toString());
134
+ }
135
+ if (this.projectPath) {
136
+ uploadCommand.push('--project-path');
137
+ uploadCommand.push(this.projectPath);
138
+ }
139
+ if (this.repositoryURL) {
140
+ uploadCommand.push('--repository-url');
141
+ uploadCommand.push(this.repositoryURL);
142
+ }
143
+ if (this.disableGit) {
144
+ uploadCommand.push('--disable-git');
145
+ }
146
+ if (this.removeSourcesContent) {
147
+ uploadCommand.push('--remove-sources-content');
148
+ }
149
+ if (this.dryRun) {
150
+ uploadCommand.push('--dry-run');
151
+ }
152
+ return cli.run(uploadCommand, this.context);
153
+ });
154
+ }
155
+ }
156
+ exports.ReactNativeCodepushCommand = ReactNativeCodepushCommand;
157
+ ReactNativeCodepushCommand.paths = [['react-native', 'codepush']];
158
+ ReactNativeCodepushCommand.usage = clipanion_1.Command.Usage({
159
+ category: 'RUM',
160
+ description: 'Upload your React Native Codepush bundle and sourcemaps to Datadog.',
161
+ details: `
162
+ This command will upload React Native Codepush sourcemaps and their corresponding JavaScript bundle to Datadog in order to un-minify front-end stack traces received by Datadog.\n
163
+ See README for details.
164
+ `,
165
+ examples: [
166
+ [
167
+ 'Upload ios staging sourcemaps for Company/AppNameiOS',
168
+ 'datadog-ci react-native codepush --platform ios --service com.company.app --bundle ./build/main.jsbundle --sourcemap ./build/main.jsbundle.map --app Company/AppNameiOS --deployment Staging',
169
+ ],
170
+ [
171
+ 'Upload android production sourcemaps for Company/AppNameAndroid',
172
+ 'datadog-ci react-native codepush --platform android --service com.company.app --bundle ./build/index.android.bundle --sourcemap ./build/index.android.bundle.map --app Company/AppNameAndroid --deployment Production',
173
+ ],
174
+ ],
175
+ });
176
+ //# sourceMappingURL=codepush.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codepush.js","sourceRoot":"","sources":["../../../src/commands/react-native/codepush.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAAkC;AAElC,yCAA8C;AAE9C,8DAAoD;AACpD,kEAA0F;AAC1F,8DAA8D;AAC9D,gEAAgE;AAEhE,qCAAuG;AACvG,6CAA+D;AAC/D,qCAAiD;AACjD,mCAA8C;AAE9C,MAAa,0BAA2B,SAAQ,6BAAW;IAA3D;;;QAsBU,qBAAgB,GAAG,kBAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACzC,wBAAmB,GAAG,kBAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;QAC3D;;;WAGG;QACK,iBAAY,GAAG,kBAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;QACpD,WAAM,GAAG,kBAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QAClC,eAAU,GAAG,kBAAM,CAAC,MAAM,CAAC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O,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QAC7C,CAAC;KAAA;;AAhJH,gEAqLC;AApLe,gCAAK,GAAG,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,AAAjC,CAAiC;AAEtC,gCAAK,GAAG,mBAAO,CAAC,KAAK,CAAC;IAClC,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,qEAAqE;IAClF,OAAO,EAAE;;;KAGR;IACD,QAAQ,EAAE;QACR;YACE,sDAAsD;YACtD,8LAA8L;SAC/L;QACD;YACE,iEAAiE;YACjE,uNAAuN;SACxN;KACF;CACF,CAAC,AAjBiB,CAiBjB"}
@@ -0,0 +1,9 @@
1
+ export declare class NoCodepushReleaseError extends Error {
2
+ constructor(appCenterAppName: string, appCenterDeployment: string);
3
+ }
4
+ export declare class CodepushHistoryParseError extends Error {
5
+ constructor(message?: string);
6
+ }
7
+ export declare class CodepushHistoryCommandError extends Error {
8
+ constructor(message: string, command: string);
9
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CodepushHistoryCommandError = exports.CodepushHistoryParseError = exports.NoCodepushReleaseError = void 0;
4
+ class NoCodepushReleaseError extends Error {
5
+ constructor(appCenterAppName, appCenterDeployment) {
6
+ super(`No codepush release has been created yet for ${appCenterAppName} ${appCenterDeployment}`);
7
+ }
8
+ }
9
+ exports.NoCodepushReleaseError = NoCodepushReleaseError;
10
+ class CodepushHistoryParseError extends Error {
11
+ constructor(message) {
12
+ super(message);
13
+ }
14
+ }
15
+ exports.CodepushHistoryParseError = CodepushHistoryParseError;
16
+ class CodepushHistoryCommandError extends Error {
17
+ constructor(message, command) {
18
+ let errorMessage;
19
+ try {
20
+ errorMessage = JSON.parse(message).errorMessage;
21
+ // Error returned when there is no network
22
+ if (errorMessage.match('Cannot read properties of undefined')) {
23
+ super(`You need to have network access to be able to get the latest codepush label.\nCheck that ${command} returns a correct value.\nAlternatively, you can directly use the "datadog-ci react-native upload" command to upload your sourcemaps with the correct release version.`);
24
+ return;
25
+ }
26
+ }
27
+ catch (e) {
28
+ errorMessage = message;
29
+ }
30
+ super(errorMessage);
31
+ }
32
+ }
33
+ exports.CodepushHistoryCommandError = CodepushHistoryCommandError;
34
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/commands/react-native/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,gBAAwB,EAAE,mBAA2B;QAC/D,KAAK,CAAC,gDAAgD,gBAAgB,IAAI,mBAAmB,EAAE,CAAC,CAAA;IAClG,CAAC;CACF;AAJD,wDAIC;AAED,MAAa,yBAA0B,SAAQ,KAAK;IAClD,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;CACF;AAJD,8DAIC;AAED,MAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAY,OAAe,EAAE,OAAe;QAC1C,IAAI,YAAoB,CAAA;QACxB,IAAI;YACF,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,YAAY,CAAA;YAC/C,0CAA0C;YAC1C,IAAI,YAAY,CAAC,KAAK,CAAC,qCAAqC,CAAC,EAAE;gBAC7D,KAAK,CACH,4FAA4F,OAAO,yKAAyK,CAC7Q,CAAA;gBAED,OAAM;aACP;SACF;QAAC,OAAO,CAAC,EAAE;YACV,YAAY,GAAG,OAAO,CAAA;SACvB;QAED,KAAK,CAAC,YAAY,CAAC,CAAA;IACrB,CAAC;CACF;AAnBD,kEAmBC"}
@@ -0,0 +1,42 @@
1
+ import { BaseCommand } from '@datadog/datadog-ci-base';
2
+ export declare class ReactNativeInjectDebugIdCommand extends BaseCommand {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ private assetsPath;
6
+ private dryRun;
7
+ private fips;
8
+ private fipsIgnoreError;
9
+ private fipsConfig;
10
+ execute(): Promise<number>;
11
+ /**
12
+ * Scans the directory for bundles and sourcemaps, then injects Debug IDs.
13
+ *
14
+ * @param directory - The directory containing JavaScript bundles and sourcemaps.
15
+ * @param dryRun - If true, does not modify files.
16
+ */
17
+ private injectDebugIds;
18
+ /**
19
+ * Modifies the JS bundle by injecting a minified code snippet to allow runtime consumption of the given Debug ID,
20
+ * and it appends it to the end of the file, while preserving mappings.
21
+ *
22
+ * - Appends a **code snippet** containing the Debug ID.
23
+ * - Adds a **comment** with `//# debugId=<debug_id>`.
24
+ * - Moves the last `//# sourceMappingURL=` or `//@ sourceMappingURL=` comment to the end.
25
+ *
26
+ * @param filePath - The path to the JavaScript file.
27
+ * @param debugId - The Debug ID to inject.
28
+ */
29
+ private injectDebugIdIntoBundle;
30
+ /**
31
+ * Injects a Debug ID into a sourcemap JSON file.
32
+ */
33
+ private injectDebugIdIntoSourceMap;
34
+ /**
35
+ * Reads the Debug ID from a JavaScript bundle, if present.
36
+ */
37
+ private extractDebugIdFromBundle;
38
+ /**
39
+ * Reads the Debug ID from a sourcemap file.
40
+ */
41
+ private extractDebugIdFromSourceMap;
42
+ }
@@ -0,0 +1,252 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ReactNativeInjectDebugIdCommand = void 0;
16
+ const crypto_1 = require("crypto");
17
+ const fs_1 = require("fs");
18
+ const clipanion_1 = require("clipanion");
19
+ const upath_1 = __importDefault(require("upath"));
20
+ const datadog_ci_base_1 = require("@datadog/datadog-ci-base");
21
+ const constants_1 = require("@datadog/datadog-ci-base/constants");
22
+ const env_1 = require("@datadog/datadog-ci-base/helpers/env");
23
+ const fips_1 = require("@datadog/datadog-ci-base/helpers/fips");
24
+ /**
25
+ * The Debug ID is injected in the bundle as a plain string, using this prefix.
26
+ */
27
+ const DEBUG_ID_METADATA_PREFIX = 'datadog-debug-id-';
28
+ class ReactNativeInjectDebugIdCommand extends datadog_ci_base_1.BaseCommand {
29
+ constructor() {
30
+ var _a, _b;
31
+ super(...arguments);
32
+ this.assetsPath = clipanion_1.Option.String({ required: false });
33
+ this.dryRun = clipanion_1.Option.Boolean('--dry-run', false);
34
+ this.fips = clipanion_1.Option.Boolean('--fips', false);
35
+ this.fipsIgnoreError = clipanion_1.Option.Boolean('--fips-ignore-error', false);
36
+ this.fipsConfig = {
37
+ fips: (_a = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _a !== void 0 ? _a : false,
38
+ fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
39
+ };
40
+ }
41
+ execute() {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ (0, fips_1.enableFips)(this.fips || this.fipsConfig.fips, this.fipsIgnoreError || this.fipsConfig.fipsIgnoreError);
44
+ if (!this.assetsPath) {
45
+ this.context.stderr.write('[ERROR] No path specified for JS bundle and sourcemap.\n');
46
+ return 1;
47
+ }
48
+ if (!(0, fs_1.existsSync)(this.assetsPath)) {
49
+ this.context.stderr.write('[ERROR] The given path does not exist.\n');
50
+ return 1;
51
+ }
52
+ return this.injectDebugIds(this.assetsPath, this.dryRun);
53
+ });
54
+ }
55
+ /**
56
+ * Scans the directory for bundles and sourcemaps, then injects Debug IDs.
57
+ *
58
+ * @param directory - The directory containing JavaScript bundles and sourcemaps.
59
+ * @param dryRun - If true, does not modify files.
60
+ */
61
+ injectDebugIds(directory, dryRun) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ this.context.stdout.write(`Scanning directory: ${directory}\n`);
64
+ const files = yield fs_1.promises.readdir(directory);
65
+ const bundles = files.filter((file) => file.endsWith('.bundle'));
66
+ if (bundles.length === 0) {
67
+ this.context.stderr.write(`[ERROR] JS bundle not found in "${directory}". Ensure your files follow the "*.bundle" and "*.bundle.map" naming convention.\n`);
68
+ return 1;
69
+ }
70
+ for (const bundle of bundles) {
71
+ const bundlePath = upath_1.default.join(directory, bundle);
72
+ const sourcemapPath = upath_1.default.join(directory, `${bundle}.map`);
73
+ let debugId = (yield this.extractDebugIdFromBundle(bundlePath)) || (yield this.extractDebugIdFromSourceMap(sourcemapPath));
74
+ if (!debugId) {
75
+ const bundleData = yield fs_1.promises.readFile(bundlePath, 'utf-8');
76
+ debugId = generateDebugId(bundleData);
77
+ this.context.stdout.write(`Generated Debug ID for ${bundle}: ${debugId}\n`);
78
+ }
79
+ else {
80
+ this.context.stdout.write(`Found existing Debug ID for ${bundle}: ${debugId}\n`);
81
+ }
82
+ if (!dryRun) {
83
+ if (!(yield this.injectDebugIdIntoBundle(bundlePath, debugId))) {
84
+ return 1;
85
+ }
86
+ if ((0, fs_1.existsSync)(sourcemapPath)) {
87
+ if (!(yield this.injectDebugIdIntoSourceMap(sourcemapPath, debugId))) {
88
+ return 1;
89
+ }
90
+ this.context.stdout.write(`Updated Debug ID in ${bundle} and its sourcemap.\n`);
91
+ }
92
+ }
93
+ else {
94
+ this.context.stdout.write(`Dry run: No files modified.\n`);
95
+ }
96
+ }
97
+ return 0;
98
+ });
99
+ }
100
+ /**
101
+ * Modifies the JS bundle by injecting a minified code snippet to allow runtime consumption of the given Debug ID,
102
+ * and it appends it to the end of the file, while preserving mappings.
103
+ *
104
+ * - Appends a **code snippet** containing the Debug ID.
105
+ * - Adds a **comment** with `//# debugId=<debug_id>`.
106
+ * - Moves the last `//# sourceMappingURL=` or `//@ sourceMappingURL=` comment to the end.
107
+ *
108
+ * @param filePath - The path to the JavaScript file.
109
+ * @param debugId - The Debug ID to inject.
110
+ */
111
+ injectDebugIdIntoBundle(filePath, debugId) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ try {
114
+ const jsContents = yield fs_1.promises.readFile(filePath, 'utf-8');
115
+ const lines = jsContents.split('\n');
116
+ // Find the last source mapping comment (`//# sourceMappingURL=...` or `//@ sourceMappingURL=...`)
117
+ const sourcemapIndex = lines
118
+ .map((line, index) => ({ line, index }))
119
+ .reverse()
120
+ .find(({ line }) => line.startsWith('//# sourceMappingURL=') || line.startsWith('//@ sourceMappingURL='));
121
+ let sourcemapComment = '';
122
+ if (sourcemapIndex) {
123
+ // Remove the sourcemap comment so we can place it at the very end later
124
+ sourcemapComment = lines.splice(sourcemapIndex.index, 1)[0];
125
+ }
126
+ // Inject Debug ID snippet (modify as needed)
127
+ const snippet = createDebugIdSnippet(debugId);
128
+ // Append minified snippet to the bundle
129
+ lines.push(snippet);
130
+ // Re-add the sourcemap comment at the end (if it was found)
131
+ if (sourcemapComment) {
132
+ lines.push(sourcemapComment);
133
+ }
134
+ // Append Debug ID comment
135
+ lines.push(`//# debugId=${debugId}`);
136
+ // Write back the modified contents
137
+ yield fs_1.promises.writeFile(filePath, lines.join('\n'), 'utf-8');
138
+ this.context.stdout.write(`✅ Debug ID injected into ${filePath}\n`);
139
+ }
140
+ catch (error) {
141
+ const errorMsg = error instanceof Error ? error.message : String(error);
142
+ this.context.stderr.write(`❌ Failed to inject Debug ID into ${filePath}:${errorMsg}\n`);
143
+ return false;
144
+ }
145
+ return true;
146
+ });
147
+ }
148
+ /**
149
+ * Injects a Debug ID into a sourcemap JSON file.
150
+ */
151
+ injectDebugIdIntoSourceMap(sourceMapPath, debugId) {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ let sourcemapData;
154
+ try {
155
+ sourcemapData = yield fs_1.promises.readFile(sourceMapPath, 'utf-8');
156
+ }
157
+ catch (error) {
158
+ this.context.stderr.write(`[ERROR] Cannot read sourcemap from ${sourceMapPath}: ${String(error)}\n`);
159
+ return false;
160
+ }
161
+ let content;
162
+ try {
163
+ content = JSON.parse(sourcemapData);
164
+ }
165
+ catch (error) {
166
+ this.context.stderr.write(`[ERROR] Cannot parse JSON from sourcemap at ${sourceMapPath}: ${String(error)}\n`);
167
+ return false;
168
+ }
169
+ content.debugId = debugId;
170
+ try {
171
+ yield fs_1.promises.writeFile(sourceMapPath, JSON.stringify(content, undefined, 2));
172
+ }
173
+ catch (error) {
174
+ this.context.stderr.write(`[ERROR] Cannot write sourcemap file at ${sourceMapPath}: ${String(error)}\n`);
175
+ return false;
176
+ }
177
+ return true;
178
+ });
179
+ }
180
+ /**
181
+ * Reads the Debug ID from a JavaScript bundle, if present.
182
+ */
183
+ extractDebugIdFromBundle(bundlePath) {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ const content = yield fs_1.promises.readFile(bundlePath, 'utf-8');
186
+ const match = content.match(/\/\/# debugId=([a-f0-9-]+)/);
187
+ return match ? match[1] : undefined;
188
+ });
189
+ }
190
+ /**
191
+ * Reads the Debug ID from a sourcemap file.
192
+ */
193
+ extractDebugIdFromSourceMap(sourceMapPath) {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ let sourcemapData;
196
+ try {
197
+ sourcemapData = yield fs_1.promises.readFile(sourceMapPath, 'utf-8');
198
+ }
199
+ catch (error) {
200
+ throw new Error(`Cannot read sourcemap from ${sourceMapPath}: ${String(error)}`);
201
+ }
202
+ let content;
203
+ try {
204
+ content = JSON.parse(sourcemapData);
205
+ }
206
+ catch (error) {
207
+ throw new Error(`Cannot parse JSON from sourcemap at ${sourceMapPath}: ${String(error)}`);
208
+ }
209
+ return content.debugId || undefined;
210
+ });
211
+ }
212
+ }
213
+ exports.ReactNativeInjectDebugIdCommand = ReactNativeInjectDebugIdCommand;
214
+ ReactNativeInjectDebugIdCommand.paths = [['react-native', 'inject-debug-id']];
215
+ ReactNativeInjectDebugIdCommand.usage = clipanion_1.Command.Usage({
216
+ category: 'RUM',
217
+ description: 'Inject Debug ID into JavaScript bundles and sourcemaps.',
218
+ details: `
219
+ This command scans the specified directory for minified JavaScript bundles (.bundle) and their associated source maps (.map),
220
+ injecting a unique Debug ID into each file. These Debug IDs enable precise source map resolution in Datadog, ensuring accurate
221
+ stack traces and error symbolication.
222
+ `,
223
+ examples: [
224
+ ['Inject Debug ID', 'datadog-ci react-native inject-debug-id ./dist'],
225
+ ['Inject Debug ID (dry run)', 'datadog-ci react-native inject-debug-id ./dist --dry-run'],
226
+ ],
227
+ });
228
+ /**
229
+ * Creates a minified JavaScript snippet that exposes the provided Debug ID
230
+ * on the global scope at runtime.
231
+ *
232
+ * @param debugId - The Debug ID to be injected into the global scope.
233
+ * @returns A minified JavaScript string that performs the injection.
234
+ */
235
+ const createDebugIdSnippet = (debugId) => {
236
+ return `var _datadogDebugIds,_datadogDebugIdMeta;void 0===_datadogDebugIds&&(_datadogDebugIds={});try{var stack=(new Error).stack;stack&&(_datadogDebugIds[stack]="${debugId}",_datadogDebugIdMeta="${DEBUG_ID_METADATA_PREFIX}${debugId}")}catch(e){}`;
237
+ };
238
+ /**
239
+ * Converts a string into a UUID (Version 4 format) based on its MD5 hash.
240
+ *
241
+ * @param str - The input string to convert into a UUID.
242
+ * @returns A UUIDv4 string derived from the MD5 hash of the input.
243
+ */
244
+ const generateDebugId = (str) => {
245
+ const md5sum = (0, crypto_1.createHash)('md5');
246
+ md5sum.update(str);
247
+ const md5Hash = md5sum.digest('hex');
248
+ // Select a variant character (RFC 4122) - '8', '9', 'a', or 'b'
249
+ const v4variant = ['8', '9', 'a', 'b'][md5Hash.charCodeAt(16) % 4];
250
+ return `${md5Hash.substring(0, 8)}-${md5Hash.substring(8, 12)}-4${md5Hash.substring(13, 16)}-${v4variant}${md5Hash.substring(17, 20)}-${md5Hash.substring(20)}`.toLowerCase();
251
+ };
252
+ //# sourceMappingURL=injectDebugId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectDebugId.js","sourceRoot":"","sources":["../../../src/commands/react-native/injectDebugId.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAiC;AACjC,2BAAuC;AAEvC,yCAAyC;AACzC,kDAAyB;AAEzB,8DAAoD;AACpD,kEAA0F;AAC1F,8DAA8D;AAC9D,gEAAgE;AAEhE;;GAEG;AACH,MAAM,wBAAwB,GAAG,mBAAmB,CAAA;AAEpD,MAAa,+BAAgC,SAAQ,6BAAW;IAAhE;;;QAgBU,eAAU,GAAG,kBAAM,CAAC,MAAM,CAAC,EAAC,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAA;QAC7C,WAAM,GAAG,kBAAM,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QAC3C,SAAI,GAAG,kBAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QACtC,oBAAe,GAAG,kBAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;QAC9D,eAAU,GAAG;YACnB,IAAI,EAAE,MAAA,IAAA,eAAS,EAAC,OAAO,CAAC,GAAG,CAAC,wBAAY,CAAC,CAAC,mCAAI,KAAK;YACnD,eAAe,EAAE,MAAA,IAAA,eAAS,EAAC,OAAO,CAAC,GAAG,CAAC,qCAAyB,CAAC,CAAC,mCAAI,KAAK;SAC5E,CAAA;IAkMH,CAAC;IAhMc,OAAO;;YAClB,IAAA,iBAAU,EAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAA;YAEtG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBACpB,IAAI,CAAC,OAAO,C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AAO,8JAA8J,OAAO,0BAA0B,wBAAwB,GAAG,OAAO,eAAe,CAAA;AACzP,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,eAAe,GAAG,CAAC,GAAW,EAAU,EAAE;IAC9C,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAA;IAChC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAClB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAEpC,gEAAgE;IAChE,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IAElE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,SAAS,CACjF,EAAE,EACF,EAAE,CACH,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAA;AACrF,CAAC,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { CommandContext } from '@datadog/datadog-ci-base';
2
+ import { MultipartPayload } from '@datadog/datadog-ci-base/helpers/upload';
3
+ export declare class RNSourcemap {
4
+ bundleName: string;
5
+ gitData?: GitData;
6
+ sourcemapPath: string;
7
+ constructor(bundleName: string, sourcemapPath: string);
8
+ addRepositoryData(gitData: GitData): void;
9
+ asMultipartPayload(cliVersion: string, service: string, version: string, projectPath: string, platform: RNPlatform, build: string, context: CommandContext): MultipartPayload;
10
+ removeSourcesContentFromSourceMap: () => void;
11
+ private extractDebugId;
12
+ private getMetadataPayload;
13
+ }
14
+ export interface GitData {
15
+ gitCommitSha: string;
16
+ gitRepositoryPayload?: string;
17
+ gitRepositoryURL: string;
18
+ }
19
+ export declare const RN_SUPPORTED_PLATFORMS: readonly ["ios", "android"];
20
+ export type RNPlatform = (typeof RN_SUPPORTED_PLATFORMS)[number];
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RN_SUPPORTED_PLATFORMS = exports.RNSourcemap = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ class RNSourcemap {
9
+ constructor(bundleName, sourcemapPath) {
10
+ this.removeSourcesContentFromSourceMap = () => {
11
+ const newSourcemapFilePath = `${this.sourcemapPath}.no-sources-content`;
12
+ const data = fs_1.default.readFileSync(this.sourcemapPath, 'utf8');
13
+ const sourcemap = JSON.parse(data);
14
+ delete sourcemap.sourcesContent;
15
+ fs_1.default.writeFileSync(newSourcemapFilePath, JSON.stringify(sourcemap), 'utf8');
16
+ this.sourcemapPath = newSourcemapFilePath;
17
+ };
18
+ this.extractDebugId = (context) => {
19
+ try {
20
+ const data = fs_1.default.readFileSync(this.sourcemapPath, 'utf8');
21
+ const sourcemap = JSON.parse(data);
22
+ const debugId = sourcemap['debugId'];
23
+ if (debugId) {
24
+ context.stdout.write(`Extracted Debug ID from sourcemap: ${debugId}\n`);
25
+ return debugId;
26
+ }
27
+ else {
28
+ context.stderr.write(`Debug ID not found in sourcemap\n`);
29
+ }
30
+ }
31
+ catch (err) {
32
+ const errorMsg = err instanceof Error ? err.message : String(err);
33
+ context.stderr.write(`Cannot extract Debug ID from sourcemap: ${errorMsg}\n`);
34
+ }
35
+ return undefined;
36
+ };
37
+ this.bundleName = bundleName;
38
+ this.sourcemapPath = sourcemapPath;
39
+ }
40
+ addRepositoryData(gitData) {
41
+ this.gitData = gitData;
42
+ }
43
+ asMultipartPayload(cliVersion, service, version, projectPath, platform, build, context) {
44
+ const content = new Map([
45
+ [
46
+ 'event',
47
+ this.getMetadataPayload(cliVersion, service, version, projectPath, platform, build, this.extractDebugId(context)),
48
+ ],
49
+ ['source_map', { type: 'file', path: this.sourcemapPath, options: { filename: 'source_map' } }],
50
+ ]);
51
+ if (this.gitData !== undefined && this.gitData.gitRepositoryPayload !== undefined) {
52
+ content.set('repository', {
53
+ type: 'string',
54
+ options: {
55
+ contentType: 'application/json',
56
+ filename: 'repository',
57
+ },
58
+ value: this.gitData.gitRepositoryPayload,
59
+ });
60
+ }
61
+ return {
62
+ content,
63
+ };
64
+ }
65
+ getMetadataPayload(cliVersion, service, version, projectPath, platform, build, debugId) {
66
+ const metadata = {
67
+ build_number: build,
68
+ bundle_name: this.bundleName,
69
+ cli_version: cliVersion,
70
+ platform,
71
+ project_path: projectPath,
72
+ service,
73
+ type: 'react_native_sourcemap',
74
+ version,
75
+ debug_id: debugId,
76
+ };
77
+ if (this.gitData !== undefined) {
78
+ metadata.git_repository_url = this.gitData.gitRepositoryURL;
79
+ metadata.git_commit_sha = this.gitData.gitCommitSha;
80
+ }
81
+ return {
82
+ type: 'string',
83
+ options: {
84
+ contentType: 'application/json',
85
+ filename: 'event',
86
+ },
87
+ value: JSON.stringify(metadata),
88
+ };
89
+ }
90
+ }
91
+ exports.RNSourcemap = RNSourcemap;
92
+ exports.RN_SUPPORTED_PLATFORMS = ['ios', 'android'];
93
+ //# sourceMappingURL=interfaces.js.map