Skip to content

Commit

Permalink
change approch to editing svelte.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Plenituz committed Mar 2, 2023
1 parent b1719e4 commit e1b5be0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
3 changes: 3 additions & 0 deletions docs/deploying-to-aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ You just reproduced the same configuration used by the "zero configuration deplo

Your deployment commands now become
```bash
# install barbe if not already installed
curl -fsSL https://hub.barbe.app/install.sh | sh -

# deploy you app
sudo barbe apply infra.hcl

Expand Down
3 changes: 3 additions & 0 deletions docs/deploying-to-gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ You just reproduced the zero configuration deployment, except this time a GCP pr

Your deployment commands now become
```bash
# install barbe if not already installed
curl -fsSL https://hub.barbe.app/install.sh | sh -

# deploy you app
sudo barbe apply infra.hcl

Expand Down
12 changes: 11 additions & 1 deletion src/aws_sveltekit/aws_sveltekit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ function awsSveltekit(bag: Databag): Pipeline[] {
const appDir = asStr(dotBuild.app_dir || block.app_dir || '.')
const installCmd = asStr(dotBuild.install_cmd || 'npm install')
const buildCmd = asStr(dotBuild.build_cmd || 'npm run build')
let svelteConfigJs = os.file.readFile(`${appDir}/svelte.config.js`)
svelteConfigJs = svelteConfigJs.replace('export default ', 'const customer_svelteConfig = ')
svelteConfigJs += `
import __barbe_adapter from '@yarbsemaj/adapter-lambda'
if(!customer_svelteConfig.kit) customer_svelteConfig.kit = {}
customer_svelteConfig.kit.adapter = __barbe_adapter()
if(!customer_svelteConfig.kit.csrf) customer_svelteConfig.kit.csrf = {}
customer_svelteConfig.kit.csrf.checkOrigin = false
export default customer_svelteConfig
`
return {
Type: 'buildkit_run_in_container',
Name: `aws_sveltekit_${bag.Name}`,
Expand All @@ -62,8 +72,8 @@ function awsSveltekit(bag: Databag): Pipeline[] {
RUN ${installCmd}
RUN npm install -D @yarbsemaj/adapter-lambda
RUN mv svelte.config.js customer_svelte.config.js
COPY --from=src svelte.config.js svelte.config.js
RUN npx svelte-kit sync
RUN ${buildCmd}
RUN mkdir -p __barbe_next/static
Expand Down
9 changes: 0 additions & 9 deletions src/aws_sveltekit/svelte.config.template.js

This file was deleted.

25 changes: 12 additions & 13 deletions src/build/aws_sveltekit.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,17 +995,6 @@
var TERRAFORM_EXECUTE_URL2 = `barbe-serverless/terraform_execute.js:${BARBE_SLS_VERSION2}`;
var AWS_NETWORK_URL = `barbe-serverless/aws_network.js:${BARBE_SLS_VERSION2}`;

// aws_sveltekit/svelte.config.template.js
var svelte_config_template_default = `import customer_svelteConfig from "./customer_svelte.config.js";
import adapter from '@yarbsemaj/adapter-lambda'
if(!customer_svelteConfig.kit) customer_svelteConfig.kit = {}
customer_svelteConfig.kit.adapter = adapter()
if(!customer_svelteConfig.kit.csrf) customer_svelteConfig.kit.csrf = {}
customer_svelteConfig.kit.csrf.checkOrigin = false
export default customer_svelteConfig`;

// ../../barbe-serverless/src/barbe-sls-lib/helpers.ts
function awsDomainBlockResources({ dotDomain, domainValue, resourcePrefix, apexHostedZoneId, cloudData, cloudResource }) {
const nameToken = dotDomain.name || dotDomain.names;
Expand Down Expand Up @@ -1176,6 +1165,16 @@ export default customer_svelteConfig`;
const appDir = asStr(dotBuild.app_dir || block.app_dir || ".");
const installCmd = asStr(dotBuild.install_cmd || "npm install");
const buildCmd = asStr(dotBuild.build_cmd || "npm run build");
let svelteConfigJs = os.file.readFile(`${appDir}/svelte.config.js`);
svelteConfigJs = svelteConfigJs.replace("export default ", "const customer_svelteConfig = ");
svelteConfigJs += `
import __barbe_adapter from '@yarbsemaj/adapter-lambda'
if(!customer_svelteConfig.kit) customer_svelteConfig.kit = {}
customer_svelteConfig.kit.adapter = __barbe_adapter()
if(!customer_svelteConfig.kit.csrf) customer_svelteConfig.kit.csrf = {}
customer_svelteConfig.kit.csrf.checkOrigin = false
export default customer_svelteConfig
`;
return {
Type: "buildkit_run_in_container",
Name: `aws_sveltekit_${bag.Name}`,
Expand All @@ -1189,7 +1188,7 @@ export default customer_svelteConfig`;
outputDir
],
input_files: {
"svelte.config.js": svelte_config_template_default
"svelte.config.js": svelteConfigJs
},
dockerfile: `
FROM node:${nodeJsVersion}${nodeJsVersionTag}
Expand All @@ -1202,8 +1201,8 @@ export default customer_svelteConfig`;
RUN ${installCmd}
RUN npm install -D @yarbsemaj/adapter-lambda
RUN mv svelte.config.js customer_svelte.config.js
COPY --from=src svelte.config.js svelte.config.js
RUN npx svelte-kit sync
RUN ${buildCmd}
RUN mkdir -p __barbe_next/static
Expand Down
2 changes: 1 addition & 1 deletion try.cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: 'This stack creates a CodeBuild project that deploys a front end pr
Parameters:
GitUrl:
Type: String
Description: URL of the git repository containing your front end project to deploy
Description: URL of the git repository containing your front end project to deploy, make sure to include the protocol (https:// for example)
DomainName:
Type: String
Description: Domain name to use for the application, make sure you have a hosted zone in Route53 for this domain
Expand Down

0 comments on commit e1b5be0

Please sign in to comment.