Skip to content

Commit 938ff9d

Browse files
authored
Misc fixes for Windows (#60)
1 parent 8830b85 commit 938ff9d

File tree

7 files changed

+80
-55
lines changed

7 files changed

+80
-55
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ cache:
77
directories:
88
- global-cli/node_modules
99
- node_modules
10-
script: tests/e2e.sh
10+
script: tasks/e2e.sh

package.json

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"babel-preset-es2015": "6.9.0",
3636
"babel-preset-es2016": "6.11.3",
3737
"babel-preset-react": "6.11.1",
38-
"chalk": "^1.1.3",
38+
"chalk": "1.1.3",
3939
"cross-spawn": "4.0.0",
4040
"css-loader": "0.23.1",
4141
"eslint": "3.1.1",
@@ -55,38 +55,11 @@
5555
"webpack-dev-server": "1.14.1"
5656
},
5757
"devDependencies": {
58+
"bundle-deps": "^1.0.0",
5859
"react": "^15.2.1",
5960
"react-dom": "^15.2.1"
6061
},
61-
"bundledDependencies": [
62-
"autoprefixer",
63-
"babel-core",
64-
"babel-eslint",
65-
"babel-loader",
66-
"babel-plugin-syntax-trailing-function-commas",
67-
"babel-plugin-transform-class-properties",
68-
"babel-plugin-transform-object-rest-spread",
69-
"babel-plugin-transform-react-constant-elements",
70-
"babel-preset-es2015",
71-
"babel-preset-es2016",
72-
"babel-preset-react",
73-
"chalk",
74-
"cross-spawn",
75-
"css-loader",
76-
"eslint",
77-
"eslint-loader",
78-
"eslint-plugin-import",
79-
"eslint-plugin-react",
80-
"extract-text-webpack-plugin",
81-
"file-loader",
82-
"html-webpack-plugin",
83-
"json-loader",
84-
"opn",
85-
"postcss-loader",
86-
"rimraf",
87-
"style-loader",
88-
"url-loader",
89-
"webpack",
90-
"webpack-dev-server"
91-
]
62+
"optionalDependencies": {
63+
"fsevents": "1.0.14"
64+
}
9265
}

scripts/eject.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,27 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
5151

5252
// Ensure that the host folder is clean and we won't override any files
5353
files.forEach(function(file) {
54-
if (fs.existsSync(path.join(hostPath, file))) {
55-
console.error(
56-
'`' + file + '` already exists in your app folder. We cannot ' +
57-
'continue as you would lose all the changes in that file or directory. ' +
58-
'Please delete it (maybe make a copy for backup) and run this ' +
59-
'command again.'
60-
);
61-
process.exit(1);
62-
}
54+
if (fs.existsSync(path.join(hostPath, file))) {
55+
console.error(
56+
'`' + file + '` already exists in your app folder. We cannot ' +
57+
'continue as you would lose all the changes in that file or directory. ' +
58+
'Please delete it (maybe make a copy for backup) and run this ' +
59+
'command again.'
60+
);
61+
process.exit(1);
62+
}
6363
});
6464

6565
// Copy the files over
6666
fs.mkdirSync(path.join(hostPath, 'config'));
6767
fs.mkdirSync(path.join(hostPath, 'scripts'));
6868

