-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vandita Patidar
committed
Feb 17, 2025
1 parent
e63ca97
commit bb4eeef
Showing
7 changed files
with
552 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,50 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "." | ||
}, | ||
{ | ||
"path": "packages/toolkit" | ||
}, | ||
{ | ||
"path": "packages/core" | ||
}, | ||
{ | ||
"path": "packages/amazonq" | ||
} | ||
], | ||
"settings": { | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} | ||
} | ||
"folders": [ | ||
{ | ||
"path": ".", | ||
}, | ||
{ | ||
"path": "packages/toolkit", | ||
}, | ||
{ | ||
"path": "packages/core", | ||
}, | ||
{ | ||
"path": "packages/amazonq", | ||
}, | ||
], | ||
"settings": { | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
}, | ||
"launch": { | ||
"configurations": [ | ||
{ | ||
"type": "aws-sam", | ||
"request": "direct-invoke", | ||
"name": "core:src/awsService/appBuilder/serverlessLand.getProjectUri (nodejs14.x)", | ||
"invokeTarget": { | ||
"target": "code", | ||
"projectRoot": "/Users/vanditap/src/github.com/aws-toolkit-vscode/packages/core", | ||
"lambdaHandler": "src/awsService/appBuilder/serverlessLand.getProjectUri", | ||
}, | ||
"lambda": { | ||
"runtime": "nodejs14.x", | ||
"payload": {}, | ||
"environmentVariables": {}, | ||
}, | ||
}, | ||
{ | ||
"name": "Test Lint", | ||
"type": "node", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/scripts/lint/testLint.ts", | ||
"outFiles": ["${workspaceFolder}/dist/**/*.js"], | ||
"preLaunchTask": "build", | ||
"presentation": { | ||
"group": "7_TestLint", | ||
"order": 1, | ||
}, | ||
}, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
packages/core/src/awsService/appBuilder/models/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"patterns": { | ||
"s3-lambda-resizing-sam": { | ||
"name": "Resizing image", | ||
"description": "Lambda, S3 • Python, Javascript, Java, .NET • SAM", | ||
"runtimes": [ | ||
{ | ||
"id": "python", | ||
"name": "Python" | ||
}, | ||
{ | ||
"id": "javascript", | ||
"name": "Javascript" | ||
}, | ||
{ | ||
"id": "dotnet", | ||
"name": "Dotnet" | ||
}, | ||
{ | ||
"id": "java", | ||
"name": "Java" | ||
} | ||
], | ||
"iac": [ | ||
{ | ||
"id": "sam", | ||
"name": "SAM" | ||
} | ||
] | ||
}, | ||
"apigw-rest-api-lambda-sam": { | ||
"name": "Rest API", | ||
"description": "Lambda, API Gateway • Python, Javascript, Java, .NET • SAM", | ||
"runtimes": [ | ||
{ | ||
"id": "python", | ||
"name": "Python" | ||
}, | ||
{ | ||
"id": "javascript", | ||
"name": "Javascript" | ||
}, | ||
{ | ||
"id": "dotnet", | ||
"name": "Dotnet" | ||
}, | ||
{ | ||
"id": "java", | ||
"name": "Java" | ||
} | ||
], | ||
"iac": [ | ||
{ | ||
"id": "sam", | ||
"name": "AWS SAM" | ||
} | ||
] | ||
} | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
packages/core/src/awsService/appBuilder/serverlessLand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as nls from 'vscode-nls' | ||
const localize = nls.loadMessageBundle() | ||
import * as path from 'path' | ||
// import * as vscode from 'vscode' | ||
import { getTelemetryResult, RegionProvider } from '../../shared' | ||
import { getLogger } from '../../shared/logger' | ||
import globals from '../../shared/extensionGlobals' | ||
import { checklogs } from '../../shared/localizedText' | ||
// import { fileExists } from '../../shared/filesystemUtilities' | ||
// import { CreateServerlessLandWizardForm } from '../appBuilder/wizards/serverlessLandWizard' | ||
import { Result, telemetry } from '../../shared/telemetry/telemetry' | ||
import { CreateServerlessLandWizard } from '../appBuilder/wizards/serverlessLandWizard' | ||
import { ExtContext } from '../../shared/extensions' | ||
import { addFolderToWorkspace } from '../../shared/utilities/workspaceUtils' | ||
|
||
export const readmeFile: string = 'README.md' | ||
|
||
// export async function getProjectUri( | ||
// config: Pick<CreateServerlessLandWizardForm, 'location' | 'name'>, | ||
// files: string | ||
// ): Promise<vscode.Uri | undefined> { | ||
// if (files.length === 0) { | ||
// throw Error('expected "files" parameter to have at least one item') | ||
// } | ||
// let file: string | ||
// let cfnTemplatePath: string | ||
// for (const f of files) { | ||
// file = f | ||
// cfnTemplatePath = path.resolve(config.location.fsPath, config.name, file) | ||
// if (await fileExists(cfnTemplatePath)) { | ||
// return vscode.Uri.file(cfnTemplatePath) | ||
// } | ||
// } | ||
// void vscode.window.showWarningMessage( | ||
// localize( | ||
// 'AWS.samcli.initWizard.source.error.notFound', | ||
// 'Project created successfully, but {0} file not found: {1}', | ||
// file!, | ||
// cfnTemplatePath! | ||
// ) | ||
// ) | ||
// } | ||
|
||
/** | ||
* Creates a new Serverless Land project using the provided extension context | ||
* @param extContext Extension context containing AWS credentials and region information | ||
* @returns Promise that resolves when the project creation is complete | ||
* | ||
* This function: | ||
* 1. Validates AWS credentials and regions | ||
* 2. Launches the Serverless Land project creation wizard | ||
* 3. Creates the project structure | ||
* 4. Adds the project folder to the workspace | ||
* 5. Opens the README.md file if available | ||
* 6. Handles errors and emits telemetry | ||
*/ | ||
export async function createNewServerlessLandProject(extContext: ExtContext): Promise<void> { | ||
const awsContext = extContext.awsContext | ||
const regionProvider: RegionProvider = extContext.regionProvider | ||
let createResult: Result = 'Succeeded' | ||
let reason: string | undefined | ||
|
||
try { | ||
const credentials = await awsContext.getCredentials() | ||
const schemaRegions = regionProvider | ||
.getRegions() | ||
.filter((r) => regionProvider.isServiceInRegion('schemas', r.id)) | ||
const defaultRegion = awsContext.getCredentialDefaultRegion() | ||
|
||
// Launch the project creation wizard | ||
const config = await new CreateServerlessLandWizard({ | ||
credentials, | ||
schemaRegions, | ||
defaultRegion, | ||
}).run() | ||
if (!config) { | ||
createResult = 'Cancelled' | ||
reason = 'userCancelled' | ||
return | ||
} | ||
|
||
// Add the project folder to the workspace | ||
await addFolderToWorkspace( | ||
{ | ||
uri: config.location, | ||
name: path.basename(config.location.fsPath), | ||
}, | ||
true | ||
) | ||
|
||
// Verify project creation and locate project files | ||
// const projectUri = await getProjectUri(config, readmeFile) | ||
// if (!projectUri) { | ||
// reason = 'fileNotFound' | ||
|
||
// return | ||
// } | ||
|
||
// Open README.md file | ||
// const readmeUri = vscode.Uri.file(path.join(path.dirname(projectUri.fsPath), readmeFile)) | ||
// if (await fileExists(readmeUri.fsPath)) { | ||
// const document = await vscode.workspace.openTextDocument(readmeUri) | ||
// await vscode.window.showTextDocument(document) | ||
// } else { | ||
// getLogger().warn( | ||
// localize('AWS.serverlessLand.readme.notFound', 'README.md file not found in the project directory') | ||
// ) | ||
// } | ||
} catch (err) { | ||
createResult = getTelemetryResult(err) | ||
reason = getTelemetryResult(err) | ||
|
||
globals.outputChannel.show(true) | ||
getLogger().error( | ||
localize('AWS.samcli.initWizard.general.error', 'Error creating new SAM Application. {0}', checklogs()) | ||
) | ||
|
||
getLogger().error('Error creating new SAM Application: %O', err as Error) | ||
} finally { | ||
// add telemetry | ||
telemetry.sam_init.emit({ | ||
result: createResult, | ||
reason: reason, | ||
}) | ||
} | ||
} |
Oops, something went wrong.