@@ -2,10 +2,20 @@ import { LayerVersion, LayerVersionOptions } from 'aws-cdk-lib/aws-lambda';
22import { Construct } from 'constructs' ;
33import { Bundling } from './bundling' ;
44import { getManifestPath } from './cargo' ;
5+ // import { CargoProject } from './cargo';
56import { BundlingOptions } from './types' ;
67
7-
8+ /**
9+ * Properties for a RustExtension
10+ */
811export interface RustExtensionProps extends LayerVersionOptions {
12+ /**
13+ * Bundling options
14+ *
15+ * @default - use default bundling options
16+ */
17+ readonly bundling ?: BundlingOptions ;
18+
919 /**
1020 * The name of the binary to build, in case that's different than the package's name.
1121 */
@@ -14,47 +24,48 @@ export interface RustExtensionProps extends LayerVersionOptions {
1424 /**
1525 * Path to a directory containing your Cargo.toml file, or to your Cargo.toml directly.
1626 *
17- * This will accept a directory path containing a `Cargo.toml` file, a filepath to your
18- * `Cargo.toml` file (i.e. `path/to/Cargo.toml`), or a git repository URL
19- * (e.g. `https://github.com/your_user/your_repo`).
20- *
21- * When using a git repository URL, the repository will be cloned to a temporary directory.
27+ * This will accept a directory path containing a `Cargo.toml` file (i.e. `path/to/package`), or a filepath to your
28+ * `Cargo.toml` file (i.e. `path/to/Cargo.toml`). When the `gitRemote` option is provided,
29+ * the `manifestPath` is relative to the root of the git repository.
2230 *
2331 * @default - check the current directory for a `Cargo.toml` file, and throws
2432 * an error if the file doesn't exist.
2533 */
2634 readonly manifestPath ?: string ;
2735
2836 /**
29- * Bundling options
37+ * The git remote URL to clone (e.g `https://github.com/your_user/your_repo`).
3038 *
31- * @default - use default bundling options
39+ * This repository will be cloned to a temporary directory using `git`.
40+ * The `git` command must be available in the PATH.
3241 */
33- readonly bundling ?: BundlingOptions ;
42+ readonly gitRemote ?: string ;
3443
3544 /**
36- * The branch to clone if the `manifestPath` is a git repository.
45+ * The git reference to checkout. This can be a branch, tag, or commit hash.
46+ *
47+ * If this option is not provided, `git clone` will run with the flag `--depth 1`.
3748 *
3849 * @default - the default branch, i.e. HEAD.
3950 */
40- readonly branch ?: string ;
51+ readonly gitReference ?: string ;
4152
4253 /**
43- * Always clone the repository if using a git `manifestPath` , even if it has already been
54+ * Always clone the repository if using the `gitRemote` option , even if it has already been
4455 * cloned to the temporary directory.
4556 *
46- * @default - clones only if the repository and branch does not already exist in the
57+ * @default - clones only if the repository and reference don't already exist in the
4758 * temporary directory.
4859 */
49- readonly alwaysClone ?: boolean ;
60+ readonly gitForceClone ?: boolean ;
5061}
5162
5263/**
5364 * A Lambda extension written in Rust
5465 */
5566export class RustExtension extends LayerVersion {
5667 constructor ( scope : Construct , resourceName : string , props ?: RustExtensionProps ) {
57- const manifestPath = getManifestPath ( props ?. manifestPath ?? 'Cargo.toml' , props ?. branch , props ?. alwaysClone ) ;
68+ const manifestPath = getManifestPath ( props || { } ) ;
5869 const bundling = props ?. bundling ?? { } ;
5970
6071 super ( scope , resourceName , {
0 commit comments