Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevoss committed Jul 25, 2024
1 parent 29f3c5e commit e5fbe2e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion actions/setup-wp-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ runs:
ACTION_PATH: ${{ github.action_path }}
INPUT_CONFIG: ${{ inputs.config }}
run: |
npx zx@8 $ACTION_PATH/dist/create-wp-env-config.cjs \
npx zx@8 $ACTION_PATH/dist/create-wp-env-config.js \
--wp="$INPUT_WP" \
--php="$INPUT_PHP" \
--plugins="$INPUT_PLUGINS" \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use strict";

// actions/setup-wp-env/create-wp-env-config.ts


Expand Down Expand Up @@ -46,14 +44,14 @@ async function main() {
)
}
};
await import_zx.fs.ensureDir(WP_ENV_TMP_DIR);
await import_zx.fs.writeJSON(`${WP_ENV_TMP_DIR}/.wp-env.json`, content, {
await fs.ensureDir(WP_ENV_TMP_DIR);
await fs.writeJSON(`${WP_ENV_TMP_DIR}/.wp-env.json`, content, {
spaces: 2
});
}
function getOptions(args) {
const entries = Object.entries(args);
const options = (0, import_zx.minimist)(process.argv.slice(2), {
const options = minimist(process.argv.slice(2), {
string: entries.filter(([, { type }]) => type === "string").map(([key]) => key),
boolean: entries.filter(([, { type }]) => type === "boolean").map(([key]) => key),
default: Object.fromEntries(
Expand Down
6 changes: 3 additions & 3 deletions scripts/remove-zx-imports-tsup-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export default function removeZxImportsTsupPlugin() {
buildEnd: ({ writtenFiles }) =>
Promise.all(
writtenFiles.map(async (file) => {
const content = (await fs.readFile(file.name, 'utf-8'))
.replaceAll(/^import .+ from "zx";?$/gm, '')
.replaceAll('var import_zx = require("zx");', '');
const content = (
await fs.readFile(file.name, 'utf-8')
).replaceAll(/^import .+ from "zx";?$/gm, '');

await fs.writeFile(file.name, content, 'utf-8');
}),
Expand Down
29 changes: 13 additions & 16 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ import { defineConfig } from 'tsup';
import removeZxImportsTsupPlugin from './scripts/remove-zx-imports-tsup-plugin.js';

export default [
defineActionConfig('setup-wp-env'),
defineActionConfig('setup-elementor-env', ['index.ts'], true),
];

function defineActionConfig(
action: string,
files: string[] = [],
bundle: boolean = false,
) {
return defineConfig({
entry: [`actions/${action}/${files.join(',') || '*.ts'}`],
outDir: `actions/${action}/dist`,
format: 'cjs',
defineConfig({
entry: [`actions/setup-wp-env/*.ts`],
outDir: `actions/setup-wp-env/dist`,
format: 'esm',
plugins: [removeZxImportsTsupPlugin()],
noExternal: bundle ? [/.+/] : [],
platform: 'node',
});
}
}),
defineConfig({
entry: [`actions/setup-elementor-env/index.ts`],
outDir: `actions/setup-elementor-env/dist`,
format: 'cjs',
noExternal: [/.+/],
platform: 'node',
}),
];

0 comments on commit e5fbe2e

Please sign in to comment.