@apps-in-toss/cli 0.0.40 → 1.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.
Files changed (3) hide show
  1. package/dist/index.cjs +633 -40
  2. package/dist/index.js +633 -40
  3. package/package.json +9 -3
package/dist/index.cjs CHANGED
@@ -779,7 +779,7 @@ __export(src_exports, {
779
779
  });
780
780
  module.exports = __toCommonJS(src_exports);
781
781
  init_cjs_shims();
782
- var import_clipanion4 = require("clipanion");
782
+ var import_clipanion5 = require("clipanion");
783
783
 
784
784
  // src/DeployCommand.ts
785
785
  init_cjs_shims();
@@ -787,7 +787,7 @@ var import_assert = __toESM(require("assert"), 1);
787
787
  var import_fs2 = __toESM(require("fs"), 1);
788
788
  var import_path = __toESM(require("path"), 1);
789
789
  var p = __toESM(require("@clack/prompts"), 1);
790
- var import_utils = require("@react-native-bedrock/utils");
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);
@@ -916,7 +916,7 @@ init_cjs_shims();
916
916
  var import_fs3 = __toESM(require("fs"), 1);
917
917
  var import_path2 = __toESM(require("path"), 1);
918
918
  var p2 = __toESM(require("@clack/prompts"), 1);
919
- var import_utils2 = require("@react-native-bedrock/utils");
919
+ var import_utils2 = require("@granite-js/utils");
920
920
  var import_clipanion2 = require("clipanion");
921
921
 
922
922
  // ../../.yarn/cache/es-toolkit-npm-1.32.0-019fc7c155-56ba965570.zip/node_modules/es-toolkit/dist/index.mjs
@@ -961,9 +961,10 @@ export default defineConfig({
961
961
  });
962
962
  `;
963
963
  var REACT_NATIVE_FRAMEWORK_CONFIG_TEMPLATE = `import { appsInToss } from '@apps-in-toss/framework/plugins';
964
- import { defineConfig } from 'react-native-bedrock/config';
964
+ import { defineConfig } from '@granite-js/react-native/config';
965
965
 
