Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Add WordPress constants using CLI arguments #1811

Open
wants to merge 4 commits into
base: fix/1706-login-with-site-email-verification
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/playground/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ async function run() {
type: 'boolean',
default: false,
})
.option('constants', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UX nit:
Could we make this singular like --constant and allow specifying multiple times?

describe: 'Define constants to be used in the Blueprint.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we document the format of the argument, even if it seems intuitive?

type: 'array',
string: true,
default: [],
})
.showHelpOnFail(false)
.check((args) => {
if (args.wp !== undefined && !isValidWordPressSlug(args.wp)) {
Expand Down Expand Up @@ -295,7 +301,6 @@ async function run() {
: fs.existsSync(preinstalledWpContentPath)
? readAsFile(preinstalledWpContentPath)
: fetchWordPress(wpDetails.url, monitor);

requestHandler = await bootWordPress({
siteUrl: absoluteUrl,
createPhpRuntime: async () =>
Expand All @@ -319,6 +324,16 @@ async function run() {
}
},
},
constants: args.constants.reduce(
(acc: Record<string, string>, curr: string) => {
const [key, value] = curr.split('=');
if (key && value !== undefined) {
acc[key.trim()] = value.trim();
}
return acc;
},
{}
),
});

const php = await requestHandler.getPrimaryPhp();
Expand Down
Loading