Skip to content

Commit

Permalink
refactor(core): fold "assets" to "core"
Browse files Browse the repository at this point in the history
Fold the "assets" module, which includes the `Staging` construct that takes care of staging asset files into the cloud assembly during synthesis into "core". This is in order to allow implementing custom resources that leverage assets throughout the framework.

A subsequent commit will add a mini-framework for custom resources that leverages this capability.
  • Loading branch information
Elad Ben-Israel committed Apr 30, 2020
1 parent 1ee629e commit 4bd8453
Show file tree
Hide file tree
Showing 33 changed files with 361 additions and 193 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"**/jszip/**",
"@aws-cdk/cdk-assets-schema/semver",
"@aws-cdk/cdk-assets-schema/semver/**",
"@aws-cdk/assets/minimatch",
"@aws-cdk/assets/minimatch/**",
"@aws-cdk/core/minimatch",
"@aws-cdk/core/minimatch/**",
"@aws-cdk/aws-codepipeline-actions/case",
"@aws-cdk/aws-codepipeline-actions/case/**",
"@aws-cdk/aws-ecr-assets/minimatch",
Expand Down
10 changes: 3 additions & 7 deletions packages/@aws-cdk/assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
<!--BEGIN STABILITY BANNER-->
---

![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)
![Deprecated](https://img.shields.io/badge/deprecated-critical.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
> This API may emit warnings. Backward compatibility is not guaranteed.
---
<!--END STABILITY BANNER-->

This module includes core classes for to CDK assets, used for copying asset
files to a staging area. Most CDK users should not need to use the classes in
this package directly.


All types moved to @aws-cdk/core.
11 changes: 0 additions & 11 deletions packages/@aws-cdk/assets/lib/api.ts

This file was deleted.

29 changes: 0 additions & 29 deletions packages/@aws-cdk/assets/lib/fs/follow-mode.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/@aws-cdk/assets/lib/fs/index.ts

This file was deleted.

33 changes: 0 additions & 33 deletions packages/@aws-cdk/assets/lib/fs/options.ts

This file was deleted.

71 changes: 67 additions & 4 deletions packages/@aws-cdk/assets/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,67 @@
export * from './api';
export * from './fs/follow-mode';
export * from './fs/options';
export * from './staging';
import * as core from '@aws-cdk/core';

/**
* Deprecated.
* @deprecated moved to `core.IAsset`
*/
export interface IAsset extends core.IAsset { }

/**
* Deprecated.
* @deprecated moved to `core.StagingProps`
*/
export interface StagingProps extends core.AssetStagingProps {

}

/**
* Deprecated.
* @deprecated moved to `core.Staging`
*/
export class Staging extends core.AssetStaging { }

/**
* Deprecated.
* @deprecated moved to `core.CopyOptions`
*/
export interface CopyOptions extends core.CopyOptions { }

/**
* Deprecated.
* @deprecated moved to `core.CopyOptions`
*/
export interface FingerprintOptions extends core.FingerprintOptions { }

/**
* Deprecated.
* @deprecated moved to `core.FollowMode`
*/
export enum FollowMode {
/**
* Never follow symlinks.
*/
NEVER = 'never',

/**
* Materialize all symlinks, whether they are internal or external to the source directory.
*/
ALWAYS = 'always',

/**
* Only follows symlinks that are external to the source directory.
*/
EXTERNAL = 'external',

// ----------------- TODO::::::::::::::::::::::::::::::::::::::::::::
/**
* Forbids source from having any symlinks pointing outside of the source
* tree.
*
* This is the safest mode of operation as it ensures that copy operations
* won't materialize files from the user's file system. Internal symlinks are
* not followed.
*
* If the copy operation runs into an external symlink, it will fail.
*/
BLOCK_EXTERNAL = 'internal-only',
}
21 changes: 7 additions & 14 deletions packages/@aws-cdk/assets/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@aws-cdk/assets",
"version": "0.0.0",
"description": "Integration of CDK apps with local assets",
"description": "This module is deprecated. All types are now available under the core module",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"jsii": {
Expand Down Expand Up @@ -64,7 +64,6 @@
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"@types/minimatch": "^3.0.3",
"@types/nodeunit": "^0.0.30",
"@types/sinon": "^9.0.0",
"aws-cdk": "0.0.0",
Expand All @@ -78,7 +77,6 @@
"dependencies": {
"@aws-cdk/core": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"minimatch": "^3.0.4",
"constructs": "^3.0.2"
},
"homepage": "https://github.com/aws/aws-cdk",
Expand All @@ -90,19 +88,14 @@
"engines": {
"node": ">= 10.12.0"
},
"bundledDependencies": [
"minimatch"
],
"stability": "experimental",
"maturity": "experimental",
"stability": "deprecated",
"maturity": "deprecated",
"awscdkio": {
"announce": false
},
"awslint": {
"exclude": [
"docs-public-apis:@aws-cdk/assets.StagingProps",
"docs-public-apis:@aws-cdk/assets.StagingProps.sourcePath",
"docs-public-apis:@aws-cdk/assets.FollowMode"
"construct-ctor-props-type:@aws-cdk/assets.Staging"
]
},
"awscdkio": {
"announce": false
}
}
2 changes: 0 additions & 2 deletions packages/@aws-cdk/aws-codebuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"pkglint": "0.0.0"
},
"dependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-cloudwatch": "0.0.0",
"@aws-cdk/aws-codecommit": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
Expand All @@ -95,7 +94,6 @@
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-cloudwatch": "0.0.0",
"@aws-cdk/aws-codecommit": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
Expand Down
9 changes: 4 additions & 5 deletions packages/@aws-cdk/aws-ecr-assets/lib/image-asset.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import * as assets from '@aws-cdk/assets';
import * as ecr from '@aws-cdk/aws-ecr';
import { Construct, Stack, Token } from '@aws-cdk/core';
import { AssetStaging, Construct, FingerprintOptions, IAsset, Stack, Token } from '@aws-cdk/core';
import * as fs from 'fs';
import * as minimatch from 'minimatch';
import * as path from 'path';

