@@ -14,17 +14,13 @@ cd "$(dirname "$0")"
14
14
15
15
# CLI and app temporary locations
16
16
# http://unix.stackexchange.com/a/84980
17
+ temp_cli_path=` mktemp -d 2> /dev/null || mktemp -d -t ' temp_cli_path' `
17
18
temp_app_path=` mktemp -d 2> /dev/null || mktemp -d -t ' temp_app_path' `
18
- custom_registry_url=http://localhost:4873
19
- original_npm_registry_url=` npm get registry`
20
- original_yarn_registry_url=` yarn config get registry`
21
19
22
20
function cleanup {
23
21
echo ' Cleaning up.'
24
22
cd " $root_path "
25
- rm -rf " $temp_app_path "
26
- npm set registry " $original_npm_registry_url "
27
- yarn config set registry " $original_yarn_registry_url "
23
+ rm -rf " $temp_cli_path " " $temp_app_path "
28
24
}
29
25
30
26
# Error messages are redirected to stderr
@@ -59,6 +55,10 @@ function checkDependencies {
59
55
fi
60
56
}
61
57
58
+ function create_react_app {
59
+ node " $temp_cli_path " /node_modules/create-react-app/index.js $*
60
+ }
61
+
62
62
# Exit the script with a helpful error message when any error is encountered
63
63
trap ' set +x; handle_error $LINENO $BASH_COMMAND' ERR
64
64
@@ -72,82 +72,98 @@ set -x
72
72
cd ..
73
73
root_path=$PWD
74
74
75
+ # Clear cache to avoid issues with incorrect packages being used
76
+ if hash yarnpkg 2> /dev/null
77
+ then
78
+ # AppVeyor uses an old version of yarn.
79
+ # Once updated to 0.24.3 or above, the workaround can be removed
80
+ # and replaced with `yarnpkg cache clean`
81
+ # Issues:
82
+ # https://github.com/yarnpkg/yarn/issues/2591
83
+ # https://github.com/appveyor/ci/issues/1576
84
+ # https://github.com/facebookincubator/create-react-app/pull/2400
85
+ # When removing workaround, you may run into
86
+ # https://github.com/facebookincubator/create-react-app/issues/2030
87
+ case " $( uname -s) " in
88
+ * CYGWIN* |MSYS* |MINGW* ) yarn=yarn.cmd;;
89
+ * ) yarn=yarnpkg;;
90
+ esac
91
+ $yarn cache clean
92
+ fi
93
+
75
94
if hash npm 2> /dev/null
76
95
then
77
- npm i -g npm@latest
96
+ # npm 5 is too buggy right now
97
+ if [ $( npm -v | head -c 1) -eq 5 ]; then
98
+ npm i -g npm@^4.x
99
+ fi ;
78
100
npm cache clean || npm cache verify
79
101
fi
80
102
81
- # Bootstrap monorepo
82
- yarn
103
+ # Prevent bootstrap, we only want top-level dependencies
104
+ cp package.json package.json.bak
105
+ grep -v " postinstall" package.json > temp && mv temp package.json
106
+ npm install
107
+ mv package.json.bak package.json
83
108
84
- # ******************************************************************************
85
- # First, publish the monorepo.
86
- # ******************************************************************************
87
-
88
- # Start local registry
89
- tmp_registry_log=` mktemp`
90
- nohup npx
[email protected] & > $tmp_registry_log &
91
- # Wait for `verdaccio` to boot
92
- grep -q ' http address' <( tail -f $tmp_registry_log )
93
-
94
- # Set registry to local registry
95
- npm set registry " $custom_registry_url "
96
- yarn config set registry " $custom_registry_url "
109
+ if [ " $USE_YARN " = " yes" ]
110
+ then
111
+ # Install Yarn so that the test can use it to install packages.
112
+ npm install -g yarn
113
+ yarn cache clean
114
+ fi
97
115
98
- # Login so we can publish packages
99
- npx [email protected] -u user -p password -e [email protected] -r " $custom_registry_url " --quotes
116
+ # We removed the postinstall, so do it manually
117
+ node bootstrap.js
100
118
101
- # Publish the monorepo
102
- git clean -df
103
- ./tasks/publish.sh --yes --force-publish= * --skip-git --cd-version=prerelease --exact --npm-tag=latest
119
+ cd packages/react-error-overlay/
120
+ npm run build:prod
121
+ cd ../..
104
122
105
123
# ******************************************************************************
106
- # Test --scripts-version with a version number
124
+ # First, pack and install create-react-app.
107
125
# ******************************************************************************
108
126
109
- cd " $temp_app_path "
110
- npx create-react-app --scripts-version=1.0.17 test-app-version-number
111
- cd test-app-version-number
127
+ # Pack CLI
128
+ cd " $root_path " /packages/ create-react-app
129
+ cli_path= $PWD / ` npm pack `
112
130
113
- # Check corresponding scripts version is installed.
114
- exists node_modules/react-scripts
115
- grep ' "version": "1.0.17"' node_modules/react-scripts/package.json
116
- checkDependencies
131
+ # Install the CLI in a temporary location
132
+ cd " $temp_cli_path "
133
+ npm install " $cli_path "
117
134
118
135
# ******************************************************************************
119
- # Test --use-npm flag
136
+ # Test --scripts-version with a version number
120
137
# ******************************************************************************
121
138
122
139
cd " $temp_app_path "
123
- npx create-react-app --use-npm -- scripts-version=1.0.17 test-use-npm-flag
124
- cd test-use-npm-flag
140
+ create_react_app -- scripts-version=0.4.0 test-app-version-number
141
+ cd test-app-version-number
125
142
126
143
# Check corresponding scripts version is installed.
127
144
exists node_modules/react-scripts
128
- [ ! -e " yarn.lock" ] && echo " yarn.lock correctly does not exist"
129
- grep ' "version": "1.0.17"' node_modules/react-scripts/package.json
145
+ grep ' "version": "0.4.0"' node_modules/react-scripts/package.json
130
146
checkDependencies
131
147
132
148
# ******************************************************************************
133
149
# Test --scripts-version with a tarball url
134
150
# ******************************************************************************
135
151
136
152
cd " $temp_app_path "
137
- npx create-react-app -- scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17 .tgz test-app-tarball-url
153
+ create_react_app -- scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-0.4.0 .tgz test-app-tarball-url
138
154
cd test-app-tarball-url
139
155
140
156
# Check corresponding scripts version is installed.
141
157
exists node_modules/react-scripts
142
- grep ' "version": "1.0.17 "' node_modules/react-scripts/package.json
158
+ grep ' "version": "0.4.0 "' node_modules/react-scripts/package.json
143
159
checkDependencies
144
160
145
161
# ******************************************************************************
146
162
# Test --scripts-version with a custom fork of react-scripts
147
163
# ******************************************************************************
148
164
149
165
cd " $temp_app_path "
150
- npx create-react-app --scripts-version=react-scripts-fork test-app-fork
166
+ create_react_app --scripts-version=react-scripts-fork test-app-fork
151
167
cd test-app-fork
152
168
153
169
# Check corresponding scripts version is installed.
@@ -159,7 +175,7 @@ exists node_modules/react-scripts-fork
159
175
160
176
cd " $temp_app_path "
161
177
# we will install a non-existing package to simulate a failed installataion.
162
- npx create-react-app --scripts-version=` date +%s` test-app-should-not-exist || true
178
+ create_react_app --scripts-version=` date +%s` test-app-should-not-exist || true
163
179
# confirm that the project folder was deleted
164
180
test ! -d test-app-should-not-exist
165
181
@@ -171,7 +187,7 @@ cd "$temp_app_path"
171
187
mkdir test-app-should-remain
172
188
echo ' ## Hello' > ./test-app-should-remain/README.md
173
189
# we will install a non-existing package to simulate a failed installataion.
174
- npx create-react-app --scripts-version=` date +%s` test-app-should-remain || true
190
+ create_react_app --scripts-version=` date +%s` test-app-should-remain || true
175
191
# confirm the file exist
176
192
test -e test-app-should-remain/README.md
177
193
# confirm only README.md is the only file in the directory
185
201
186
202
cd $temp_app_path
187
203
curl " https://registry.npmjs.org/@enoah_netzach/react-scripts/-/react-scripts-0.9.0.tgz" -o enoah-scripts-0.9.0.tgz
188
- npx create-react-app --scripts-version=$temp_app_path /enoah-scripts-0.9.0.tgz test-app-scoped-fork-tgz
204
+ create_react_app --scripts-version=$temp_app_path /enoah-scripts-0.9.0.tgz test-app-scoped-fork-tgz
189
205
cd test-app-scoped-fork-tgz
190
206
191
207
# Check corresponding scripts version is installed.
@@ -200,22 +216,22 @@ cd "$temp_app_path"
200
216
mkdir test-app-nested-paths-t1
201
217
cd test-app-nested-paths-t1
202
218
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
203
- npx create-react-app test-app-nested-paths-t1/aa/bb/cc/dd
219
+ create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
204
220
cd test-app-nested-paths-t1/aa/bb/cc/dd
205
- yarn start --smoke-test
221
+ npm start -- --smoke-test
206
222
207
223
# Testing a path that does not exist
208
224
cd " $temp_app_path "
209
- npx create-react-app test-app-nested-paths-t2/aa/bb/cc/dd
225
+ create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
210
226
cd test-app-nested-paths-t2/aa/bb/cc/dd
211
- yarn start --smoke-test
227
+ npm start -- --smoke-test
212
228
213
229
# Testing a path that is half exists
214
230
cd " $temp_app_path "
215
231
mkdir -p test-app-nested-paths-t3/aa
216
- npx create-react-app test-app-nested-paths-t3/aa/bb/cc/dd
232
+ create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
217
233
cd test-app-nested-paths-t3/aa/bb/cc/dd
218
- yarn start --smoke-test
234
+ npm start -- --smoke-test
219
235
220
236
# Cleanup
221
237
cleanup
0 commit comments