Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-nodejs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-nodejs
Commits
545b330b
Unverified
Commit
545b330b
authored
Oct 08, 2018
by
Jeremy Morrell
Committed by
GitHub
Oct 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve bin/detect error messages (#575)
parent
549a36a9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
92 additions
and
1 deletion
+92
-1
detect
bin/detect
+65
-1
.gitignore
test/fixtures/gitignore-package-json/.gitignore
+1
-0
LICENSE
test/fixtures/node-project-missing-package-json/LICENSE
+0
-0
README.md
test/fixtures/node-project-missing-package-json/README.md
+0
-0
index.js
test/fixtures/node-project-missing-package-json/index.js
+0
-0
CHANGELOG.md
...xtures/node-project-missing-package-json/src/CHANGELOG.md
+0
-0
app.js
test/fixtures/node-project-missing-package-json/src/app.js
+0
-0
webpack.config.js
...s/node-project-missing-package-json/src/webpack.config.js
+0
-0
.slugignore
test/fixtures/slugignore-package-json/.slugignore
+1
-0
run
test/run
+25
-0
No files found.
bin/detect
View file @
545b330b
#!/usr/bin/env bash
#!/usr/bin/env bash
# bin/detect <build-dir>
# bin/detect <build-dir>
error
()
{
local
c
=
"2,999 s/^/ ! /"
# send all of our output to stderr
exec
1>&2
echo
-e
"
\0
33[1;31m"
# bold; red
echo
-n
" ! ERROR: "
# this will be fed from stdin
case
$(
uname
)
in
Darwin
)
sed
-l
"
$c
"
;;
# mac/bsd sed: -l buffers on line boundaries
*
)
sed
-u
"
$c
"
;;
# unix/gnu sed: -u unbuffered (arbitrary) chunks of data
esac
echo
-e
"
\0
33[0m"
# reset style
exit
1
}
if
[
-f
$1
/package.json
]
;
then
if
[
-f
$1
/package.json
]
;
then
echo
'Node.js'
echo
'Node.js'
exit
0
exit
0
fi
fi
>
&2
echo
'Node.js: package.json not found in application root'
if
[[
-f
"
$1
/.slugignore"
]]
&&
grep
-Fxq
"package.json"
"
$1
/.slugignore"
;
then
error
<<
EOF
'package.json' listed in '.slugignore' file
The 'heroku/nodejs' buildpack is set on this application, but was
unable to detect a 'package.json' file. This is likely because
the '.slugignore' file is removing it before the build begins.
For more information, refer to the following documentation:
https://devcenter.heroku.com/articles/slug-compiler#ignoring-files-with-slugignore
EOF
elif
[[
-f
"
$1
/.gitignore"
]]
&&
grep
-Fxq
"package.json"
"
$1
/.gitignore"
;
then
error
<<
EOF
'package.json' listed in '.gitignore' file
The 'heroku/nodejs' buildpack is set on this application, but was
unable to detect a 'package.json' file. This is likely because
the '.gitignore' file is preventing it from being checked in to
the git repo.
For more information, refer to the following documentation:
https://devcenter.heroku.com/articles/gitignore
EOF
else
error
<<-
EOF
Application not supported by 'heroku/nodejs' buildpack
The 'heroku/nodejs' buildpack is set on this application, but was
unable to detect a Node.js codebase.
A Node.js app on Heroku requires a 'package.json' at the root of
the directory structure.
If you are trying to deploy a Node.js application, ensure that this
file is present at the top level directory. This directory has the
following files:
$(
ls
-1p
$1
)
If you are trying to deploy an application written in another
language, you need to change the list of buildpacks set on your
Heroku app using the 'heroku buildpacks' command.
For more information, refer to the following documentation:
https://devcenter.heroku.com/articles/buildpacks
https://devcenter.heroku.com/articles/nodejs-support#activation
EOF
fi
exit
1
exit
1
test/fixtures/gitignore-package-json/.gitignore
0 → 100644
View file @
545b330b
package.json
test/fixtures/node-project-missing-package-json/LICENSE
0 → 100644
View file @
545b330b
test/fixtures/node-project-missing-package-json/README.md
0 → 100644
View file @
545b330b
test/fixtures/node-project-missing-package-json/index.js
0 → 100644
View file @
545b330b
test/fixtures/node-project-missing-package-json/src/CHANGELOG.md
0 → 100644
View file @
545b330b
test/fixtures/node-project-missing-package-json/src/app.js
0 → 100644
View file @
545b330b
test/fixtures/node-project-missing-package-json/src/webpack.config.js
0 → 100644
View file @
545b330b
test/fixtures/slugignore-package-json/.slugignore
0 → 100644
View file @
545b330b
package.json
test/run
View file @
545b330b
...
@@ -990,6 +990,22 @@ testMemoryMetrics() {
...
@@ -990,6 +990,22 @@ testMemoryMetrics() {
assertFileNotContains
"measure#buildpack.nodejs.exec.heroku-postbuild.memory="
$metrics_log
assertFileNotContains
"measure#buildpack.nodejs.exec.heroku-postbuild.memory="
$metrics_log
}
}
testBinDetectWarnings
()
{
detect
"slugignore-package-json"
assertCapturedError
"'package.json' listed in '.slugignore' file"
assertCapturedError
"https://devcenter.heroku.com/articles/slug-compiler#ignoring-files-with-slugignore"
detect
"gitignore-package-json"
assertCapturedError
"'package.json' listed in '.gitignore' file"
assertCapturedError
"https://devcenter.heroku.com/articles/gitignore"
detect
"node-project-missing-package-json"
assertCapturedError
"Application not supported by 'heroku/nodejs' buildpack"
assertCapturedError
"https://devcenter.heroku.com/articles/nodejs-support#activation"
assertCapturedError
"index.js"
assertCapturedError
"src/"
}
# Utils
# Utils
pushd
"
$(
dirname
0
)
"
>
/dev/null
pushd
"
$(
dirname
0
)
"
>
/dev/null
...
@@ -1018,6 +1034,15 @@ default_process_types_cleanup() {
...
@@ -1018,6 +1034,15 @@ default_process_types_cleanup() {
fi
fi
}
}
detect
()
{
default_process_types_cleanup
bp_dir
=
$(
mktmpdir
)
compile_dir
=
$(
mktmpdir
)
cp
-a
"
$(
pwd
)
"
/
*
${
bp_dir
}
cp
-a
${
bp_dir
}
/test/fixtures/
$1
/.
${
compile_dir
}
capture
${
bp_dir
}
/bin/detect
${
compile_dir
}
}
compile
()
{
compile
()
{
default_process_types_cleanup
default_process_types_cleanup
bp_dir
=
$(
mktmpdir
)
bp_dir
=
$(
mktmpdir
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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