/**
* Options for DockerImageAsset
*/
export interface DockerImageAssetOptions extends assets.FingerprintOptions {
export interface DockerImageAssetOptions extends FingerprintOptions {
/**
* ECR repository name
*
Expand Down Expand Up @@ -64,7 +63,7 @@ export interface DockerImageAssetProps extends DockerImageAssetOptions {
*
* The image will be created in build time and uploaded to an ECR repository.
*/
export class DockerImageAsset extends Construct implements assets.IAsset {
export class DockerImageAsset extends Construct implements IAsset {
/**
* The full URI of the image (including a tag). Use this reference to pull
* the asset.
Expand Down Expand Up @@ -128,7 +127,7 @@ export class DockerImageAsset extends Construct implements assets.IAsset {
// deletion of the ECR repository the app used).
extraHash.version = '1.21.0';

const staging = new assets.Staging(this, 'Staging', {
const staging = new AssetStaging(this, 'Staging', {
...props,
exclude,
sourcePath: dir,
Expand Down
2 changes: 0 additions & 2 deletions packages/@aws-cdk/aws-ecr-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"@aws-cdk/cloud-assembly-schema": "0.0.0"
},
"dependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-cloudformation": "0.0.0",
"@aws-cdk/aws-ecr": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
Expand All @@ -84,7 +83,6 @@
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-cloudformation": "0.0.0",
"@aws-cdk/aws-ecr": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"pkglint": "0.0.0"
},
"dependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
"@aws-cdk/aws-elasticloadbalancingv2": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
Expand All @@ -94,7 +93,6 @@
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
"@aws-cdk/aws-elasticloadbalancingv2": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
Expand Down
7 changes: 3 additions & 4 deletions packages/@aws-cdk/aws-s3-assets/lib/asset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as assets from '@aws-cdk/assets';
import * as iam from '@aws-cdk/aws-iam';
import * as s3 from '@aws-cdk/aws-s3';
import * as cdk from '@aws-cdk/core';
Expand All @@ -8,7 +7,7 @@ import * as path from 'path';

const ARCHIVE_EXTENSIONS = [ '.zip', '.jar' ];

export interface AssetOptions extends assets.CopyOptions {
export interface AssetOptions extends cdk.CopyOptions {

/**
* A list of principals that should be able to read this asset from S3.
Expand Down Expand Up @@ -50,7 +49,7 @@ export interface AssetProps extends AssetOptions {
* An asset represents a local file or directory, which is automatically uploaded to S3
* and then can be referenced within a CDK application.
*/
export class Asset extends cdk.Construct implements assets.IAsset {
export class Asset extends cdk.Construct implements cdk.IAsset {
/**
* Attribute that represents the name of the bucket this asset exists in.
*/
Expand Down Expand Up @@ -92,7 +91,7 @@ export class Asset extends cdk.Construct implements assets.IAsset {
super(scope, id);

// stage the asset source (conditionally).
const staging = new assets.Staging(this, 'Stage', {
const staging = new cdk.AssetStaging(this, 'Stage', {
...props,
sourcePath: path.resolve(props.path),
});
Expand Down
2 changes: 0 additions & 2 deletions packages/@aws-cdk/aws-s3-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"ts-mock-imports": "^1.3.0"
},
"dependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
"@aws-cdk/aws-s3": "0.0.0",
"@aws-cdk/core": "0.0.0",
Expand All @@ -81,7 +80,6 @@
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
"@aws-cdk/aws-s3": "0.0.0",
"@aws-cdk/core": "0.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-s3-deployment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-cloudformation": "0.0.0",
"@aws-cdk/aws-cloudfront": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/@aws-cdk/aws-stepfunctions-tasks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"pkglint": "0.0.0"
},
"dependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-cloudwatch": "0.0.0",
"@aws-cdk/aws-batch": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
Expand All @@ -107,7 +106,6 @@
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/assets": "0.0.0",
"@aws-cdk/aws-batch": "0.0.0",
"@aws-cdk/aws-cloudwatch": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
Expand Down
Loading

0 comments on commit 4bd8453

Please sign in to comment.