wp-advads 1.0.17 → 1.0.18
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 +4 -0
- package/src/commands/index.js +1 -0
- package/src/commands/patch/index.js +83 -0
- package/src/commands/setup/create-plugin.js +1 -2
- package/src/commands/setup/prompts.js +1 -1
- package/src/utilities/index.js +1 -0
- package/src/utilities/semver.js +33 -0
- package/template/configs/.phpcs.xml.dist +2 -1
package/package.json
CHANGED
package/src/app.js
CHANGED
package/src/commands/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as backup } from './backup/index.js'
|
|
2
2
|
export { default as makeFile } from './file/index.js'
|
|
3
3
|
export { default as help } from './help/index.js'
|
|
4
|
+
export { default as patch } from './patch/index.js'
|
|
4
5
|
export { default as release } from './release/index.js'
|
|
5
6
|
export { default as setupPlugin } from './setup/index.js'
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External Dependencies
|
|
3
|
+
*/
|
|
4
|
+
import fs from 'fs'
|
|
5
|
+
import logSymbols from 'log-symbols'
|
|
6
|
+
import { waterfall } from 'async'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal Dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { heading, getCacheStore, msgSuccessOnSameLine, msgErrorTitle, msgSuccessTitle, onSameLine, SemVer } from "../../utilities/index.js"
|
|
12
|
+
|
|
13
|
+
let pluginVersion = false
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get version from readme.txt file
|
|
17
|
+
*/
|
|
18
|
+
function getVersion(next) {
|
|
19
|
+
heading( 'Parsing readme.txt for version' )
|
|
20
|
+
|
|
21
|
+
fs.readFile('./readme.txt', (err, buffer) => {
|
|
22
|
+
if ( null !== err ) {
|
|
23
|
+
onSameLine(`${logSymbols.error} Failed to get Readme file`)
|
|
24
|
+
return next(true)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const content = buffer.toString()
|
|
28
|
+
let regex = new RegExp('^(?<prefix>Stable tag:\\h*)(?<version>(.*))$', 'mi')
|
|
29
|
+
regex = regex.exec(content)
|
|
30
|
+
if (null !== regex) {
|
|
31
|
+
regex = regex.groups
|
|
32
|
+
pluginVersion = regex.version.trim()
|
|
33
|
+
msgSuccessOnSameLine('Version found: ' + pluginVersion)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
next()
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function updateVersion(next, args) {
|
|
41
|
+
const cache = getCacheStore()
|
|
42
|
+
const answers = cache.getKey('answers')
|
|
43
|
+
const semver = new SemVer(pluginVersion)
|
|
44
|
+
const increment = {
|
|
45
|
+
major: false,
|
|
46
|
+
minor: false,
|
|
47
|
+
patch: false,
|
|
48
|
+
...args
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let strIncrement = 'patch'
|
|
52
|
+
if ( increment.major ) {
|
|
53
|
+
strIncrement = 'major'
|
|
54
|
+
} else if ( increment.minor ) {
|
|
55
|
+
strIncrement = 'minor'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
answers.wp.version = semver.inc(strIncrement)
|
|
59
|
+
cache.setKey( 'answers', answers )
|
|
60
|
+
cache.save()
|
|
61
|
+
next()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default function(args) {
|
|
65
|
+
heading('Incrementing Version...')
|
|
66
|
+
console.log('');
|
|
67
|
+
|
|
68
|
+
waterfall(
|
|
69
|
+
[
|
|
70
|
+
getVersion,
|
|
71
|
+
(next) => updateVersion(next, args)
|
|
72
|
+
],
|
|
73
|
+
( err, results ) => {
|
|
74
|
+
console.log('');
|
|
75
|
+
if (err) {
|
|
76
|
+
msgErrorTitle('We failed!!!')
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
msgSuccessTitle('All done!')
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
}
|
|
@@ -35,7 +35,7 @@ function setPluginData(next) {
|
|
|
35
35
|
// Root
|
|
36
36
|
pluginData.folder,
|
|
37
37
|
pluginData.folder + '/languages',
|
|
38
|
-
pluginData.folder + '/
|
|
38
|
+
pluginData.folder + '/views',
|
|
39
39
|
|
|
40
40
|
// Assets
|
|
41
41
|
pluginData.folder + '/assets/css',
|
|
@@ -43,7 +43,6 @@ function setPluginData(next) {
|
|
|
43
43
|
pluginData.folder + '/assets/js',
|
|
44
44
|
pluginData.folder + '/assets/src',
|
|
45
45
|
pluginData.folder + '/assets/img',
|
|
46
|
-
pluginData.folder + '/assets/acf',
|
|
47
46
|
|
|
48
47
|
// Includes
|
|
49
48
|
pluginData.folder + '/includes',
|
|
@@ -8,7 +8,7 @@ import kebabCase from 'lodash/kebabCase.js'
|
|
|
8
8
|
/**
|
|
9
9
|
* Node dependencies
|
|
10
10
|
*/
|
|
11
|
-
import { getCacheStore, getSettings
|
|
11
|
+
import { getCacheStore, getSettings } from '../../utilities/index.js'
|
|
12
12
|
|
|
13
13
|
export default ( next ) => {
|
|
14
14
|
const cache = getCacheStore()
|
package/src/utilities/index.js
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class SemVer {
|
|
2
|
+
constructor(version) {
|
|
3
|
+
this.rawVersion = version
|
|
4
|
+
|
|
5
|
+
this.parseVersion()
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
parseVersion() {
|
|
9
|
+
const regex = new RegExp('(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)(?:-(?<pre>alpha|beta|rc))?(?:\\.(?<pre_count>\\d+))?', 'gm')
|
|
10
|
+
this.baseVersion = { ...regex.exec(this.rawVersion).groups }
|
|
11
|
+
|
|
12
|
+
this.baseVersion.major = parseInt(this.baseVersion.major)
|
|
13
|
+
this.baseVersion.minor = parseInt(this.baseVersion.minor)
|
|
14
|
+
this.baseVersion.patch = parseInt(this.baseVersion.patch)
|
|
15
|
+
this.baseVersion.pre = undefined === this.baseVersion.pre ? false : this.baseVersion.pre
|
|
16
|
+
this.baseVersion.pre_count = undefined === this.baseVersion.pre_count ? false : this.baseVersion.pre_count
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getCurrentVersion() {
|
|
20
|
+
return this.rawVersion
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
inc(type) {
|
|
24
|
+
const nextVersion = { ...this.baseVersion }
|
|
25
|
+
nextVersion[type] += 1
|
|
26
|
+
|
|
27
|
+
return this.format(nextVersion);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
format(version) {
|
|
31
|
+
return `${version.major}.${version.minor}.${version.patch}`
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
<!-- PHPCompatibility configs: -->
|
|
24
24
|
<config name="testVersion" value="7.2-" />
|
|
25
25
|
<config name="minimum_supported_wp_version" value="4.9" />
|
|
26
|
+
<config name="minimum_wp_version" value="4.9" />
|
|
26
27
|
|
|
27
28
|
<rule ref="PHPCompatibility">
|
|
28
29
|
<include-pattern>*\.php$</include-pattern>
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
|
|
56
57
|
<!-- Disable disallow short arrays and enforce them: -->
|
|
57
58
|
<rule ref="WordPress-Extra">
|
|
58
|
-
<exclude name="
|
|
59
|
+
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
|
|
59
60
|
</rule>
|
|
60
61
|
|
|
61
62
|
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|