@@ -14,13 +14,12 @@ cd "$(dirname "$0")"
1414
1515# CLI and app temporary locations
1616# http://unix.stackexchange.com/a/84980
17- temp_cli_path=` mktemp -d 2> /dev/null || mktemp -d -t ' temp_cli_path' `
1817temp_app_path=` mktemp -d 2> /dev/null || mktemp -d -t ' temp_app_path' `
1918
2019function cleanup {
2120 echo ' Cleaning up.'
2221 cd " $root_path "
23- rm -rf " $temp_cli_path " " $ temp_app_path"
22+ rm -rf " $temp_app_path "
2423}
2524
2625# Error messages are redirected to stderr
@@ -55,10 +54,6 @@ function checkDependencies {
5554 fi
5655}
5756
58- function create_react_app {
59- node " $temp_cli_path " /node_modules/create-react-app/index.js $*
60- }
61-
6257# Exit the script with a helpful error message when any error is encountered
6358trap ' set +x; handle_error $LINENO $BASH_COMMAND' ERR
6459
@@ -72,6 +67,12 @@ set -x
7267cd ..
7368root_path=$PWD
7469
70+ if hash npm 2> /dev/null
71+ then
72+ npm i -g npm@latest
73+ npm cache clean || npm cache verify
74+ fi
75+
7576# Prevent bootstrap, we only want top-level dependencies
7677cp package.json package.json.bak
7778grep -v " postinstall" package.json > temp && mv temp package.json
@@ -86,23 +87,32 @@ yarn run build:prod
8687cd ../..
8788
8889# ******************************************************************************
89- # First, pack and install create-react-app .
90+ # First, publish the monorepo .
9091# ******************************************************************************
9192
92- # Pack CLI
93- cd " $root_path " /packages/create-react-app
94- cli_path=$PWD /` npm pack`
93+ # Start local registry
94+ tmp_registry_log=` mktemp`
95+ nohup npx verdaccio@2.7.2 & > $tmp_registry_log &
96+ # Wait for `verdaccio` to boot
97+ grep -q ' http address' <( tail -f $tmp_registry_log )
98+
99+ # Set registry to local registry
100+ npm set registry http://localhost:4873
101+ yarn config set registry http://localhost:4873
102+
103+ # Login so we can publish packages
104+ npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r http://localhost:4873 --quotes
95105
96- # Install the CLI in a temporary location
97- cd " $temp_cli_path "
98- yarn add " $cli_path "
106+ # Publish the monorepo
107+ git clean -f
108+ ./tasks/release.sh --yes --force-publish= * --skip-git --cd-version=prerelease --exact --npm-tag=latest
99109
100110# ******************************************************************************
101111# Test --scripts-version with a version number
102112# ******************************************************************************
103113
104114cd " $temp_app_path "
105- create_react_app --scripts-version=1.0.17 test-app-version-number
115+ npx create-react-app --scripts-version=1.0.17 test-app-version-number
106116cd test-app-version-number
107117
108118# Check corresponding scripts version is installed.
@@ -115,7 +125,7 @@ checkDependencies
115125# ******************************************************************************
116126
117127cd " $temp_app_path "
118- create_react_app --use-npm --scripts-version=1.0.17 test-use-npm-flag
128+ npx create-react-app --use-npm --scripts-version=1.0.17 test-use-npm-flag
119129cd test-use-npm-flag
120130
121131# Check corresponding scripts version is installed.
@@ -129,7 +139,7 @@ checkDependencies
129139# ******************************************************************************
130140
131141cd " $temp_app_path "
132- create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17.tgz test-app-tarball-url
142+ npx create-react-app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17.tgz test-app-tarball-url
133143cd test-app-tarball-url
134144
135145# Check corresponding scripts version is installed.
@@ -142,7 +152,7 @@ checkDependencies
142152# ******************************************************************************
143153
144154cd " $temp_app_path "
145- create_react_app --scripts-version=react-scripts-fork test-app-fork
155+ npx create-react-app --scripts-version=react-scripts-fork test-app-fork
146156cd test-app-fork
147157
148158# Check corresponding scripts version is installed.
@@ -154,7 +164,7 @@ exists node_modules/react-scripts-fork
154164
155165cd " $temp_app_path "
156166# we will install a non-existing package to simulate a failed installataion.
157- create_react_app --scripts-version=` date +%s` test-app-should-not-exist || true
167+ npx create-react-app --scripts-version=` date +%s` test-app-should-not-exist || true
158168# confirm that the project folder was deleted
159169test ! -d test-app-should-not-exist
160170
@@ -166,7 +176,7 @@ cd "$temp_app_path"
166176mkdir test-app-should-remain
167177echo ' ## Hello' > ./test-app-should-remain/README.md
168178# we will install a non-existing package to simulate a failed installataion.
169- create_react_app --scripts-version=` date +%s` test-app-should-remain || true
179+ npx create-react-app --scripts-version=` date +%s` test-app-should-remain || true
170180# confirm the file exist
171181test -e test-app-should-remain/README.md
172182# confirm only README.md is the only file in the directory
180190
181191cd $temp_app_path
182192curl " https://registry.npmjs.org/@enoah_netzach/react-scripts/-/react-scripts-0.9.0.tgz" -o enoah-scripts-0.9.0.tgz
183- create_react_app --scripts-version=$temp_app_path /enoah-scripts-0.9.0.tgz test-app-scoped-fork-tgz
193+ npx create-react-app --scripts-version=$temp_app_path /enoah-scripts-0.9.0.tgz test-app-scoped-fork-tgz
184194cd test-app-scoped-fork-tgz
185195
186196# Check corresponding scripts version is installed.
@@ -195,20 +205,20 @@ cd "$temp_app_path"
195205mkdir test-app-nested-paths-t1
196206cd test-app-nested-paths-t1
197207mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
198- create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
208+ npx create-react-app test-app-nested-paths-t1/aa/bb/cc/dd
199209cd test-app-nested-paths-t1/aa/bb/cc/dd
200210yarn start --smoke-test
201211
202212# Testing a path that does not exist
203213cd " $temp_app_path "
204- create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
214+ npx create-react-app test-app-nested-paths-t2/aa/bb/cc/dd
205215cd test-app-nested-paths-t2/aa/bb/cc/dd
206216yarn start --smoke-test
207217
208218# Testing a path that is half exists
209219cd " $temp_app_path "
210220mkdir -p test-app-nested-paths-t3/aa
211- create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
221+ npx create-react-app test-app-nested-paths-t3/aa/bb/cc/dd
212222cd test-app-nested-paths-t3/aa/bb/cc/dd
213223yarn start --smoke-test
214224
0 commit comments