Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevoss committed Jul 24, 2024
1 parent c59a76f commit 8b0a490
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .github/actions/setup-wp-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ runs:
INPUT_ACTIVE_THEME: ${{ inputs.active-theme }}
INPUT_MAPPINGS: ${{ inputs.mappings }}
ACTION_PATH: ${{ github.action_path }}
INPUT_CONFIG: ${{ github.config }}
run: |
npx zx@8 $ACTION_PATH/../../../dist/setup-wp-env/create-wp-env-config.js \
--wp="$INPUT_WP" \
Expand All @@ -49,7 +50,8 @@ runs:
--themes="$INPUT_THEMES" \
--active-theme="$INPUT_ACTIVE_THEME" \
--mappings="$INPUT_ACTIVE_THEME" \
--config-dir="./.wp-env-tmp"
--config="$INPUT_CONFIG" \
--dir="./.wp-env-tmp"
shell: bash

- name: Output wp-env config file
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,5 @@ jobs:
themes: 'https://downloads.wordpress.org/theme/hello-elementor.zip'
active-theme: 'hello-elementor'
config: |
elementor-templates:./tests/playwright/templates
elementor-config:./tests/wp-env/config
config2: |-
elementor-templates:./tests/playwright/templates
elementor-config:./tests/wp-env/config
ELEMENTOR_SHOW_HIDDEN_EXPERIMENTS:true
SOME_STRING:"THIS IS SOME STRING"
15 changes: 7 additions & 8 deletions dist/setup-wp-env/create-wp-env-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ async function main() {
plugins,
themes,
mappings,
"config-dir": configDir,
dir,
"active-theme": activeTheme,
config1,
config2
config
} = getOptions({
wp: { type: "string", default: null },
php: { type: "string", default: null },
Expand All @@ -22,12 +21,12 @@ async function main() {
validate: (value) => typeof value === "string" && /^[a-z0-9-]+$/.test(value)
},
mappings: { type: "string", default: "" },
"config-dir": { type: "string", default: "./" },
dir: { type: "string", default: "./" },
config1: { type: "string", default: "" },
config2: { type: "string", default: "" }
});
console.log(config1, config2);
const config = {
console.log(config);
const content = {
core: wp ? `WordPress/Wordpress#${wp}` : null,
phpVersion: php ? php : null,
themes: parseAsArray(themes),
Expand All @@ -43,8 +42,8 @@ async function main() {
)
}
};
await fs.ensureDir(configDir);
await fs.writeJSON(`${configDir}/.wp-env.json`, config, { spaces: 2 });
await fs.ensureDir(dir);
await fs.writeJSON(`${dir}/.wp-env.json`, content, { spaces: 2 });
}
function getOptions(args) {
const entries = Object.entries(args);
Expand Down
15 changes: 7 additions & 8 deletions src/setup-wp-env/create-wp-env-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ async function main() {
plugins,
themes,
mappings,
'config-dir': configDir,
dir,
'active-theme': activeTheme,
config1,
config2,
config,
} = getOptions({
wp: { type: 'string', default: null },
php: { type: 'string', default: null },
Expand All @@ -23,14 +22,14 @@ async function main() {
typeof value === 'string' && /^[a-z0-9-]+$/.test(value),
},
mappings: { type: 'string', default: '' },
'config-dir': { type: 'string', default: './' },
dir: { type: 'string', default: './' },
config1: { type: 'string', default: '' },
config2: { type: 'string', default: '' },
});

console.log(config1, config2);
console.log(config);

const config = {
const content = {
core: wp ? `WordPress/Wordpress#${wp}` : null,
phpVersion: php ? php : null,
themes: parseAsArray(themes),
Expand All @@ -48,8 +47,8 @@ async function main() {
},
};

await fs.ensureDir(configDir);
await fs.writeJSON(`${configDir}/.wp-env.json`, config, { spaces: 2 });
await fs.ensureDir(dir);
await fs.writeJSON(`${dir}/.wp-env.json`, content, { spaces: 2 });
}

function getOptions(
Expand Down

0 comments on commit 8b0a490

Please sign in to comment.