Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1054f7f
Replace instances of require() with import
agibson-godaddy Feb 28, 2025
f1be39f
Move config to separate file that we can export
agibson-godaddy Mar 12, 2025
67e1f65
Initialize config from inside sake file
agibson-godaddy Mar 12, 2025
ea38b7a
Refactor replacement pipes
agibson-godaddy Mar 12, 2025
b9ad28d
Export scripts
agibson-godaddy Mar 12, 2025
d05267b
Refactor validation task
agibson-godaddy Mar 12, 2025
95ae9ed
Refactor bump task
agibson-godaddy Mar 12, 2025
d6cb231
Rework wc tasks
agibson-godaddy Mar 13, 2025
a6a6826
Only import the fs function we use
agibson-godaddy Mar 13, 2025
742c38a
Rework config task
agibson-godaddy Mar 13, 2025
b20d287
Rework linting
agibson-godaddy Mar 13, 2025
c87cc19
Rework imagemin
agibson-godaddy Mar 13, 2025
a8d9bd3
Adjust gulpif import
agibson-godaddy Mar 14, 2025
8f118fe
Rework shell tasks
agibson-godaddy Mar 14, 2025
47a4296
Rework watch
agibson-godaddy Mar 14, 2025
6e429df
Rework styles
agibson-godaddy Mar 14, 2025
975f55e
Rework makepot
agibson-godaddy Mar 14, 2025
0a99b85
Rework decaffeinate
agibson-godaddy Mar 14, 2025
08d14e1
Rework clean tasks
agibson-godaddy Mar 14, 2025
2182c87
Rework compile task
agibson-godaddy Mar 14, 2025
f1ff8e8
Rework scripts
agibson-godaddy Mar 14, 2025
0f20169
Rework github tasks
agibson-godaddy Mar 14, 2025
d235325
Rework zip
agibson-godaddy Mar 14, 2025
75f1ebb
Rework prompt
agibson-godaddy Mar 14, 2025
40a5a55
Rework bundle
agibson-godaddy Mar 14, 2025
06141a6
Use task suffix in constants
agibson-godaddy Mar 14, 2025
beafea5
Use task suffix
agibson-godaddy Mar 14, 2025
5c517b0
Use task suffix
agibson-godaddy Mar 14, 2025
e1c28d6
Use task suffix
agibson-godaddy Mar 14, 2025
a68bfe0
Use task suffix
agibson-godaddy Mar 14, 2025
0370715
Start reworking deploy
agibson-godaddy Mar 14, 2025
59a5cca
Rework deploy tasks
agibson-godaddy Mar 17, 2025
d0bae0f
Update prerelease tasks
agibson-godaddy Mar 17, 2025
c0a821b
Update upfw tasks
agibson-godaddy Mar 17, 2025
1291ccd
Update naming
agibson-godaddy Mar 17, 2025
0212867
Update naming
agibson-godaddy Mar 17, 2025
c79a6e0
Fix import
agibson-godaddy Mar 17, 2025
c1ccfcf
Update deprecated sass import
agibson-godaddy Mar 17, 2025
2b08904
Remove console log
agibson-godaddy Mar 19, 2025
df04967
Rework how series is created
agibson-godaddy Mar 19, 2025
d72c2ba
Add force option
agibson-godaddy Mar 25, 2025
3ec049c
Check new WC variables
agibson-godaddy May 7, 2025
9dff11a
Propagate up exit
agibson-godaddy May 7, 2025
880b09f
Add helpers
agibson-godaddy May 7, 2025
64c1fd4
Export as const
agibson-godaddy May 7, 2025
b3fc823
Check if dry run deploy
agibson-godaddy May 7, 2025
0001544
Add additional checks for non interactive mode
agibson-godaddy May 7, 2025
d0cd0ed
Do not prompt docs in non-interactive
agibson-godaddy May 7, 2025
a8da9c0
Use plugin version from arguments
agibson-godaddy May 15, 2025
b47c091
Support skipping linting
agibson-godaddy May 15, 2025
fe03d00
Fix merge conflicts
agibson-godaddy Jan 30, 2026
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
8 changes: 6 additions & 2 deletions bin/sake.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ const args = [
'--cwd', process.cwd()
]))

