@stacksjs/ts-cloud 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +1 -1
- package/dist/deploy/index.d.ts +1 -0
- package/dist/deploy/static-site-helper.d.ts +91 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +77 -0
- package/package.json +3 -3
package/dist/bin/cli.js
CHANGED
|
@@ -360,7 +360,7 @@ Run \`${this.name??"cli"} --help\` for usage.`;Q1.stderr.write(`${W}${Z}${G}
|
|
|
360
360
|
`).length-1;this.output.write(t0.move(-999,$*-1))}render(){let $=K9(this._render(this)??"",B9.stdout.columns,{hard:!0,trim:!1});if($===this._prevFrame)return;if(this.state==="initial")this.output.write(t0.hide);else{let J=a7(this._prevFrame,$);if(this.restoreCursor(),J&&J?.length===1){let Y=J[0];this.output.write(t0.move(0,Y)),this.output.write(Y$.lines(1));let Q=$.split(`
|
|
361
361
|
`);this.output.write(Q[Y]),this._prevFrame=$,this.output.write(t0.move(0,Q.length-Y-1));return}if(J&&J?.length>1){let Y=J[0];this.output.write(t0.move(0,Y)),this.output.write(Y$.down());let Z=$.split(`
|
|
362
362
|
`).slice(Y);this.output.write(Z.join(`
|
|
363
|
-
`)),this._prevFrame=$;return}this.output.write(Y$.down())}if(this.output.write($),this.state==="initial")this.state="active";this._prevFrame=$}}function e7($,J){if($===void 0)return 0;if(J.length===0)return 0;let Q=J.findIndex((Z)=>Z.value===$);return Q!==-1?Q:0}function $J($,J){return(J.label??String(J.value)).toLowerCase().includes($.toLowerCase())}function JJ($,J){if(!J)return;if($)return J;return J[0]}class YJ extends z${filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#Y="";#Q;#J;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return B2.inverse(B2.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[J,...Y]=this.userInput.slice(this._cursor);return`${$}${B2.inverse(J)}${Y.join("")}`}get options(){if(typeof this.#J==="function")return this.#J();return this.#J}constructor($){super($);this.#J=$.options;let J=this.options;this.filteredOptions=[...J],this.multiple=$.multiple===!0,this.#Q=$.filter??$J;let Y;if($.initialValue&&Array.isArray($.initialValue))if(this.multiple)Y=$.initialValue;else Y=$.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)Y=[this.options[0].value];if(Y)for(let Q of Y){let Z=J.findIndex((W)=>W.value===Q);if(Z!==-1)this.toggleSelected(Q),this.#$=Z}this.focusedValue=this.options[this.#$]?.value,this.on("key",(Q,Z)=>this.#Z(Q,Z)),this.on("userInput",(Q)=>this.#W(Q))}_isActionKey($,J){return $==="\t"||this.multiple&&this.isNavigating&&J.name==="space"&&$!==void 0&&$!==""}#Z($,J){let Y=J.name==="up",Q=J.name==="down",Z=J.name==="return";if(Y||Q){if(this.#$=Math.max(0,Math.min(this.#$+(Y?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(Z)this.value=JJ(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&(J.name==="tab"||this.isNavigating&&J.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected($){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes($))this.selectedValues=this.selectedValues.filter((J)=>J!==$);else this.selectedValues=[...this.selectedValues,$];else this.selectedValues=[$]}#W($){if($!==this.#Y){this.#Y=$;let J=this.options;if($)this.filteredOptions=J.filter((Y)=>this.#Q($,Y));else this.filteredOptions=[...J];if(this.#$=e7(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class QJ extends z${options;cursor=0;#$;getGroupItems($){return this.options.filter((J)=>J.group===$)}isGroupSelected($){let J=this.getGroupItems($),Y=this.value;if(Y===void 0)return!1;return J.every((Q)=>Y.includes(Q.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0)this.value=[];if($.group===!0){let J=$.value,Y=this.getGroupItems(J);if(this.isGroupSelected(J))this.value=this.value.filter((Q)=>Y.findIndex((Z)=>Z.value===Q)===-1);else this.value=[...this.value,...Y.map((Q)=>Q.value)];this.value=Array.from(new Set(this.value))}else{let J=this.value.includes($.value);this.value=J?this.value.filter((Y)=>Y!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:J}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(J).flatMap(([Y,Q])=>[{value:Y,group:!0,label:Y},...Q.map((Z)=>({...Z,group:Y}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Y})=>Y===$.cursorAt),this.#$?0:1),this.on("cursor",(Y)=>{switch(Y){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Q=this.options[this.cursor]?.group===!0;if(!this.#$&&Q)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Q=this.options[this.cursor]?.group===!0;if(!this.#$&&Q)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var ZJ=K7();var U0=($,J)=>ZJ?$:J,VQ=U0("◆","*"),XQ=U0("■","x"),_Q=U0("▲","x"),qQ=U0("◇","o"),LQ=U0("┌","T"),WJ=U0("│","|"),MQ=U0("└","—"),wQ=U0("●",">"),TQ=U0("○"," "),DQ=U0("◻","[•]"),NQ=U0("◼","[+]"),RQ=U0("◻","[ ]"),SQ=U0("▪","•"),PQ=U0("─","-"),xQ=U0("╮","+"),CQ=U0("├","+"),hQ=U0("╯","+"),IQ=U0("●","•"),kQ=U0("◆","*"),bQ=U0("▲","!"),yQ=U0("■","x");var vQ={light:U0("─","-"),heavy:U0("━","="),block:U0("█","#")};function GJ(){return`${B2.gray(WJ)} `}var fQ=GJ();var F$="0.2.
|
|
363
|
+
`)),this._prevFrame=$;return}this.output.write(Y$.down())}if(this.output.write($),this.state==="initial")this.state="active";this._prevFrame=$}}function e7($,J){if($===void 0)return 0;if(J.length===0)return 0;let Q=J.findIndex((Z)=>Z.value===$);return Q!==-1?Q:0}function $J($,J){return(J.label??String(J.value)).toLowerCase().includes($.toLowerCase())}function JJ($,J){if(!J)return;if($)return J;return J[0]}class YJ extends z${filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#Y="";#Q;#J;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return B2.inverse(B2.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[J,...Y]=this.userInput.slice(this._cursor);return`${$}${B2.inverse(J)}${Y.join("")}`}get options(){if(typeof this.#J==="function")return this.#J();return this.#J}constructor($){super($);this.#J=$.options;let J=this.options;this.filteredOptions=[...J],this.multiple=$.multiple===!0,this.#Q=$.filter??$J;let Y;if($.initialValue&&Array.isArray($.initialValue))if(this.multiple)Y=$.initialValue;else Y=$.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)Y=[this.options[0].value];if(Y)for(let Q of Y){let Z=J.findIndex((W)=>W.value===Q);if(Z!==-1)this.toggleSelected(Q),this.#$=Z}this.focusedValue=this.options[this.#$]?.value,this.on("key",(Q,Z)=>this.#Z(Q,Z)),this.on("userInput",(Q)=>this.#W(Q))}_isActionKey($,J){return $==="\t"||this.multiple&&this.isNavigating&&J.name==="space"&&$!==void 0&&$!==""}#Z($,J){let Y=J.name==="up",Q=J.name==="down",Z=J.name==="return";if(Y||Q){if(this.#$=Math.max(0,Math.min(this.#$+(Y?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(Z)this.value=JJ(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&(J.name==="tab"||this.isNavigating&&J.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected($){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes($))this.selectedValues=this.selectedValues.filter((J)=>J!==$);else this.selectedValues=[...this.selectedValues,$];else this.selectedValues=[$]}#W($){if($!==this.#Y){this.#Y=$;let J=this.options;if($)this.filteredOptions=J.filter((Y)=>this.#Q($,Y));else this.filteredOptions=[...J];if(this.#$=e7(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class QJ extends z${options;cursor=0;#$;getGroupItems($){return this.options.filter((J)=>J.group===$)}isGroupSelected($){let J=this.getGroupItems($),Y=this.value;if(Y===void 0)return!1;return J.every((Q)=>Y.includes(Q.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0)this.value=[];if($.group===!0){let J=$.value,Y=this.getGroupItems(J);if(this.isGroupSelected(J))this.value=this.value.filter((Q)=>Y.findIndex((Z)=>Z.value===Q)===-1);else this.value=[...this.value,...Y.map((Q)=>Q.value)];this.value=Array.from(new Set(this.value))}else{let J=this.value.includes($.value);this.value=J?this.value.filter((Y)=>Y!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:J}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(J).flatMap(([Y,Q])=>[{value:Y,group:!0,label:Y},...Q.map((Z)=>({...Z,group:Y}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Y})=>Y===$.cursorAt),this.#$?0:1),this.on("cursor",(Y)=>{switch(Y){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Q=this.options[this.cursor]?.group===!0;if(!this.#$&&Q)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Q=this.options[this.cursor]?.group===!0;if(!this.#$&&Q)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var ZJ=K7();var U0=($,J)=>ZJ?$:J,VQ=U0("◆","*"),XQ=U0("■","x"),_Q=U0("▲","x"),qQ=U0("◇","o"),LQ=U0("┌","T"),WJ=U0("│","|"),MQ=U0("└","—"),wQ=U0("●",">"),TQ=U0("○"," "),DQ=U0("◻","[•]"),NQ=U0("◼","[+]"),RQ=U0("◻","[ ]"),SQ=U0("▪","•"),PQ=U0("─","-"),xQ=U0("╮","+"),CQ=U0("├","+"),hQ=U0("╯","+"),IQ=U0("●","•"),kQ=U0("◆","*"),bQ=U0("▲","!"),yQ=U0("■","x");var vQ={light:U0("─","-"),heavy:U0("━","="),block:U0("█","#")};function GJ(){return`${B2.gray(WJ)} `}var fQ=GJ();var F$="0.2.10";import{existsSync as j$}from"node:fs";import{mkdir as EJ,writeFile as I9}from"node:fs/promises";var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"};function q1($,J){return`${e[J]}${$}${e.reset}`}function P($){console.log(`${e.green}✓${e.reset} ${$}`)}function M($){console.error(`${e.red}✗${e.reset} ${$}`)}function y($){console.warn(`${e.yellow}⚠${e.reset} ${$}`)}var d0=y;function z($){console.log(`${e.blue}ℹ${e.reset} ${$}`)}function t($){console.log(`${e.cyan}→${e.reset} ${$}`)}function q($){console.log(`
|
|
364
364
|
${e.bright}${e.cyan}${$}${e.reset}
|
|
365
365
|
`)}var A$=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);class L{frames=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];interval=null;currentFrame=0;message;constructor($){this.message=$}get text(){return this.message}set text($){if(this.message=$,A$&&this.interval)console.log(` ${$}`)}start(){if(A$){console.log(` ${this.message}`),this.interval=!0;return}this.interval=setInterval(()=>{process.stdout.write(`\r${e.cyan}${this.frames[this.currentFrame]}${e.reset} ${this.message}`),this.currentFrame=(this.currentFrame+1)%this.frames.length},80)}succeed($){this.stop(),P($||this.message)}fail($){this.stop(),M($||this.message)}warn($){this.stop(),d0($||this.message)}stop(){if(this.interval){if(!A$)process.stdout.write("\r");if(typeof this.interval==="object")clearInterval(this.interval);this.interval=null}}}async function G0($,J){let Q=(await import("node:readline")).createInterface({input:process.stdin,output:process.stdout});return new Promise((Z)=>{let W=J?`${e.cyan}?${e.reset} ${$} ${e.gray}(${J})${e.reset}: `:`${e.cyan}?${e.reset} ${$}: `;Q.question(W,(G)=>{Q.close(),Z(G||J||"")})})}async function h($,J=!1){let Y=await G0(`${$} (y/n)`,J?"y":"n");return Y.toLowerCase()==="y"||Y.toLowerCase()==="yes"}async function O$($,J){console.log(`${e.cyan}?${e.reset} ${$}`),J.forEach((Z,W)=>{console.log(` ${e.gray}${W+1}.${e.reset} ${Z}`)});let Y=await G0("Select","1"),Q=Number.parseInt(Y)-1;if(Q>=0&&Q<J.length)return J[Q];return J[0]}function g($,J){let Y=$.map((Z,W)=>{let G=Math.max(...J.map((U)=>(U[W]||"").length));return Math.max(Z.length,G)}),Q=$.map((Z,W)=>Z.padEnd(Y[W])).join(" ");console.log(q1(Q,"bright")),console.log(q1("─".repeat(Q.length),"gray")),J.forEach((Z)=>{let W=Z.map((G,U)=>(G||"").padEnd(Y[U])).join(" ");console.log(W)})}function x1($,J="cyan"){let Y=$.split(`
|
|
366
366
|
`),Q=Math.max(...Y.map((W)=>W.length)),Z="─".repeat(Q+2);console.log(q1(`┌${Z}┐`,J)),Y.forEach((W)=>{console.log(q1(`│ ${W.padEnd(Q)} │`,J))}),console.log(q1(`└${Z}┘`,J))}async function P9(){return!0}async function x9(){try{let{AWSClient:$}=await Promise.resolve().then(() => (Z0(),_1));return await new $().request({service:"sts",region:"us-east-1",method:"POST",path:"/",body:new URLSearchParams({Action:"GetCallerIdentity",Version:"2011-06-15"}).toString()}),!0}catch{return!1}}async function C9(){try{let{AWSClient:$}=await Promise.resolve().then(() => (Z0(),_1)),Y=await new $().request({service:"sts",region:"us-east-1",method:"POST",path:"/",body:new URLSearchParams({Action:"GetCallerIdentity",Version:"2011-06-15"}).toString()});return Y.Account||Y.GetCallerIdentityResult?.Account||null}catch{return null}}async function h9(){try{let{AWSClient:$}=await Promise.resolve().then(() => (Z0(),_1)),Y=await new $().request({service:"ec2",region:"us-east-1",method:"POST",path:"/",body:new URLSearchParams({Action:"DescribeRegions",Version:"2016-11-15"}).toString()}),Q=[];if(Y.regionInfo){let Z=Array.isArray(Y.regionInfo)?Y.regionInfo:[Y.regionInfo];Q.push(...Z.map((W)=>W.regionName))}return Q.length>0?Q:S9()}catch{return S9()}}function S9(){return["us-east-1","us-east-2","us-west-1","us-west-2","eu-west-1","eu-central-1","ap-southeast-1","ap-northeast-1"]}function E$($){$.command("init","Initialize a new ts-cloud project").option("--mode <mode>","Deployment mode: server, serverless, or hybrid").option("--name <name>","Project name").option("--region <region>","AWS Region").action(async(J)=>{if(q("Initializing ts-cloud Project"),j$("cloud.config.ts")){if(!await h("cloud.config.ts already exists. Overwrite?",!1)){z("Initialization cancelled");return}}let Y=J?.name||await G0("Project name","my-app"),Q=J?.mode||await O$("Select deployment mode",["serverless","server","hybrid"]),Z=J?.region||await O$("Select AWS region",["us-east-1","us-west-2","eu-west-1","eu-central-1","ap-southeast-1"]),W=new L("Creating configuration file...");W.start();let G=`import { defineConfig } from '@ts-cloud/core'
|
package/dist/deploy/index.d.ts
CHANGED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level static site deployer with smart defaults.
|
|
3
|
+
*
|
|
4
|
+
* Most callers don't need the full surface of
|
|
5
|
+
* `deployStaticSiteWithExternalDnsFull` — they want to point a build
|
|
6
|
+
* directory at a domain and let the helper sort out:
|
|
7
|
+
* - Porkbun DNS (default for non-Route53 setups)
|
|
8
|
+
* - Non-SPA error handling (so /favicon.ico, /robots.txt, etc. don't
|
|
9
|
+
* masquerade as the homepage)
|
|
10
|
+
* - AWS env-var validation up front
|
|
11
|
+
* - Sensible cache-control headers
|
|
12
|
+
*
|
|
13
|
+
* `deploySite` is the one-call entrypoint; the lower-level
|
|
14
|
+
* `deployStaticSiteWithExternalDnsFull` and `deployStaticSiteFull`
|
|
15
|
+
* remain available for callers that need the full surface.
|
|
16
|
+
*/
|
|
17
|
+
export type StaticSiteDnsProvider = 'porkbun' | 'godaddy' | {
|
|
18
|
+
provider: 'porkbun';
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
secretKey?: string;
|
|
21
|
+
} | {
|
|
22
|
+
provider: 'godaddy';
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
secretKey?: string;
|
|
25
|
+
environment?: 'production' | 'ote';
|
|
26
|
+
};
|
|
27
|
+
export interface DeploySiteConfig {
|
|
28
|
+
/** Site name used for AWS resource naming. */
|
|
29
|
+
siteName: string;
|
|
30
|
+
/** Apex or subdomain (e.g. "paweldregan.com"). */
|
|
31
|
+
domain: string;
|
|
32
|
+
/** AWS region for the S3 bucket. Defaults to "us-east-1". */
|
|
33
|
+
region?: string;
|
|
34
|
+
/** Output directory containing built files. Defaults to "dist". */
|
|
35
|
+
sourceDir?: string;
|
|
36
|
+
/** S3 bucket name (auto-generated from the domain if omitted). */
|
|
37
|
+
bucket?: string;
|
|
38
|
+
/** CloudFormation stack name (auto-generated if omitted). */
|
|
39
|
+
stackName?: string;
|
|
40
|
+
/** Default root object served at "/". Defaults to "index.html". */
|
|
41
|
+
defaultRootObject?: string;
|
|
42
|
+
/** Error document served on 403/404. Defaults to "404.html". */
|
|
43
|
+
errorDocument?: string;
|
|
44
|
+
/**
|
|
45
|
+
* DNS provider config. Defaults to Porkbun, reading PORKBUN_API_KEY /
|
|
46
|
+
* PORKBUN_SECRET_KEY from env. Pass `'godaddy'` or a full provider
|
|
47
|
+
* object to override.
|
|
48
|
+
*/
|
|
49
|
+
dnsProvider?: StaticSiteDnsProvider;
|
|
50
|
+
/** Pre-issued ACM cert ARN. Auto-created when omitted. */
|
|
51
|
+
certificateArn?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Cache-Control header for uploaded objects. Defaults to short-TTL
|
|
54
|
+
* (one hour) so HTML edits propagate quickly; long-lived assets can
|
|
55
|
+
* still set their own Cache-Control via S3 object metadata if needed.
|
|
56
|
+
*/
|
|
57
|
+
cacheControl?: string;
|
|
58
|
+
/**
|
|
59
|
+
* SPA mode. Defaults to false. With false, missing files return a
|
|
60
|
+
* real 404 with the error document. With true, missing files fall
|
|
61
|
+
* through to the index document with a 200 — required for
|
|
62
|
+
* client-side-routed SPAs but wrong for multi-page static sites.
|
|
63
|
+
*/
|
|
64
|
+
singlePageApp?: boolean;
|
|
65
|
+
/** Empty the bucket before uploading (default: false). */
|
|
66
|
+
cleanBucket?: boolean;
|
|
67
|
+
/** AWS resource tags. */
|
|
68
|
+
tags?: Record<string, string>;
|
|
69
|
+
/** Progress callback. */
|
|
70
|
+
onProgress?: (stage: string, detail?: string) => void;
|
|
71
|
+
}
|
|
72
|
+
export interface DeploySiteResult {
|
|
73
|
+
success: boolean;
|
|
74
|
+
domain?: string;
|
|
75
|
+
url?: string;
|
|
76
|
+
bucket?: string;
|
|
77
|
+
distributionId?: string;
|
|
78
|
+
distributionDomain?: string;
|
|
79
|
+
certificateArn?: string;
|
|
80
|
+
filesUploaded?: number;
|
|
81
|
+
filesSkipped?: number;
|
|
82
|
+
message?: string;
|
|
83
|
+
durationMs: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Deploy a static site to AWS (S3 + CloudFront + ACM) with DNS managed
|
|
87
|
+
* via Porkbun (or another supported external provider). Validates AWS +
|
|
88
|
+
* DNS-provider credentials up front, fills in opinionated defaults, and
|
|
89
|
+
* routes to the underlying CloudFormation flow.
|
|
90
|
+
*/
|
|
91
|
+
export declare function deploySite(config: DeploySiteConfig): Promise<DeploySiteResult>;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export type { ValidationError as TemplateValidationError, ValidationResult as Te
|
|
|
5
5
|
export { AWSClient, CloudFormationClient, CloudFormationClient as AWSCloudFormationClient, CloudFrontClient, CloudFrontClient as AWSCloudFrontClient, EC2Client, S3Client, Route53Client, Route53DomainsClient, ACMClient, ACMDnsValidator, ECRClient, ECSClient, STSClient, SSMClient, SecretsManagerClient, SESClient, EmailClient, SNSClient, SQSClient, LambdaClient, CloudWatchLogsClient, ConnectClient, ELBv2Client, RDSClient, DynamoDBClient, OpenSearchClient, TranscribeClient, BedrockClient, BedrockRuntimeClient, ComprehendClient, RekognitionClient, TextractClient, PollyClient, TranslateClient, PersonalizeClient, KendraClient, EventBridgeClient, ElastiCacheClient, SchedulerClient, IAMClient, ApplicationAutoScalingClient, SmsClient, VoiceClient, SupportClient, EFSClient, } from './aws';
|
|
6
6
|
export type { AWSRequestOptions, AWSClientConfig, AWSError, AWSCredentials as AWSClientCredentials, StackParameter, StackTag, CreateStackOptions, UpdateStackOptions, DescribeStacksOptions, StackEvent, Stack, InvalidationOptions, Distribution, S3SyncOptions, S3CopyOptions, S3ListOptions, S3Object, CertificateDetail, Certificate as ELBv2Certificate, RekognitionS3Object, RekognitionBoundingBox, TextractS3Object, TextractBoundingBox, CountryCode, ContactType, ContactDetail, KendraCreateDataSourceCommandInput, KendraCreateDataSourceCommandOutput, KendraListDataSourcesCommandInput, KendraListDataSourcesCommandOutput, InvokeModelCommandInput, InvokeModelCommandOutput, InvokeModelWithResponseStreamCommandInput, InvokeModelWithResponseStreamCommandOutput, CreateModelCustomizationJobCommandInput, CreateModelCustomizationJobCommandOutput, GetModelCustomizationJobCommandInput, GetModelCustomizationJobCommandOutput, ListFoundationModelsCommandInput, ListFoundationModelsCommandOutput, AttributeValue as DynamoDBAttributeValue, KeySchemaElement, AttributeDefinition as DynamoDBAttributeDefinition, } from './aws';
|
|
7
7
|
export * from './ssl';
|
|
8
|
-
export { deployStaticSite, deployStaticSiteFull, uploadStaticFiles, invalidateCache, deleteStaticSite, generateStaticSiteTemplate, deployStaticSiteWithExternalDns, deployStaticSiteWithExternalDnsFull, generateExternalDnsStaticSiteTemplate, } from './deploy';
|
|
9
|
-
export type { StaticSiteConfig, DeployResult, UploadOptions, ExternalDnsStaticSiteConfig, ExternalDnsDeployResult, } from './deploy';
|
|
8
|
+
export { deployStaticSite, deployStaticSiteFull, uploadStaticFiles, invalidateCache, deleteStaticSite, generateStaticSiteTemplate, deployStaticSiteWithExternalDns, deployStaticSiteWithExternalDnsFull, generateExternalDnsStaticSiteTemplate, deploySite, } from './deploy';
|
|
9
|
+
export type { StaticSiteConfig, DeployResult, UploadOptions, ExternalDnsStaticSiteConfig, ExternalDnsDeployResult, DeploySiteConfig, DeploySiteResult, StaticSiteDnsProvider, } from './deploy';
|
|
10
10
|
export { createDnsProvider, detectDnsProvider, DnsProviderFactory, dnsProviders, PorkbunProvider, GoDaddyProvider, Route53Provider, UnifiedDnsValidator, createPorkbunValidator, createGoDaddyValidator, createRoute53Validator, } from './dns';
|
|
11
11
|
export type { DnsProvider, DnsProviderConfig, DnsRecord, DnsRecordType, DnsRecordResult, CreateRecordResult, DeleteRecordResult, ListRecordsResult, } from './dns';
|
|
12
12
|
export * from '@ts-cloud/core';
|
package/dist/index.js
CHANGED
|
@@ -75341,6 +75341,82 @@ class AcmeClient {
|
|
|
75341
75341
|
init_static_site();
|
|
75342
75342
|
init_static_site_external_dns();
|
|
75343
75343
|
|
|
75344
|
+
// src/deploy/static-site-helper.ts
|
|
75345
|
+
init_static_site_external_dns();
|
|
75346
|
+
import process6 from "node:process";
|
|
75347
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
75348
|
+
import { join as join9 } from "node:path";
|
|
75349
|
+
async function deploySite(config4) {
|
|
75350
|
+
const start = Date.now();
|
|
75351
|
+
const sourceDir = config4.sourceDir ?? "dist";
|
|
75352
|
+
if (!existsSync10(join9(sourceDir, "index.html"))) {
|
|
75353
|
+
return fail(start, `${sourceDir}/ has no index.html — build first.`);
|
|
75354
|
+
}
|
|
75355
|
+
if (!process6.env.AWS_ACCESS_KEY_ID || !process6.env.AWS_SECRET_ACCESS_KEY) {
|
|
75356
|
+
return fail(start, "Missing AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY in env.");
|
|
75357
|
+
}
|
|
75358
|
+
const dns2 = resolveDnsProvider(config4.dnsProvider);
|
|
75359
|
+
if ("error" in dns2)
|
|
75360
|
+
return fail(start, dns2.error);
|
|
75361
|
+
const result = await deployStaticSiteWithExternalDnsFull({
|
|
75362
|
+
siteName: config4.siteName,
|
|
75363
|
+
region: config4.region ?? "us-east-1",
|
|
75364
|
+
domain: config4.domain,
|
|
75365
|
+
bucket: config4.bucket,
|
|
75366
|
+
stackName: config4.stackName,
|
|
75367
|
+
certificateArn: config4.certificateArn,
|
|
75368
|
+
defaultRootObject: config4.defaultRootObject ?? "index.html",
|
|
75369
|
+
errorDocument: config4.errorDocument ?? "404.html",
|
|
75370
|
+
cacheControl: config4.cacheControl ?? "max-age=3600, public",
|
|
75371
|
+
sourceDir,
|
|
75372
|
+
cleanBucket: config4.cleanBucket ?? false,
|
|
75373
|
+
singlePageApp: config4.singlePageApp ?? false,
|
|
75374
|
+
dnsProvider: dns2,
|
|
75375
|
+
tags: {
|
|
75376
|
+
ManagedBy: "ts-cloud",
|
|
75377
|
+
Application: config4.siteName,
|
|
75378
|
+
...config4.tags
|
|
75379
|
+
},
|
|
75380
|
+
onProgress: config4.onProgress
|
|
75381
|
+
});
|
|
75382
|
+
return {
|
|
75383
|
+
success: !!result.success,
|
|
75384
|
+
domain: result.domain,
|
|
75385
|
+
url: result.domain ? `https://${result.domain}` : result.distributionDomain ? `https://${result.distributionDomain}` : undefined,
|
|
75386
|
+
bucket: result.bucket,
|
|
75387
|
+
distributionId: result.distributionId,
|
|
75388
|
+
distributionDomain: result.distributionDomain,
|
|
75389
|
+
certificateArn: result.certificateArn,
|
|
75390
|
+
filesUploaded: result.filesUploaded,
|
|
75391
|
+
filesSkipped: result.filesSkipped,
|
|
75392
|
+
message: result.message,
|
|
75393
|
+
durationMs: Date.now() - start
|
|
75394
|
+
};
|
|
75395
|
+
}
|
|
75396
|
+
function resolveDnsProvider(input) {
|
|
75397
|
+
const config4 = typeof input === "string" ? { provider: input } : input ?? { provider: "porkbun" };
|
|
75398
|
+
if (config4.provider === "porkbun") {
|
|
75399
|
+
const c = config4;
|
|
75400
|
+
const apiKey = c?.apiKey ?? process6.env.PORKBUN_API_KEY;
|
|
75401
|
+
const secretKey = c?.secretKey ?? process6.env.PORKBUN_SECRET_KEY ?? process6.env.PORKBUN_SECRET_API_KEY;
|
|
75402
|
+
if (!apiKey || !secretKey)
|
|
75403
|
+
return { error: "Missing PORKBUN_API_KEY / PORKBUN_SECRET_KEY in env." };
|
|
75404
|
+
return { provider: "porkbun", apiKey, secretKey };
|
|
75405
|
+
}
|
|
75406
|
+
if (config4.provider === "godaddy") {
|
|
75407
|
+
const c = config4;
|
|
75408
|
+
const apiKey = c?.apiKey ?? process6.env.GODADDY_API_KEY;
|
|
75409
|
+
const apiSecret = c?.secretKey ?? process6.env.GODADDY_API_SECRET;
|
|
75410
|
+
const environment = c?.environment ?? process6.env.GODADDY_ENVIRONMENT;
|
|
75411
|
+
if (!apiKey || !apiSecret)
|
|
75412
|
+
return { error: "Missing GODADDY_API_KEY / GODADDY_API_SECRET in env." };
|
|
75413
|
+
return { provider: "godaddy", apiKey, apiSecret, environment };
|
|
75414
|
+
}
|
|
75415
|
+
return { error: `Unsupported DNS provider: ${config4.provider}` };
|
|
75416
|
+
}
|
|
75417
|
+
function fail(start, message) {
|
|
75418
|
+
return { success: false, message, durationMs: Date.now() - start };
|
|
75419
|
+
}
|
|
75344
75420
|
// src/index.ts
|
|
75345
75421
|
init_dns();
|
|
75346
75422
|
export {
|
|
@@ -75525,6 +75601,7 @@ export {
|
|
|
75525
75601
|
deployStaticSiteWithExternalDns,
|
|
75526
75602
|
deployStaticSiteFull,
|
|
75527
75603
|
deployStaticSite,
|
|
75604
|
+
deploySite,
|
|
75528
75605
|
deleteStaticSite,
|
|
75529
75606
|
defaultLocalConfig,
|
|
75530
75607
|
defaultConfig2 as defaultConfig,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/ts-cloud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.10",
|
|
5
5
|
"description": "A lightweight, performant infrastructure-as-code library and CLI for deploying both server-based (EC2) and serverless applications.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"test": "bun test"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@ts-cloud/aws-types": "0.2.
|
|
89
|
-
"@ts-cloud/core": "0.2.
|
|
88
|
+
"@ts-cloud/aws-types": "0.2.10",
|
|
89
|
+
"@ts-cloud/core": "0.2.10",
|
|
90
90
|
"@stacksjs/ts-xml": "^0.1.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|