Skip to content
This repository has been archived by the owner on Apr 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3764 from ussuri/cleanup-templates-infra
Browse files Browse the repository at this point in the history
Remove support for custom JS dependencies in project type spec
  • Loading branch information
ussuri committed Dec 8, 2014
1 parent 53bf53b commit 45a74d8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 70 deletions.
12 changes: 0 additions & 12 deletions ide/web/lib/templates/addons/bower_deps/bower.json_

This file was deleted.

5 changes: 0 additions & 5 deletions ide/web/lib/templates/addons/bower_deps/setup.json

This file was deleted.

11 changes: 0 additions & 11 deletions ide/web/lib/templates/addons/bower_deps/template.dart

This file was deleted.

3 changes: 0 additions & 3 deletions ide/web/lib/templates/templates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import '../package_mgmt/bower_properties.dart';
import '../utils.dart' as utils;
import '../workspace.dart';

part 'addons/bower_deps/template.dart';
part 'chrome/chrome_app_polymer_js/template.dart';
part 'polymer/template.dart';
part 'polymer/polymer_element_dart/template.dart';
Expand Down Expand Up @@ -116,8 +115,6 @@ abstract class ProjectTemplate {
}

switch (id) {
case 'addons/bower_deps':
return new BowerDepsTemplate(id, globalVars, localVars);
case 'chrome/chrome_app_polymer_js':
return new ChromeAppWithPolymerJSTemplate(id, globalVars, localVars);
case 'polymer/polymer_element_js':
Expand Down
45 changes: 7 additions & 38 deletions ide/web/spark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2241,16 +2241,7 @@ class BuildApkAction extends SparkActionWithDialog {

class NewProjectAction extends SparkActionWithDialog {
InputElement _nameElt;

// TODO(ussuri): Eliminate this and dependencies as per BUG #3619.
static const _KNOWN_JS_PACKAGES = const {
'polymer': 'Polymer/polymer#master',
'core-elements': 'Polymer/core-elements#master',
'paper-elements': 'Polymer/paper-elements#master'
};
// Matches: "proj-template", "proj-template;polymer,core-elements".
// TODO(ussuri): Set to '([\/\w_-]+)' when fixing BUG #3619.
static final _TEMPLATE_REGEX = new RegExp(r'([\/\w_-]+)(;(([\w-],?)+))?');
SelectElement get _typeElt => getElement('select[name="type"]');

NewProjectAction(Spark spark, Element dialog)
: super(spark, "project-new", "New Project…", dialog) {
Expand Down Expand Up @@ -2282,7 +2273,7 @@ class NewProjectAction extends SparkActionWithDialog {
}

ws.WorkspaceRoot root = filesystem.fileSystemAccess.getRootFor(location);
final List<ProjectTemplate> templates = [];
List<ProjectTemplate> templates;

// TODO(ussuri): Can this no-op `return Future.value()` be removed?
return new Future.value().then((_) {
Expand All @@ -2291,33 +2282,11 @@ class NewProjectAction extends SparkActionWithDialog {
new TemplateVar('sourceName', name.toLowerCase())
];

// Add a template for the main project type.
final SelectElement projectTypeElt = getElement('select[name="type"]');
final Match match = _TEMPLATE_REGEX.matchAsPrefix(projectTypeElt.value);
assert(match.groupCount > 0);
final String templId = match.group(1);
final String jsDepsStr = match.group(3);

_analyticsTracker.sendEvent('action', 'project-new', templId);
templates.add(new ProjectTemplate(templId, globalVars));

// Possibly also add a mix-in template for JS dependencies, if the
// project type requires them.
if (jsDepsStr != null) {
List<String> jsDeps = [];
for (final depName in jsDepsStr.split(',')) {
final String depPath = _KNOWN_JS_PACKAGES[depName];
assert(depPath != null);
jsDeps.add('"$depName": "$depPath"');
}
if (jsDeps.isNotEmpty) {
final localVars = [
new TemplateVar('dependencies', jsDeps.join(',\n '))
];
templates.add(
new ProjectTemplate("addons/bower_deps", globalVars, localVars));
}
}
_analyticsTracker.sendEvent('action', 'project-new', _typeElt.value);

// Add templates to be used to create the project.
final List<String> ids = _typeElt.value.split('+');
templates = ids.map((id) => new ProjectTemplate(id, globalVars));

return new ProjectBuilder(location.entry, templates, spark).build();
}).then((_) {
Expand Down
2 changes: 1 addition & 1 deletion ide/web/spark_polymer_ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
<option value="chrome/chrome_app_js">
JavaScript Chrome App
</option>
<option value="chrome/chrome_app_polymer_js;polymer,paper-elements">
<option value="chrome/chrome_app_polymer_js">
JavaScript Chrome App (using Polymer paper elements)
</option>
</optgroup>
Expand Down

0 comments on commit 45a74d8

Please sign in to comment.