@google-cloud/cloud-run-mcp 1.6.0 → 1.8.0

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.
@@ -0,0 +1,51 @@
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ /**
18
+ * Waits for a specific string to appear in a stream's output.
19
+ * This is useful for synchronizing tests with asynchronous child processes,
20
+ * ensuring that a server or process has started and emitted an
21
+ * expected "ready" message before proceeding with test assertions.
22
+ *
23
+ * @param {ReadableStream} stream - The stream to listen to (e.g., process.stdout or process.stderr).
24
+ * @param {string} str - The string to wait for in the stream's output.
25
+ * @param {number} [timeoutMs=7000] - The maximum time in milliseconds to wait before rejecting.
26
+ * @returns {Promise<string>} A promise that resolves with the accumulated data
27
+ * when the string is found, or rejects if the timeout is reached.
28
+ */
29
+ export async function waitForString(stream, str, timeoutMs = 7000) {
30
+ let accumulatedData = '';
31
+ return new Promise((resolve, reject) => {
32
+ const timeout = setTimeout(() => {
33
+ stream.removeListener('data', onData);
34
+ reject(
35
+ new Error(`waitForString timed out after ${timeoutMs}ms waiting for "${str}".
36
+ Saw:
37
+ ${accumulatedData}`)
38
+ );
39
+ }, timeoutMs);
40
+
41
+ function onData(data) {
42
+ accumulatedData += data.toString();
43
+ if (accumulatedData.includes(str)) {
44
+ clearTimeout(timeout);
45
+ stream.removeListener('data', onData);
46
+ resolve(accumulatedData);
47
+ }
48
+ }
49
+ stream.on('data', onData);
50
+ });
51
+ }
@@ -163,7 +163,7 @@ export async function setSourceDeployProjectPermissions(projectId) {
163
163
  const context = {
164
164
  serviceUsageClient: serviceUsageClient,
165
165
  };
166
- await ensureApisEnabled(context, projectId, ['run.googleapis.com']);
166
+ await ensureApisEnabled(projectId, ['run.googleapis.com']);
167
167
  console.log('Adding editor role to Compute SA...');
168
168
  const projectNumber = await getProjectNumber(projectId);
169
169
  const member = `serviceAccount:${projectNumber}-compute@developer.gserviceaccount.com`;
@@ -43,7 +43,7 @@ describe('Deployment workflows', () => {
43
43
  const configImageDeploy = {
44
44
  projectId: projectId,
45
45
  serviceName: 'hello-scenario',
46
- region: 'europe-west1',
46
+ region: 'us-central1',
47
47
  imageUrl: 'gcr.io/cloudrun/hello',
48
48
  };
49
49
  await deployImage(configImageDeploy);
@@ -55,7 +55,7 @@ describe('Deployment workflows', () => {
55
55
  const configFailingBuild = {
56
56
  projectId: projectId,
57
57
  serviceName: 'example-failing-app',
58
- region: 'europe-west1',
58
+ region: 'us-central1',
59
59
  files: [
60
60
  {
61
61
  filename: 'main.txt',
@@ -83,7 +83,7 @@ describe('Deployment workflows', () => {
83
83
  const configGoWithContent = {
84
84
  projectId: projectId,
85
85
  serviceName: 'example-go-app-content',
86
- region: 'europe-west1',
86
+ region: 'us-central1',
87
87
  files: [
88
88
  { filename: 'main.go', content: mainGoContent },
89
89
  { filename: 'go.mod', content: goModContent },