heroku 10.3.1-alpha.0 → 10.3.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ const historyFile = path.join(process.env.HOME || process.env.USERPROFILE, '.her
11
11
  const stateFile = path.join(process.env.HOME || process.env.USERPROFILE, '.heroku_repl_state')
12
12
 
13
13
  const maxHistory = 1000
14
-
14
+ const mcpMode = process.env.HEROKU_MCP_MODE === 'true'
15
15
  /**
16
16
  * Map of commands used to provide completion
17
17
  * data. The key is the flag or arg name to
@@ -81,6 +81,10 @@ class HerokuRepl {
81
81
  removeHistoryDuplicates: true,
82
82
  historySize: maxHistory,
83
83
  completer: async line => {
84
+ if (mcpMode) {
85
+ return [[], line]
86
+ }
87
+
84
88
  const [command, ...parts] = line.split(' ')
85
89
  if (command === 'set') {
86
90
  return this.#buildSetCompletions(parts)
@@ -102,8 +106,11 @@ class HerokuRepl {
102
106
  * @param {Config} config The oclif core config object
103
107
  */
104
108
  constructor(config) {
105
- this.#prepareHistory()
106
- this.#loadState()
109
+ if (!mcpMode) {
110
+ this.#prepareHistory()
111
+ this.#loadState()
112
+ }
113
+
107
114
  this.#config = config
108
115
  }
109
116
 
@@ -161,7 +168,7 @@ class HerokuRepl {
161
168
  async done() {
162
169
  await new Promise(resolve => {
163
170
  this.#rl.once('close', () => {
164
- this.#historyStream.close()
171
+ this.#historyStream?.close()
165
172
  fs.writeFileSync(stateFile, JSON.stringify(Object.fromEntries(this.#setValues)), 'utf8')
166
173
  resolve()
167
174
  })
@@ -191,7 +198,7 @@ class HerokuRepl {
191
198
  */
192
199
  #processLine = async input => {
193
200
  this.#history.push(input)
194
- this.#historyStream.write(input + '\n')
201
+ this.#historyStream?.write(input + '\n')
195
202
 
196
203
  const [command, ...args] = input.split(' ')
197
204
  if (command === 'exit') {
@@ -230,14 +237,32 @@ class HerokuRepl {
230
237
  // the REPL to enter an invalid state. We need
231
238
  // to pause the readline interface and restore
232
239
  // it when the command is done.
233
- process.stdin.setRawMode(false)
240
+ if (process.stdin.isTTY) {
241
+ process.stdin.setRawMode(false)
242
+ }
243
+
234
244
  this.#rl.pause()
235
245
  this.#rl.off('line', this.#processLine)
246
+ if (mcpMode) {
247
+ process.stdout.write('<<<BEGIN RESULTS>>>\n')
248
+ }
249
+
236
250
  await this.#config.runCommand(command, args.filter(Boolean))
237
251
  } catch (error) {
238
- console.error(error.message)
252
+ if (mcpMode) {
253
+ process.stderr.write(`<<<ERROR>>>\n${error.message}\n<<<END ERROR>>>\n`)
254
+ } else {
255
+ console.error(error.message)
256
+ }
239
257
  } finally {
240
- process.stdin.setRawMode(true)
258
+ if (process.stdin.isTTY) {
259
+ process.stdin.setRawMode(true)
260
+ }
261
+
262
+ if (mcpMode) {
263
+ process.stdout.write('<<<END RESULTS>>>\n')
264
+ }
265
+
241
266
  this.#rl.resume()
242
267
  this.#rl.on('line', this.#processLine)
243
268
  // Force readline to refresh the current line
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function default_1() {
4
- const host = process.env.HEROKU_DATA_HOST || process.env.HEROKU_POSTGRESQL_HOST;
5
- return host ? host : 'api.data.heroku.com';
4
+ return process.env.HEROKU_DATA_HOST || 'api.data.heroku.com';
6
5
  }
7
6
  exports.default = default_1;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  exports.default = (app, database, json, heroku) => {
6
- const HOST = process.env.HEROKU_REDIS_HOST || 'api.data.heroku.com';
6
+ const HOST = process.env.HEROKU_DATA_HOST || process.env.HEROKU_REDIS_HOST || 'api.data.heroku.com';
7
7
  const ADDON = process.env.HEROKU_REDIS_ADDON_NAME || 'heroku-redis';
8
8
  return {
9
9
  request(path, method = 'GET', body = null) {
@@ -14486,5 +14486,5 @@
14486
14486
  ]
14487
14487
  }
14488
14488
  },
14489
- "version": "10.3.1-alpha.0"
14489
+ "version": "10.3.1-alpha.2"
14490
14490
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "heroku",
3
3
  "description": "CLI to interact with Heroku",
4
- "version": "10.3.1-alpha.0",
4
+ "version": "10.3.1-alpha.2",
5
5
  "author": "Heroku",
6
6
  "bin": "./bin/run",
7
7
  "bugs": "https://github.com/heroku/cli/issues",
@@ -398,5 +398,5 @@
398
398
  "version": "oclif readme --multi && git add README.md ../../docs"
399
399
  },
400
400
  "types": "lib/index.d.ts",
401
- "gitHead": "8a2d0aaa20a89db92a7ecc1e7c054e2ae95d2abb"
401
+ "gitHead": "0acca590c6553e4bcd04a75f8fffcf6e2d49e2e4"
402
402
  }