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.
Files changed (47) hide show
  1. package/package.json +9 -11
  2. package/src/app.js +80 -27
  3. package/src/commands/class.js +63 -0
  4. package/src/commands/css.js +36 -0
  5. package/src/commands/index.js +8 -6
  6. package/src/commands/init.js +166 -0
  7. package/src/commands/javascript.js +36 -0
  8. package/src/commands/release/change-version.js +61 -45
  9. package/src/commands/release/changelog.js +2 -2
  10. package/src/commands/release/composer.js +8 -16
  11. package/src/commands/release/git.js +5 -25
  12. package/src/commands/release/github.js +2 -4
  13. package/src/commands/release/prompts.js +1 -1
  14. package/src/commands/release/semver.js +2 -2
  15. package/src/commands/release/translations.js +10 -32
  16. package/src/commands/release.js +55 -0
  17. package/src/commands/updates.js +31 -0
  18. package/src/commands/views.js +31 -0
  19. package/src/utilities/filesystem.js +148 -0
  20. package/src/utilities/formatting.js +6 -2
  21. package/src/utilities/index.js +4 -5
  22. package/src/utilities/misc.js +12 -0
  23. package/src/utilities/semver.js +6 -1
  24. package/src/utilities/settings.js +94 -0
  25. package/src/utilities/shell.js +17 -0
  26. package/template/files/class-empty.php +26 -0
  27. package/template/{make/file-initializer.php → files/class-initializer.php} +5 -4
  28. package/template/{make/file-integration.php → files/class-integration.php} +5 -4
  29. package/template/{make/file-routes.php → files/class-rest.php} +5 -4
  30. package/template/{make/file-singleton.php → files/class-singleton.php} +5 -4
  31. package/template/files/javascript.js +13 -0
  32. package/template/files/stylesheet.css +8 -0
  33. package/template/files/update.php +21 -0
  34. package/template/{make/file.php → files/view.php} +3 -10
  35. package/src/commands/backup/index.js +0 -50
  36. package/src/commands/file/create-file.js +0 -127
  37. package/src/commands/file/index.js +0 -29
  38. package/src/commands/help/index.js +0 -16
  39. package/src/commands/patch/index.js +0 -84
  40. package/src/commands/release/index.js +0 -68
  41. package/src/commands/release/webpack.js +0 -30
  42. package/src/commands/setup/index.js +0 -28
  43. package/src/commands/setup/prompts.js +0 -111
  44. package/src/utilities/cache.js +0 -23
  45. package/src/utilities/command.js +0 -29
  46. package/src/utilities/file.js +0 -57
  47. package/src/utilities/folder.js +0 -64
