@apps-in-toss/cli 1.14.1 → 2.0.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 +1066 -201
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1052 -191
- package/package.json +13 -5
- package/bin.js +0 -4
package/dist/index.cjs
CHANGED
|
@@ -45,10 +45,10 @@ var require_picocolors = __commonJS({
|
|
|
45
45
|
"../../../.yarn/cache/picocolors-npm-1.1.1-b0c45fa35e-e2e3e8170a.zip/node_modules/picocolors/picocolors.js"(exports2, module2) {
|
|
46
46
|
"use strict";
|
|
47
47
|
init_cjs_shims();
|
|
48
|
-
var
|
|
49
|
-
var argv =
|
|
50
|
-
var env =
|
|
51
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") ||
|
|
48
|
+
var p8 = process || {};
|
|
49
|
+
var argv = p8.argv || [];
|
|
50
|
+
var env = p8.env || {};
|
|
51
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p8.platform === "win32" || (p8.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
52
52
|
var formatter = (open, close, replace = open) => (input) => {
|
|
53
53
|
let string = "" + input, index = string.indexOf(close, open.length);
|
|
54
54
|
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
@@ -232,9 +232,9 @@ var require_ms = __commonJS({
|
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
-
// ../../../.yarn/__virtual__/debug-virtual-
|
|
235
|
+
// ../../../.yarn/__virtual__/debug-virtual-4a69f763f8/0/cache/debug-npm-4.4.0-f1ca372596-db94f1a182.zip/node_modules/debug/src/common.js
|
|
236
236
|
var require_common = __commonJS({
|
|
237
|
-
"../../../.yarn/__virtual__/debug-virtual-
|
|
237
|
+
"../../../.yarn/__virtual__/debug-virtual-4a69f763f8/0/cache/debug-npm-4.4.0-f1ca372596-db94f1a182.zip/node_modules/debug/src/common.js"(exports2, module2) {
|
|
238
238
|
"use strict";
|
|
239
239
|
init_cjs_shims();
|
|
240
240
|
function setup(env) {
|
|
@@ -411,9 +411,9 @@ var require_common = __commonJS({
|
|
|
411
411
|
}
|
|
412
412
|
});
|
|
413
413
|
|
|
414
|
-
// ../../../.yarn/__virtual__/debug-virtual-
|
|
414
|
+
// ../../../.yarn/__virtual__/debug-virtual-4a69f763f8/0/cache/debug-npm-4.4.0-f1ca372596-db94f1a182.zip/node_modules/debug/src/browser.js
|
|
415
415
|
var require_browser = __commonJS({
|
|
416
|
-
"../../../.yarn/__virtual__/debug-virtual-
|
|
416
|
+
"../../../.yarn/__virtual__/debug-virtual-4a69f763f8/0/cache/debug-npm-4.4.0-f1ca372596-db94f1a182.zip/node_modules/debug/src/browser.js"(exports2, module2) {
|
|
417
417
|
"use strict";
|
|
418
418
|
init_cjs_shims();
|
|
419
419
|
exports2.formatArgs = formatArgs;
|
|
@@ -583,15 +583,15 @@ var require_browser = __commonJS({
|
|
|
583
583
|
}
|
|
584
584
|
});
|
|
585
585
|
|
|
586
|
-
// ../../../.yarn/__virtual__/debug-virtual-
|
|
586
|
+
// ../../../.yarn/__virtual__/debug-virtual-4a69f763f8/0/cache/debug-npm-4.4.0-f1ca372596-db94f1a182.zip/node_modules/debug/src/node.js
|
|
587
587
|
var require_node = __commonJS({
|
|
588
|
-
"../../../.yarn/__virtual__/debug-virtual-
|
|
588
|
+
"../../../.yarn/__virtual__/debug-virtual-4a69f763f8/0/cache/debug-npm-4.4.0-f1ca372596-db94f1a182.zip/node_modules/debug/src/node.js"(exports2, module2) {
|
|
589
589
|
"use strict";
|
|
590
590
|
init_cjs_shims();
|
|
591
591
|
var tty = require("tty");
|
|
592
592
|
var util = require("util");
|
|
593
593
|
exports2.init = init;
|
|
594
|
-
exports2.log =
|
|
594
|
+
exports2.log = log7;
|
|
595
595
|
exports2.formatArgs = formatArgs;
|
|
596
596
|
exports2.save = save;
|
|
597
597
|
exports2.load = load;
|
|
@@ -726,7 +726,7 @@ var require_node = __commonJS({
|
|
|
726
726
|
}
|
|
727
727
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
728
728
|
}
|
|
729
|
-
function
|
|
729
|
+
function log7(...args) {
|
|
730
730
|
return process.stderr.write(util.formatWithOptions(exports2.inspectOpts, ...args) + "\n");
|
|
731
731
|
}
|
|
732
732
|
function save(namespaces) {
|
|
@@ -759,9 +759,9 @@ var require_node = __commonJS({
|
|
|
759
759
|
}
|
|
760
760
|
});
|
|
761
761
|
|
|
762
|
-
// ../../../.yarn/__virtual__/debug-virtual-
|
|
762
|
+
// ../../../.yarn/__virtual__/debug-virtual-4a69f763f8/0/cache/debug-npm-4.4.0-f1ca372596-db94f1a182.zip/node_modules/debug/src/index.js
|
|
763
763
|
var require_src = __commonJS({
|
|
764
|
-
"../../../.yarn/__virtual__/debug-virtual-
|
|
764
|
+
"../../../.yarn/__virtual__/debug-virtual-4a69f763f8/0/cache/debug-npm-4.4.0-f1ca372596-db94f1a182.zip/node_modules/debug/src/index.js"(exports2, module2) {
|
|
765
765
|
"use strict";
|
|
766
766
|
init_cjs_shims();
|
|
767
767
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
@@ -775,36 +775,690 @@ var require_src = __commonJS({
|
|
|
775
775
|
// src/index.ts
|
|
776
776
|
var src_exports = {};
|
|
777
777
|
__export(src_exports, {
|
|
778
|
-
|
|
778
|
+
babelBuild: () => import_web_config3.babelBuild,
|
|
779
|
+
babelJsonReplacementPlugin: () => import_web_config3.babelJsonReplacementPlugin,
|
|
780
|
+
getPackageManager: () => import_web_config3.getPackageManager,
|
|
781
|
+
initialize: () => initialize,
|
|
782
|
+
loadConfig: () => import_web_config3.loadConfig
|
|
779
783
|
});
|
|
780
784
|
module.exports = __toCommonJS(src_exports);
|
|
781
785
|
init_cjs_shims();
|
|
782
|
-
var
|
|
786
|
+
var import_clipanion7 = require("clipanion");
|
|
787
|
+
|
|
788
|
+
// src/BuildCommand.ts
|
|
789
|
+
init_cjs_shims();
|
|
790
|
+
var import_path7 = __toESM(require("path"), 1);
|
|
791
|
+
var p3 = __toESM(require("@clack/prompts"), 1);
|
|
792
|
+
var import_utils4 = require("@granite-js/utils");
|
|
793
|
+
var import_clipanion = require("clipanion");
|
|
794
|
+
|
|
795
|
+
// src/build/buildArtifact/index.ts
|
|
796
|
+
init_cjs_shims();
|
|
797
|
+
var p2 = __toESM(require("@clack/prompts"), 1);
|
|
798
|
+
|
|
799
|
+
// src/build/buildArtifact/defaultBuildDeps.ts
|
|
800
|
+
init_cjs_shims();
|
|
801
|
+
var import_plugins = require("@apps-in-toss/plugins");
|
|
802
|
+
var import_uuidv7 = require("uuidv7");
|
|
803
|
+
|
|
804
|
+
// src/build/buildArtifact/utils.ts
|
|
805
|
+
init_cjs_shims();
|
|
806
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
807
|
+
var import_path = __toESM(require("path"), 1);
|
|
808
|
+
|
|
809
|
+
// src/build/buildArtifact/constants.ts
|
|
810
|
+
init_cjs_shims();
|
|
811
|
+
var RUNTIME_BUILD_DEFINITIONS = [
|
|
812
|
+
{ runtimeVersion: "0.84.0" },
|
|
813
|
+
{ runtimeVersion: "0.72.6", configTargetVersion: "0.72.6" }
|
|
814
|
+
];
|
|
815
|
+
var DIST_DIRECTORY = "dist";
|
|
816
|
+
|
|
817
|
+
// src/build/buildArtifact/utils.ts
|
|
818
|
+
async function clearBuildCache(packageRoot) {
|
|
819
|
+
await import_promises.default.rm(import_path.default.join(packageRoot, DIST_DIRECTORY), { recursive: true, force: true });
|
|
820
|
+
}
|
|
821
|
+
async function ensureGraniteConfigExists(graniteConfigPath) {
|
|
822
|
+
try {
|
|
823
|
+
await import_promises.default.access(graniteConfigPath);
|
|
824
|
+
} catch {
|
|
825
|
+
throw new Error(`Cannot find granite config: ${graniteConfigPath}`);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
async function resolveArtifactOptions(strategy, context) {
|
|
829
|
+
if (strategy.getArtifactOptions == null) {
|
|
830
|
+
return { isGame: context.appType === "game" };
|
|
831
|
+
}
|
|
832
|
+
return strategy.getArtifactOptions(context);
|
|
833
|
+
}
|
|
834
|
+
async function readAppManifest(appJsonPath) {
|
|
835
|
+
const appJsonRaw = await import_promises.default.readFile(appJsonPath, "utf8");
|
|
836
|
+
const appJson = JSON.parse(appJsonRaw);
|
|
837
|
+
if (typeof appJson.appName !== "string" || appJson.appName.length === 0) {
|
|
838
|
+
throw new Error(`Invalid appName in ${appJsonPath}`);
|
|
839
|
+
}
|
|
840
|
+
return {
|
|
841
|
+
appName: appJson.appName,
|
|
842
|
+
appType: appJson.appType ?? void 0
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// src/build/resolveBuildStrategy.ts
|
|
847
|
+
init_cjs_shims();
|
|
848
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
849
|
+
async function resolveBuildStrategy(graniteConfigPath, strategyFactories) {
|
|
850
|
+
const graniteConfigSource = await import_promises2.default.readFile(graniteConfigPath, "utf8");
|
|
851
|
+
for (const strategy of strategyFactories) {
|
|
852
|
+
if (await strategy.match({ graniteConfigPath, graniteConfigSource })) {
|
|
853
|
+
return strategy;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
throw new Error(`Cannot resolve build strategy: ${graniteConfigPath}`);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// src/build/buildArtifact/defaultBuildDeps.ts
|
|
860
|
+
var defaultBuildDeps = {
|
|
861
|
+
clearBuildCache,
|
|
862
|
+
resolveStrategy: resolveBuildStrategy,
|
|
863
|
+
collectDependencyVersions: import_plugins.collectDependencyVersions,
|
|
864
|
+
createArtifact: import_plugins.createArtifact,
|
|
865
|
+
getSdkVersion: import_plugins.getSdkVersion,
|
|
866
|
+
generateDeploymentId: import_uuidv7.uuidv7
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
// src/build/buildArtifact/prepareArtifact.ts
|
|
870
|
+
init_cjs_shims();
|
|
871
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
872
|
+
|
|
873
|
+
// src/utils/constants.ts
|
|
874
|
+
init_cjs_shims();
|
|
875
|
+
var APP_MANIFEST_NAME = "app.json";
|
|
876
|
+
var DEFAULT_API_BASE_URL = "https://apps-in-toss.toss.im/console";
|
|
877
|
+
|
|
878
|
+
// src/build/buildArtifact/prepareArtifact.ts
|
|
879
|
+
async function prepareArtifact({
|
|
880
|
+
packageRoot,
|
|
881
|
+
preparation,
|
|
882
|
+
services
|
|
883
|
+
}) {
|
|
884
|
+
const appJsonPath = import_path2.default.join(packageRoot, ".granite", APP_MANIFEST_NAME);
|
|
885
|
+
const { appName, appType } = await readAppManifest(appJsonPath);
|
|
886
|
+
const outfile = import_path2.default.join(packageRoot, `${appName}.ait`);
|
|
887
|
+
const { dependencies, devDependencies } = await services.collectDependencyVersions(packageRoot);
|
|
888
|
+
const sdkVersion = services.getSdkVersion();
|
|
889
|
+
const artifactOptions = await resolveArtifactOptions(preparation.strategy, {
|
|
890
|
+
...preparation.context,
|
|
891
|
+
appName,
|
|
892
|
+
appType
|
|
893
|
+
});
|
|
894
|
+
return {
|
|
895
|
+
appJsonPath,
|
|
896
|
+
appName,
|
|
897
|
+
appType,
|
|
898
|
+
outfile,
|
|
899
|
+
sdkVersion,
|
|
900
|
+
dependencies,
|
|
901
|
+
devDependencies,
|
|
902
|
+
artifactOptions
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// src/build/buildArtifact/prepareBuild.ts
|
|
907
|
+
init_cjs_shims();
|
|
908
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
909
|
+
async function prepareBuild({
|
|
910
|
+
packageRoot,
|
|
911
|
+
services,
|
|
912
|
+
strategies
|
|
913
|
+
}) {
|
|
914
|
+
const graniteConfigPath = import_path3.default.join(packageRoot, "granite.config.ts");
|
|
915
|
+
const deploymentId = services.generateDeploymentId();
|
|
916
|
+
await ensureGraniteConfigExists(graniteConfigPath);
|
|
917
|
+
await services.clearBuildCache(packageRoot);
|
|
918
|
+
const strategy = await services.resolveStrategy(graniteConfigPath, strategies);
|
|
919
|
+
const buildInput = {
|
|
920
|
+
runtimeBuildDefinitions: RUNTIME_BUILD_DEFINITIONS
|
|
921
|
+
};
|
|
922
|
+
if (buildInput.runtimeBuildDefinitions.length === 0) {
|
|
923
|
+
throw new Error("No runtime build definitions provided");
|
|
924
|
+
}
|
|
925
|
+
return {
|
|
926
|
+
strategy,
|
|
927
|
+
context: { packageRoot, deploymentId, graniteConfigPath },
|
|
928
|
+
buildInput,
|
|
929
|
+
primaryRuntimeVersion: buildInput.runtimeBuildDefinitions[0].runtimeVersion
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// src/build/buildArtifact/runStrategyBuild.ts
|
|
934
|
+
init_cjs_shims();
|
|
935
|
+
var p = __toESM(require("@clack/prompts"), 1);
|
|
936
|
+
async function runStrategyBuild(preparation) {
|
|
937
|
+
const buildResults = await preparation.strategy.build(preparation.buildInput, preparation.context);
|
|
938
|
+
const bundleFiles = [];
|
|
939
|
+
for (let i = 0; i < buildResults.length; i++) {
|
|
940
|
+
const result = buildResults[i];
|
|
941
|
+
bundleFiles.push(...result.bundleFiles);
|
|
942
|
+
p.log.step(`[${i + 1}/${buildResults.length}] Built for RN ${result.runtimeVersion}`);
|
|
943
|
+
}
|
|
944
|
+
return bundleFiles;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// src/build/RNBuildStrategy.ts
|
|
948
|
+
init_cjs_shims();
|
|
949
|
+
var import_promises4 = __toESM(require("fs/promises"), 1);
|
|
950
|
+
var import_path5 = __toESM(require("path"), 1);
|
|
951
|
+
var import_web_config = require("@apps-in-toss/web-config");
|
|
952
|
+
var import_execa = require("execa");
|
|
953
|
+
|
|
954
|
+
// src/build/createRuntimeBundleFiles.ts
|
|
955
|
+
init_cjs_shims();
|
|
956
|
+
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
957
|
+
var import_path4 = __toESM(require("path"), 1);
|
|
958
|
+
async function createRuntimeBundleFiles({
|
|
959
|
+
packageRoot,
|
|
960
|
+
runtimeVersion,
|
|
961
|
+
bundleOutputDir
|
|
962
|
+
}) {
|
|
963
|
+
const distPath = import_path4.default.isAbsolute(bundleOutputDir) ? bundleOutputDir : import_path4.default.join(packageRoot, bundleOutputDir);
|
|
964
|
+
const platforms = ["ios", "android"];
|
|
965
|
+
const runtimeName = runtimeVersion.replace(/\./g, "_");
|
|
966
|
+
const bundleFiles = [];
|
|
967
|
+
for (const platform of platforms) {
|
|
968
|
+
const sourceJsPath = import_path4.default.join(distPath, `bundle.${platform}.js`);
|
|
969
|
+
const sourceMapPath = import_path4.default.join(distPath, `bundle.${platform}.js.map`);
|
|
970
|
+
const targetJsPath = import_path4.default.join(distPath, `bundle.${platform}.${runtimeName}.js`);
|
|
971
|
+
const targetMapPath = import_path4.default.join(distPath, `bundle.${platform}.${runtimeName}.js.map`);
|
|
972
|
+
await copyRequiredFile(sourceJsPath, targetJsPath);
|
|
973
|
+
await copyRequiredFile(sourceMapPath, targetMapPath);
|
|
974
|
+
bundleFiles.push({
|
|
975
|
+
path: targetJsPath,
|
|
976
|
+
platform,
|
|
977
|
+
runtimeVersion
|
|
978
|
+
});
|
|
979
|
+
bundleFiles.push({
|
|
980
|
+
path: targetMapPath,
|
|
981
|
+
platform,
|
|
982
|
+
runtimeVersion
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
return bundleFiles;
|
|
986
|
+
}
|
|
987
|
+
async function copyRequiredFile(sourcePath, targetPath) {
|
|
988
|
+
try {
|
|
989
|
+
await import_promises3.default.copyFile(sourcePath, targetPath);
|
|
990
|
+
} catch {
|
|
991
|
+
throw new Error(`Missing build output file: ${sourcePath}`);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// src/utils/injectAppsInTossTarget.ts
|
|
996
|
+
init_cjs_shims();
|
|
997
|
+
|
|
998
|
+
// src/MigrateCommand/codemod/index.ts
|
|
999
|
+
init_cjs_shims();
|
|
1000
|
+
|
|
1001
|
+
// src/MigrateCommand/codemod/transform.ts
|
|
1002
|
+
init_cjs_shims();
|
|
1003
|
+
var import_jscodeshift = __toESM(require("jscodeshift"), 1);
|
|
1004
|
+
function transform(source, { transformers: transformers2, options = {} }) {
|
|
1005
|
+
const j = import_jscodeshift.default.withParser("tsx");
|
|
1006
|
+
const report = [];
|
|
1007
|
+
const stats = /* @__PURE__ */ new Map();
|
|
1008
|
+
const context = {
|
|
1009
|
+
j,
|
|
1010
|
+
jscodeshift: j,
|
|
1011
|
+
stats: (name, quantity = 1) => {
|
|
1012
|
+
if (quantity === 0) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
stats.set(name, (stats.get(name) ?? 0) + quantity);
|
|
1016
|
+
},
|
|
1017
|
+
report: (message) => {
|
|
1018
|
+
report.push(message);
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
const root = transformers2.reduce((root2, transformer) => transformer(root2, context, options), j(source));
|
|
1022
|
+
return root.toSource();
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// src/utils/injectAppsInTossTarget.ts
|
|
1026
|
+
var TARGET_IMPORTS = [
|
|
1027
|
+
{ source: "@apps-in-toss/framework/plugins", importName: "appsInToss" },
|
|
1028
|
+
{ source: "@apps-in-toss/plugins", importName: "appsInToss" },
|
|
1029
|
+
{ source: "@apps-in-toss/framework/internal", importName: "appsInTossHost" },
|
|
1030
|
+
{ source: "@apps-in-toss/plugins/internal", importName: "appsInTossHost" }
|
|
1031
|
+
];
|
|
1032
|
+
function createAppsInTossTargetTransformer(stats) {
|
|
1033
|
+
return (root, { j }, options) => {
|
|
1034
|
+
const fileName = options?.fileName ?? "<unknown>";
|
|
1035
|
+
const targetVersion = options?.targetVersion;
|
|
1036
|
+
if (typeof targetVersion !== "string" || targetVersion.length === 0) {
|
|
1037
|
+
return root;
|
|
1038
|
+
}
|
|
1039
|
+
const localNames = /* @__PURE__ */ new Set();
|
|
1040
|
+
let warnedForUnsupportedArg = false;
|
|
1041
|
+
for (const targetImport of TARGET_IMPORTS) {
|
|
1042
|
+
root.find(j.ImportDeclaration, {
|
|
1043
|
+
source: { value: targetImport.source }
|
|
1044
|
+
}).forEach((importPath) => {
|
|
1045
|
+
for (const specifier of importPath.node.specifiers ?? []) {
|
|
1046
|
+
if (specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === targetImport.importName) {
|
|
1047
|
+
localNames.add(specifier.local?.name ?? targetImport.importName);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
if (localNames.size === 0) {
|
|
1053
|
+
return root;
|
|
1054
|
+
}
|
|
1055
|
+
root.find(j.CallExpression).forEach((path13) => {
|
|
1056
|
+
const callee = path13.node.callee;
|
|
1057
|
+
if (!j.Identifier.check(callee) || !localNames.has(callee.name)) {
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
stats.matchedCallCount += 1;
|
|
1061
|
+
const firstArg = path13.node.arguments[0];
|
|
1062
|
+
if (firstArg == null) {
|
|
1063
|
+
path13.node.arguments = [
|
|
1064
|
+
j.objectExpression([j.objectProperty(j.identifier("target"), j.stringLiteral(targetVersion))])
|
|
1065
|
+
];
|
|
1066
|
+
stats.updatedCallCount += 1;
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
if (!j.ObjectExpression.check(firstArg)) {
|
|
1070
|
+
stats.hadUnsupportedArgument = true;
|
|
1071
|
+
if (!warnedForUnsupportedArg) {
|
|
1072
|
+
warnedForUnsupportedArg = true;
|
|
1073
|
+
options?.onUnsupportedArgument?.(fileName);
|
|
1074
|
+
}
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
const targetProp = firstArg.properties.find((property) => {
|
|
1078
|
+
if (!j.ObjectProperty.check(property)) {
|
|
1079
|
+
return false;
|
|
1080
|
+
}
|
|
1081
|
+
if (j.Identifier.check(property.key)) {
|
|
1082
|
+
return property.key.name === "target";
|
|
1083
|
+
}
|
|
1084
|
+
return j.StringLiteral.check(property.key) && property.key.value === "target";
|
|
1085
|
+
});
|
|
1086
|
+
if (targetProp != null && j.ObjectProperty.check(targetProp)) {
|
|
1087
|
+
targetProp.value = j.stringLiteral(targetVersion);
|
|
1088
|
+
stats.updatedCallCount += 1;
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
firstArg.properties.unshift(j.objectProperty(j.identifier("target"), j.stringLiteral(targetVersion)));
|
|
1092
|
+
stats.updatedCallCount += 1;
|
|
1093
|
+
});
|
|
1094
|
+
return root;
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
function injectAppsInTossTargetWithResult(source, options) {
|
|
1098
|
+
const stats = {
|
|
1099
|
+
matchedCallCount: 0,
|
|
1100
|
+
updatedCallCount: 0,
|
|
1101
|
+
hadUnsupportedArgument: false
|
|
1102
|
+
};
|
|
1103
|
+
const code = transform(source, {
|
|
1104
|
+
transformers: [createAppsInTossTargetTransformer(stats)],
|
|
1105
|
+
options
|
|
1106
|
+
});
|
|
1107
|
+
return {
|
|
1108
|
+
code,
|
|
1109
|
+
...stats
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// src/build/RNBuildStrategy.ts
|
|
1114
|
+
var GRANITE_DIRECTORY = ".granite";
|
|
1115
|
+
var TEMP_CONFIG_FILE_PREFIX = ".ait-runtime";
|
|
1116
|
+
var BUNDLE_OUTPUT_DIRECTORY = "dist";
|
|
1117
|
+
var RNBuildStrategy = class {
|
|
1118
|
+
name = "rn";
|
|
1119
|
+
match(context) {
|
|
1120
|
+
return true;
|
|
1121
|
+
}
|
|
1122
|
+
async build(input, context) {
|
|
1123
|
+
const results = [];
|
|
1124
|
+
const graniteCommand = resolveGraniteCommand();
|
|
1125
|
+
for (const definition of input.runtimeBuildDefinitions) {
|
|
1126
|
+
const graniteBuildArgs = await resolveGraniteBuildArgs(definition, context);
|
|
1127
|
+
const tempConfigPath = graniteBuildArgs.tempConfigPath;
|
|
1128
|
+
const commandArgs = [...graniteCommand.prefixArgs, "build", ...graniteBuildArgs.args];
|
|
1129
|
+
try {
|
|
1130
|
+
await (0, import_execa.execa)(graniteCommand.executable, commandArgs, {
|
|
1131
|
+
cwd: context.packageRoot,
|
|
1132
|
+
env: {
|
|
1133
|
+
...process.env,
|
|
1134
|
+
AIT_DEPLOYMENT_ID: context.deploymentId
|
|
1135
|
+
},
|
|
1136
|
+
stdio: "inherit"
|
|
1137
|
+
});
|
|
1138
|
+
} catch (error) {
|
|
1139
|
+
throw new Error(`granite build failed: ${graniteCommand.executable} ${commandArgs.join(" ")}`, {
|
|
1140
|
+
cause: error
|
|
1141
|
+
});
|
|
1142
|
+
} finally {
|
|
1143
|
+
if (tempConfigPath != null) {
|
|
1144
|
+
await import_promises4.default.rm(tempConfigPath, { force: true });
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
results.push({
|
|
1148
|
+
runtimeVersion: definition.runtimeVersion,
|
|
1149
|
+
bundleFiles: await createRuntimeBundleFiles({
|
|
1150
|
+
packageRoot: context.packageRoot,
|
|
1151
|
+
runtimeVersion: definition.runtimeVersion,
|
|
1152
|
+
bundleOutputDir: BUNDLE_OUTPUT_DIRECTORY
|
|
1153
|
+
})
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
return results;
|
|
1157
|
+
}
|
|
1158
|
+
async getArtifactOptions(context) {
|
|
1159
|
+
return {
|
|
1160
|
+
isGame: context.appType === "game"
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
function resolveGraniteCommand() {
|
|
1165
|
+
const { packageManager } = (0, import_web_config.getPackageManager)({ isExecutor: true });
|
|
1166
|
+
return {
|
|
1167
|
+
executable: packageManager,
|
|
1168
|
+
prefixArgs: ["granite"]
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
async function resolveGraniteBuildArgs(definition, context) {
|
|
1172
|
+
if (definition.configTargetVersion == null) {
|
|
1173
|
+
return { args: ["--no-cache"] };
|
|
1174
|
+
}
|
|
1175
|
+
const targetVersion = definition.configTargetVersion;
|
|
1176
|
+
const tempConfigRelativePath = createTempConfigRelativePath(targetVersion);
|
|
1177
|
+
const tempConfigPath = import_path5.default.join(context.packageRoot, tempConfigRelativePath);
|
|
1178
|
+
try {
|
|
1179
|
+
await writeRuntimeConfig(context.graniteConfigPath, tempConfigPath, targetVersion);
|
|
1180
|
+
return {
|
|
1181
|
+
args: ["--config", tempConfigRelativePath, "--no-cache"],
|
|
1182
|
+
tempConfigPath
|
|
1183
|
+
};
|
|
1184
|
+
} catch {
|
|
1185
|
+
return { args: ["--no-cache"], tempConfigPath };
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
function createTempConfigRelativePath(targetVersion) {
|
|
1189
|
+
const runtimeName = targetVersion.replace(/\./g, "_");
|
|
1190
|
+
return import_path5.default.join(GRANITE_DIRECTORY, `${TEMP_CONFIG_FILE_PREFIX}-${runtimeName}.config.ts`);
|
|
1191
|
+
}
|
|
1192
|
+
async function writeRuntimeConfig(graniteConfigPath, tempConfigPath, targetVersion) {
|
|
1193
|
+
const source = await import_promises4.default.readFile(graniteConfigPath, "utf8");
|
|
1194
|
+
const transformed = injectAppsInTossTargetWithResult(source, {
|
|
1195
|
+
fileName: graniteConfigPath,
|
|
1196
|
+
targetVersion
|
|
1197
|
+
});
|
|
1198
|
+
if (transformed.matchedCallCount === 0) {
|
|
1199
|
+
throw new Error(
|
|
1200
|
+
`Cannot inject target (${targetVersion}) into ${graniteConfigPath}: appsInToss/appsInTossHost call not found`
|
|
1201
|
+
);
|
|
1202
|
+
}
|
|
1203
|
+
if (transformed.hadUnsupportedArgument) {
|
|
1204
|
+
throw new Error(
|
|
1205
|
+
`Cannot inject target (${targetVersion}) into ${graniteConfigPath}: unsupported plugin argument shape detected`
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
await import_promises4.default.mkdir(import_path5.default.dirname(tempConfigPath), { recursive: true });
|
|
1209
|
+
await import_promises4.default.writeFile(tempConfigPath, transformed.code, "utf8");
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
// src/build/WebBuildStrategy.ts
|
|
1213
|
+
init_cjs_shims();
|
|
1214
|
+
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
1215
|
+
var import_module = require("module");
|
|
1216
|
+
var import_path6 = __toESM(require("path"), 1);
|
|
1217
|
+
var import_web_config2 = require("@apps-in-toss/web-config");
|
|
1218
|
+
var import_execa2 = require("execa");
|
|
1219
|
+
var APP_MANIFEST_NAME2 = "app.json";
|
|
1220
|
+
var WebBuildStrategy = class {
|
|
1221
|
+
name = "web";
|
|
1222
|
+
config;
|
|
1223
|
+
prepared = false;
|
|
1224
|
+
match({ graniteConfigSource }) {
|
|
1225
|
+
return graniteConfigSource.includes("@apps-in-toss/web-framework");
|
|
1226
|
+
}
|
|
1227
|
+
async build(input, context) {
|
|
1228
|
+
const config = await this.ensurePrepared(context);
|
|
1229
|
+
const results = [];
|
|
1230
|
+
for (const definition of input.runtimeBuildDefinitions) {
|
|
1231
|
+
for (const platform of ["ios", "android"]) {
|
|
1232
|
+
const buildResult = await buildRuntimeBundle({
|
|
1233
|
+
config,
|
|
1234
|
+
runtimeVersion: definition.runtimeVersion,
|
|
1235
|
+
deploymentId: context.deploymentId,
|
|
1236
|
+
packageRoot: context.packageRoot,
|
|
1237
|
+
platform
|
|
1238
|
+
});
|
|
1239
|
+
await (0, import_web_config2.writeBundle)(buildResult, { platform, config, cwd: context.packageRoot });
|
|
1240
|
+
}
|
|
1241
|
+
results.push({
|
|
1242
|
+
runtimeVersion: definition.runtimeVersion,
|
|
1243
|
+
bundleFiles: await createRuntimeBundleFiles({
|
|
1244
|
+
packageRoot: context.packageRoot,
|
|
1245
|
+
runtimeVersion: definition.runtimeVersion,
|
|
1246
|
+
bundleOutputDir: config.outdir
|
|
1247
|
+
})
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
return results;
|
|
1251
|
+
}
|
|
1252
|
+
async getArtifactOptions(context) {
|
|
1253
|
+
const config = await this.ensureConfig();
|
|
1254
|
+
const isGame = config.webViewProps?.type === "game";
|
|
1255
|
+
const extra = {
|
|
1256
|
+
brand: config.brand,
|
|
1257
|
+
...config.navigationBar != null ? { navigationBar: config.navigationBar } : {},
|
|
1258
|
+
...config.webViewProps != null ? { webViewProps: config.webViewProps } : {}
|
|
1259
|
+
};
|
|
1260
|
+
const webDistDir = import_path6.default.join(context.packageRoot, config.outdir, "web");
|
|
1261
|
+
const additionalFilesToZip = await getWebDistFiles(webDistDir);
|
|
1262
|
+
return { isGame, additionalFilesToZip, extra };
|
|
1263
|
+
}
|
|
1264
|
+
async ensurePrepared(context) {
|
|
1265
|
+
const config = await this.ensureConfig();
|
|
1266
|
+
if (this.prepared) {
|
|
1267
|
+
return config;
|
|
1268
|
+
}
|
|
1269
|
+
const outdir = import_path6.default.join(context.packageRoot, config.outdir);
|
|
1270
|
+
const webDistDir = import_path6.default.join(context.packageRoot, config.outdir, "web");
|
|
1271
|
+
try {
|
|
1272
|
+
const files = await import_promises5.default.readdir(webDistDir);
|
|
1273
|
+
if (files.includes("index.html")) {
|
|
1274
|
+
await this.writeAppJson(context);
|
|
1275
|
+
this.prepared = true;
|
|
1276
|
+
return config;
|
|
1277
|
+
}
|
|
1278
|
+
} catch {
|
|
1279
|
+
}
|
|
1280
|
+
const { packageManager } = (0, import_web_config2.getPackageManager)({ isExecutor: true });
|
|
1281
|
+
await import_promises5.default.rm(outdir, { recursive: true, force: true });
|
|
1282
|
+
await (0, import_execa2.execa)(packageManager, config.web.commands.build.split(" "), {
|
|
1283
|
+
cwd: context.packageRoot,
|
|
1284
|
+
stdio: "inherit",
|
|
1285
|
+
shell: true
|
|
1286
|
+
});
|
|
1287
|
+
await import_promises5.default.mkdir(webDistDir, { recursive: true });
|
|
1288
|
+
const items = await import_promises5.default.readdir(outdir);
|
|
1289
|
+
for (const item of items) {
|
|
1290
|
+
const src = import_path6.default.join(outdir, item);
|
|
1291
|
+
const dest = import_path6.default.join(webDistDir, item);
|
|
1292
|
+
if (src === webDistDir) {
|
|
1293
|
+
continue;
|
|
1294
|
+
}
|
|
1295
|
+
await import_promises5.default.rename(src, dest);
|
|
1296
|
+
}
|
|
1297
|
+
const webDistFiles = await import_promises5.default.readdir(webDistDir);
|
|
1298
|
+
if (webDistFiles.length === 0) {
|
|
1299
|
+
throw new Error(
|
|
1300
|
+
`Web build output is empty. Check that your outdir path and web.commands.build output path match in granite.config.ts.`
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
if (!webDistFiles.includes("index.html")) {
|
|
1304
|
+
throw new Error(
|
|
1305
|
+
`Web build output requires ${config.outdir}/web/index.html. Currently only CSR / SSG environments are supported.`
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
await this.writeAppJson(context);
|
|
1309
|
+
this.prepared = true;
|
|
1310
|
+
return config;
|
|
1311
|
+
}
|
|
1312
|
+
async writeAppJson(context) {
|
|
1313
|
+
const config = await this.ensureConfig();
|
|
1314
|
+
const graniteDir = import_path6.default.join(context.packageRoot, ".granite");
|
|
1315
|
+
await import_promises5.default.mkdir(graniteDir, { recursive: true });
|
|
1316
|
+
await import_promises5.default.writeFile(
|
|
1317
|
+
import_path6.default.join(graniteDir, APP_MANIFEST_NAME2),
|
|
1318
|
+
JSON.stringify(
|
|
1319
|
+
{
|
|
1320
|
+
appName: config.appName,
|
|
1321
|
+
permissions: config.permissions
|
|
1322
|
+
},
|
|
1323
|
+
null,
|
|
1324
|
+
2
|
|
1325
|
+
),
|
|
1326
|
+
"utf8"
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
async ensureConfig() {
|
|
1330
|
+
if (this.config) {
|
|
1331
|
+
return this.config;
|
|
1332
|
+
}
|
|
1333
|
+
const config = await (0, import_web_config2.loadConfig)();
|
|
1334
|
+
if (!config) {
|
|
1335
|
+
throw new Error("Cannot find granite config");
|
|
1336
|
+
}
|
|
1337
|
+
this.config = config;
|
|
1338
|
+
return this.config;
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
async function buildRuntimeBundle({
|
|
1342
|
+
config,
|
|
1343
|
+
runtimeVersion,
|
|
1344
|
+
deploymentId,
|
|
1345
|
+
packageRoot,
|
|
1346
|
+
platform = "ios"
|
|
1347
|
+
}) {
|
|
1348
|
+
const buildNumber = getBuildNumber();
|
|
1349
|
+
const projectRequire = (0, import_module.createRequire)(import_path6.default.join(packageRoot, "package.json"));
|
|
1350
|
+
const rnSuffix = runtimeVersion.startsWith("0.72") ? "rn72" : "rn84";
|
|
1351
|
+
const prebuiltPath = projectRequire.resolve(`@apps-in-toss/web-framework/prebuilt/prod/${platform}/${rnSuffix}`);
|
|
1352
|
+
return (0, import_web_config2.babelBuild)({
|
|
1353
|
+
config,
|
|
1354
|
+
platform,
|
|
1355
|
+
buildNumber,
|
|
1356
|
+
deploymentId,
|
|
1357
|
+
prebuiltPath
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
function getBuildNumber() {
|
|
1361
|
+
const date = /* @__PURE__ */ new Date();
|
|
1362
|
+
const year = date.getFullYear();
|
|
1363
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
1364
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
1365
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
1366
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
1367
|
+
const seconds = String(date.getSeconds()).padStart(2, "0");
|
|
1368
|
+
return `${year}${month}${day}${hours}${minutes}${seconds}`;
|
|
1369
|
+
}
|
|
1370
|
+
async function getWebDistFiles(webDistDir) {
|
|
1371
|
+
const additionalFilesToZip = [];
|
|
1372
|
+
try {
|
|
1373
|
+
const allFiles = await import_promises5.default.readdir(webDistDir, { recursive: true });
|
|
1374
|
+
const webFiles = await Promise.all(
|
|
1375
|
+
allFiles.map(async (file) => {
|
|
1376
|
+
const filePath = import_path6.default.join(webDistDir, String(file));
|
|
1377
|
+
const stat = await import_promises5.default.stat(filePath);
|
|
1378
|
+
return stat.isFile() ? String(file) : null;
|
|
1379
|
+
})
|
|
1380
|
+
).then((files) => files.filter((file) => file !== null));
|
|
1381
|
+
additionalFilesToZip.push(
|
|
1382
|
+
...webFiles.map((file) => ({
|
|
1383
|
+
path: import_path6.default.join(webDistDir, file),
|
|
1384
|
+
name: import_path6.default.join("web", file)
|
|
1385
|
+
}))
|
|
1386
|
+
);
|
|
1387
|
+
} catch {
|
|
1388
|
+
}
|
|
1389
|
+
return additionalFilesToZip;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// src/build/buildArtifact/index.ts
|
|
1393
|
+
async function buildArtifact(packageRoot, deps = {}) {
|
|
1394
|
+
const services = {
|
|
1395
|
+
...defaultBuildDeps,
|
|
1396
|
+
...deps
|
|
1397
|
+
};
|
|
1398
|
+
const strategies = [new WebBuildStrategy(), new RNBuildStrategy()];
|
|
1399
|
+
const preparation = await prepareBuild({ packageRoot, services, strategies });
|
|
1400
|
+
const bundleFiles = await runStrategyBuild(preparation);
|
|
1401
|
+
const artifact = await prepareArtifact({ packageRoot, preparation, services });
|
|
1402
|
+
p2.log.step("Creating .ait artifact...");
|
|
1403
|
+
await services.createArtifact({
|
|
1404
|
+
reactNativeVersion: preparation.primaryRuntimeVersion,
|
|
1405
|
+
sdkVersion: artifact.sdkVersion,
|
|
1406
|
+
isGame: artifact.artifactOptions.isGame,
|
|
1407
|
+
isWeb: preparation.strategy.name === "web",
|
|
1408
|
+
appJsonPath: artifact.appJsonPath,
|
|
1409
|
+
deploymentId: preparation.context.deploymentId,
|
|
1410
|
+
packageJson: {
|
|
1411
|
+
dependencies: artifact.dependencies,
|
|
1412
|
+
devDependencies: artifact.devDependencies
|
|
1413
|
+
},
|
|
1414
|
+
bundleFiles,
|
|
1415
|
+
outfile: artifact.outfile,
|
|
1416
|
+
...artifact.artifactOptions.additionalFilesToZip != null ? { additionalFilesToZip: artifact.artifactOptions.additionalFilesToZip } : {},
|
|
1417
|
+
...artifact.artifactOptions.extra != null ? { extra: artifact.artifactOptions.extra } : {}
|
|
1418
|
+
});
|
|
1419
|
+
return { outfile: artifact.outfile, deploymentId: preparation.context.deploymentId };
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// src/BuildCommand.ts
|
|
1423
|
+
var BuildCommand = class extends import_clipanion.Command {
|
|
1424
|
+
static paths = [["build"]];
|
|
1425
|
+
static usage = import_clipanion.Command.Usage({
|
|
1426
|
+
category: "Build",
|
|
1427
|
+
description: "Build Apps In Toss artifact",
|
|
1428
|
+
examples: [["Build artifact", "ait build"]]
|
|
1429
|
+
});
|
|
1430
|
+
async execute() {
|
|
1431
|
+
const packageRoot = (0, import_utils4.getPackageRoot)();
|
|
1432
|
+
const buildResult = await buildArtifact(packageRoot);
|
|
1433
|
+
p3.log.success(`AIT build completed (${import_path7.default.basename(buildResult.outfile)})`);
|
|
1434
|
+
p3.log.info(`deploymentId: ${buildResult.deploymentId}`);
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
783
1437
|
|
|
784
1438
|
// src/DeployCommand.ts
|
|
785
1439
|
init_cjs_shims();
|
|
786
1440
|
var import_assert = __toESM(require("assert"), 1);
|
|
787
1441
|
var import_fs3 = __toESM(require("fs"), 1);
|
|
788
|
-
var
|
|
1442
|
+
var import_path9 = __toESM(require("path"), 1);
|
|
789
1443
|
var import_ait_format = require("@apps-in-toss/ait-format");
|
|
790
|
-
var
|
|
791
|
-
var
|
|
792
|
-
var
|
|
1444
|
+
var p4 = __toESM(require("@clack/prompts"), 1);
|
|
1445
|
+
var import_utils5 = require("@granite-js/utils");
|
|
1446
|
+
var import_clipanion2 = require("clipanion");
|
|
793
1447
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
794
1448
|
|
|
795
1449
|
// src/utils/TokenStorage.ts
|
|
796
1450
|
init_cjs_shims();
|
|
797
1451
|
var import_fs = __toESM(require("fs"), 1);
|
|
798
1452
|
var import_os = __toESM(require("os"), 1);
|
|
799
|
-
var
|
|
1453
|
+
var import_path8 = __toESM(require("path"), 1);
|
|
800
1454
|
var TokenStorage = class {
|
|
801
1455
|
static get path() {
|
|
802
1456
|
const home = import_os.default.homedir();
|
|
803
|
-
const dir =
|
|
1457
|
+
const dir = import_path8.default.join(home, ".ait");
|
|
804
1458
|
if (!import_fs.default.existsSync(dir)) {
|
|
805
1459
|
import_fs.default.mkdirSync(dir, { recursive: true });
|
|
806
1460
|
}
|
|
807
|
-
return
|
|
1461
|
+
return import_path8.default.join(dir, "credentials");
|
|
808
1462
|
}
|
|
809
1463
|
static read() {
|
|
810
1464
|
const file = this.path;
|
|
@@ -846,11 +1500,6 @@ var TokenStorage = class {
|
|
|
846
1500
|
}
|
|
847
1501
|
};
|
|
848
1502
|
|
|
849
|
-
// src/utils/constants.ts
|
|
850
|
-
init_cjs_shims();
|
|
851
|
-
var APP_MANIFEST_NAME = "app.json";
|
|
852
|
-
var DEFAULT_API_BASE_URL = "https://apps-in-toss.toss.im/console";
|
|
853
|
-
|
|
854
1503
|
// src/utils/upload.ts
|
|
855
1504
|
init_cjs_shims();
|
|
856
1505
|
var import_fs2 = __toESM(require("fs"), 1);
|
|
@@ -889,7 +1538,7 @@ async function handleFetchResponse(response) {
|
|
|
889
1538
|
|
|
890
1539
|
// src/utils/withRetry.ts
|
|
891
1540
|
init_cjs_shims();
|
|
892
|
-
var
|
|
1541
|
+
var import_promises6 = require("timers/promises");
|
|
893
1542
|
async function withRetry(fn, options = {}) {
|
|
894
1543
|
const { maxRetries = 60, delayMs = 1e4, shouldRetryOnResult, shouldRetryOnError, onRetry } = options;
|
|
895
1544
|
let attempt = 0;
|
|
@@ -898,7 +1547,7 @@ async function withRetry(fn, options = {}) {
|
|
|
898
1547
|
const result = await fn();
|
|
899
1548
|
if (shouldRetryOnResult && shouldRetryOnResult(result)) {
|
|
900
1549
|
onRetry?.(attempt + 1, { result });
|
|
901
|
-
await (0,
|
|
1550
|
+
await (0, import_promises6.setTimeout)(delayMs);
|
|
902
1551
|
attempt++;
|
|
903
1552
|
continue;
|
|
904
1553
|
}
|
|
@@ -909,7 +1558,7 @@ async function withRetry(fn, options = {}) {
|
|
|
909
1558
|
throw error;
|
|
910
1559
|
}
|
|
911
1560
|
onRetry?.(attempt + 1, { error });
|
|
912
|
-
await (0,
|
|
1561
|
+
await (0, import_promises6.setTimeout)(delayMs);
|
|
913
1562
|
attempt++;
|
|
914
1563
|
}
|
|
915
1564
|
}
|
|
@@ -1017,29 +1666,29 @@ function checkBundleStatus(delayMs = 1e4, maxRetries = 10) {
|
|
|
1017
1666
|
}
|
|
1018
1667
|
|
|
1019
1668
|
// src/DeployCommand.ts
|
|
1020
|
-
var DeployCommand = class extends
|
|
1669
|
+
var DeployCommand = class extends import_clipanion2.Command {
|
|
1021
1670
|
static paths = [["deploy"]];
|
|
1022
|
-
apiKey =
|
|
1671
|
+
apiKey = import_clipanion2.Option.String("--api-key", {
|
|
1023
1672
|
required: false,
|
|
1024
1673
|
description: "\uBC30\uD3EC\uB97C \uC704\uD55C API \uD0A4\uC785\uB2C8\uB2E4. \uBA85\uC2DC\uC801\uC73C\uB85C \uC774 \uC635\uC158\uC73C\uB85C api key\uB97C \uC9C1\uC811 \uC785\uB825\uD558\uAC70\uB098, --profile \uC635\uC158\uC744 \uC0AC\uC6A9\uD574\uC11C \uD504\uB85C\uD544\uC744 \uC9C0\uC815\uD558\uBA74 \uD504\uB85C\uD544\uC5D0 \uB4F1\uB85D\uB41C api key\uB97C \uC0AC\uC6A9\uD574\uC694."
|
|
1025
1674
|
});
|
|
1026
|
-
workspace =
|
|
1675
|
+
workspace = import_clipanion2.Option.String("--workspace", {
|
|
1027
1676
|
required: false,
|
|
1028
1677
|
description: "(deprecated) \uD1A0\uD070 \uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4 \uC774\uB984\uC785\uB2C8\uB2E4. \uC774 \uC635\uC158 \uB300\uC2E0 --profile \uC635\uC158\uC744 \uC0AC\uC6A9\uD574\uC8FC\uC138\uC694."
|
|
1029
1678
|
});
|
|
1030
|
-
profile =
|
|
1679
|
+
profile = import_clipanion2.Option.String("--profile", {
|
|
1031
1680
|
required: false,
|
|
1032
1681
|
description: "ait token add \uBA85\uB839\uC5B4\uB97C \uD1B5\uD574 \uB4F1\uB85D\uD55C \uD504\uB85C\uD544\uC774\uC5D0\uC694. \uD504\uB85C\uD544\uC774 \uC5C6\uC73C\uBA74 default \uD504\uB85C\uD544\uC744 \uC0AC\uC6A9\uD574\uC694."
|
|
1033
1682
|
});
|
|
1034
|
-
baseUrl =
|
|
1683
|
+
baseUrl = import_clipanion2.Option.String("--base-url", {
|
|
1035
1684
|
description: "API Base URL",
|
|
1036
1685
|
required: false
|
|
1037
1686
|
});
|
|
1038
|
-
location =
|
|
1687
|
+
location = import_clipanion2.Option.String("--location", {
|
|
1039
1688
|
description: "\uC5C5\uB85C\uB4DC\uD560 .ait \uD30C\uC77C\uC758 \uACBD\uB85C\uB97C \uBA85\uC2DC\uC801\uC73C\uB85C \uC9C0\uC815\uD574\uC694. \uAE30\uBCF8\uAC12\uC740 \uD604\uC7AC \uD328\uD0A4\uC9C0 \uB8E8\uD2B8 \uB514\uB809\uD1A0\uB9AC\uC5D0 \uC788\uB294 ait \uD30C\uC77C\uC774\uC5D0\uC694.",
|
|
1040
1689
|
required: false
|
|
1041
1690
|
});
|
|
1042
|
-
schemeOnly =
|
|
1691
|
+
schemeOnly = import_clipanion2.Option.Boolean("--scheme-only", {
|
|
1043
1692
|
required: false,
|
|
1044
1693
|
description: "\uBC30\uD3EC \uACB0\uACFC\uB97C intoss-private scheme\uB9CC \uCD9C\uB825\uD558\uB3C4\uB85D \uC124\uC815\uD574\uC694. \uAE30\uBCF8\uAC12\uC740 false\uC608\uC694."
|
|
1045
1694
|
});
|
|
@@ -1047,10 +1696,10 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
1047
1696
|
const baseUrl = this.baseUrl;
|
|
1048
1697
|
const profile = this.profile || this.workspace || "default";
|
|
1049
1698
|
if (this.workspace) {
|
|
1050
|
-
|
|
1699
|
+
p4.log.warn("(deprecated) --workspace \uC635\uC158\uC740 \uC774\uC81C \uC0AC\uC6A9\uD558\uC9C0 \uC54A\uC544\uC694. \uC774 \uC635\uC158 \uB300\uC2E0 --profile \uC635\uC158\uC744 \uC0AC\uC6A9\uD574\uC8FC\uC138\uC694.");
|
|
1051
1700
|
}
|
|
1052
1701
|
const apiKey = await this.getApiKey(profile);
|
|
1053
|
-
if (
|
|
1702
|
+
if (p4.isCancel(apiKey)) {
|
|
1054
1703
|
return;
|
|
1055
1704
|
}
|
|
1056
1705
|
try {
|
|
@@ -1066,7 +1715,7 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
1066
1715
|
(0, import_assert.default)(typeof deploymentId2 === "string", "ait \uD30C\uC77C\uC5D0 deploymentId\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1067
1716
|
return { appName: appName2, deploymentId: deploymentId2 };
|
|
1068
1717
|
} else if (format === import_ait_format.AppsInTossBundle.Format.ZIP) {
|
|
1069
|
-
const rawAppManifest = await (0,
|
|
1718
|
+
const rawAppManifest = await (0, import_utils5.readZipContent)(resolvedArtifactPath, APP_MANIFEST_NAME);
|
|
1070
1719
|
const appManifest = JSON.parse(rawAppManifest);
|
|
1071
1720
|
const appName2 = appManifest.appName;
|
|
1072
1721
|
const deploymentId2 = appManifest._metadata.deploymentId;
|
|
@@ -1087,7 +1736,7 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
1087
1736
|
baseUrl
|
|
1088
1737
|
});
|
|
1089
1738
|
} else {
|
|
1090
|
-
await
|
|
1739
|
+
await p4.tasks([
|
|
1091
1740
|
{
|
|
1092
1741
|
title: `${colorAppName} \uC571 \uBC30\uD3EC \uC911...`,
|
|
1093
1742
|
task: async () => {
|
|
@@ -1125,7 +1774,7 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
1125
1774
|
this.context.stdout.write(`${result}
|
|
1126
1775
|
`);
|
|
1127
1776
|
} else {
|
|
1128
|
-
|
|
1777
|
+
p4.note(this.decorate(result, import_picocolors.default.green));
|
|
1129
1778
|
}
|
|
1130
1779
|
}
|
|
1131
1780
|
printError(error) {
|
|
@@ -1133,7 +1782,7 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
1133
1782
|
this.context.stdout.write(`${error.message}
|
|
1134
1783
|
`);
|
|
1135
1784
|
} else {
|
|
1136
|
-
|
|
1785
|
+
p4.log.error(error.message);
|
|
1137
1786
|
}
|
|
1138
1787
|
}
|
|
1139
1788
|
async getApiKey(profile) {
|
|
@@ -1141,7 +1790,7 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
1141
1790
|
if (token) {
|
|
1142
1791
|
return token;
|
|
1143
1792
|
}
|
|
1144
|
-
return await
|
|
1793
|
+
return await p4.password({
|
|
1145
1794
|
message: "\uC571\uC778\uD1A0\uC2A4 \uBC30\uD3EC API \uD0A4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694",
|
|
1146
1795
|
validate: (value) => {
|
|
1147
1796
|
if (value.length === 0) {
|
|
@@ -1156,24 +1805,24 @@ var DeployCommand = class extends import_clipanion.Command {
|
|
|
1156
1805
|
if (!location.endsWith(".ait")) {
|
|
1157
1806
|
throw new Error("\uBC30\uD3EC\uD560 \uD30C\uC77C\uC740 .ait \uD655\uC7A5\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4.");
|
|
1158
1807
|
}
|
|
1159
|
-
return
|
|
1808
|
+
return import_path9.default.resolve(location);
|
|
1160
1809
|
}
|
|
1161
|
-
const packageRoot = (0,
|
|
1810
|
+
const packageRoot = (0, import_utils5.getPackageRoot)();
|
|
1162
1811
|
const artifactFile = import_fs3.default.readdirSync(packageRoot).find((file) => file.endsWith(".ait"));
|
|
1163
1812
|
if (!artifactFile) {
|
|
1164
1813
|
throw new Error("\uBC30\uD3EC\uD560 .ait \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
1165
1814
|
}
|
|
1166
|
-
return
|
|
1815
|
+
return import_path9.default.resolve(packageRoot, artifactFile);
|
|
1167
1816
|
}
|
|
1168
1817
|
};
|
|
1169
1818
|
|
|
1170
1819
|
// src/InitCommand.ts
|
|
1171
1820
|
init_cjs_shims();
|
|
1172
1821
|
var import_fs4 = __toESM(require("fs"), 1);
|
|
1173
|
-
var
|
|
1174
|
-
var
|
|
1175
|
-
var
|
|
1176
|
-
var
|
|
1822
|
+
var import_path10 = __toESM(require("path"), 1);
|
|
1823
|
+
var p5 = __toESM(require("@clack/prompts"), 1);
|
|
1824
|
+
var import_utils6 = require("@granite-js/utils");
|
|
1825
|
+
var import_clipanion3 = require("clipanion");
|
|
1177
1826
|
|
|
1178
1827
|
// ../../../.yarn/cache/es-toolkit-npm-1.32.0-019fc7c155-56ba965570.zip/node_modules/es-toolkit/dist/index.mjs
|
|
1179
1828
|
init_cjs_shims();
|
|
@@ -1270,7 +1919,7 @@ function transformTemplate(templateString, values) {
|
|
|
1270
1919
|
|
|
1271
1920
|
// src/InitCommand.ts
|
|
1272
1921
|
async function templateWebFramework({ appName, cwd, skipInput }) {
|
|
1273
|
-
const packageJson = await import_fs4.default.promises.readFile(
|
|
1922
|
+
const packageJson = await import_fs4.default.promises.readFile(import_path10.default.join(cwd, "package.json"), {
|
|
1274
1923
|
encoding: "utf-8"
|
|
1275
1924
|
});
|
|
1276
1925
|
const scripts = JSON.parse(packageJson);
|
|
@@ -1279,25 +1928,25 @@ async function templateWebFramework({ appName, cwd, skipInput }) {
|
|
|
1279
1928
|
build: scripts?.scripts?.build
|
|
1280
1929
|
};
|
|
1281
1930
|
scripts.scripts.dev = "granite dev";
|
|
1282
|
-
scripts.scripts.build = "
|
|
1931
|
+
scripts.scripts.build = "ait build";
|
|
1283
1932
|
scripts.scripts.deploy = "ait deploy";
|
|
1284
|
-
await import_fs4.default.promises.writeFile(
|
|
1933
|
+
await import_fs4.default.promises.writeFile(import_path10.default.join(cwd, "package.json"), JSON.stringify(scripts, null, 2), {
|
|
1285
1934
|
encoding: "utf-8"
|
|
1286
1935
|
});
|
|
1287
|
-
|
|
1288
|
-
await import_fs4.default.promises.appendFile(
|
|
1936
|
+
p5.log.step(".gitignore \uD30C\uC77C\uC744 \uC5C5\uB370\uC774\uD2B8\uD558\uB294 \uC911...");
|
|
1937
|
+
await import_fs4.default.promises.appendFile(import_path10.default.join(cwd, ".gitignore"), "\n.granite\n");
|
|
1289
1938
|
const placeholder = {
|
|
1290
1939
|
dev: originalScripts.dev === "granite dev" ? "" : originalScripts.dev,
|
|
1291
|
-
build: originalScripts.build === "
|
|
1940
|
+
build: originalScripts.build === "ait build" ? "" : originalScripts.build
|
|
1292
1941
|
};
|
|
1293
|
-
const scriptInputs = skipInput ? placeholder : await
|
|
1942
|
+
const scriptInputs = skipInput ? placeholder : await p5.group(
|
|
1294
1943
|
{
|
|
1295
|
-
dev: () =>
|
|
1944
|
+
dev: () => p5.text({
|
|
1296
1945
|
message: "\uC6F9 \uBC88\uB4E4\uB7EC\uC758 dev \uBA85\uB839\uC5B4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.",
|
|
1297
1946
|
defaultValue: placeholder.dev,
|
|
1298
1947
|
placeholder: placeholder.dev
|
|
1299
1948
|
}),
|
|
1300
|
-
build: () =>
|
|
1949
|
+
build: () => p5.text({
|
|
1301
1950
|
message: "\uC6F9 \uBC88\uB4E4\uB7EC\uC758 build \uBA85\uB839\uC5B4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.",
|
|
1302
1951
|
defaultValue: placeholder.build,
|
|
1303
1952
|
placeholder: placeholder.build
|
|
@@ -1305,52 +1954,64 @@ async function templateWebFramework({ appName, cwd, skipInput }) {
|
|
|
1305
1954
|
},
|
|
1306
1955
|
{
|
|
1307
1956
|
onCancel: () => {
|
|
1308
|
-
|
|
1957
|
+
p5.cancel("\uCD08\uAE30\uD654\uAC00 \uCDE8\uC18C\uB418\uC5C8\uC2B5\uB2C8\uB2E4");
|
|
1309
1958
|
}
|
|
1310
1959
|
}
|
|
1311
1960
|
);
|
|
1312
|
-
|
|
1313
|
-
const webPort = skipInput ? "5173" : await
|
|
1961
|
+
p5.log.step("granite.config.ts \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
|
|
1962
|
+
const webPort = skipInput ? "5173" : await p5.text({
|
|
1314
1963
|
message: "Enter web port",
|
|
1315
1964
|
placeholder: "5173",
|
|
1316
1965
|
defaultValue: "5173"
|
|
1317
1966
|
});
|
|
1318
|
-
if (
|
|
1319
|
-
|
|
1967
|
+
if (p5.isCancel(webPort)) {
|
|
1968
|
+
p5.cancel("\uCD08\uAE30\uD654\uAC00 \uCDE8\uC18C\uB418\uC5C8\uC2B5\uB2C8\uB2E4");
|
|
1320
1969
|
return;
|
|
1321
1970
|
}
|
|
1322
1971
|
const config = transformTemplate(WEB_FRAMEWORK_CONFIG_TEMPLATE, {
|
|
1323
1972
|
appName,
|
|
1324
1973
|
webPort,
|
|
1325
1974
|
webDevCommand: scriptInputs.dev === "granite dev" ? "" : scriptInputs.dev,
|
|
1326
|
-
webBuildCommand: scriptInputs.build === "
|
|
1975
|
+
webBuildCommand: scriptInputs.build === "ait build" ? "" : scriptInputs.build
|
|
1327
1976
|
});
|
|
1328
|
-
await import_fs4.default.promises.writeFile(
|
|
1977
|
+
await import_fs4.default.promises.writeFile(import_path10.default.join(cwd, "granite.config.ts"), config, {
|
|
1329
1978
|
encoding: "utf-8"
|
|
1330
1979
|
});
|
|
1331
1980
|
}
|
|
1332
1981
|
async function templateReactNative({ appName, cwd }) {
|
|
1333
|
-
|
|
1982
|
+
const packageJsonPath = import_path10.default.join(cwd, "package.json");
|
|
1983
|
+
const packageJsonRaw = await import_fs4.default.promises.readFile(packageJsonPath, {
|
|
1984
|
+
encoding: "utf-8"
|
|
1985
|
+
});
|
|
1986
|
+
const packageJson = JSON.parse(packageJsonRaw);
|
|
1987
|
+
packageJson.scripts ||= {};
|
|
1988
|
+
packageJson.scripts.dev = "granite dev";
|
|
1989
|
+
packageJson.scripts.build = "ait build";
|
|
1990
|
+
packageJson.scripts.deploy = "ait deploy";
|
|
1991
|
+
await import_fs4.default.promises.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), {
|
|
1992
|
+
encoding: "utf-8"
|
|
1993
|
+
});
|
|
1994
|
+
p5.log.step("granite.config.ts \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
|
|
1334
1995
|
const config = transformTemplate(REACT_NATIVE_FRAMEWORK_CONFIG_TEMPLATE, {
|
|
1335
1996
|
appName
|
|
1336
1997
|
});
|
|
1337
|
-
await import_fs4.default.promises.writeFile(
|
|
1998
|
+
await import_fs4.default.promises.writeFile(import_path10.default.join(cwd, "granite.config.ts"), config, {
|
|
1338
1999
|
encoding: "utf-8"
|
|
1339
2000
|
});
|
|
1340
|
-
|
|
1341
|
-
await import_fs4.default.promises.writeFile(
|
|
2001
|
+
p5.log.step("src/_app.tsx \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
|
|
2002
|
+
await import_fs4.default.promises.writeFile(import_path10.default.join(cwd, "src", "_app.tsx"), APP_TEMPLATE, {
|
|
1342
2003
|
encoding: "utf-8"
|
|
1343
2004
|
});
|
|
1344
2005
|
}
|
|
1345
|
-
var InitCommand = class extends
|
|
2006
|
+
var InitCommand = class extends import_clipanion3.Command {
|
|
1346
2007
|
static paths = [[`init`]];
|
|
1347
|
-
template =
|
|
1348
|
-
appName =
|
|
1349
|
-
skipInput =
|
|
2008
|
+
template = import_clipanion3.Option.String("--template", { required: false });
|
|
2009
|
+
appName = import_clipanion3.Option.String("--app-name", { required: false });
|
|
2010
|
+
skipInput = import_clipanion3.Option.Boolean("--skip-input", { required: false, hidden: true });
|
|
1350
2011
|
async execute() {
|
|
1351
2012
|
const template = await ensureSelect({
|
|
1352
2013
|
value: this.template,
|
|
1353
|
-
prompt: async () =>
|
|
2014
|
+
prompt: async () => p5.select({
|
|
1354
2015
|
message: "\uD504\uB85C\uC81D\uD2B8\uB97C \uCD08\uAE30\uD654\uD560 \uD15C\uD50C\uB9BF\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694.",
|
|
1355
2016
|
options: [
|
|
1356
2017
|
{
|
|
@@ -1366,14 +2027,14 @@ var InitCommand = class extends import_clipanion2.Command {
|
|
|
1366
2027
|
]
|
|
1367
2028
|
})
|
|
1368
2029
|
});
|
|
1369
|
-
if (
|
|
2030
|
+
if (p5.isCancel(template)) {
|
|
1370
2031
|
process.exit(0);
|
|
1371
2032
|
}
|
|
1372
|
-
const cwd = (0,
|
|
1373
|
-
|
|
2033
|
+
const cwd = (0, import_utils6.getPackageRoot)();
|
|
2034
|
+
p5.intro("\u{1F680} \uC571 \uCD08\uAE30\uD654\uB97C \uC2DC\uC791\uD569\uB2C8\uB2E4");
|
|
1374
2035
|
const appName = await ensureSelect({
|
|
1375
2036
|
value: this.appName,
|
|
1376
|
-
prompt: async () =>
|
|
2037
|
+
prompt: async () => p5.text({
|
|
1377
2038
|
message: "Enter app name",
|
|
1378
2039
|
validate: (value) => {
|
|
1379
2040
|
if (!value) {
|
|
@@ -1387,11 +2048,11 @@ var InitCommand = class extends import_clipanion2.Command {
|
|
|
1387
2048
|
}
|
|
1388
2049
|
})
|
|
1389
2050
|
});
|
|
1390
|
-
if (
|
|
1391
|
-
|
|
2051
|
+
if (p5.isCancel(appName)) {
|
|
2052
|
+
p5.cancel("\uCD08\uAE30\uD654\uAC00 \uCDE8\uC18C\uB418\uC5C8\uC2B5\uB2C8\uB2E4");
|
|
1392
2053
|
return;
|
|
1393
2054
|
}
|
|
1394
|
-
|
|
2055
|
+
p5.log.step(`\uC571 \uC774\uB984\uC774 '${appName}'\uC73C\uB85C \uC124\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4`);
|
|
1395
2056
|
switch (template) {
|
|
1396
2057
|
case "web-framework": {
|
|
1397
2058
|
await templateWebFramework({
|
|
@@ -1409,7 +2070,7 @@ var InitCommand = class extends import_clipanion2.Command {
|
|
|
1409
2070
|
break;
|
|
1410
2071
|
}
|
|
1411
2072
|
}
|
|
1412
|
-
|
|
2073
|
+
p5.outro("\u2728 \uCD08\uAE30\uD654\uAC00 \uC644\uB8CC\uB418\uC5C8\uC2B5\uB2C8\uB2E4!");
|
|
1413
2074
|
}
|
|
1414
2075
|
};
|
|
1415
2076
|
|
|
@@ -1418,7 +2079,7 @@ init_cjs_shims();
|
|
|
1418
2079
|
|
|
1419
2080
|
// src/MigrateCommand/MigrateCommand.ts
|
|
1420
2081
|
init_cjs_shims();
|
|
1421
|
-
var
|
|
2082
|
+
var import_clipanion4 = require("clipanion");
|
|
1422
2083
|
|
|
1423
2084
|
// src/MigrateCommand/logger/index.ts
|
|
1424
2085
|
init_cjs_shims();
|
|
@@ -1489,27 +2150,27 @@ async function renameFile(oldPath, newPath) {
|
|
|
1489
2150
|
|
|
1490
2151
|
// src/MigrateCommand/presets/granite/configProcessor.ts
|
|
1491
2152
|
var configTransformer = (root, { j }) => {
|
|
1492
|
-
root.find(j.ImportDeclaration).forEach((
|
|
1493
|
-
const source =
|
|
2153
|
+
root.find(j.ImportDeclaration).forEach((path13) => {
|
|
2154
|
+
const source = path13.value.source;
|
|
1494
2155
|
if (j.StringLiteral.check(source) && source.value === "react-native-bedrock/config") {
|
|
1495
|
-
const defineConfigName =
|
|
2156
|
+
const defineConfigName = path13.value.specifiers?.find(
|
|
1496
2157
|
(specifier) => j.ImportSpecifier.check(specifier) && specifier.imported.name === "defineConfig"
|
|
1497
2158
|
)?.local?.name;
|
|
1498
2159
|
if (!defineConfigName) {
|
|
1499
2160
|
return;
|
|
1500
2161
|
}
|
|
1501
|
-
root.find(j.CallExpression).forEach((
|
|
1502
|
-
const callee =
|
|
1503
|
-
if (j.Identifier.check(callee) && callee.name === defineConfigName &&
|
|
1504
|
-
const obj =
|
|
2162
|
+
root.find(j.CallExpression).forEach((path14) => {
|
|
2163
|
+
const callee = path14.value.callee;
|
|
2164
|
+
if (j.Identifier.check(callee) && callee.name === defineConfigName && path14.value.arguments.length > 0 && j.ObjectExpression.check(path14.value.arguments[0])) {
|
|
2165
|
+
const obj = path14.value.arguments[0];
|
|
1505
2166
|
const hasScheme = obj.properties.some(
|
|
1506
2167
|
(prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "scheme"
|
|
1507
2168
|
);
|
|
1508
2169
|
if (!hasScheme) {
|
|
1509
2170
|
obj.properties.unshift(j.objectProperty(j.identifier("scheme"), j.stringLiteral("intoss")));
|
|
1510
2171
|
}
|
|
1511
|
-
const routerImport = root.find(j.ImportDeclaration).filter((
|
|
1512
|
-
const source2 =
|
|
2172
|
+
const routerImport = root.find(j.ImportDeclaration).filter((path15) => {
|
|
2173
|
+
const source2 = path15.value.source;
|
|
1513
2174
|
return j.StringLiteral.check(source2) && source2.value === "@granite-js/plugin-router";
|
|
1514
2175
|
});
|
|
1515
2176
|
if (routerImport.length === 0) {
|
|
@@ -1658,12 +2319,12 @@ var identifierReplacementsTransformer = (root, { j }) => {
|
|
|
1658
2319
|
}
|
|
1659
2320
|
});
|
|
1660
2321
|
});
|
|
1661
|
-
root.find(j.Identifier).forEach((
|
|
1662
|
-
const name =
|
|
2322
|
+
root.find(j.Identifier).forEach((path13) => {
|
|
2323
|
+
const name = path13.value.name;
|
|
1663
2324
|
if (importedVariables.has(name)) {
|
|
1664
|
-
const newName = toGraniteName(
|
|
2325
|
+
const newName = toGraniteName(path13.value.name);
|
|
1665
2326
|
if (newName) {
|
|
1666
|
-
|
|
2327
|
+
path13.value.name = newName;
|
|
1667
2328
|
}
|
|
1668
2329
|
}
|
|
1669
2330
|
});
|
|
@@ -1672,11 +2333,11 @@ var identifierReplacementsTransformer = (root, { j }) => {
|
|
|
1672
2333
|
|
|
1673
2334
|
// src/MigrateCommand/presets/granite/isBedrockProject.ts
|
|
1674
2335
|
init_cjs_shims();
|
|
1675
|
-
var
|
|
2336
|
+
var fs11 = __toESM(require("fs"), 1);
|
|
1676
2337
|
var BASE_NAME = "bedrock.config";
|
|
1677
2338
|
var EXTENSIONS = ["ts", "mts", "js", "cjs"];
|
|
1678
2339
|
async function isBedrockProject(cwd) {
|
|
1679
|
-
const files =
|
|
2340
|
+
const files = fs11.readdirSync(cwd);
|
|
1680
2341
|
return files.some(isBedrockConfigFile);
|
|
1681
2342
|
}
|
|
1682
2343
|
function isBedrockConfigFile(file) {
|
|
@@ -1716,8 +2377,8 @@ var packageImportsTransformer = (root, { j }, { fileName = "<unknown>" }) => {
|
|
|
1716
2377
|
}
|
|
1717
2378
|
return value;
|
|
1718
2379
|
}
|
|
1719
|
-
root.find(j.ImportDeclaration).forEach((
|
|
1720
|
-
const source =
|
|
2380
|
+
root.find(j.ImportDeclaration).forEach((path13) => {
|
|
2381
|
+
const source = path13.value.source;
|
|
1721
2382
|
if (j.StringLiteral.check(source)) {
|
|
1722
2383
|
const transformed = transformPackageName(source.value);
|
|
1723
2384
|
if (transformed !== source.value) {
|
|
@@ -1727,8 +2388,8 @@ var packageImportsTransformer = (root, { j }, { fileName = "<unknown>" }) => {
|
|
|
1727
2388
|
});
|
|
1728
2389
|
root.find(j.CallExpression, {
|
|
1729
2390
|
callee: { name: "require" }
|
|
1730
|
-
}).forEach((
|
|
1731
|
-
const args =
|
|
2391
|
+
}).forEach((path13) => {
|
|
2392
|
+
const args = path13.value.arguments;
|
|
1732
2393
|
if (args.length > 0 && j.StringLiteral.check(args[0])) {
|
|
1733
2394
|
const transformed = transformPackageName(args[0].value);
|
|
1734
2395
|
if (transformed !== args[0].value) {
|
|
@@ -1736,8 +2397,8 @@ var packageImportsTransformer = (root, { j }, { fileName = "<unknown>" }) => {
|
|
|
1736
2397
|
}
|
|
1737
2398
|
}
|
|
1738
2399
|
});
|
|
1739
|
-
root.find(j.ImportExpression).forEach((
|
|
1740
|
-
const source =
|
|
2400
|
+
root.find(j.ImportExpression).forEach((path13) => {
|
|
2401
|
+
const source = path13.value.source;
|
|
1741
2402
|
if (j.StringLiteral.check(source)) {
|
|
1742
2403
|
const transformed = transformPackageName(source.value);
|
|
1743
2404
|
if (transformed !== source.value) {
|
|
@@ -1798,9 +2459,19 @@ var processPackageJson = async (cwd, config) => {
|
|
|
1798
2459
|
if (packageJson.scripts) {
|
|
1799
2460
|
const scripts = packageJson.scripts;
|
|
1800
2461
|
for (const [key, value] of Object.entries(scripts)) {
|
|
1801
|
-
if (typeof value
|
|
1802
|
-
|
|
1803
|
-
|
|
2462
|
+
if (typeof value !== "string") {
|
|
2463
|
+
continue;
|
|
2464
|
+
}
|
|
2465
|
+
let nextValue = value;
|
|
2466
|
+
if (nextValue.includes("bedrock")) {
|
|
2467
|
+
nextValue = nextValue.replace(/\bbedrock\b/g, "granite");
|
|
2468
|
+
}
|
|
2469
|
+
if (nextValue.includes("granite build")) {
|
|
2470
|
+
nextValue = nextValue.replace(/granite build/g, "ait build");
|
|
2471
|
+
}
|
|
2472
|
+
if (nextValue !== value) {
|
|
2473
|
+
scripts[key] = nextValue;
|
|
2474
|
+
modified = true;
|
|
1804
2475
|
}
|
|
1805
2476
|
}
|
|
1806
2477
|
}
|
|
@@ -1835,14 +2506,14 @@ var APPS_IN_TOSS_FRAMEWORK_EXPORTS = [
|
|
|
1835
2506
|
];
|
|
1836
2507
|
var toAppsInTossFrameworkImport = (root, { j }, { fileName = "<unknown>" }) => {
|
|
1837
2508
|
const appsInTossFrameworkMembers = [];
|
|
1838
|
-
root.find(j.ImportDeclaration).forEach((
|
|
1839
|
-
const source =
|
|
2509
|
+
root.find(j.ImportDeclaration).forEach((path13) => {
|
|
2510
|
+
const source = path13.node.source.value;
|
|
1840
2511
|
if (typeof source !== "string") {
|
|
1841
2512
|
return;
|
|
1842
2513
|
}
|
|
1843
2514
|
if (source === "@granite-js/react-native") {
|
|
1844
|
-
if (Array.isArray(
|
|
1845
|
-
|
|
2515
|
+
if (Array.isArray(path13.node.specifiers)) {
|
|
2516
|
+
path13.node.specifiers = path13.node.specifiers.filter((specifier) => {
|
|
1846
2517
|
if (shouldImportFromAppsInTossFramework(fileName, specifier)) {
|
|
1847
2518
|
appsInTossFrameworkMembers.push(specifier);
|
|
1848
2519
|
return false;
|
|
@@ -1850,8 +2521,8 @@ var toAppsInTossFrameworkImport = (root, { j }, { fileName = "<unknown>" }) => {
|
|
|
1850
2521
|
return true;
|
|
1851
2522
|
});
|
|
1852
2523
|
}
|
|
1853
|
-
if (
|
|
1854
|
-
j(
|
|
2524
|
+
if (path13.node.specifiers?.length === 0) {
|
|
2525
|
+
j(path13).remove();
|
|
1855
2526
|
}
|
|
1856
2527
|
}
|
|
1857
2528
|
});
|
|
@@ -1873,33 +2544,6 @@ function shouldImportFromAppsInTossFramework(fileName, specifier) {
|
|
|
1873
2544
|
}
|
|
1874
2545
|
}
|
|
1875
2546
|
|
|
1876
|
-
// src/MigrateCommand/codemod/index.ts
|
|
1877
|
-
init_cjs_shims();
|
|
1878
|
-
|
|
1879
|
-
// src/MigrateCommand/codemod/transform.ts
|
|
1880
|
-
init_cjs_shims();
|
|
1881
|
-
var import_jscodeshift = __toESM(require("jscodeshift"), 1);
|
|
1882
|
-
function transform(source, { transformers: transformers2, options = {} }) {
|
|
1883
|
-
const j = import_jscodeshift.default.withParser("tsx");
|
|
1884
|
-
const report = [];
|
|
1885
|
-
const stats = /* @__PURE__ */ new Map();
|
|
1886
|
-
const context = {
|
|
1887
|
-
j,
|
|
1888
|
-
jscodeshift: j,
|
|
1889
|
-
stats: (name, quantity = 1) => {
|
|
1890
|
-
if (quantity === 0) {
|
|
1891
|
-
return;
|
|
1892
|
-
}
|
|
1893
|
-
stats.set(name, (stats.get(name) ?? 0) + quantity);
|
|
1894
|
-
},
|
|
1895
|
-
report: (message) => {
|
|
1896
|
-
report.push(message);
|
|
1897
|
-
}
|
|
1898
|
-
};
|
|
1899
|
-
const root = transformers2.reduce((root2, transformer) => transformer(root2, context, options), j(source));
|
|
1900
|
-
return root.toSource();
|
|
1901
|
-
}
|
|
1902
|
-
|
|
1903
2547
|
// src/MigrateCommand/fs/fileScanner.ts
|
|
1904
2548
|
init_cjs_shims();
|
|
1905
2549
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
@@ -1964,26 +2608,239 @@ var migrateGranite = async (cwd, config) => {
|
|
|
1964
2608
|
`);
|
|
1965
2609
|
};
|
|
1966
2610
|
|
|
2611
|
+
// src/MigrateCommand/presets/react-native-0-84-0/index.ts
|
|
2612
|
+
init_cjs_shims();
|
|
2613
|
+
|
|
2614
|
+
// src/MigrateCommand/presets/react-native-0-84-0/migrateReactNative0840.ts
|
|
2615
|
+
init_cjs_shims();
|
|
2616
|
+
var import_dedent2 = __toESM(require("dedent"), 1);
|
|
2617
|
+
var TARGET_DEPENDENCY_VERSIONS = {
|
|
2618
|
+
react: "19.2.3",
|
|
2619
|
+
"react-dom": "19.2.3",
|
|
2620
|
+
"react-native": "0.84.0",
|
|
2621
|
+
"@types/react": "19.2.3",
|
|
2622
|
+
"@types/react-dom": "19.2.3",
|
|
2623
|
+
"react-test-renderer": "19.2.3",
|
|
2624
|
+
"babel-preset-granite": "1.0.3",
|
|
2625
|
+
"@babel/plugin-transform-flow-strip-types": "7.27.1",
|
|
2626
|
+
"@granite-js/react-native": "1.0.4",
|
|
2627
|
+
"@granite-js/native": "1.0.4",
|
|
2628
|
+
"@granite-js/plugin-core": "1.0.4",
|
|
2629
|
+
"@granite-js/plugin-env": "1.0.4",
|
|
2630
|
+
"@granite-js/plugin-hermes": "1.0.4",
|
|
2631
|
+
"@granite-js/plugin-router": "1.0.4",
|
|
2632
|
+
"@granite-js/plugin-micro-frontend": "1.0.4",
|
|
2633
|
+
"@granite-js/plugin-sentry": "1.0.4",
|
|
2634
|
+
"@toss/tds-react-native": "2.0.2",
|
|
2635
|
+
"brick-module": "0.5.0"
|
|
2636
|
+
};
|
|
2637
|
+
var BABEL_CONFIG_TEMPLATE = `module.exports = {
|
|
2638
|
+
presets: ['babel-preset-granite'],
|
|
2639
|
+
};
|
|
2640
|
+
`;
|
|
2641
|
+
var REQUIRED_DEPENDENCIES_BY_FIELD = {
|
|
2642
|
+
dependencies: {
|
|
2643
|
+
"brick-module": TARGET_DEPENDENCY_VERSIONS["brick-module"]
|
|
2644
|
+
},
|
|
2645
|
+
devDependencies: {
|
|
2646
|
+
"babel-preset-granite": TARGET_DEPENDENCY_VERSIONS["babel-preset-granite"]
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
var DEPENDENCY_FIELDS = ["dependencies", "devDependencies", "peerDependencies"];
|
|
2650
|
+
function processDependencyMap(deps, frameworkVersion) {
|
|
2651
|
+
let modified = false;
|
|
2652
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
2653
|
+
if (name.startsWith("@apps-in-toss/")) {
|
|
2654
|
+
if (name === "@apps-in-toss/framework" || frameworkVersion == null) {
|
|
2655
|
+
continue;
|
|
2656
|
+
}
|
|
2657
|
+
if (version !== frameworkVersion) {
|
|
2658
|
+
deps[name] = frameworkVersion;
|
|
2659
|
+
modified = true;
|
|
2660
|
+
}
|
|
2661
|
+
continue;
|
|
2662
|
+
}
|
|
2663
|
+
const targetVersion = TARGET_DEPENDENCY_VERSIONS[name];
|
|
2664
|
+
if (targetVersion == null || version === targetVersion) {
|
|
2665
|
+
continue;
|
|
2666
|
+
}
|
|
2667
|
+
if (version !== targetVersion) {
|
|
2668
|
+
deps[name] = targetVersion;
|
|
2669
|
+
modified = true;
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
return modified;
|
|
2673
|
+
}
|
|
2674
|
+
function findDependencyVersion(packageJson, dependencyName) {
|
|
2675
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
2676
|
+
const deps = packageJson[field];
|
|
2677
|
+
if (deps?.[dependencyName] != null) {
|
|
2678
|
+
return deps[dependencyName];
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
return void 0;
|
|
2682
|
+
}
|
|
2683
|
+
function hasReactNativeDependency(packageJson) {
|
|
2684
|
+
return findDependencyVersion(packageJson, "react-native") != null;
|
|
2685
|
+
}
|
|
2686
|
+
function processScriptMap(scripts) {
|
|
2687
|
+
let modified = false;
|
|
2688
|
+
for (const [scriptName, scriptValue] of Object.entries(scripts)) {
|
|
2689
|
+
if (!scriptValue.includes("granite build")) {
|
|
2690
|
+
continue;
|
|
2691
|
+
}
|
|
2692
|
+
const nextScriptValue = scriptValue.replace(/granite build/g, "ait build");
|
|
2693
|
+
if (nextScriptValue !== scriptValue) {
|
|
2694
|
+
scripts[scriptName] = nextScriptValue;
|
|
2695
|
+
modified = true;
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
return modified;
|
|
2699
|
+
}
|
|
2700
|
+
function ensureRequiredDependencies(packageJson) {
|
|
2701
|
+
let modified = false;
|
|
2702
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
2703
|
+
const requiredDependencies = REQUIRED_DEPENDENCIES_BY_FIELD[field];
|
|
2704
|
+
if (requiredDependencies == null) {
|
|
2705
|
+
continue;
|
|
2706
|
+
}
|
|
2707
|
+
packageJson[field] ??= {};
|
|
2708
|
+
const deps = packageJson[field];
|
|
2709
|
+
if (deps == null) {
|
|
2710
|
+
continue;
|
|
2711
|
+
}
|
|
2712
|
+
for (const [dependencyName, requiredVersion] of Object.entries(requiredDependencies)) {
|
|
2713
|
+
if (deps[dependencyName] === requiredVersion) {
|
|
2714
|
+
continue;
|
|
2715
|
+
}
|
|
2716
|
+
deps[dependencyName] = requiredVersion;
|
|
2717
|
+
modified = true;
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
return modified;
|
|
2721
|
+
}
|
|
2722
|
+
async function processPackageJson2(cwd, config) {
|
|
2723
|
+
logger.log("Processing package.json...");
|
|
2724
|
+
const packageJsonPath = `${cwd}/package.json`;
|
|
2725
|
+
if (!await fileExists(packageJsonPath)) {
|
|
2726
|
+
logger.log("No package.json found");
|
|
2727
|
+
return false;
|
|
2728
|
+
}
|
|
2729
|
+
try {
|
|
2730
|
+
const content = await readFile(packageJsonPath);
|
|
2731
|
+
const packageJson = JSON.parse(content);
|
|
2732
|
+
if (!hasReactNativeDependency(packageJson)) {
|
|
2733
|
+
logger.log("Skipping migration: react-native dependency not found in package.json");
|
|
2734
|
+
return false;
|
|
2735
|
+
}
|
|
2736
|
+
const appsInTossFrameworkVersion = findDependencyVersion(packageJson, "@apps-in-toss/framework");
|
|
2737
|
+
let modified = false;
|
|
2738
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
2739
|
+
if (packageJson[field] == null) {
|
|
2740
|
+
continue;
|
|
2741
|
+
}
|
|
2742
|
+
modified = processDependencyMap(packageJson[field], appsInTossFrameworkVersion) || modified;
|
|
2743
|
+
}
|
|
2744
|
+
modified = ensureRequiredDependencies(packageJson) || modified;
|
|
2745
|
+
if (packageJson.scripts != null) {
|
|
2746
|
+
modified = processScriptMap(packageJson.scripts) || modified;
|
|
2747
|
+
}
|
|
2748
|
+
if (!modified) {
|
|
2749
|
+
logger.log("No changes needed in package.json");
|
|
2750
|
+
return true;
|
|
2751
|
+
}
|
|
2752
|
+
if (config.dryRun === true) {
|
|
2753
|
+
logger.log("Skipping package.json write in dry run mode");
|
|
2754
|
+
return true;
|
|
2755
|
+
}
|
|
2756
|
+
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
|
|
2757
|
+
logger.success("Updated package.json");
|
|
2758
|
+
return true;
|
|
2759
|
+
} catch (error) {
|
|
2760
|
+
logger.error(`Failed to process package.json: ${error}`);
|
|
2761
|
+
return false;
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
function isTargetBabelConfig(content) {
|
|
2765
|
+
return content.trim() === BABEL_CONFIG_TEMPLATE.trim();
|
|
2766
|
+
}
|
|
2767
|
+
async function processBabelConfig(cwd, config) {
|
|
2768
|
+
logger.log("Processing babel.config.js...");
|
|
2769
|
+
const babelConfigPath = `${cwd}/babel.config.js`;
|
|
2770
|
+
if (!await fileExists(babelConfigPath)) {
|
|
2771
|
+
logger.log("No babel.config.js found");
|
|
2772
|
+
return;
|
|
2773
|
+
}
|
|
2774
|
+
try {
|
|
2775
|
+
const content = await readFile(babelConfigPath);
|
|
2776
|
+
if (isTargetBabelConfig(content)) {
|
|
2777
|
+
logger.log("No changes needed in babel.config.js");
|
|
2778
|
+
return;
|
|
2779
|
+
}
|
|
2780
|
+
if (config.dryRun === true) {
|
|
2781
|
+
logger.log("Skipping babel.config.js write in dry run mode");
|
|
2782
|
+
return;
|
|
2783
|
+
}
|
|
2784
|
+
await writeFile(babelConfigPath, BABEL_CONFIG_TEMPLATE);
|
|
2785
|
+
logger.success("Updated babel.config.js");
|
|
2786
|
+
} catch (error) {
|
|
2787
|
+
logger.error(`Failed to process babel.config.js: ${error}`);
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
var migrateReactNative0840 = async (cwd, config) => {
|
|
2791
|
+
const isReactNativeProject = await processPackageJson2(cwd, config);
|
|
2792
|
+
if (!isReactNativeProject) {
|
|
2793
|
+
logger.log("Skipping remaining migration steps");
|
|
2794
|
+
return;
|
|
2795
|
+
}
|
|
2796
|
+
await processBabelConfig(cwd, config);
|
|
2797
|
+
logger.log(import_dedent2.default`
|
|
2798
|
+
Please check the following steps:
|
|
2799
|
+
|
|
2800
|
+
- Install dependencies
|
|
2801
|
+
- Run type checks
|
|
2802
|
+
- Run lint checks
|
|
2803
|
+
- Run tests
|
|
2804
|
+
- Review migration warnings manually (if any)\n
|
|
2805
|
+
`);
|
|
2806
|
+
};
|
|
2807
|
+
|
|
1967
2808
|
// src/MigrateCommand/presets/index.ts
|
|
1968
2809
|
var MIGRATE_PRESETS = {
|
|
1969
|
-
granite: migrateGranite
|
|
2810
|
+
granite: migrateGranite,
|
|
2811
|
+
"react-native-0-84-0": migrateReactNative0840
|
|
1970
2812
|
};
|
|
1971
2813
|
|
|
1972
2814
|
// src/MigrateCommand/MigrateCommand.ts
|
|
1973
|
-
|
|
2815
|
+
function getAvailablePresetTargets() {
|
|
2816
|
+
return Object.keys(MIGRATE_PRESETS).sort();
|
|
2817
|
+
}
|
|
2818
|
+
function logAvailablePresets(level = "log") {
|
|
2819
|
+
const output = level === "error" ? logger.error.bind(logger) : logger.log.bind(logger);
|
|
2820
|
+
output("Available migration presets:");
|
|
2821
|
+
for (const target of getAvailablePresetTargets()) {
|
|
2822
|
+
output(`- ${target}`);
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
var MigrateCommand = class extends import_clipanion4.Command {
|
|
1974
2826
|
static paths = [[`migrate`]];
|
|
1975
|
-
static usage =
|
|
2827
|
+
static usage = import_clipanion4.Command.Usage({
|
|
1976
2828
|
category: "Migration",
|
|
1977
2829
|
description: "Run migration",
|
|
1978
2830
|
examples: [
|
|
1979
2831
|
["Run migration", "ait migrate <target>"],
|
|
1980
|
-
["Check migration availability", "ait migrate
|
|
2832
|
+
["Check migration availability", "ait migrate"],
|
|
2833
|
+
["Dry run migration", "ait migrate <target> --dry-run"]
|
|
1981
2834
|
]
|
|
1982
2835
|
});
|
|
1983
|
-
target =
|
|
1984
|
-
dryRun =
|
|
2836
|
+
target = import_clipanion4.Option.String({ required: false });
|
|
2837
|
+
dryRun = import_clipanion4.Option.Boolean("--dry-run", { required: false });
|
|
1985
2838
|
async execute() {
|
|
1986
2839
|
try {
|
|
2840
|
+
if (this.target == null) {
|
|
2841
|
+
logAvailablePresets();
|
|
2842
|
+
return 0;
|
|
2843
|
+
}
|
|
1987
2844
|
const cwd = process.cwd();
|
|
1988
2845
|
const config = {
|
|
1989
2846
|
dryRun: this.dryRun
|
|
@@ -1992,7 +2849,9 @@ var MigrateCommand = class extends import_clipanion3.Command {
|
|
|
1992
2849
|
logger.log(`Working directory: ${cwd}`);
|
|
1993
2850
|
const migrate = MIGRATE_PRESETS[this.target];
|
|
1994
2851
|
if (migrate == null) {
|
|
1995
|
-
|
|
2852
|
+
logger.error(`Unknown target: ${this.target}`);
|
|
2853
|
+
logAvailablePresets("error");
|
|
2854
|
+
return 1;
|
|
1996
2855
|
}
|
|
1997
2856
|
await migrate(cwd, config);
|
|
1998
2857
|
logger.success("Migration completed successfully!");
|
|
@@ -2006,13 +2865,13 @@ var MigrateCommand = class extends import_clipanion3.Command {
|
|
|
2006
2865
|
|
|
2007
2866
|
// src/TokenCommand.ts
|
|
2008
2867
|
init_cjs_shims();
|
|
2009
|
-
var
|
|
2010
|
-
var
|
|
2868
|
+
var p6 = __toESM(require("@clack/prompts"), 1);
|
|
2869
|
+
var import_clipanion5 = require("clipanion");
|
|
2011
2870
|
var import_debug3 = __toESM(require_src(), 1);
|
|
2012
2871
|
var debug3 = (0, import_debug3.default)("cli:token");
|
|
2013
|
-
var TokenCommand = class extends
|
|
2872
|
+
var TokenCommand = class extends import_clipanion5.Command {
|
|
2014
2873
|
static paths = [["token"]];
|
|
2015
|
-
static usage =
|
|
2874
|
+
static usage = import_clipanion5.Command.Usage({
|
|
2016
2875
|
description: "\uD1A0\uD070 \uAD00\uB828 \uD558\uC704 \uBA85\uB839\uC744 \uAD00\uB9AC\uD569\uB2C8\uB2E4.",
|
|
2017
2876
|
examples: [
|
|
2018
2877
|
["\uD1A0\uD070 \uCD94\uAC00", "ait token add <profile?>"],
|
|
@@ -2023,20 +2882,20 @@ var TokenCommand = class extends import_clipanion4.Command {
|
|
|
2023
2882
|
debug3("execute");
|
|
2024
2883
|
}
|
|
2025
2884
|
};
|
|
2026
|
-
var TokenAddCommand = class extends
|
|
2885
|
+
var TokenAddCommand = class extends import_clipanion5.Command {
|
|
2027
2886
|
static paths = [["token", "add"]];
|
|
2028
|
-
static usage =
|
|
2887
|
+
static usage = import_clipanion5.Command.Usage({
|
|
2029
2888
|
description: "\uC2DC\uD06C\uB9BF \uD1A0\uD070\uC744 \uCD94\uAC00\uD569\uB2C8\uB2E4.",
|
|
2030
2889
|
examples: [
|
|
2031
2890
|
["\uAE30\uBCF8 \uBCC4\uCE6D\uC73C\uB85C \uD1A0\uD070 \uCD94\uAC00", "ait token add"],
|
|
2032
2891
|
["\uBCC4\uCE6D\uC744 \uC9C0\uC815\uD558\uC5EC \uD1A0\uD070 \uCD94\uAC00", "ait token add dev"]
|
|
2033
2892
|
]
|
|
2034
2893
|
});
|
|
2035
|
-
profile =
|
|
2036
|
-
apiKey =
|
|
2894
|
+
profile = import_clipanion5.Option.String({ required: false });
|
|
2895
|
+
apiKey = import_clipanion5.Option.String("--api-key", { required: false });
|
|
2037
2896
|
async execute() {
|
|
2038
2897
|
const profile = this.profile || "default";
|
|
2039
|
-
const secret = this.apiKey ? this.apiKey : await
|
|
2898
|
+
const secret = this.apiKey ? this.apiKey : await p6.password({
|
|
2040
2899
|
message: "Enter secret token:",
|
|
2041
2900
|
validate: (value) => {
|
|
2042
2901
|
if (value.length === 0) {
|
|
@@ -2045,7 +2904,7 @@ var TokenAddCommand = class extends import_clipanion4.Command {
|
|
|
2045
2904
|
return;
|
|
2046
2905
|
}
|
|
2047
2906
|
});
|
|
2048
|
-
if (
|
|
2907
|
+
if (p6.isCancel(secret)) {
|
|
2049
2908
|
return;
|
|
2050
2909
|
}
|
|
2051
2910
|
TokenStorage.set(profile, secret);
|
|
@@ -2054,16 +2913,16 @@ var TokenAddCommand = class extends import_clipanion4.Command {
|
|
|
2054
2913
|
`);
|
|
2055
2914
|
}
|
|
2056
2915
|
};
|
|
2057
|
-
var TokenRemoveCommand = class extends
|
|
2916
|
+
var TokenRemoveCommand = class extends import_clipanion5.Command {
|
|
2058
2917
|
static paths = [["token", "remove"]];
|
|
2059
|
-
static usage =
|
|
2918
|
+
static usage = import_clipanion5.Command.Usage({
|
|
2060
2919
|
description: "\uC2DC\uD06C\uB9BF \uD1A0\uD070\uC744 \uC0AD\uC81C\uD569\uB2C8\uB2E4.",
|
|
2061
2920
|
examples: [
|
|
2062
2921
|
["\uAE30\uBCF8 \uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4\uC758 \uD1A0\uD070 \uC0AD\uC81C", "ait token remove"],
|
|
2063
2922
|
["\uBCC4\uCE6D\uC744 \uC9C0\uC815\uD558\uC5EC \uD1A0\uD070 \uC0AD\uC81C", "ait token remove dev"]
|
|
2064
2923
|
]
|
|
2065
2924
|
});
|
|
2066
|
-
profile =
|
|
2925
|
+
profile = import_clipanion5.Option.String({ required: false });
|
|
2067
2926
|
async execute() {
|
|
2068
2927
|
const profile = this.profile || "default";
|
|
2069
2928
|
const removed = TokenStorage.delete(profile);
|
|
@@ -2083,15 +2942,15 @@ init_cjs_shims();
|
|
|
2083
2942
|
|
|
2084
2943
|
// src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
|
|
2085
2944
|
init_cjs_shims();
|
|
2086
|
-
var
|
|
2087
|
-
var
|
|
2088
|
-
var
|
|
2945
|
+
var fs15 = __toESM(require("fs/promises"), 1);
|
|
2946
|
+
var p7 = __toESM(require("@clack/prompts"), 1);
|
|
2947
|
+
var import_clipanion6 = require("clipanion");
|
|
2089
2948
|
|
|
2090
2949
|
// src/integrations/UploadSentrySourcemap/downloadArtifacts.ts
|
|
2091
2950
|
init_cjs_shims();
|
|
2092
|
-
var
|
|
2951
|
+
var fs12 = __toESM(require("fs"), 1);
|
|
2093
2952
|
var os2 = __toESM(require("os"), 1);
|
|
2094
|
-
var
|
|
2953
|
+
var path11 = __toESM(require("path"), 1);
|
|
2095
2954
|
var import_stream = require("stream");
|
|
2096
2955
|
var import_util = require("util");
|
|
2097
2956
|
var import_debug4 = __toESM(require_src(), 1);
|
|
@@ -2120,36 +2979,36 @@ async function downloadArtifacts(options) {
|
|
|
2120
2979
|
}
|
|
2121
2980
|
const tmpDir = await createTempDirectory();
|
|
2122
2981
|
const tmpFile = `${deploymentId}.zip`;
|
|
2123
|
-
const tmpFilePath =
|
|
2124
|
-
const fileStream =
|
|
2982
|
+
const tmpFilePath = path11.join(tmpDir.path, tmpFile);
|
|
2983
|
+
const fileStream = fs12.createWriteStream(tmpFilePath);
|
|
2125
2984
|
await streamPipeline(response.body, fileStream);
|
|
2126
2985
|
debug4("Artifacts downloaded", { tmpFilePath });
|
|
2127
2986
|
return tmpFilePath;
|
|
2128
2987
|
}
|
|
2129
2988
|
function createTempDirectory() {
|
|
2130
|
-
const tempDir =
|
|
2131
|
-
|
|
2989
|
+
const tempDir = path11.join(os2.tmpdir(), "apps-in-toss", "sentry-integration");
|
|
2990
|
+
fs12.mkdirSync(tempDir, { recursive: true });
|
|
2132
2991
|
debug4("Temp directory created", { tempDir });
|
|
2133
2992
|
return {
|
|
2134
2993
|
path: tempDir,
|
|
2135
2994
|
cleanup: () => {
|
|
2136
|
-
|
|
2995
|
+
fs12.rmSync(tempDir, { recursive: true, force: true });
|
|
2137
2996
|
}
|
|
2138
2997
|
};
|
|
2139
2998
|
}
|
|
2140
2999
|
|
|
2141
3000
|
// src/integrations/UploadSentrySourcemap/extractSentryDebugId.ts
|
|
2142
3001
|
init_cjs_shims();
|
|
2143
|
-
var
|
|
3002
|
+
var import_promises7 = __toESM(require("fs/promises"), 1);
|
|
2144
3003
|
async function extractSentryDebugId(bundlePath) {
|
|
2145
|
-
const bundleContent = await
|
|
3004
|
+
const bundleContent = await import_promises7.default.readFile(bundlePath, "utf-8");
|
|
2146
3005
|
return bundleContent.match(/SENTRY_DEBUG_ID=([\w-]+)/)?.[1];
|
|
2147
3006
|
}
|
|
2148
3007
|
|
|
2149
3008
|
// src/integrations/UploadSentrySourcemap/extractSources.ts
|
|
2150
3009
|
init_cjs_shims();
|
|
2151
|
-
var
|
|
2152
|
-
var
|
|
3010
|
+
var fs14 = __toESM(require("fs"), 1);
|
|
3011
|
+
var path12 = __toESM(require("path"), 1);
|
|
2153
3012
|
var import_stream2 = require("stream");
|
|
2154
3013
|
var import_util2 = require("util");
|
|
2155
3014
|
var zlib = __toESM(require("zlib"), 1);
|
|
@@ -2170,12 +3029,12 @@ async function extractSources(zipPath) {
|
|
|
2170
3029
|
hermesSourceMap: ""
|
|
2171
3030
|
}
|
|
2172
3031
|
};
|
|
2173
|
-
await
|
|
3032
|
+
await fs14.createReadStream(zipPath).pipe(unzipper.Parse()).on("entry", async (entry) => {
|
|
2174
3033
|
const isRoot = !entry.path.includes("/");
|
|
2175
|
-
const fileName =
|
|
2176
|
-
const outputPath =
|
|
3034
|
+
const fileName = path12.basename(entry.path);
|
|
3035
|
+
const outputPath = path12.join(path12.dirname(zipPath), fileName);
|
|
2177
3036
|
if (isRoot) {
|
|
2178
|
-
entry.pipe(
|
|
3037
|
+
entry.pipe(fs14.createWriteStream(outputPath));
|
|
2179
3038
|
const platform = fileName.includes("android") ? "android" : "ios";
|
|
2180
3039
|
if (fileName.endsWith(".js")) {
|
|
2181
3040
|
sources[platform].packagerBundle = outputPath;
|
|
@@ -2203,7 +3062,7 @@ async function extractSources(zipPath) {
|
|
|
2203
3062
|
}
|
|
2204
3063
|
async function decompressGzip(gzFile) {
|
|
2205
3064
|
const outfile = gzFile.replace(/\.gz$/g, "");
|
|
2206
|
-
await pipe(
|
|
3065
|
+
await pipe(fs14.createReadStream(gzFile), zlib.createGunzip(), fs14.createWriteStream(outfile));
|
|
2207
3066
|
return outfile;
|
|
2208
3067
|
}
|
|
2209
3068
|
|
|
@@ -2234,33 +3093,33 @@ function uploadSourcemap(bundlePath, sourcemapPath, options) {
|
|
|
2234
3093
|
}
|
|
2235
3094
|
|
|
2236
3095
|
// src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
|
|
2237
|
-
var UploadSentrySourcemap = class extends
|
|
3096
|
+
var UploadSentrySourcemap = class extends import_clipanion6.Command {
|
|
2238
3097
|
static paths = [["sentry", "upload-sourcemap"]];
|
|
2239
|
-
apiKey =
|
|
3098
|
+
apiKey = import_clipanion6.Option.String("--api-key", {
|
|
2240
3099
|
required: false,
|
|
2241
3100
|
description: "\uC778\uC99D API \uD0A4"
|
|
2242
3101
|
});
|
|
2243
|
-
appName =
|
|
3102
|
+
appName = import_clipanion6.Option.String("--app-name", {
|
|
2244
3103
|
required: false,
|
|
2245
3104
|
description: "\uC571 \uC774\uB984"
|
|
2246
3105
|
});
|
|
2247
|
-
deploymentId =
|
|
3106
|
+
deploymentId = import_clipanion6.Option.String("--deployment-id", {
|
|
2248
3107
|
required: false,
|
|
2249
3108
|
description: "\uBC30\uD3EC ID"
|
|
2250
3109
|
});
|
|
2251
|
-
sentryAuthToken =
|
|
3110
|
+
sentryAuthToken = import_clipanion6.Option.String("--sentry-auth-token", {
|
|
2252
3111
|
required: false,
|
|
2253
3112
|
description: "Sentry \uC778\uC99D\uD0A4"
|
|
2254
3113
|
});
|
|
2255
|
-
sentryOrg =
|
|
3114
|
+
sentryOrg = import_clipanion6.Option.String("--sentry-org", {
|
|
2256
3115
|
required: false,
|
|
2257
3116
|
description: "Sentry \uC870\uC9C1"
|
|
2258
3117
|
});
|
|
2259
|
-
sentryProject =
|
|
3118
|
+
sentryProject = import_clipanion6.Option.String("--sentry-project", {
|
|
2260
3119
|
required: false,
|
|
2261
3120
|
description: "Sentry \uD504\uB85C\uC81D\uD2B8"
|
|
2262
3121
|
});
|
|
2263
|
-
baseUrl =
|
|
3122
|
+
baseUrl = import_clipanion6.Option.String("--base-url", {
|
|
2264
3123
|
description: "API Base URL"
|
|
2265
3124
|
});
|
|
2266
3125
|
async execute() {
|
|
@@ -2274,7 +3133,7 @@ var UploadSentrySourcemap = class extends import_clipanion5.Command {
|
|
|
2274
3133
|
try {
|
|
2275
3134
|
const zipPath = await downloadArtifacts({ apiKey, appName, deploymentId, baseUrl });
|
|
2276
3135
|
const sources = await extractSources(zipPath);
|
|
2277
|
-
await
|
|
3136
|
+
await p7.tasks([
|
|
2278
3137
|
{
|
|
2279
3138
|
title: "Android \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC911...",
|
|
2280
3139
|
task: async () => {
|
|
@@ -2300,10 +3159,10 @@ var UploadSentrySourcemap = class extends import_clipanion5.Command {
|
|
|
2300
3159
|
}
|
|
2301
3160
|
}
|
|
2302
3161
|
]);
|
|
2303
|
-
|
|
3162
|
+
p7.outro("Sentry \uC18C\uC2A4\uB9F5 \uC5C5\uB85C\uB4DC \uC644\uB8CC");
|
|
2304
3163
|
} catch (error) {
|
|
2305
3164
|
if (error instanceof Error) {
|
|
2306
|
-
|
|
3165
|
+
p7.log.error(error.message);
|
|
2307
3166
|
} else {
|
|
2308
3167
|
console.error(error);
|
|
2309
3168
|
}
|
|
@@ -2316,14 +3175,14 @@ var UploadSentrySourcemap = class extends import_clipanion5.Command {
|
|
|
2316
3175
|
throw new Error("Sentry Debug ID\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2317
3176
|
}
|
|
2318
3177
|
const mergedSourceMap = await mergeSourceMaps(
|
|
2319
|
-
await
|
|
2320
|
-
await
|
|
3178
|
+
await fs15.readFile(sources.packagerSourceMap, "utf-8"),
|
|
3179
|
+
await fs15.readFile(sources.hermesSourceMap, "utf-8")
|
|
2321
3180
|
);
|
|
2322
3181
|
const injectedSourceMap = injectSentryDebugId(mergedSourceMap, debugId);
|
|
2323
|
-
await
|
|
3182
|
+
await fs15.writeFile(sources.hermesSourceMap, JSON.stringify(injectedSourceMap, null, 2), "utf-8");
|
|
2324
3183
|
}
|
|
2325
3184
|
async promptRequiredValue(type, message, validateMessage) {
|
|
2326
|
-
const result = await
|
|
3185
|
+
const result = await p7[type]({
|
|
2327
3186
|
message,
|
|
2328
3187
|
validate: (value) => {
|
|
2329
3188
|
if (value.length === 0) {
|
|
@@ -2332,7 +3191,7 @@ var UploadSentrySourcemap = class extends import_clipanion5.Command {
|
|
|
2332
3191
|
return;
|
|
2333
3192
|
}
|
|
2334
3193
|
});
|
|
2335
|
-
if (
|
|
3194
|
+
if (p7.isCancel(result)) {
|
|
2336
3195
|
throw new Error("\uC791\uC5C5\uC774 \uCDE8\uC18C\uB418\uC5C8\uC5B4\uC694.");
|
|
2337
3196
|
}
|
|
2338
3197
|
return result;
|
|
@@ -2340,11 +3199,13 @@ var UploadSentrySourcemap = class extends import_clipanion5.Command {
|
|
|
2340
3199
|
};
|
|
2341
3200
|
|
|
2342
3201
|
// src/index.ts
|
|
3202
|
+
var import_web_config3 = require("@apps-in-toss/web-config");
|
|
2343
3203
|
function initialize() {
|
|
2344
|
-
const cli = new
|
|
3204
|
+
const cli = new import_clipanion7.Cli({
|
|
2345
3205
|
binaryLabel: "ait",
|
|
2346
3206
|
binaryName: "ait"
|
|
2347
3207
|
});
|
|
3208
|
+
cli.register(BuildCommand);
|
|
2348
3209
|
cli.register(DeployCommand);
|
|
2349
3210
|
cli.register(InitCommand);
|
|
2350
3211
|
cli.register(MigrateCommand);
|
|
@@ -2352,10 +3213,14 @@ function initialize() {
|
|
|
2352
3213
|
cli.register(TokenCommand);
|
|
2353
3214
|
cli.register(TokenAddCommand);
|
|
2354
3215
|
cli.register(TokenRemoveCommand);
|
|
2355
|
-
cli.register(
|
|
3216
|
+
cli.register(import_clipanion7.Builtins.HelpCommand);
|
|
2356
3217
|
cli.runExit(process.argv.slice(2));
|
|
2357
3218
|
}
|
|
2358
3219
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2359
3220
|
0 && (module.exports = {
|
|
2360
|
-
|
|
3221
|
+
babelBuild,
|
|
3222
|
+
babelJsonReplacementPlugin,
|
|
3223
|
+
getPackageManager,
|
|
3224
|
+
initialize,
|
|
3225
|
+
loadConfig
|
|
2361
3226
|
});
|