Skip to content

Commit

Permalink
0.3.0
Browse files Browse the repository at this point in the history
* remove app generator
* upgrade to angular 4
  • Loading branch information
luisvt committed Sep 7, 2017
1 parent fe0e77f commit 10be498
Show file tree
Hide file tree
Showing 29 changed files with 48 additions and 383 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.3.0

* remove app generator
* upgrade to angular 4

## 0.2.1+1
* small fix on service generation

Expand Down
96 changes: 0 additions & 96 deletions bin/app.dart

This file was deleted.

47 changes: 0 additions & 47 deletions bin/app_template_data.dart

This file was deleted.

6 changes: 3 additions & 3 deletions bin/component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ main(List<String> args) async {

if (config?.componentsPath != null) {
path = "${config.componentsPath}/${toTableName(name)}";
lib = "lib/components.dart";
lib = config.useComponentsFile ? "lib/components.dart" : null;
}

String prefix = config?.componentsPath != null ? "lib/" : "";
Expand All @@ -33,12 +33,12 @@ main(List<String> args) async {
}

String componentTemplateDart(String name) =>
'''import 'package:angular2/core.dart';
'''import 'package:angular/angular.dart';
@Component(
selector: '${toPolyName(name)}',
templateUrl: '${toTableName(name)}.html',
styleUrls: const <String>['${toTableName(name)}.css'])
styleUrls: const ['${toTableName(name)}.css'])
class ${toUpperCamelCase(name)} implements OnInit {
${toUpperCamelCase(name)}();
Expand Down
6 changes: 3 additions & 3 deletions bin/component_inline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ main(List<String> args) async {

if (config?.componentsPath != null) {
path = "${config.componentsPath}/${toTableName(name)}";
lib = "lib/components.dart";
lib = config.useComponentsFile ? "lib/components.dart" : null;
}

String prefix = config?.componentsPath != null ? "lib/" : "";
Expand All @@ -31,7 +31,7 @@ main(List<String> args) async {
}

String componentTemplateDart(String name) =>
'''import 'package:angular2/core.dart';
'''import 'package:angular/angular.dart';
@Component(
selector: '${toPolyName(name)}',
Expand All @@ -40,7 +40,7 @@ String componentTemplateDart(String name) =>
${toPolyName(name)} works!
</p>
\'\'\',
styleUrls: const <String>['${toTableName(name)}.css'])
styleUrls: const ['${toTableName(name)}.css'])
class ${toUpperCamelCase(name)} implements OnInit {
${toUpperCamelCase(name)}();
Expand Down
6 changes: 3 additions & 3 deletions bin/directive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ main(List<String> args) async {

if (config?.directivesPath != null) {
path = "${config.directivesPath}";
lib = "lib/directives.dart";
lib = config.useDirectivesFile ? "lib/directives.dart" : null;
}

String prefix = config?.directivesPath != null ? "lib/" : "";
Expand All @@ -28,10 +28,10 @@ main(List<String> args) async {
}

String directiveTemplate(String name) => '''
import "package:angular2/core.dart";
import "package:angular/angular.dart";
@Directive(
selector: '[${toPolyName(name)}]'
selector: '[${toLowerCamelCase(name)}]'
)
class ${toUpperCamelCase(name)} {
Expand Down
6 changes: 0 additions & 6 deletions bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'component.dart' as component;
import 'directive.dart' as directive;
import 'service.dart' as service;
import 'pipe.dart' as pipe;
import 'app.dart' as app;
import 'component_inline.dart' as component_inline;
import 'route.dart' as route;
import 'init.dart' as init;
Expand Down Expand Up @@ -41,10 +40,6 @@ main(List<String> args) {
_showHelp(args, 2);
route.main(args.getRange(1, args.length).toList());
break;
case 'new':
_showHelp(args, 1);
app.main(args.getRange(1, args.length).toList());
break;
case '--help':
case '-h':
default:
Expand All @@ -57,7 +52,6 @@ void _showHelp([List<String> args, int index]) {
print('''
USAGE:
-h, --help : shows this content.
new <app_name> : create a new Angular2 application.
component <component_name> : create a new folder with the name of component.
component_inline <component_name> : create a new folder with the name of component but without html file.
directive <directive_name> : create a new directive.
Expand Down
4 changes: 2 additions & 2 deletions bin/pipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ main(List<String> args) async {

if (config?.pipesPath != null) {
path = "${config.pipesPath}";
lib = "lib/pipes.dart";
lib = config.usePipesFile ? "lib/pipes.dart" : null;
}

String prefix = config?.pipesPath != null ? "lib/" : "";
Expand All @@ -28,7 +28,7 @@ main(List<String> args) async {
}

String pipeTemplate(String name) => '''
import "package:angular2/core.dart";
import "package:angular/angular.dart";
@Pipe(
name: '${toLowerCamelCase(name)}'
Expand Down
34 changes: 15 additions & 19 deletions bin/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ main(List<String> args) async {

if (config?.routesPath != null) {
path = "${config.routesPath}/${toTableName(name)}";
lib = "lib/routes.dart";
lib = config.useRoutesFile ? "lib/routes.dart" : null;
}

String prefix = config?.routesPath != null ? "lib/" : "";
Expand All @@ -26,31 +26,25 @@ main(List<String> args) async {
String htmlPath = '$filePath.${config.htmlExtension}';
String cssPath = '$filePath.${config.cssExtension}';

await writeInFile(dartPath, componentRouteTemplateDart(name, routePath));
await writeInFile(dartPath, componentRouteTemplateDart(name));
await writeInFile(htmlPath, componentTemplateHtml(name));
await createFile(cssPath);

if (lib != null) {
addToLibrary("$path/${toTableName(name)}.dart", lib);
addToRouteConfig(toUpperCamelCase(name), config?.rootPath);
}
addToRouteConfig(toUpperCamelCase(name), config?.rootPath, routePath, dartPath);
}

String componentRouteTemplateDart(String name, String path) => '''import 'package:angular2/core.dart';
import 'package:angular2/router.dart';
String componentRouteTemplateDart(String name) =>
'''import 'package:angular/angular.dart';
@Component(
selector: '${name.replaceAll("_", "-")}',
templateUrl: '${toTableName(name)}.html',
styleUrls: const <String>['${toTableName(name)}.css'])
styleUrls: const ['${toTableName(name)}.css'])
class ${toUpperCamelCase(name)} implements OnInit {
static const String route_name = "${toUpperCamelCase(name)}";
static const String route_path = "$path";
static const Route route = const Route(path: ${toUpperCamelCase(name)}.route_path,
component: ${toUpperCamelCase(name)},
name: ${toUpperCamelCase(name)}.route_name);
${toUpperCamelCase(name)}();
@override
Expand All @@ -59,18 +53,20 @@ class ${toUpperCamelCase(name)} implements OnInit {
}
''';

addToRouteConfig(String className, String rootPath) {
addToRouteConfig(String className, String rootPath, String routePath, String dartPath) {
File rootComponent = new File("lib/$rootPath");

if (rootComponent.existsSync()) {
String content = rootComponent.readAsStringSync();
content = formatter.format(content);
if (!config.useRoutesFile) {
content = "import 'package:${config.projectName}/${dartPath.replaceFirst('lib/', '')}';\n" + content;
}
content = content.replaceFirst(
"/*Insert Routes here*/",
'''
/*Insert Routes here*/
$className.route,
''');
new RegExp(r'@RouteConfig\(const\s*\['),
"""@RouteConfig(const [
const Route(path: '$routePath${toPolyName(className)}',
component: $className,
name: '$className'),""");
rootComponent.writeAsStringSync(formatter.format(content));
output("Route Inserted into root component.\n", Color.yellow);
}
Expand Down
4 changes: 2 additions & 2 deletions bin/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ main(List<String> args) async {

if (config?.servicesPath != null) {
path = "${config.servicesPath}";
lib = "lib/services.dart";
lib = config.useServicesFile ? "lib/services.dart" : null;
}

String prefix = config?.servicesPath != null ? "lib/" : "";
Expand All @@ -29,7 +29,7 @@ main(List<String> args) async {

String serviceTemplate(String name) =>
'''
import "package:angular2/core.dart";
import "package:angular/core.dart";
@Injectable()
class ${toUpperCamelCase(name)} {
Expand Down
7 changes: 0 additions & 7 deletions bin/template/.analysis_options

This file was deleted.

6 changes: 0 additions & 6 deletions bin/template/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions bin/template/generator.config.yaml

This file was deleted.

Loading

0 comments on commit 10be498

Please sign in to comment.