@google-cloud/cloud-run-mcp 1.3.0 → 1.5.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.
@@ -14,64 +14,22 @@ See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import readline from 'readline/promises';
18
- import { stdin as input, stdout as output } from 'process';
17
+ import { test } from 'node:test';
18
+ import assert from 'node:assert';
19
19
  import { createProjectAndAttachBilling } from '../../lib/gcp-projects.js';
20
20
 
21
- /**
22
- * Prompts the user for an optional project ID or allows them to proceed with auto-generation.
23
- * Checks for a project ID from command line arguments first.
24
- * @returns {Promise<string|undefined>} The Google Cloud project ID or undefined if auto-generation is chosen.
25
- */
26
- async function getOptionalProjectId() {
27
- let projectIdInput = process.argv[2]; // Get the third element (index 2) which is the first argument
21
+ test('should create a new project and attach billing', async () => {
22
+ console.log('Attempting to create a new project and attach billing...');
23
+ const newProjectResult = await createProjectAndAttachBilling();
28
24
 
29
- if (projectIdInput && projectIdInput.trim() !== '') {
30
- console.log(
31
- `Using Project ID from command line argument: ${projectIdInput.trim()}`
32
- );
33
- return projectIdInput.trim();
34
- }
35
-
36
- const rl = readline.createInterface({ input, output });
37
- projectIdInput = await rl.question(
38
- 'Enter a specific Project ID to use (or press Enter to auto-generate): '
25
+ assert(newProjectResult, 'newProjectResult should not be null');
26
+ assert(
27
+ newProjectResult.projectId,
28
+ 'newProjectResult.projectId should not be null'
39
29
  );
40
- rl.close();
41
-
42
- if (projectIdInput && projectIdInput.trim() !== '') {
43
- console.log(
44
- `Attempting to create project with specified ID: ${projectIdInput.trim()}`
45
- );
46
- return projectIdInput.trim();
47
- }
48
- console.log('No Project ID specified. An ID will be auto-generated.');
49
- return undefined;
50
- }
51
-
52
- async function main() {
53
- try {
54
- const optionalProjectId = await getOptionalProjectId();
55
- console.log('Attempting to create a new project and attach billing...');
56
- const newProjectResult =
57
- await createProjectAndAttachBilling(optionalProjectId);
58
30
 
59
- if (newProjectResult && newProjectResult.projectId) {
60
- console.log(
61
- `Successfully created project: ${newProjectResult.projectId}`
62
- );
63
- console.log(newProjectResult.billingMessage);
64
- console.log('\nProject creation test completed successfully.');
65
- } else {
66
- console.error(
67
- 'Failed to create a new project or retrieve project details.'
68
- );
69
- process.exit(1);
70
- }
71
- } catch (error) {
72
- console.error('Error during project creation test:', error.message);
73
- process.exit(1);
74
- }
75
- }
76
-
77
- main();
31
+ console.log(
32
+ `Successfully created project: ${newProjectResult.projectId}`
33
+ );
34
+ console.log(newProjectResult.billingMessage);
35
+ });