Skip to content

Commit

Permalink
make cli work and enable admin privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
melo936 committed Sep 28, 2024
1 parent 4f6c4d8 commit 8b9c6ff
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 132 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ jobs:
- run: dart run build_runner build --delete-conflicting-outputs
working-directory: common

- run: dart compile exe common/bin/main.dart -o revitool.exe
- name: Build revitool CLI
run: dart compile exe common/bin/main.dart -o revitool.exe

- run: flutter build windows --build-name=${{ env.NEW_VERSION }} --build-number=1 --obfuscate --split-debug-info=/symbols --dart-define="APP_VERSION=${{ env.NEW_VERSION }}"
- name: Enable Administrator Privileges for revitool CLI app
run: |
mt.exe -manifest common/app.manifest -outputresource:revitool.exe;1
- name: Build revitool GUI
run: flutter build windows --build-name=${{ env.NEW_VERSION }} --build-number=1 --obfuscate --split-debug-info=/symbols --dart-define="APP_VERSION=${{ env.NEW_VERSION }}"
working-directory: gui

- name: Build Installer
Expand Down
25 changes: 0 additions & 25 deletions .vscode/launch.json

This file was deleted.

2 changes: 2 additions & 0 deletions common/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

*.exe
10 changes: 10 additions & 0 deletions common/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
41 changes: 24 additions & 17 deletions common/bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,30 @@ import 'package:args/command_runner.dart';
import 'package:common/common.dart';

Future<void> main(List<String> args) async {
if (args.isNotEmpty) {
if (!WinRegistryService.isSupported || !Directory(ameTemp).existsSync()) {
logger.i(
'Unsupported build detected. Please apply ReviOS on your system',
);
exit(55);
if (!WinRegistryService.isSupported && !Directory(ameTemp).existsSync()) {
logger.i('Unsupported build detected. Please apply ReviOS on your system');
exit(55);
}

if (args.isEmpty) {
final guiPath =
"${mainPath.substring(0, mainPath.lastIndexOf("\\"))}\\revitoolw.exe";
if (await Directory(guiPath).exists()) {
await Process.start('revitoolw', []);
exit(0);
}
final vers =
const String.fromEnvironment("APP_VERSION").replaceAll(".", "");
stdout.writeln("Running Revision Tool $vers");
final runner = CommandRunner<String>("revitool", "Revision Tool CLI")
..addCommand(MSStoreCommand())
..addCommand(DefenderCommand())
..addCommand(WindowsPackageCommand())
..addCommand(PlaybookPatchesCommand());
// ..addCommand(RecommendationCommand());
await runner.run(args);
exit(0);
exit(1);
}

logger.i('Revision Tool CLI is starting');

final runner = CommandRunner<String>("revitool",
"Revision Tool CLI v${const String.fromEnvironment('APP_VERSION')}")
..addCommand(MSStoreCommand())
..addCommand(DefenderCommand())
..addCommand(WindowsPackageCommand())
..addCommand(PlaybookPatchesCommand());
// ..addCommand(RecommendationCommand());
await runner.run(args);
exit(0);
}
2 changes: 1 addition & 1 deletion common/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final tempReviPath = p.join(Directory.systemTemp.path, 'Revision-Tool', 'Logs');

final logger = Logger(
filter: ProductionFilter(),
printer: PrettyPrinter(), // Use the PrettyPrinter to format and print log
printer: PrettyPrinter(),
output: FileOutput(
overrideExisting: true,
file: File.fromUri(
Expand Down
82 changes: 1 addition & 81 deletions common/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ packages:
source: hosted
version: "4.10.0"
collection:
dependency: transitive
dependency: "direct main"
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
Expand All @@ -142,14 +142,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: c1fb2dce3c0085f39dc72668e85f8e0210ec7de05345821ff58530567df345a5
url: "https://pub.dev"
source: hosted
version: "1.9.2"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -350,14 +342,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.6"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
Expand Down Expand Up @@ -422,22 +406,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3
url: "https://pub.dev"
source: hosted
version: "1.1.3"
shelf_web_socket:
dependency: transitive
description:
Expand All @@ -462,22 +430,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.4"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b
url: "https://pub.dev"
source: hosted
version: "2.1.2"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
Expand Down Expand Up @@ -534,14 +486,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: "713a8789d62f3233c46b4a90b174737b2c04cb6ae4500f2aa8b1be8f03f5e67f"
url: "https://pub.dev"
source: hosted
version: "1.25.8"
test_api:
dependency: transitive
description:
Expand All @@ -550,14 +494,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.3"
test_core:
dependency: transitive
description:
name: test_core
sha256: "12391302411737c176b0b5d6491f466b0dd56d4763e347b6714efbaa74d7953d"
url: "https://pub.dev"
source: hosted
version: "0.6.5"
timing:
dependency: transitive
description:
Expand All @@ -574,14 +510,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
url: "https://pub.dev"
source: hosted
version: "14.3.0"
watcher:
dependency: transitive
description:
Expand Down Expand Up @@ -614,14 +542,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.1"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
win32:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions common/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ environment:

# Add regular dependencies here.
dependencies:
args: ^2.4.2
# collection: ^1.19.0

# Network
dio: ^5.7.0
Expand All @@ -22,14 +20,16 @@ dependencies:
logger: ^2.4.0

# Other
args: ^2.5.0
path: ^1.9.0
process_run: ^1.2.0+1
win32_registry: ^1.1.5
xml: ^6.5.0
collection: ^1.18.0

dev_dependencies:
build_runner: ^2.4.12
freezed: ^2.5.7
json_serializable: ^6.8.0
lints: ^4.0.0
test: ^1.24.0
# test: ^1.24.0
4 changes: 2 additions & 2 deletions gui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import 'package:system_theme/system_theme.dart';
import 'package:win32_registry/win32_registry.dart';
import 'package:window_plus/window_plus.dart';

Future<void> main(List<String> args) async {
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();

logger.i('Revision Tool is starting');
logger.i('Revision Tool GUI is starting');

if (WinRegistryService.isSupported) {
logger.i('isSupported is true');
Expand Down
3 changes: 3 additions & 0 deletions gui/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)

# Run as administrator
SET_TARGET_PROPERTIES(${BINARY_NAME} PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS")
2 changes: 1 addition & 1 deletion gui/windows/runner/Runner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ BEGIN
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "Revision Tool" "\0"
VALUE "LegalCopyright", "Copyright (C) MeetRevision. All rights reserved." "\0"
VALUE "OriginalFilename", "gui.exe" "\0"
VALUE "OriginalFilename", "revitoolw.exe" "\0"
VALUE "ProductName", "Revision Tool" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
Expand Down

0 comments on commit 8b9c6ff

Please sign in to comment.