Skip to content

Commit 8f98b50

Browse files
author
Ray Cohen
committed
ember deploy production builds the create react app and outputs the files in the build folder
1 parent 2ab42b9 commit 8f98b50

File tree

2 files changed

+61
-5
lines changed

2 files changed

+61
-5
lines changed

index.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,59 @@
11
/* jshint node: true */
22
'use strict';
33

4+
var DeployPluginBase = require('ember-cli-deploy-plugin');
5+
var Promise = require('ember-cli/lib/ext/promise');
6+
var exec = require('child_process').exec;
7+
var glob = require('glob');
8+
49
module.exports = {
5-
name: 'ember-cli-deploy-create-react-app'
10+
name: 'ember-cli-deploy-create-react-app',
11+
12+
createDeployPlugin: function(options) {
13+
var Plugin = DeployPluginBase.extend({
14+
name: options.name,
15+
16+
defaultConfig: {},
17+
18+
build: function(context) {
19+
var self = this;
20+
var options = {};
21+
options.cwd = '../fluxproofofconcept';
22+
23+
return new Promise(function(resolve, reject) {
24+
exec('npm run build', options, function(error, stdout, stderr) {
25+
if (error) {
26+
reject();
27+
return;
28+
}
29+
30+
var files = glob.sync('**/**/*', {cwd: '../fluxproofofconcept/build'});
31+
32+
if (files && files.length) {
33+
files.forEach(function(path) {
34+
self.log('✔ ' + path, { verbose: true });
35+
});
36+
} else {
37+
self.log('No files :(');
38+
}
39+
40+
resolve({
41+
distDir: '../fluxproofofconcept/build',
42+
distFiles: files
43+
});
44+
});
45+
}).then(function(results) {
46+
exec('ls', options, function(error, stdout, stderr) {
47+
if (error) {
48+
reject();
49+
return;
50+
}
51+
resolve(results);
52+
});
53+
});
54+
}
55+
});
56+
57+
return new Plugin();
58+
}
659
};

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "ember-cli-deploy-create-react-app",
3-
"version": "0.0.0",
4-
"description": "The default blueprint for ember-cli addons.",
3+
"version": "0.0.1",
4+
"description": "Plugin to build a react app",
55
"keywords": [
6-
"ember-addon"
6+
"ember-addon",
7+
"ember-cli-deploy-plugin"
78
],
89
"license": "MIT",
910
"author": "",
@@ -18,7 +19,8 @@
1819
"test": "ember try:each"
1920
},
2021
"dependencies": {
21-
"ember-cli-babel": "^5.1.7"
22+
"ember-cli-babel": "^5.1.7",
23+
"ember-cli-deploy-plugin": "^0.2.9"
2224
},
2325
"devDependencies": {
2426
"broccoli-asset-rev": "^2.4.5",
@@ -41,6 +43,7 @@
4143
"ember-load-initializers": "^0.5.1",
4244
"ember-resolver": "^2.0.3",
4345
"ember-welcome-page": "^1.0.3",
46+
"glob": "^7.1.1",
4447
"loader.js": "^4.0.10"
4548
},
4649
"engines": {

0 commit comments

Comments
 (0)