Skip to content

Commit

Permalink
Merge branch 'main' into versioned
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 9, 2022
2 parents 4ae917e + 6893ad6 commit 1bf12c8
Show file tree
Hide file tree
Showing 25 changed files with 178 additions and 361 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"d3-scale": "4.0.2",
"diff": "5.1.0",
"esbuild": "0.15.10",
"esbuild-css-modules-plugin": "2.5.2",
"eslint": "8.24.0",
"esbuild-css-modules-plugin": "2.6.0",
"eslint": "8.25.0",
"eslint-config-next": "12.3.1",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
Expand Down
4 changes: 0 additions & 4 deletions ts/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ package(default_visibility = ["//:__subpackages__"])

ts_project(
name = "ts",
srcs = glob(
include = ["*.ts"],
exclude = ["*_test.ts"],
),
)
8 changes: 8 additions & 0 deletions ts/fs/BUILD
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"],
)
9 changes: 9 additions & 0 deletions ts/fs/index.ts
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;
}
}
22 changes: 7 additions & 15 deletions ts/pulumi/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//ts:rules.bzl", "nodejs_binary", "ts_project")
load("//ts:rules.bzl", "jest_test", "nodejs_binary", "ts_project")
load("@bazel_skylib//rules:native_binary.bzl", "native_test")

package(default_visibility = ["//deploy:__subpackages__"])
Expand All @@ -16,26 +16,18 @@ ts_project(
deps = [
"//ts/pulumi/dog",
"//ts/pulumi/im",
"//ts/pulumi/im/shadwell/thomas",
"//ts/pulumi/me",
"@npm//@types/cross-spawn",
"@npm//@types/jest",
"@npm//cross-spawn",
],
)

nodejs_binary(
name = "configs",
data = [
":pulumi",
":pulumi_files",
],
entry_point = "test.js",
)

native_test(
name = "configs_test",
src = ":configs.sh",
out = "whatever",
data = [":configs"],
jest_test(
name = "tests",
srcs = ["pulumi_test.js"],
deps = [":pulumi"],
)

nodejs_binary(
Expand Down
8 changes: 4 additions & 4 deletions ts/pulumi/dog/pleaseintroducemetoyour/index.ts
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';
2 changes: 2 additions & 0 deletions ts/pulumi/dog/pleaseintroducemetoyour/public/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ts_project(
name = "public",
data = ["//ts/pulumi/dog/pleaseintroducemetoyour/public/static"],
deps = [
"//ts/fs",
"//ts/pulumi/lib",
"@npm//@bazel/runfiles",
"@npm//@pulumi/aws",
"@npm//@pulumi/pulumi",
Expand Down
65 changes: 39 additions & 26 deletions ts/pulumi/dog/pleaseintroducemetoyour/public/index.ts
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;
1 change: 1 addition & 0 deletions ts/pulumi/dog/pleaseintroducemetoyour/public/static/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package(default_visibility = ["//ts/pulumi/dog/pleaseintroducemetoyour/public:__
ts_project(
name = "ts",
deps = [
"@npm//@bazel/runfiles",
"@npm//@types/react",
"@npm//next",
"@npm//react",
Expand Down
3 changes: 2 additions & 1 deletion ts/pulumi/im/shadwell/thomas/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("//ts:rules.bzl", "ts_project")

package(default_visibility = ["//ts/pulumi/im/shadwell:__pkg__"])
#package(default_visibility = ["//ts/pulumi/im/shadwell:__pkg__"])
package(default_visibility = ["//visibility:public"])

ts_project(
name = "thomas",
Expand Down
1 change: 1 addition & 0 deletions ts/pulumi/im/shadwell/thomas/public/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ts_project(
name = "public",
data = ["index.html"],
deps = [
"//ts/pulumi/lib",
"@npm//@bazel/runfiles",
"@npm//@pulumi/aws",
"@npm//@pulumi/pulumi",
Expand Down
4 changes: 2 additions & 2 deletions ts/pulumi/im/shadwell/thomas/public/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { runfiles } from '@bazel/runfiles';
import * as aws from '@pulumi/aws';
import * as pulumi from '@pulumi/pulumi';
import mime from 'mime';
import { fileAsset } from 'monorepo/ts/pulumi/lib';
import path from 'path';

const basePath = 'ts/pulumi/im/shadwell/thomas/public';
Expand All @@ -14,7 +14,7 @@ const file =
key: workspacePath,
bucket,
contentType: mime.getType(absolutePath) || undefined,
source: new pulumi.asset.FileAsset(absolutePath),
source: fileAsset(absolutePath),
acl: 'public-read',
});
};
Expand Down
11 changes: 11 additions & 0 deletions ts/pulumi/lib/BUILD
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",
],
)
8 changes: 8 additions & 0 deletions ts/pulumi/lib/index.ts
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);
}
1 change: 0 additions & 1 deletion ts/pulumi/me/zemn/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package(default_visibility = ["//ts/pulumi/me:__pkg__"])
ts_project(
name = "zemn",
deps = [
"//ts/pulumi/me/zemn/factorio",
"//ts/pulumi/me/zemn/zone",
"@npm//@pulumi/aws",
"@npm//@pulumi/pulumi",
Expand Down
16 changes: 0 additions & 16 deletions ts/pulumi/me/zemn/factorio/BUILD

This file was deleted.

63 changes: 0 additions & 63 deletions ts/pulumi/me/zemn/factorio/config.json

This file was deleted.

Loading

0 comments on commit 1bf12c8

Please sign in to comment.