@@ -8,21 +8,31 @@ const core_1 = require("@actions/core");
88const fs_1 = require ( "fs" ) ;
99const path_1 = __importDefault ( require ( "path" ) ) ;
1010const constants_1 = require ( "./constants" ) ;
11- /* Replaces all instances of a match in a string. */
11+ /**
12+ * Replaces all instances of a match in a string.
13+ */
1214const replaceAll = ( input , find , replace ) => input . split ( find ) . join ( replace ) ;
13- /* Utility function that checks to see if a value is undefined or not.
14- If allowEmptyString is passed the parameter is allowed to contain an empty string as a valid parameter. */
15+ /**
16+ * Utility function that checks to see if a value is undefined or not.
17+ * If allowEmptyString is passed the parameter is allowed to contain an empty string as a valid parameter.
18+ */
1519const isNullOrUndefined = ( value ) => typeof value === 'undefined' || value === null || value === '' ;
1620exports . isNullOrUndefined = isNullOrUndefined ;
17- /* Generates a token type used for the action. */
21+ /**
22+ * Generates a token type used for the action.
23+ */
1824const generateTokenType = ( action ) => action . sshKey ? 'SSH Deploy Key' : action . token ? 'Deploy Token' : '…' ;
1925exports . generateTokenType = generateTokenType ;
20- /* Generates a the repository path used to make the commits. */
26+ /**
27+ * Generates a the repository path used to make the commits.
28+ */
2129const generateRepositoryPath = ( action ) => action . sshKey
2230 ? `git@${ action . hostname } :${ action . repositoryName } `
2331 : `https://${ `x-access-token:${ action . token } ` } @${ action . hostname } /${ action . repositoryName } .git` ;
2432exports . generateRepositoryPath = generateRepositoryPath ;
25- /* Genetate absolute folder path by the provided folder name */
33+ /**
34+ * Generate absolute folder path by the provided folder name
35+ */
2636const generateFolderPath = ( action ) => {
2737 const folderName = action [ 'folder' ] ;
2838 return path_1 . default . isAbsolute ( folderName )
@@ -32,12 +42,16 @@ const generateFolderPath = (action) => {
3242 : path_1 . default . join ( action . workspace , folderName ) ;
3343} ;
3444exports . generateFolderPath = generateFolderPath ;
35- /* Checks for the required tokens and formatting. Throws an error if any case is matched. */
45+ /**
46+ * Checks for the required tokens and formatting. Throws an error if any case is matched.
47+ */
3648const hasRequiredParameters = ( action , params ) => {
3749 const nonNullParams = params . filter ( param => ! ( 0 , exports . isNullOrUndefined ) ( action [ param ] ) ) ;
3850 return Boolean ( nonNullParams . length ) ;
3951} ;
40- /* Verifies the action has the required parameters to run, otherwise throw an error. */
52+ /**
53+ * Verifies the action has the required parameters to run, otherwise throw an error.
54+ */
4155const checkParameters = ( action ) => {
4256 if ( ! hasRequiredParameters ( action , [ 'token' , 'sshKey' ] ) ) {
4357 throw new Error ( 'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. For more details on how to use an ssh deploy key please refer to the documentation.' ) ;
@@ -56,7 +70,9 @@ const checkParameters = (action) => {
5670 }
5771} ;
5872exports . checkParameters = checkParameters ;
59- /* Suppresses sensitive information from being exposed in error messages. */
73+ /**
74+ * Suppresses sensitive information from being exposed in error messages.
75+ */
6076const suppressSensitiveInformation = ( str , action ) => {
6177 let value = str ;
6278 if ( ( 0 , core_1 . isDebug ) ( ) ) {
@@ -70,12 +86,17 @@ const suppressSensitiveInformation = (str, action) => {
7086 return value ;
7187} ;
7288exports . suppressSensitiveInformation = suppressSensitiveInformation ;
89+ /**
90+ * Extracts message from an error object.
91+ */
7392const extractErrorMessage = ( error ) => error instanceof Error
7493 ? error . message
7594 : typeof error == 'string'
7695 ? error
7796 : JSON . stringify ( error ) ;
7897exports . extractErrorMessage = extractErrorMessage ;
79- /** Strips the protocol from a provided URL. */
98+ /**
99+ * Strips the protocol from a provided URL.
100+ */
80101const stripProtocolFromUrl = ( url ) => url . replace ( / ^ (?: h t t p s ? : \/ \/ ) ? (?: w w w \. ) ? / i, '' ) . split ( '/' ) [ 0 ] ;
81102exports . stripProtocolFromUrl = stripProtocolFromUrl ;
0 commit comments