Skip to content

Commit 98de7d8

Browse files
authored
Merge pull request #42 from heroku/k80/fir-check
feat: add check for fir apps with error messages
2 parents 2d5e113 + 99e9903 commit 98de7d8

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

lib/exec.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ function * checkStatus(context, heroku, configVars) {
5757
});;
5858
}
5959

60-
function * initFeature(context, heroku, callback) {
60+
function * initFeature(context, heroku, command = undefined, callback) {
6161
var buildpackUrls = ["https://github.com/heroku/exec-buildpack", "urn:buildpack:heroku/exec"]
6262
let promises = {
63-
app: heroku.get(`/apps/${context.app}`),
6463
feature: heroku.get(`/apps/${context.app}/features/runtime-heroku-exec`),
6564
config: heroku.get(`/apps/${context.app}/config-vars`),
6665
buildpacks: heroku.request({
@@ -69,16 +68,30 @@ function * initFeature(context, heroku, callback) {
6968
})
7069
}
7170

71+
const app = yield heroku.get(`/apps/${context.app}`, {
72+
headers: {
73+
Accept: 'application/vnd.heroku+json; version=3.sdk'
74+
}
75+
})
76+
77+
if (app.generation === 'fir') {
78+
const errorMessage = command === 'exec' ?
79+
'This command is unavailable for this app. Use `heroku run:inside` instead. See https://devcenter.heroku.com/articles/run-tasks-in-an-existing-dyno.' :
80+
'This command is unavailable for this app. See https://devcenter.heroku.com/articles/generations.'
81+
cli.error(errorMessage)
82+
cli.exit(1);
83+
}
84+
7285
let data = yield promises
7386
let feature = data.feature
7487
let configVars = data.config
7588
let buildpacks = data.buildpacks
7689

77-
if (data.app['space'] != null) {
78-
if (data.app['space']['shield'] === true) {
90+
if (app['space'] != null) {
91+
if (app['space']['shield'] === true) {
7992
cli.error(`This feature is restricted for Shield Private Spaces`)
8093
cli.exit(1);
81-
} else if (data.app['build_stack']['name'] === 'container') {
94+
} else if (app['build_stack']['name'] === 'container') {
8295
cli.warn(`${context.app} is using the container stack which is not officially supported.`);
8396
} else if (buildpacks.length === 0) {
8497
cli.error(`${context.app} has no Buildpack URL set. You must deploy your application first!`)

0 commit comments

Comments
 (0)