-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: version bump * feature: create teams publish command * feature: initial teams publish command * feature: extend teams-build command * refactor: minor reordering * refactor: improve parameter names * refactor: change build-command text slightly to better differentiate between the two types of messages * feature: refine teams-publish command * refactor: format project * refactor: improve output message * refactor: reformat project * chore: complete version bump-up * feature: remove artifact link from publish message * refactor: rename jscm sub-commands * refactor: rename to match command-names * refactor: reformat files * feature: improve message quality * wip * chore: add test artifact-links * feature: adapt command to use environment variables * chore: move isUrlValid to utility * chore: simplify everything * refactor: use semis * refactor: use functions instead of classes * test: add tests for teams messaging * chore: formatting * chore: formatting * refactor: use correct artifact links file in testing * feature: improve artifact type check --------- Co-authored-by: Julian König <[email protected]>
- Loading branch information
1 parent
74682c5
commit 884fd37
Showing
13 changed files
with
317 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
"printWidth": 120, | ||
"tabWidth": 2, | ||
"trailingComma": "none", | ||
"semi": false | ||
"semi": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface CmArtifactLink { | ||
name: string; | ||
type: string; | ||
url: string; | ||
md5: string; | ||
versionName: string; | ||
bundleId: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface TeamsCommandLineOptions { | ||
platform: string; | ||
projectName: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import axios from "axios"; | ||
import { isUrlValid } from "./isUrlValid"; | ||
|
||
export interface TeamsDevelopMessagingOptions { | ||
projectName: string; | ||
webhook: string; | ||
artifactUrl: string; | ||
buildUrl: string; | ||
buildWasSuccessful: boolean; | ||
platform: string; | ||
buildNumber: number; | ||
} | ||
|
||
export async function runTeamsDevelopMessagingCommand(options: TeamsDevelopMessagingOptions): Promise<void> { | ||
if (!isUrlValid(options.webhook)) { | ||
console.error("The given webhook is not valid."); | ||
process.exit(1); | ||
} | ||
|
||
if (!isUrlValid(options.artifactUrl)) { | ||
console.error("The given artifactUrl is not valid."); | ||
process.exit(1); | ||
} | ||
|
||
if (!isUrlValid(options.buildUrl)) { | ||
console.error("The given buildUrl is not valid."); | ||
process.exit(1); | ||
} | ||
|
||
const statusIdentifier = options.buildWasSuccessful ? "Successful" : "Failed"; | ||
const platformIdentifier = options.platform.toUpperCase(); | ||
|
||
const messageContents = { | ||
title: `New ${statusIdentifier.toLowerCase()} ${options.platform} debug build for the "${options.projectName}" App`, | ||
summary: `${options.projectName}: ${statusIdentifier} build - ${platformIdentifier}`, | ||
text: options.buildWasSuccessful | ||
? `New Build: #${options.buildNumber} - ${platformIdentifier} <br/> The latest version build successfully and is now available as an artifact.` | ||
: `New Build: #${options.buildNumber} - ${platformIdentifier} <br/> A problem occurred while building the newly released version. The corresponding logs are available.`, | ||
potentialAction: [ | ||
{ | ||
"@type": "OpenUri", | ||
name: options.buildWasSuccessful ? `Download ${options.platform}-App` : "Download Flutter Logs", | ||
targets: [{ os: "default", uri: options.artifactUrl }] | ||
}, | ||
{ | ||
"@type": "OpenUri", | ||
name: "Open Build", | ||
targets: [{ os: "default", uri: options.buildUrl }] | ||
} | ||
] | ||
}; | ||
|
||
await axios.post(options.webhook, messageContents).catch((_) => { | ||
console.log("Could not send message to teams channel."); | ||
process.exit(1); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import axios from "axios"; | ||
import { isUrlValid } from "./isUrlValid"; | ||
|
||
export interface TeamsProductionMessagingOptions { | ||
projectName: string; | ||
platform: string; | ||
buildUrl: string; | ||
buildNumber: number; | ||
webhook: string; | ||
} | ||
|
||
export async function runTeamsProductionMessagingCommand(options: TeamsProductionMessagingOptions): Promise<void> { | ||
if (!isUrlValid(options.webhook)) { | ||
console.error("The given webhook is not valid."); | ||
process.exit(1); | ||
} | ||
|
||
if (!isUrlValid(options.buildUrl)) { | ||
console.error("The given buildUrl is not valid."); | ||
process.exit(1); | ||
} | ||
|
||
const platformIdentifier = options.platform.toUpperCase(); | ||
const storeName = platformIdentifier === "IOS" ? "App Store" : "Google Play Store"; | ||
const messageContents = { | ||
title: `${options.projectName}: New release is now available in the ${storeName} [${platformIdentifier}]`, | ||
summary: `New Release - ${platformIdentifier}`, | ||
text: `New Release: #${options.buildNumber} - ${platformIdentifier} <br/> | ||
The newly released version is now available in the ${storeName}. `, | ||
potentialAction: [ | ||
{ | ||
"@type": "OpenUri", | ||
name: "Open Build", | ||
targets: [{ os: "default", uri: options.buildUrl }] | ||
} | ||
] | ||
}; | ||
|
||
await axios.post(options.webhook, messageContents).catch((_) => { | ||
console.log("Could not send message to teams channel."); | ||
process.exit(1); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function isUrlValid(url: string): boolean { | ||
try { | ||
// eslint-disable-next-line no-new | ||
new URL(url); | ||
return true; | ||
} catch (err) { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.