966
966
  export default defineConfig({
967
+ scheme: 'intoss',
967
968
  appName: '%%appName%%',
968
969
  plugins: [
969
970
  appsInToss({
@@ -980,7 +981,7 @@ export default defineConfig({
980
981
  `;
981
982
  var APP_TEMPLATE = `import { AppsInToss } from '@apps-in-toss/framework';
982
983
  import { PropsWithChildren } from 'react';
983
- import { InitialProps } from 'react-native-bedrock';
984
+ import { InitialProps } from '@granite-js/react-native';
984
985
  import { context } from '../require.context';
985
986
 
986
987
  function AppContainer({ children }: PropsWithChildren<InitialProps>) {
@@ -1023,17 +1024,17 @@ async function templateWebFramework({ appName, cwd, skipInput }) {
1023
1024
  dev: scripts?.scripts?.dev || scripts?.scripts?.start,
1024
1025
  build: scripts?.scripts?.build
1025
1026
  };
1026
- scripts.scripts.dev = "bedrock dev";
1027
- scripts.scripts.build = "bedrock build";
1027
+ scripts.scripts.dev = "granite dev";
1028
+ scripts.scripts.build = "granite build";
1028
1029
  scripts.scripts.deploy = "ait deploy";
1029
1030
  await import_fs3.default.promises.writeFile(import_path2.default.join(cwd, "package.json"), JSON.stringify(scripts, null, 2), {
1030
1031
  encoding: "utf-8"
1031
1032
  });
1032
1033
  p2.log.step(".gitignore \uD30C\uC77C\uC744 \uC5C5\uB370\uC774\uD2B8\uD558\uB294 \uC911...");
1033
- await import_fs3.default.promises.appendFile(import_path2.default.join(cwd, ".gitignore"), "\n.bedrock\n");
1034
+ await import_fs3.default.promises.appendFile(import_path2.default.join(cwd, ".gitignore"), "\n.granite\n");
1034
1035
  const placeholder = {
1035
- dev: originalScripts.dev === "bedrock dev" ? "" : originalScripts.dev,
1036
- build: originalScripts.build === "bedrock build" ? "" : originalScripts.build
1036
+ dev: originalScripts.dev === "granite dev" ? "" : originalScripts.dev,
1037
+ build: originalScripts.build === "granite build" ? "" : originalScripts.build
1037
1038
  };
1038
1039
  const scriptInputs = skipInput ? placeholder : await p2.group(
1039
1040
  {
@@ -1054,7 +1055,7 @@ async function templateWebFramework({ appName, cwd, skipInput }) {
1054
1055
  }
1055
1056
  }
1056
1057
  );
1057
- p2.log.step("bedrock.config.ts \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
1058
+ p2.log.step("granite.config.ts \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
1058
1059
  const webPort = skipInput ? "5173" : await p2.text({
1059
1060
  message: "Enter web port",
1060
1061
  placeholder: "5173",
@@ -1067,19 +1068,19 @@ async function templateWebFramework({ appName, cwd, skipInput }) {
1067
1068
  const config = transformTemplate(WEB_FRAMEWORK_CONFIG_TEMPLATE, {
1068
1069
  appName,
1069
1070
  webPort,
1070
- webDevCommand: scriptInputs.dev === "bedrock dev" ? "" : scriptInputs.dev,
1071
- webBuildCommand: scriptInputs.build === "bedrock build" ? "" : scriptInputs.build
1071
+ webDevCommand: scriptInputs.dev === "granite dev" ? "" : scriptInputs.dev,
1072
+ webBuildCommand: scriptInputs.build === "granite build" ? "" : scriptInputs.build
1072
1073
  });
1073
- await import_fs3.default.promises.writeFile(import_path2.default.join(cwd, "bedrock.config.ts"), config, {
1074
+ await import_fs3.default.promises.writeFile(import_path2.default.join(cwd, "granite.config.ts"), config, {
1074
1075
  encoding: "utf-8"
1075
1076
  });
1076
1077
  }
1077
1078
  async function templateReactNative({ appName, cwd }) {
1078
- p2.log.step("bedrock.config.ts \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
1079
+ p2.log.step("granite.config.ts \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
1079
1080
  const config = transformTemplate(REACT_NATIVE_FRAMEWORK_CONFIG_TEMPLATE, {
1080
1081
  appName
1081
1082
  });
1082
- await import_fs3.default.promises.writeFile(import_path2.default.join(cwd, "bedrock.config.ts"), config, {
1083
+ await import_fs3.default.promises.writeFile(import_path2.default.join(cwd, "granite.config.ts"), config, {
1083
1084
  encoding: "utf-8"
1084
1085
  });
1085
1086
  p2.log.step("src/_app.tsx \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
@@ -1105,8 +1106,8 @@ var InitCommand = class extends import_clipanion2.Command {
1105
1106
  },
1106
1107
  {
1107
1108
  value: "react-native",
1108
- label: "React Native \uD504\uB808\uC784\uC6CC\uD06C (Bedrock)",
1109
- hint: "Bedrock \uD504\uB85C\uC81D\uD2B8\uC5D0 \uC571\uC778\uD1A0\uC2A4 React Native\uC6A9 \uAC1C\uBC1C\uD658\uACBD\uC744 \uC138\uD305\uD569\uB2C8\uB2E4."
1109
+ label: "React Native \uD504\uB808\uC784\uC6CC\uD06C (Granite)",
1110
+ hint: "Granite \uD504\uB85C\uC81D\uD2B8\uC5D0 \uC571\uC778\uD1A0\uC2A4 React Native\uC6A9 \uAC1C\uBC1C\uD658\uACBD\uC744 \uC138\uD305\uD569\uB2C8\uB2E4."
1110
1111
  }
1111
1112
  ]
1112
1113
  })
@@ -1158,18 +1159,609 @@ var InitCommand = class extends import_clipanion2.Command {
1158
1159
  }
1159
1160
  };
1160
1161
 
1162
+ // src/MigrateCommand/index.ts
1163
+ init_cjs_shims();
1164
+
1165
+ // src/MigrateCommand/MigrateCommand.ts
1166
+ init_cjs_shims();
1167
+ var import_clipanion3 = require("clipanion");
1168
+
1169
+ // src/MigrateCommand/logger/index.ts
1170
+ init_cjs_shims();
1171
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
1172
+ var Logger = class {
1173
+ prefix = import_picocolors2.default.bold(import_picocolors2.default.bgCyan(import_picocolors2.default.black(" MIGRATE ")));
1174
+ log(...args) {
1175
+ console.log(this.prefix, ...args);
1176
+ }
1177
+ success(...args) {
1178
+ console.log(this.prefix, import_picocolors2.default.green("\u2713"), ...args);
1179
+ }
1180
+ error(...args) {
1181
+ console.error(this.prefix, import_picocolors2.default.red("\u2717"), ...args);
1182
+ }
1183
+ warn(...args) {
1184
+ console.warn(this.prefix, import_picocolors2.default.yellow("!"), ...args);
1185
+ }
1186
+ };
1187
+ var logger = new Logger();
1188
+
1189
+ // src/MigrateCommand/presets/index.ts
1190
+ init_cjs_shims();
1191
+
1192
+ // src/MigrateCommand/presets/granite/index.ts
1193
+ init_cjs_shims();
1194
+
1195
+ // src/MigrateCommand/presets/granite/migrateGranite.ts
1196
+ init_cjs_shims();
1197
+ var import_assert2 = __toESM(require("assert"), 1);
1198
+ var import_dedent = __toESM(require("dedent"), 1);
1199
+
1200
+ // src/MigrateCommand/presets/granite/configProcessor.ts
1201
+ init_cjs_shims();
1202
+
1203
+ // src/MigrateCommand/fs/fileProcessor.ts
1204
+ init_cjs_shims();
1205
+ var import_fs4 = require("fs");
1206
+ async function readFile(filePath) {
1207
+ try {
1208
+ return await import_fs4.promises.readFile(filePath, "utf-8");
1209
+ } catch {
1210
+ throw new Error(`Failed to read file: ${filePath}`);
1211
+ }
1212
+ }
1213
+ async function writeFile(filePath, content) {
1214
+ try {
1215
+ await import_fs4.promises.writeFile(filePath, content, "utf-8");
1216
+ } catch {
1217
+ throw new Error(`Failed to write file: ${filePath}`);
1218
+ }
1219
+ }
1220
+ async function fileExists(filePath) {
1221
+ try {
1222
+ await import_fs4.promises.access(filePath);
1223
+ return true;
1224
+ } catch {
1225
+ return false;
1226
+ }
1227
+ }
1228
+ async function renameFile(oldPath, newPath) {
1229
+ try {
1230
+ await import_fs4.promises.rename(oldPath, newPath);
1231
+ } catch {
1232
+ throw new Error(`Failed to rename file: ${oldPath} -> ${newPath}`);
1233
+ }
1234
+ }
1235
+
1236
+ // src/MigrateCommand/presets/granite/configProcessor.ts
1237
+ var configTransformer = (root, { j }) => {
1238
+ root.find(j.ImportDeclaration).forEach((path5) => {
1239
+ const source = path5.value.source;
1240
+ if (j.StringLiteral.check(source) && source.value === "react-native-bedrock/config") {
1241
+ const defineConfigName = path5.value.specifiers?.find(
1242
+ (specifier) => j.ImportSpecifier.check(specifier) && specifier.imported.name === "defineConfig"
1243
+ )?.local?.name;
1244
+ if (!defineConfigName) {
1245
+ return;
1246
+ }
1247
+ root.find(j.CallExpression).forEach((path6) => {
1248
+ const callee = path6.value.callee;
1249
+ if (j.Identifier.check(callee) && callee.name === defineConfigName && path6.value.arguments.length > 0 && j.ObjectExpression.check(path6.value.arguments[0])) {
1250
+ const obj = path6.value.arguments[0];
1251
+ const hasScheme = obj.properties.some(
1252
+ (prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "scheme"
1253
+ );
1254
+ if (!hasScheme) {
1255
+ obj.properties.unshift(j.objectProperty(j.identifier("scheme"), j.stringLiteral("intoss")));
1256
+ }
1257
+ const routerImport = root.find(j.ImportDeclaration).filter((path7) => {
1258
+ const source2 = path7.value.source;
1259
+ return j.StringLiteral.check(source2) && source2.value === "@granite-js/plugin-router";
1260
+ });
1261
+ if (routerImport.length === 0) {
1262
+ const firstImport = root.find(j.ImportDeclaration).at(0);
1263
+ if (firstImport.length > 0) {
1264
+ firstImport.insertAfter(
1265
+ j.importDeclaration(
1266
+ [j.importSpecifier(j.identifier("router"))],
1267
+ j.stringLiteral("@granite-js/plugin-router")
1268
+ )
1269
+ );
1270
+ }
1271
+ }
1272
+ const hasPlugins = obj.properties.some(
1273
+ (prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "plugins"
1274
+ );
1275
+ const routerPluginCallExpr = j.callExpression(j.identifier("router"), []);
1276
+ if (hasPlugins) {
1277
+ const pluginsProp = obj.properties.find(
1278
+ (prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "plugins"
1279
+ );
1280
+ if (j.ObjectProperty.check(pluginsProp) && j.ArrayExpression.check(pluginsProp.value)) {
1281
+ const hasRouter = pluginsProp.value.elements.some(
1282
+ (element) => j.Identifier.check(element) && element.name === "router"
1283
+ );
1284
+ if (!hasRouter) {
1285
+ pluginsProp.value.elements.push(routerPluginCallExpr);
1286
+ }
1287
+ }
1288
+ } else {
1289
+ obj.properties.unshift(
1290
+ j.objectProperty(j.identifier("plugins"), j.arrayExpression([routerPluginCallExpr]))
1291
+ );
1292
+ }
1293
+ }
1294
+ });
1295
+ }
1296
+ });
1297
+ return root;
1298
+ };
1299
+ var processBedrockConfig = async (cwd, config) => {
1300
+ logger.log("Processing bedrock.config.ts...");
1301
+ const bedrockConfigPath = `${cwd}/bedrock.config.ts`;
1302
+ const graniteConfigPath = `${cwd}/granite.config.ts`;
1303
+ if (!await fileExists(bedrockConfigPath)) {
1304
+ logger.log("No bedrock.config.ts found");
1305
+ return;
1306
+ }
1307
+ if (config.dryRun) {
1308
+ return;
1309
+ }
1310
+ try {
1311
+ await renameFile(bedrockConfigPath, graniteConfigPath);
1312
+ logger.success("Renamed bedrock.config.ts to granite.config.ts");
1313
+ } catch (error) {
1314
+ logger.error(`Failed to process bedrock.config.ts: ${error}`);
1315
+ }
1316
+ };
1317
+
1318
+ // src/MigrateCommand/presets/granite/gitignoreProcessor.ts
1319
+ init_cjs_shims();
1320
+ var processGitignore = async (cwd, config) => {
1321
+ let modified = false;
1322
+ logger.log("Processing .gitignore...");
1323
+ const gitignorePath = `${cwd}/.gitignore`;
1324
+ try {
1325
+ if (await fileExists(gitignorePath)) {
1326
+ const content = await readFile(gitignorePath);
1327
+ const newContent = content.replace(/\.bedrock/g, ".granite");
1328
+ if (newContent !== content) {
1329
+ if (config.dryRun) {
1330
+ logger.log("Skipping file write in dry run mode");
1331
+ } else {
1332
+ await writeFile(gitignorePath, newContent);
1333
+ logger.success("Updated .gitignore");
1334
+ }
1335
+ modified ||= true;
1336
+ } else {
1337
+ logger.log(`No changes needed in ${gitignorePath}`);
1338
+ }
1339
+ }
1340
+ } catch (error) {
1341
+ logger.error(`Failed to process .gitignore: ${error}`);
1342
+ }
1343
+ if (!modified) {
1344
+ logger.log("No .gitignore found");
1345
+ return;
1346
+ }
1347
+ };
1348
+
1349
+ // src/MigrateCommand/presets/granite/identifierReplacements.ts
1350
+ init_cjs_shims();
1351
+
1352
+ // src/MigrateCommand/codemod/utils.ts
1353
+ init_cjs_shims();
1354
+ function getIdentifierName(j, id) {
1355
+ if (typeof id === "string") {
1356
+ return id;
1357
+ }
1358
+ if (j.Identifier.check(id)) {
1359
+ return id.name;
1360
+ }
1361
+ return "";
1362
+ }
1363
+
1364
+ // src/MigrateCommand/presets/granite/identifierReplacements.ts
1365
+ var identifierReplacementsTransformer = (root, { j }) => {
1366
+ const importedVariables = /* @__PURE__ */ new Set();
1367
+ function toGraniteName(name) {
1368
+ let newName = null;
1369
+ if (name === "BedrockRoute") {
1370
+ newName = "createRoute";
1371
+ } else if (name.startsWith("bedrock")) {
1372
+ newName = toGraniteCamel(name);
1373
+ } else if (name.startsWith("Bedrock")) {
1374
+ newName = toGranitePascal(name);
1375
+ } else if (name.startsWith("BEDROCK")) {
1376
+ newName = toGraniteSnake(name);
1377
+ }
1378
+ return newName;
1379
+ }
1380
+ function toGraniteCamel(name) {
1381
+ const rest = name.substring(7);
1382
+ return "granite" + rest;
1383
+ }
1384
+ function toGranitePascal(name) {
1385
+ const rest = name.substring(7);
1386
+ return "Granite" + rest;
1387
+ }
1388
+ function toGraniteSnake(name) {
1389
+ const rest = name.substring(7);
1390
+ return "GRANITE" + rest;
1391
+ }
1392
+ root.find(j.ImportDeclaration, { source: { value: "react-native-bedrock" } }).forEach((importPath) => {
1393
+ importPath.value.specifiers?.forEach((specifier) => {
1394
+ if (j.ImportSpecifier.check(specifier)) {
1395
+ const importedName = getIdentifierName(j, specifier.imported);
1396
+ const localName = specifier.local ? getIdentifierName(j, specifier.local) : importedName;
1397
+ if (j.Identifier.check(specifier.imported)) {
1398
+ const newName = toGraniteName(importedName);
1399
+ if (newName) {
1400
+ specifier.imported.name = newName;
1401
+ }
1402
+ }
1403
+ importedVariables.add(localName);
1404
+ }
1405
+ });
1406
+ });
1407
+ root.find(j.Identifier).forEach((path5) => {
1408
+ const name = path5.value.name;
1409
+ if (importedVariables.has(name)) {
1410
+ const newName = toGraniteName(path5.value.name);
1411
+ if (newName) {
1412
+ path5.value.name = newName;
1413
+ }
1414
+ }
1415
+ });
1416
+ return root;
1417
+ };
1418
+
1419
+ // src/MigrateCommand/presets/granite/isBedrockProject.ts
1420
+ init_cjs_shims();
1421
+ var fs5 = __toESM(require("fs"), 1);
1422
+ var BASE_NAME = "bedrock.config";
1423
+ var EXTENSIONS = ["ts", "mts", "js", "cjs"];
1424
+ async function isBedrockProject(cwd) {
1425
+ const files = fs5.readdirSync(cwd);
1426
+ return files.some(isBedrockConfigFile);
1427
+ }
1428
+ function isBedrockConfigFile(file) {
1429
+ return EXTENSIONS.some((ext) => file === `${BASE_NAME}.${ext}`);
1430
+ }
1431
+
1432
+ // src/MigrateCommand/presets/granite/packageImports.ts
1433
+ init_cjs_shims();
1434
+ var import_picocolors3 = __toESM(require_picocolors(), 1);
1435
+
1436
+ // src/MigrateCommand/presets/granite/constants.ts
1437
+ init_cjs_shims();
1438
+ var UNSUPPORTED_LIBRARIES = [
1439
+ "@react-native-bedrock/e2e-testing-library",
1440
+ "@react-native-bedrock/babel-plugin-obfuscate"
1441
+ ];
1442
+ var TARGET_VERSION = {
1443
+ granitePackages: "0.1.21",
1444
+ appsInTossPackages: "^1.0.0",
1445
+ tossDesignSystem: "^1.0.4"
1446
+ };
1447
+
1448
+ // src/MigrateCommand/presets/granite/packageImports.ts
1449
+ var packageImportsTransformer = (root, { j }, { fileName = "<unknown>" }) => {
1450
+ function transformPackageName(value) {
1451
+ if (UNSUPPORTED_LIBRARIES.includes(value)) {
1452
+ const libName = import_picocolors3.default.gray(`(${value})`);
1453
+ logger.warn(`Unsupported library found ${libName}`);
1454
+ logger.warn(`\u2514\u2500 ${import_picocolors3.default.gray(`at ${fileName}`)}`);
1455
+ return value;
1456
+ }
1457
+ if (value === "react-native-bedrock" || value.startsWith("react-native-bedrock/")) {
1458
+ return value.replace("react-native-bedrock", "@granite-js/react-native");
1459
+ }
1460
+ if (value.startsWith("@react-native-bedrock/")) {
1461
+ return value.replace("@react-native-bedrock/", "@granite-js/");
1462
+ }
1463
+ return value;
1464
+ }
1465
+ root.find(j.ImportDeclaration).forEach((path5) => {
1466
+ const source = path5.value.source;
1467
+ if (j.StringLiteral.check(source)) {
1468
+ const transformed = transformPackageName(source.value);
1469
+ if (transformed !== source.value) {
1470
+ source.value = transformed;
1471
+ }
1472
+ }
1473
+ });
1474
+ root.find(j.CallExpression, {
1475
+ callee: { name: "require" }
1476
+ }).forEach((path5) => {
1477
+ const args = path5.value.arguments;
1478
+ if (args.length > 0 && j.StringLiteral.check(args[0])) {
1479
+ const transformed = transformPackageName(args[0].value);
1480
+ if (transformed !== args[0].value) {
1481
+ args[0].value = transformed;
1482
+ }
1483
+ }
1484
+ });
1485
+ root.find(j.ImportExpression).forEach((path5) => {
1486
+ const source = path5.value.source;
1487
+ if (j.StringLiteral.check(source)) {
1488
+ const transformed = transformPackageName(source.value);
1489
+ if (transformed !== source.value) {
1490
+ source.value = transformed;
1491
+ }
1492
+ }
1493
+ });
1494
+ return root;
1495
+ };
1496
+
1497
+ // src/MigrateCommand/presets/granite/packageJsonProcessor.ts
1498
+ init_cjs_shims();
1499
+ var import_picocolors4 = __toESM(require_picocolors(), 1);
1500
+ var processPackageJson = async (cwd, config) => {
1501
+ logger.log("Processing package.json...");
1502
+ const packageJsonPath = `${cwd}/package.json`;
1503
+ if (!await fileExists(packageJsonPath)) {
1504
+ logger.log("No package.json found");
1505
+ return;
1506
+ }
1507
+ try {
1508
+ const content = await readFile(packageJsonPath);
1509
+ const packageJson = JSON.parse(content);
1510
+ let modified = false;
1511
+ const depFields = ["dependencies", "devDependencies", "peerDependencies"];
1512
+ for (const field of depFields) {
1513
+ if (packageJson[field]) {
1514
+ const deps = packageJson[field];
1515
+ const newDeps = {
1516
+ "@granite-js/plugin-router": TARGET_VERSION.granitePackages
1517
+ };
1518
+ for (const [originLibName, originLibVersion] of Object.entries(deps)) {
1519
+ let libName = originLibName;
1520
+ let libVersion = originLibVersion;
1521
+ if (originLibName === "react-native-bedrock") {
1522
+ libName = "@granite-js/react-native";
1523
+ libVersion = TARGET_VERSION.granitePackages;
1524
+ } else if (originLibName.startsWith("@react-native-bedrock/")) {
1525
+ if (UNSUPPORTED_LIBRARIES.includes(originLibName)) {
1526
+ const packageName = import_picocolors4.default.gray(`(${originLibName})`);
1527
+ logger.warn(`Unsupported library found in package.json ${packageName}`);
1528
+ } else {
1529
+ libName = originLibName.replace("@react-native-bedrock", "@granite-js");
1530
+ libVersion = TARGET_VERSION.granitePackages;
1531
+ }
1532
+ }
1533
+ if (libName.startsWith("@apps-in-toss/")) {
1534
+ libVersion = TARGET_VERSION.appsInTossPackages;
1535
+ } else if (libName === "@toss-design-system/react-native") {
1536
+ libVersion = TARGET_VERSION.tossDesignSystem;
1537
+ }
1538
+ newDeps[libName] = libVersion;
1539
+ modified ||= libName !== originLibName;
1540
+ }
1541
+ packageJson[field] = newDeps;
1542
+ }
1543
+ }
1544
+ if (packageJson.scripts) {
1545
+ const scripts = packageJson.scripts;
1546
+ for (const [key, value] of Object.entries(scripts)) {
1547
+ if (typeof value === "string" && value.includes("bedrock")) {
1548
+ scripts[key] = value.replace(/\bbedrock\b/g, "granite");
1549
+ modified ||= true;
1550
+ }
1551
+ }
1552
+ }
1553
+ if (config.dryRun) {
1554
+ return;
1555
+ }
1556
+ if (modified) {
1557
+ await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
1558
+ logger.success("Updated package.json");
1559
+ } else {
1560
+ logger.log("No changes needed in package.json");
1561
+ }
1562
+ } catch (error) {
1563
+ logger.error(`Failed to process package.json: ${error}`);
1564
+ }
1565
+ };
1566
+
1567
+ // src/MigrateCommand/presets/granite/toAppsInTossFrameworkImport.ts
1568
+ init_cjs_shims();
1569
+ var APPS_IN_TOSS_FRAMEWORK_EXPORTS = [
1570
+ "closeView",
1571
+ "getLocale",
1572
+ "getSchemeUri",
1573
+ "generateHapticFeedback",
1574
+ "share",
1575
+ "setSecureScreen",
1576
+ "setScreenAwakeMode",
1577
+ "getNetworkStatus",
1578
+ "setIosSwipeGestureEnabled",
1579
+ "openURL",
1580
+ "getPlatformOS"
1581
+ ];
1582
+ var toAppsInTossFrameworkImport = (root, { j }, { fileName = "<unknown>" }) => {
1583
+ const appsInTossFrameworkMembers = [];
1584
+ root.find(j.ImportDeclaration).forEach((path5) => {
1585
+ const source = path5.node.source.value;
1586
+ if (typeof source !== "string") {
1587
+ return;
1588
+ }
1589
+ if (source === "@granite-js/react-native") {
1590
+ if (Array.isArray(path5.node.specifiers)) {
1591
+ path5.node.specifiers = path5.node.specifiers.filter((specifier) => {
1592
+ if (shouldImportFromAppsInTossFramework(fileName, specifier)) {
1593
+ appsInTossFrameworkMembers.push(specifier);
1594
+ return false;
1595
+ }
1596
+ return true;
1597
+ });
1598
+ }
1599
+ if (path5.node.specifiers?.length === 0) {
1600
+ j(path5).remove();
1601
+ }
1602
+ }
1603
+ });
1604
+ if (appsInTossFrameworkMembers.length > 0) {
1605
+ const importStatement = j.importDeclaration(appsInTossFrameworkMembers, j.literal("@apps-in-toss/framework"));
1606
+ root.find(j.Program).get("body", 0).insertBefore(importStatement);
1607
+ }
1608
+ return root;
1609
+ };
1610
+ function shouldImportFromAppsInTossFramework(fileName, specifier) {
1611
+ switch (specifier.type) {
1612
+ case "ImportSpecifier":
1613
+ return APPS_IN_TOSS_FRAMEWORK_EXPORTS.includes(String(specifier.imported.name));
1614
+ case "ImportDefaultSpecifier":
1615
+ case "ImportNamespaceSpecifier":
1616
+ default:
1617
+ logger.warn(`Unknown import specifier in ${fileName}`);
1618
+ return false;
1619
+ }
1620
+ }
1621
+
1622
+ // src/MigrateCommand/codemod/index.ts
1623
+ init_cjs_shims();
1624
+
1625
+ // src/MigrateCommand/codemod/transform.ts
1626
+ init_cjs_shims();
1627
+ var import_jscodeshift = __toESM(require("jscodeshift"), 1);
1628
+ function transform(source, { transformers: transformers2, options = {} }) {
1629
+ const j = import_jscodeshift.default.withParser("tsx");
1630
+ const report = [];
1631
+ const stats = /* @__PURE__ */ new Map();
1632
+ const context = {
1633
+ j,
1634
+ jscodeshift: j,
1635
+ stats: (name, quantity = 1) => {
1636
+ if (quantity === 0) {
1637
+ return;
1638
+ }
1639
+ stats.set(name, (stats.get(name) ?? 0) + quantity);
1640
+ },
1641
+ report: (message) => {
1642
+ report.push(message);
1643
+ }
1644
+ };
1645
+ const root = transformers2.reduce((root2, transformer) => transformer(root2, context, options), j(source));
1646
+ return root.toSource();
1647
+ }
1648
+
1649
+ // src/MigrateCommand/fs/fileScanner.ts
1650
+ init_cjs_shims();
1651
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
1652
+ var DEFAULT_EXTENSIONS = ["js", "ts", "jsx", "tsx", "cjs", "mjs"];
1653
+ var DEFAULT_EXCLUDE_PATTERNS = ["**/node_modules/**", "**/.git/**", "**/dist/**"];
1654
+ async function scanFiles(directory, options = {}) {
1655
+ const { extensions = DEFAULT_EXTENSIONS, excludePatterns = DEFAULT_EXCLUDE_PATTERNS } = options;
1656
+ const patterns = extensions.map((ext) => `**/*.${ext}`);
1657
+ const files = await (0, import_fast_glob.default)(patterns, {
1658
+ cwd: directory,
1659
+ absolute: true,
1660
+ ignore: excludePatterns
1661
+ });
1662
+ return files;
1663
+ }
1664
+
1665
+ // src/MigrateCommand/presets/granite/migrateGranite.ts
1666
+ var transformers = [
1667
+ configTransformer,
1668
+ identifierReplacementsTransformer,
1669
+ packageImportsTransformer,
1670
+ toAppsInTossFrameworkImport
1671
+ ];
1672
+ var migrateGranite = async (cwd, config) => {
1673
+ (0, import_assert2.default)(isBedrockProject(cwd), "This is not a Bedrock project");
1674
+ let processedCount = 0;
1675
+ const files = await scanFiles(cwd);
1676
+ logger.log(`Found ${files.length} source files`);
1677
+ logger.log("Processing source files...");
1678
+ for (const file of files) {
1679
+ try {
1680
+ const content = await readFile(file);
1681
+ const newContent = await transform(content, {
1682
+ transformers,
1683
+ options: {
1684
+ fileName: file
1685
+ }
1686
+ });
1687
+ if (config.dryRun !== true && newContent !== content) {
1688
+ await writeFile(file, newContent);
1689
+ processedCount++;
1690
+ }
1691
+ } catch (error) {
1692
+ logger.error(`Failed to process file: ${file}`, error);
1693
+ }
1694
+ }
1695
+ if (processedCount > 0) {
1696
+ logger.success(`Processed ${processedCount} source files`);
1697
+ } else {
1698
+ logger.log("No source files needed processing");
1699
+ }
1700
+ await processPackageJson(cwd, config);
1701
+ await processGitignore(cwd, config);
1702
+ await processBedrockConfig(cwd, config);
1703
+ logger.log(import_dedent.default`
1704
+ Please check the following steps:
1705
+
1706
+ - Install dependencies
1707
+ - Run type checks
1708
+ - Run lint checks if a lint config exists
1709
+ - Verify test results if tests are present\n
1710
+ `);
1711
+ };
1712
+
1713
+ // src/MigrateCommand/presets/index.ts
1714
+ var MIGRATE_PRESETS = {
1715
+ granite: migrateGranite
1716
+ };
1717
+
1718
+ // src/MigrateCommand/MigrateCommand.ts
1719
+ var MigrateCommand = class extends import_clipanion3.Command {
1720
+ static paths = [[`migrate`]];
1721
+ static usage = import_clipanion3.Command.Usage({
1722
+ category: "Migration",
1723
+ description: "Run migration",
1724
+ examples: [
1725
+ ["Run migration", "ait migrate <target>"],
1726
+ ["Check migration availability", "ait migrate <target> --dryRun"]
1727
+ ]
1728
+ });
1729
+ target = import_clipanion3.Option.String({ required: true });
1730
+ dryRun = import_clipanion3.Option.Boolean("--dry-run", { required: false });
1731
+ async execute() {
1732
+ try {
1733
+ const cwd = process.cwd();
1734
+ const config = {
1735
+ dryRun: this.dryRun
1736
+ };
1737
+ logger.log("Starting migration...");
1738
+ logger.log(`Working directory: ${cwd}`);
1739
+ const migrate = MIGRATE_PRESETS[this.target];
1740
+ if (migrate == null) {
1741
+ throw new Error(`Unknown target: ${this.target}`);
1742
+ }
1743
+ await migrate(cwd, config);
1744
+ logger.success("Migration completed successfully!");
1745
+ return 0;
1746
+ } catch (error) {
1747
+ logger.error(`Migration failed: ${error.message}`);
1748
+ return 1;
1749
+ }
1750
+ }
1751
+ };
1752
+
1161
1753
  // src/integrations/UploadSentrySourcemap/index.ts
1162
1754
  init_cjs_shims();
1163
1755
 
1164
1756
  // src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
1165
1757
  init_cjs_shims();
1166
- var fs7 = __toESM(require("fs/promises"), 1);
1758
+ var fs9 = __toESM(require("fs/promises"), 1);
1167
1759
  var p3 = __toESM(require("@clack/prompts"), 1);
1168
- var import_clipanion3 = require("clipanion");
1760
+ var import_clipanion4 = require("clipanion");
1169
1761
 
1170
1762
  // src/integrations/UploadSentrySourcemap/downloadArtifacts.ts
1171
1763
  init_cjs_shims();
1172
- var fs4 = __toESM(require("fs"), 1);
1764
+ var fs6 = __toESM(require("fs"), 1);
1173
1765
  var os = __toESM(require("os"), 1);
1174
1766
  var path3 = __toESM(require("path"), 1);
1175
1767
  var import_stream = require("stream");
@@ -1201,19 +1793,19 @@ async function downloadArtifacts(options) {
1201
1793
  const tmpDir = await createTempDirectory();
1202
1794
  const tmpFile = `${deploymentId}.zip`;
1203
1795
  const tmpFilePath = path3.join(tmpDir.path, tmpFile);
1204
- const fileStream = fs4.createWriteStream(tmpFilePath);
1796
+ const fileStream = fs6.createWriteStream(tmpFilePath);
1205
1797
  await streamPipeline(response.body, fileStream);
1206
1798
  debug4("Artifacts downloaded", { tmpFilePath });
1207
1799
  return tmpFilePath;
1208
1800
  }
1209
1801
  function createTempDirectory() {
1210
1802
  const tempDir = path3.join(os.tmpdir(), "apps-in-toss", "sentry-integration");
1211
- fs4.mkdirSync(tempDir, { recursive: true });
1803
+ fs6.mkdirSync(tempDir, { recursive: true });
1212
1804
  debug4("Temp directory created", { tempDir });
1213
1805
  return {
1214
1806
  path: tempDir,
1215
1807
  cleanup: () => {
1216
- fs4.rmSync(tempDir, { recursive: true, force: true });
1808
+ fs6.rmSync(tempDir, { recursive: true, force: true });
1217
1809
  }
1218
1810
  };
1219
1811
  }
@@ -1228,7 +1820,7 @@ async function extractSentryDebugId(bundlePath) {
1228
1820
 
1229
1821
  // src/integrations/UploadSentrySourcemap/extractSources.ts
1230
1822
  init_cjs_shims();
1231
- var fs6 = __toESM(require("fs"), 1);
1823
+ var fs8 = __toESM(require("fs"), 1);
1232
1824
  var path4 = __toESM(require("path"), 1);
1233
1825
  var import_stream2 = require("stream");
1234
1826
  var import_util2 = require("util");
@@ -1250,12 +1842,12 @@ async function extractSources(zipPath) {
1250
1842
  hermesSourceMap: ""
1251
1843
  }
1252
1844
  };
1253
- await fs6.createReadStream(zipPath).pipe(unzipper.Parse()).on("entry", async (entry) => {
1845
+ await fs8.createReadStream(zipPath).pipe(unzipper.Parse()).on("entry", async (entry) => {
1254
1846
  const isRoot = !entry.path.includes("/");
1255
1847
  const fileName = path4.basename(entry.path);
1256
1848
  const outputPath = path4.join(path4.dirname(zipPath), fileName);
1257
1849
  if (isRoot) {
1258
- entry.pipe(fs6.createWriteStream(outputPath));
1850
+ entry.pipe(fs8.createWriteStream(outputPath));
1259
1851
  const platform = fileName.includes("android") ? "android" : "ios";
1260
1852
  if (fileName.endsWith(".js")) {
1261
1853
  sources[platform].packagerBundle = outputPath;
@@ -1283,7 +1875,7 @@ async function extractSources(zipPath) {
1283
1875
  }
1284
1876
  async function decompressGzip(gzFile) {
1285
1877
  const outfile = gzFile.replace(/\.gz$/g, "");
1286
- await pipe(fs6.createReadStream(gzFile), zlib.createGunzip(), fs6.createWriteStream(outfile));
1878
+ await pipe(fs8.createReadStream(gzFile), zlib.createGunzip(), fs8.createWriteStream(outfile));
1287
1879
  return outfile;
1288
1880
  }
1289
1881
 
@@ -1314,33 +1906,33 @@ function uploadSourcemap(bundlePath, sourcemapPath, options) {
1314
1906
  }
1315
1907
 
1316
1908
  // src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
1317
- var UploadSentrySourcemap = class extends import_clipanion3.Command {
1909
+ var UploadSentrySourcemap = class extends import_clipanion4.Command {
1318
1910
  static paths = [["sentry", "upload-sourcemap"]];
1319
- apiKey = import_clipanion3.Option.String("--api-key", {
1911
+ apiKey = import_clipanion4.Option.String("--api-key", {
1320
1912
  required: false,
1321
1913
  description: "\uC778\uC99D API \uD0A4"
1322
1914
  });
1323
- appName = import_clipanion3.Option.String("--app-name", {
1915
+ appName = import_clipanion4.Option.String("--app-name", {
1324
1916
  required: false,
1325
1917
  description: "\uC571 \uC774\uB984"
1326
1918
  });
1327
- deploymentId = import_clipanion3.Option.String("--deployment-id", {
1919
+ deploymentId = import_clipanion4.Option.String("--deployment-id", {
1328
1920
  required: false,
1329
1921
  description: "\uBC30\uD3EC ID"
1330
1922
  });
1331
- sentryAuthToken = import_clipanion3.Option.String("--sentry-auth-token", {
1923
+ sentryAuthToken = import_clipanion4.Option.String("--sentry-auth-token", {
1332
1924
  required: false,
1333
1925
  description: "Sentry \uC778\uC99D\uD0A4"
1334
1926
  });
1335
- sentryOrg = import_clipanion3.Option.String("--sentry-org", {
1927
+ sentryOrg = import_clipanion4.Option.String("--sentry-org", {
1336
1928
  required: false,
1337
1929
  description: "Sentry \uC870\uC9C1"
1338
1930
  });
1339
- sentryProject = import_clipanion3.Option.String("--sentry-project", {
1931
+ sentryProject = import_clipanion4.Option.String("--sentry-project", {
1340
1932
  required: false,
1341
1933
  description: "Sentry \uD504\uB85C\uC81D\uD2B8"
1342
1934
  });
1343
- baseUrl = import_clipanion3.Option.String("--base-url", {
1935
+ baseUrl = import_clipanion4.Option.String("--base-url", {
1344
1936
  description: "API Base URL"
1345
1937
  });
1346
1938
  async execute() {
@@ -1396,11 +1988,11 @@ var UploadSentrySourcemap = class extends import_clipanion3.Command {
1396
1988
  throw new Error("Sentry Debug ID\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1397
1989
  }
1398
1990
  const mergedSourceMap = await mergeSourceMaps(
1399
- await fs7.readFile(sources.packagerSourceMap, "utf-8"),
1400
- await fs7.readFile(sources.hermesSourceMap, "utf-8")
1991
+ await fs9.readFile(sources.packagerSourceMap, "utf-8"),
1992
+ await fs9.readFile(sources.hermesSourceMap, "utf-8")
1401
1993
  );
1402
1994
  const injectedSourceMap = injectSentryDebugId(mergedSourceMap, debugId);
1403
- await fs7.writeFile(sources.hermesSourceMap, JSON.stringify(injectedSourceMap, null, 2), "utf-8");
1995
+ await fs9.writeFile(sources.hermesSourceMap, JSON.stringify(injectedSourceMap, null, 2), "utf-8");
1404
1996
  }
1405
1997
  async promptRequiredValue(type, message, validateMessage) {
1406
1998
  const result = await p3[type]({
@@ -1421,12 +2013,13 @@ var UploadSentrySourcemap = class extends import_clipanion3.Command {
1421
2013
 
1422
2014
  // src/index.ts
1423
2015
  function initialize() {
1424
- const cli = new import_clipanion4.Cli({
2016
+ const cli = new import_clipanion5.Cli({
1425
2017
  binaryLabel: "ait",
1426
2018
  binaryName: "ait"
1427
2019
  });
1428
2020
  cli.register(DeployCommand);
1429
2021
  cli.register(InitCommand);
2022
+ cli.register(MigrateCommand);
1430
2023
  cli.register(UploadSentrySourcemap);
1431
2024
  cli.runExit(process.argv.slice(2));
1432
2025
  }