1+ #! /bin/bash
2+ # Copyright (c) 2015-present, Facebook, Inc.
3+ #
4+ # This source code is licensed under the MIT license found in the
5+ # LICENSE file in the root directory of this source tree.
6+
7+ # ******************************************************************************
8+ # This installs the development version of the global CLI from source.
9+ # It is useful for testing the end-to-end flow locally.
10+ # ******************************************************************************
11+
12+ # Start in tasks/ even if run from root directory
13+ cd " $( dirname " $0 " ) "
14+
15+ function cleanup {
16+ echo ' Cleaning up.'
17+ }
18+
19+ # Error messages are redirected to stderr
20+ function handle_error {
21+ echo " $( basename $0 ) : ERROR! An error was encountered executing line $1 ." 1>&2 ;
22+ cleanup
23+ echo ' Exiting with error.' 1>&2 ;
24+ exit 1
25+ }
26+
27+ function handle_exit {
28+ cleanup
29+ echo ' Exiting without error.' 1>&2 ;
30+ exit
31+ }
32+
33+ # Exit the script with a helpful error message when any error is encountered
34+ trap ' set +x; handle_error $LINENO $BASH_COMMAND' ERR
35+
36+ # Cleanup before exit on any termination signal
37+ trap ' set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
38+
39+ # Echo every command being executed
40+ set -x
41+
42+ # Go to root
43+ cd ..
44+ root_path=$PWD
45+
46+ # ******************************************************************************
47+ # Pack react-scripts so we can verify they work.
48+ # ******************************************************************************
49+
50+ # Install all our packages
51+ " $root_path " /node_modules/.bin/lerna bootstrap
52+
53+ cd packages/create-typescript-package
54+
55+ # Save package.json because we're going to touch it
56+ cp package.json package.json.orig
57+
58+ # Replace own dependencies (those in the `packages` dir) with the local paths
59+ # of those packages.
60+ node " $root_path " /tasks/replace-own-deps.js
61+
62+ # Finally, pack react-scripts
63+ ctp_path=" $root_path " /packages/create-typescript-package/` npm pack`
64+
65+ # Restore package.json
66+ rm package.json
67+ mv package.json.orig package.json
68+
69+
70+ # ******************************************************************************
71+ # Now that we have packed them, call the global CLI.
72+ # ******************************************************************************
73+
74+ # If Yarn is installed, clean its cache because it may have cached create-typescript-package
75+ yarn cache clean || true
76+
77+ # Go back to the root directory and run the command from here
78+ cd " $root_path "
79+ npm install -g " $ctp_path "
80+
81+ # Cleanup
82+ cleanup
0 commit comments