@byaga/cdk-patterns 0.8.5 → 0.9.1
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.
- package/lib/DeployStack.d.ts +2 -0
- package/lib/DeployStack.js +12 -6
- package/lib/IStackArguments.d.ts +1 -0
- package/lib/SsmParameter.d.ts +1 -0
- package/lib/SsmParameter.js +1 -1
- package/lib/StaticWebSite.d.ts +5 -0
- package/lib/StaticWebSite.js +55 -40
- package/lib/methods/empty-directory.js +0 -1
- package/package.json +2 -2
- package/.fleet/run.json +0 -11
- package/src/ApiCertificate.ts +0 -32
- package/src/CognitoApiGatewayAuthorizer.ts +0 -25
- package/src/DeployStack.ts +0 -56
- package/src/DynamoDbTable.ts +0 -40
- package/src/FunctionIntegration.ts +0 -93
- package/src/ICorsConfig.ts +0 -5
- package/src/IDomainConfig.ts +0 -8
- package/src/IHostedZoneConfig.ts +0 -5
- package/src/IStackArguments.ts +0 -8
- package/src/NodeJsLambda.ts +0 -31
- package/src/NodeJsLambdaLayer.ts +0 -27
- package/src/Output.ts +0 -11
- package/src/RestApi.ts +0 -180
- package/src/Role.ts +0 -165
- package/src/SsmParameter.ts +0 -47
- package/src/StaticWebSite.ts +0 -99
- package/src/index.ts +0 -15
- package/src/methods/apply-honeycomb-to-lambda.ts +0 -22
- package/src/methods/build-node-source.ts +0 -97
- package/src/methods/duration.ts +0 -24
- package/src/methods/empty-directory.ts +0 -19
- package/src/methods/generate-hash.ts +0 -49
- package/src/methods/get-source-directory.ts +0 -11
- package/src/methods/walk-directory.ts +0 -30
@@ -1,49 +0,0 @@
|
|
1
|
-
import * as crypto from 'crypto'
|
2
|
-
import * as path from 'path'
|
3
|
-
import * as fs from 'fs'
|
4
|
-
import walk, {IIgnoreOptions} from './walk-directory'
|
5
|
-
|
6
|
-
const ALGO = 'sha1';
|
7
|
-
const ENCODING = 'base64';
|
8
|
-
|
9
|
-
interface HashOptions {
|
10
|
-
ignore: IIgnoreOptions
|
11
|
-
}
|
12
|
-
|
13
|
-
export interface HashResult {
|
14
|
-
hash?: string
|
15
|
-
children?: HashItem[]
|
16
|
-
}
|
17
|
-
export interface HashItem {
|
18
|
-
hash: string,
|
19
|
-
path: string,
|
20
|
-
name: string
|
21
|
-
}
|
22
|
-
|
23
|
-
export function generateHash(folder: string, opt: HashOptions): string {
|
24
|
-
const files = walk(folder, opt.ignore);
|
25
|
-
|
26
|
-
const hash = crypto.createHash(ALGO);
|
27
|
-
const children = files
|
28
|
-
.sort((a, b) => a.fullpath().localeCompare(b.fullpath()))
|
29
|
-
.map((child) => {
|
30
|
-
const relPath = path.relative(process.cwd(), child.fullpath())
|
31
|
-
const fileHash = crypto.createHash(ALGO);
|
32
|
-
fileHash.update(relPath);
|
33
|
-
fileHash.update(fs.readFileSync(child.fullpath()));
|
34
|
-
|
35
|
-
const file = {
|
36
|
-
name: child.name,
|
37
|
-
path: relPath,
|
38
|
-
hash: fileHash.digest(ENCODING)
|
39
|
-
};
|
40
|
-
hash.update(file.hash);
|
41
|
-
|
42
|
-
return file;
|
43
|
-
});
|
44
|
-
|
45
|
-
return JSON.stringify({
|
46
|
-
hash: hash.digest(ENCODING),
|
47
|
-
children
|
48
|
-
}, null, '\t')
|
49
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import * as path from 'path'
|
2
|
-
|
3
|
-
export const sourceRoot = path.resolve(process.cwd(), "../src");
|
4
|
-
export const distributionRoot = path.resolve(process.cwd(), "../dist");
|
5
|
-
|
6
|
-
export function getSourceDirectory(type: string, id: string): string {
|
7
|
-
return path.join(sourceRoot, type, id)
|
8
|
-
}
|
9
|
-
export function getBuildDirectory(type: string, id: string): string {
|
10
|
-
return path.join(distributionRoot, type, id)
|
11
|
-
}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import * as path from 'path'
|
2
|
-
import * as fs from 'fs'
|
3
|
-
|
4
|
-
export interface IIgnoreOptions {
|
5
|
-
excluded?: (stat: fs.Dirent) => boolean,
|
6
|
-
included?: (stat: fs.Dirent) => boolean,
|
7
|
-
childrenExcluded?: (stat: fs.Dirent) => boolean,
|
8
|
-
childrenIncluded?: (stat: fs.Dirent) => boolean
|
9
|
-
}
|
10
|
-
export const yes = () => true
|
11
|
-
export const no = () => false
|
12
|
-
|
13
|
-
export default function walkDirectory(directory: string, options: IIgnoreOptions, filepaths: DirentExtended[] = []): DirentExtended[] {
|
14
|
-
const { excluded = no, included = yes, childrenExcluded = no, childrenIncluded = yes} = options;
|
15
|
-
const files = fs.readdirSync(directory, {withFileTypes: true}) as unknown[] as DirentExtended[];
|
16
|
-
for (let stats of files) {
|
17
|
-
const filepath = path.join(directory, stats.name)
|
18
|
-
stats.fullpath = () => filepath
|
19
|
-
if (stats.isDirectory() && !childrenExcluded(stats) && childrenIncluded(stats)) {
|
20
|
-
walkDirectory(filepath, options, filepaths)
|
21
|
-
} else if (stats.isFile() && !excluded(stats) && included(stats)) {
|
22
|
-
filepaths.push(stats)
|
23
|
-
}
|
24
|
-
}
|
25
|
-
return filepaths;
|
26
|
-
}
|
27
|
-
|
28
|
-
export interface DirentExtended extends fs.Dirent {
|
29
|
-
fullpath: () => string
|
30
|
-
}
|