Skip to content

Commit 228ed5e

Browse files
committed
chore: wip
chore: wip chore: wip chore: wip chore: wip chore: wip chore: wip chore: wip chore: wip chore: wip chore: wip chore: wip
1 parent b0fc761 commit 228ed5e

File tree

29 files changed

+160
-65
lines changed

29 files changed

+160
-65
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.lockb binary diff=lockb

.stacks/core/actions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
},
5151
"peerDependencies": {
5252
"@stacksjs/cli": "workspace:*",
53+
"@stacksjs/cloud": "workspace:*",
5354
"@stacksjs/config": "workspace:*",
5455
"@stacksjs/database": "workspace:*",
5556
"@stacksjs/env": "workspace:*",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// TODO: port over logic from meemalabs/cloudfront to invalidate cache
2+
// buddy cloud invalidate-cache --paths /index.html /about.html
3+
4+
import { CloudFrontClient, CreateInvalidationCommand} from '@aws-sdk/client-cloudfront'
5+
6+
const cloudfront = new CloudFrontClient();
7+
8+
const params = {
9+
DistributionId: 'YOUR_DISTRIBUTION_ID', /* required */
10+
InvalidationBatch: { /* required */
11+
CallerReference: '' + Date.now(), /* required */
12+
Paths: { /* required */
13+
Quantity: 1, /* required */
14+
Items: [
15+
'/*',
16+
/* more items */
17+
]
18+
}
19+
}
20+
};
21+
22+
const command = new CreateInvalidationCommand(params);
23+
24+
cloudfront.send(command).then(
25+
(data) => console.log(data),
26+
(err) => console.log(err, err.stack)
27+
);

.stacks/core/buddy/src/commands/dev.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export function dev(buddy: CLI) {
6161
else {
6262
if (options.components)
6363
await runComponentsDevServer(options)
64+
if (options.docs)
65+
await runDocsDevServer(options)
6466
else if (options.api)
6567
await runFunctionsDevServer(options)
6668
else if (options.pages)

.stacks/core/cloud/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@aws-lambda-powertools/tracer": "^1.12.1",
6262
"@stacksjs/dns": "workspace:*",
6363
"aws-cdk-lib": "^2.93.0",
64+
"@aws-sdk/client-cloudfront": "^3.398.0",
6465
"constructs": "^10.2.69"
6566
},
6667
"devDependencies": {

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,24 @@ export class StacksCloud extends Stack {
194194
domainName,
195195
})
196196

197+
const docsSource = '../../../storage/app/docs'
198+
const websiteSource = app.docMode ? docsSource : '../../../storage/app/public'
199+
const privateSource = '../../../storage/private'
200+
197201
new s3deploy.BucketDeployment(this, 'DeployWebsite', {
198-
sources: [s3deploy.Source.asset('../../../storage/app/docs')],
199-
// sources: [s3deploy.Source.asset('../../../storage/public')],
202+
sources: [s3deploy.Source.asset(websiteSource)],
200203
destinationBucket: publicBucket,
201204
distribution,
202205
distributionPaths: ['/*'],
203206
})
204207

205208
new s3deploy.BucketDeployment(this, 'DeployPrivateFiles', {
206-
sources: [s3deploy.Source.asset('../../../storage/private')],
209+
sources: [s3deploy.Source.asset(privateSource)],
207210
destinationBucket: privateBucket,
208211
})
209212

210213
new s3deploy.BucketDeployment(this, 'DeployDocs', {
211-
sources: [s3deploy.Source.asset('../../../storage/app/docs')],
214+
sources: [s3deploy.Source.asset(docsSource)],
212215
destinationBucket: docsBucket,
213216
distribution: docsDistribution,
214217
distributionPaths: ['/*'],

.stacks/core/docs/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { log, runCommand } from '@stacksjs/cli'
22

3-
const result = await runCommand('bun build ./src/index.ts --outdir dist --format esm --external vitepress --external @stacksjs/config --external @stacksjs/path --external @stacksjs/vite --target bun', {
3+
const result = await runCommand('bun build ./src/index.ts --outdir dist --format esm --external vitepress --external @stacksjs/config --external @stacksjs/alias --external @stacksjs/path --external @stacksjs/vite --external @stacksjs/server --target node', {
44
cwd: import.meta.dir,
55
})
66

.stacks/core/docs/src/index.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,53 @@
11
import { defineConfig } from 'vitepress'
2+
import type { UserConfig } from 'vitepress'
3+
import { alias } from '@stacksjs/alias'
24
import { path as p } from '@stacksjs/path'
35
import { app, docs } from '@stacksjs/config'
46
import { docsEngine } from '@stacksjs/vite'
7+
import { server } from '@stacksjs/server'
8+
9+
export function docsUrl() {
10+
const appUrl = app.url
11+
const docsSubdomain = app.subdomains.docs
12+
const protocolPattern = /^https?:\/\//i
13+
const urlForParsing = protocolPattern.test(appUrl) ? appUrl : `http://${docsSubdomain}.${appUrl}:3333`
14+
const urlObj = new URL(urlForParsing)
15+
const domainParts = urlObj.hostname.split('.')
16+
domainParts[domainParts.length - 1] = 'localhost' // replace TLD with 'localhost' for local dev
17+
const host = domainParts.join('.')
18+
return `https://${host}`
19+
}
520

621
const defaultConfig = {
722
title: `${app.name} Documentation`,
23+
srcDir: p.projectPath('docs'),
24+
outDir: p.projectStoragePath('app/docs'),
25+
cacheDir: p.projectStoragePath('app/cache/docs'),
26+
sitemap: {
27+
hostname: docsUrl(),
28+
},
829

930
vite: {
1031
envDir: p.projectPath(),
1132
envPrefix: 'FRONTEND_',
1233

13-
server: {
14-
host: 'docs.stacks.test',
15-
port: 3333,
34+
server: server({
35+
type: 'docs',
36+
}),
37+
38+
resolve: {
39+
alias
1640
},
1741

1842
plugins: [
1943
docsEngine(),
2044
],
2145
},
22-
}
46+
} satisfies UserConfig
2347

2448
const config = {
2549
...defaultConfig,
2650
...docs,
27-
}
51+
} satisfies UserConfig
2852

2953
export default defineConfig(config)

.stacks/core/env/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ const handler = {
131131
return cache[prop]
132132

133133
const newEnv = loadEnv('development', projectPath(), '') as (NodeJS.ProcessEnv & Env)
134-
process.env = newEnv
135134
cache[prop] = newEnv[prop]
136135
return newEnv[prop]
137136
},

.stacks/core/error-handling/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { log, runCommand } from '@stacksjs/cli'
22

3-
const result = await runCommand('bun build ./src/index.ts --outdir dist --format esm --external @stacksjs/cli --external @stacksjs/path --external @stacksjs/storage --target bun', {
3+
const result = await runCommand('bun build ./src/index.ts --outdir dist --format esm --external @stacksjs/cli --external @stacksjs/path --external @stacksjs/storage --target node', {
44
cwd: import.meta.dir,
55
})
66

0 commit comments

Comments
 (0)