wp-advads 1.0.7 → 1.0.9
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 +16 -27
- package/src/commands/backup/index.js +11 -7
- package/src/commands/file/create-file.js +96 -0
- package/src/commands/file/index.js +29 -0
- package/src/commands/help/index.js +11 -4
- package/src/commands/index.js +5 -0
- package/src/commands/release/change-version.js +124 -0
- package/src/commands/release/changelog.js +259 -0
- package/src/commands/release/composer.js +37 -0
- package/src/commands/release/git.js +119 -0
- package/src/commands/release/github.js +62 -0
- package/src/commands/release/index.js +41 -45
- package/src/commands/release/prompts.js +59 -0
- package/src/commands/release/semver.js +198 -0
- package/src/commands/release/translations.js +66 -0
- package/src/commands/setup/create-plugin.js +213 -170
- package/src/commands/setup/index.js +2 -2
- package/src/commands/setup/prompts.js +15 -17
- package/src/utilities/cache.js +23 -0
- package/src/utilities/command.js +29 -0
- package/src/utilities/file.js +57 -0
- package/src/utilities/folder.js +64 -0
- package/src/utilities/formatting.js +97 -0
- package/src/utilities/index.js +6 -0
- package/src/utilities/shell.js +36 -0
- package/template/configs/.eslintignore +4 -1
- package/template/configs/.gitattributes +33 -0
- package/template/configs/{.phpcs.xml → .phpcs.xml.dist} +1 -0
- package/template/configs/.prettierignore +2 -0
- package/template/configs/.stylelintrc +19 -5
- package/template/configs/package.json +2 -2
- package/template/configs/webpack.mix.js +4 -3
- package/template/make/file-singleton.php +43 -0
- package/template/make/file.php +26 -0
- package/template/tools/laravel-mix/wp-pot.js +40 -28
- package/template/tools/wp-glotpress.js +125 -103
- package/src/helpers.js +0 -135
- package/template/.husky/pre-commit +0 -4
- package/template/configs/gitattributes +0 -25
- package/template/configs/gitignore +0 -38
- package/template/configs/webpack.mix.local.js +0 -3
- /package/template/{assets → plugin/assets/scss}/app.scss +0 -0
- /package/template/{assets → plugin/assets/src}/app.js +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node dependencies
|
|
3
|
+
*/
|
|
4
|
+
import fs from 'fs'
|
|
5
|
+
import { join } from 'path'
|
|
6
|
+
import { createRequire } from 'node:module'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal Dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { CACHE_FILE } from './cache.js'
|
|
12
|
+
import { getArguments } from './command.js'
|
|
13
|
+
|
|
14
|
+
export function folderEmptiness(folder) {
|
|
15
|
+
const folderFiles = fs.readdirSync(folder)
|
|
16
|
+
if (1 === folderFiles.length || 0 === folderFiles.length) {
|
|
17
|
+
return true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getCurrentFolder() {
|
|
24
|
+
let folder = process.cwd()
|
|
25
|
+
const args = getArguments()
|
|
26
|
+
|
|
27
|
+
if ( undefined !== args.folder ) {
|
|
28
|
+
folder = resolve( './' + args.folder )
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return folder
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getRootFolder() {
|
|
35
|
+
let counter = 0
|
|
36
|
+
const check = function( folder ) {
|
|
37
|
+
const isEmptyFolder = folderEmptiness(folder)
|
|
38
|
+
|
|
39
|
+
if (isEmptyFolder) {
|
|
40
|
+
return folder
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const existsConfig = fs.existsSync( folder + '/' + CACHE_FILE )
|
|
44
|
+
const existsPkg = fs.existsSync( folder + '/package.json' )
|
|
45
|
+
if (existsConfig || existsPkg) {
|
|
46
|
+
return folder
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ( 5 === counter ) {
|
|
50
|
+
return process.cwd()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
counter++
|
|
54
|
+
return check(join(folder, '../'))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return check(process.cwd())
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getTemplateFolder() {
|
|
61
|
+
const require = createRequire( import.meta.url )
|
|
62
|
+
return require.resolve( '../../template' )
|
|
63
|
+
.replace( '/index.js', '' )
|
|
64
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
import logSymbols from 'log-symbols'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Print heading.
|
|
9
|
+
*
|
|
10
|
+
* @param {String} title Title to print
|
|
11
|
+
*
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
export function heading(title) {
|
|
15
|
+
console.log('')
|
|
16
|
+
console.log( chalk.bold.green( 'Ⓞ ' + title ) )
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Print text on new line.
|
|
21
|
+
*
|
|
22
|
+
* @param {String} text Text to print
|
|
23
|
+
*
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
26
|
+
export function onNewLine(text) {
|
|
27
|
+
console.log('')
|
|
28
|
+
console.log(text)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Print text on same line by clearing buffer.
|
|
33
|
+
*
|
|
34
|
+
* @param {String} text Text to print
|
|
35
|
+
*
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
export function onSameLine(text) {
|
|
39
|
+
process.stdout.clearLine()
|
|
40
|
+
process.stdout.cursorTo(0)
|
|
41
|
+
console.log(text)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Print text on same line by clearing buffer.
|
|
46
|
+
*
|
|
47
|
+
* @param {String} text Text to print
|
|
48
|
+
*
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
export function msgSuccessOnSameLine(text) {
|
|
52
|
+
onSameLine(`${logSymbols.success} ${text}`)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Print text on same line by clearing buffer.
|
|
57
|
+
*
|
|
58
|
+
* @param {String} text Text to print
|
|
59
|
+
*
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
62
|
+
export function msgErrorOnSameLine(text) {
|
|
63
|
+
onSameLine(`${logSymbols.error} ${text}`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Print success text in bold green font
|
|
68
|
+
*
|
|
69
|
+
* @param {String} msg Text to print
|
|
70
|
+
*
|
|
71
|
+
* @returns {void}
|
|
72
|
+
*/
|
|
73
|
+
export function msgSuccessTitle(msg) {
|
|
74
|
+
console.log( `${logSymbols.success} ${chalk.bold.green(`${msg}`)}` )
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Print error text in bold green font
|
|
79
|
+
*
|
|
80
|
+
* @param {String} msg Text to print
|
|
81
|
+
*
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
84
|
+
export function msgErrorTitle(msg) {
|
|
85
|
+
console.log( `${logSymbols.error} ${chalk.bold.magenta(`${msg}`)}` )
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Write text on current buffer
|
|
90
|
+
*
|
|
91
|
+
* @param {String} text Text to write
|
|
92
|
+
*
|
|
93
|
+
* @returns {void}
|
|
94
|
+
*/
|
|
95
|
+
export function write(text) {
|
|
96
|
+
process.stdout.write(text)
|
|
97
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { exec, spawn } from 'node:child_process'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal Dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { onSameLine } from './formatting.js'
|
|
10
|
+
|
|
11
|
+
export function runCommand( command, args, callback ) {
|
|
12
|
+
const commandSpawn = spawn( command, args, {
|
|
13
|
+
shell: true,
|
|
14
|
+
stdio: [ 'inherit' ]
|
|
15
|
+
} )
|
|
16
|
+
|
|
17
|
+
commandSpawn.stdout.on( 'data', (data) => {
|
|
18
|
+
onSameLine(data.toString())
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
commandSpawn.stderr.on( 'data', (data) => {
|
|
22
|
+
onSameLine(data.toString().replace('\n','').replace('\r','').trim())
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
commandSpawn.on( 'close', (code) => {
|
|
26
|
+
callback()
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function execCommand( command, callback ) {
|
|
31
|
+
if ('string' !== typeof command) {
|
|
32
|
+
command = command.join(' ')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exec( command, (error, stdout, stderr) => callback(stdout, error, stderr) )
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Set the default behavior, in case people don't have `core.autocrlf` set.
|
|
2
|
+
* text=auto
|
|
3
|
+
|
|
4
|
+
# Declare files that will always have LF line endings on checkout.
|
|
5
|
+
*.php text eol=lf
|
|
6
|
+
|
|
7
|
+
# Denote all files that are truly binary and should not be modified.
|
|
8
|
+
*.aar binary
|
|
9
|
+
*.gif binary
|
|
10
|
+
*.jar binary
|
|
11
|
+
*.jpg binary
|
|
12
|
+
*.png binary
|
|
13
|
+
*.ttf binary
|
|
14
|
+
*.webp binary
|
|
15
|
+
|
|
16
|
+
# Remove files for archives generated using `git archive`.
|
|
17
|
+
/.* export-ignore
|
|
18
|
+
changelog.txt export-ignore
|
|
19
|
+
composer.* export-ignore
|
|
20
|
+
package*.json export-ignore
|
|
21
|
+
phpcs.* export-ignore
|
|
22
|
+
phpunit.* export-ignore
|
|
23
|
+
README.md export-ignore
|
|
24
|
+
|
|
25
|
+
# Remove folders for archives generated using `git archive`.
|
|
26
|
+
assets/admin/scss export-ignore
|
|
27
|
+
assets/admin/src export-ignore
|
|
28
|
+
assets/frontend/scss export-ignore
|
|
29
|
+
assets/frontend/src export-ignore
|
|
30
|
+
bin/ export-ignore
|
|
31
|
+
.changelog/ export-ignore
|
|
32
|
+
tests/ export-ignore
|
|
33
|
+
adv-ads-scaffolding export-ignore
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<exclude-pattern>*/languages/*</exclude-pattern>
|
|
16
16
|
<exclude-pattern>*/lib/*</exclude-pattern>
|
|
17
17
|
<exclude-pattern>*/node_modules/*</exclude-pattern>
|
|
18
|
+
<exclude-pattern>*/packages/*</exclude-pattern>
|
|
18
19
|
<exclude-pattern>*/tests/*</exclude-pattern>
|
|
19
20
|
<exclude-pattern>*/vendor/*</exclude-pattern>
|
|
20
21
|
<exclude-pattern>*/index.php</exclude-pattern>
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "@wordpress/stylelint-config",
|
|
3
3
|
"ignoreFiles": [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
]
|
|
4
|
+
"**/*.js",
|
|
5
|
+
"assets/css/*.min.css",
|
|
6
|
+
"node_modules/**/*.css",
|
|
7
|
+
"vendor/**/*.css"
|
|
8
|
+
],
|
|
9
|
+
"rules": {
|
|
10
|
+
"at-rule-no-unknown": [
|
|
11
|
+
true,
|
|
12
|
+
{
|
|
13
|
+
"ignoreAtRules": [
|
|
14
|
+
"tailwind",
|
|
15
|
+
"apply",
|
|
16
|
+
"variants",
|
|
17
|
+
"responsive",
|
|
18
|
+
"screen"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
9
23
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/advanced-ads/{{package.name}}.git"
|
|
10
10
|
},
|
|
11
|
-
"author": "
|
|
11
|
+
"author": "{{author.name}}",
|
|
12
12
|
"license": "GPL-3.0-or-later",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/advanced-ads/{{package.name}}/issues"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"watch": "mix watch",
|
|
20
20
|
"watch-poll": "mix watch -- --watch-options-poll=1000",
|
|
21
21
|
"hot": "mix watch --hot",
|
|
22
|
-
"
|
|
22
|
+
"build": "mix --production",
|
|
23
23
|
"lint": "lint-staged",
|
|
24
24
|
"lint:css": "stylelint \"**/*.css\" --cache",
|
|
25
25
|
"lint:js": "eslint . --cache",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
const mix = require('laravel-mix');
|
|
5
5
|
const { join } = require('path');
|
|
6
|
+
const packageData = require('./package.json');
|
|
6
7
|
require('./tools/laravel-mix/wp-pot');
|
|
7
8
|
|
|
8
9
|
// Local config.
|
|
@@ -57,8 +58,8 @@ mix.js('assets/src/app.js', 'assets/js/app.js');
|
|
|
57
58
|
* WordPress translation
|
|
58
59
|
*/
|
|
59
60
|
mix.wpPot({
|
|
60
|
-
output:
|
|
61
|
-
file:
|
|
61
|
+
output: packageData.wpPot.output,
|
|
62
|
+
file: packageData.wpPot.file,
|
|
62
63
|
skipJS: true,
|
|
63
|
-
domain:
|
|
64
|
+
domain: packageData.wpPot.domain,
|
|
64
65
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* {{heading}}.
|
|
4
|
+
*
|
|
5
|
+
* @package {{php.package}}
|
|
6
|
+
* @author {{author.name}} <{{author.email}}>
|
|
7
|
+
* @since {{wp.version}}
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
namespace {{php.package}}{{namespace}};
|
|
11
|
+
|
|
12
|
+
use AdvancedAds\Framework\Interfaces\WordPress_Integration;
|
|
13
|
+
|
|
14
|
+
defined( 'ABSPATH' ) || exit;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* {{heading}}.
|
|
18
|
+
*/
|
|
19
|
+
class {{className}} implements WordPress_Integration {
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Main instance
|
|
23
|
+
*
|
|
24
|
+
* Ensure only one instance is loaded or can be loaded.
|
|
25
|
+
*
|
|
26
|
+
* @return {{className}}
|
|
27
|
+
*/
|
|
28
|
+
public static function get() {
|
|
29
|
+
static $instance;
|
|
30
|
+
|
|
31
|
+
if ( null === $instance ) {
|
|
32
|
+
$instance = new {{className}}();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return $instance;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Hook into WordPress.
|
|
40
|
+
*/
|
|
41
|
+
public function hooks() {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* {{heading}}.
|
|
4
|
+
*
|
|
5
|
+
* @package {{php.package}}
|
|
6
|
+
* @author {{author.name}} <{{author.email}}>
|
|
7
|
+
* @since {{wp.version}}
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
namespace {{php.package}}{{namespace}};
|
|
11
|
+
|
|
12
|
+
use AdvancedAds\Framework\Interfaces\WordPress_Integration;
|
|
13
|
+
|
|
14
|
+
defined( 'ABSPATH' ) || exit;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* {{heading}}.
|
|
18
|
+
*/
|
|
19
|
+
class {{className}} implements WordPress_Integration {
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hook into WordPress.
|
|
23
|
+
*/
|
|
24
|
+
public function hooks() {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,37 +1,49 @@
|
|
|
1
|
-
const mix = require('laravel-mix')
|
|
1
|
+
const mix = require('laravel-mix');
|
|
2
2
|
|
|
3
3
|
class WordPressPot {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
dependencies() {
|
|
9
|
-
this.requiresReload = `
|
|
10
|
-
Dependencies have been installed. Please run again.
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
return ['shelljs']
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
register(config) {
|
|
17
|
-
this.config = config
|
|
18
|
-
}
|
|
4
|
+
name() {
|
|
5
|
+
return 'wpPot';
|
|
6
|
+
}
|
|
19
7
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const {output, file, domain, skipJS = false, exclude = [] } = this.config
|
|
8
|
+
dependencies() {
|
|
9
|
+
this.requiresReload = `Dependencies have been installed. Please run again.`;
|
|
23
10
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
exclude.push("tools");
|
|
11
|
+
return ['shelljs'];
|
|
12
|
+
}
|
|
27
13
|
|
|
28
|
-
|
|
14
|
+
register(config) {
|
|
15
|
+
this.config = config;
|
|
16
|
+
}
|
|
29
17
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
boot() {
|
|
19
|
+
const sh = require('shelljs');
|
|
20
|
+
const {
|
|
21
|
+
output,
|
|
22
|
+
file,
|
|
23
|
+
domain,
|
|
24
|
+
skipJS = false,
|
|
25
|
+
exclude = [],
|
|
26
|
+
} = this.config;
|
|
27
|
+
|
|
28
|
+
exclude.push(".github");
|
|
29
|
+
exclude.push(".husky");
|
|
30
|
+
exclude.push(".wordpress-org");
|
|
31
|
+
exclude.push("node_modules");
|
|
32
|
+
exclude.push("packages");
|
|
33
|
+
exclude.push("tools");
|
|
34
|
+
exclude.push("vendor");
|
|
35
|
+
|
|
36
|
+
const rootPath = process.cwd();
|
|
37
|
+
|
|
38
|
+
sh.exec(
|
|
39
|
+
`wp i18n make-pot ${rootPath} ${rootPath}${output}${file} --domain=${domain} --exclude=${exclude.join(
|
|
40
|
+
','
|
|
41
|
+
)}`
|
|
42
|
+
);
|
|
43
|
+
if (false !== skipJS) {
|
|
44
|
+
sh.exec(`wp i18n make-json ${rootPath}${output}`, { silent: true });
|
|
45
|
+
}
|
|
33
46
|
}
|
|
34
|
-
}
|
|
35
47
|
}
|
|
36
48
|
|
|
37
|
-
mix.extend('wpPot', new WordPressPot())
|
|
49
|
+
mix.extend('wpPot', new WordPressPot());
|