wp-advads 1.0.16 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "wp-advads",
4
- "version": "1.0.16",
4
+ "version": "1.0.18",
5
5
  "description": "Create a Advanced Ads wordPress plugin eco system.",
6
6
  "author": {
7
7
  "name": "Shakeeb Ahmed",
package/src/app.js CHANGED
@@ -49,6 +49,10 @@ async function app() {
49
49
  if ( 'make:release' === command ) {
50
50
  commands.release(args)
51
51
  }
52
+
53
+ if ( 'patch' === command ) {
54
+ commands.patch(args)
55
+ }
52
56
  }
53
57
 
54
58
  app()
@@ -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 + '/templates',
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',
@@ -93,21 +92,33 @@ function prepareConfigFiles(next) {
93
92
  '/.editorconfig',
94
93
  '/.eslintignore',
95
94
  '/.eslintrc.js',
96
- '/.gitattributes',
97
- '/.gitignore',
95
+ '/gitattributes',
96
+ '/gitignore',
98
97
  '/.phpcs.xml.dist',
99
98
  '/.prettierignore',
100
99
  '/.prettierrc.js',
101
100
  '/.stylelintrc',
102
101
  '/composer.json',
103
102
  '/package.json',
103
+ '/postcss.config.js',
104
+ '/tailwind.config.js',
104
105
  '/webpack.mix.js',
106
+ '/webpack.mix.local.js',
105
107
  ]
106
108
 
107
109
  write('Preparing configuration files...')
108
110
 
109
111
  eachSeries( files, ( file, nextConfig ) => {
110
- prepareFile( template + file, pluginData.folder + file, nextConfig )
112
+ let dest = file
113
+ if ( '/gitattributes' === file ) {
114
+ dest = '/.gitattributes'
115
+ }
116
+
117
+ if ( '/gitignore' === file ) {
118
+ dest = '/.gitignore'
119
+ }
120
+
121
+ prepareFile( template + file, pluginData.folder + dest, nextConfig )
111
122
  }, () => {
112
123
  msgSuccessOnSameLine(`${files.length} Configuration files prepared`)
113
124
  next()
@@ -8,7 +8,7 @@ import kebabCase from 'lodash/kebabCase.js'
8
8
  /**
9
9
  * Node dependencies
10
10
  */
11
- import { getCacheStore, getSettings, heading } from '../../utilities/index.js'
11
+ import { getCacheStore, getSettings } from '../../utilities/index.js'
12
12
 
13
13
  export default ( next ) => {
14
14
  const cache = getCacheStore()
@@ -29,7 +29,7 @@ export default ( next ) => {
29
29
  type: 'input',
30
30
  name: 'wp.version',
31
31
  message: 'Enter plugin version',
32
- default: getAnswer( 'version', '1.0.0' ),
32
+ default: getAnswer( 'wp.version', '1.0.0' ),
33
33
  filter: ( val ) => val.toLowerCase()
34
34
  },
35
35
  {
@@ -4,3 +4,4 @@ export * from './file.js'
4
4
  export * from './folder.js'
5
5
  export * from './formatting.js'
6
6
  export * from './shell.js'
7
+ export * from './semver.js'
@@ -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="Generic.Arrays.DisallowShortArraySyntax"/>
59
+ <exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
59
60
  </rule>
60
61
 
61
62
  <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
@@ -0,0 +1,43 @@
1
+ # Wordpress - ignore core, configuration, examples, uploads and logs.
2
+ # https://github.com/github/gitignore/blob/main/WordPress.gitignore
3
+
4
+ # Operating System files
5
+ .DS_Store
6
+ Thumbs.db
7
+
8
+ # IDE files
9
+ .vscode/*
10
+ project.xml
11
+ project.properties
12
+ .project
13
+ .settings*
14
+ *.sublime-project
15
+ *.sublime-workspace
16
+ .sublimelinterrc
17
+
18
+ # Caches
19
+ .eslintcache
20
+ .stylelintcache
21
+
22
+ # Environment files
23
+ wp-cli.local.yml
24
+ .wp-env.override.json
25
+ npm-debug.log
26
+ .pnpm-debug.log
27
+
28
+ # Node Package Dependencies
29
+ node_modules/
30
+
31
+ # Composer
32
+ packages/**/tests/
33
+ vendor/
34
+ bin/composer/**/vendor/
35
+
36
+ # Support .gitkeep Files
37
+ !.gitkeep
38
+ webpack.mix.local.js
39
+ mix-manifest.json
40
+
41
+ # WP Browser Files
42
+ tests/_output
43
+ tests/.env
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ wpUrl: '{{wp.proxy}}',
3
+ };