Skip to content

Commit

Permalink
- added new 'env' task
Browse files Browse the repository at this point in the history
- updated readme
- updated icons
  • Loading branch information
hey24sheep committed Jul 31, 2021
1 parent 143586a commit e08880c
Show file tree
Hide file tree
Showing 29 changed files with 1,677 additions and 39 deletions.
64 changes: 47 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

Latest [Flutter](http://flutter.io) tasks for [Azure DevOps](https://azure.microsoft.com/en-gb/services/devops/).

Initially a [fork](https://github.com/hey24sheep/vsts-flutter-tasks) maintained/updated by me of the awesome work done by original author [Github](https://github.com/aloisdeniel/vsts-flutter-tasks). As per people's request, This is now a separate repo as this is now an advanced/latest extension with more features.
Initially a [fork](https://github.com/hey24sheep/vsts-flutter-tasks) maintained by me of the awesome work done by original author [Github](https://github.com/aloisdeniel/vsts-flutter-tasks). As per people's request, this is now a separate repo as this is now an advanced/latest extension with more features.

> NOTE : I will no longer maintain my fork instead this repository will be updated, as this has developed into a lot more than the original extension.
NOTE : I will no longer maintain my fork instead this repository will be updated as the fork is way ahead and with more features than the original repo.

## Support

Expand All @@ -15,21 +16,15 @@ Don't forget to star this repo, thanks.
</a>
</p>

## Installation

Installation can be done using [Visual Studio MarketPlace](https://marketplace.visualstudio.com/items?itemName=hey24sheep.flutter).

## Source Code
<br/>

Source code can be found on [Github](https://github.com/hey24sheep/azure-flutter-tasks).

Previous fork : [Github](https://github.com/hey24sheep/vsts-flutter-tasks)
## Installation & Usage

Original repo : [Github](https://github.com/aloisdeniel/vsts-flutter-tasks).
Installation can be done using [Visual Studio MarketPlace](https://marketplace.visualstudio.com/items?itemName=hey24sheep.flutter). Add the tasks to your build definition.

## Usage
<br/>

Add the tasks to your build definition.
# Pipeline Tasks

### Install

Expand Down Expand Up @@ -99,7 +94,30 @@ Launch a Flutter command with custom arguments.
* Select the `projectDirectory` that contains the `pubspec.yaml` file.
* _(Optional)_. Set `flutterDirectory` to set path to the Flutter SDK if you were not using `Flutter Install` task before this one

## FAQ
### Env

![](images/step_env.png)

Task to create the environment variables `FlutterToolPath`, `FlutterPubCachePath` and `DartToolPath`.

* Pick the `Flutter path from` either to `Custom Path` or `File Path`.
* Select the `Custom Path` to give a path string like "`$(Agent.ToolsDirectory)/<yourPath>/flutter`"
* Select the `File Path` to set path to the Flutter SDK

> NOTE : Do not give path to 'bin' folder
<br/>

# Environment Variables
Environment variables created by the `Install` or `Env` tasks are :

* `$(FlutterToolPath)` - can be used as "`$(FlutterToolPath)/flutter packages get`"
* `$(FlutterPubCachePath)` can be used as "`$(FlutterPubCachePath)/pubver set $(Version)`"
* `$(DartToolPath)` - can be used as "`$(DartToolPath)/dart prog.dart arg1`"

<br/>

# FAQ


> Flutter command isn't recognized ?
Expand All @@ -108,15 +126,27 @@ Make sure that you have a `Flutter Install` at the beginning of your definition.

> Can I run a custom Flutter command ?
Yes, right after the `Flutter Install` task, a `FlutterToolPath` environment variable points to the `bin` of the Flutter SDK directory. You just have to use `$(FlutterToolPath)` in your following tasks. Example: "$(FlutterToolPath)/flutter packages get"
Yes, right after the `Flutter Install` task, a `FlutterToolPath` environment variable points to the `bin` of the Flutter SDK directory. You just have to use `$(FlutterToolPath)` in your following tasks. Example: "`$(FlutterToolPath)/flutter packages get`"

> Can I run Dart program ?
Yes, right after the `Flutter Install` task, a `DartToolPath` environment variable points to the `bin` of the Dart SDK directory. You just have to use `$(DartToolPath)` in your following tasks. Example: "$(DartToolPath)/dart program.dart arg1 arg2"
Yes, right after the `Flutter Install` task, a `DartToolPath` environment variable points to the `bin` of the Dart SDK directory. You just have to use `$(DartToolPath)` in your following tasks. Example: "`$(DartToolPath)/dart program.dart arg1 arg2`"

> Can I access Flutter's pub-cache ?
Yes, right after the `Flutter Install` task, a `FlutterPubCachePath` environment variable points to the `pub-cache` directory that Flutter installs all depdencies. You just have to use `$(FlutterPubCachePath)` in your following tasks. Example: "$(FlutterPubCachePath)/pubver set $(Version)"
Yes, right after the `Flutter Install` task, a `FlutterPubCachePath` environment variable points to the `pub-cache` directory that Flutter installs all depdencies. You just have to use `$(FlutterPubCachePath)` in your following tasks. Example: "`$(FlutterPubCachePath)/pubver set $(Version)`"

<br/>

## Source Code

Source code can be found on [Github](https://github.com/hey24sheep/azure-flutter-tasks).

Previous fork : [Github](https://github.com/hey24sheep/vsts-flutter-tasks)

Original repo : [Github](https://github.com/aloisdeniel/vsts-flutter-tasks).

<br/>

## License

Expand Down
3 changes: 3 additions & 0 deletions publish-build-with-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ tsc
cd ../command
npm install
tsc
cd ../env
npm install
tsc
cd ../../

# Create extension
Expand Down
2 changes: 2 additions & 0 deletions publish-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ cd ../analyze
tsc
cd ../command
tsc
cd ../env
tsc
cd ../../

# Create extension
Expand Down
4 changes: 2 additions & 2 deletions tasks/analyze/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tasks/analyze/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flutteranalyze",
"version": "0.2.35",
"version": "0.2.36",
"description": "Flutter Analyze Task",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion tasks/analyze/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 35
"Patch": 36
},
"groups": [],
"instanceNameFormat": "Flutter Analyze",
Expand Down
4 changes: 2 additions & 2 deletions tasks/build/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tasks/build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flutterbuild",
"version": "0.2.44",
"version": "0.2.45",
"description": "Flutter Build Task",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion tasks/build/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 44
"Patch": 45
},
"groups": [],
"instanceNameFormat": "Flutter Build $(target)",
Expand Down
4 changes: 2 additions & 2 deletions tasks/command/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tasks/command/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fluttercommand",
"version": "0.2.33",
"version": "0.2.34",
"description": "Flutter Command Task",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion tasks/command/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 34
"Patch": 35
},
"groups": [],
"instanceNameFormat": "Flutter Command",
Expand Down
Binary file added tasks/env/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tasks/env/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions tasks/env/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const task = require("azure-pipelines-task-lib");
const path = require("path");
// paths
const FLUTTER_EXE_RELATIVEPATH = 'bin';
const DART_EXE_RELATIVEPATH = 'cache/dart-sdk/bin';
const FLUTTER_PUB_CACHE_RELATIVEPATH = '.pub-cache/bin';
// env variables used as $('<env_var_name>') like $(FlutterToolPath)/flutter
const FLUTTER_TOOL_PATH_ENV_VAR = 'FlutterToolPath';
const FLUTTER_PUBCACHE_PATH_ENV_VAR = 'FlutterPubCachePath';
const DART_TOOL_PATH_ENV_VAR = 'DartToolPath';
function main() {
return __awaiter(this, void 0, void 0, function* () {
// 1. Get where to get the path from
let pathType = task.getInput('pathType', true);
// 1.1 Getting path
var flutterDir = task.getInput(pathType, true);
// 2. Creating flutter environment variable
let fullFlutterPath = path.join(flutterDir, FLUTTER_EXE_RELATIVEPATH);
task.debug(`Set ${FLUTTER_TOOL_PATH_ENV_VAR} with '${fullFlutterPath}'`);
task.setVariable(FLUTTER_TOOL_PATH_ENV_VAR, fullFlutterPath);
// 2.1 Create flutter pub-cache environment variable
let fullPubCachePath = path.join(flutterDir, FLUTTER_PUB_CACHE_RELATIVEPATH);
task.debug(`Set ${DART_TOOL_PATH_ENV_VAR} with '${fullPubCachePath}'`);
task.setVariable(FLUTTER_PUBCACHE_PATH_ENV_VAR, fullPubCachePath);
// 2.2 Create dart environment variable
let fullDartPath = path.join(fullFlutterPath, DART_EXE_RELATIVEPATH);
task.debug(`Set ${DART_TOOL_PATH_ENV_VAR} with '${fullDartPath}'`);
task.setVariable(DART_TOOL_PATH_ENV_VAR, fullDartPath);
task.setResult(task.TaskResult.Succeeded, "Environment Variables Set");
});
}
main().catch(error => {
task.setResult(task.TaskResult.Failed, error);
});
41 changes: 41 additions & 0 deletions tasks/env/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as task from "azure-pipelines-task-lib";
import * as path from 'path';

// paths
const FLUTTER_EXE_RELATIVEPATH = 'bin';
const DART_EXE_RELATIVEPATH = 'cache/dart-sdk/bin';
const FLUTTER_PUB_CACHE_RELATIVEPATH = '.pub-cache/bin';

// env variables used as $('<env_var_name>') like $(FlutterToolPath)/flutter
const FLUTTER_TOOL_PATH_ENV_VAR: string = 'FlutterToolPath';
const FLUTTER_PUBCACHE_PATH_ENV_VAR: string = 'FlutterPubCachePath';
const DART_TOOL_PATH_ENV_VAR: string = 'DartToolPath';

async function main(): Promise<void> {
// 1. Get where to get the path from
let pathType = task.getInput('pathType', true);

// 1.1 Getting path
var flutterDir = task.getInput(pathType, true);

// 2. Creating flutter environment variable
let fullFlutterPath: string = path.join(flutterDir, FLUTTER_EXE_RELATIVEPATH);
task.debug(`Set ${FLUTTER_TOOL_PATH_ENV_VAR} with '${fullFlutterPath}'`);
task.setVariable(FLUTTER_TOOL_PATH_ENV_VAR, fullFlutterPath);

// 2.1 Create flutter pub-cache environment variable
let fullPubCachePath: string = path.join(flutterDir, FLUTTER_PUB_CACHE_RELATIVEPATH);
task.debug(`Set ${DART_TOOL_PATH_ENV_VAR} with '${fullPubCachePath}'`);
task.setVariable(FLUTTER_PUBCACHE_PATH_ENV_VAR, fullPubCachePath);

// 2.2 Create dart environment variable
let fullDartPath: string = path.join(fullFlutterPath, DART_EXE_RELATIVEPATH);
task.debug(`Set ${DART_TOOL_PATH_ENV_VAR} with '${fullDartPath}'`);
task.setVariable(DART_TOOL_PATH_ENV_VAR, fullDartPath);

task.setResult(task.TaskResult.Succeeded, "Environment Variables Set");
}

main().catch(error => {
task.setResult(task.TaskResult.Failed, error);
});
Loading

0 comments on commit e08880c

Please sign in to comment.