wp-advads 1.0.30 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/app.js +12 -0
- package/src/commands/build.js +82 -0
- package/src/commands/class.js +1 -1
- package/src/commands/index.js +1 -0
- package/src/commands/release.js +2 -2
- package/src/commands/wp-pot.js +2 -1
- package/src/utilities/shell.js +2 -2
- package/src/commands/release/composer.js +0 -29
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -46,6 +46,18 @@ const app = async () => {
|
|
|
46
46
|
.description('Create new config file for the project')
|
|
47
47
|
.action(commands.init);
|
|
48
48
|
|
|
49
|
+
// Command: build
|
|
50
|
+
program
|
|
51
|
+
.command('build')
|
|
52
|
+
.description('Build the plugin/theme according to the config file')
|
|
53
|
+
.action(commands.build);
|
|
54
|
+
|
|
55
|
+
// Command: plugin
|
|
56
|
+
// program
|
|
57
|
+
// .command('plugin')
|
|
58
|
+
// .description('Create a new plugin')
|
|
59
|
+
// .action(commands.plugin);
|
|
60
|
+
|
|
49
61
|
// Command: release
|
|
50
62
|
program
|
|
51
63
|
.command('release')
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External Dependencies
|
|
3
|
+
*/
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import chalk from 'chalk'
|
|
6
|
+
import { waterfall } from 'async'
|
|
7
|
+
import logSymbols from 'log-symbols'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Node dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { pluginData } from './release.js';
|
|
13
|
+
import wpPot from './wp-pot.js';
|
|
14
|
+
import { heading, onSameLine, execCommand } from '../utilities/index.js'
|
|
15
|
+
|
|
16
|
+
export default async (nextProcess = null) => {
|
|
17
|
+
heading('Building the plugin...')
|
|
18
|
+
console.log('------------------------------------------------');
|
|
19
|
+
|
|
20
|
+
waterfall(
|
|
21
|
+
[
|
|
22
|
+
(next) => {
|
|
23
|
+
process.stdout.write('Clearing packages folder...')
|
|
24
|
+
try {
|
|
25
|
+
fs.rmSync( 'packages', { recursive: true, force: true } );
|
|
26
|
+
onSameLine(`${logSymbols.success} Cleared packages folder`)
|
|
27
|
+
} catch ( _ ) {}
|
|
28
|
+
next();
|
|
29
|
+
},
|
|
30
|
+
(next) => {
|
|
31
|
+
process.stdout.write('Installing PHP dependencies...')
|
|
32
|
+
|
|
33
|
+
execCommand(
|
|
34
|
+
'composer install -o -a -n --no-dev --no-scripts',
|
|
35
|
+
function(stdout, error, stderr) {
|
|
36
|
+
onSameLine(`${logSymbols.success} Installed PHP dependencies`);
|
|
37
|
+
process.stderr.write('Composer dumping....')
|
|
38
|
+
|
|
39
|
+
execCommand('composer dump', function(stdout, error, stderr) {
|
|
40
|
+
onSameLine(`${logSymbols.success} Composer updated`)
|
|
41
|
+
pluginData.commitMessages.push('update 3rd party dependecies')
|
|
42
|
+
next();
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
env: { ...process.env, COMPOSER_VENDOR_DIR: 'packages' },
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
},
|
|
51
|
+
(next) => {
|
|
52
|
+
process.stdout.write('Building plugin resources...')
|
|
53
|
+
execCommand( 'npx wp-scripts build', function() {
|
|
54
|
+
onSameLine(`${logSymbols.success} Built plugin resources`);
|
|
55
|
+
pluginData.commitMessages.push('Build plugin resources')
|
|
56
|
+
next();
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
(next) => {
|
|
60
|
+
console.log('')
|
|
61
|
+
wpPot(next);
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
( err, results ) => {
|
|
65
|
+
if (err) {
|
|
66
|
+
console.log('');
|
|
67
|
+
console.log( `${logSymbols.error} ${chalk.bold.red(`We failed somewhere! Work hard mate...`)}` )
|
|
68
|
+
if (typeof nextProcess === 'function') {
|
|
69
|
+
nextProcess(true);
|
|
70
|
+
}
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (typeof nextProcess === 'function') {
|
|
75
|
+
nextProcess();
|
|
76
|
+
} else {
|
|
77
|
+
console.log('');
|
|
78
|
+
console.log( `${logSymbols.success} ${chalk.bold.green(`All done!`)}` )
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
package/src/commands/class.js
CHANGED
|
@@ -50,7 +50,7 @@ export default (classname, options) => {
|
|
|
50
50
|
data.heading = header || filenameToHeading(filename) + ' template file';
|
|
51
51
|
data.description = description || 'Brief description of the styles in this file';
|
|
52
52
|
data.className = namespace.pop();
|
|
53
|
-
data.namespace = '\\' + namespace.join('\\');
|
|
53
|
+
data.namespace = namespace.length > 0 ? '\\' + namespace.join('\\') : '';
|
|
54
54
|
|
|
55
55
|
const content = compileTemplate(getTemplateFile(`files/${template}.php`), data);
|
|
56
56
|
writeFile(folder, `class-${filename}`, content);
|
package/src/commands/index.js
CHANGED
package/src/commands/release.js
CHANGED
|
@@ -17,9 +17,9 @@ import prompts from './release/prompts.js'
|
|
|
17
17
|
import getSemVer from './release/semver.js'
|
|
18
18
|
import { githubPreTasks, githubFinalTasks } from './release/github.js'
|
|
19
19
|
import updateTranslations from './release/translations.js'
|
|
20
|
-
import updateComposer from './release/composer.js'
|
|
21
20
|
import updateChangelog from './release/changelog.js'
|
|
22
21
|
import updateVersionNumber from './release/change-version.js'
|
|
22
|
+
import wpBuild from './build.js'
|
|
23
23
|
|
|
24
24
|
export const pluginData = {
|
|
25
25
|
commitMessages: [],
|
|
@@ -37,7 +37,7 @@ export default async () => {
|
|
|
37
37
|
getSemVer,
|
|
38
38
|
githubPreTasks,
|
|
39
39
|
updateTranslations,
|
|
40
|
-
|
|
40
|
+
wpBuild,
|
|
41
41
|
updateVersionNumber,
|
|
42
42
|
updateChangelog,
|
|
43
43
|
githubFinalTasks
|
package/src/commands/wp-pot.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { heading, msgSuccess, runCommand, getSetting } from "../utilities/index.js"
|
|
5
5
|
|
|
6
|
-
export default () => {
|
|
6
|
+
export default (next = null) => {
|
|
7
7
|
heading('Generating PO and MO files...')
|
|
8
8
|
|
|
9
9
|
const settings = getSetting()
|
|
@@ -39,5 +39,6 @@ export default () => {
|
|
|
39
39
|
|
|
40
40
|
runCommand( command.join(' '), [], () => {
|
|
41
41
|
msgSuccess('PO and MO files generated successfully');
|
|
42
|
+
if (next) next();
|
|
42
43
|
} );
|
|
43
44
|
}
|
package/src/utilities/shell.js
CHANGED
|
@@ -44,10 +44,10 @@ export function runCommand( command, args, callback ) {
|
|
|
44
44
|
*
|
|
45
45
|
* @returns {void}
|
|
46
46
|
*/
|
|
47
|
-
export function execCommand( command, callback ) {
|
|
47
|
+
export function execCommand( command, callback, options = {} ) {
|
|
48
48
|
if ('string' !== typeof command) {
|
|
49
49
|
command = command.join(' ')
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
exec( command, (error, stdout, stderr) => callback(stdout, error, stderr) )
|
|
52
|
+
exec( command, options, (error, stdout, stderr) => callback(stdout, error, stderr) )
|
|
53
53
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External Dependencies
|
|
3
|
-
*/
|
|
4
|
-
import logSymbols from 'log-symbols'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal Dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { pluginData } from '../release.js';
|
|
10
|
-
import { heading, execCommand, onSameLine } from "../../utilities/index.js"
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Execute routine
|
|
14
|
-
*/
|
|
15
|
-
export default function updateComposer(next) {
|
|
16
|
-
heading('Updating composer')
|
|
17
|
-
|
|
18
|
-
process.stderr.write('Dumping....')
|
|
19
|
-
|
|
20
|
-
execCommand('composer build', function(stdout, error, stderr) {
|
|
21
|
-
if(stderr.includes('not defined')) {
|
|
22
|
-
onSameLine(`${logSymbols.error} Command "build" is not defined.`)
|
|
23
|
-
} else {
|
|
24
|
-
pluginData.commitMessages.push('update 3rd party dependecies and composer dump-autoloader')
|
|
25
|
-
onSameLine(`${logSymbols.success} composer updated`)
|
|
26
|
-
}
|
|
27
|
-
next()
|
|
28
|
-
})
|
|
29
|
-
}
|