diff --git a/docs/deploying-to-aws.md b/docs/deploying-to-aws.md index 9f24cba..7218778 100644 --- a/docs/deploying-to-aws.md +++ b/docs/deploying-to-aws.md @@ -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 diff --git a/docs/deploying-to-gcp.md b/docs/deploying-to-gcp.md index f436dd3..1776f37 100644 --- a/docs/deploying-to-gcp.md +++ b/docs/deploying-to-gcp.md @@ -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 diff --git a/src/aws_sveltekit/aws_sveltekit.ts b/src/aws_sveltekit/aws_sveltekit.ts index 074fc42..0bd3fa5 100644 --- a/src/aws_sveltekit/aws_sveltekit.ts +++ b/src/aws_sveltekit/aws_sveltekit.ts @@ -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}`, @@ -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 diff --git a/src/aws_sveltekit/svelte.config.template.js b/src/aws_sveltekit/svelte.config.template.js deleted file mode 100644 index 1c2b399..0000000 --- a/src/aws_sveltekit/svelte.config.template.js +++ /dev/null @@ -1,9 +0,0 @@ -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 \ No newline at end of file diff --git a/src/build/aws_sveltekit.js b/src/build/aws_sveltekit.js index 5249cb4..1a1c9e8 100644 --- a/src/build/aws_sveltekit.js +++ b/src/build/aws_sveltekit.js @@ -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; @@ -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}`, @@ -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} @@ -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 diff --git a/try.cloudformation.yml b/try.cloudformation.yml index c9ff4a3..445cace 100644 --- a/try.cloudformation.yml +++ b/try.cloudformation.yml @@ -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