@apps-in-toss/cli 0.0.39 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +573 -40
  2. package/dist/index.js +573 -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,549 @@ 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.20",
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/codemod/index.ts
1568
+ init_cjs_shims();
1569
+
1570
+ // src/MigrateCommand/codemod/transform.ts
1571
+ init_cjs_shims();
1572
+ var import_jscodeshift = __toESM(require("jscodeshift"), 1);
1573
+ function transform(source, { transformers: transformers2, options = {} }) {
1574
+ const j = import_jscodeshift.default.withParser("tsx");
1575
+ const report = [];
1576
+ const stats = /* @__PURE__ */ new Map();
1577
+ const context = {
1578
+ j,
1579
+ jscodeshift: j,
1580
+ stats: (name, quantity = 1) => {
1581
+ if (quantity === 0) {
1582
+ return;
1583
+ }
1584
+ stats.set(name, (stats.get(name) ?? 0) + quantity);
1585
+ },
1586
+ report: (message) => {
1587
+ report.push(message);
1588
+ }
1589
+ };
1590
+ const root = transformers2.reduce((root2, transformer) => transformer(root2, context, options), j(source));
1591
+ return root.toSource();
1592
+ }
1593
+
1594
+ // src/MigrateCommand/fs/fileScanner.ts
1595
+ init_cjs_shims();
1596
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
1597
+ var DEFAULT_EXTENSIONS = ["js", "ts", "jsx", "tsx", "cjs", "mjs"];
1598
+ var DEFAULT_EXCLUDE_PATTERNS = ["**/node_modules/**", "**/.git/**", "**/dist/**"];
1599
+ async function scanFiles(directory, options = {}) {
1600
+ const { extensions = DEFAULT_EXTENSIONS, excludePatterns = DEFAULT_EXCLUDE_PATTERNS } = options;
1601
+ const patterns = extensions.map((ext) => `**/*.${ext}`);
1602
+ const files = await (0, import_fast_glob.default)(patterns, {
1603
+ cwd: directory,
1604
+ absolute: true,
1605
+ ignore: excludePatterns
1606
+ });
1607
+ return files;
1608
+ }
1609
+
1610
+ // src/MigrateCommand/presets/granite/migrateGranite.ts
1611
+ var transformers = [configTransformer, identifierReplacementsTransformer, packageImportsTransformer];
1612
+ var migrateGranite = async (cwd, config) => {
1613
+ (0, import_assert2.default)(isBedrockProject(cwd), "This is not a Bedrock project");
1614
+ let processedCount = 0;
1615
+ const files = await scanFiles(cwd);
1616
+ logger.log(`Found ${files.length} source files`);
1617
+ logger.log("Processing source files...");
1618
+ for (const file of files) {
1619
+ try {
1620
+ const content = await readFile(file);
1621
+ const newContent = await transform(content, {
1622
+ transformers,
1623
+ options: {
1624
+ fileName: file
1625
+ }
1626
+ });
1627
+ if (config.dryRun !== true && newContent !== content) {
1628
+ await writeFile(file, newContent);
1629
+ processedCount++;
1630
+ }
1631
+ } catch (error) {
1632
+ logger.error(`Failed to process file: ${file}`, error);
1633
+ }
1634
+ }
1635
+ if (processedCount > 0) {
1636
+ logger.success(`Processed ${processedCount} source files`);
1637
+ } else {
1638
+ logger.log("No source files needed processing");
1639
+ }
1640
+ await processPackageJson(cwd, config);
1641
+ await processGitignore(cwd, config);
1642
+ await processBedrockConfig(cwd, config);
1643
+ logger.log(import_dedent.default`
1644
+ Please check the following steps:
1645
+
1646
+ - Install dependencies
1647
+ - Run type checks
1648
+ - Run lint checks if a lint config exists
1649
+ - Verify test results if tests are present\n
1650
+ `);
1651
+ };
1652
+
1653
+ // src/MigrateCommand/presets/index.ts
1654
+ var MIGRATE_PRESETS = {
1655
+ granite: migrateGranite
1656
+ };
1657
+
1658
+ // src/MigrateCommand/MigrateCommand.ts
1659
+ var MigrateCommand = class extends import_clipanion3.Command {
1660
+ static paths = [[`migrate`]];
1661
+ static usage = import_clipanion3.Command.Usage({
1662
+ category: "Migration",
1663
+ description: "Run migration",
1664
+ examples: [
1665
+ ["Run migration", "ait migrate <target>"],
1666
+ ["Check migration availability", "ait migrate <target> --dryRun"]
1667
+ ]
1668
+ });
1669
+ target = import_clipanion3.Option.String({ required: true });
1670
+ dryRun = import_clipanion3.Option.Boolean("--dry-run", { required: false });
1671
+ async execute() {
1672
+ try {
1673
+ const cwd = process.cwd();
1674
+ const config = {
1675
+ dryRun: this.dryRun
1676
+ };
1677
+ logger.log("Starting migration...");
1678
+ logger.log(`Working directory: ${cwd}`);
1679
+ const migrate = MIGRATE_PRESETS[this.target];
1680
+ if (migrate == null) {
1681
+ throw new Error(`Unknown target: ${this.target}`);
1682
+ }
1683
+ await migrate(cwd, config);
1684
+ logger.success("Migration completed successfully!");
1685
+ return 0;
1686
+ } catch (error) {
1687
+ logger.error(`Migration failed: ${error.message}`);
1688
+ return 1;
1689
+ }
1690
+ }
1691
+ };
1692
+
1161
1693
  // src/integrations/UploadSentrySourcemap/index.ts