6969
files.forEach(function(file) {
70-
console.log('Copying ' + file + ' to ' + hostPath);
71-
var content = fs.readFileSync(path.join(selfPath, file), 'utf8');
72-
// Remove license header
73-
content = content.replace(/^\/\*\*(\*(?!\/)|[^*])*\*\//, '').trim() + '\n';
74-
fs.writeFileSync(path.join(hostPath, file), content);
70+
console.log('Copying ' + file + ' to ' + hostPath);
71+
var content = fs.readFileSync(path.join(selfPath, file), 'utf8');
72+
// Remove license header
73+
content = content.replace(/^\/\*\*(\*(?!\/)|[^*])*\*\//, '').trim() + '\n';
74+
fs.writeFileSync(path.join(hostPath, file), content);
7575
});
7676
console.log();
7777

@@ -82,8 +82,12 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
8282
delete hostPackage.devDependencies['react-scripts'];
8383

8484
Object.keys(selfPackage.dependencies).forEach(function (key) {
85-
console.log('Adding dependency: ' + key);
86-
hostPackage.devDependencies[key] = selfPackage.dependencies[key];
85+
// For some reason optionalDependencies end up in dependencies after install
86+
if (selfPackage.optionalDependencies[key]) {
87+
return;
88+
}
89+
console.log('Adding dependency: ' + key);
90+
hostPackage.devDependencies[key] = selfPackage.dependencies[key];
8791
});
8892

8993
console.log('Updating scripts');
@@ -94,8 +98,8 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
9498

9599
console.log('Writing package.json');
96100
fs.writeFileSync(
97-
path.join(hostPath, 'package.json'),
98-
JSON.stringify(hostPackage, null, 2)
101+
path.join(hostPath, 'package.json'),
102+
JSON.stringify(hostPackage, null, 2)
99103
);
100104
console.log();
101105

scripts/init.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ module.exports = function(hostPath, appName, verbose) {
1717
var hostPackage = require(path.join(hostPath, 'package.json'));
1818
var selfPackage = require(path.join(selfPath, 'package.json'));
1919

20-
// Copy over devDependencies
20+
// Copy over some of the devDependencies
2121
hostPackage.dependencies = hostPackage.dependencies || {};
22-
for (var key in selfPackage.devDependencies) {
22+
['react', 'react-dom'].forEach(function (key) {
2323
hostPackage.dependencies[key] = selfPackage.devDependencies[key];
24-
}
24+
});
2525

2626
// Setup the script rules
2727
hostPackage.scripts = {};

scripts/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function formatMessage(message) {
5252
'Module not found:'
5353
)
5454
// Internal stacks are generally useless so we strip them
55-
.replace(/^\s*at\s.*\(.*:\d+:\d+\.*\).*\n/gm, '') // at ... (...:x:y)
55+
.replace(/^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, '') // at ... ...:x:y
5656
// Webpack loader names obscure CSS filenames
5757
.replace('./~/css-loader!./~/postcss-loader!', '');
5858
}
File renamed without changes.

tasks/release.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2015-present, Facebook, Inc.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree. An additional grant
6+
# of patent rights can be found in the PATENTS file in the same directory.
7+
8+
# Start in tests/ even if run from root directory
9+
cd "$(dirname "$0")"
10+
11+
# Exit the script on any command with non 0 return code
12+
# We assume that all the commands in the pipeline set their return code
13+
# properly and that we do not need to validate that the output is correct
14+
set -e
15+
16+
# Echo every command being executed
17+
set -x
18+
19+
# Go to root
20+
cd ..
21+
22+
# You can only release with npm >= 3
23+
if [ $(npm -v | head -c 1) -lt 3 ]; then
24+
echo "Releasing requires npm >= 3. Aborting.";
25+
exit 1;
26+
fi;
27+
28+
if [ -n "$(git status --porcelain)" ]; then
29+
echo "Your git status is not clean. Aborting.";
30+
exit 1;
31+
fi
32+
33+
# Force dedupe
34+
npm dedupe
35+
36+
# Don't bundle fsevents because it is optional and OS X-only
37+
# Since it's in optionalDependencies, it will attempt install outside bundle
38+
rm -rf node_modules/fsevents
39+
40+
# This modifies package.json to copy all dependencies to bundledDependencies
41+
# We will revert package.json back after release to avoid doing it every time
42+
node ./node_modules/.bin/bundle-deps
43+
44+
# Go!
45+
npm publish "$@"
46+
47+
# Discard changes to package.json
48+
git checkout -- .

0 commit comments

Comments
 (0)