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(mason): export StringCaseExtensions #679

Merged
merged 5 commits into from Dec 23, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/mason_cli.yaml
Expand Up @@ -93,4 +93,4 @@ jobs:
dart pub global activate pana

- name: Verify Pub Score
run: ../../tool/verify_pub_score.sh
run: ../../tool/verify_pub_score.sh 100
1 change: 1 addition & 0 deletions packages/mason/lib/mason.dart
Expand Up @@ -36,5 +36,6 @@ export 'src/mason_lock_json.dart' show MasonLockJson;
export 'src/mason_yaml.dart' show BrickLocation, GitPath, MasonYaml;
export 'src/path.dart' show canonicalize;
export 'src/render.dart' show RenderTemplate;
export 'src/string_case_extensions.dart' show StringCaseExtensions;
export 'src/version.dart' show packageVersion;
export 'src/yaml_encode.dart' show Yaml;
8 changes: 4 additions & 4 deletions packages/mason/lib/src/render.dart
@@ -1,7 +1,7 @@
import 'dart:convert';

import 'package:mason/mason.dart';
import 'package:mustache_template/mustache_template.dart';
import 'package:recase/recase.dart';

final _newlineInRegExp = RegExp(r'(\\\r\n|\\\r|\\\n)');
final _newlineOutRegExp = RegExp(r'(\r\n|\r|\n)');
Expand Down Expand Up @@ -37,10 +37,10 @@ final _builtInLambdas = <String, LambdaFunction>{
'headerCase': (ctx) => ctx.renderString().headerCase,

/// lower case
'lowerCase': (ctx) => ctx.renderString().toLowerCase(),
'lowerCase': (ctx) => ctx.renderString().lowerCase,

/// {{ mustache case }}
'mustacheCase': (ctx) => '{{ ${ctx.renderString()} }}',
'mustacheCase': (ctx) => ctx.renderString().mustacheCase,

/// PascalCase
'pascalCase': (ctx) => ctx.renderString().pascalCase,
Expand All @@ -61,7 +61,7 @@ final _builtInLambdas = <String, LambdaFunction>{
'titleCase': (ctx) => ctx.renderString().titleCase,

/// UPPER CASE
'upperCase': (ctx) => ctx.renderString().toUpperCase(),
'upperCase': (ctx) => ctx.renderString().upperCase,
};

/// [Map] of all the built-in variables.
Expand Down
43 changes: 43 additions & 0 deletions packages/mason/lib/src/string_case_extensions.dart
@@ -0,0 +1,43 @@
import 'package:recase/recase.dart' show ReCase;

/// Built-in [String] casing extensions.
extension StringCaseExtensions on String {
/// camelCase
String get camelCase => ReCase(this).camelCase;

/// CONSTANT_CASE
String get constantCase => ReCase(this).constantCase;

/// dot.case
String get dotCase => ReCase(this).dotCase;

/// Header-Case
String get headerCase => ReCase(this).headerCase;

/// lower case
String get lowerCase => toLowerCase();

/// {{ mustache case }}
String get mustacheCase => '{{ $this }}';

/// PascalCase
String get pascalCase => ReCase(this).pascalCase;

/// param-case
String get paramCase => ReCase(this).paramCase;

/// path/case
String get pathCase => ReCase(this).pathCase;

/// Sentence case
String get sentenceCase => ReCase(this).sentenceCase;

/// snake_case
String get snakeCase => ReCase(this).snakeCase;

/// Title Case
String get titleCase => ReCase(this).titleCase;

/// UPPER CASE
String get upperCase => toUpperCase();
}
1 change: 0 additions & 1 deletion packages/mason_cli/lib/src/commands/bundle.dart
Expand Up @@ -4,7 +4,6 @@ import 'dart:io';
import 'package:mason/mason.dart';
import 'package:mason_cli/src/command.dart';
import 'package:path/path.dart' as path;
import 'package:recase/recase.dart';

/// Supported Bundle Types
enum BundleType {
Expand Down
1 change: 0 additions & 1 deletion packages/mason_cli/lib/src/commands/new.dart
Expand Up @@ -3,7 +3,6 @@ import 'dart:io';
import 'package:mason/mason.dart';
import 'package:mason_cli/src/command.dart';
import 'package:path/path.dart' as p;
import 'package:recase/recase.dart';

/// {@template new_command}
/// `mason new` command which creates a new brick.
Expand Down
1 change: 0 additions & 1 deletion packages/mason_cli/pubspec.yaml
Expand Up @@ -19,7 +19,6 @@ dependencies:
meta: ^1.7.0
path: ^1.8.0
pub_updater: ^0.2.2
recase: ^4.0.0

dev_dependencies:
build_runner: ^2.0.0
Expand Down