1162
1694
  init_cjs_shims();
1163
1695
 
1164
1696
  // src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
1165
1697
  init_cjs_shims();
1166
- var fs7 = __toESM(require("fs/promises"), 1);
1698
+ var fs9 = __toESM(require("fs/promises"), 1);
1167
1699
  var p3 = __toESM(require("@clack/prompts"), 1);
1168
- var import_clipanion3 = require("clipanion");
1700
+ var import_clipanion4 = require("clipanion");
1169
1701
 
1170
1702
  // src/integrations/UploadSentrySourcemap/downloadArtifacts.ts
1171
1703
  init_cjs_shims();
1172
- var fs4 = __toESM(require("fs"), 1);
1704
+ var fs6 = __toESM(require("fs"), 1);
1173
1705
  var os = __toESM(require("os"), 1);
1174
1706
  var path3 = __toESM(require("path"), 1);
1175
1707
  var import_stream = require("stream");
@@ -1201,19 +1733,19 @@ async function downloadArtifacts(options) {
1201
1733
  const tmpDir = await createTempDirectory();
1202
1734
  const tmpFile = `${deploymentId}.zip`;
1203
1735
  const tmpFilePath = path3.join(tmpDir.path, tmpFile);
1204
- const fileStream = fs4.createWriteStream(tmpFilePath);
1736
+ const fileStream = fs6.createWriteStream(tmpFilePath);
1205
1737
  await streamPipeline(response.body, fileStream);
1206
1738
  debug4("Artifacts downloaded", { tmpFilePath });
1207
1739
  return tmpFilePath;
1208
1740
  }
1209
1741
  function createTempDirectory() {
1210
1742
  const tempDir = path3.join(os.tmpdir(), "apps-in-toss", "sentry-integration");
1211
- fs4.mkdirSync(tempDir, { recursive: true });
1743
+ fs6.mkdirSync(tempDir, { recursive: true });
1212
1744
  debug4("Temp directory created", { tempDir });
1213
1745
  return {
1214
1746
  path: tempDir,
1215
1747
  cleanup: () => {
1216
- fs4.rmSync(tempDir, { recursive: true, force: true });
1748
+ fs6.rmSync(tempDir, { recursive: true, force: true });
1217
1749
  }
1218
1750
  };
1219
1751
  }
@@ -1228,7 +1760,7 @@ async function extractSentryDebugId(bundlePath) {
1228
1760
 
1229
1761
  // src/integrations/UploadSentrySourcemap/extractSources.ts
1230
1762
  init_cjs_shims();
1231
- var fs6 = __toESM(require("fs"), 1);
1763
+ var fs8 = __toESM(require("fs"), 1);
1232
1764
  var path4 = __toESM(require("path"), 1);
1233
1765
  var import_stream2 = require("stream");
1234
1766
  var import_util2 = require("util");
@@ -1250,12 +1782,12 @@ async function extractSources(zipPath) {
1250
1782
  hermesSourceMap: ""
1251
1783
  }
1252
1784
  };
