Skip to content

Commit 8e23964

Browse files
committed
checking php files recursively
1 parent eec1459 commit 8e23964

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ 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);
@@ -134,7 +135,7 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
134135
// Delete release.zip if it exists
135136
try {
136137
yield fs_1.default.promises.unlink(releaseZipPath);
137-
core.debug(`Deleted release.zip`);
138+
core.info(`Deleted release.zip`);
138139
}
139140
catch (error) {
140141
core.debug(`Error while deleting release.zip for Linux PHP app: ${error}`);
@@ -147,14 +148,24 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
147148
// Check if the webPackage folder contains a composer.json file
148149
const composerFile = 'composer.json';
149150
if (fs_1.default.existsSync(path_1.default.join(webPackage, composerFile))) {
151+
core.info(`Detected PHP app by presence of ${composerFile}`);
150152
return true;
151153
}
152154
// Check if the webPackage folder contains a .php file
153-
const hasPhpFiles = fs_1.default.readdirSync(webPackage).some(file => file.endsWith('.php'));
155+
core.info(`Checking for .php files in the web package directory: ${webPackage}`);
156+
const hasPhpFiles = fs_1.default.readdirSync(webPackage, { withFileTypes: true, recursive: true }).some(file => file.isFile() && file.name.endsWith('.php'));
157+
// const entries = fs.readdirSync(webPackage, { withFileTypes: true, recursive: true });
158+
// return entries.some(entry => entry.isFile() && entry.name.endsWith('.php'));
159+
if (hasPhpFiles) {
160+
core.info(`Detected PHP app by presence of .php files`);
161+
}
162+
else {
163+
core.info(`No .php files found in the web package directory.`);
164+
}
154165
return hasPhpFiles;
155166
}
156167
catch (error) {
157-
core.debug(`Error while checking if the app is PHP: ${error}`);
168+
core.info(`Error while checking if the app is PHP: ${error}`);
158169
}
159170
return false;
160171
});

src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts

Lines changed: 17 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,6 +91,7 @@ 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

@@ -104,7 +106,7 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
104106

105107
try {
106108
await fs.promises.unlink(releaseZipPath);
107-
core.debug(`Deleted release.zip`);
109+
core.info(`Deleted release.zip`);
108110
} catch (error) {
109111
core.debug(`Error while deleting release.zip for Linux PHP app: ${error}`);
110112
}
@@ -116,17 +118,29 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
116118
// Check if the webPackage folder contains a composer.json file
117119
const composerFile = 'composer.json';
118120
if (fs.existsSync(path.join(webPackage, composerFile))) {
121+
core.info(`Detected PHP app by presence of ${composerFile}`);
119122
return true;
120123
}
121124

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

125138
return hasPhpFiles;
126139
} catch (error) {
127-
core.debug(`Error while checking if the app is PHP: ${error}`);
140+
core.info(`Error while checking if the app is PHP: ${error}`);
128141
}
129142

130143
return false;
131144
}
145+
132146
}

0 commit comments

Comments
 (0)