Skip to content

Commit b226b26

Browse files
committed
checking php files recursively
1 parent eec1459 commit b226b26

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,19 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
124124
const releaseZipPath = path_1.default.join(webPackage, 'release.zip');
125125
// Ignore if the app is not a Linux app or if release.zip does not exist
126126
if (!this.actionParams.isLinux || !fs_1.default.existsSync(releaseZipPath)) {
127+
core.info(`release.zip does not exist or not a Linux app, skipping deletion: ${releaseZipPath}`);
127128
return;
128129
}
129130
let isPhpApp = yield this.checkIfTheAppIsPhpApp(webPackage);
130131
// No need to delete release.zip for non-PHP apps
131132
if (!isPhpApp) {
133+
core.info(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`);
132134
return;
133135
}
134136
// Delete release.zip if it exists
135137
try {
136138
yield fs_1.default.promises.unlink(releaseZipPath);
137-
core.debug(`Deleted release.zip`);
139+
core.info(`Deleted release.zip`);
138140
}
139141
catch (error) {
140142
core.debug(`Error while deleting release.zip for Linux PHP app: ${error}`);
@@ -147,14 +149,22 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
147149
// Check if the webPackage folder contains a composer.json file
148150
const composerFile = 'composer.json';
149151
if (fs_1.default.existsSync(path_1.default.join(webPackage, composerFile))) {
152+
core.info(`Detected PHP app by presence of ${composerFile}`);
150153
return true;
151154
}
152155
// Check if the webPackage folder contains a .php file
153-
const hasPhpFiles = fs_1.default.readdirSync(webPackage).some(file => file.endsWith('.php'));
156+
core.info(`Checking for .php files in the web package directory: ${webPackage}`);
157+
const hasPhpFiles = fs_1.default.readdirSync(webPackage, { withFileTypes: true, recursive: true }).some(file => file.isFile() && file.name.endsWith('.php'));
158+
if (hasPhpFiles) {
159+
core.info(`Detected PHP app by presence of .php files`);
160+
}
161+
else {
162+
core.info(`No .php files found in the web package directory.`);
163+
}
154164
return hasPhpFiles;
155165
}
156166
catch (error) {
157-
core.debug(`Error while checking if the app is PHP: ${error}`);
167+
core.info(`Error while checking if the app is PHP: ${error}`);
158168
}
159169
return false;
160170
});

src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { addAnnotation } from 'azure-actions-appservice-rest/Utilities/Annotatio
99

1010
import fs from 'fs';
1111
import path from 'path';
12+
import { dir } from 'console';
1213

1314
export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
1415

@@ -90,21 +91,23 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
9091

9192
// Ignore if the app is not a Linux app or if release.zip does not exist
9293
if (!this.actionParams.isLinux || !fs.existsSync(releaseZipPath)) {
94+
core.info(`release.zip does not exist or not a Linux app, skipping deletion: ${releaseZipPath}`);
9395
return;
9496
}
9597

9698
let isPhpApp = await this.checkIfTheAppIsPhpApp(webPackage);
9799

98100
// No need to delete release.zip for non-PHP apps
99101
if (!isPhpApp) {
102+
core.info(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`);
100103
return;
101104
}
102105

103106
// Delete release.zip if it exists
104107

105108
try {
106109
await fs.promises.unlink(releaseZipPath);
107-
core.debug(`Deleted release.zip`);
110+
core.info(`Deleted release.zip`);
108111
} catch (error) {
109112
core.debug(`Error while deleting release.zip for Linux PHP app: ${error}`);
110113
}
@@ -116,17 +119,26 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
116119
// Check if the webPackage folder contains a composer.json file
117120
const composerFile = 'composer.json';
118121
if (fs.existsSync(path.join(webPackage, composerFile))) {
122+
core.info(`Detected PHP app by presence of ${composerFile}`);
119123
return true;
120124
}
121125

122126
// Check if the webPackage folder contains a .php file
123-
const hasPhpFiles = fs.readdirSync(webPackage).some(file => file.endsWith('.php'));
127+
core.info(`Checking for .php files in the web package directory: ${webPackage}`);
128+
const hasPhpFiles = fs.readdirSync(webPackage, {withFileTypes: true, recursive: true}).some(file => file.isFile() && file.name.endsWith('.php'));
129+
130+
if (hasPhpFiles) {
131+
core.info(`Detected PHP app by presence of .php files`);
132+
} else {
133+
core.info(`No .php files found in the web package directory.`);
134+
}
124135

125136
return hasPhpFiles;
126137
} catch (error) {
127-
core.debug(`Error while checking if the app is PHP: ${error}`);
138+
core.info(`Error while checking if the app is PHP: ${error}`);
128139
}
129140

130141
return false;
131142
}
143+
132144
}

0 commit comments

Comments
 (0)