Skip to content

Commit

Permalink
docs: add doc for dart
Browse files Browse the repository at this point in the history
  • Loading branch information
CaiJingLong committed May 19, 2023
1 parent 8acb6e6 commit d7995b3
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"MD041": false
}
67 changes: 67 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2023-05-19

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`github_action_core` - `v0.1.0+3`](#github_action_core---v0103)

---

#### `github_action_core` - `v0.1.0+3`

- **REVERT**: changelog. ([f324d6a4](https://github.com/dart-action/tools.git/commit/f324d6a405fbe6a081bbee43109492ed42c0b862))


## 2023-05-19

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`github_action_core` - `v0.1.0+2`](#github_action_core---v0102)

---

#### `github_action_core` - `v0.1.0+2`

- **DOCS**: utils. ([4f2c0147](https://github.com/fluttercandies/flutter_image_compress/commit/4f2c014743b0a803c7fde554044baf1fc08a36df))


## 2023-05-19

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`github_action_core` - `v0.1.0+1`](#github_action_core---v0101)

---

#### `github_action_core` - `v0.1.0+1`

- **DOCS**: Add for command. ([a68b967a](https://github.com/fluttercandies/flutter_image_compress/commit/a68b967ab9fab2656cdff9fbe1af89cc8bedb830))

6 changes: 3 additions & 3 deletions melos.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: flutter_image_compress
repository: https://github.com/fluttercandies/flutter_image_compress
name: github-action-tools-workspace
repository: https://github.com/dart-action/tools

packages:
- packages/**
Expand All @@ -14,7 +14,7 @@ scripts:
format:
exec: dart format --set-exit-if-changed .
cp_files:
exec: cp ../../LICENSE .
exec: cp ../../LICENSE . && cp ../../.markdownlint.jsonc .

sdkPath: auto

Expand Down
3 changes: 3 additions & 0 deletions packages/github_action_core/.markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"MD041": false
}
2 changes: 0 additions & 2 deletions packages/github_action_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Changelog

## 0.1.0

- Initial version.
14 changes: 14 additions & 0 deletions packages/github_action_core/lib/src/command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,33 @@ import 'package:uuid/uuid.dart';

import 'utils.dart';

/// Issues a command to the job step.
void issueCommand(
String command, Map<String, dynamic> properties, dynamic message) {
final cmd = Command(command, properties, message);
stdout.write('${cmd.toString()}${Platform.operatingSystem}');
}

/// Issues a command with a given name and optional message.
void issue(String name, {String message = ''}) {
issueCommand(name, {}, message);
}

/// The command string prefix.
const _cmdString = '::';

/// Represents a command with properties and a message.
class Command {
/// The command name.
String command;

/// The properties associated with the command.
final Map<String, dynamic> properties;

/// The message of the command.
final String message;

/// Creates a new instance of the [Command] class.
Command(this.command, this.properties, this.message) {
if (command.isEmpty) {
command = 'missing.command';
Expand Down Expand Up @@ -55,13 +65,15 @@ class Command {
}
}

/// Escapes the command data by replacing special characters.
String escapeData(dynamic s) {
return toCommandValue(s)
.replaceAll('%', '%25')
.replaceAll('\r', '%0D')
.replaceAll('\n', '%0A');
}

/// Escapes the command property by replacing special characters.
String escapeProperty(dynamic s) {
return toCommandValue(s)
.replaceAll('%', '%25')
Expand All @@ -71,6 +83,7 @@ String escapeProperty(dynamic s) {
.replaceAll(',', '%2C');
}

/// Issues a file command with a command name and a message.
void issueFileCommand(String command, dynamic message) {
final filePath = Platform.environment['GITHUB_$command'];
if (filePath == null) {
Expand All @@ -86,6 +99,7 @@ void issueFileCommand(String command, dynamic message) {
mode: FileMode.append, encoding: utf8);
}

/// Prepares a key-value message with a delimiter for a command.
String prepareKeyValueMessage(String key, dynamic value) {
final delimiter = 'ghadelimiter_${Uuid().v4()}';
final convertedValue = toCommandValue(value);
Expand Down
2 changes: 2 additions & 0 deletions packages/github_action_core/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';

import 'core.dart';

/// Converts the input to a command value.
String toCommandValue(dynamic input) {
if (input == null) {
return '';
Expand All @@ -11,6 +12,7 @@ String toCommandValue(dynamic input) {
return jsonEncode(input);
}

/// Converts the annotation properties to command properties.
Map<String, dynamic> toCommandProperties(
AnnotationProperties? annotationProperties) {
if (annotationProperties == null) {
Expand Down

0 comments on commit d7995b3

Please sign in to comment.