Skip to content

Commit

Permalink
Merge pull request #107 from PierreBeucher/typo-curl
Browse files Browse the repository at this point in the history
fix curl request in install script
  • Loading branch information
PierreBeucher authored Jan 7, 2025
2 parents ed807c6 + abcf356 commit 4ea7606
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ send_analytics_event() {
\"distinct_id\": \"$INSTALL_POSTHOG_DISTINCT_ID\",
\"properties\": {
\"\$process_person_profile\": false,
\"event_details\": $eventDetails,
\"event_details\": \"$eventDetails\",
\"os_name\": \"$(uname -s)\",
\"os_arch\": \"$(uname -m)\"
}
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ async function main(){
const program = buildProgram()
await program.parseAsync(process.argv)

// Shutdown
await AnalyticsManager.get().shutdown()

} catch (e){
logger.error("Oops, something went wrong 😨", e)
logger.error("If you think this is a bug, please file an issue with error logs: https://github.com/PierreBeucher/cloudypad/issues")

const eventProps = e instanceof Error ? { errorMessage: e.message, stackTrace: e.stack } : { errorMessage: String(e), stackTrace: "unknown" }
AnalyticsManager.get().sendEvent("error", eventProps)
const analytics = AnalyticsManager.get()
analytics.sendEvent("error", eventProps)
await analytics.shutdown()

process.exit(1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/analytics/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class PostHogAnalyticsClient extends AbstractAnalyticsClient {
protected async doShutdown() {
this.logger.debug(`Shutting down PostHog analytics client...`)

await this.postHog.shutdown() // Wait at most 5s before final shutdown
await this.postHog.shutdown()

this.logger.debug(`Shut down complete for PostHog analytics client`)
}
Expand Down
24 changes: 19 additions & 5 deletions src/tools/pulumi/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface InstancePulumiClientArgs {
stackName: string
}

const LOG_ON_OUTPUT_COLOR = "always"

/**
* An abstract Pulumi client for a Cloudy Pad instance
*/
Expand Down Expand Up @@ -97,7 +99,7 @@ export abstract class InstancePulumiClient<ConfigType, OutputType> {
// Might become a flag later
await stack.cancel()

const upRes = await stack.up({ onOutput: (msg) => { console.info(msg.trim()) }, color: "auto", refresh: true })
const upRes = await stack.up({ onOutput: this.stackLogOnOutput, color: LOG_ON_OUTPUT_COLOR, refresh: true })

this.logger.trace(`Up result: ${JSON.stringify(upRes)}`)

Expand All @@ -120,7 +122,7 @@ export abstract class InstancePulumiClient<ConfigType, OutputType> {
// Might become a flag later
await stack.cancel()

const prevRes = await stack.preview({ onOutput: (msg) => { console.info(msg.trim()) }, color: "auto", refresh: true })
const prevRes = await stack.preview({ onOutput: this.stackLogOnOutput, color: LOG_ON_OUTPUT_COLOR, refresh: true })

this.logger.trace(`Preview result: ${JSON.stringify(prevRes)}`)

Expand All @@ -139,10 +141,22 @@ export abstract class InstancePulumiClient<ConfigType, OutputType> {

this.logger.debug(`Refreshing stack ${stack.name} before destroy result`)

const refreshRes = await stack.refresh({ onOutput: console.info, color: "auto" })
const refreshRes = await stack.refresh({ onOutput: this.stackLogOnOutput, color: LOG_ON_OUTPUT_COLOR })
this.logger.trace(`Refresh result: ${JSON.stringify(refreshRes)}`)

const destroyRes = await stack.destroy({ onOutput: console.info, color: "auto", remove: true })
const destroyRes = await stack.destroy({ onOutput: this.stackLogOnOutput, color: LOG_ON_OUTPUT_COLOR, remove: true })
this.logger.trace(`Destroy result: ${JSON.stringify(destroyRes)}`)
}
}

/**
* Log Pulumi output to console using stdout directly and tweaking a bit the output for nicer display
* @param msg raw pulumi output on stack action
*/
private async stackLogOnOutput(_msg: string){

let msg = _msg
if(msg.trim() === ".") msg = "." // if msg is a dot with newlines or spaces, print it as a dot without newline

process.stdout.write(msg)
}
}

0 comments on commit 4ea7606

Please sign in to comment.