Skip to content

Commit fa901fe

Browse files
committed
chore: wip
1 parent a6a58fa commit fa901fe

File tree

11 files changed

+27
-109
lines changed

11 files changed

+27
-109
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ updates
1010
tests/unit/coverage
1111
dist*
1212
storage/app/docs/*
13+
storage/app/cloud/*
1314
!.gitkeep
1415

1516
.fleet

.stacks/core/cloud/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"bootstrap": "cdk bootstrap --profile stacks",
4848
"deploy": "cdk deploy --profile stacks",
4949
"build": "bun build.ts",
50-
"build-layer": "bun scripts/build-layer.ts",
51-
"publish-layer": "bun scripts/publish-layer.ts",
50+
"build-layer": "bun ./src/runtime/aws/scripts/build-layer.ts",
51+
"publish-layer": "bun ./src/runtime/aws/scripts/publish-layer.ts",
5252
"typecheck": "bun --bun tsc --noEmit",
5353
"prepublishOnly": "bun run build"
5454
},

.stacks/core/cloud/src/cloud.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import {
99
aws_certificatemanager as acm,
1010
aws_cloudfront as cloudfront,
1111
aws_cloudfront_origins as origins,
12+
aws_lambda as lambda,
1213
aws_route53 as route53,
1314
aws_s3 as s3,
1415
aws_s3_deployment as s3deploy,
1516
aws_route53_targets as targets,
1617
aws_wafv2 as wafv2,
1718
} from 'aws-cdk-lib'
18-
import { projectPath } from '@stacksjs/path'
19+
import { hasFiles } from '@stacksjs/storage'
20+
import { path as p } from '@stacksjs/path'
1921
import { app } from '@stacksjs/config'
2022

2123
export class StacksCloud extends Stack {
@@ -131,7 +133,7 @@ export class StacksCloud extends Stack {
131133
})
132134

133135
const docsSource = '../../../storage/app/docs'
134-
const websiteSource = app.docMode ? docsSource : '../../../storage/app/public'
136+
const websiteSource = app.docMode ? docsSource : '../../../storage/public'
135137
const privateSource = '../../../storage/private'
136138

137139
new s3deploy.BucketDeployment(this, 'DeployWebsite', {
@@ -146,6 +148,14 @@ export class StacksCloud extends Stack {
146148
destinationBucket: privateBucket,
147149
})
148150

151+
const layer = new lambda.LayerVersion(this, 'Stacks', {
152+
code: lambda.Code.fromAsset(p.projectStoragePath('app/cloud/bun-lambda-layer.zip')),
153+
compatibleRuntimes: [lambda.Runtime.PROVIDED_AL2, lambda.Runtime.PROVIDED],
154+
compatibleArchitectures: [lambda.Architecture.ARM_64],
155+
license: 'MIT',
156+
description: 'Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager.',
157+
});
158+
149159
if (shouldDeployDocs()) {
150160
this.deployDocs(zone, originAccessIdentity, webAcl, docsSource, logBucket)
151161
}
@@ -248,10 +258,10 @@ export class StacksCloud extends Stack {
248258
distributionPaths: ['/*'],
249259
})
250260

251-
new Output(this, 'DocsBucketName', {
252-
value: docsBucket.bucketName,
253-
description: 'The name of the docs bucket',
254-
})
261+
// new Output(this, 'DocsBucketName', {
262+
// value: docsBucket.bucketName,
263+
// description: 'The name of the docs bucket',
264+
// })
255265

256266
// Prints out the web endpoint to the terminal
257267
new Output(this, 'DocsUrl', {
@@ -262,5 +272,5 @@ export class StacksCloud extends Stack {
262272
}
263273

264274
function shouldDeployDocs() {
265-
return hasFiles(projectPath('docs'))
275+
return hasFiles(p.projectPath('docs'))
266276
}

.stacks/core/cloud/src/runtime/aws/scripts/build-layer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ process.stdout.getWindowSize = () => [80, 80]
33
process.stderr.getWindowSize = () => [80, 80]
44

55
import { createReadStream, createWriteStream } from 'node:fs'
6-
import { join } from 'node:path'
6+
import { path as p } from '@stacksjs/path'
77
import { Command, Flags } from '@oclif/core'
88
import JSZip from 'jszip'
99

1010
export class BuildCommand extends Command {
11-
static summary = 'Build a custom Lambda layer for Bun.'
11+
static summary = 'Build a custom Lambda layer for Stacks & Bun.'
1212

1313
static flags = {
1414
arch: Flags.string({
@@ -31,7 +31,7 @@ export class BuildCommand extends Command {
3131
layer: Flags.string({
3232
description: 'The name of the Lambda layer.',
3333
multiple: true,
34-
default: ['bun'],
34+
default: ['stacks'],
3535
}),
3636
region: Flags.string({
3737
description: 'The region to publish the layer.',
@@ -82,7 +82,7 @@ export class BuildCommand extends Command {
8282
const cwd = bun.name.split('/')[0]
8383
archive = archive.folder(cwd) ?? archive
8484
for (const filename of ['bootstrap', 'runtime.ts']) {
85-
const path = join(__dirname, '..', filename)
85+
const path = p.join(__dirname, '..', filename)
8686
archive.file(filename, createReadStream(path))
8787
}
8888
this.log('Saving...', output)
@@ -94,7 +94,7 @@ export class BuildCommand extends Command {
9494
level: 9,
9595
},
9696
})
97-
.pipe(createWriteStream(output))
97+
.pipe(createWriteStream(p.projectStoragePath(`app/cloud/${output}`)))
9898
this.log('Saved')
9999
}
100100
}

.stacks/core/cloud/src/runtime/aws/scripts/publish-layer.ts

Lines changed: 0 additions & 92 deletions
This file was deleted.

.stacks/core/eslint-plugin-stacks/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"@typescript-eslint/utils": "^6.5.0"
3030
},
3131
"devDependencies": {
32-
"@types/node": "^20.5.7",
3332
"unbuild": "latest"
3433
}
3534
}

.stacks/core/eslint-plugin-stacksjs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"@typescript-eslint/utils": "^6.5.0"
2828
},
2929
"devDependencies": {
30-
"@types/node": "^20.5.7",
3130
"unbuild": "latest"
3231
}
3332
}

.stacks/ide/dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ resx
185185
retriable
186186
rimraf
187187
roadmap
188+
Runtimes
188189
rustfmt
189190
safelist
190191
sasl

bun.lockb

-112 Bytes
Binary file not shown.

config/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ export default {
2323
locale: 'en',
2424
fallbackLocale: 'en',
2525
cipher: 'aes-256-cbc',
26-
docMode: false,
26+
docMode: true,
2727
} satisfies AppConfig

0 commit comments

Comments
 (0)