Skip to content

Commit

Permalink
Misc fixes for Windows (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jul 21, 2016
1 parent 8830b85 commit 938ff9d
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cache:
directories:
- global-cli/node_modules
- node_modules
script: tests/e2e.sh
script: tasks/e2e.sh
37 changes: 5 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"babel-preset-es2015": "6.9.0",
"babel-preset-es2016": "6.11.3",
"babel-preset-react": "6.11.1",
"chalk": "^1.1.3",
"chalk": "1.1.3",
"cross-spawn": "4.0.0",
"css-loader": "0.23.1",
"eslint": "3.1.1",
Expand All @@ -55,38 +55,11 @@
"webpack-dev-server": "1.14.1"
},
"devDependencies": {
"bundle-deps": "^1.0.0",
"react": "^15.2.1",
"react-dom": "^15.2.1"
},
"bundledDependencies": [
"autoprefixer",
"babel-core",
"babel-eslint",
"babel-loader",
"babel-plugin-syntax-trailing-function-commas",
"babel-plugin-transform-class-properties",
"babel-plugin-transform-object-rest-spread",
"babel-plugin-transform-react-constant-elements",
"babel-preset-es2015",
"babel-preset-es2016",
"babel-preset-react",
"chalk",
"cross-spawn",
"css-loader",
"eslint",
"eslint-loader",
"eslint-plugin-import",
"eslint-plugin-react",
"extract-text-webpack-plugin",
"file-loader",
"html-webpack-plugin",
"json-loader",
"opn",
"postcss-loader",
"rimraf",
"style-loader",
"url-loader",
"webpack",
"webpack-dev-server"
]
"optionalDependencies": {
"fsevents": "1.0.14"
}
}
40 changes: 22 additions & 18 deletions scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,27 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi

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

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

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

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

Object.keys(selfPackage.dependencies).forEach(function (key) {
console.log('Adding dependency: ' + key);
hostPackage.devDependencies[key] = selfPackage.dependencies[key];
// For some reason optionalDependencies end up in dependencies after install
if (selfPackage.optionalDependencies[key]) {
return;
}
console.log('Adding dependency: ' + key);
hostPackage.devDependencies[key] = selfPackage.dependencies[key];
});

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

console.log('Writing package.json');
fs.writeFileSync(
path.join(hostPath, 'package.json'),
JSON.stringify(hostPackage, null, 2)
path.join(hostPath, 'package.json'),
JSON.stringify(hostPackage, null, 2)
);
console.log();

Expand Down
6 changes: 3 additions & 3 deletions scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ module.exports = function(hostPath, appName, verbose) {
var hostPackage = require(path.join(hostPath, 'package.json'));
var selfPackage = require(path.join(selfPath, 'package.json'));

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

// Setup the script rules
hostPackage.scripts = {};
Expand Down
2 changes: 1 addition & 1 deletion scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function formatMessage(message) {
'Module not found:'
)
// Internal stacks are generally useless so we strip them
.replace(/^\s*at\s.*\(.*:\d+:\d+\.*\).*\n/gm, '') // at ... (...:x:y)
.replace(/^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, '') // at ... ...:x:y
// Webpack loader names obscure CSS filenames
.replace('./~/css-loader!./~/postcss-loader!', '');
}
Expand Down
File renamed without changes.
48 changes: 48 additions & 0 deletions tasks/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

# Start in tests/ even if run from root directory
cd "$(dirname "$0")"

# Exit the script on any command with non 0 return code
# We assume that all the commands in the pipeline set their return code
# properly and that we do not need to validate that the output is correct
set -e

# Echo every command being executed
set -x

# Go to root
cd ..

# You can only release with npm >= 3
if [ $(npm -v | head -c 1) -lt 3 ]; then
echo "Releasing requires npm >= 3. Aborting.";
exit 1;
fi;

if [ -n "$(git status --porcelain)" ]; then
echo "Your git status is not clean. Aborting.";
exit 1;
fi

# Force dedupe
npm dedupe

# Don't bundle fsevents because it is optional and OS X-only
# Since it's in optionalDependencies, it will attempt install outside bundle
rm -rf node_modules/fsevents

# This modifies package.json to copy all dependencies to bundledDependencies
# We will revert package.json back after release to avoid doing it every time
node ./node_modules/.bin/bundle-deps

# Go!
npm publish "$@"

# Discard changes to package.json
git checkout -- .

0 comments on commit 938ff9d

Please sign in to comment.