Skip to content

Commit 178f006

Browse files
authored
Merge pull request #59 from rwjblue/update-broccoli-work
Update broccoli node to be broccoli-plugin based.
2 parents d5445cc + b648613 commit 178f006

4 files changed

Lines changed: 46 additions & 53 deletions

File tree

generate-deprecations-tree.js

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,41 @@
11
'use strict';
22

3-
var fs = require('fs');
4-
var path = require('path');
5-
var rimraf = require('rimraf');
6-
var quickTemp = require('quick-temp');
7-
var hashStrings = require('broccoli-kitchen-sink-helpers').hashStrings;
3+
const fs = require('fs');
4+
const path = require('path');
85

9-
function TemplateLinter(deprecationSource) {
10-
this.description = 'TemplateLinter';
11-
this.deprecationSource = deprecationSource;
12-
this.lastHash = undefined;
13-
}
14-
15-
TemplateLinter.prototype.content = function() {
16-
return this.deprecationSource._templateDeprecations
17-
.map(function(item) {
18-
return 'Ember.deprecate(\n' +
19-
' ' + item.message + ',\n' +
20-
' ' + item.test + ',\n' +
21-
' ' + item.options + '\n' +
22-
');';
23-
})
24-
.join('\n');
25-
};
26-
27-
TemplateLinter.prototype.read = function() {
28-
var dir = quickTemp.makeOrReuse(this, 'template-linter-cache');
29-
30-
var outputPath = path.join(dir, 'template-deprecations-test.js');
6+
const Plugin = require('broccoli-plugin');
317

32-
var content = this.content();
33-
var hash = hashStrings([content]);
8+
module.exports = class DeprecationWorkflowTemplateDeprecationProducer extends Plugin {
9+
constructor(workflowAddonInstance, tree) {
10+
super([tree], {
11+
annotation: 'deprecation-workflow-template-deprecations',
12+
persistentOutput: true,
13+
needsCache: false,
14+
});
3415

35-
if (this.lastHash !== hash) {
36-
this.lastHash = hash;
37-
fs.writeFileSync(outputPath, content);
16+
this.workflowAddonInstance = workflowAddonInstance;
17+
this.lastContent = undefined;
3818
}
3919

40-
return dir;
41-
};
42-
43-
TemplateLinter.prototype.cleanup = function() {
44-
return rimraf.sync(this['template-linter-cache']);
45-
};
20+
content() {
21+
return this.workflowAddonInstance._templateDeprecations
22+
.map(function(item) {
23+
return 'Ember.deprecate(\n' +
24+
' ' + item.message + ',\n' +
25+
' ' + item.test + ',\n' +
26+
' ' + item.options + '\n' +
27+
');';
28+
})
29+
.join('\n');
30+
}
4631

32+
build() {
33+
let outputPath = path.join(this.outputPath, 'template-deprecations-test.js');
4734

48-
module.exports = TemplateLinter;
35+
let content = this.content();
36+
if (this.lastContent !== content) {
37+
this.lastContent = content;
38+
fs.writeFileSync(outputPath, content);
39+
}
40+
}
41+
}

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ module.exports = {
116116
}
117117
},
118118

119-
lintTree: function() {
120-
var TemplateLinter = require('./generate-deprecations-tree');
119+
lintTree: function(type, tree) {
120+
if (type === 'template') {
121+
var TemplateLinter = require('./generate-deprecations-tree');
121122

122-
return new TemplateLinter(this);
123+
return new TemplateLinter(this, tree);
124+
}
123125
}
124126
};

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121
"test:all": "ember try:each"
2222
},
2323
"dependencies": {
24-
"broccoli-funnel": "^1.0.1",
25-
"broccoli-kitchen-sink-helpers": "^0.3.1",
26-
"broccoli-merge-trees": "^1.1.1",
27-
"ember-debug-handlers-polyfill": "^1.0.2",
28-
"quick-temp": "^0.1.5",
29-
"rimraf": "^2.5.2"
24+
"broccoli-funnel": "^2.0.1",
25+
"broccoli-merge-trees": "^3.0.1",
26+
"broccoli-plugin": "^1.3.1",
27+
"ember-debug-handlers-polyfill": "^1.1.1"
3028
},
3129
"devDependencies": {
3230
"@ember/optional-features": "^0.6.3",

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ broccoli-lint-eslint@^4.2.1:
11261126
lodash.defaultsdeep "^4.6.0"
11271127
md5-hex "^2.0.0"
11281128

1129-
broccoli-merge-trees@^1.0.0, broccoli-merge-trees@^1.1.1:
1129+
broccoli-merge-trees@^1.0.0:
11301130
version "1.2.4"
11311131
resolved "https://registry.yarnpkg.com/broccoli-merge-trees/-/broccoli-merge-trees-1.2.4.tgz#a001519bb5067f06589d91afa2942445a2d0fdb5"
11321132
dependencies:
@@ -1146,7 +1146,7 @@ broccoli-merge-trees@^2.0.0:
11461146
broccoli-plugin "^1.3.0"
11471147
merge-trees "^1.0.1"
11481148

1149-
broccoli-merge-trees@^3.0.0:
1149+
broccoli-merge-trees@^3.0.0, broccoli-merge-trees@^3.0.1:
11501150
version "3.0.1"
11511151
resolved "https://registry.yarnpkg.com/broccoli-merge-trees/-/broccoli-merge-trees-3.0.1.tgz#545dfe9f695cec43372b3ee7e63c7203713ea554"
11521152
dependencies:
@@ -1208,7 +1208,7 @@ broccoli-plugin@1.1.0:
12081208
rimraf "^2.3.4"
12091209
symlink-or-copy "^1.0.1"
12101210

1211-
broccoli-plugin@^1.0.0, broccoli-plugin@^1.2.0, broccoli-plugin@^1.2.1, broccoli-plugin@^1.3.0:
1211+
broccoli-plugin@^1.0.0, broccoli-plugin@^1.2.0, broccoli-plugin@^1.2.1, broccoli-plugin@^1.3.0, broccoli-plugin@^1.3.1:
12121212
version "1.3.1"
12131213
resolved "https://registry.yarnpkg.com/broccoli-plugin/-/broccoli-plugin-1.3.1.tgz#a26315732fb99ed2d9fb58f12a1e14e986b4fabd"
12141214
dependencies:
@@ -2166,7 +2166,7 @@ ember-cli@~3.4.3:
21662166
watch-detector "^0.1.0"
21672167
yam "^0.0.24"
21682168

2169-
ember-debug-handlers-polyfill@^1.0.2:
2169+
ember-debug-handlers-polyfill@^1.1.1:
21702170
version "1.1.1"
21712171
resolved "https://registry.yarnpkg.com/ember-debug-handlers-polyfill/-/ember-debug-handlers-polyfill-1.1.1.tgz#e9ae0a720271a834221179202367421b580002ef"
21722172

@@ -5246,7 +5246,7 @@ ret@~0.1.10:
52465246
version "0.1.15"
52475247
resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
52485248

5249-
rimraf@^2.2.8, rimraf@^2.3.2, rimraf@^2.3.4, rimraf@^2.4.3, rimraf@^2.4.4, rimraf@^2.5.2, rimraf@^2.5.3, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2:
5249+
rimraf@^2.2.8, rimraf@^2.3.2, rimraf@^2.3.4, rimraf@^2.4.3, rimraf@^2.4.4, rimraf@^2.5.3, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2:
52505250
version "2.6.2"
52515251
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
52525252
dependencies:

0 commit comments

Comments
 (0)