Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
2f62ff84
Commit
2f62ff84
authored
8 years ago
by
Dan Abramov
Browse files
Options
Download
Email Patches
Plain Diff
Clarify some of the comments
parent
6c8713b7
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tasks/clean_pack.sh
+20
-23
tasks/clean_pack.sh
tasks/e2e.sh
+2
-1
tasks/e2e.sh
tasks/release.sh
+8
-13
tasks/release.sh
with
30 additions
and
37 deletions
+30
-37
tasks/clean_pack.sh
+
20
-
23
View file @
2f62ff84
...
...
@@ -5,14 +5,15 @@
# 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.
# In success case, the only output to stdout is the packagename,
# which might be used by the caller of `tasks/clean_pack.sh`
# This script cleans up the code from blocks only used during local development.
# We call this as part of the `release.sh` script.
# On success, the only output to stdout is the package name.
# Start even if run from root directory
cd
"
$(
dirname
"
$0
"
)
"
#
p
rint error messages to stderr
#
t
he c
leanup function is optionally defined in caller script
#
P
rint error messages to stderr
.
#
T
he c
alling script may then handle them.
function
handle_error
{
echo
"
$(
basename
$0
)
:
\0
33[31mERROR!
\0
33[m An error was encountered executing
\0
33[36mline
$1
\0
33[m."
1>&2
;
cleanup
...
...
@@ -28,8 +29,8 @@ function handle_exit {
function
cleanup
{
cd
$initial_path
#
remove Jest
snap test
file from local dev project if exists
rm
../template/src/__
tests__/__
snapshots__/App
-
test.js.snap
#
Uncomment when
snap
shot
test
ing is enabled by default:
#
rm ../template/src/__snapshots__/App
.
test.js.snap
rm
-rf
../
$clean_path
}
...
...
@@ -39,29 +40,23 @@ trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
# Cleanup before exit on any termination signal
trap
'set +x; handle_exit'
SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
# `tasks/clean_pack.sh` the two directories to make sure they are valid npm modules
initial_path
=
$PWD
# Go to root
initial_path
=
$PWD
cd
..
# create a temporary clean folder that contains production only code
# do not overwrite any files in the current folder
# Create a temporary clean folder that contains production-only code.
# Do not overwrite any files in the current folder.
clean_path
=
`
mktemp
-d
clean_XXXX
`
# copy files to folder .clean-pack
# `npm publish` looks package.json, if it has a files field, only pack listed files
# follwoing folders, although not listed in the files field, are not copied
# - .git : contains lot of small files
# - $clean_path : the destination folder
# - node_modules : contains lots of small files
# - build : .gitignored folder used in local development
# Copy some of the project files to the temporary folder.
# Exclude folders that definitely won’t be part of the package from processing.
# We will strip the dev-only code there, and then copy files back.
rsync
-av
--exclude
=
'.git'
--exclude
=
$clean_path
\
--exclude
=
'node_modules'
--exclude
=
'build'
\
'./'
$clean_path
>
/dev/null
--exclude
=
'node_modules'
--exclude
=
'build'
\
'./'
$clean_path
>
/dev/null
# Now remove all the code relevant to development of Create React App.
cd
$clean_path
# remove dev-only code
files
=
"
$(
find
-L
.
-name
"*.js"
-type
f
)
"
for
file
in
$files
;
do
sed
-i
.bak
'/\/\/ @remove-on-publish-begin/,/\/\/ @remove-on-publish-end/d'
$file
...
...
@@ -71,8 +66,10 @@ done
# Pack!
packname
=
`
npm pack
`
# copy package
to current folder
#
Now we can
copy
the
package
back.
cd
..
cp
-f
$clean_path
/
$packname
./
cleanup
# Output the package name so `release.sh` can pick it up.
echo
$packname
This diff is collapsed.
Click to expand it.
tasks/e2e.sh
+
2
-
1
View file @
2f62ff84
...
...
@@ -81,7 +81,8 @@ cd global-cli
npm
install
cli_path
=
$PWD
/
`
npm pack
`
# Install the cli in a temporary location ( http://unix.stackexchange.com/a/84980 )
# Install the CLI in a temporary location
# http://unix.stackexchange.com/a/84980
temp_cli_path
=
`
mktemp
-d
2>/dev/null
||
mktemp
-d
-t
'temp_cli_path'
`
cd
$temp_cli_path
npm
install
$cli_path
...
...
This diff is collapsed.
Click to expand it.
tasks/release.sh
+
8
-
13
View file @
2f62ff84
...
...
@@ -31,24 +31,19 @@ if [ -n "$(git status --porcelain)" ]; then
exit
1
;
fi
#
c
reate a temporary clean folder that contains production only code
#
d
o not overwrite any files in the current folder
#
C
reate a temporary clean folder that contains production only code
.
#
D
o not overwrite any files in the current folder
.
clean_path
=
`
mktemp
-d
clean_XXXX
`
# copy files to folder .clean-pack
# `npm publish` looks package.json, if it has a files field, only pack listed files
# follwoing folders, although not listed in the files field, are not copied
# - .git : contains lot of small files
# - $clean_path : the destination folder
# - node_modules : contains lots of small files
# - build : .gitignored folder used in local development
# Copy some of the project files to the temporary folder.
# Exclude folders that definitely won’t be part of the package from processing.
# We will strip the dev-only code there, and then copy files back.
rsync
-av
--exclude
=
'.git'
--exclude
=
$clean_path
\
--exclude
=
'node_modules'
--exclude
=
'build'
\
'./'
'$clean_path'
>
/dev/null
--exclude
=
'node_modules'
--exclude
=
'build'
\
'./'
'$clean_path'
>
/dev/null
# Now remove all the code relevant to development of Create React App.
cd
$clean_path
# remove dev-only code
files
=
"
$(
find
-L
.
-name
"*.js"
-type
f
)
"
for
file
in
$files
;
do
sed
-i
.bak
'/\/\/ @remove-on-publish-begin/,/\/\/ @remove-on-publish-end/d'
$file
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets