xcode file add 추가
This commit is contained in:
parent
4ac1f5671e
commit
550ece1c94
6 changed files with 115 additions and 10 deletions
57
lib/oto/commands/build/xcodeproj.dart
Normal file
57
lib/oto/commands/build/xcodeproj.dart
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:dart_framework/platform/process.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
||||
class XcodeprojAddFile extends Command {
|
||||
Function? get error => null;
|
||||
String rubyCode = '''
|
||||
# add_file_xcodeproj.rb
|
||||
# encoding: UTF-8
|
||||
require 'xcodeproj'
|
||||
|
||||
project = Xcodeproj::Project.open('{XCODEPROJ_PATH}')
|
||||
target = project.targets.find { |t| t.name == '{TARGET}' }
|
||||
group = project.main_group
|
||||
file_ref = group.new_file('{ADD_FILE_PATH}')
|
||||
|
||||
# 📌 타겟에 파일 포함
|
||||
build_file = target.add_file_references([file_ref]).first
|
||||
|
||||
# 📌 Copy Bundle Resources에 명시적으로 추가
|
||||
target.resources_build_phase.add_file_reference(file_ref)
|
||||
|
||||
project.save
|
||||
|
||||
puts "✅ {ADD_FILE_PATH} 파일이 프로젝트에 추가되고, Copy Bundle Resources에 포함되었습니다."
|
||||
''';
|
||||
|
||||
/*
|
||||
* sudo gem install xcodeproj
|
||||
*/
|
||||
|
||||
@override
|
||||
Future execute(DataCommand command) async {
|
||||
var data = DataXcodeprojAddFile.fromJson(getParam(command));
|
||||
var template = rubyCode
|
||||
.replaceAll('{TARGET}', data.target)
|
||||
.replaceAll('{ADD_FILE_PATH}', data.addFilePath)
|
||||
.replaceAll('{XCODEPROJ_PATH}', data.xcodeprojPath);
|
||||
|
||||
var file = File('${data.workspace}/add_file_xcodeproj.rb');
|
||||
file.writeAsStringSync(template, flush: true);
|
||||
|
||||
var shell = StringBuffer();
|
||||
shell.write('export LANG=en_US.UTF-8 && cd ${data.workspace}');
|
||||
shell.write(' && ruby add_file_xcodeproj.rb');
|
||||
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
workspace: workspace,
|
||||
printStderr: true,
|
||||
logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import 'package:oto_cli/oto/commands/build/build_flutter.dart';
|
|||
import 'package:oto_cli/oto/commands/build/build_ios.dart';
|
||||
import 'package:oto_cli/oto/commands/build/build_msbuild.dart';
|
||||
import 'package:oto_cli/oto/commands/build/testflight_ios.dart';
|
||||
import 'package:oto_cli/oto/commands/build/xcodeproj.dart';
|
||||
import 'package:oto_cli/oto/commands/file/directory.dart';
|
||||
import 'package:oto_cli/oto/commands/file/file.dart';
|
||||
import 'package:oto_cli/oto/commands/file/file_diff_check.dart';
|
||||
|
|
@ -58,6 +59,7 @@ enum CommandType {
|
|||
TestflightUpload,
|
||||
TestflightStatusCheck,
|
||||
TestflightDistribute,
|
||||
XcodeprojAddFile,
|
||||
BuildMSBuild,
|
||||
CodeSign,
|
||||
CodeSignVerify,
|
||||
|
|
@ -131,6 +133,7 @@ abstract class Command {
|
|||
CommandType.TestflightUpload: () => TestflightUpload(),
|
||||
CommandType.TestflightStatusCheck: () => TestflightStatusCheck(),
|
||||
CommandType.TestflightDistribute: () => TestflightDistribute(),
|
||||
CommandType.XcodeprojAddFile: () => XcodeprojAddFile(),
|
||||
CommandType.BuildMSBuild: () => BuildMSBuild(),
|
||||
CommandType.CodeSign: () => CodeSign(),
|
||||
CommandType.CodeSignVerify: () => CodeSignVerify(),
|
||||
|
|
|
|||
|
|
@ -18,23 +18,23 @@ class JsonBase extends Command {
|
|||
var keys = item.from.split('.');
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if(arrReg.hasMatch(key)) {
|
||||
if (arrReg.hasMatch(key)) {
|
||||
//array case
|
||||
var match = arrReg.firstMatch(key);
|
||||
if(match != null && match.groupCount != 0) {
|
||||
if (match != null && match.groupCount != 0) {
|
||||
print(match.groupCount);
|
||||
var arrKey = match.group(1);
|
||||
var arrIndex = int.parse(match.group(2)!);
|
||||
if (temp.containsKey(arrKey)) {
|
||||
var arr = temp[arrKey] as List;
|
||||
if(arr.length > arrIndex) {
|
||||
if (arr.length > arrIndex) {
|
||||
var value = arr[arrIndex];
|
||||
if (i == keys.length - 1) {
|
||||
await setProperty(item.setValue, value.toString());
|
||||
break;
|
||||
} else {
|
||||
temp = value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw Exception('Out of range: "$key" in $item');
|
||||
}
|
||||
|
|
@ -56,8 +56,6 @@ class JsonBase extends Command {
|
|||
throw Exception('Not exist key: "$key" in $item');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
|
|
@ -114,11 +112,17 @@ class JsonWriterFile extends Command {
|
|||
temp = temp[keys[i]];
|
||||
}
|
||||
} else {
|
||||
throw Exception('Not exist key: "$key" in $item');
|
||||
if (i == keys.length - 1) {
|
||||
temp[keys[i]] = item.value;
|
||||
} else {
|
||||
temp[keys[i]] = <String, dynamic>{};
|
||||
temp = temp[keys[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
content = jsonPrettyEncode(json);
|
||||
print(content);
|
||||
file.writeAsStringSync(content, flush: true);
|
||||
} on Exception catch (e) {
|
||||
throw Exception('Json parsing error: $e');
|
||||
|
|
|
|||
|
|
@ -364,7 +364,6 @@ class DataTestflightStatusCheck extends DataParam {
|
|||
Map<String, dynamic> toJson() => _$DataTestflightStatusCheckToJson(this);
|
||||
}
|
||||
|
||||
|
||||
//TestflightUpload
|
||||
@JsonSerializable()
|
||||
class DataTestflightDistribute extends DataParam {
|
||||
|
|
@ -402,6 +401,21 @@ class DataPublishiOS extends DataParam {
|
|||
Map<String, dynamic> toJson() => _$DataPublishiOSToJson(this);
|
||||
}
|
||||
|
||||
//DataXcodeprojAddFile
|
||||
@JsonSerializable()
|
||||
class DataXcodeprojAddFile extends DataParam {
|
||||
DataXcodeprojAddFile();
|
||||
|
||||
late String addFilePath;
|
||||
late String target;
|
||||
late String xcodeprojPath;
|
||||
|
||||
factory DataXcodeprojAddFile.fromJson(Map<String, dynamic> json) =>
|
||||
_$DataXcodeprojAddFileFromJson(json);
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$DataXcodeprojAddFileToJson(this);
|
||||
}
|
||||
|
||||
//FTP
|
||||
@JsonSerializable()
|
||||
class DataFTP extends DataParam {
|
||||
|
|
@ -1184,4 +1198,3 @@ class DataDelay extends DataParam {
|
|||
@override
|
||||
Map<String, dynamic> toJson() => _$DataDelayToJson(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ const _$CommandTypeEnumMap = {
|
|||
CommandType.TestflightUpload: 'TestflightUpload',
|
||||
CommandType.TestflightStatusCheck: 'TestflightStatusCheck',
|
||||
CommandType.TestflightDistribute: 'TestflightDistribute',
|
||||
CommandType.XcodeprojAddFile: 'XcodeprojAddFile',
|
||||
CommandType.BuildMSBuild: 'BuildMSBuild',
|
||||
CommandType.CodeSign: 'CodeSign',
|
||||
CommandType.CodeSignVerify: 'CodeSignVerify',
|
||||
|
|
@ -719,6 +720,33 @@ Map<String, dynamic> _$DataPublishiOSToJson(DataPublishiOS instance) =>
|
|||
'destinationPath': instance.destinationPath,
|
||||
};
|
||||
|
||||
DataXcodeprojAddFile _$DataXcodeprojAddFileFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
DataXcodeprojAddFile()
|
||||
..workspace = json['workspace'] as String?
|
||||
..passExitCodes = (json['passExitCodes'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
.toList()
|
||||
..setResult = json['setResult'] as String?
|
||||
..setExitCode = json['setExitCode'] as String?
|
||||
..showPrint = json['showPrint'] as bool?
|
||||
..addFilePath = json['addFilePath'] as String
|
||||
..target = json['target'] as String
|
||||
..xcodeprojPath = json['xcodeprojPath'] as String;
|
||||
|
||||
Map<String, dynamic> _$DataXcodeprojAddFileToJson(
|
||||
DataXcodeprojAddFile instance) =>
|
||||
<String, dynamic>{
|
||||
'workspace': instance.workspace,
|
||||
'passExitCodes': instance.passExitCodes,
|
||||
'setResult': instance.setResult,
|
||||
'setExitCode': instance.setExitCode,
|
||||
'showPrint': instance.showPrint,
|
||||
'addFilePath': instance.addFilePath,
|
||||
'target': instance.target,
|
||||
'xcodeprojPath': instance.xcodeprojPath,
|
||||
};
|
||||
|
||||
DataFTP _$DataFTPFromJson(Map<String, dynamic> json) => DataFTP()
|
||||
..workspace = json['workspace'] as String?
|
||||
..passExitCodes = (json['passExitCodes'] as List<dynamic>?)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ dependencies:
|
|||
xml: ^6.3.0
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^5.0.0
|
||||
lints: ^6.0.0
|
||||
test: ^1.24.9
|
||||
build_runner: ^2.1.4
|
||||
json_serializable: ^6.0.1
|
||||
|
|
|
|||
Loading…
Reference in a new issue