-
Notifications
You must be signed in to change notification settings - Fork 820
Expand file tree
/
Copy pathindex.ts
More file actions
41 lines (39 loc) · 1.45 KB
/
index.ts
File metadata and controls
41 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { GetPackageAssetPaths } from '@aws-amplify/amplify-cli-core';
import { FunctionRuntimeContributorFactory } from '@aws-amplify/amplify-function-plugin-interface';
import * as fs from 'fs-extra';
import { layerPythonPipFile, relativeShimPath } from './constants';
import { pythonBuild } from './util/buildUtils';
import { pythonInvoke } from './util/invokeUtil';
import { checkDeps } from './util/depUtils';
import { pythonPackage } from './util/packageUtils';
export const functionRuntimeContributorFactory: FunctionRuntimeContributorFactory = (context) => {
return {
contribute: async (request) => {
const selection = request.selection;
if (selection !== 'python') {
throw new Error(`Unknown selection ${selection}`);
}
return {
runtime: {
name: 'Python',
value: 'python',
cloudTemplateValue: 'python3.8',
defaultHandler: 'index.handler',
layerExecutablePath: 'python',
layerDefaultFiles: [
{
path: 'python',
filename: 'Pipfile',
content: fs.readFileSync(layerPythonPipFile, 'utf-8'),
},
],
},
};
},
checkDependencies: checkDeps,
package: (request) => pythonPackage(context, request),
build: pythonBuild,
invoke: (request) => pythonInvoke(context, request),
};
};
export const getPackageAssetPaths: GetPackageAssetPaths = async () => [relativeShimPath];