@zsukim/ctv-run 1.0.2 → 1.0.3

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/README.md CHANGED
@@ -65,7 +65,8 @@
65
65
  | `port` | | TV가 로드할 URL의 포트 |
66
66
  | `activity` | | 실행할 Activity (기본값: `.MainActivity`) |
67
67
  | `adbPath` | | adb 실행 경로 (기본값: `adb`) |
68
- | `androidAssetsPath` | Static Mode 시 ✅ | dist 파일이 복사될 Android `assets` 폴더 절대 경로 |
68
+ | `androidProjectPath` | Static Mode 시 ✅ | Android 프로젝트 루트 경로 (gradlew가 있는 폴더) |
69
+ | `moduleName` | | Android 모듈명 (기본값: `app`) |
69
70
 
70
71
  **Tizen**
71
72
 
@@ -21,7 +21,7 @@ const ip_1 = require("../utils/ip");
21
21
  const platform_1 = require("../utils/platform");
22
22
  function runFireTv() {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
- var _a, _b, _c, _d, _e, _f, _g, _h;
24
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
25
25
  const args = process.argv.slice(2);
26
26
  const config = (0, config_1.loadConfig)();
27
27
  const getArg = (0, platform_1.makeArgParser)(args);
@@ -31,49 +31,61 @@ function runFireTv() {
31
31
  const pkg = getArg('package') || ((_c = config.fire) === null || _c === void 0 ? void 0 : _c.package);
32
32
  const activity = getArg('activity') || ((_d = config.fire) === null || _d === void 0 ? void 0 : _d.activity) || '.MainActivity';
33
33
  const targetArg = getArg('target');
34
- const androidAssetsPath = getArg('assetsPath') || ((_e = config.fire) === null || _e === void 0 ? void 0 : _e.androidAssetsPath);
34
+ const androidProjectPath = getArg('androidProjectPath') || ((_e = config.fire) === null || _e === void 0 ? void 0 : _e.androidProjectPath);
35
+ const moduleName = getArg('moduleName') || ((_f = config.fire) === null || _f === void 0 ? void 0 : _f.moduleName) || 'app';
35
36
  // 앱 URL 결정 (Live Mode 전용)
36
- const userUrl = getArg('url') || ((_f = config.fire) === null || _f === void 0 ? void 0 : _f.url);
37
- const port = getArg('port') || ((_g = config.fire) === null || _g === void 0 ? void 0 : _g.port) || ((_h = config.common) === null || _h === void 0 ? void 0 : _h.devServerPort) || 3000;
37
+ const userUrl = getArg('url') || ((_g = config.fire) === null || _g === void 0 ? void 0 : _g.url);
38
+ const port = getArg('port') || ((_h = config.fire) === null || _h === void 0 ? void 0 : _h.port) || ((_j = config.common) === null || _j === void 0 ? void 0 : _j.devServerPort) || 3000;
38
39
  const appUrl = userUrl || `http://${(0, ip_1.getLocalIp)()}:${port}`;
39
40
  if (!tvIp || !pkg) {
40
41
  console.error(`\n❌ Fire TV 필수 설정(ip, package)이 누락되었습니다!`);
41
42
  return;
42
43
  }
43
- // Static Mode: dist를 Android assets에 복사 (Tizen/WebOS와 동일한 개념)
44
+ // Static Mode
44
45
  if (targetArg) {
45
- if (!androidAssetsPath) {
46
- console.error(`\n❌ ctv.config.json에 'androidAssetsPath'가 설정되어 있지 않습니다.`);
46
+ if (!androidProjectPath) {
47
+ console.error(`\n❌ ctv.config.json에 'androidProjectPath'가 설정되어 있지 않습니다.`);
47
48
  return;
48
49
  }
49
50
  const distPath = path_1.default.resolve(process.cwd(), targetArg);
50
- const finalAssetsPath = path_1.default.isAbsolute(androidAssetsPath)
51
- ? androidAssetsPath
52
- : path_1.default.resolve(process.cwd(), androidAssetsPath);
51
+ const assetsPath = path_1.default.join(androidProjectPath, moduleName, 'src', 'main', 'assets');
52
+ const apkPath = path_1.default.join(androidProjectPath, moduleName, 'build', 'outputs', 'apk', 'debug', `${moduleName}-debug.apk`);
53
53
  console.log(`-----------------------------------------`);
54
54
  console.log(`📡 Target TV IP : ${tvIp}`);
55
55
  console.log(`📦 Package Name : ${pkg}`);
56
56
  console.log(`🛠 ADB Binary : ${adbBin}`);
57
- console.log(`📦 Mode : 📂 Static Mode (Assets Embedded)`);
58
- console.log(`📂 Path : ${finalAssetsPath}`);
57
+ console.log(`📦 Mode : 📂 Static Mode`);
58
+ console.log(`📂 Project : ${androidProjectPath}`);
59
59
  console.log(`-----------------------------------------`);
60
60
  try {
61
- const parentPath = path_1.default.dirname(finalAssetsPath);
62
- if (!fs_1.default.existsSync(parentPath)) {
63
- console.error(`\n❌ 경로 오류: 부모 폴더가 존재하지 않습니다. (${parentPath})`);
61
+ // assets 복사
62
+ if (!fs_1.default.existsSync(path_1.default.dirname(assetsPath))) {
63
+ console.error(`\n❌ 경로 오류: Android 프로젝트를 찾을 없습니다. (${androidProjectPath})`);
64
64
  return;
65
65
  }
66
- if (fs_1.default.existsSync(finalAssetsPath)) {
67
- (0, child_process_1.execSync)(`rm -rf "${finalAssetsPath}"/*`);
66
+ if (fs_1.default.existsSync(assetsPath)) {
67
+ (0, child_process_1.execSync)(`rm -rf "${assetsPath}"/*`);
68
68
  }
69
69
  else {
70
- (0, child_process_1.execSync)(`mkdir -p "${finalAssetsPath}"`);
70
+ (0, child_process_1.execSync)(`mkdir -p "${assetsPath}"`);
71
71
  }
72
- (0, child_process_1.execSync)(`cp -r "${distPath}"/* "${finalAssetsPath}"`);
72
+ (0, child_process_1.execSync)(`cp -r "${distPath}"/* "${assetsPath}"`);
73
73
  console.log(`✅ Asset copy complete.`);
74
+ // APK 빌드
75
+ console.log(`\n🔨 Building APK...`);
76
+ (0, child_process_1.execSync)(`./gradlew ${moduleName}:assembleDebug`, {
77
+ cwd: androidProjectPath,
78
+ stdio: 'inherit',
79
+ });
80
+ // APK 설치
81
+ console.log(`\n📲 Installing APK...`);
82
+ (0, child_process_1.execSync)(`${adbBin} -s ${tvIp}:5555 install -r "${apkPath}"`, {
83
+ stdio: 'inherit',
84
+ });
85
+ console.log(`✅ APK install complete.`);
74
86
  }
75
87
  catch (err) {
76
- console.error(`\n❌ 파일 복사 에러 발생: ${err.message}`);
88
+ console.error(`\n❌ Static Mode 실패: ${err.message}`);
77
89
  return;
78
90
  }
79
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zsukim/ctv-run",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Smart TV deployment CLI for Vizio, LG webOS, Fire TV, and Samsung Tizen",
5
5
  "keywords": [
6
6
  "ctv",