1253
- await fs6.createReadStream(zipPath).pipe(unzipper.Parse()).on("entry", async (entry) => {
1785
+ await fs8.createReadStream(zipPath).pipe(unzipper.Parse()).on("entry", async (entry) => {
1254
1786
  const isRoot = !entry.path.includes("/");
1255
1787
  const fileName = path4.basename(entry.path);
1256
1788
  const outputPath = path4.join(path4.dirname(zipPath), fileName);
1257
1789
  if (isRoot) {
1258
- entry.pipe(fs6.createWriteStream(outputPath));
1790
+ entry.pipe(fs8.createWriteStream(outputPath));
1259
1791
  const platform = fileName.includes("android") ? "android" : "ios";
1260
1792
  if (fileName.endsWith(".js")) {
1261
1793
  sources[platform].packagerBundle = outputPath;
@@ -1283,7 +1815,7 @@ async function extractSources(zipPath) {
1283
1815
  }
1284
1816
  async function decompressGzip(gzFile) {
1285
1817
  const outfile = gzFile.replace(/\.gz$/g, "");
1286
- await pipe(fs6.createReadStream(gzFile), zlib.createGunzip(), fs6.createWriteStream(outfile));
1818
+ await pipe(fs8.createReadStream(gzFile), zlib.createGunzip(), fs8.createWriteStream(outfile));
1287
1819
  return outfile;
1288
1820
  }
1289
1821
 
@@ -1314,33 +1846,33 @@ function uploadSourcemap(bundlePath, sourcemapPath, options) {
1314
1846
  }
1315
1847
 
1316
1848
  // src/integrations/UploadSentrySourcemap/UploadSentrySourcemap.ts
1317
- var UploadSentrySourcemap = class extends import_clipanion3.Command {
1849
+ var UploadSentrySourcemap = class extends import_clipanion4.Command {
1318
1850
  static paths = [["sentry", "upload-sourcemap"]];
1319
- apiKey = import_clipanion3.Option.String("--api-key", {
1851
+ apiKey = import_clipanion4.Option.String("--api-key", {
1320
1852
  required: false,
1321
1853
  description: "\uC778\uC99D API \uD0A4"
1322
1854
  });
1323
- appName = import_clipanion3.Option.String("--app-name", {
1855
+ appName = import_clipanion4.Option.String("--app-name", {
1324
1856
  required: false,
1325
1857
  description: "\uC571 \uC774\uB984"
1326
1858
  });
1327
- deploymentId = import_clipanion3.Option.String("--deployment-id", {
1859
+ deploymentId = import_clipanion4.Option.String("--deployment-id", {
1328
1860
  required: false,
1329
1861
  description: "\uBC30\uD3EC ID"
1330
1862
  });
1331
- sentryAuthToken = import_clipanion3.Option.String("--sentry-auth-token", {
1863
+ sentryAuthToken = import_clipanion4.Option.String("--sentry-auth-token", {
1332
1864
  required: false,
1333
1865
  description: "Sentry \uC778\uC99D\uD0A4"
1334
1866
  });
1335
- sentryOrg = import_clipanion3.Option.String("--sentry-org", {
1867
+ sentryOrg = import_clipanion4.Option.String("--sentry-org", {
1336
1868
  required: false,
1337
1869
  description: "Sentry \uC870\uC9C1"
1338
1870
  });
1339
- sentryProject = import_clipanion3.Option.String("--sentry-project", {
1871
+ sentryProject = import_clipanion4.Option.String("--sentry-project", {
1340
1872
  required: false,
1341
1873
  description: "Sentry \uD504\uB85C\uC81D\uD2B8"
1342
1874
  });
1343
- baseUrl = import_clipanion3.Option.String("--base-url", {
1875
+ baseUrl = import_clipanion4.Option.String("--base-url", {
1344
1876
  description: "API Base URL"
1345
1877
  });
1346
1878
  async execute() {
@@ -1396,11 +1928,11 @@ var UploadSentrySourcemap = class extends import_clipanion3.Command {
1396
1928
  throw new Error("Sentry Debug ID\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1397
1929
  }
1398
1930
  const mergedSourceMap = await mergeSourceMaps(
1399
- await fs7.readFile(sources.packagerSourceMap, "utf-8"),
1400
- await fs7.readFile(sources.hermesSourceMap, "utf-8")
1931
+ await fs9.readFile(sources.packagerSourceMap, "utf-8"),
1932
+ await fs9.readFile(sources.hermesSourceMap, "utf-8")
1401
1933
  );
1402
1934
  const injectedSourceMap = injectSentryDebugId(mergedSourceMap, debugId);
1403
- await fs7.writeFile(sources.hermesSourceMap, JSON.stringify(injectedSourceMap, null, 2), "utf-8");
1935
+ await fs9.writeFile(sources.hermesSourceMap, JSON.stringify(injectedSourceMap, null, 2), "utf-8");
1404
1936
  }
1405
1937
  async promptRequiredValue(type, message, validateMessage) {
1406
1938
  const result = await p3[type]({
@@ -1421,12 +1953,13 @@ var UploadSentrySourcemap = class extends import_clipanion3.Command {
1421
1953
 
1422
1954
  // src/index.ts
1423
1955
  function initialize() {
1424
- const cli = new import_clipanion4.Cli({
1956
+ const cli = new import_clipanion5.Cli({
1425
1957
  binaryLabel: "ait",
1426
1958
  binaryName: "ait"
1427
1959
  });
1428
1960
  cli.register(DeployCommand);
1429
1961
  cli.register(InitCommand);
1962
+ cli.register(MigrateCommand);
1430
1963
  cli.register(UploadSentrySourcemap);
1431
1964
  cli.runExit(process.argv.slice(2));
1432
1965
  }