-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
25 changed files
with
178 additions
and
361 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("//ts:rules.bzl", "ts_project") | ||
|
||
package(default_visibility = ["//:__subpackages__"]) | ||
|
||
ts_project( | ||
name = "fs", | ||
deps = ["@npm//@types/node"], | ||
) |
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,9 @@ | ||
import { Dirent } from 'fs'; | ||
import { readdir } from 'fs/promises'; | ||
|
||
export async function* walk(path: string): AsyncGenerator<Dirent> { | ||
for (const entity of await readdir(path, { withFileTypes: true })) { | ||
if (entity.isDirectory()) yield* walk(entity.name); | ||
yield entity; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './A'; | ||
export * from './cert'; | ||
export * from './cloudfront'; | ||
export * from './zone'; | ||
export * from 'monorepo/ts/pulumi/dog/pleaseintroducemetoyour/A'; | ||
export * from 'monorepo/ts/pulumi/dog/pleaseintroducemetoyour/cert'; | ||
export * from 'monorepo/ts/pulumi/dog/pleaseintroducemetoyour/cloudfront'; | ||
export * as Public from 'monorepo/ts/pulumi/dog/pleaseintroducemetoyour/public'; | ||
export * from 'monorepo/ts/pulumi/dog/pleaseintroducemetoyour/zone'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,55 @@ | ||
import { runfiles } from '@bazel/runfiles'; | ||
import * as aws from '@pulumi/aws'; | ||
import * as pulumi from '@pulumi/pulumi'; | ||
import glob from 'glob-promise'; | ||
import mime from 'mime'; | ||
import { walk } from 'monorepo/ts/fs'; | ||
import { fileAsset } from 'monorepo/ts/pulumi/lib'; | ||
import path from 'path'; | ||
|
||
const basePath = 'ts/pulumi/dog/pleaseintroducemetoyour/public/static/out'; | ||
const basePath = runfiles.resolveWorkspaceRelative( | ||
'ts/pulumi/dog/pleaseintroducemetoyour/public/static/out' | ||
); | ||
|
||
const file = | ||
(bucket: aws.s3.BucketObjectArgs['bucket']) => (relativePath: string) => { | ||
const workspacePath = path.posix.join(basePath, relativePath); | ||
const absolutePath = runfiles.resolveWorkspaceRelative(workspacePath); | ||
return new aws.s3.BucketObject(workspacePath, { | ||
key: workspacePath, | ||
bucket, | ||
contentType: mime.getType(absolutePath) || undefined, | ||
source: new pulumi.asset.FileAsset(absolutePath), | ||
acl: 'public-read', | ||
}); | ||
}; | ||
function trimPrefix(prefix: string, haystack: string): string { | ||
if (!haystack.startsWith(prefix)) | ||
throw new Error( | ||
`Can't trim prefix; ${haystack} doesn't start with ${prefix}` | ||
); | ||
|
||
return haystack.slice(prefix.length); | ||
} | ||
|
||
export const indexPage = fileAsset(path.join(basePath, 'index.html')); | ||
export const errorPage = fileAsset(path.join(basePath, '404.html')); | ||
|
||
export const files = (async function* () { | ||
for await (const entity of walk(basePath)) { | ||
if (!entity.isFile()) continue; | ||
yield fileAsset(entity.name); | ||
} | ||
})(); | ||
|
||
export const bucket = new aws.s3.Bucket('pleaseintroducemetoyour.dog', { | ||
acl: 'public-read', | ||
website: { | ||
indexDocument: 'index.html', | ||
indexDocument: indexPage.then(async asset => | ||
trimPrefix(basePath, await asset.path) | ||
), | ||
errorDocument: errorPage.then(async asset => | ||
trimPrefix(basePath, await asset.path) | ||
), | ||
}, | ||
}); | ||
|
||
const File = file(bucket); | ||
|
||
async function Files() { | ||
const ret = []; | ||
for (const file of await glob(basePath + '/*')) { | ||
ret.push(File(file)); | ||
export const bucketObjects = (async function* () { | ||
for await (const file of files) { | ||
yield new aws.s3.BucketObject(await file.path, { | ||
key: trimPrefix(basePath, await file.path), | ||
bucket, | ||
contentType: mime.getType(await file.path) ?? undefined, | ||
source: file, | ||
acl: 'public-read', | ||
}); | ||
} | ||
return ret; | ||
} | ||
|
||
export const files = Files(); | ||
})(); | ||
|
||
export default bucket; |
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
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
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,11 @@ | ||
load("//ts:rules.bzl", "ts_project") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
ts_project( | ||
name = "lib", | ||
deps = [ | ||
"@npm//@pulumi/pulumi", | ||
"@npm//@types/node", | ||
], | ||
) |
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,8 @@ | ||
import * as fs from 'node:fs/promises'; | ||
|
||
import * as pulumi from '@pulumi/pulumi'; | ||
|
||
export async function fileAsset(file: string | Promise<string>) { | ||
await fs.access(await file); | ||
return new pulumi.asset.FileAsset(await file); | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.