Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: intellij & Windows support #7

Merged
merged 16 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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