Skip to content

Commit

Permalink
Merge pull request #122 from bigbite/feature/named-admin-user
Browse files Browse the repository at this point in the history
feat: allow admin username to set from config adminUsername
  • Loading branch information
con322 authored May 3, 2023
2 parents 62f8903 + 729c1ac commit f052e72
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/cli/commands/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if( file_exists ( ABSPATH . '.userid' ) ) {
wpcli(
`core ${getWPInstallType(config.multisite)} --url=${
config.url
} --title="WP Cypress" --admin_user=admin --admin_password=password --admin_email="[email protected]" --skip-email`,
} --title="WP Cypress" --admin_user=${config.adminUsername} --admin_password=password --admin_email="[email protected]" --skip-email`,
logFile,
),
'Installing WordPress',
Expand Down Expand Up @@ -118,9 +118,9 @@ if( file_exists ( ABSPATH . '.userid' ) ) {
);

await run(
async () => wpcli('wp-cypress-set-user admin', logFile),
'Set user to admin',
'User set to admin',
async () => wpcli(`wp-cypress-set-user ${config.adminUsername}`, logFile),
`Set user to ${config.adminUsername}`,
`User set to ${config.adminUsername}`,
logFile,
);

Expand Down
6 changes: 3 additions & 3 deletions lib/cli/commands/softReset.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const softReset = async (packageDir, logFile, options = false) => {
await cli(`bash update.sh ${version} false`, logFile);

await run(
async () => wpcli('wp-cypress-set-user admin', logFile),
'Set user to admin',
'User set to admin',
async () => wpcli(`wp-cypress-set-user ${config.adminUsername}`, logFile),
`Set user to ${config.adminUsername}`,
`User set to ${config.adminUsername}`,
logFile,
);

Expand Down
1 change: 1 addition & 0 deletions lib/modules/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const createConfig = async (packageDir, hasVolumeSupport = true) => {
multisite: false,
url: false,
phpMemoryLimit: '128M',
adminUsername: 'admin',
});

const schema = await fs.readJSON(`${packageDir}/lib/schemas/config-validation.json`);
Expand Down
4 changes: 4 additions & 0 deletions lib/schemas/config-validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"type": "string",
"errorMessage": "wp.seedsPath is not a string"
},
"adminUsername": {
"type": "string",
"errorMessage": "wp.adminUsername is not a string"
},
"multisite": {
"type": ["boolean", "string"],
"errorMessage": "multisite is not set to false, true or subdomains"
Expand Down

0 comments on commit f052e72

Please sign in to comment.