@@ -1,111 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import get from 'lodash/get.js'
5
- import inquirer from 'inquirer'
6
- import kebabCase from 'lodash/kebabCase.js'
7
-
8
- /**
9
- * Node dependencies
10
- */
11
- import { getCacheStore, getSettings } from '../../utilities/index.js'
12
-
13
- export default ( next ) => {
14
- const cache = getCacheStore()
15
- const settings = getSettings()
16
- const getAnswer = ( key, defaultVal = '' ) => get( settings, key, defaultVal )
17
-
18
- const questions = [
19
-
20
- // WordPress
21
- {
22
- type: 'input',
23
- name: 'wp.textDomain',
24
- message: 'Enter text domain for i18n',
25
- default: getAnswer( 'wp.textDomain' ),
26
- filter: ( val ) => val.toLowerCase()
27
- },
28
- {
29
- type: 'input',
30
- name: 'wp.version',
31
- message: 'Enter plugin version',
32
- default: getAnswer( 'wp.version', '1.0.0' ),
33
- filter: ( val ) => val.toLowerCase()
34
- },
35
- {
36
- type: 'input',
37
- name: 'wp.name',
38
- message: 'Enter plugin name',
39
- default: getAnswer( 'wp.name' ),
40
- },
41
- {
42
- type: 'input',
43
- name: 'wp.description',
44
- message: 'Enter plugin description',
45
- default: getAnswer( 'wp.description' ),
46
- },
47
- {
48
- type: 'input',
49
- name: 'wp.proxy',
50
- message: 'Enter wordpress installation url',
51
- default: getAnswer( 'wp.proxy' ),
52
- },
53
-
54
- // PHP
55
- {
56
- type: 'input',
57
- name: 'php.package',
58
- message: 'Enter php package attribute',
59
- default: getAnswer( 'php.package' ),
60
- filter: ( val ) => val.replace( / /g, '' )
61
- },
62
- ]
63
-
64
- inquirer.prompt( questions )
65
- .then( ( answers ) => {
66
- const date = new Date()
67
- answers = {
68
- ...answers,
69
- year: date.getFullYear(),
70
- company: {
71
- name: 'Advanced Ads',
72
- url: 'https://wpadvancedads.com/',
73
- },
74
- author: {
75
- name: 'Advanced Ads',
76
- email: 'info@wpadvancedads.com',
77
- url: 'https://wpadvancedads.com/',
78
- }
79
- }
80
-
81
- // Validation.
82
- if ( '' === answers.wp.textDomain ) {
83
- answers.wp.textDomain = answers.company.name
84
- .toLowerCase()
85
- .replace( / /g, '-' )
86
- }
87
-
88
- if ( '' === answers.wp.name ) {
89
- answers.wp.name = answers.company.name
90
- }
91
-
92
- if ( '' === answers.php.package ) {
93
- answers.php.package = answers.company.name
94
- .replace( / /g, '' )
95
- }
96
-
97
- // Formatting.
98
- answers.package = {
99
- vendor: kebabCase( answers.company.name ),
100
- name: kebabCase( answers.wp.name )
101
- }
102
- answers.functionName = answers.php.package
103
- .toLowerCase()
104
- .replace( /\\/g, '_' )
105
-
106
- // Cache.
107
- cache.setKey( 'answers', answers )
108
- cache.save()
109
- next( null, answers )
110
- } )
111
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import flatCache from 'flat-cache'
5
-
6
- /**
7
- * Internal Dependencies
8
- */
9
- import { getRootFolder } from './folder.js'
10
-
11
- export const CACHE_FILE = 'adv-ads-scaffolding'
12
-
13
- export function getCacheStore() {
14
- return flatCache.load( CACHE_FILE, getRootFolder() )
15
- }
16
-
17
- export function getSettings() {
18
- const cache = getCacheStore()
19
- let saved = cache.all()
20
- saved = saved ? saved.answers : {}
21
-
22
- return saved
23
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * External Dependencies
3
- */
4
- import argv from 'yargs-parser'
5
-
6
- /**
7
- * Get arguments
8
- *
9
- * @returns {Array} arguments
10
- */
11
- export function getArguments() {
12
- return argv( process.argv.slice( 2 ) )
13
- }
14
-
15
- /**
16
- * Get command with arguments
17
- *
18
- * @returns {Object} command and arguments
19
- */
20
- export function getCommand() {
21
- const args = getArguments()
22
- const { _, ...rest } = args
23
- const command = _[0] || 'help'
24
-
25
- return {
26
- command,
27
- args: rest || []
28
- }
29
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import chalk from 'chalk'
5
- import logSymbols from 'log-symbols'
6
-
7
- /**
8
- * Node dependencies
9
- */
10
- import fs from 'fs'
11
- import { onSameLine } from './formatting.js'
12
-
13
- export function backupFile(name, file) {
14
- if ( ! fs.existsSync(file) ) {
15
- console.log( `${logSymbols.error} ${chalk.red(`${name} file not found!`)}` )
16
- return
17
- }
18
-
19
- fs.renameSync(
20
- file,
21
- file + '.bak'
22
- )
23
- console.log( `${logSymbols.success} ${chalk.dim(`${name} backed up!`)}` )
24
- }
25
-
26
- export function deleteFile(name, file) {
27
- if ( ! fs.existsSync(file) ) {
28
- console.log( `${logSymbols.error} ${chalk.red(`${name} file not found!`)}` )
29
- return
30
- }
31
-
32
- fs.rmSync(file)
33
- console.log( `${logSymbols.success} ${chalk.dim(`${name} deleted!`)}` )
34
- }
35
-
36
- export function updateFileContent(fileName, messages, next, callback) {
37
- process.stdout.write(messages.updating)
38
-
39
- fs.readFile(fileName, (err, buffer) => {
40
- if ( null !== err ) {
41
- onSameLine(`${logSymbols.error} ${messages.failed}`)
42
- return next(true)
43
- }
44
-
45
- const content = callback(buffer.toString())
46
-
47
- fs.writeFile(fileName, content, (err) => {
48
- if ( null !== err ) {
49
- onSameLine(`${logSymbols.error} ${messages.failed}`)
50
- return next(true)
51
- }
52
-
53
- onSameLine(`${logSymbols.success} ${messages.updated}`)
54
- next()
55
- })
56
- })
57
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * Node dependencies
3
- */
4
- import fs from 'fs'
5
- import { join, sep } 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( `${sep}index.js`, '' )
64
- }