// fire up gulp
spawn('node', args, { cwd: process.cwd(), stdio: 'inherit' })
const child = spawn('node', args, { cwd: process.cwd(), stdio: 'inherit' })

// we need the exit code of the child process to propagate up to the main process
child.on('exit', function(code) {
process.exitCode = code
})
33 changes: 33 additions & 0 deletions helpers/arguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import minimist from 'minimist'

/**
* Determines if the command is being run in "non-interactive mode". If true, we should never present with prompts.
* @returns {boolean}
*/
export function isNonInteractive()
{
return process.argv.includes('--non-interactive');
}

/**
* Whether this is a dry run deployment. If true, the deploy to WooCommerce will not actually happen.
* @returns {boolean}
*/
export const isDryRunDeploy = () =>{
return process.argv.includes('--dry-run');
}

/**
* The new version of the plugin to deploy. This can be provided via arguments instead of using the prompt.
* This will likely be supplied when using non-interactive mode (e.g. CI/CD).
* @returns {string|null} The version of the plugin to be deployed, if provided.
*/
export const newPluginVersion = () => {
const argv = minimist(process.argv.slice(2))

return argv['new-version'] || null;
}

export const skipLinting = () => {
return process.argv.includes('--skip-linting');
}
8 changes: 7 additions & 1 deletion tasks/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { lintPhpTask } from './lint.js'
import { minifyImagesTask } from './imagemin.js'
import { makepotTask } from './makepot.js'
import { stylesTask } from './styles.js'
import { skipLinting } from '../helpers/arguments.js';
const sass = gulpSaas(dartSaas);

