@apps-in-toss/cli 0.0.28 → 0.0.29
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.
- package/dist/index.cjs +310 -41
- package/dist/index.js +309 -40
- package/package.json +7 -3
package/dist/index.cjs
CHANGED
|
@@ -192,11 +192,11 @@ var require_common = __commonJS({
|
|
|
192
192
|
let enableOverride = null;
|
|
193
193
|
let namespacesCache;
|
|
194
194
|
let enabledCache;
|
|
195
|
-
function
|
|
196
|
-
if (!
|
|
195
|
+
function debug5(...args) {
|
|
196
|
+
if (!debug5.enabled) {
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
|
-
const self =
|
|
199
|
+
const self = debug5;
|
|
200
200
|
const curr = Number(/* @__PURE__ */ new Date());
|
|
201
201
|
const ms = curr - (prevTime || curr);
|
|
202
202
|
self.diff = ms;
|
|
@@ -226,12 +226,12 @@ var require_common = __commonJS({
|
|
|
226
226
|
const logFn = self.log || createDebug.log;
|
|
227
227
|
logFn.apply(self, args);
|
|
228
228
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
Object.defineProperty(
|
|
229
|
+
debug5.namespace = namespace;
|
|
230
|
+
debug5.useColors = createDebug.useColors();
|
|
231
|
+
debug5.color = createDebug.selectColor(namespace);
|
|
232
|
+
debug5.extend = extend;
|
|
233
|
+
debug5.destroy = createDebug.destroy;
|
|
234
|
+
Object.defineProperty(debug5, "enabled", {
|
|
235
235
|
enumerable: true,
|
|
236
236
|
configurable: false,
|
|
237
237
|
get: () => {
|
|
@@ -249,9 +249,9 @@ var require_common = __commonJS({
|
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
251
|
if (typeof createDebug.init === "function") {
|
|
252
|
-
createDebug.init(
|
|
252
|
+
createDebug.init(debug5);
|
|
253
253
|
}
|
|
254
|
-
return
|
|
254
|
+
return debug5;
|
|
255
255
|
}
|
|
256
256
|
function extend(namespace, delimiter) {
|
|
257
257
|
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
@@ -517,7 +517,7 @@ var require_node = __commonJS({
|
|
|
517
517
|
var tty = require("tty");
|
|
518
518
|
var util = require("util");
|
|
519
519
|
exports2.init = init;
|
|
520
|
-
exports2.log =
|
|
520
|
+
exports2.log = log4;
|
|
521
521
|
exports2.formatArgs = formatArgs;
|
|
522
522
|
exports2.save = save;
|
|
523
523
|
exports2.load = load;
|
|
@@ -652,7 +652,7 @@ var require_node = __commonJS({
|
|
|
652
652
|
}
|
|
653
653
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
654
654
|
}
|
|
655
|
-
function
|
|
655
|
+
function log4(...args) {
|
|
656
656
|
return process.stderr.write(util.formatWithOptions(exports2.inspectOpts, ...args) + "\n");
|
|
657
657
|
}
|
|
658
658
|
function save(namespaces) {
|
|
@@ -665,11 +665,11 @@ var require_node = __commonJS({
|
|
|
665
665
|
function load() {
|
|
666
666
|
return process.env.DEBUG;
|
|
667
667
|
}
|
|
668
|
-
function init(
|
|
669
|
-
|
|
668
|
+
function init(debug5) {
|
|
669
|
+
debug5.inspectOpts = {};
|
|
670
670
|
const keys = Object.keys(exports2.inspectOpts);
|
|
671
671
|
for (let i = 0; i < keys.length; i++) {
|
|
672
|
-
|
|
672
|
+
debug5.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
module2.exports = require_common()(exports2);
|
|
@@ -703,10 +703,10 @@ var require_picocolors = __commonJS({
|
|
|
703
703
|
"../../.yarn/cache/picocolors-npm-1.1.1-b0c45fa35e-e2e3e8170a.zip/node_modules/picocolors/picocolors.js"(exports2, module2) {
|
|
704
704
|
"use strict";
|
|
705
705
|
init_cjs_shims();
|
|
706
|
-
var
|
|
707
|
-
var argv =
|
|
708
|
-
var env =
|
|
709
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") ||
|
|
706
|
+
var p4 = process || {};
|
|
707
|
+
var argv = p4.argv || [];
|
|
708
|
+
var env = p4.env || {};
|
|
709
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p4.platform === "win32" || (p4.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
710
710
|
var formatter = (open, close, replace = open) => (input) => {
|
|
711
711
|
let string = "" + input, index = string.indexOf(close, open.length);
|
|
712
712
|
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
@@ -779,7 +779,7 @@ __export(src_exports, {
|
|
|
779
779
|
});
|
|
780
780
|
module.exports = __toCommonJS(src_exports);
|
|
781
781
|
init_cjs_shims();
|
|
782
|
-
var
|
|
782
|
+
var import_clipanion4 = require("clipanion");
|
|
783
783
|
|
|
784
784
|
// src/DeployCommand.ts
|
|
785
785
|
init_cjs_shims();
|
|
@@ -789,7 +789,7 @@ var import_path = __toESM(require("path"), 1);
|
|
|
789
789
|
var p = __toESM(require("@clack/prompts"), 1);
|
|
790
790
|
var import_utils = require("@react-native-bedrock/utils");
|
|
791
791
|
var import_clipanion = require("clipanion");
|
|
792
|
-
var
|
|
792
|
+
var import_debug3 = __toESM(require_src(), 1);
|
|
793
793
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
794
794
|
|
|
795
795
|
// src/utils/constants.ts
|
|
@@ -800,10 +800,30 @@ var DEFAULT_API_BASE_URL = "https://apps-in-toss.toss.im/console";
|
|
|
800
800
|
// src/utils/upload.ts
|
|
801
801
|
init_cjs_shims();
|
|
802
802
|
var import_fs = __toESM(require("fs"), 1);
|
|
803
|
+
var import_debug2 = __toESM(require_src(), 1);
|
|
804
|
+
|
|
805
|
+
// src/utils/handleFetchResponse.ts
|
|
806
|
+
init_cjs_shims();
|
|
803
807
|
var import_debug = __toESM(require_src(), 1);
|
|
804
|
-
var debug = (0, import_debug.default)("
|
|
808
|
+
var debug = (0, import_debug.default)("api");
|
|
809
|
+
async function handleFetchResponse(response) {
|
|
810
|
+
debug(`Response ${response.status} ${response.statusText}`);
|
|
811
|
+
if (!response.ok) {
|
|
812
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
813
|
+
}
|
|
814
|
+
const data = await response.clone().json();
|
|
815
|
+
debug("response", data);
|
|
816
|
+
if (data.resultType !== "SUCCESS") {
|
|
817
|
+
const errorCode = data?.error?.errorCode ?? "-1";
|
|
818
|
+
const errorReason = data?.error.reason ?? "unknown";
|
|
819
|
+
throw new Error(`${errorReason} (Code: ${errorCode})`);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// src/utils/upload.ts
|
|
824
|
+
var debug2 = (0, import_debug2.default)("cli:deploy");
|
|
805
825
|
async function uploadArtifact(config) {
|
|
806
|
-
|
|
826
|
+
debug2("uploadArtifact", config);
|
|
807
827
|
const baseUrl = config.baseUrl ?? DEFAULT_API_BASE_URL;
|
|
808
828
|
const response = await fetch(
|
|
809
829
|
`${baseUrl}/api-public/v3/appsintossconsole/bundles/${config.appName}/deployments/${config.deploymentId}/upload`,
|
|
@@ -817,24 +837,11 @@ async function uploadArtifact(config) {
|
|
|
817
837
|
duplex: "half"
|
|
818
838
|
}
|
|
819
839
|
);
|
|
820
|
-
return
|
|
821
|
-
}
|
|
822
|
-
async function handleResponse(response) {
|
|
823
|
-
debug(`Response ${response.status} ${response.statusText}`);
|
|
824
|
-
if (!response.ok) {
|
|
825
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
826
|
-
}
|
|
827
|
-
const data = await response.clone().json();
|
|
828
|
-
debug("uploadArtifact response", data);
|
|
829
|
-
if (data.resultType !== "SUCCESS") {
|
|
830
|
-
const errorCode = data?.error?.errorCode ?? "-1";
|
|
831
|
-
const errorReason = data?.error.reason ?? "unknown";
|
|
832
|
-
throw new Error(`${errorReason} (Code: ${errorCode})`);
|
|
833
|
-
}
|
|
840
|
+
return handleFetchResponse(response);
|
|
834
841
|
}
|
|
835
842
|
|
|
836
843
|
// src/DeployCommand.ts
|
|
837
|
-
var
|
|
844
|
+
var debug3 = (0, import_debug3.default)("cli:deploy");
|
|
838
845
|
var DeployCommand = class extends import_clipanion.Command {
|
|
839
846
|
static paths = [["deploy"]];
|
|
840
847
|
apiKey = import_clipanion.Option.String("--api-key", {
|
|
@@ -873,7 +880,7 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
873
880
|
(0, import_assert.default)(typeof deploymentId2 === "string", "invalid deploymentId");
|
|
874
881
|
return { appName: appName2, deploymentId: deploymentId2 };
|
|
875
882
|
}).catch((error) => {
|
|
876
|
-
|
|
883
|
+
debug3("invalid ait file", error);
|
|
877
884
|
throw new Error("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 ait \uD30C\uC77C\uC785\uB2C8\uB2E4");
|
|
878
885
|
});
|
|
879
886
|
const colorAppName = import_picocolors.default.underline(import_picocolors.default.cyan(appName));
|
|
@@ -1151,14 +1158,276 @@ var InitCommand = class extends import_clipanion2.Command {
|
|
|
1151
1158
|
}
|
|
1152
1159
|
};
|
|
1153
1160
|
|
|
1161
|
+
// src/integrations/UploadSentrySourcemap/index.ts
|
|
1162
|
+
init_cjs_shims();
|
|
1163
|
+
|
|
1164
|
+
// src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
|
|
1165
|
+
init_cjs_shims();
|
|
1166
|
+
var fs7 = __toESM(require("fs/promises"), 1);
|
|
1167
|
+
var p3 = __toESM(require("@clack/prompts"), 1);
|
|
1168
|
+
var import_clipanion3 = require("clipanion");
|
|
1169
|
+
|
|
1170
|
+
// src/integrations/UploadSentrySourcemap/downloadArtifacts.ts
|
|
1171
|
+
init_cjs_shims();
|
|
1172
|
+
var fs4 = __toESM(require("fs"), 1);
|
|
1173
|
+
var os = __toESM(require("os"), 1);
|
|
1174
|
+
var path3 = __toESM(require("path"), 1);
|
|
1175
|
+
var import_stream = require("stream");
|
|
1176
|
+
var import_util = require("util");
|
|
1177
|
+
var import_debug4 = __toESM(require_src(), 1);
|
|
1178
|
+
var debug4 = (0, import_debug4.default)("integrations:sentry");
|
|
1179
|
+
var streamPipeline = (0, import_util.promisify)(import_stream.pipeline);
|
|
1180
|
+
async function downloadArtifacts(options) {
|
|
1181
|
+
const { appName, deploymentId, apiKey, baseUrl = DEFAULT_API_BASE_URL } = options;
|
|
1182
|
+
const params = new URLSearchParams({
|
|
1183
|
+
appName,
|
|
1184
|
+
deploymentId
|
|
1185
|
+
});
|
|
1186
|
+
const requestUrl = `${baseUrl}/api-public/v3/openapi/bundles/download?${params.toString()}`;
|
|
1187
|
+
debug4("Request URL", { requestUrl });
|
|
1188
|
+
const response = await fetch(`${baseUrl}/api-public/v3/openapi/bundles/download?${params.toString()}`, {
|
|
1189
|
+
method: "GET",
|
|
1190
|
+
headers: {
|
|
1191
|
+
"Content-Type": "application/json",
|
|
1192
|
+
Authorization: `Bearer ${apiKey}`
|
|
1193
|
+
}
|
|
1194
|
+
});
|
|
1195
|
+
if (!response.ok) {
|
|
1196
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
1197
|
+
}
|
|
1198
|
+
if (response.body == null) {
|
|
1199
|
+
throw new Error("No response body");
|
|
1200
|
+
}
|
|
1201
|
+
const tmpDir = await createTempDirectory();
|
|
1202
|
+
const tmpFile = `${deploymentId}.zip`;
|
|
1203
|
+
const tmpFilePath = path3.join(tmpDir.path, tmpFile);
|
|
1204
|
+
const fileStream = fs4.createWriteStream(tmpFilePath);
|
|
1205
|
+
await streamPipeline(response.body, fileStream);
|
|
1206
|
+
debug4("Artifacts downloaded", { tmpFilePath });
|
|
1207
|
+
return tmpFilePath;
|
|
1208
|
+
}
|
|
1209
|
+
function createTempDirectory() {
|
|
1210
|
+
const tempDir = path3.join(os.tmpdir(), "apps-in-toss", "sentry-integration");
|
|
1211
|
+
fs4.mkdirSync(tempDir, { recursive: true });
|
|
1212
|
+
debug4("Temp directory created", { tempDir });
|
|
1213
|
+
return {
|
|
1214
|
+
path: tempDir,
|
|
1215
|
+
cleanup: () => {
|
|
1216
|
+
fs4.rmSync(tempDir, { recursive: true, force: true });
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// src/integrations/UploadSentrySourcemap/extractSentryDebugId.ts
|
|
1222
|
+
init_cjs_shims();
|
|
1223
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
1224
|
+
async function extractSentryDebugId(bundlePath) {
|
|
1225
|
+
const bundleContent = await import_promises.default.readFile(bundlePath, "utf-8");
|
|
1226
|
+
return bundleContent.match(/SENTRY_DEBUG_ID=([\w-]+)/)?.[1];
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// src/integrations/UploadSentrySourcemap/extractSources.ts
|
|
1230
|
+
init_cjs_shims();
|
|
1231
|
+
var fs6 = __toESM(require("fs"), 1);
|
|
1232
|
+
var path4 = __toESM(require("path"), 1);
|
|
1233
|
+
var import_stream2 = require("stream");
|
|
1234
|
+
var import_util2 = require("util");
|
|
1235
|
+
var zlib = __toESM(require("zlib"), 1);
|
|
1236
|
+
var unzipper = __toESM(require("unzipper"), 1);
|
|
1237
|
+
var pipe = (0, import_util2.promisify)(import_stream2.pipeline);
|
|
1238
|
+
async function extractSources(zipPath) {
|
|
1239
|
+
const sources = {
|
|
1240
|
+
android: {
|
|
1241
|
+
packagerBundle: "",
|
|
1242
|
+
packagerSourceMap: "",
|
|
1243
|
+
hermesBundle: "",
|
|
1244
|
+
hermesSourceMap: ""
|
|
1245
|
+
},
|
|
1246
|
+
ios: {
|
|
1247
|
+
packagerBundle: "",
|
|
1248
|
+
packagerSourceMap: "",
|
|
1249
|
+
hermesBundle: "",
|
|
1250
|
+
hermesSourceMap: ""
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
await fs6.createReadStream(zipPath).pipe(unzipper.Parse()).on("entry", async (entry) => {
|
|
1254
|
+
const isRoot = !entry.path.includes("/");
|
|
1255
|
+
const fileName = path4.basename(entry.path);
|
|
1256
|
+
const outputPath = path4.join(path4.dirname(zipPath), fileName);
|
|
1257
|
+
if (isRoot) {
|
|
1258
|
+
entry.pipe(fs6.createWriteStream(outputPath));
|
|
1259
|
+
const platform = fileName.includes("android") ? "android" : "ios";
|
|
1260
|
+
if (fileName.endsWith(".js")) {
|
|
1261
|
+
sources[platform].packagerBundle = outputPath;
|
|
1262
|
+
} else if (fileName.endsWith(".hbc.gz")) {
|
|
1263
|
+
sources[platform].hermesBundle = outputPath;
|
|
1264
|
+
} else if (fileName.endsWith(".js.map")) {
|
|
1265
|
+
sources[platform].packagerSourceMap = outputPath;
|
|
1266
|
+
} else if (fileName.endsWith(".hbc.map")) {
|
|
1267
|
+
sources[platform].hermesSourceMap = outputPath;
|
|
1268
|
+
}
|
|
1269
|
+
} else {
|
|
1270
|
+
entry.autodrain();
|
|
1271
|
+
}
|
|
1272
|
+
}).promise();
|
|
1273
|
+
if (Object.values({ ...sources.android, ...sources.ios }).some((source) => source === "")) {
|
|
1274
|
+
throw new Error("invalid artifact");
|
|
1275
|
+
}
|
|
1276
|
+
const [androidHermesBundle, iosHermesBundle] = await Promise.all([
|
|
1277
|
+
decompressGzip(sources.android.hermesBundle),
|
|
1278
|
+
decompressGzip(sources.ios.hermesBundle)
|
|
1279
|
+
]);
|
|
1280
|
+
sources.android.hermesBundle = androidHermesBundle;
|
|
1281
|
+
sources.ios.hermesBundle = iosHermesBundle;
|
|
1282
|
+
return sources;
|
|
1283
|
+
}
|
|
1284
|
+
async function decompressGzip(gzFile) {
|
|
1285
|
+
const outfile = gzFile.replace(/\.gz$/g, "");
|
|
1286
|
+
await pipe(fs6.createReadStream(gzFile), zlib.createGunzip(), fs6.createWriteStream(outfile));
|
|
1287
|
+
return outfile;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
// src/integrations/UploadSentrySourcemap/injectSentryDebugId.ts
|
|
1291
|
+
init_cjs_shims();
|
|
1292
|
+
function injectSentryDebugId(rawSourceMap, debugId) {
|
|
1293
|
+
rawSourceMap.debugId = debugId;
|
|
1294
|
+
return rawSourceMap;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
// src/integrations/UploadSentrySourcemap/mergeSourcemap.ts
|
|
1298
|
+
init_cjs_shims();
|
|
1299
|
+
var import_source_map = require("source-map");
|
|
1300
|
+
async function mergeSourceMaps(packagerSourceMap, hermesSourceMap) {
|
|
1301
|
+
const packagerMapConsumer = await new import_source_map.SourceMapConsumer(packagerSourceMap);
|
|
1302
|
+
const hermesMapConsumer = await new import_source_map.SourceMapConsumer(hermesSourceMap);
|
|
1303
|
+
const generator = import_source_map.SourceMapGenerator.fromSourceMap(hermesMapConsumer);
|
|
1304
|
+
generator.applySourceMap(packagerMapConsumer, hermesMapConsumer.sources[0]);
|
|
1305
|
+
return generator.toJSON();
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// src/integrations/UploadSentrySourcemap/uploadSourcemap.ts
|
|
1309
|
+
init_cjs_shims();
|
|
1310
|
+
var import_cli = __toESM(require("@sentry/cli"), 1);
|
|
1311
|
+
function uploadSourcemap(bundlePath, sourcemapPath, options) {
|
|
1312
|
+
const client = new import_cli.default(null, options);
|
|
1313
|
+
return client.execute(["sourcemaps", "upload", "--debug-id-reference", bundlePath, sourcemapPath], true);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
// src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
|
|
1317
|
+
var UploadSentrySourcemap = class extends import_clipanion3.Command {
|
|
1318
|
+
static paths = [["sentry", "upload-sourcemap"]];
|
|
1319
|
+
apiKey = import_clipanion3.Option.String("--api-key", {
|
|
1320
|
+
required: false,
|
|
1321
|
+
description: "\uC778\uC99D API \uD0A4"
|
|
1322
|
+
});
|
|
1323
|
+
appName = import_clipanion3.Option.String("--app-name", {
|
|
1324
|
+
required: false,
|
|
1325
|
+
description: "\uC571 \uC774\uB984"
|
|
1326
|
+
});
|
|
1327
|
+
deploymentId = import_clipanion3.Option.String("--deployment-id", {
|
|
1328
|
+
required: false,
|
|
1329
|
+
description: "\uBC30\uD3EC ID"
|
|
1330
|
+
});
|
|
1331
|
+
sentryAuthToken = import_clipanion3.Option.String("--sentry-auth-token", {
|
|
1332
|
+
required: false,
|
|
1333
|
+
description: "Sentry \uC778\uC99D\uD0A4"
|
|
1334
|
+
});
|
|
1335
|
+
sentryOrg = import_clipanion3.Option.String("--sentry-org", {
|
|
1336
|
+
required: false,
|
|
1337
|
+
description: "Sentry \uC870\uC9C1"
|
|
1338
|
+
});
|
|
1339
|
+
sentryProject = import_clipanion3.Option.String("--sentry-project", {
|
|
1340
|
+
required: false,
|
|
1341
|
+
description: "Sentry \uD504\uB85C\uC81D\uD2B8"
|
|
1342
|
+
});
|
|
1343
|
+
baseUrl = import_clipanion3.Option.String("--base-url", {
|
|
1344
|
+
description: "API Base URL"
|
|
1345
|
+
});
|
|
1346
|
+
async execute() {
|
|
1347
|
+
const { baseUrl } = this;
|
|
1348
|
+
const apiKey = this.apiKey || await this.promptRequiredValue("password", "\uC571\uC778\uD1A0\uC2A4 API \uD0A4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694", "API \uD0A4\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1349
|
+
const appName = this.appName || await this.promptRequiredValue("text", "\uC571 \uC774\uB984\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uC571 \uC774\uB984\uC740 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1350
|
+
const deploymentId = this.deploymentId || await this.promptRequiredValue("text", "\uBC30\uD3EC ID\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uBC30\uD3EC ID\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1351
|
+
const sentryAuthToken = this.sentryAuthToken || process.env.SENTRY_AUTH_TOKEN || await this.promptRequiredValue("password", "Sentry \uC778\uC99D\uD0A4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uC778\uC99D\uD0A4\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1352
|
+
const sentryOrg = this.sentryOrg || process.env.SENTRY_ORG || await this.promptRequiredValue("text", "Sentry \uC870\uC9C1\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uC870\uC9C1\uC740 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1353
|
+
const sentryProject = this.sentryProject || process.env.SENTRY_PROJECT || await this.promptRequiredValue("text", "Sentry \uD504\uB85C\uC81D\uD2B8\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uD504\uB85C\uC81D\uD2B8\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1354
|
+
try {
|
|
1355
|
+
const zipPath = await downloadArtifacts({ apiKey, appName, deploymentId, baseUrl });
|
|
1356
|
+
const sources = await extractSources(zipPath);
|
|
1357
|
+
await p3.tasks([
|
|
1358
|
+
{
|
|
1359
|
+
title: "Android \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC911...",
|
|
1360
|
+
task: async () => {
|
|
1361
|
+
await this.prepareSourceMapForUpload(sources.android);
|
|
1362
|
+
await uploadSourcemap(sources.android.hermesBundle, sources.android.hermesSourceMap, {
|
|
1363
|
+
authToken: sentryAuthToken,
|
|
1364
|
+
org: sentryOrg,
|
|
1365
|
+
project: sentryProject
|
|
1366
|
+
});
|
|
1367
|
+
return "Android \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC644\uB8CC";
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
title: "iOS \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC911...",
|
|
1372
|
+
task: async () => {
|
|
1373
|
+
await this.prepareSourceMapForUpload(sources.ios);
|
|
1374
|
+
await uploadSourcemap(sources.ios.hermesBundle, sources.ios.hermesSourceMap, {
|
|
1375
|
+
authToken: sentryAuthToken,
|
|
1376
|
+
org: sentryOrg,
|
|
1377
|
+
project: sentryProject
|
|
1378
|
+
});
|
|
1379
|
+
return "iOS \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC644\uB8CC";
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
]);
|
|
1383
|
+
p3.outro("Sentry \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC644\uB8CC");
|
|
1384
|
+
} catch (error) {
|
|
1385
|
+
if (error instanceof Error) {
|
|
1386
|
+
p3.log.error(error.message);
|
|
1387
|
+
} else {
|
|
1388
|
+
console.error(error);
|
|
1389
|
+
}
|
|
1390
|
+
process.exit(1);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
async prepareSourceMapForUpload(sources) {
|
|
1394
|
+
const debugId = await extractSentryDebugId(sources.packagerBundle);
|
|
1395
|
+
if (debugId == null) {
|
|
1396
|
+
throw new Error("Sentry Debug ID\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1397
|
+
}
|
|
1398
|
+
const mergedSourceMap = await mergeSourceMaps(
|
|
1399
|
+
await fs7.readFile(sources.packagerSourceMap, "utf-8"),
|
|
1400
|
+
await fs7.readFile(sources.hermesSourceMap, "utf-8")
|
|
1401
|
+
);
|
|
1402
|
+
const injectedSourceMap = injectSentryDebugId(mergedSourceMap, debugId);
|
|
1403
|
+
await fs7.writeFile(sources.hermesSourceMap, JSON.stringify(injectedSourceMap, null, 2), "utf-8");
|
|
1404
|
+
}
|
|
1405
|
+
async promptRequiredValue(type, message, validateMessage) {
|
|
1406
|
+
const result = await p3[type]({
|
|
1407
|
+
message,
|
|
1408
|
+
validate: (value) => {
|
|
1409
|
+
if (value.length === 0) {
|
|
1410
|
+
return validateMessage;
|
|
1411
|
+
}
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
});
|
|
1415
|
+
if (p3.isCancel(result)) {
|
|
1416
|
+
throw new Error("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB418\uC5C8\uC5B4\uC694.");
|
|
1417
|
+
}
|
|
1418
|
+
return result;
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
|
|
1154
1422
|
// src/index.ts
|
|
1155
1423
|
function initialize() {
|
|
1156
|
-
const cli = new
|
|
1424
|
+
const cli = new import_clipanion4.Cli({
|
|
1157
1425
|
binaryLabel: "ait",
|
|
1158
1426
|
binaryName: "ait"
|
|
1159
1427
|
});
|
|
1160
1428
|
cli.register(DeployCommand);
|
|
1161
1429
|
cli.register(InitCommand);
|
|
1430
|
+
cli.register(UploadSentrySourcemap);
|
|
1162
1431
|
cli.runExit(process.argv.slice(2));
|
|
1163
1432
|
}
|
|
1164
1433
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
|
@@ -193,11 +193,11 @@ var require_common = __commonJS({
|
|
|
193
193
|
let enableOverride = null;
|
|
194
194
|
let namespacesCache;
|
|
195
195
|
let enabledCache;
|
|
196
|
-
function
|
|
197
|
-
if (!
|
|
196
|
+
function debug5(...args) {
|
|
197
|
+
if (!debug5.enabled) {
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
|
-
const self =
|
|
200
|
+
const self = debug5;
|
|
201
201
|
const curr = Number(/* @__PURE__ */ new Date());
|
|
202
202
|
const ms = curr - (prevTime || curr);
|
|
203
203
|
self.diff = ms;
|
|
@@ -227,12 +227,12 @@ var require_common = __commonJS({
|
|
|
227
227
|
const logFn = self.log || createDebug.log;
|
|
228
228
|
logFn.apply(self, args);
|
|
229
229
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
Object.defineProperty(
|
|
230
|
+
debug5.namespace = namespace;
|
|
231
|
+
debug5.useColors = createDebug.useColors();
|
|
232
|
+
debug5.color = createDebug.selectColor(namespace);
|
|
233
|
+
debug5.extend = extend;
|
|
234
|
+
debug5.destroy = createDebug.destroy;
|
|
235
|
+
Object.defineProperty(debug5, "enabled", {
|
|
236
236
|
enumerable: true,
|
|
237
237
|
configurable: false,
|
|
238
238
|
get: () => {
|
|
@@ -250,9 +250,9 @@ var require_common = __commonJS({
|
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
252
|
if (typeof createDebug.init === "function") {
|
|
253
|
-
createDebug.init(
|
|
253
|
+
createDebug.init(debug5);
|
|
254
254
|
}
|
|
255
|
-
return
|
|
255
|
+
return debug5;
|
|
256
256
|
}
|
|
257
257
|
function extend(namespace, delimiter) {
|
|
258
258
|
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
@@ -518,7 +518,7 @@ var require_node = __commonJS({
|
|
|
518
518
|
var tty = __require("tty");
|
|
519
519
|
var util = __require("util");
|
|
520
520
|
exports.init = init;
|
|
521
|
-
exports.log =
|
|
521
|
+
exports.log = log4;
|
|
522
522
|
exports.formatArgs = formatArgs;
|
|
523
523
|
exports.save = save;
|
|
524
524
|
exports.load = load;
|
|
@@ -653,7 +653,7 @@ var require_node = __commonJS({
|
|
|
653
653
|
}
|
|
654
654
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
655
655
|
}
|
|
656
|
-
function
|
|
656
|
+
function log4(...args) {
|
|
657
657
|
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
|
|
658
658
|
}
|
|
659
659
|
function save(namespaces) {
|
|
@@ -666,11 +666,11 @@ var require_node = __commonJS({
|
|
|
666
666
|
function load() {
|
|
667
667
|
return process.env.DEBUG;
|
|
668
668
|
}
|
|
669
|
-
function init(
|
|
670
|
-
|
|
669
|
+
function init(debug5) {
|
|
670
|
+
debug5.inspectOpts = {};
|
|
671
671
|
const keys = Object.keys(exports.inspectOpts);
|
|
672
672
|
for (let i = 0; i < keys.length; i++) {
|
|
673
|
-
|
|
673
|
+
debug5.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
674
674
|
}
|
|
675
675
|
}
|
|
676
676
|
module.exports = require_common()(exports);
|
|
@@ -704,10 +704,10 @@ var require_picocolors = __commonJS({
|
|
|
704
704
|
"../../.yarn/cache/picocolors-npm-1.1.1-b0c45fa35e-e2e3e8170a.zip/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
705
705
|
"use strict";
|
|
706
706
|
init_esm_shims();
|
|
707
|
-
var
|
|
708
|
-
var argv =
|
|
709
|
-
var env =
|
|
710
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") ||
|
|
707
|
+
var p4 = process || {};
|
|
708
|
+
var argv = p4.argv || [];
|
|
709
|
+
var env = p4.env || {};
|
|
710
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p4.platform === "win32" || (p4.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
711
711
|
var formatter = (open, close, replace = open) => (input) => {
|
|
712
712
|
let string = "" + input, index = string.indexOf(close, open.length);
|
|
713
713
|
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
@@ -779,7 +779,7 @@ import { Cli } from "clipanion";
|
|
|
779
779
|
|
|
780
780
|
// src/DeployCommand.ts
|
|
781
781
|
init_esm_shims();
|
|
782
|
-
var
|
|
782
|
+
var import_debug3 = __toESM(require_src(), 1);
|
|
783
783
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
784
784
|
import assert from "assert";
|
|
785
785
|
import fs2 from "fs";
|
|
@@ -795,11 +795,31 @@ var DEFAULT_API_BASE_URL = "https://apps-in-toss.toss.im/console";
|
|
|
795
795
|
|
|
796
796
|
// src/utils/upload.ts
|
|
797
797
|
init_esm_shims();
|
|
798
|
-
var
|
|
798
|
+
var import_debug2 = __toESM(require_src(), 1);
|
|
799
799
|
import fs from "fs";
|
|
800
|
-
|
|
800
|
+
|
|
801
|
+
// src/utils/handleFetchResponse.ts
|
|
802
|
+
init_esm_shims();
|
|
803
|
+
var import_debug = __toESM(require_src(), 1);
|
|
804
|
+
var debug = (0, import_debug.default)("api");
|
|
805
|
+
async function handleFetchResponse(response) {
|
|
806
|
+
debug(`Response ${response.status} ${response.statusText}`);
|
|
807
|
+
if (!response.ok) {
|
|
808
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
809
|
+
}
|
|
810
|
+
const data = await response.clone().json();
|
|
811
|
+
debug("response", data);
|
|
812
|
+
if (data.resultType !== "SUCCESS") {
|
|
813
|
+
const errorCode = data?.error?.errorCode ?? "-1";
|
|
814
|
+
const errorReason = data?.error.reason ?? "unknown";
|
|
815
|
+
throw new Error(`${errorReason} (Code: ${errorCode})`);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
// src/utils/upload.ts
|
|
820
|
+
var debug2 = (0, import_debug2.default)("cli:deploy");
|
|
801
821
|
async function uploadArtifact(config) {
|
|
802
|
-
|
|
822
|
+
debug2("uploadArtifact", config);
|
|
803
823
|
const baseUrl = config.baseUrl ?? DEFAULT_API_BASE_URL;
|
|
804
824
|
const response = await fetch(
|
|
805
825
|
`${baseUrl}/api-public/v3/appsintossconsole/bundles/${config.appName}/deployments/${config.deploymentId}/upload`,
|
|
@@ -813,24 +833,11 @@ async function uploadArtifact(config) {
|
|
|
813
833
|
duplex: "half"
|
|
814
834
|
}
|
|
815
835
|
);
|
|
816
|
-
return
|
|
817
|
-
}
|
|
818
|
-
async function handleResponse(response) {
|
|
819
|
-
debug(`Response ${response.status} ${response.statusText}`);
|
|
820
|
-
if (!response.ok) {
|
|
821
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
822
|
-
}
|
|
823
|
-
const data = await response.clone().json();
|
|
824
|
-
debug("uploadArtifact response", data);
|
|
825
|
-
if (data.resultType !== "SUCCESS") {
|
|
826
|
-
const errorCode = data?.error?.errorCode ?? "-1";
|
|
827
|
-
const errorReason = data?.error.reason ?? "unknown";
|
|
828
|
-
throw new Error(`${errorReason} (Code: ${errorCode})`);
|
|
829
|
-
}
|
|
836
|
+
return handleFetchResponse(response);
|
|
830
837
|
}
|
|
831
838
|
|
|
832
839
|
// src/DeployCommand.ts
|
|
833
|
-
var
|
|
840
|
+
var debug3 = (0, import_debug3.default)("cli:deploy");
|
|
834
841
|
var DeployCommand = class extends Command {
|
|
835
842
|
static paths = [["deploy"]];
|
|
836
843
|
apiKey = Option.String("--api-key", {
|
|
@@ -869,7 +876,7 @@ var DeployCommand = class extends Command {
|
|
|
869
876
|
assert(typeof deploymentId2 === "string", "invalid deploymentId");
|
|
870
877
|
return { appName: appName2, deploymentId: deploymentId2 };
|
|
871
878
|
}).catch((error) => {
|
|
872
|
-
|
|
879
|
+
debug3("invalid ait file", error);
|
|
873
880
|
throw new Error("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 ait \uD30C\uC77C\uC785\uB2C8\uB2E4");
|
|
874
881
|
});
|
|
875
882
|
const colorAppName = import_picocolors.default.underline(import_picocolors.default.cyan(appName));
|
|
@@ -1147,6 +1154,267 @@ var InitCommand = class extends Command2 {
|
|
|
1147
1154
|
}
|
|
1148
1155
|
};
|
|
1149
1156
|
|
|
1157
|
+
// src/integrations/UploadSentrySourcemap/index.ts
|
|
1158
|
+
init_esm_shims();
|
|
1159
|
+
|
|
1160
|
+
// src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
|
|
1161
|
+
init_esm_shims();
|
|
1162
|
+
import * as fs7 from "fs/promises";
|
|
1163
|
+
import * as p3 from "@clack/prompts";
|
|
1164
|
+
import { Command as Command3, Option as Option3 } from "clipanion";
|
|
1165
|
+
|
|
1166
|
+
// src/integrations/UploadSentrySourcemap/downloadArtifacts.ts
|
|
1167
|
+
init_esm_shims();
|
|
1168
|
+
var import_debug4 = __toESM(require_src(), 1);
|
|
1169
|
+
import * as fs4 from "fs";
|
|
1170
|
+
import * as os from "os";
|
|
1171
|
+
import * as path3 from "path";
|
|
1172
|
+
import { pipeline } from "stream";
|
|
1173
|
+
import { promisify } from "util";
|
|
1174
|
+
var debug4 = (0, import_debug4.default)("integrations:sentry");
|
|
1175
|
+
var streamPipeline = promisify(pipeline);
|
|
1176
|
+
async function downloadArtifacts(options) {
|
|
1177
|
+
const { appName, deploymentId, apiKey, baseUrl = DEFAULT_API_BASE_URL } = options;
|
|
1178
|
+
const params = new URLSearchParams({
|
|
1179
|
+
appName,
|
|
1180
|
+
deploymentId
|
|
1181
|
+
});
|
|
1182
|
+
const requestUrl = `${baseUrl}/api-public/v3/openapi/bundles/download?${params.toString()}`;
|
|
1183
|
+
debug4("Request URL", { requestUrl });
|
|
1184
|
+
const response = await fetch(`${baseUrl}/api-public/v3/openapi/bundles/download?${params.toString()}`, {
|
|
1185
|
+
method: "GET",
|
|
1186
|
+
headers: {
|
|
1187
|
+
"Content-Type": "application/json",
|
|
1188
|
+
Authorization: `Bearer ${apiKey}`
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
if (!response.ok) {
|
|
1192
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
1193
|
+
}
|
|
1194
|
+
if (response.body == null) {
|
|
1195
|
+
throw new Error("No response body");
|
|
1196
|
+
}
|
|
1197
|
+
const tmpDir = await createTempDirectory();
|
|
1198
|
+
const tmpFile = `${deploymentId}.zip`;
|
|
1199
|
+
const tmpFilePath = path3.join(tmpDir.path, tmpFile);
|
|
1200
|
+
const fileStream = fs4.createWriteStream(tmpFilePath);
|
|
1201
|
+
await streamPipeline(response.body, fileStream);
|
|
1202
|
+
debug4("Artifacts downloaded", { tmpFilePath });
|
|
1203
|
+
return tmpFilePath;
|
|
1204
|
+
}
|
|
1205
|
+
function createTempDirectory() {
|
|
1206
|
+
const tempDir = path3.join(os.tmpdir(), "apps-in-toss", "sentry-integration");
|
|
1207
|
+
fs4.mkdirSync(tempDir, { recursive: true });
|
|
1208
|
+
debug4("Temp directory created", { tempDir });
|
|
1209
|
+
return {
|
|
1210
|
+
path: tempDir,
|
|
1211
|
+
cleanup: () => {
|
|
1212
|
+
fs4.rmSync(tempDir, { recursive: true, force: true });
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
// src/integrations/UploadSentrySourcemap/extractSentryDebugId.ts
|
|
1218
|
+
init_esm_shims();
|
|
1219
|
+
import fs5 from "fs/promises";
|
|
1220
|
+
async function extractSentryDebugId(bundlePath) {
|
|
1221
|
+
const bundleContent = await fs5.readFile(bundlePath, "utf-8");
|
|
1222
|
+
return bundleContent.match(/SENTRY_DEBUG_ID=([\w-]+)/)?.[1];
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// src/integrations/UploadSentrySourcemap/extractSources.ts
|
|
1226
|
+
init_esm_shims();
|
|
1227
|
+
import * as fs6 from "fs";
|
|
1228
|
+
import * as path4 from "path";
|
|
1229
|
+
import { pipeline as pipeline2 } from "stream";
|
|
1230
|
+
import { promisify as promisify2 } from "util";
|
|
1231
|
+
import * as zlib from "zlib";
|
|
1232
|
+
import * as unzipper from "unzipper";
|
|
1233
|
+
var pipe = promisify2(pipeline2);
|
|
1234
|
+
async function extractSources(zipPath) {
|
|
1235
|
+
const sources = {
|
|
1236
|
+
android: {
|
|
1237
|
+
packagerBundle: "",
|
|
1238
|
+
packagerSourceMap: "",
|
|
1239
|
+
hermesBundle: "",
|
|
1240
|
+
hermesSourceMap: ""
|
|
1241
|
+
},
|
|
1242
|
+
ios: {
|
|
1243
|
+
packagerBundle: "",
|
|
1244
|
+
packagerSourceMap: "",
|
|
1245
|
+
hermesBundle: "",
|
|
1246
|
+
hermesSourceMap: ""
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
await fs6.createReadStream(zipPath).pipe(unzipper.Parse()).on("entry", async (entry) => {
|
|
1250
|
+
const isRoot = !entry.path.includes("/");
|
|
1251
|
+
const fileName = path4.basename(entry.path);
|
|
1252
|
+
const outputPath = path4.join(path4.dirname(zipPath), fileName);
|
|
1253
|
+
if (isRoot) {
|
|
1254
|
+
entry.pipe(fs6.createWriteStream(outputPath));
|
|
1255
|
+
const platform = fileName.includes("android") ? "android" : "ios";
|
|
1256
|
+
if (fileName.endsWith(".js")) {
|
|
1257
|
+
sources[platform].packagerBundle = outputPath;
|
|
1258
|
+
} else if (fileName.endsWith(".hbc.gz")) {
|
|
1259
|
+
sources[platform].hermesBundle = outputPath;
|
|
1260
|
+
} else if (fileName.endsWith(".js.map")) {
|
|
1261
|
+
sources[platform].packagerSourceMap = outputPath;
|
|
1262
|
+
} else if (fileName.endsWith(".hbc.map")) {
|
|
1263
|
+
sources[platform].hermesSourceMap = outputPath;
|
|
1264
|
+
}
|
|
1265
|
+
} else {
|
|
1266
|
+
entry.autodrain();
|
|
1267
|
+
}
|
|
1268
|
+
}).promise();
|
|
1269
|
+
if (Object.values({ ...sources.android, ...sources.ios }).some((source) => source === "")) {
|
|
1270
|
+
throw new Error("invalid artifact");
|
|
1271
|
+
}
|
|
1272
|
+
const [androidHermesBundle, iosHermesBundle] = await Promise.all([
|
|
1273
|
+
decompressGzip(sources.android.hermesBundle),
|
|
1274
|
+
decompressGzip(sources.ios.hermesBundle)
|
|
1275
|
+
]);
|
|
1276
|
+
sources.android.hermesBundle = androidHermesBundle;
|
|
1277
|
+
sources.ios.hermesBundle = iosHermesBundle;
|
|
1278
|
+
return sources;
|
|
1279
|
+
}
|
|
1280
|
+
async function decompressGzip(gzFile) {
|
|
1281
|
+
const outfile = gzFile.replace(/\.gz$/g, "");
|
|
1282
|
+
await pipe(fs6.createReadStream(gzFile), zlib.createGunzip(), fs6.createWriteStream(outfile));
|
|
1283
|
+
return outfile;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
// src/integrations/UploadSentrySourcemap/injectSentryDebugId.ts
|
|
1287
|
+
init_esm_shims();
|
|
1288
|
+
function injectSentryDebugId(rawSourceMap, debugId) {
|
|
1289
|
+
rawSourceMap.debugId = debugId;
|
|
1290
|
+
return rawSourceMap;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// src/integrations/UploadSentrySourcemap/mergeSourcemap.ts
|
|
1294
|
+
init_esm_shims();
|
|
1295
|
+
import { SourceMapConsumer, SourceMapGenerator } from "source-map";
|
|
1296
|
+
async function mergeSourceMaps(packagerSourceMap, hermesSourceMap) {
|
|
1297
|
+
const packagerMapConsumer = await new SourceMapConsumer(packagerSourceMap);
|
|
1298
|
+
const hermesMapConsumer = await new SourceMapConsumer(hermesSourceMap);
|
|
1299
|
+
const generator = SourceMapGenerator.fromSourceMap(hermesMapConsumer);
|
|
1300
|
+
generator.applySourceMap(packagerMapConsumer, hermesMapConsumer.sources[0]);
|
|
1301
|
+
return generator.toJSON();
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// src/integrations/UploadSentrySourcemap/uploadSourcemap.ts
|
|
1305
|
+
init_esm_shims();
|
|
1306
|
+
import SentryCLI from "@sentry/cli";
|
|
1307
|
+
function uploadSourcemap(bundlePath, sourcemapPath, options) {
|
|
1308
|
+
const client = new SentryCLI(null, options);
|
|
1309
|
+
return client.execute(["sourcemaps", "upload", "--debug-id-reference", bundlePath, sourcemapPath], true);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
// src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
|
|
1313
|
+
var UploadSentrySourcemap = class extends Command3 {
|
|
1314
|
+
static paths = [["sentry", "upload-sourcemap"]];
|
|
1315
|
+
apiKey = Option3.String("--api-key", {
|
|
1316
|
+
required: false,
|
|
1317
|
+
description: "\uC778\uC99D API \uD0A4"
|
|
1318
|
+
});
|
|
1319
|
+
appName = Option3.String("--app-name", {
|
|
1320
|
+
required: false,
|
|
1321
|
+
description: "\uC571 \uC774\uB984"
|
|
1322
|
+
});
|
|
1323
|
+
deploymentId = Option3.String("--deployment-id", {
|
|
1324
|
+
required: false,
|
|
1325
|
+
description: "\uBC30\uD3EC ID"
|
|
1326
|
+
});
|
|
1327
|
+
sentryAuthToken = Option3.String("--sentry-auth-token", {
|
|
1328
|
+
required: false,
|
|
1329
|
+
description: "Sentry \uC778\uC99D\uD0A4"
|
|
1330
|
+
});
|
|
1331
|
+
sentryOrg = Option3.String("--sentry-org", {
|
|
1332
|
+
required: false,
|
|
1333
|
+
description: "Sentry \uC870\uC9C1"
|
|
1334
|
+
});
|
|
1335
|
+
sentryProject = Option3.String("--sentry-project", {
|
|
1336
|
+
required: false,
|
|
1337
|
+
description: "Sentry \uD504\uB85C\uC81D\uD2B8"
|
|
1338
|
+
});
|
|
1339
|
+
baseUrl = Option3.String("--base-url", {
|
|
1340
|
+
description: "API Base URL"
|
|
1341
|
+
});
|
|
1342
|
+
async execute() {
|
|
1343
|
+
const { baseUrl } = this;
|
|
1344
|
+
const apiKey = this.apiKey || await this.promptRequiredValue("password", "\uC571\uC778\uD1A0\uC2A4 API \uD0A4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694", "API \uD0A4\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1345
|
+
const appName = this.appName || await this.promptRequiredValue("text", "\uC571 \uC774\uB984\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uC571 \uC774\uB984\uC740 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1346
|
+
const deploymentId = this.deploymentId || await this.promptRequiredValue("text", "\uBC30\uD3EC ID\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uBC30\uD3EC ID\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1347
|
+
const sentryAuthToken = this.sentryAuthToken || process.env.SENTRY_AUTH_TOKEN || await this.promptRequiredValue("password", "Sentry \uC778\uC99D\uD0A4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uC778\uC99D\uD0A4\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1348
|
+
const sentryOrg = this.sentryOrg || process.env.SENTRY_ORG || await this.promptRequiredValue("text", "Sentry \uC870\uC9C1\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uC870\uC9C1\uC740 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1349
|
+
const sentryProject = this.sentryProject || process.env.SENTRY_PROJECT || await this.promptRequiredValue("text", "Sentry \uD504\uB85C\uC81D\uD2B8\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694", "\uD504\uB85C\uC81D\uD2B8\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.");
|
|
1350
|
+
try {
|
|
1351
|
+
const zipPath = await downloadArtifacts({ apiKey, appName, deploymentId, baseUrl });
|
|
1352
|
+
const sources = await extractSources(zipPath);
|
|
1353
|
+
await p3.tasks([
|
|
1354
|
+
{
|
|
1355
|
+
title: "Android \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC911...",
|
|
1356
|
+
task: async () => {
|
|
1357
|
+
await this.prepareSourceMapForUpload(sources.android);
|
|
1358
|
+
await uploadSourcemap(sources.android.hermesBundle, sources.android.hermesSourceMap, {
|
|
1359
|
+
authToken: sentryAuthToken,
|
|
1360
|
+
org: sentryOrg,
|
|
1361
|
+
project: sentryProject
|
|
1362
|
+
});
|
|
1363
|
+
return "Android \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC644\uB8CC";
|
|
1364
|
+
}
|
|
1365
|
+
},
|
|
1366
|
+
{
|
|
1367
|
+
title: "iOS \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC911...",
|
|
1368
|
+
task: async () => {
|
|
1369
|
+
await this.prepareSourceMapForUpload(sources.ios);
|
|
1370
|
+
await uploadSourcemap(sources.ios.hermesBundle, sources.ios.hermesSourceMap, {
|
|
1371
|
+
authToken: sentryAuthToken,
|
|
1372
|
+
org: sentryOrg,
|
|
1373
|
+
project: sentryProject
|
|
1374
|
+
});
|
|
1375
|
+
return "iOS \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC644\uB8CC";
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
]);
|
|
1379
|
+
p3.outro("Sentry \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC644\uB8CC");
|
|
1380
|
+
} catch (error) {
|
|
1381
|
+
if (error instanceof Error) {
|
|
1382
|
+
p3.log.error(error.message);
|
|
1383
|
+
} else {
|
|
1384
|
+
console.error(error);
|
|
1385
|
+
}
|
|
1386
|
+
process.exit(1);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
async prepareSourceMapForUpload(sources) {
|
|
1390
|
+
const debugId = await extractSentryDebugId(sources.packagerBundle);
|
|
1391
|
+
if (debugId == null) {
|
|
1392
|
+
throw new Error("Sentry Debug ID\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1393
|
+
}
|
|
1394
|
+
const mergedSourceMap = await mergeSourceMaps(
|
|
1395
|
+
await fs7.readFile(sources.packagerSourceMap, "utf-8"),
|
|
1396
|
+
await fs7.readFile(sources.hermesSourceMap, "utf-8")
|
|
1397
|
+
);
|
|
1398
|
+
const injectedSourceMap = injectSentryDebugId(mergedSourceMap, debugId);
|
|
1399
|
+
await fs7.writeFile(sources.hermesSourceMap, JSON.stringify(injectedSourceMap, null, 2), "utf-8");
|
|
1400
|
+
}
|
|
1401
|
+
async promptRequiredValue(type, message, validateMessage) {
|
|
1402
|
+
const result = await p3[type]({
|
|
1403
|
+
message,
|
|
1404
|
+
validate: (value) => {
|
|
1405
|
+
if (value.length === 0) {
|
|
1406
|
+
return validateMessage;
|
|
1407
|
+
}
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
if (p3.isCancel(result)) {
|
|
1412
|
+
throw new Error("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB418\uC5C8\uC5B4\uC694.");
|
|
1413
|
+
}
|
|
1414
|
+
return result;
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1150
1418
|
// src/index.ts
|
|
1151
1419
|
function initialize() {
|
|
1152
1420
|
const cli = new Cli({
|
|
@@ -1155,6 +1423,7 @@ function initialize() {
|
|
|
1155
1423
|
});
|
|
1156
1424
|
cli.register(DeployCommand);
|
|
1157
1425
|
cli.register(InitCommand);
|
|
1426
|
+
cli.register(UploadSentrySourcemap);
|
|
1158
1427
|
cli.runExit(process.argv.slice(2));
|
|
1159
1428
|
}
|
|
1160
1429
|
export {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.29",
|
|
5
5
|
"description": "CLI for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/debug": "^4",
|
|
28
28
|
"@types/node": "^22.10.2",
|
|
29
|
+
"@types/unzipper": "^0",
|
|
29
30
|
"debug": "^4.4.0",
|
|
30
31
|
"es-toolkit": "^1.32.0",
|
|
31
32
|
"eslint": "^9.7.0",
|
|
@@ -37,10 +38,13 @@
|
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@clack/prompts": "^0.10.0",
|
|
39
40
|
"@react-native-bedrock/utils": "0.0.25",
|
|
40
|
-
"
|
|
41
|
+
"@sentry/cli": "^2.46.0",
|
|
42
|
+
"clipanion": "^4.0.0-rc.4",
|
|
43
|
+
"source-map": "^0.8.0-beta.0",
|
|
44
|
+
"unzipper": "^0.12.3"
|
|
41
45
|
},
|
|
42
46
|
"publishConfig": {
|
|
43
47
|
"access": "public"
|
|
44
48
|
},
|
|
45
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "d05ff237b358da05d562728d0ac965f00c419d63"
|
|
46
50
|
}
|