| 62 | private buildManifest: BuildManifest | undefined; |
| 63 | |
| 64 | constructor({ |
| 65 | apiKey = validApiKey, |
| 66 | deployConfig = null, |
| 67 | isTty = true, |
| 68 | outputColumns = 80, |
| 69 | debug = false, |
| 70 | fixedInputStatTime, |
| 71 | fixedOutputStatTime, |
| 72 | buildManifest |
| 73 | }: MockDeployEffectsOptions = {}) { |
| 74 | super(); |
| 75 | this.authEffects = new MockAuthEffects(); |
| 76 | this.configEffects = new MockConfigEffects(); |
| 77 | |
| 78 | this.observableApiKey = apiKey; |
| 79 | this.deployConfigs = {}; |
| 80 | this.defaultDeployConfig = deployConfig; |
| 81 | this.isTty = isTty; |
| 82 | this.outputColumns = outputColumns; |
| 83 | this.debug = debug; |
| 84 | this.fixedInputStatTime = fixedInputStatTime; |
| 85 | this.fixedOutputStatTime = fixedOutputStatTime; |
| 86 | this.buildManifest = buildManifest; |
| 87 | |
| 88 | this.output = new Writable({ |
| 89 | write: (data, _enc, callback) => { |
| 90 | const dataString = data.toString(); |
| 91 | let matched = false; |
| 92 | for (const [index, {prompt, response}] of this.ioResponses.entries()) { |
| 93 | if (dataString.match(prompt)) { |
| 94 | // Having to null/reinit input seems wrong. |
| 95 | // TODO: find the correct way to submit to readline but keep the same |
| 96 | // input stream across multiple readline interactions. |
| 97 | this.input.push(`${response}\n`); |
| 98 | this.input.push(null); |
| 99 | this.input = new Readable(); |
| 100 | this.ioResponses.splice(index, 1); |
| 101 | matched = true; |
| 102 | break; |
| 103 | } |
| 104 | } |
| 105 | if (!matched && debug) console.debug("Unmatched output:", dataString); |
| 106 | callback(); |
| 107 | } |
| 108 | }); |
| 109 | } |
| 110 | |
| 111 | private getDeployConfigKey(sourceRoot: string, deployConfigPath?: string): string { |
| 112 | return `${sourceRoot}::${deployConfigPath ?? "<default>"}`; |