-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: local installation of melos in workspace (#431)
- Loading branch information
Showing
27 changed files
with
537 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CMD /C dart pub global activate --source=path . --executable=melos | ||
CMD /C dart pub global activate --source=path . --executable=melos --overwrite | ||
REM Workaround an issue when running global executables on Windows for the first time. | ||
CMD /C melos > NUL | ||
melos bootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
|
||
dart pub global activate --source="path" . --executable="melos" | ||
dart pub global activate --source="path" . --executable="melos" --overwrite | ||
melos bootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,11 @@ | ||
// ignore_for_file: avoid_print | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:args/command_runner.dart'; | ||
import 'package:cli_launcher/cli_launcher.dart'; | ||
import 'package:melos/src/command_runner.dart'; | ||
import 'package:melos/src/common/exception.dart'; | ||
import 'package:melos/src/common/utils.dart' as utils; | ||
import 'package:melos/src/workspace_configs.dart'; | ||
import 'package:melos/version.g.dart'; | ||
import 'package:pub_updater/pub_updater.dart'; | ||
|
||
Future<void> main(List<String> arguments) async { | ||
if (arguments.contains('--version') || arguments.contains('-v')) { | ||
print(melosVersion); | ||
// No version checks on CIs. | ||
if (utils.isCI) return; | ||
|
||
// Check for updates. | ||
final pubUpdater = PubUpdater(); | ||
const packageName = 'melos'; | ||
final isUpToDate = await pubUpdater.isUpToDate( | ||
packageName: packageName, | ||
currentVersion: melosVersion, | ||
Future<void> main(List<String> arguments) async => launchExecutable( | ||
arguments, | ||
LaunchConfig( | ||
name: ExecutableName('melos'), | ||
launchFromSelf: false, | ||
entrypoint: melosEntryPoint, | ||
), | ||
); | ||
if (!isUpToDate) { | ||
final latestVersion = await pubUpdater.getLatestVersion(packageName); | ||
final shouldUpdate = utils.promptBool( | ||
message: 'There is a new version of $packageName available ' | ||
'($latestVersion). Would you like to update?', | ||
defaultsTo: true, | ||
defaultsToWithoutPrompt: false, | ||
); | ||
if (shouldUpdate) { | ||
await pubUpdater.update(packageName: packageName); | ||
print('$packageName has been updated to version $latestVersion.'); | ||
} | ||
} | ||
|
||
return; | ||
} | ||
try { | ||
final config = shouldUseEmptyConfig(arguments) | ||
? MelosWorkspaceConfig.empty() | ||
: await MelosWorkspaceConfig.fromDirectory(Directory.current); | ||
await MelosCommandRunner(config).run(arguments); | ||
} on MelosException catch (err) { | ||
stderr.writeln(err.toString()); | ||
exitCode = 1; | ||
} on UsageException catch (err) { | ||
stderr.writeln(err.toString()); | ||
exitCode = 1; | ||
} catch (err) { | ||
exitCode = 1; | ||
rethrow; | ||
} | ||
} | ||
|
||
bool shouldUseEmptyConfig(List<String> arguments) { | ||
final willShowHelp = arguments.isEmpty || | ||
arguments.contains('--help') || | ||
arguments.contains('-h'); | ||
return willShowHelp; | ||
} |
Oops, something went wrong.