Skip to content

Commit f052e72

Browse files
authored
Merge pull request #122 from bigbite/feature/named-admin-user
feat: allow admin username to set from config adminUsername
2 parents 62f8903 + 729c1ac commit f052e72

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

lib/cli/commands/reset.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ if( file_exists ( ABSPATH . '.userid' ) ) {
8686
wpcli(
8787
`core ${getWPInstallType(config.multisite)} --url=${
8888
config.url
89-
} --title="WP Cypress" --admin_user=admin --admin_password=password --admin_email="admin@test.com" --skip-email`,
89+
} --title="WP Cypress" --admin_user=${config.adminUsername} --admin_password=password --admin_email="admin@test.com" --skip-email`,
9090
logFile,
9191
),
9292
'Installing WordPress',
@@ -118,9 +118,9 @@ if( file_exists ( ABSPATH . '.userid' ) ) {
118118
);
119119

120120
await run(
121-
async () => wpcli('wp-cypress-set-user admin', logFile),
122-
'Set user to admin',
123-
'User set to admin',
121+
async () => wpcli(`wp-cypress-set-user ${config.adminUsername}`, logFile),
122+
`Set user to ${config.adminUsername}`,
123+
`User set to ${config.adminUsername}`,
124124
logFile,
125125
);
126126

lib/cli/commands/softReset.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const softReset = async (packageDir, logFile, options = false) => {
2222
await cli(`bash update.sh ${version} false`, logFile);
2323

2424
await run(
25-
async () => wpcli('wp-cypress-set-user admin', logFile),
26-
'Set user to admin',
27-
'User set to admin',
25+
async () => wpcli(`wp-cypress-set-user ${config.adminUsername}`, logFile),
26+
`Set user to ${config.adminUsername}`,
27+
`User set to ${config.adminUsername}`,
2828
logFile,
2929
);
3030

lib/modules/createConfig.js

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const createConfig = async (packageDir, hasVolumeSupport = true) => {
4848
multisite: false,
4949
url: false,
5050
phpMemoryLimit: '128M',
51+
adminUsername: 'admin',
5152
});
5253

5354
const schema = await fs.readJSON(`${packageDir}/lib/schemas/config-validation.json`);

lib/schemas/config-validation.json

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
"type": "string",
2121
"errorMessage": "wp.seedsPath is not a string"
2222
},
23+
"adminUsername": {
24+
"type": "string",
25+
"errorMessage": "wp.adminUsername is not a string"
26+
},
2327
"multisite": {
2428
"type": ["boolean", "string"],
2529
"errorMessage": "multisite is not set to false, true or subdomains"

0 commit comments

Comments
 (0)