Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ Run from your project root (the directory that contains `package.json` with your
npx wp-deployer
```

Show CLI help or version:
CLI sub-commands:

```sh
npx wp-deployer --help
npx wp-deployer --version
npx wp-deployer --assets
```

Use `--assets` when you only want to push the assets directory (e.g. screenshots, banner) to WordPress.org and skip trunk and tag deployment.

Or add a script to `package.json` and run it:

```sh
Expand Down
22 changes: 18 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const exec = promisify(execCb)
const __dirname = path.dirname(fileURLToPath(import.meta.url))

const argv = minimist(process.argv.slice(2), {
boolean: ['help', 'version'],
boolean: ['help', 'version', 'assets'],
alias: { h: 'help', v: 'version' }
})

Expand All @@ -38,8 +38,9 @@ function printHelp () {
Deploy a WordPress plugin or theme to WordPress.org SVN using wpDeployer in package.json.

Options:
--help, -h Show this message
--version, -v Print wp-deployer version
--help, -h Show this message
--version, -v Print wp-deployer version
--assets Deploy only the assets directory (plugin only; skips trunk and tag)
`)
}

Expand Down Expand Up @@ -72,7 +73,7 @@ process.on('SIGINT', () => {
const wpDeployer = async () => {
console.log(chalk.cyan('Processing...'))

const { settings, error, errorMessage } = resolveSettings(pkg)
let { settings, error, errorMessage } = resolveSettings(pkg)
if (error === 'invalid_slug') {
console.error(chalk.red(`Invalid slug: ${errorMessage}`))
return EXIT_CONFIG
Expand Down Expand Up @@ -106,6 +107,19 @@ const wpDeployer = async () => {
return EXIT_CONFIG
}

if (argv.assets) {
if (settings.repoType !== 'plugin') {
console.error(chalk.red('--assets is only supported for plugins.'))
return EXIT_CONFIG
}
settings = {
...settings,
deployTrunk: false,
deployTag: false,
deployAssets: true
}
}

try {
runPreflightSync(settings, { fs, awk })
} catch (e) {
Expand Down
6 changes: 6 additions & 0 deletions test/cli-flags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ describe('CLI flags', () => {
assert.strictEqual(r.status, 0, r.stderr)
assert.match(r.stdout, /Usage:\s*wp-deployer/i)
})

it('--help documents --assets', () => {
const r = spawnSync(process.execPath, [indexJs, '--help'], { encoding: 'utf8' })
assert.strictEqual(r.status, 0, r.stderr)
assert.match(r.stdout, /--assets\b/)
})
})