@apps-in-toss/cli 1.0.3 → 1.1.1
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 +391 -125
- package/dist/index.js +390 -124
- package/package.json +3 -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 debug6(...args) {
|
|
196
|
+
if (!debug6.enabled) {
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
|
-
const self =
|
|
199
|
+
const self = debug6;
|
|
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
|
+
debug6.namespace = namespace;
|
|
230
|
+
debug6.useColors = createDebug.useColors();
|
|
231
|
+
debug6.color = createDebug.selectColor(namespace);
|
|
232
|
+
debug6.extend = extend;
|
|
233
|
+
debug6.destroy = createDebug.destroy;
|
|
234
|
+
Object.defineProperty(debug6, "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(debug6);
|
|
253
253
|
}
|
|
254
|
-
return
|
|
254
|
+
return debug6;
|
|
255
255
|
}
|
|
256
256
|
function extend(namespace, delimiter) {
|
|
257
257
|
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
@@ -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(debug6) {
|
|
669
|
+
debug6.inspectOpts = {};
|
|
670
670
|
const keys = Object.keys(exports2.inspectOpts);
|
|
671
671
|
for (let i = 0; i < keys.length; i++) {
|
|
672
|
-
|
|
672
|
+
debug6.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 p5 = process || {};
|
|
707
|
+
var argv = p5.argv || [];
|
|
708
|
+
var env = p5.env || {};
|
|
709
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p5.platform === "win32" || (p5.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,19 +779,73 @@ __export(src_exports, {
|
|
|
779
779
|
});
|
|
780
780
|
module.exports = __toCommonJS(src_exports);
|
|
781
781
|
init_cjs_shims();
|
|
782
|
-
var
|
|
782
|
+
var import_clipanion6 = require("clipanion");
|
|
783
783
|
|
|
784
784
|
// src/DeployCommand.ts
|
|
785
785
|
init_cjs_shims();
|
|
786
786
|
var import_assert = __toESM(require("assert"), 1);
|
|
787
|
-
var
|
|
788
|
-
var
|
|
787
|
+
var import_fs3 = __toESM(require("fs"), 1);
|
|
788
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
789
789
|
var p = __toESM(require("@clack/prompts"), 1);
|
|
790
790
|
var import_utils = require("@granite-js/utils");
|
|
791
791
|
var import_clipanion = require("clipanion");
|
|
792
792
|
var import_debug3 = __toESM(require_src(), 1);
|
|
793
793
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
794
794
|
|
|
795
|
+
// src/utils/TokenStorage.ts
|
|
796
|
+
init_cjs_shims();
|
|
797
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
798
|
+
var import_os = __toESM(require("os"), 1);
|
|
799
|
+
var import_path = __toESM(require("path"), 1);
|
|
800
|
+
var TokenStorage = class {
|
|
801
|
+
static get path() {
|
|
802
|
+
const home = import_os.default.homedir();
|
|
803
|
+
const dir = import_path.default.join(home, ".ait");
|
|
804
|
+
if (!import_fs.default.existsSync(dir)) {
|
|
805
|
+
import_fs.default.mkdirSync(dir, { recursive: true });
|
|
806
|
+
}
|
|
807
|
+
return import_path.default.join(dir, "credentials");
|
|
808
|
+
}
|
|
809
|
+
static read() {
|
|
810
|
+
const file = this.path;
|
|
811
|
+
if (!import_fs.default.existsSync(file)) {
|
|
812
|
+
return {};
|
|
813
|
+
}
|
|
814
|
+
const raw = import_fs.default.readFileSync(file, "utf8");
|
|
815
|
+
try {
|
|
816
|
+
const parsed = JSON.parse(raw);
|
|
817
|
+
if (parsed && typeof parsed === "object") {
|
|
818
|
+
return parsed;
|
|
819
|
+
}
|
|
820
|
+
} catch {
|
|
821
|
+
}
|
|
822
|
+
return {};
|
|
823
|
+
}
|
|
824
|
+
static write(map) {
|
|
825
|
+
const file = this.path;
|
|
826
|
+
const content = JSON.stringify(map, null, 2);
|
|
827
|
+
import_fs.default.writeFileSync(file, content, { encoding: "utf8" });
|
|
828
|
+
}
|
|
829
|
+
static set(workspace, token) {
|
|
830
|
+
const creds = this.read();
|
|
831
|
+
creds[workspace] = token;
|
|
832
|
+
this.write(creds);
|
|
833
|
+
}
|
|
834
|
+
static delete(workspace) {
|
|
835
|
+
const creds = this.read();
|
|
836
|
+
if (workspace in creds) {
|
|
837
|
+
delete creds[workspace];
|
|
838
|
+
this.write(creds);
|
|
839
|
+
return true;
|
|
840
|
+
}
|
|
841
|
+
return false;
|
|
842
|
+
}
|
|
843
|
+
static get(workspace) {
|
|
844
|
+
const creds = this.read();
|
|
845
|
+
return creds[workspace];
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
|
|
795
849
|
// src/utils/constants.ts
|
|
796
850
|
init_cjs_shims();
|
|
797
851
|
var APP_MANIFEST_NAME = "app.json";
|
|
@@ -799,9 +853,21 @@ var DEFAULT_API_BASE_URL = "https://apps-in-toss.toss.im/console";
|
|
|
799
853
|
|
|
800
854
|
// src/utils/upload.ts
|
|
801
855
|
init_cjs_shims();
|
|
802
|
-
var
|
|
856
|
+
var import_fs2 = __toESM(require("fs"), 1);
|
|
803
857
|
var import_debug2 = __toESM(require_src(), 1);
|
|
804
858
|
|
|
859
|
+
// src/utils/flowAsync.ts
|
|
860
|
+
init_cjs_shims();
|
|
861
|
+
function flowAsync(...funcs) {
|
|
862
|
+
return async function(...args) {
|
|
863
|
+
let result = funcs.length ? await funcs[0].apply(this, args) : args[0];
|
|
864
|
+
for (let i = 1; i < funcs.length; i++) {
|
|
865
|
+
result = await funcs[i]?.call(this, result);
|
|
866
|
+
}
|
|
867
|
+
return result;
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
|
|
805
871
|
// src/utils/handleFetchResponse.ts
|
|
806
872
|
init_cjs_shims();
|
|
807
873
|
var import_debug = __toESM(require_src(), 1);
|
|
@@ -815,29 +881,139 @@ async function handleFetchResponse(response) {
|
|
|
815
881
|
debug("response", data);
|
|
816
882
|
if (data.resultType !== "SUCCESS") {
|
|
817
883
|
const errorCode = data?.error?.errorCode ?? "-1";
|
|
818
|
-
const errorReason = data?.error
|
|
884
|
+
const errorReason = data?.error?.reason ?? "unknown";
|
|
819
885
|
throw new Error(`${errorReason} (Code: ${errorCode})`);
|
|
820
886
|
}
|
|
887
|
+
return data.success;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
// src/utils/withRetry.ts
|
|
891
|
+
init_cjs_shims();
|
|
892
|
+
var import_promises = require("timers/promises");
|
|
893
|
+
async function withRetry(fn, options = {}) {
|
|
894
|
+
const { maxRetries = 60, delayMs = 1e4, shouldRetryOnResult, shouldRetryOnError, onRetry } = options;
|
|
895
|
+
let attempt = 0;
|
|
896
|
+
while (attempt < maxRetries) {
|
|
897
|
+
try {
|
|
898
|
+
const result = await fn();
|
|
899
|
+
if (shouldRetryOnResult && shouldRetryOnResult(result)) {
|
|
900
|
+
onRetry?.(attempt + 1, { result });
|
|
901
|
+
await (0, import_promises.setTimeout)(delayMs);
|
|
902
|
+
attempt++;
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
905
|
+
return result;
|
|
906
|
+
} catch (error) {
|
|
907
|
+
const retryable = shouldRetryOnError ? shouldRetryOnError(error) : false;
|
|
908
|
+
if (!retryable) {
|
|
909
|
+
throw error;
|
|
910
|
+
}
|
|
911
|
+
onRetry?.(attempt + 1, { error });
|
|
912
|
+
await (0, import_promises.setTimeout)(delayMs);
|
|
913
|
+
attempt++;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
throw new Error("\uCD5C\uB300 \uB300\uAE30\uC2DC\uAC04\uC744 \uCD08\uACFC\uD588\uC5B4\uC694.");
|
|
821
917
|
}
|
|
822
918
|
|
|
823
919
|
// src/utils/upload.ts
|
|
824
920
|
var debug2 = (0, import_debug2.default)("cli:deploy");
|
|
825
921
|
async function uploadArtifact(config) {
|
|
826
922
|
debug2("uploadArtifact", config);
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
923
|
+
return flowAsync(uploadStart(), uploadArtifactToRemote(), uploadComplete(), checkBundleStatus())(config);
|
|
924
|
+
}
|
|
925
|
+
function uploadStart() {
|
|
926
|
+
return async (config) => {
|
|
927
|
+
debug2("uploadStart", config);
|
|
928
|
+
const baseUrl = config.baseUrl ?? DEFAULT_API_BASE_URL;
|
|
929
|
+
const response = await fetch(`${baseUrl}/api-public/v3/openapi/bundles/${config.appName}/upload-start`, {
|
|
831
930
|
method: "POST",
|
|
832
931
|
headers: {
|
|
833
|
-
"Content-Type": "application/
|
|
834
|
-
|
|
932
|
+
"Content-Type": "application/json",
|
|
933
|
+
Authorization: `Bearer ${config.apiKey}`
|
|
835
934
|
},
|
|
836
|
-
body:
|
|
935
|
+
body: JSON.stringify({
|
|
936
|
+
deploymentId: config.deploymentId
|
|
937
|
+
})
|
|
938
|
+
});
|
|
939
|
+
return {
|
|
940
|
+
config,
|
|
941
|
+
output: await handleFetchResponse(response)
|
|
942
|
+
};
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
function uploadArtifactToRemote() {
|
|
946
|
+
return async (params) => {
|
|
947
|
+
const { config, output } = params;
|
|
948
|
+
debug2("uploadArtifactToRemote", config, output);
|
|
949
|
+
const stat = await import_fs2.default.promises.stat(config.artifactPath);
|
|
950
|
+
const stream = import_fs2.default.createReadStream(config.artifactPath);
|
|
951
|
+
const response = await fetch(output.uploadUrl, {
|
|
952
|
+
method: "PUT",
|
|
953
|
+
headers: {
|
|
954
|
+
"Content-Type": "application/zip",
|
|
955
|
+
"Content-Length": String(stat.size)
|
|
956
|
+
},
|
|
957
|
+
body: stream,
|
|
837
958
|
duplex: "half"
|
|
959
|
+
});
|
|
960
|
+
if (!response.ok) {
|
|
961
|
+
throw new Error("\uC5C5\uB85C\uB4DC\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uC2DC\uB3C4\uD574\uC8FC\uC138\uC694.");
|
|
838
962
|
}
|
|
839
|
-
|
|
840
|
-
|
|
963
|
+
return config;
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
function uploadComplete() {
|
|
967
|
+
return async (config) => {
|
|
968
|
+
debug2("uploadComplete", config);
|
|
969
|
+
const baseUrl = config.baseUrl ?? DEFAULT_API_BASE_URL;
|
|
970
|
+
const response = await fetch(`${baseUrl}/api-public/v3/openapi/bundles/${config.appName}/upload-complete`, {
|
|
971
|
+
method: "POST",
|
|
972
|
+
headers: {
|
|
973
|
+
"Content-Type": "application/json",
|
|
974
|
+
Authorization: `Bearer ${config.apiKey}`
|
|
975
|
+
},
|
|
976
|
+
body: JSON.stringify({
|
|
977
|
+
deploymentId: config.deploymentId
|
|
978
|
+
})
|
|
979
|
+
});
|
|
980
|
+
await handleFetchResponse(response);
|
|
981
|
+
return config;
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
function checkBundleStatus(delayMs = 1e4, maxRetries = 10) {
|
|
985
|
+
return async (config) => {
|
|
986
|
+
const baseUrl = config.baseUrl ?? DEFAULT_API_BASE_URL;
|
|
987
|
+
function assertBuildNotFailed(config2, reviewStatus2) {
|
|
988
|
+
if (reviewStatus2 === "BUILD_FAILED") {
|
|
989
|
+
throw new Error(
|
|
990
|
+
`\uBE4C\uB4DC\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4. \uCF58\uC194\uC5D0\uC11C \uBE4C\uB4DC \uC2E4\uD328 \uC0AC\uC720\uB97C \uD655\uC778\uD574\uC8FC\uC138\uC694.(deploymentId: ${config2.deploymentId})`
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
async function pollBundleStatus() {
|
|
995
|
+
const response = await fetch(
|
|
996
|
+
`${baseUrl}/api-public/v3/openapi/bundles/${config.appName}/deployments/${config.deploymentId}`,
|
|
997
|
+
{
|
|
998
|
+
method: "GET",
|
|
999
|
+
headers: {
|
|
1000
|
+
"Content-Type": "application/json",
|
|
1001
|
+
Authorization: `Bearer ${config.apiKey}`
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
const { reviewStatus: reviewStatus2 } = await handleFetchResponse(response);
|
|
1006
|
+
return reviewStatus2;
|
|
1007
|
+
}
|
|
1008
|
+
const reviewStatus = await withRetry(pollBundleStatus, {
|
|
1009
|
+
maxRetries,
|
|
1010
|
+
delayMs,
|
|
1011
|
+
shouldRetryOnResult: (reviewStatus2) => reviewStatus2 === "BUILDING" || reviewStatus2 === "PREPARE",
|
|
1012
|
+
shouldRetryOnError: () => false,
|
|
1013
|
+
onRetry: (attempt, info) => debug2("checkBundleStatus: retry", { attempt, ...info })
|
|
1014
|
+
});
|
|
1015
|
+
assertBuildNotFailed(config, reviewStatus);
|
|
1016
|
+
};
|
|
841
1017
|
}
|
|
842
1018
|
|
|
843
1019
|
// src/DeployCommand.ts
|
|
@@ -848,30 +1024,27 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
848
1024
|
required: false,
|
|
849
1025
|
description: "\uC54C\uD30C \uBC30\uD3EC\uB97C \uC704\uD55C API \uD0A4"
|
|
850
1026
|
});
|
|
1027
|
+
workspace = import_clipanion.Option.String("--workspace", {
|
|
1028
|
+
required: false,
|
|
1029
|
+
description: "\uD1A0\uD070 \uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4 \uC774\uB984"
|
|
1030
|
+
});
|
|
851
1031
|
baseUrl = import_clipanion.Option.String("--base-url", {
|
|
852
1032
|
description: "API Base URL"
|
|
853
1033
|
});
|
|
854
1034
|
async execute() {
|
|
855
1035
|
const baseUrl = this.baseUrl;
|
|
856
|
-
const
|
|
857
|
-
|
|
858
|
-
validate: (value) => {
|
|
859
|
-
if (value.length === 0) {
|
|
860
|
-
return "API \uD0A4\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.";
|
|
861
|
-
}
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
864
|
-
});
|
|
1036
|
+
const workspace = this.workspace || "default";
|
|
1037
|
+
const apiKey = await this.getApiKey(workspace);
|
|
865
1038
|
if (p.isCancel(apiKey)) {
|
|
866
1039
|
return;
|
|
867
1040
|
}
|
|
868
1041
|
try {
|
|
869
1042
|
const packageRoot = (0, import_utils.getPackageRoot)();
|
|
870
|
-
const artifactFile =
|
|
1043
|
+
const artifactFile = import_fs3.default.readdirSync(packageRoot).find((file) => file.endsWith(".ait"));
|
|
871
1044
|
if (!artifactFile) {
|
|
872
1045
|
throw new Error("\uBC30\uD3EC\uD560 .ait \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
873
1046
|
}
|
|
874
|
-
const resolvedArtifactPath =
|
|
1047
|
+
const resolvedArtifactPath = import_path2.default.resolve(packageRoot, artifactFile);
|
|
875
1048
|
const { appName, deploymentId } = await (0, import_utils.readZipContent)(resolvedArtifactPath, APP_MANIFEST_NAME).then((rawAppManifest) => {
|
|
876
1049
|
const appManifest = JSON.parse(rawAppManifest);
|
|
877
1050
|
const appName2 = appManifest.appName;
|
|
@@ -909,12 +1082,27 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
909
1082
|
process.exit(1);
|
|
910
1083
|
}
|
|
911
1084
|
}
|
|
1085
|
+
async getApiKey(workspace) {
|
|
1086
|
+
const token = TokenStorage.get(workspace) || this.apiKey;
|
|
1087
|
+
if (token) {
|
|
1088
|
+
return token;
|
|
1089
|
+
}
|
|
1090
|
+
return await p.password({
|
|
1091
|
+
message: "\uC571\uC778\uD1A0\uC2A4 \uBC30\uD3EC API \uD0A4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694",
|
|
1092
|
+
validate: (value) => {
|
|
1093
|
+
if (value.length === 0) {
|
|
1094
|
+
return "API \uD0A4\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.";
|
|
1095
|
+
}
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
912
1100
|
};
|
|
913
1101
|
|
|
914
1102
|
// src/InitCommand.ts
|
|
915
1103
|
init_cjs_shims();
|
|
916
|
-
var
|
|
917
|
-
var
|
|
1104
|
+
var import_fs4 = __toESM(require("fs"), 1);
|
|
1105
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
918
1106
|
var p2 = __toESM(require("@clack/prompts"), 1);
|
|
919
1107
|
var import_utils2 = require("@granite-js/utils");
|
|
920
1108
|
var import_clipanion2 = require("clipanion");
|
|
@@ -1016,7 +1204,7 @@ function transformTemplate(templateString, values) {
|
|
|
1016
1204
|
|
|
1017
1205
|
// src/InitCommand.ts
|
|
1018
1206
|
async function templateWebFramework({ appName, cwd, skipInput }) {
|
|
1019
|
-
const packageJson = await
|
|
1207
|
+
const packageJson = await import_fs4.default.promises.readFile(import_path3.default.join(cwd, "package.json"), {
|
|
1020
1208
|
encoding: "utf-8"
|
|
1021
1209
|
});
|
|
1022
1210
|
const scripts = JSON.parse(packageJson);
|
|
@@ -1027,11 +1215,11 @@ async function templateWebFramework({ appName, cwd, skipInput }) {
|
|
|
1027
1215
|
scripts.scripts.dev = "granite dev";
|
|
1028
1216
|
scripts.scripts.build = "granite build";
|
|
1029
1217
|
scripts.scripts.deploy = "ait deploy";
|
|
1030
|
-
await
|
|
1218
|
+
await import_fs4.default.promises.writeFile(import_path3.default.join(cwd, "package.json"), JSON.stringify(scripts, null, 2), {
|
|
1031
1219
|
encoding: "utf-8"
|
|
1032
1220
|
});
|
|
1033
1221
|
p2.log.step(".gitignore \uD30C\uC77C\uC744 \uC5C5\uB370\uC774\uD2B8\uD558\uB294 \uC911...");
|
|
1034
|
-
await
|
|
1222
|
+
await import_fs4.default.promises.appendFile(import_path3.default.join(cwd, ".gitignore"), "\n.granite\n");
|
|
1035
1223
|
const placeholder = {
|
|
1036
1224
|
dev: originalScripts.dev === "granite dev" ? "" : originalScripts.dev,
|
|
1037
1225
|
build: originalScripts.build === "granite build" ? "" : originalScripts.build
|
|
@@ -1071,7 +1259,7 @@ async function templateWebFramework({ appName, cwd, skipInput }) {
|
|
|
1071
1259
|
webDevCommand: scriptInputs.dev === "granite dev" ? "" : scriptInputs.dev,
|
|
1072
1260
|
webBuildCommand: scriptInputs.build === "granite build" ? "" : scriptInputs.build
|
|
1073
1261
|
});
|
|
1074
|
-
await
|
|
1262
|
+
await import_fs4.default.promises.writeFile(import_path3.default.join(cwd, "granite.config.ts"), config, {
|
|
1075
1263
|
encoding: "utf-8"
|
|
1076
1264
|
});
|
|
1077
1265
|
}
|
|
@@ -1080,11 +1268,11 @@ async function templateReactNative({ appName, cwd }) {
|
|
|
1080
1268
|
const config = transformTemplate(REACT_NATIVE_FRAMEWORK_CONFIG_TEMPLATE, {
|
|
1081
1269
|
appName
|
|
1082
1270
|
});
|
|
1083
|
-
await
|
|
1271
|
+
await import_fs4.default.promises.writeFile(import_path3.default.join(cwd, "granite.config.ts"), config, {
|
|
1084
1272
|
encoding: "utf-8"
|
|
1085
1273
|
});
|
|
1086
1274
|
p2.log.step("src/_app.tsx \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
|
|
1087
|
-
await
|
|
1275
|
+
await import_fs4.default.promises.writeFile(import_path3.default.join(cwd, "src", "_app.tsx"), APP_TEMPLATE, {
|
|
1088
1276
|
encoding: "utf-8"
|
|
1089
1277
|
});
|
|
1090
1278
|
}
|
|
@@ -1202,24 +1390,24 @@ init_cjs_shims();
|
|
|
1202
1390
|
|
|
1203
1391
|
// src/MigrateCommand/fs/fileProcessor.ts
|
|
1204
1392
|
init_cjs_shims();
|
|
1205
|
-
var
|
|
1393
|
+
var import_fs5 = require("fs");
|
|
1206
1394
|
async function readFile(filePath) {
|
|
1207
1395
|
try {
|
|
1208
|
-
return await
|
|
1396
|
+
return await import_fs5.promises.readFile(filePath, "utf-8");
|
|
1209
1397
|
} catch {
|
|
1210
1398
|
throw new Error(`Failed to read file: ${filePath}`);
|
|
1211
1399
|
}
|
|
1212
1400
|
}
|
|
1213
1401
|
async function writeFile(filePath, content) {
|
|
1214
1402
|
try {
|
|
1215
|
-
await
|
|
1403
|
+
await import_fs5.promises.writeFile(filePath, content, "utf-8");
|
|
1216
1404
|
} catch {
|
|
1217
1405
|
throw new Error(`Failed to write file: ${filePath}`);
|
|
1218
1406
|
}
|
|
1219
1407
|
}
|
|
1220
1408
|
async function fileExists(filePath) {
|
|
1221
1409
|
try {
|
|
1222
|
-
await
|
|
1410
|
+
await import_fs5.promises.access(filePath);
|
|
1223
1411
|
return true;
|
|
1224
1412
|
} catch {
|
|
1225
1413
|
return false;
|
|
@@ -1227,7 +1415,7 @@ async function fileExists(filePath) {
|
|
|
1227
1415
|
}
|
|
1228
1416
|
async function renameFile(oldPath, newPath) {
|
|
1229
1417
|
try {
|
|
1230
|
-
await
|
|
1418
|
+
await import_fs5.promises.rename(oldPath, newPath);
|
|
1231
1419
|
} catch {
|
|
1232
1420
|
throw new Error(`Failed to rename file: ${oldPath} -> ${newPath}`);
|
|
1233
1421
|
}
|
|
@@ -1235,27 +1423,27 @@ async function renameFile(oldPath, newPath) {
|
|
|
1235
1423
|
|
|
1236
1424
|
// src/MigrateCommand/presets/granite/configProcessor.ts
|
|
1237
1425
|
var configTransformer = (root, { j }) => {
|
|
1238
|
-
root.find(j.ImportDeclaration).forEach((
|
|
1239
|
-
const source =
|
|
1426
|
+
root.find(j.ImportDeclaration).forEach((path6) => {
|
|
1427
|
+
const source = path6.value.source;
|
|
1240
1428
|
if (j.StringLiteral.check(source) && source.value === "react-native-bedrock/config") {
|
|
1241
|
-
const defineConfigName =
|
|
1429
|
+
const defineConfigName = path6.value.specifiers?.find(
|
|
1242
1430
|
(specifier) => j.ImportSpecifier.check(specifier) && specifier.imported.name === "defineConfig"
|
|
1243
1431
|
)?.local?.name;
|
|
1244
1432
|
if (!defineConfigName) {
|
|
1245
1433
|
return;
|
|
1246
1434
|
}
|
|
1247
|
-
root.find(j.CallExpression).forEach((
|
|
1248
|
-
const callee =
|
|
1249
|
-
if (j.Identifier.check(callee) && callee.name === defineConfigName &&
|
|
1250
|
-
const obj =
|
|
1435
|
+
root.find(j.CallExpression).forEach((path7) => {
|
|
1436
|
+
const callee = path7.value.callee;
|
|
1437
|
+
if (j.Identifier.check(callee) && callee.name === defineConfigName && path7.value.arguments.length > 0 && j.ObjectExpression.check(path7.value.arguments[0])) {
|
|
1438
|
+
const obj = path7.value.arguments[0];
|
|
1251
1439
|
const hasScheme = obj.properties.some(
|
|
1252
1440
|
(prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "scheme"
|
|
1253
1441
|
);
|
|
1254
1442
|
if (!hasScheme) {
|
|
1255
1443
|
obj.properties.unshift(j.objectProperty(j.identifier("scheme"), j.stringLiteral("intoss")));
|
|
1256
1444
|
}
|
|
1257
|
-
const routerImport = root.find(j.ImportDeclaration).filter((
|
|
1258
|
-
const source2 =
|
|
1445
|
+
const routerImport = root.find(j.ImportDeclaration).filter((path8) => {
|
|
1446
|
+
const source2 = path8.value.source;
|
|
1259
1447
|
return j.StringLiteral.check(source2) && source2.value === "@granite-js/plugin-router";
|
|
1260
1448
|
});
|
|
1261
1449
|
if (routerImport.length === 0) {
|
|
@@ -1404,12 +1592,12 @@ var identifierReplacementsTransformer = (root, { j }) => {
|
|
|
1404
1592
|
}
|
|
1405
1593
|
});
|
|
1406
1594
|
});
|
|
1407
|
-
root.find(j.Identifier).forEach((
|
|
1408
|
-
const name =
|
|
1595
|
+
root.find(j.Identifier).forEach((path6) => {
|
|
1596
|
+
const name = path6.value.name;
|
|
1409
1597
|
if (importedVariables.has(name)) {
|
|
1410
|
-
const newName = toGraniteName(
|
|
1598
|
+
const newName = toGraniteName(path6.value.name);
|
|
1411
1599
|
if (newName) {
|
|
1412
|
-
|
|
1600
|
+
path6.value.name = newName;
|
|
1413
1601
|
}
|
|
1414
1602
|
}
|
|
1415
1603
|
});
|
|
@@ -1418,11 +1606,11 @@ var identifierReplacementsTransformer = (root, { j }) => {
|
|
|
1418
1606
|
|
|
1419
1607
|
// src/MigrateCommand/presets/granite/isBedrockProject.ts
|
|
1420
1608
|
init_cjs_shims();
|
|
1421
|
-
var
|
|
1609
|
+
var fs6 = __toESM(require("fs"), 1);
|
|
1422
1610
|
var BASE_NAME = "bedrock.config";
|
|
1423
1611
|
var EXTENSIONS = ["ts", "mts", "js", "cjs"];
|
|
1424
1612
|
async function isBedrockProject(cwd) {
|
|
1425
|
-
const files =
|
|
1613
|
+
const files = fs6.readdirSync(cwd);
|
|
1426
1614
|
return files.some(isBedrockConfigFile);
|
|
1427
1615
|
}
|
|
1428
1616
|
function isBedrockConfigFile(file) {
|
|
@@ -1462,8 +1650,8 @@ var packageImportsTransformer = (root, { j }, { fileName = "<unknown>" }) => {
|
|
|
1462
1650
|
}
|
|
1463
1651
|
return value;
|
|
1464
1652
|
}
|
|
1465
|
-
root.find(j.ImportDeclaration).forEach((
|
|
1466
|
-
const source =
|
|
1653
|
+
root.find(j.ImportDeclaration).forEach((path6) => {
|
|
1654
|
+
const source = path6.value.source;
|
|
1467
1655
|
if (j.StringLiteral.check(source)) {
|
|
1468
1656
|
const transformed = transformPackageName(source.value);
|
|
1469
1657
|
if (transformed !== source.value) {
|
|
@@ -1473,8 +1661,8 @@ var packageImportsTransformer = (root, { j }, { fileName = "<unknown>" }) => {
|
|
|
1473
1661
|
});
|
|
1474
1662
|
root.find(j.CallExpression, {
|
|
1475
1663
|
callee: { name: "require" }
|
|
1476
|
-
}).forEach((
|
|
1477
|
-
const args =
|
|
1664
|
+
}).forEach((path6) => {
|
|
1665
|
+
const args = path6.value.arguments;
|
|
1478
1666
|
if (args.length > 0 && j.StringLiteral.check(args[0])) {
|
|
1479
1667
|
const transformed = transformPackageName(args[0].value);
|
|
1480
1668
|
if (transformed !== args[0].value) {
|
|
@@ -1482,8 +1670,8 @@ var packageImportsTransformer = (root, { j }, { fileName = "<unknown>" }) => {
|
|
|
1482
1670
|
}
|
|
1483
1671
|
}
|
|
1484
1672
|
});
|
|
1485
|
-
root.find(j.ImportExpression).forEach((
|
|
1486
|
-
const source =
|
|
1673
|
+
root.find(j.ImportExpression).forEach((path6) => {
|
|
1674
|
+
const source = path6.value.source;
|
|
1487
1675
|
if (j.StringLiteral.check(source)) {
|
|
1488
1676
|
const transformed = transformPackageName(source.value);
|
|
1489
1677
|
if (transformed !== source.value) {
|
|
@@ -1581,14 +1769,14 @@ var APPS_IN_TOSS_FRAMEWORK_EXPORTS = [
|
|
|
1581
1769
|
];
|
|
1582
1770
|
var toAppsInTossFrameworkImport = (root, { j }, { fileName = "<unknown>" }) => {
|
|
1583
1771
|
const appsInTossFrameworkMembers = [];
|
|
1584
|
-
root.find(j.ImportDeclaration).forEach((
|
|
1585
|
-
const source =
|
|
1772
|
+
root.find(j.ImportDeclaration).forEach((path6) => {
|
|
1773
|
+
const source = path6.node.source.value;
|
|
1586
1774
|
if (typeof source !== "string") {
|
|
1587
1775
|
return;
|
|
1588
1776
|
}
|
|
1589
1777
|
if (source === "@granite-js/react-native") {
|
|
1590
|
-
if (Array.isArray(
|
|
1591
|
-
|
|
1778
|
+
if (Array.isArray(path6.node.specifiers)) {
|
|
1779
|
+
path6.node.specifiers = path6.node.specifiers.filter((specifier) => {
|
|
1592
1780
|
if (shouldImportFromAppsInTossFramework(fileName, specifier)) {
|
|
1593
1781
|
appsInTossFrameworkMembers.push(specifier);
|
|
1594
1782
|
return false;
|
|
@@ -1596,8 +1784,8 @@ var toAppsInTossFrameworkImport = (root, { j }, { fileName = "<unknown>" }) => {
|
|
|
1596
1784
|
return true;
|
|
1597
1785
|
});
|
|
1598
1786
|
}
|
|
1599
|
-
if (
|
|
1600
|
-
j(
|
|
1787
|
+
if (path6.node.specifiers?.length === 0) {
|
|
1788
|
+
j(path6).remove();
|
|
1601
1789
|
}
|
|
1602
1790
|
}
|
|
1603
1791
|
});
|
|
@@ -1750,24 +1938,98 @@ var MigrateCommand = class extends import_clipanion3.Command {
|
|
|
1750
1938
|
}
|
|
1751
1939
|
};
|
|
1752
1940
|
|
|
1941
|
+
// src/TokenCommand.ts
|
|
1942
|
+
init_cjs_shims();
|
|
1943
|
+
var p3 = __toESM(require("@clack/prompts"), 1);
|
|
1944
|
+
var import_clipanion4 = require("clipanion");
|
|
1945
|
+
var import_debug4 = __toESM(require_src(), 1);
|
|
1946
|
+
var debug4 = (0, import_debug4.default)("cli:token");
|
|
1947
|
+
var TokenCommand = class extends import_clipanion4.Command {
|
|
1948
|
+
static paths = [["token"]];
|
|
1949
|
+
static usage = import_clipanion4.Command.Usage({
|
|
1950
|
+
description: "\uD1A0\uD070 \uAD00\uB828 \uD558\uC704 \uBA85\uB839\uC744 \uAD00\uB9AC\uD569\uB2C8\uB2E4.",
|
|
1951
|
+
examples: [
|
|
1952
|
+
["\uD1A0\uD070 \uCD94\uAC00", "ait token add <workspace?>"],
|
|
1953
|
+
["\uD1A0\uD070 \uC0AD\uC81C", "ait token remove <workspace?>"]
|
|
1954
|
+
]
|
|
1955
|
+
});
|
|
1956
|
+
async execute() {
|
|
1957
|
+
debug4("execute");
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
var TokenAddCommand = class extends import_clipanion4.Command {
|
|
1961
|
+
static paths = [["token", "add"]];
|
|
1962
|
+
static usage = import_clipanion4.Command.Usage({
|
|
1963
|
+
description: "\uC2DC\uD06C\uB9BF \uD1A0\uD070\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4.",
|
|
1964
|
+
examples: [
|
|
1965
|
+
["\uAE30\uBCF8 \uBCC4\uCE6D\uC73C\uB85C \uD1A0\uD070 \uCD94\uAC00", "ait token add"],
|
|
1966
|
+
["\uBCC4\uCE6D\uC744 \uC9C0\uC815\uD558\uC5EC \uD1A0\uD070 \uCD94\uAC00", "ait token add dev"]
|
|
1967
|
+
]
|
|
1968
|
+
});
|
|
1969
|
+
workspace = import_clipanion4.Option.String({ required: false });
|
|
1970
|
+
apiKey = import_clipanion4.Option.String("--api-key", { required: false });
|
|
1971
|
+
async execute() {
|
|
1972
|
+
const workspace = this.workspace || "default";
|
|
1973
|
+
const secret = this.apiKey ? this.apiKey : await p3.password({
|
|
1974
|
+
message: "Enter secret token:",
|
|
1975
|
+
validate: (value) => {
|
|
1976
|
+
if (value.length === 0) {
|
|
1977
|
+
return "\uD1A0\uD070\uC740 \uBE44\uC5B4 \uC788\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.";
|
|
1978
|
+
}
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1981
|
+
});
|
|
1982
|
+
if (p3.isCancel(secret)) {
|
|
1983
|
+
return;
|
|
1984
|
+
}
|
|
1985
|
+
TokenStorage.set(workspace, secret);
|
|
1986
|
+
debug4("token add", { workspace });
|
|
1987
|
+
this.context.stdout.write(`${workspace} \uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4\uB85C\uC758 \uC694\uCCAD\uC740 \uC774\uC81C \uBE44\uBC00 \uD1A0\uD070\uC744 \uC0AC\uC6A9\uD558\uC5EC \uC778\uC99D\uB429\uB2C8\uB2E4.
|
|
1988
|
+
`);
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
var TokenRemoveCommand = class extends import_clipanion4.Command {
|
|
1992
|
+
static paths = [["token", "remove"]];
|
|
1993
|
+
static usage = import_clipanion4.Command.Usage({
|
|
1994
|
+
description: "\uC2DC\uD06C\uB9BF \uD1A0\uD070\uC744 \uC0AD\uC81C\uD569\uB2C8\uB2E4.",
|
|
1995
|
+
examples: [
|
|
1996
|
+
["\uAE30\uBCF8 \uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4\uC758 \uD1A0\uD070 \uC0AD\uC81C", "ait token remove"],
|
|
1997
|
+
["\uBCC4\uCE6D\uC744 \uC9C0\uC815\uD558\uC5EC \uD1A0\uD070 \uC0AD\uC81C", "ait token remove dev"]
|
|
1998
|
+
]
|
|
1999
|
+
});
|
|
2000
|
+
workspace = import_clipanion4.Option.String({ required: false });
|
|
2001
|
+
async execute() {
|
|
2002
|
+
const workspace = this.workspace || "default";
|
|
2003
|
+
const removed = TokenStorage.delete(workspace);
|
|
2004
|
+
debug4("token remove", { workspace });
|
|
2005
|
+
if (removed) {
|
|
2006
|
+
this.context.stdout.write(`\uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4\uC758 \uD1A0\uD070\uC744 \uC81C\uAC70\uD588\uC2B5\uB2C8\uB2E4: ${workspace}.
|
|
2007
|
+
`);
|
|
2008
|
+
} else {
|
|
2009
|
+
this.context.stdout.write(`\uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4\uC758 \uD1A0\uD070\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${workspace}.
|
|
2010
|
+
`);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
|
|
1753
2015
|
// src/integrations/UploadSentrySourcemap/index.ts
|
|
1754
2016
|
init_cjs_shims();
|
|
1755
2017
|
|
|
1756
2018
|
// src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
|
|
1757
2019
|
init_cjs_shims();
|
|
1758
|
-
var
|
|
1759
|
-
var
|
|
1760
|
-
var
|
|
2020
|
+
var fs10 = __toESM(require("fs/promises"), 1);
|
|
2021
|
+
var p4 = __toESM(require("@clack/prompts"), 1);
|
|
2022
|
+
var import_clipanion5 = require("clipanion");
|
|
1761
2023
|
|
|
1762
2024
|
// src/integrations/UploadSentrySourcemap/downloadArtifacts.ts
|
|
1763
2025
|
init_cjs_shims();
|
|
1764
|
-
var
|
|
1765
|
-
var
|
|
1766
|
-
var
|
|
2026
|
+
var fs7 = __toESM(require("fs"), 1);
|
|
2027
|
+
var os2 = __toESM(require("os"), 1);
|
|
2028
|
+
var path4 = __toESM(require("path"), 1);
|
|
1767
2029
|
var import_stream = require("stream");
|
|
1768
2030
|
var import_util = require("util");
|
|
1769
|
-
var
|
|
1770
|
-
var
|
|
2031
|
+
var import_debug5 = __toESM(require_src(), 1);
|
|
2032
|
+
var debug5 = (0, import_debug5.default)("integrations:sentry");
|
|
1771
2033
|
var streamPipeline = (0, import_util.promisify)(import_stream.pipeline);
|
|
1772
2034
|
async function downloadArtifacts(options) {
|
|
1773
2035
|
const { appName, deploymentId, apiKey, baseUrl = DEFAULT_API_BASE_URL } = options;
|
|
@@ -1776,7 +2038,7 @@ async function downloadArtifacts(options) {
|
|
|
1776
2038
|
deploymentId
|
|
1777
2039
|
});
|
|
1778
2040
|
const requestUrl = `${baseUrl}/api-public/v3/openapi/bundles/download?${params.toString()}`;
|
|
1779
|
-
|
|
2041
|
+
debug5("Request URL", { requestUrl });
|
|
1780
2042
|
const response = await fetch(`${baseUrl}/api-public/v3/openapi/bundles/download?${params.toString()}`, {
|
|
1781
2043
|
method: "GET",
|
|
1782
2044
|
headers: {
|
|
@@ -1792,36 +2054,36 @@ async function downloadArtifacts(options) {
|
|
|
1792
2054
|
}
|
|
1793
2055
|
const tmpDir = await createTempDirectory();
|
|
1794
2056
|
const tmpFile = `${deploymentId}.zip`;
|
|
1795
|
-
const tmpFilePath =
|
|
1796
|
-
const fileStream =
|
|
2057
|
+
const tmpFilePath = path4.join(tmpDir.path, tmpFile);
|
|
2058
|
+
const fileStream = fs7.createWriteStream(tmpFilePath);
|
|
1797
2059
|
await streamPipeline(response.body, fileStream);
|
|
1798
|
-
|
|
2060
|
+
debug5("Artifacts downloaded", { tmpFilePath });
|
|
1799
2061
|
return tmpFilePath;
|
|
1800
2062
|
}
|
|
1801
2063
|
function createTempDirectory() {
|
|
1802
|
-
const tempDir =
|
|
1803
|
-
|
|
1804
|
-
|
|
2064
|
+
const tempDir = path4.join(os2.tmpdir(), "apps-in-toss", "sentry-integration");
|
|
2065
|
+
fs7.mkdirSync(tempDir, { recursive: true });
|
|
2066
|
+
debug5("Temp directory created", { tempDir });
|
|
1805
2067
|
return {
|
|
1806
2068
|
path: tempDir,
|
|
1807
2069
|
cleanup: () => {
|
|
1808
|
-
|
|
2070
|
+
fs7.rmSync(tempDir, { recursive: true, force: true });
|
|
1809
2071
|
}
|
|
1810
2072
|
};
|
|
1811
2073
|
}
|
|
1812
2074
|
|
|
1813
2075
|
// src/integrations/UploadSentrySourcemap/extractSentryDebugId.ts
|
|
1814
2076
|
init_cjs_shims();
|
|
1815
|
-
var
|
|
2077
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
1816
2078
|
async function extractSentryDebugId(bundlePath) {
|
|
1817
|
-
const bundleContent = await
|
|
2079
|
+
const bundleContent = await import_promises2.default.readFile(bundlePath, "utf-8");
|
|
1818
2080
|
return bundleContent.match(/SENTRY_DEBUG_ID=([\w-]+)/)?.[1];
|
|
1819
2081
|
}
|
|
1820
2082
|
|
|
1821
2083
|
// src/integrations/UploadSentrySourcemap/extractSources.ts
|
|
1822
2084
|
init_cjs_shims();
|
|
1823
|
-
var
|
|
1824
|
-
var
|
|
2085
|
+
var fs9 = __toESM(require("fs"), 1);
|
|
2086
|
+
var path5 = __toESM(require("path"), 1);
|
|
1825
2087
|
var import_stream2 = require("stream");
|
|
1826
2088
|
var import_util2 = require("util");
|
|
1827
2089
|
var zlib = __toESM(require("zlib"), 1);
|
|
@@ -1842,12 +2104,12 @@ async function extractSources(zipPath) {
|
|
|
1842
2104
|
hermesSourceMap: ""
|
|
1843
2105
|
}
|
|
1844
2106
|
};
|
|
1845
|
-
await
|
|
2107
|
+
await fs9.createReadStream(zipPath).pipe(unzipper.Parse()).on("entry", async (entry) => {
|
|
1846
2108
|
const isRoot = !entry.path.includes("/");
|
|
1847
|
-
const fileName =
|
|
1848
|
-
const outputPath =
|
|
2109
|
+
const fileName = path5.basename(entry.path);
|
|
2110
|
+
const outputPath = path5.join(path5.dirname(zipPath), fileName);
|
|
1849
2111
|
if (isRoot) {
|
|
1850
|
-
entry.pipe(
|
|
2112
|
+
entry.pipe(fs9.createWriteStream(outputPath));
|
|
1851
2113
|
const platform = fileName.includes("android") ? "android" : "ios";
|
|
1852
2114
|
if (fileName.endsWith(".js")) {
|
|
1853
2115
|
sources[platform].packagerBundle = outputPath;
|
|
@@ -1875,7 +2137,7 @@ async function extractSources(zipPath) {
|
|
|
1875
2137
|
}
|
|
1876
2138
|
async function decompressGzip(gzFile) {
|
|
1877
2139
|
const outfile = gzFile.replace(/\.gz$/g, "");
|
|
1878
|
-
await pipe(
|
|
2140
|
+
await pipe(fs9.createReadStream(gzFile), zlib.createGunzip(), fs9.createWriteStream(outfile));
|
|
1879
2141
|
return outfile;
|
|
1880
2142
|
}
|
|
1881
2143
|
|
|
@@ -1906,33 +2168,33 @@ function uploadSourcemap(bundlePath, sourcemapPath, options) {
|
|
|
1906
2168
|
}
|
|
1907
2169
|
|
|
1908
2170
|
// src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
|
|
1909
|
-
var UploadSentrySourcemap = class extends
|
|
2171
|
+
var UploadSentrySourcemap = class extends import_clipanion5.Command {
|
|
1910
2172
|
static paths = [["sentry", "upload-sourcemap"]];
|
|
1911
|
-
apiKey =
|
|
2173
|
+
apiKey = import_clipanion5.Option.String("--api-key", {
|
|
1912
2174
|
required: false,
|
|
1913
2175
|
description: "\uC778\uC99D API \uD0A4"
|
|
1914
2176
|
});
|
|
1915
|
-
appName =
|
|
2177
|
+
appName = import_clipanion5.Option.String("--app-name", {
|
|
1916
2178
|
required: false,
|
|
1917
2179
|
description: "\uC571 \uC774\uB984"
|
|
1918
2180
|
});
|
|
1919
|
-
deploymentId =
|
|
2181
|
+
deploymentId = import_clipanion5.Option.String("--deployment-id", {
|
|
1920
2182
|
required: false,
|
|
1921
2183
|
description: "\uBC30\uD3EC ID"
|
|
1922
2184
|
});
|
|
1923
|
-
sentryAuthToken =
|
|
2185
|
+
sentryAuthToken = import_clipanion5.Option.String("--sentry-auth-token", {
|
|
1924
2186
|
required: false,
|
|
1925
2187
|
description: "Sentry \uC778\uC99D\uD0A4"
|
|
1926
2188
|
});
|
|
1927
|
-
sentryOrg =
|
|
2189
|
+
sentryOrg = import_clipanion5.Option.String("--sentry-org", {
|
|
1928
2190
|
required: false,
|
|
1929
2191
|
description: "Sentry \uC870\uC9C1"
|
|
1930
2192
|
});
|
|
1931
|
-
sentryProject =
|
|
2193
|
+
sentryProject = import_clipanion5.Option.String("--sentry-project", {
|
|
1932
2194
|
required: false,
|
|
1933
2195
|
description: "Sentry \uD504\uB85C\uC81D\uD2B8"
|
|
1934
2196
|
});
|
|
1935
|
-
baseUrl =
|
|
2197
|
+
baseUrl = import_clipanion5.Option.String("--base-url", {
|
|
1936
2198
|
description: "API Base URL"
|
|
1937
2199
|
});
|
|
1938
2200
|
async execute() {
|
|
@@ -1946,7 +2208,7 @@ var UploadSentrySourcemap = class extends import_clipanion4.Command {
|
|
|
1946
2208
|
try {
|
|
1947
2209
|
const zipPath = await downloadArtifacts({ apiKey, appName, deploymentId, baseUrl });
|
|
1948
2210
|
const sources = await extractSources(zipPath);
|
|
1949
|
-
await
|
|
2211
|
+
await p4.tasks([
|
|
1950
2212
|
{
|
|
1951
2213
|
title: "Android \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC911...",
|
|
1952
2214
|
task: async () => {
|
|
@@ -1972,10 +2234,10 @@ var UploadSentrySourcemap = class extends import_clipanion4.Command {
|
|
|
1972
2234
|
}
|
|
1973
2235
|
}
|
|
1974
2236
|
]);
|
|
1975
|
-
|
|
2237
|
+
p4.outro("Sentry \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC644\uB8CC");
|
|
1976
2238
|
} catch (error) {
|
|
1977
2239
|
if (error instanceof Error) {
|
|
1978
|
-
|
|
2240
|
+
p4.log.error(error.message);
|
|
1979
2241
|
} else {
|
|
1980
2242
|
console.error(error);
|
|
1981
2243
|
}
|
|
@@ -1988,14 +2250,14 @@ var UploadSentrySourcemap = class extends import_clipanion4.Command {
|
|
|
1988
2250
|
throw new Error("Sentry Debug ID\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1989
2251
|
}
|
|
1990
2252
|
const mergedSourceMap = await mergeSourceMaps(
|
|
1991
|
-
await
|
|
1992
|
-
await
|
|
2253
|
+
await fs10.readFile(sources.packagerSourceMap, "utf-8"),
|
|
2254
|
+
await fs10.readFile(sources.hermesSourceMap, "utf-8")
|
|
1993
2255
|
);
|
|
1994
2256
|
const injectedSourceMap = injectSentryDebugId(mergedSourceMap, debugId);
|
|
1995
|
-
await
|
|
2257
|
+
await fs10.writeFile(sources.hermesSourceMap, JSON.stringify(injectedSourceMap, null, 2), "utf-8");
|
|
1996
2258
|
}
|
|
1997
2259
|
async promptRequiredValue(type, message, validateMessage) {
|
|
1998
|
-
const result = await
|
|
2260
|
+
const result = await p4[type]({
|
|
1999
2261
|
message,
|
|
2000
2262
|
validate: (value) => {
|
|
2001
2263
|
if (value.length === 0) {
|
|
@@ -2004,7 +2266,7 @@ var UploadSentrySourcemap = class extends import_clipanion4.Command {
|
|
|
2004
2266
|
return;
|
|
2005
2267
|
}
|
|
2006
2268
|
});
|
|
2007
|
-
if (
|
|
2269
|
+
if (p4.isCancel(result)) {
|
|
2008
2270
|
throw new Error("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB418\uC5C8\uC5B4\uC694.");
|
|
2009
2271
|
}
|
|
2010
2272
|
return result;
|
|
@@ -2013,7 +2275,7 @@ var UploadSentrySourcemap = class extends import_clipanion4.Command {
|
|
|
2013
2275
|
|
|
2014
2276
|
// src/index.ts
|
|
2015
2277
|
function initialize() {
|
|
2016
|
-
const cli = new
|
|
2278
|
+
const cli = new import_clipanion6.Cli({
|
|
2017
2279
|
binaryLabel: "ait",
|
|
2018
2280
|
binaryName: "ait"
|
|
2019
2281
|
});
|
|
@@ -2021,6 +2283,10 @@ function initialize() {
|
|
|
2021
2283
|
cli.register(InitCommand);
|
|
2022
2284
|
cli.register(MigrateCommand);
|
|
2023
2285
|
cli.register(UploadSentrySourcemap);
|
|
2286
|
+
cli.register(TokenCommand);
|
|
2287
|
+
cli.register(TokenAddCommand);
|
|
2288
|
+
cli.register(TokenRemoveCommand);
|
|
2289
|
+
cli.register(import_clipanion6.Builtins.HelpCommand);
|
|
2024
2290
|
cli.runExit(process.argv.slice(2));
|
|
2025
2291
|
}
|
|
2026
2292
|
// Annotate the CommonJS export names for ESM import in node:
|