wp-advads 1.0.22 → 1.0.23
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 +9 -11
- package/src/app.js +80 -27
- package/src/commands/class.js +63 -0
- package/src/commands/css.js +36 -0
- package/src/commands/index.js +8 -6
- package/src/commands/init.js +166 -0
- package/src/commands/javascript.js +36 -0
- package/src/commands/release/change-version.js +61 -45
- package/src/commands/release/changelog.js +2 -2
- package/src/commands/release/composer.js +8 -16
- package/src/commands/release/git.js +5 -25
- package/src/commands/release/github.js +2 -4
- package/src/commands/release/prompts.js +1 -1
- package/src/commands/release/semver.js +2 -2
- package/src/commands/release/translations.js +10 -32
- package/src/commands/release.js +55 -0
- package/src/commands/updates.js +31 -0
- package/src/commands/views.js +31 -0
- package/src/utilities/filesystem.js +148 -0
- package/src/utilities/formatting.js +6 -2
- package/src/utilities/index.js +4 -5
- package/src/utilities/misc.js +12 -0
- package/src/utilities/semver.js +6 -1
- package/src/utilities/settings.js +94 -0
- package/src/utilities/shell.js +17 -0
- package/template/files/class-empty.php +26 -0
- package/template/{make/file-initializer.php → files/class-initializer.php} +5 -4
- package/template/{make/file-integration.php → files/class-integration.php} +5 -4
- package/template/{make/file-routes.php → files/class-rest.php} +5 -4
- package/template/{make/file-singleton.php → files/class-singleton.php} +5 -4
- package/template/files/javascript.js +13 -0
- package/template/files/stylesheet.css +8 -0
- package/template/files/update.php +21 -0
- package/template/{make/file.php → files/view.php} +3 -10
- package/src/commands/backup/index.js +0 -50
- package/src/commands/file/create-file.js +0 -127
- package/src/commands/file/index.js +0 -29
- package/src/commands/help/index.js +0 -16
- package/src/commands/patch/index.js +0 -84
- package/src/commands/release/index.js +0 -68
- package/src/commands/release/webpack.js +0 -30
- package/src/commands/setup/index.js +0 -28
- package/src/commands/setup/prompts.js +0 -111
- package/src/utilities/cache.js +0 -23
- package/src/utilities/command.js +0 -29
- package/src/utilities/file.js +0 -57
- package/src/utilities/folder.js +0 -64
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "wp-advads",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.23",
|
|
5
5
|
"description": "Create a Advanced Ads wordPress plugin eco system.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Shakeeb Ahmed",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/advanced-ads/
|
|
20
|
+
"url": "git+https://github.com/advanced-ads/wp-advads.git"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"wordpress",
|
|
@@ -29,15 +29,13 @@
|
|
|
29
29
|
"url": "https://github.com/advanced-ads/npm-scaffolding/issues"
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/advanced-ads/npm-scaffolding#readme",
|
|
32
|
-
"
|
|
33
|
-
"async": "^3.2.
|
|
34
|
-
"chalk": "^5.
|
|
35
|
-
"
|
|
36
|
-
"fs-extra": "^
|
|
37
|
-
"
|
|
38
|
-
"handlebars": "^4.7.7",
|
|
39
|
-
"inquirer": "^9.1.1",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"async": "^3.2.6",
|
|
34
|
+
"chalk": "^5.4.1",
|
|
35
|
+
"commander": "^13.1.0",
|
|
36
|
+
"fs-extra": "^11.3.0",
|
|
37
|
+
"inquirer": "^12.5.2",
|
|
40
38
|
"lodash": "^4.17.21",
|
|
41
|
-
"
|
|
39
|
+
"log-symbols": "^7.0.0"
|
|
42
40
|
}
|
|
43
41
|
}
|
package/src/app.js
CHANGED
|
@@ -4,55 +4,108 @@
|
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
6
|
import chalk from 'chalk'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal Dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { getCommand } from './utilities/index.js'
|
|
12
|
-
import packageDetails from '../package.json' assert { type: "json" }
|
|
7
|
+
import { program } from 'commander'
|
|
13
8
|
|
|
14
9
|
/**
|
|
15
10
|
* Commands
|
|
16
11
|
*/
|
|
17
12
|
import * as commands from './commands/index.js'
|
|
13
|
+
import { configFileExists, onNewLine } from './utilities/index.js'
|
|
18
14
|
|
|
19
15
|
/**
|
|
20
16
|
* App
|
|
21
17
|
*/
|
|
22
|
-
async
|
|
18
|
+
const app = async () => {
|
|
23
19
|
console.log(
|
|
24
20
|
[
|
|
25
21
|
chalk.hex('#FADC00').inverse.bold('Advanced Ads WordPress Plugin Toolkit'),
|
|
26
|
-
chalk.white( '
|
|
22
|
+
chalk.white( 'v2.0.0' ),
|
|
27
23
|
chalk.dim( 'by Shakeeb Ahmed' )
|
|
28
24
|
].join(" ")
|
|
29
25
|
);
|
|
30
26
|
|
|
27
|
+
program.configureHelp({
|
|
28
|
+
sortSubcommands: true,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
program
|
|
32
|
+
.name('wp-advads')
|
|
33
|
+
.description('CLI to Advanced Ads scaffolding utilities')
|
|
34
|
+
.version('2.0.0')
|
|
35
|
+
.hook('preAction', (thisCommand, actionCommand) => {
|
|
36
|
+
if ( 'init' !== actionCommand.name() && ! configFileExists() ) {
|
|
37
|
+
onNewLine(chalk.bgRed.white('Config file not found. Run `wp-advads init` to create a new config file.'));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
.showHelpAfterError();
|
|
42
|
+
|
|
43
|
+
// Command: init
|
|
44
|
+
program
|
|
45
|
+
.command('init')
|
|
46
|
+
.description('Create new config file for the project')
|
|
47
|
+
.action(commands.init);
|
|
48
|
+
|
|
49
|
+
// Command: plugin
|
|
50
|
+
// program
|
|
51
|
+
// .command('plugin')
|
|
52
|
+
// .description('Create a new plugin')
|
|
53
|
+
// .action(commands.plugin);
|
|
54
|
+
|
|
55
|
+
// Command: release
|
|
56
|
+
program
|
|
57
|
+
.command('release')
|
|
58
|
+
.description('Create a new release for the plugin')
|
|
59
|
+
.action(commands.release);
|
|
31
60
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
61
|
+
// Command: class
|
|
62
|
+
program
|
|
63
|
+
.command('class')
|
|
64
|
+
.description('Create a new class file')
|
|
65
|
+
.argument('<classname>', 'Classname')
|
|
66
|
+
.option('-h <heading>', 'Heading of the file')
|
|
67
|
+
.option('-d <description>', 'Description of the file')
|
|
68
|
+
.option('-i', 'Initializer interface template')
|
|
69
|
+
.option('-g', 'Integration interface template')
|
|
70
|
+
.option('-r', 'Rest interface template')
|
|
71
|
+
.option('-s', 'Singleton template')
|
|
72
|
+
.action(commands.classFile);
|
|
36
73
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
74
|
+
// Command: view
|
|
75
|
+
program
|
|
76
|
+
.command('view')
|
|
77
|
+
.description('Create a new view')
|
|
78
|
+
.argument('<viewname>', 'name of the view')
|
|
79
|
+
.argument('[heading]', 'Heading of the file')
|
|
80
|
+
.action(commands.views);
|
|
40
81
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
82
|
+
// Command: updates
|
|
83
|
+
program
|
|
84
|
+
.command('updates')
|
|
85
|
+
.description('Updates for the plugin')
|
|
86
|
+
.argument('<version>', 'version number')
|
|
87
|
+
.action(commands.updates);
|
|
44
88
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
89
|
+
// Command: js
|
|
90
|
+
program
|
|
91
|
+
.command('js')
|
|
92
|
+
.description('Create a new JavaScript file')
|
|
93
|
+
.argument('<filename>', 'name of the file')
|
|
94
|
+
.option('-h <heading>', 'Heading of the file')
|
|
95
|
+
.option('-d <description>', 'Description of the file')
|
|
96
|
+
.action(commands.javascript);
|
|
48
97
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
98
|
+
// Command: css
|
|
99
|
+
program
|
|
100
|
+
.command('css')
|
|
101
|
+
.description('Create a new CSS file')
|
|
102
|
+
.argument('<filename>', 'name of the file')
|
|
103
|
+
.option('-h <heading>', 'Heading of the file')
|
|
104
|
+
.option('-d <description>', 'Description of the file')
|
|
105
|
+
.action(commands.css);
|
|
52
106
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
107
|
+
// Lets begin
|
|
108
|
+
program.parse(process.argv)
|
|
56
109
|
}
|
|
57
110
|
|
|
58
111
|
app()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External Dependencies
|
|
3
|
+
*/
|
|
4
|
+
import capitalize from 'lodash/capitalize.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Node Dependencies
|
|
8
|
+
*/
|
|
9
|
+
import path from 'path';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal Dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { getSetting, writeFile, filenameToHeading, heading, getProjectRoot, msgErrorTitle, getTemplateFile, compileTemplate, runCommand } from "../utilities/index.js";
|
|
15
|
+
|
|
16
|
+
function templateName(options) {
|
|
17
|
+
const length = Object.keys(options).length
|
|
18
|
+
|
|
19
|
+
if ( 0 === length ) {
|
|
20
|
+
return 'class-empty';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const hash = {
|
|
24
|
+
'i': 'class-initializer',
|
|
25
|
+
'g': 'class-integration',
|
|
26
|
+
'r': 'class-rest',
|
|
27
|
+
's': 'class-singleton',
|
|
28
|
+
}
|
|
29
|
+
const has = Object.keys(options)[0]
|
|
30
|
+
|
|
31
|
+
return hash[has] ?? 'class-empty';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default (classname, options) => {
|
|
35
|
+
heading('Creating class file...')
|
|
36
|
+
const {
|
|
37
|
+
h: header = null,
|
|
38
|
+
d: description = null,
|
|
39
|
+
} = options
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const template = templateName(options);
|
|
43
|
+
const namespace = classname.split('\\');
|
|
44
|
+
const paths = classname.toLowerCase().split('\\');
|
|
45
|
+
const filename = paths.pop() + '.php';
|
|
46
|
+
const folder = path.join(getProjectRoot(), getSetting('paths.php'), paths.join('/'));
|
|
47
|
+
|
|
48
|
+
// Data
|
|
49
|
+
const data = getSetting();
|
|
50
|
+
data.heading = header || filenameToHeading(filename) + ' template file';
|
|
51
|
+
data.description = description || 'Brief description of the styles in this file';
|
|
52
|
+
data.className = namespace.pop();
|
|
53
|
+
data.namespace = '\\' + namespace.join('\\');
|
|
54
|
+
|
|
55
|
+
const content = compileTemplate(getTemplateFile(`files/${template}.php`), data);
|
|
56
|
+
writeFile(folder, `class-${filename}`, content);
|
|
57
|
+
runCommand( 'composer', [ 'dump' ], () => {} );
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
msgErrorTitle('We failed!!!');
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Node Dependencies
|
|
4
|
+
*/
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal Dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getSetting, writeFile, heading, filenameToHeading, getProjectRoot, msgErrorTitle, getTemplateFile, compileTemplate } from "../utilities/index.js";
|
|
11
|
+
|
|
12
|
+
export default (name, options) => {
|
|
13
|
+
heading('Creating CSS file...')
|
|
14
|
+
const {
|
|
15
|
+
h: header = null,
|
|
16
|
+
d: description = null,
|
|
17
|
+
} = options
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const paths = name.toLowerCase().split('\\')
|
|
21
|
+
const filename = paths.pop() + '.css';
|
|
22
|
+
const folder = path.join(getProjectRoot(), getSetting('paths.css'), paths.join('/'));
|
|
23
|
+
|
|
24
|
+
// Data
|
|
25
|
+
const data = getSetting();
|
|
26
|
+
data.heading = header || filenameToHeading(name) + ' styles.';
|
|
27
|
+
data.description = description || 'Brief description of the styles in this file';
|
|
28
|
+
|
|
29
|
+
const content = compileTemplate(getTemplateFile('files/stylesheet.css'), data);
|
|
30
|
+
writeFile(folder, filename, content);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
msgErrorTitle('We failed!!!');
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/commands/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as
|
|
1
|
+
export { default as css } from './css.js'
|
|
2
|
+
export { default as classFile } from './class.js'
|
|
3
|
+
export { default as init } from './init.js'
|
|
4
|
+
export { default as javascript } from './javascript.js'
|
|
5
|
+
// export { default as plugin } from './plugin.js'
|
|
6
|
+
export { default as release } from './release.js'
|
|
7
|
+
export { default as updates } from './updates.js'
|
|
8
|
+
export { default as views } from './views.js'
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import inquirer from 'inquirer'
|
|
5
|
+
import kebabCase from 'lodash/kebabCase.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Node dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getSetting, heading, saveConfig, msgSuccessTitle } from '../utilities/index.js'
|
|
11
|
+
|
|
12
|
+
export default async () => {
|
|
13
|
+
const questions = [
|
|
14
|
+
// Product
|
|
15
|
+
{
|
|
16
|
+
type: 'input',
|
|
17
|
+
name: 'wp.name',
|
|
18
|
+
message: 'The name of your plugin/theme',
|
|
19
|
+
default: getSetting( 'wp.name', 'Advanced Ads' ),
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'input',
|
|
23
|
+
name: 'wp.description',
|
|
24
|
+
message: 'A short description of the plugin/theme',
|
|
25
|
+
default: getSetting( 'wp.description' ),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'input',
|
|
29
|
+
name: 'wp.version',
|
|
30
|
+
message: 'The current version number of the plugin/theme',
|
|
31
|
+
default: getSetting( 'wp.version', '1.0.0' ),
|
|
32
|
+
filter: ( val ) => val.toLowerCase()
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// WordPress
|
|
36
|
+
{
|
|
37
|
+
type: 'input',
|
|
38
|
+
name: 'wp.requireWP',
|
|
39
|
+
message: 'The lowest WordPress version that the plugin/theme will work on',
|
|
40
|
+
default: getSetting( 'wp.requireWP', '6.0' ),
|
|
41
|
+
filter: ( val ) => val.toLowerCase()
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: 'input',
|
|
45
|
+
name: 'wp.requirePHP',
|
|
46
|
+
message: 'The minimum required PHP version',
|
|
47
|
+
default: getSetting( 'wp.requirePHP', '7.4' ),
|
|
48
|
+
filter: ( val ) => val.toLowerCase()
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'input',
|
|
52
|
+
name: 'wp.textDomain',
|
|
53
|
+
message: 'The gettext text domain of the plugin/theme',
|
|
54
|
+
default: getSetting( 'wp.textDomain' ),
|
|
55
|
+
filter: ( val ) => val.toLowerCase()
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'input',
|
|
59
|
+
name: 'wp.glotpress',
|
|
60
|
+
message: 'The glotpress project slug',
|
|
61
|
+
default: getSetting( 'wp.glotpress' ),
|
|
62
|
+
filter: ( val ) => val.toLowerCase()
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
// Paths
|
|
66
|
+
{
|
|
67
|
+
type: 'input',
|
|
68
|
+
name: 'paths.php',
|
|
69
|
+
message: 'The source files of the plugin/theme',
|
|
70
|
+
default: getSetting( 'paths.php', 'includes' ),
|
|
71
|
+
filter: ( val ) => val.toLowerCase()
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'input',
|
|
75
|
+
name: 'paths.views',
|
|
76
|
+
message: 'The path to views folder of the plugin/theme',
|
|
77
|
+
default: getSetting( 'paths.views', 'views' ),
|
|
78
|
+
filter: ( val ) => val.toLowerCase()
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'input',
|
|
82
|
+
name: 'paths.updates',
|
|
83
|
+
message: 'The path to updates folder of the plugin/theme',
|
|
84
|
+
default: getSetting( 'paths.updates', 'updates' ),
|
|
85
|
+
filter: ( val ) => val.toLowerCase()
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: 'input',
|
|
89
|
+
name: 'paths.javascript',
|
|
90
|
+
message: 'The path to javascript folder of the plugin/theme',
|
|
91
|
+
default: getSetting( 'paths.javascript', 'assets/src' ),
|
|
92
|
+
filter: ( val ) => val.toLowerCase()
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: 'input',
|
|
96
|
+
name: 'paths.css',
|
|
97
|
+
message: 'The path to css folder of the plugin/theme',
|
|
98
|
+
default: getSetting( 'paths.css', 'assets/css' ),
|
|
99
|
+
filter: ( val ) => val.toLowerCase()
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// Misc
|
|
103
|
+
{
|
|
104
|
+
type: 'input',
|
|
105
|
+
name: 'misc.package',
|
|
106
|
+
message: 'Enter php package namespace',
|
|
107
|
+
default: getSetting( 'misc.package' ),
|
|
108
|
+
filter: ( val ) => val.replace( / /g, '' )
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
type: 'input',
|
|
112
|
+
name: 'misc.prefix',
|
|
113
|
+
message: 'Enter prefix to be used for functions',
|
|
114
|
+
default: getSetting( 'misc.prefix' ),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: 'input',
|
|
118
|
+
name: 'misc.constprefix',
|
|
119
|
+
message: 'Enter prefix to be used for constants',
|
|
120
|
+
default: getSetting( 'misc.constprefix' ),
|
|
121
|
+
},
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
heading('How you want your plugin?')
|
|
125
|
+
inquirer.prompt( questions )
|
|
126
|
+
.then( ( answers ) => {
|
|
127
|
+
const date = new Date()
|
|
128
|
+
answers = {
|
|
129
|
+
...answers,
|
|
130
|
+
year: date.getFullYear(),
|
|
131
|
+
company: {
|
|
132
|
+
name: 'Advanced Ads',
|
|
133
|
+
url: 'https://wpadvancedads.com/',
|
|
134
|
+
},
|
|
135
|
+
author: {
|
|
136
|
+
name: 'Advanced Ads',
|
|
137
|
+
email: 'info@wpadvancedads.com',
|
|
138
|
+
url: 'https://wpadvancedads.com/',
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
answers.package = {
|
|
143
|
+
vendor: kebabCase( answers.company.name ),
|
|
144
|
+
name: kebabCase( answers.wp.name )
|
|
145
|
+
}
|
|
146
|
+
answers.wp.textDomain = answers.wp.textDomain || answers.package.name
|
|
147
|
+
|
|
148
|
+
// Glotpress
|
|
149
|
+
answers.glotpress = false
|
|
150
|
+
if (answers.wp.glotpress) {
|
|
151
|
+
answers.glotpress = {
|
|
152
|
+
project: answers.wp.glotpress,
|
|
153
|
+
destination: "./languages/",
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
answers.wpPot = {
|
|
158
|
+
output: "/languages/",
|
|
159
|
+
file: `${answers.wp.textDomain}.pot`,
|
|
160
|
+
domain: answers.wp.textDomain
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
saveConfig( answers )
|
|
164
|
+
msgSuccessTitle('Config file created successfully!')
|
|
165
|
+
} )
|
|
166
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Node Dependencies
|
|
4
|
+
*/
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal Dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getSetting, writeFile, heading, filenameToHeading, getProjectRoot, msgErrorTitle, getTemplateFile, compileTemplate } from "../utilities/index.js";
|
|
11
|
+
|
|
12
|
+
export default (name, options) => {
|
|
13
|
+
heading('Creating javascript file...')
|
|
14
|
+
const {
|
|
15
|
+
h: header = null,
|
|
16
|
+
d: description = null,
|
|
17
|
+
} = options
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const paths = name.toLowerCase().split('\\')
|
|
21
|
+
const filename = paths.pop() + '.js';
|
|
22
|
+
const folder = path.join(getProjectRoot(), getSetting('paths.javascript'), paths.join('/'));
|
|
23
|
+
|
|
24
|
+
// Data
|
|
25
|
+
const data = getSetting();
|
|
26
|
+
data.heading = header || filenameToHeading(name) + ' module.';
|
|
27
|
+
data.description = description || 'Description of the module';
|
|
28
|
+
|
|
29
|
+
const content = compileTemplate(getTemplateFile('files/javascript.js'), data);
|
|
30
|
+
writeFile(folder, filename, content);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
msgErrorTitle('We failed!!!');
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -9,8 +9,8 @@ import { forEach, waterfall } from 'async'
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal Dependencies
|
|
11
11
|
*/
|
|
12
|
-
import { pluginData } from '
|
|
13
|
-
import { heading, onSameLine, updateFileContent } from "../../utilities/index.js"
|
|
12
|
+
import { pluginData } from '../release.js'
|
|
13
|
+
import { getSetting, heading, onSameLine, saveConfig, updateFileContent } from "../../utilities/index.js"
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Update version in readme.txt file
|
|
@@ -56,63 +56,79 @@ function updatePluginFiles(next) {
|
|
|
56
56
|
return next(true)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
`${constantRe.opening}${version}${constantRe.closing}`,
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if(update) {
|
|
93
|
-
pluginData.commitMessages.push('update version in ' + fileName)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return content
|
|
59
|
+
const phpFiles = files.filter(file => {
|
|
60
|
+
return path.extname(file).toLowerCase() === '.php' && file.toLowerCase() !== 'index.php'
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if ( phpFiles.length < 1 ) {
|
|
64
|
+
onSameLine(`${logSymbols.error} No PHP files found`)
|
|
65
|
+
return next(true)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
forEach(phpFiles, (fileName, nextFile) => {
|
|
69
|
+
updateFileContent(
|
|
70
|
+
fileName,
|
|
71
|
+
{
|
|
72
|
+
updating: `Updating ${fileName}`,
|
|
73
|
+
failed: `Failed to update ${fileName}`,
|
|
74
|
+
updated: `${fileName} updated successfully`,
|
|
75
|
+
},
|
|
76
|
+
nextFile,
|
|
77
|
+
(content) => {
|
|
78
|
+
let update = false
|
|
79
|
+
const version = pluginData.semver.getNextVersionString()
|
|
80
|
+
let versionRe = new RegExp('^(?<prefix>(?:[ \\t]*<\\?php)?[ \\t\\/*#@]*Version: +)(?<version>.*)$', 'mi')
|
|
81
|
+
let constantRe = new RegExp('^(?<opening>(?:[ \\t])?define.*[\\\'"].*_VERSION[\\\'"],.*[\\\'"])(?<version>.*)(?<closing>[\\\'"].*)$', 'mi')
|
|
82
|
+
|
|
83
|
+
versionRe = versionRe.exec(content)
|
|
84
|
+
if (null !== versionRe) {
|
|
85
|
+
update = true
|
|
86
|
+
versionRe = versionRe.groups
|
|
87
|
+
content = content.replace(`${versionRe.prefix}${versionRe.version}`, `${versionRe.prefix}${version}`)
|
|
97
88
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
|
|
90
|
+
constantRe = constantRe.exec(content)
|
|
91
|
+
if (null !== constantRe) {
|
|
92
|
+
update = true
|
|
93
|
+
constantRe = constantRe.groups
|
|
94
|
+
content = content.replace(
|
|
95
|
+
`${constantRe.opening}${constantRe.version}${constantRe.closing}`,
|
|
96
|
+
`${constantRe.opening}${version}${constantRe.closing}`,
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if(update) {
|
|
101
|
+
pluginData.commitMessages.push('update version in ' + fileName)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return content
|
|
105
|
+
}
|
|
106
|
+
)
|
|
102
107
|
}, () => next())
|
|
103
108
|
})
|
|
104
109
|
}
|
|
105
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Update version in config file
|
|
113
|
+
*/
|
|
114
|
+
function updateConfigFile(next) {
|
|
115
|
+
const settings = getSetting()
|
|
116
|
+
settings.wp.version = pluginData.semver.getNextVersionString()
|
|
117
|
+
saveConfig(settings)
|
|
118
|
+
onSameLine(`${logSymbols.success} Version updated in config file`)
|
|
119
|
+
}
|
|
120
|
+
|
|
106
121
|
/**
|
|
107
122
|
* Execute routine
|
|
108
123
|
*/
|
|
109
|
-
export function updateVersionNumber(next) {
|
|
124
|
+
export default function updateVersionNumber(next) {
|
|
110
125
|
heading('Updating files for new version')
|
|
111
126
|
|
|
112
127
|
const flow = []
|
|
113
128
|
|
|
114
129
|
if (!pluginData.semver.preRelease) {
|
|
115
130
|
flow.push(updateReadme)
|
|
131
|
+
flow.push(updateConfigFile)
|
|
116
132
|
}
|
|
117
133
|
|
|
118
134
|
flow.push(updatePluginFiles)
|
|
@@ -8,7 +8,7 @@ import { forEach, waterfall } from 'async'
|
|
|
8
8
|
/**
|
|
9
9
|
* Internal Dependencies
|
|
10
10
|
*/
|
|
11
|
-
import { pluginData } from '
|
|
11
|
+
import { pluginData } from '../release.js';
|
|
12
12
|
import { heading, execCommand, onSameLine, updateFileContent } from "../../utilities/index.js"
|
|
13
13
|
|
|
14
14
|
const LOCALES_CHANGELOG = {
|
|
@@ -241,7 +241,7 @@ function cleanChangelogDirectory(next) {
|
|
|
241
241
|
/**
|
|
242
242
|
* Execute routine
|
|
243
243
|
*/
|
|
244
|
-
export function updateChangelog(next) {
|
|
244
|
+
export default function updateChangelog(next) {
|
|
245
245
|
heading('Creating changelog')
|
|
246
246
|
|
|
247
247
|
const flow = [
|