@caweb/cli 1.13.6 → 1.14.0
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/commands/env/shell.js +1 -1
- package/commands/env/start.js +84 -88
- package/commands/index.js +9 -8
- package/commands/sync/index.js +3 -5
- package/configs/wp-env.js +57 -14
- package/lib/cli.js +5 -9
- package/lib/helpers.js +36 -11
- package/lib/index.js +0 -12
- package/lib/wordpress/index.js +6 -10
- package/lib/wordpress/options.js +17 -4
- package/lib/wordpress/setup/caweb.js +62 -0
- package/lib/wordpress/setup/divi.js +90 -0
- package/lib/wordpress/setup/index.js +130 -0
- package/lib/wordpress/wordpress.js +45 -165
- package/package.json +17 -14
- package/commands/env/update-plugins.js +0 -44
- package/lib/admin.js +0 -40
- package/lib/wordpress/caweb.js +0 -114
- package/lib/wordpress/divi.js +0 -127
- package/lib/wordpress/download-sources.js +0 -286
package/commands/env/shell.js
CHANGED
package/commands/env/start.js
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import * as dockerCompose from 'docker-compose';
|
|
7
|
-
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import deepmerge from 'deepmerge';
|
|
8
9
|
/**
|
|
9
10
|
* WordPress dependencies
|
|
10
11
|
*/
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { didCacheChange, getCache } from '@wordpress/env/lib/cache.js';
|
|
15
|
-
import { canAccessWPORG } from '@wordpress/env/lib/wordpress.js';
|
|
12
|
+
import WPEnv from '@wordpress/env';
|
|
13
|
+
import { md5} from '../../lib/helpers.js';
|
|
14
|
+
// import { canAccessWPORG } from '../../lib/wordpress/index.js';
|
|
16
15
|
|
|
17
16
|
const CONFIG_CACHE_KEY = 'config_checksum';
|
|
17
|
+
const CACHE_FILE_NAME = 'wp-env-cache.json';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Internal dependencies
|
|
@@ -22,8 +22,8 @@ const CONFIG_CACHE_KEY = 'config_checksum';
|
|
|
22
22
|
import {
|
|
23
23
|
appPath,
|
|
24
24
|
projectPath,
|
|
25
|
+
currentPath,
|
|
25
26
|
configureCAWeb,
|
|
26
|
-
downloadSources,
|
|
27
27
|
configureWordPress,
|
|
28
28
|
runCmd,
|
|
29
29
|
runCLICmds
|
|
@@ -32,6 +32,38 @@ import {
|
|
|
32
32
|
import { wpEnvConfig, wpEnvOverrideConfig } from '../../configs/wp-env.js';
|
|
33
33
|
import {default as SyncProcess} from '../sync/index.js';
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Gets the directory in which generated files are created.
|
|
37
|
+
*
|
|
38
|
+
* By default: '~/.wp-env/'. On Linux with snap packages: '~/wp-env/'. Can be
|
|
39
|
+
* overridden with the WP_ENV_HOME environment variable.
|
|
40
|
+
*
|
|
41
|
+
* @return {Promise<string>} The absolute path to the `wp-env` home directory.
|
|
42
|
+
*/
|
|
43
|
+
async function getCacheDirectory() {
|
|
44
|
+
// Allow user to override download location.
|
|
45
|
+
if ( process.env.WP_ENV_HOME ) {
|
|
46
|
+
return path.resolve( process.env.WP_ENV_HOME );
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Installing docker with Snap Packages on Linux is common, but does not
|
|
51
|
+
* support hidden directories. Therefore we use a public directory when
|
|
52
|
+
* snap packages exist.
|
|
53
|
+
*
|
|
54
|
+
* @see https://github.com/WordPress/gutenberg/issues/20180#issuecomment-587046325
|
|
55
|
+
*/
|
|
56
|
+
let usesSnap;
|
|
57
|
+
try {
|
|
58
|
+
fs.statSync( '/snap' );
|
|
59
|
+
usesSnap = true;
|
|
60
|
+
} catch {
|
|
61
|
+
usesSnap = false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return path.resolve( os.homedir(), usesSnap ? 'wp-env' : '.wp-env' );
|
|
65
|
+
}
|
|
66
|
+
|
|
35
67
|
/**
|
|
36
68
|
* Starts the development server.
|
|
37
69
|
*
|
|
@@ -55,6 +87,7 @@ export default async function start({
|
|
|
55
87
|
xdebug,
|
|
56
88
|
scripts,
|
|
57
89
|
debug,
|
|
90
|
+
spx,
|
|
58
91
|
sync,
|
|
59
92
|
bare,
|
|
60
93
|
plugin,
|
|
@@ -62,122 +95,85 @@ export default async function start({
|
|
|
62
95
|
multisite,
|
|
63
96
|
subdomain
|
|
64
97
|
}) {
|
|
98
|
+
let configFilePath = path.resolve( appPath, '.wp-env.json' );
|
|
99
|
+
let configOverrideFilePath = path.resolve( appPath, '.wp-env.override.json' );
|
|
65
100
|
|
|
66
|
-
|
|
67
|
-
|
|
101
|
+
const workDirectoryPath = path.resolve(
|
|
102
|
+
await getCacheDirectory(),
|
|
103
|
+
md5( configFilePath )
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// Keys should not be saved in the repository so we store them in the override.json file.
|
|
68
107
|
// Write CAWeb .wp-env.override.json file.
|
|
69
|
-
if( ! fs.existsSync(
|
|
108
|
+
if( ! fs.existsSync( configOverrideFilePath ) ){
|
|
70
109
|
spinner.stop()
|
|
71
110
|
|
|
72
|
-
// Keys should not be saved in the repository so we store them in the override.json file.
|
|
73
111
|
fs.writeFileSync(
|
|
74
|
-
|
|
75
|
-
JSON.stringify( await wpEnvOverrideConfig(bare, multisite, subdomain, plugin, theme), null, 4 )
|
|
112
|
+
configOverrideFilePath,
|
|
113
|
+
JSON.stringify( await wpEnvOverrideConfig({workDirectoryPath,bare, multisite, subdomain, plugin, theme}), null, 4 )
|
|
76
114
|
);
|
|
77
115
|
|
|
78
116
|
spinner.start('Writing .wp-env.override.json file...');
|
|
79
117
|
|
|
118
|
+
}else {
|
|
119
|
+
let overrideConfig = JSON.parse( fs.readFileSync( configOverrideFilePath ) );
|
|
120
|
+
|
|
121
|
+
// if the override file doesn't have Divi credentials prompt for them again.
|
|
122
|
+
if( ! overrideConfig.config.ET_USERNAME || ! overrideConfig.config.ET_API_KEY ){
|
|
123
|
+
spinner.stop()
|
|
124
|
+
|
|
125
|
+
let diviConfig = await wpEnvOverrideConfig({workDirectoryPath,bare, multisite, subdomain, plugin, theme});
|
|
126
|
+
|
|
127
|
+
fs.writeFileSync(
|
|
128
|
+
configOverrideFilePath,
|
|
129
|
+
JSON.stringify( deepmerge( overrideConfig, diviConfig ), null, 4 )
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
spinner.start('Writing .wp-env.override.json file...');
|
|
133
|
+
}
|
|
80
134
|
}
|
|
81
135
|
|
|
82
136
|
// Write CAWeb .wp-env.json file.
|
|
83
|
-
if( ! fs.existsSync(
|
|
137
|
+
if( ! fs.existsSync( configFilePath ) || update ){
|
|
84
138
|
spinner.stop()
|
|
85
139
|
|
|
86
140
|
fs.writeFileSync(
|
|
87
|
-
|
|
88
|
-
JSON.stringify( wpEnvConfig(bare, multisite, subdomain, plugin, theme), null, 4 )
|
|
141
|
+
configFilePath,
|
|
142
|
+
JSON.stringify( await wpEnvConfig({workDirectoryPath,bare, multisite, subdomain, plugin, theme}), null, 4 )
|
|
89
143
|
);
|
|
90
144
|
|
|
91
145
|
spinner.start('Writing .wp-env.json file...');
|
|
92
146
|
}
|
|
93
147
|
|
|
94
|
-
// Get current wp-env cache key
|
|
95
|
-
const config = await loadConfig(path.resolve('.'));
|
|
96
|
-
const { workDirectoryPath } = config;
|
|
97
|
-
const cacheKey = await getCache(CONFIG_CACHE_KEY, {workDirectoryPath});
|
|
98
|
-
|
|
99
148
|
// Set extra configuration for WordPress.
|
|
100
149
|
// Increase max execution time to 300 seconds.
|
|
101
150
|
process.env.WORDPRESS_CONFIG_EXTRA = 'set_time_limit(300);';
|
|
102
151
|
|
|
103
|
-
// we can enable phpMyAdmin since @wordpress/env:10.14.0
|
|
104
|
-
if( config.env.development.config.WP_ENV_PHPMYADMIN_PORT ){
|
|
105
|
-
process.env.WP_ENV_PHPMYADMIN_PORT = config.env.development.config.WP_ENV_PHPMYADMIN_PORT;
|
|
106
|
-
}
|
|
107
|
-
if( config.env.tests.config.WP_ENV_TESTS_PHPMYADMIN_PORT ){
|
|
108
|
-
process.env.WP_ENV_TESTS_PHPMYADMIN_PORT = config.env.tests.config.WP_ENV_TESTS_PHPMYADMIN_PORT;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
152
|
// wp-env launch.
|
|
112
|
-
await
|
|
153
|
+
await WPEnv.start({
|
|
113
154
|
spinner,
|
|
114
155
|
update,
|
|
115
156
|
xdebug,
|
|
157
|
+
spx,
|
|
116
158
|
scripts,
|
|
117
159
|
debug,
|
|
118
160
|
})
|
|
119
161
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// We aren't done lets clear the default WordPress text.
|
|
124
|
-
spinner.prefixText = '';
|
|
125
|
-
spinner.text = '';
|
|
126
|
-
|
|
127
|
-
// Check if we should configure settings.
|
|
128
|
-
const shouldConfigureWp = ( update ||
|
|
129
|
-
( await didCacheChange( CONFIG_CACHE_KEY, cacheKey, {
|
|
130
|
-
workDirectoryPath,
|
|
131
|
-
} ) )) &&
|
|
132
|
-
// Don't reconfigure everything when we can't connect to the internet because
|
|
133
|
-
// the majority of update tasks involve connecting to the internet. (Such
|
|
134
|
-
// as downloading sources and pulling docker images.)
|
|
135
|
-
( await canAccessWPORG() );
|
|
136
|
-
|
|
137
|
-
// Only run configurations when config has changed.
|
|
138
|
-
if( shouldConfigureWp ){
|
|
139
|
-
// Download any resources required for CAWeb.
|
|
140
|
-
if( ! bare ){
|
|
141
|
-
spinner.text = 'Downloading CAWeb resources...';
|
|
142
|
-
// Download sources for development and tests.
|
|
143
|
-
await Promise.all( [
|
|
144
|
-
downloadSources('development', {spinner, config}),
|
|
145
|
-
downloadSources('tests', {spinner, config})
|
|
146
|
-
] );
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Make additional WordPress Configurations.
|
|
150
|
-
await Promise.all( [
|
|
151
|
-
retry( () => configureWordPress( 'development', config, spinner, multisite, subdomain ), {
|
|
152
|
-
times: 2,
|
|
153
|
-
} ),
|
|
154
|
-
retry( () => configureWordPress( 'tests', config, spinner, multisite, subdomain ), {
|
|
155
|
-
times: 2,
|
|
156
|
-
} )
|
|
157
|
-
] );
|
|
158
|
-
|
|
159
|
-
// Make CAWeb WordPress Configurations.
|
|
160
|
-
await Promise.all( [
|
|
161
|
-
retry( () => configureCAWeb( 'development', config, spinner ), {
|
|
162
|
-
times: 2,
|
|
163
|
-
} ),
|
|
164
|
-
retry( () => configureCAWeb( 'tests', config, spinner ), {
|
|
165
|
-
times: 2,
|
|
166
|
-
} ),
|
|
167
|
-
] );
|
|
162
|
+
if( sync ){
|
|
163
|
+
// Save pretext from wp-env if it exists for later.
|
|
164
|
+
let preText = undefined !== spinner.prefixText ? spinner.prefixText.slice(0, -1) : '';
|
|
168
165
|
|
|
166
|
+
// We aren't done lets clear the default WordPress text.
|
|
167
|
+
spinner.prefixText = '';
|
|
169
168
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
await SyncProcess({spinner, debug, target: 'static', dest: 'local'})
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
spinner.prefixText = preText;
|
|
169
|
+
// sync any static information.
|
|
170
|
+
spinner.text = `Syncing CAWebPublishing development Environment...`;
|
|
171
|
+
// Sync the static site to the local WordPress instance.
|
|
172
|
+
await SyncProcess({spinner, debug, target: 'static', dest: 'local'})
|
|
180
173
|
|
|
174
|
+
// Restore pretext.
|
|
175
|
+
spinner.prefixText = preText;
|
|
176
|
+
}
|
|
181
177
|
|
|
182
178
|
spinner.text = 'Done!';
|
|
183
179
|
};
|
package/commands/index.js
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
// These are default wp-env commands. No need to overwrite these commands
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import WPEnv from '@wordpress/env';
|
|
6
|
+
const {
|
|
7
|
+
clean,
|
|
8
|
+
logs,
|
|
9
|
+
run,
|
|
10
|
+
stop,
|
|
11
|
+
destroy,
|
|
12
|
+
installPath
|
|
13
|
+
} = WPEnv;
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Internal dependencies
|
|
@@ -36,7 +39,6 @@ import convertSite from './sites/convert-site.js';
|
|
|
36
39
|
// we overwrite the start command so we can run additional steps.
|
|
37
40
|
import start from './env/start.js';
|
|
38
41
|
import shell from './env/shell.js';
|
|
39
|
-
import updatePlugins from './env/update-plugins.js';
|
|
40
42
|
|
|
41
43
|
// import test from './test.js';
|
|
42
44
|
import genScripts from './gen-scripts.js';
|
|
@@ -55,7 +57,6 @@ export {
|
|
|
55
57
|
stop,
|
|
56
58
|
destroy,
|
|
57
59
|
sync,
|
|
58
|
-
updatePlugins,
|
|
59
60
|
shell,
|
|
60
61
|
createBlock,
|
|
61
62
|
updateBlock,
|
package/commands/sync/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import fs from 'fs';
|
|
6
|
-
import loadConfig from '@wordpress/env/lib/config/load-config.js';
|
|
7
6
|
import axios from 'axios';
|
|
8
7
|
|
|
9
8
|
// since we are in a spinner,
|
|
@@ -181,9 +180,6 @@ export default async function sync({
|
|
|
181
180
|
postIds
|
|
182
181
|
} ) {
|
|
183
182
|
|
|
184
|
-
// this gets the working directory path after wp-env validation
|
|
185
|
-
const {workDirectoryPath} = await loadConfig(path.resolve('.'));
|
|
186
|
-
|
|
187
183
|
// read caweb configuration file.
|
|
188
184
|
let serviceConfig = fs.existsSync(configFile) ? JSON.parse( fs.readFileSync(configFile) ) : { sync: {} };
|
|
189
185
|
|
|
@@ -217,7 +213,9 @@ export default async function sync({
|
|
|
217
213
|
process.exit(1)
|
|
218
214
|
}
|
|
219
215
|
}
|
|
220
|
-
|
|
216
|
+
|
|
217
|
+
console.log( target)
|
|
218
|
+
console.log( dest )
|
|
221
219
|
/**
|
|
222
220
|
* each instance has to have a url, user, pwd property
|
|
223
221
|
*/
|
package/configs/wp-env.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '../lib/helpers.js';
|
|
14
14
|
import { promptForDivi } from './prompts.js';
|
|
15
15
|
import { config, env } from 'process';
|
|
16
|
+
import { CAWEB_OPTIONS, DIVI_OPTIONS } from'../lib/wordpress/options.js';
|
|
16
17
|
|
|
17
18
|
const localFile = path.join(projectPath, 'package.json');
|
|
18
19
|
const pkg = JSON.parse( fs.readFileSync(localFile) );
|
|
@@ -32,25 +33,72 @@ const cawebJson = fs.existsSync( path.join(appPath, 'caweb.json') ) ?
|
|
|
32
33
|
*
|
|
33
34
|
* @returns object
|
|
34
35
|
*/
|
|
35
|
-
function wpEnvConfig ( bare, multisite, subdomain, plugin, theme ) {
|
|
36
|
+
async function wpEnvConfig ( {workDirectoryPath: cwd , bare, multisite, subdomain, plugin, theme} ) {
|
|
36
37
|
let themes = [];
|
|
37
38
|
let plugins = [];
|
|
39
|
+
let args = {cwd, bare, multisite, subdomain, plugin, theme};
|
|
40
|
+
let argString = Object.entries( args ).map( ([k, v]) => `--${k} ${v}` ).join( ' ' );
|
|
41
|
+
|
|
42
|
+
let setupFile = path.join( projectPath, 'lib', 'wordpress', 'setup', 'index.js' );
|
|
38
43
|
|
|
39
44
|
let envConfig = {
|
|
40
45
|
core: `WordPress/WordPress#${pkg.config.WP_VER}`,
|
|
41
46
|
phpVersion: `${pkg.config.PHP_VER}`,
|
|
42
47
|
multisite,
|
|
48
|
+
themes: [
|
|
49
|
+
`CAWebPublishing/CAWeb#${pkg.config.CAWEB_VER}`
|
|
50
|
+
],
|
|
51
|
+
plugins: [
|
|
52
|
+
'CAWebPublishing/caweb-dev',
|
|
53
|
+
`https://downloads.wordpress.org/plugin/query-monitor.${pkg.config.QUERY_MONITOR}.zip`,
|
|
54
|
+
],
|
|
43
55
|
env: {
|
|
44
|
-
development: {
|
|
45
|
-
|
|
56
|
+
development: {
|
|
57
|
+
port: 8888,
|
|
58
|
+
phpmyadminPort: 9998,
|
|
59
|
+
config: {}
|
|
60
|
+
},
|
|
61
|
+
tests: {
|
|
62
|
+
port: 8889,
|
|
63
|
+
phpmyadminPort: 9999,
|
|
64
|
+
config: {}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
lifecycleScripts: {
|
|
68
|
+
afterStart: `node ${ setupFile } ${ argString }`,
|
|
69
|
+
},
|
|
70
|
+
config: {
|
|
71
|
+
...pkg.config.DEFAULTS
|
|
46
72
|
}
|
|
47
73
|
}
|
|
48
74
|
|
|
49
|
-
if( multisite
|
|
50
|
-
|
|
75
|
+
if( multisite ){
|
|
76
|
+
if( ! bare ){
|
|
77
|
+
// if multisite set default theme to CAWeb
|
|
78
|
+
// this allows for any new sites created to use CAWeb as the default theme.
|
|
79
|
+
pkg.config.DEFAULTS.WP_DEFAULT_THEME = 'CAWeb';
|
|
80
|
+
}
|
|
81
|
+
// if subdomain add the subdomain constant
|
|
82
|
+
if( subdomain ){
|
|
83
|
+
pkg.config.DEFAULTS.SUBDOMAIN_INSTALL= true;
|
|
84
|
+
}
|
|
51
85
|
}
|
|
52
86
|
|
|
53
|
-
|
|
87
|
+
// iterate over available CAWeb options.
|
|
88
|
+
Object.entries(CAWEB_OPTIONS).forEach(([k,v]) => {
|
|
89
|
+
envConfig.config[k] = v.defaultValue;
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// iterate over available Divi options.
|
|
93
|
+
Object.entries(DIVI_OPTIONS).forEach(([group, options]) => {
|
|
94
|
+
// we dont want to set any automatic update options here.
|
|
95
|
+
if( 'et_automatic_updates_options' === group ) return;
|
|
96
|
+
|
|
97
|
+
// iterate over each group options.
|
|
98
|
+
Object.entries(options).forEach(([key, data]) => {
|
|
99
|
+
envConfig.config[key] = data.defaultValue;
|
|
100
|
+
})
|
|
101
|
+
})
|
|
54
102
|
|
|
55
103
|
// if root directory is a theme
|
|
56
104
|
if( theme ){
|
|
@@ -131,7 +179,6 @@ function wpEnvConfig ( bare, multisite, subdomain, plugin, theme ) {
|
|
|
131
179
|
|
|
132
180
|
}
|
|
133
181
|
|
|
134
|
-
|
|
135
182
|
/**
|
|
136
183
|
* Build .wp-env.override.json
|
|
137
184
|
*
|
|
@@ -143,16 +190,12 @@ function wpEnvConfig ( bare, multisite, subdomain, plugin, theme ) {
|
|
|
143
190
|
*
|
|
144
191
|
* @returns object
|
|
145
192
|
*/
|
|
146
|
-
async function wpEnvOverrideConfig(){
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
let config = {
|
|
193
|
+
async function wpEnvOverrideConfig({workDirectoryPath}){
|
|
194
|
+
return {
|
|
150
195
|
config: {
|
|
151
|
-
...
|
|
196
|
+
...await promptForDivi()
|
|
152
197
|
}
|
|
153
198
|
}
|
|
154
|
-
|
|
155
|
-
return config;
|
|
156
199
|
}
|
|
157
200
|
|
|
158
201
|
export {
|
package/lib/cli.js
CHANGED
|
@@ -166,6 +166,11 @@ function addWPEnvCommands(){
|
|
|
166
166
|
'--xdebug <mode>',
|
|
167
167
|
'Enables Xdebug. If not passed, Xdebug is turned off. If no modes are set, uses "debug". You may set multiple Xdebug modes by passing them in a comma-separated list: `--xdebug=develop,coverage`. See https://xdebug.org/docs/all_settings#mode for information about Xdebug modes.',
|
|
168
168
|
)
|
|
169
|
+
.option(
|
|
170
|
+
'--spx',
|
|
171
|
+
'A simple profiling extension for PHP that provides low-overhead profiling with a built-in web UI.',
|
|
172
|
+
''
|
|
173
|
+
)
|
|
169
174
|
.option(
|
|
170
175
|
'--scripts',
|
|
171
176
|
'Execute any configured lifecycle scripts.',
|
|
@@ -298,15 +303,6 @@ function addWPEnvCommands(){
|
|
|
298
303
|
* Adds commands for wp instances
|
|
299
304
|
*/
|
|
300
305
|
function addWPInstanceCommands(){
|
|
301
|
-
// Update Plugins Command.
|
|
302
|
-
program.command('update-plugins')
|
|
303
|
-
.description('Updates all plugins in the WordPress environment.')
|
|
304
|
-
.argument('[slug]', 'Plugin slug to update.', 'all')
|
|
305
|
-
.addOption(new Option('--environment <env>', 'Which environment to use.').choices(['development', 'tests']).default('development'))
|
|
306
|
-
.allowUnknownOption(true)
|
|
307
|
-
.allowExcessArguments(true)
|
|
308
|
-
.action( withSpinner(env.updatePlugins) )
|
|
309
|
-
|
|
310
306
|
// Sync changes from one WordPress instance to another.
|
|
311
307
|
program.command('sync')
|
|
312
308
|
.description('Sync changes from one WordPress instance to another.')
|
package/lib/helpers.js
CHANGED
|
@@ -7,6 +7,8 @@ import spawn from 'cross-spawn';
|
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { sync as resolveBin } from 'resolve-bin';
|
|
9
9
|
import * as dockerCompose from 'docker-compose';
|
|
10
|
+
import { promisify } from 'util';
|
|
11
|
+
import crypto from 'crypto';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Internal dependencies
|
|
@@ -73,26 +75,29 @@ async function runCmd(cmd, args,opts = { stdio: 'pipe' }){
|
|
|
73
75
|
*
|
|
74
76
|
* @returns {Promise}
|
|
75
77
|
*/
|
|
76
|
-
async function runCLICmds(
|
|
78
|
+
async function runCLICmds({
|
|
77
79
|
environment,
|
|
78
80
|
cmds,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
) {
|
|
81
|
+
cwd,
|
|
82
|
+
debug = false
|
|
83
|
+
}) {
|
|
82
84
|
|
|
83
85
|
// We return the promise whether there is an output or an error.
|
|
84
86
|
return await dockerCompose.run(
|
|
85
87
|
environment === 'development' ? 'cli' : 'tests-cli',
|
|
86
88
|
[ 'bash', '-c', cmds.join( ' && ' ) ],
|
|
87
89
|
{
|
|
88
|
-
cwd
|
|
90
|
+
cwd,
|
|
89
91
|
env: process.env,
|
|
90
92
|
commandOptions: [],
|
|
91
|
-
log:
|
|
93
|
+
log: debug,
|
|
92
94
|
callback: (buffer, result) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
// Remove the Container information and new lines.
|
|
96
|
+
if ( 'stdout' === result && debug ){
|
|
97
|
+
// process.stdout.write( buffer.toString().replace(/\s*Container .*Running\n/g, '') );
|
|
98
|
+
// writeLine(buffer.toString().replace(/\s*Container .*Running\n|\n/g, ''), { color: 'red' });
|
|
95
99
|
}
|
|
100
|
+
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
).then(
|
|
@@ -105,14 +110,19 @@ async function runCLICmds(
|
|
|
105
110
|
},
|
|
106
111
|
(error) => {
|
|
107
112
|
// Remove the Container information and new lines.
|
|
108
|
-
error.err = error.err.replace(/\s*Container .*Running\n
|
|
113
|
+
error.err = error.err.replace(/\s*Container .*Running\n/g, '')
|
|
114
|
+
|
|
115
|
+
writeError(error.err);
|
|
109
116
|
|
|
110
|
-
|
|
117
|
+
if( debug ){
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}else{
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
111
122
|
}
|
|
112
123
|
);
|
|
113
124
|
}
|
|
114
125
|
|
|
115
|
-
|
|
116
126
|
/**
|
|
117
127
|
* Write a line to the console.
|
|
118
128
|
*
|
|
@@ -190,6 +200,20 @@ function clearLine(count = 1) {
|
|
|
190
200
|
} while (--count);
|
|
191
201
|
}
|
|
192
202
|
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Hashes the given string using the MD5 algorithm.
|
|
206
|
+
*
|
|
207
|
+
* @param {any} data The data to hash. If not a string, converted with JSON.stringify.
|
|
208
|
+
* @return {string} An MD5 hash string.
|
|
209
|
+
*/
|
|
210
|
+
function md5( data ) {
|
|
211
|
+
const convertedData =
|
|
212
|
+
typeof data === 'string' ? data : JSON.stringify( data );
|
|
213
|
+
|
|
214
|
+
return crypto.createHash( 'md5' ).update( convertedData ).digest( 'hex' );
|
|
215
|
+
}
|
|
216
|
+
|
|
193
217
|
export {
|
|
194
218
|
currentPath,
|
|
195
219
|
projectPath,
|
|
@@ -199,4 +223,5 @@ export {
|
|
|
199
223
|
writeLine,
|
|
200
224
|
writeError,
|
|
201
225
|
clearLine,
|
|
226
|
+
md5,
|
|
202
227
|
};
|
package/lib/index.js
CHANGED
|
@@ -16,15 +16,9 @@ import {
|
|
|
16
16
|
|
|
17
17
|
// WordPress
|
|
18
18
|
import {
|
|
19
|
-
activateCAWeb,
|
|
20
19
|
configureCAWeb,
|
|
21
|
-
downloadSources,
|
|
22
20
|
configureDivi,
|
|
23
|
-
isDiviThemeActive,
|
|
24
21
|
configureWordPress,
|
|
25
|
-
isMultisite,
|
|
26
|
-
convertToMultisite,
|
|
27
|
-
generateHTAccess,
|
|
28
22
|
getTaxonomies,
|
|
29
23
|
createTaxonomies,
|
|
30
24
|
CAWEB_OPTIONS,
|
|
@@ -41,15 +35,9 @@ export {
|
|
|
41
35
|
runCmd,
|
|
42
36
|
withSpinner,
|
|
43
37
|
runCLICmds,
|
|
44
|
-
activateCAWeb,
|
|
45
38
|
configureCAWeb,
|
|
46
|
-
downloadSources,
|
|
47
39
|
configureDivi,
|
|
48
|
-
isDiviThemeActive,
|
|
49
40
|
configureWordPress,
|
|
50
|
-
isMultisite,
|
|
51
|
-
convertToMultisite,
|
|
52
|
-
generateHTAccess,
|
|
53
41
|
getTaxonomies,
|
|
54
42
|
createTaxonomies,
|
|
55
43
|
CAWEB_OPTIONS,
|
package/lib/wordpress/index.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { isCAWebActive, configureCAWeb } from "./setup/caweb.js";
|
|
2
|
+
import { configureDivi } from "./setup/divi.js";
|
|
3
|
+
import {
|
|
4
|
+
configureWordPress
|
|
5
|
+
} from "./wordpress.js";
|
|
5
6
|
import { getTaxonomies, createTaxonomies } from "./api.js";
|
|
6
7
|
import { CAWEB_OPTIONS, DIVI_OPTIONS } from './options.js';
|
|
7
8
|
|
|
8
9
|
export {
|
|
9
|
-
|
|
10
|
+
isCAWebActive,
|
|
10
11
|
configureCAWeb,
|
|
11
|
-
downloadSources,
|
|
12
12
|
configureDivi,
|
|
13
|
-
isDiviThemeActive,
|
|
14
13
|
configureWordPress,
|
|
15
|
-
isMultisite,
|
|
16
|
-
convertToMultisite,
|
|
17
|
-
generateHTAccess,
|
|
18
14
|
getTaxonomies,
|
|
19
15
|
createTaxonomies,
|
|
20
16
|
CAWEB_OPTIONS,
|
package/lib/wordpress/options.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
let SYSTEM_OPTIONS = JSON.parse( fs.readFileSync( path.resolve('', 'package.json') ) ).config.DEFAULTS;
|
|
8
|
+
Object.entries( SYSTEM_OPTIONS ).forEach( ([key, value]) => {
|
|
9
|
+
SYSTEM_OPTIONS[key] = {
|
|
10
|
+
name: key.toLowerCase(),
|
|
11
|
+
defaultValue: value,
|
|
12
|
+
label: key
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
});
|
|
4
16
|
|
|
5
17
|
/**
|
|
6
18
|
* Missing options.
|
|
@@ -15,7 +27,7 @@
|
|
|
15
27
|
const caweb_general_options = {
|
|
16
28
|
CAWEB_FAV_ICON: {
|
|
17
29
|
name: 'ca_fav_ico',
|
|
18
|
-
defaultValue: '',
|
|
30
|
+
defaultValue: '/wp-content/themes/CAWeb/src/images/system/favicon.ico',
|
|
19
31
|
label: 'Fav Icon'
|
|
20
32
|
},
|
|
21
33
|
CAWEB_NAV_MENU_STYLE: {
|
|
@@ -107,12 +119,12 @@ const caweb_utility_header_options = {
|
|
|
107
119
|
const page_header_options = {
|
|
108
120
|
CAWEB_ORG_LOGO: {
|
|
109
121
|
name: 'header_ca_branding',
|
|
110
|
-
defaultValue: '',
|
|
122
|
+
defaultValue: '/wp-content/themes/CAWeb/src/images/system/caweb-logo.png',
|
|
111
123
|
label: 'Organization Logo-Brand'
|
|
112
124
|
},
|
|
113
125
|
CAWEB_ORG_LOGO_ALT_TEXT: {
|
|
114
126
|
name: 'header_ca_branding_alt_text',
|
|
115
|
-
defaultValue: '',
|
|
127
|
+
defaultValue: 'CAWebPublishing Logo',
|
|
116
128
|
label: 'Organization Logo-Alt Text'
|
|
117
129
|
}
|
|
118
130
|
};
|
|
@@ -258,5 +270,6 @@ const DIVI_OPTIONS = {
|
|
|
258
270
|
|
|
259
271
|
export {
|
|
260
272
|
CAWEB_OPTIONS,
|
|
261
|
-
DIVI_OPTIONS
|
|
273
|
+
DIVI_OPTIONS,
|
|
274
|
+
SYSTEM_OPTIONS
|
|
262
275
|
}
|