Skip to content

Commit

Permalink
feat: intellij & Windows support (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Salakar authored Aug 24, 2020
1 parent 7980e67 commit 86a87a6
Show file tree
Hide file tree
Showing 32 changed files with 1,062 additions and 126 deletions.
39 changes: 33 additions & 6 deletions lib/src/command/bootstrap.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import 'dart:io';

import 'package:args/command_runner.dart' show Command;
import 'package:melos/src/common/intellij_project.dart';

import '../command_runner.dart';
import '../common/logger.dart';
Expand All @@ -23,6 +41,7 @@ class BootstrapCommand extends Command {
'${logger.ansi.yellow}\$${logger.ansi.noColor} ${logger.ansi.emphasized("melos bootstrap")}');
logger.stdout(
' └> ${logger.ansi.cyan}${logger.ansi.emphasized(currentWorkspace.path)}${logger.ansi.noColor}\n');
var successMessage = '${logger.ansi.green}SUCCESS${logger.ansi.noColor}';
var bootstrapProgress = logger.progress('Bootstrapping project');
await currentWorkspace.generatePubspecFile();

Expand All @@ -34,16 +53,22 @@ class BootstrapCommand extends Command {
exit(1);
}

bootstrapProgress.finish(
message: '${logger.ansi.green}SUCCESS${logger.ansi.noColor}',
showTiming: true);
bootstrapProgress.finish(message: successMessage, showTiming: true);
if (Platform.isWindows) {
// TODO Manual print finish status as it doesn't show on Windows, bug with progress library.
print(' > $successMessage');
}

var linkingProgress = logger.progress('Linking project packages');

await currentWorkspace.linkPackages();
currentWorkspace.clean(cleanPackages: false);

linkingProgress.finish(
message: '${logger.ansi.green}SUCCESS${logger.ansi.noColor}',
showTiming: true);
linkingProgress.finish(message: successMessage, showTiming: true);
if (Platform.isWindows) {
// TODO Manual print finish status as it doesn't show on Windows, bug with progress library.
print(' > $successMessage');
}

if (currentWorkspace.config.scripts.containsKey('postbootstrap')) {
logger.stdout('Running postbootstrap script...\n');
Expand All @@ -59,5 +84,7 @@ class BootstrapCommand extends Command {
});
logger.stdout(
'\n -> ${currentWorkspace.packages.length} plugins bootstrapped');

await IntellijProject.fromWorkspace(currentWorkspace).writeFiles();
}
}
23 changes: 21 additions & 2 deletions lib/src/command/clean.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import 'package:args/command_runner.dart' show Command;
import 'package:melos/src/common/intellij_project.dart';

import '../command_runner.dart';
import '../common/logger.dart';
Expand All @@ -13,17 +31,18 @@ class CleanCommand extends Command {

@override
final String description =
'Clean this workspace and all packages. This deletes the temporary pub files such as ".packages" & ".flutter-plugins". Supports all package filtering options.';
'Clean this workspace and all packages. This deletes the temporary pub & ide files such as ".packages" & ".flutter-plugins". Supports all package filtering options.';

@override
void run() async {
logger.stdout('Cleaning workspace...');
currentWorkspace.clean();
await IntellijProject.fromWorkspace(currentWorkspace).cleanFiles();
if (currentWorkspace.config.scripts.containsKey('postclean')) {
logger.stdout('Running postclean script...\n');
await MelosCommandRunner.instance.run(['run', 'postclean']);
}
logger.stdout(
'Workspace cleaned, you will need to run the bootstrap command again.');
'\nWorkspace cleaned. You will need to run the bootstrap command again to use this workspace.');
}
}
19 changes: 18 additions & 1 deletion lib/src/command/exec.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import 'dart:io';

import 'package:args/command_runner.dart' show Command;
Expand Down Expand Up @@ -25,7 +42,7 @@ class ExecCommand extends Command {
defaultsTo: false,
negatable: true,
help:
'Wether exec should fail fast and not execute the script in further packages if the script fails in a individual package.');
'Whether exec should fail fast and not execute the script in further packages if the script fails in a individual package.');
}

@override
Expand Down
17 changes: 17 additions & 0 deletions lib/src/command/run.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import 'dart:io';

import 'package:args/command_runner.dart' show Command;
Expand Down
17 changes: 17 additions & 0 deletions lib/src/command/unpublished.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import 'dart:io';

import 'package:args/command_runner.dart' show Command;
Expand Down
18 changes: 18 additions & 0 deletions lib/src/command_runner.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import 'dart:io';

import 'package:args/args.dart';
Expand Down Expand Up @@ -68,6 +85,7 @@ class MelosCommandRunner extends CommandRunner {
// TODO(salakar): log init help once init command complete
logger.stderr(
'Your current directory does not appear to be a valid workspace.');
logger.stderr('Does the "melos.yaml" file exist in the root?');
exit(1);
}

Expand Down
Loading

0 comments on commit 86a87a6

Please sign in to comment.