/************************** Scripts */
Expand Down Expand Up @@ -150,7 +151,12 @@ compileStyles.displayName = 'compile:styles'
// Compile all plugin assets
const compile = (done) => {
// default compile tasks
let tasks = [lintPhpTask, 'scripts', stylesTask, minifyImagesTask] // NOTE: do not import the `scripts` constant here, otherwise it creates a circular dependency
let tasks = ['scripts', stylesTask, minifyImagesTask] // NOTE: do not import the `scripts` constant here, otherwise it creates a circular dependency

// lint PHP unless told not to
if (! skipLinting) {
tasks.push(lintPhpTask)
}

// unless exclusively told not to, generate the POT file as well
if (!sake.options.skip_pot) {
Expand Down
29 changes: 21 additions & 8 deletions tasks/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { zipTask } from './zip.js'
import { validateReadmeHeadersTask } from './validate.js'
import { lintScriptsTask, lintStylesTask } from './lint.js'
import { copyWcRepoTask, copyWpAssetsTask, copyWpTagTask, copyWpTrunkTask } from './copy.js'
import { isDryRunDeploy, isNonInteractive } from '../helpers/arguments.js';

let validatedEnvVariables = false

Expand All @@ -44,7 +45,7 @@ function validateEnvVariables () {
let variables = ['GITHUB_API_KEY', 'GITHUB_USERNAME', 'SAKE_PRE_RELEASE_PATH']

if (sake.config.deploy.type === 'wc') {
variables = variables.concat(['WC_CONSUMER_KEY', 'WC_CONSUMER_SECRET'])
variables = variables.concat(['WC_USERNAME', 'WC_APPLICATION_PASSWORD'])
}

if (sake.config.deploy.type === 'wp') {
Expand Down Expand Up @@ -110,16 +111,28 @@ const deployTask = (done) => {
deployCreateReleasesTask,
]

if (sake.config.deploy.wooId && sake.config.deploy.type === 'wc') {
tasks.push(promptWcUploadTask)
}
if (isDryRunDeploy()) {
tasks.push(function(cb) {
log.info('Dry run deployment successful')

if (sake.config.deploy.type === 'wp') {
tasks.push(deployToWpRepoTask)
return cb()
})
} else {
if (sake.config.deploy.wooId && sake.config.deploy.type === 'wc') {
tasks.push(promptWcUploadTask)
}

if (sake.config.deploy.type === 'wp') {
tasks.push(deployToWpRepoTask)
}
}

// finally, create a docs issue, if necessary
tasks.push(gitHubCreateDocsIssueTask)
// finally, create a docs issue, if necessary, but only in interactive mode
if (!isNonInteractive()) {
tasks.push(gitHubCreateDocsIssueTask)
} else {
log.info('Running in non-interactive mode, skipping docs issue creation')
}

return gulp.series(tasks)(done)
}
Expand Down
9 changes: 5 additions & 4 deletions tasks/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import coffeelint from 'gulp-coffeelint'
import eslint from 'gulp-eslint'
import sassLint from 'gulp-sass-lint'
import { fileURLToPath } from 'node:url'
import { skipLinting } from '../helpers/arguments.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const lintPhpTask = (done) => {
if (process.argv.includes('--skip-linting')) {
if (skipLinting) {
return Promise.resolve()
}

Expand Down Expand Up @@ -46,7 +47,7 @@ const lintPhpTask = (done) => {
lintPhpTask.displayName = 'lint:php'

const lintCoffeeTask = (done) => {
if (process.argv.includes('--skip-linting')) {
if (skipLinting) {
return Promise.resolve()
}

Expand All @@ -66,7 +67,7 @@ const lintCoffeeTask = (done) => {
lintCoffeeTask.displayName = 'lint:coffee'

const lintJsTask = (done) => {
if (process.argv.includes('--skip-linting')) {
if (skipLinting) {
return Promise.resolve()
}

Expand All @@ -89,7 +90,7 @@ const lintJsTask = (done) => {
lintJsTask.displayName = 'lint:js'

const lintScssTask = (done) => {
if (process.argv.includes('--skip-linting')) {
if (skipLinting) {
return Promise.resolve()
}

Expand Down
23 changes: 22 additions & 1 deletion tasks/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import _ from 'lodash'
import sake from '../lib/sake.js'
import gulp from 'gulp'
import { wcDeployTask } from './wc.js'
import { isNonInteractive, newPluginVersion } from '../helpers/arguments.js'

function filterIncrement (value) {
if (value[1] === 'custom') {
Expand Down Expand Up @@ -39,6 +40,12 @@ function getDefault () {
* Internal task for prompting the deploy action
*/
const promptDeployTask = (done) => {
if (newPluginVersion()) {
log.info(`Using new version from arguments: ${newPluginVersion()}`)
sake.options = _.merge(sake.options, {version: newPluginVersion()})
return done()
}

let currentVersion = sake.getPluginVersion()

inquirer.prompt([
Expand Down Expand Up @@ -102,13 +109,21 @@ promptDeployTask.displayName = 'prompt:deploy'
* Internal task for prompting whether to upload the plugin to WooCommerce
*/
const promptWcUploadTask = (done) => {
const runWcDeployTask = () => gulp.series(wcDeployTask)(done);

// Skip the prompt if in non-interactive mode
if (isNonInteractive()) {
log.info('Running in non-interactive mode, automatically uploading to WooCommerce.com')
return runWcDeployTask();
}

inquirer.prompt([{
type: 'confirm',
name: 'upload_to_wc',
message: 'Upload plugin to WooCommerce.com?'
}]).then((answers) => {
if (answers.upload_to_wc) {
gulp.series(wcDeployTask)(done)
runWcDeployTask();
} else {
log.error(chalk.red('Skipped uploading to WooCommerce.com'))
done()
Expand All @@ -121,6 +136,12 @@ promptWcUploadTask.displayName = 'prompt:wc_upload'
* Internal task for prompting whether the release has been tested
*/
const promptTestedReleaseZipTask = (done) => {
// Skip the prompt if in non-interactive mode
if (isNonInteractive()) {
log.info('Running in non-interactive mode, skipping release zip testing confirmation')
return done()
}

inquirer.prompt([{
type: 'confirm',
name: 'tested_release_zip',
Expand Down