@caweb/cli 1.2.0 → 1.3.1
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/README.md +11 -6
- package/bin/caweb +1 -1
- package/bin/wp-cli.phar +0 -0
- package/commands/a11y.js +74 -0
- package/{lib/commands → commands}/blocks/create-block.js +7 -8
- package/{lib/commands → commands}/blocks/update-block.js +3 -9
- package/commands/build.js +73 -0
- package/{lib/commands → commands/env}/destroy.js +15 -22
- package/{lib/commands → commands/env}/start.js +41 -27
- package/{lib/commands → commands/env}/stop.js +4 -10
- package/{lib/commands → commands}/index.js +51 -43
- package/commands/serve.js +78 -0
- package/commands/sync.js +226 -0
- package/{lib/commands → commands}/tasks/update-plugins.js +2 -2
- package/commands/test.js +100 -0
- package/configs/aceconfig.js +28 -0
- package/{lib/configs.js → configs/docker-compose.js} +30 -83
- package/configs/webpack.config.js +119 -0
- package/configs/wp-env.js +76 -0
- package/gen/parser.js +166 -0
- package/gen/site-generator.js +111 -0
- package/lib/admin.js +1 -1
- package/lib/cli.js +106 -64
- package/lib/helpers.js +109 -0
- package/lib/index.js +53 -0
- package/lib/spinner.js +36 -8
- package/lib/wordpress/api.js +392 -0
- package/lib/{caweb.js → wordpress/caweb.js} +1 -1
- package/lib/{divi.js → wordpress/divi.js} +1 -1
- package/lib/{download-sources.js → wordpress/download-sources.js} +74 -78
- package/lib/wordpress/index.js +19 -0
- package/lib/{wordpress.js → wordpress/wordpress.js} +4 -8
- package/package.json +41 -27
- package/lib/commands/test.js +0 -46
- package/lib/utils.js +0 -150
- /package/{lib/commands → commands/tasks}/shell.js +0 -0
- /package/lib/{options.js → wordpress/options.js} +0 -0
- /package/{lib/template → template}/assets/css/popover.css +0 -0
- /package/{lib/template → template}/assets/js/popover.js +0 -0
- /package/{lib/template → template}/block/edit.js.mustache +0 -0
- /package/{lib/template → template}/block/editor.scss.mustache +0 -0
- /package/{lib/template → template}/block/index.js.mustache +0 -0
- /package/{lib/template → template}/block/save.js.mustache +0 -0
- /package/{lib/template → template}/block/style.scss.mustache +0 -0
- /package/{lib/template → template}/index.cjs +0 -0
- /package/{lib/template → template}/plugin/$slug.php.mustache +0 -0
- /package/{lib/template → template}/plugin/core/cdec-api.php.mustache +0 -0
- /package/{lib/template → template}/plugin/core/filters.php.mustache +0 -0
- /package/{lib/template → template}/plugin/core/functions.php.mustache +0 -0
- /package/{lib/template → template}/plugin/inc/renderer.php.mustache +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { activateCAWeb, configureCAWeb } from "./caweb.js";
|
|
2
|
+
import { downloadSources } from "./download-sources.js";
|
|
3
|
+
import { configureDivi, isDiviThemeActive } from "./divi.js";
|
|
4
|
+
import { configureWordPress, isMultisite, convertToMultisite, generateHTAccess } from "./wordpress.js";
|
|
5
|
+
import { getTaxonomies, createTaxonomies } from "./api.js";
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
activateCAWeb,
|
|
9
|
+
configureCAWeb,
|
|
10
|
+
downloadSources,
|
|
11
|
+
configureDivi,
|
|
12
|
+
isDiviThemeActive,
|
|
13
|
+
configureWordPress,
|
|
14
|
+
isMultisite,
|
|
15
|
+
convertToMultisite,
|
|
16
|
+
generateHTAccess,
|
|
17
|
+
getTaxonomies,
|
|
18
|
+
createTaxonomies
|
|
19
|
+
}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import fs from 'fs
|
|
5
|
-
import path from '
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {runCLICmds} from '
|
|
10
|
+
import {runCLICmds} from '../helpers.js';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Promisified dependencies
|
|
14
|
-
*/
|
|
15
|
-
const { writeFile } = fs.promises;
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* Checks whether WordPress environment is a multisite installation.
|
|
@@ -128,7 +124,7 @@ async function generateHTAccess(environment, workDirectoryPath, subdomain){
|
|
|
128
124
|
|
|
129
125
|
let folder = 'development' === environment ? 'WordPress' : 'Tests-WordPress'
|
|
130
126
|
|
|
131
|
-
|
|
127
|
+
fs.writeFileSync(path.join(workDirectoryPath, folder, '.htaccess'), htaccess);
|
|
132
128
|
|
|
133
129
|
}
|
|
134
130
|
|
package/package.json
CHANGED
|
@@ -1,53 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "CAWebPublishing Command Line Interface.",
|
|
5
5
|
"exports": "./lib/env.js",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"node": ">=
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"lib"
|
|
11
|
-
],
|
|
12
|
-
"directories": {
|
|
13
|
-
"doc": "docs",
|
|
14
|
-
"lib": "lib"
|
|
15
|
-
},
|
|
7
|
+
"node": ">=20",
|
|
8
|
+
"author": "CAWebPublishing",
|
|
9
|
+
"license": "ISC",
|
|
16
10
|
"bin": {
|
|
17
11
|
"caweb": "bin/caweb"
|
|
18
12
|
},
|
|
13
|
+
"files": [
|
|
14
|
+
"assets",
|
|
15
|
+
"bin",
|
|
16
|
+
"commands",
|
|
17
|
+
"configs",
|
|
18
|
+
"gen",
|
|
19
|
+
"lib",
|
|
20
|
+
"template"
|
|
21
|
+
],
|
|
19
22
|
"scripts": {
|
|
20
|
-
"caweb": "caweb",
|
|
21
|
-
"wp-env": "wp-env",
|
|
22
|
-
"local": "npm pack && npm i caweb-cli-%npm_package_version%.tgz",
|
|
23
23
|
"test": "echo \"Error: run tests from root\" && exit 0"
|
|
24
24
|
},
|
|
25
|
+
"homepage": "https://github.com/CAWebPublishing/caweb-cli#readme",
|
|
25
26
|
"repository": {
|
|
26
27
|
"type": "git",
|
|
27
28
|
"url": "git+https://github.com/CAWebPublishing/caweb-cli.git"
|
|
28
29
|
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/CAWebPublishing/caweb-cli/issues"
|
|
32
|
+
},
|
|
29
33
|
"keywords": [
|
|
30
34
|
"caweb",
|
|
31
35
|
"cagov"
|
|
32
36
|
],
|
|
33
|
-
"author": "CAWebPublishing",
|
|
34
|
-
"license": "ISC",
|
|
35
|
-
"bugs": {
|
|
36
|
-
"url": "https://github.com/CAWebPublishing/caweb-cli/issues"
|
|
37
|
-
},
|
|
38
37
|
"publishConfig": {
|
|
39
38
|
"access": "public"
|
|
40
39
|
},
|
|
41
|
-
"homepage": "https://github.com/CAWebPublishing/caweb-cli#readme",
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"@wordpress/create-block": "^4.32.0",
|
|
44
|
-
"@wordpress/env": "^9.0.0",
|
|
45
|
-
"chalk": "^4.0.0",
|
|
46
|
-
"commander": "^11.1.0",
|
|
47
|
-
"fs-extra": "^11.1.1"
|
|
48
|
-
},
|
|
49
40
|
"config": {
|
|
50
|
-
"WP_VER": "6.4.
|
|
41
|
+
"WP_VER": "6.4.3",
|
|
51
42
|
"PHP_VER": "8.1",
|
|
52
43
|
"CREATE_BLOCK_VER": "4.32.0",
|
|
53
44
|
"DEFAULTS": {
|
|
@@ -64,5 +55,28 @@
|
|
|
64
55
|
"SITECOOKIEPATH": "",
|
|
65
56
|
"CONCATENATE_SCRIPTS": false
|
|
66
57
|
}
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@wordpress/env": "^9.4.0",
|
|
61
|
+
"@wordpress/scripts": "^27.3.0",
|
|
62
|
+
"accessibility-checker": "^3.1.67",
|
|
63
|
+
"autoprefixer": "^10.4.17",
|
|
64
|
+
"axios": "^1.6.7",
|
|
65
|
+
"chalk": "^5.3.0",
|
|
66
|
+
"commander": "^12.0.0",
|
|
67
|
+
"cross-spawn": "^7.0.3",
|
|
68
|
+
"css-loader": "^6.10.0",
|
|
69
|
+
"docker-compose": "^0.24.6",
|
|
70
|
+
"handlebars-loader": "^1.7.3",
|
|
71
|
+
"html-to-json-parser": "^2.0.1",
|
|
72
|
+
"html-webpack-plugin": "^5.6.0",
|
|
73
|
+
"mini-css-extract-plugin": "^2.8.0",
|
|
74
|
+
"ora": "^8.0.1",
|
|
75
|
+
"postcss-loader": "^8.1.0",
|
|
76
|
+
"resolve-bin": "^1.0.1",
|
|
77
|
+
"sass-loader": "^14.1.1",
|
|
78
|
+
"terminal-link": "^3.0.0",
|
|
79
|
+
"url": "^0.11.3",
|
|
80
|
+
"webpack": "^5.90.3"
|
|
67
81
|
}
|
|
68
82
|
}
|
package/lib/commands/test.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import loadConfig from '@wordpress/env/lib/config/load-config.js';
|
|
6
|
-
import fs from 'fs-extra';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { runCLICmds, runCmd } from '../utils.js';
|
|
12
|
-
import generateOverridesMD from '../admin.js';
|
|
13
|
-
import { CAWEB_OPTIONS, DIVI_OPTIONS } from '../options.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Promisified dependencies
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Test code.
|
|
21
|
-
*
|
|
22
|
-
* @param {Object} options
|
|
23
|
-
* @param {Object} options.spinner A CLI spinner which indicates progress.
|
|
24
|
-
* @param {boolean} options.environment Which environment to test in.
|
|
25
|
-
* @param {boolean} options.debug True if debug mode is enabled.
|
|
26
|
-
*/
|
|
27
|
-
export default async function test({
|
|
28
|
-
spinner,
|
|
29
|
-
debug,
|
|
30
|
-
environment
|
|
31
|
-
} ) {
|
|
32
|
-
|
|
33
|
-
spinner.text = "Testing Code Functionality";
|
|
34
|
-
const config = await loadConfig(path.resolve('.'));
|
|
35
|
-
|
|
36
|
-
let result = await runCLICmds(
|
|
37
|
-
'development',
|
|
38
|
-
['wp --version'],
|
|
39
|
-
config,
|
|
40
|
-
spinner
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
console.log( result );
|
|
45
|
-
|
|
46
|
-
};
|
package/lib/utils.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { spawn } from 'node:child_process';
|
|
5
|
-
import dockerCompose from 'docker-compose';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import loadConfig from '@wordpress/env/lib/config/load-config.js';
|
|
8
|
-
import getHostUser from '@wordpress/env/lib/get-host-user.js';
|
|
9
|
-
import { env } from 'node:process';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Runs commands on the given WordPress environment.
|
|
18
|
-
*
|
|
19
|
-
* @param {string} environment Which environment to run docker command on.
|
|
20
|
-
* @param {string[]} cmds Array of commands to run.
|
|
21
|
-
* @param {WPConfig} config The wp-env config object.
|
|
22
|
-
* @param {Object} spinner A CLI spinner which indicates progress.
|
|
23
|
-
*
|
|
24
|
-
* @returns {Promise}
|
|
25
|
-
*/
|
|
26
|
-
async function runCLICmds(
|
|
27
|
-
environment,
|
|
28
|
-
cmds,
|
|
29
|
-
config,
|
|
30
|
-
spinner
|
|
31
|
-
) {
|
|
32
|
-
|
|
33
|
-
// We return the promise whether there is an output or an error.
|
|
34
|
-
return await dockerCompose.run(
|
|
35
|
-
environment === 'development' ? 'cli' : 'tests-cli',
|
|
36
|
-
[ 'bash', '-c', cmds.join( ' && ' ) ],
|
|
37
|
-
{
|
|
38
|
-
cwd: config.workDirectoryPath,
|
|
39
|
-
commandOptions: [],
|
|
40
|
-
log: config.debug,
|
|
41
|
-
callback: (buffer, result) => {
|
|
42
|
-
if( config.debug ){
|
|
43
|
-
spinner.text = buffer.toString();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
).then(
|
|
48
|
-
(output) => {
|
|
49
|
-
// Remove the Container information and new lines.
|
|
50
|
-
output.err = output.err.replace(/\s*Container .*Running\n|\n/g, '')
|
|
51
|
-
output.out = output.out.replace(/\s*Container .*Running\n|\n/g, '')
|
|
52
|
-
|
|
53
|
-
return '' !== output.out ? output.out : output.err;
|
|
54
|
-
},
|
|
55
|
-
(error) => {
|
|
56
|
-
// Remove the Container information and new lines.
|
|
57
|
-
error.err = error.err.replace(/\s*Container .*Running\n|\n/g, '')
|
|
58
|
-
|
|
59
|
-
return error;
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Runs command directly.
|
|
67
|
-
*
|
|
68
|
-
* @param {string} cmd Command to run.
|
|
69
|
-
* @param {string[]} args List of command arguments.
|
|
70
|
-
* @param {string[]} opts List of spawn options.
|
|
71
|
-
* @param {Object} spinner A CLI spinner which indicates progress.
|
|
72
|
-
* @param {boolean} debug True if debug mode is enabled.
|
|
73
|
-
*
|
|
74
|
-
* @returns {Promise}
|
|
75
|
-
*/
|
|
76
|
-
async function runCmd(cmd, args,spinner, opts = { stdio: 'pipe' }, debug = false){
|
|
77
|
-
// fix various commands.
|
|
78
|
-
switch (cmd) {
|
|
79
|
-
case 'npm':
|
|
80
|
-
case 'npx':
|
|
81
|
-
/**
|
|
82
|
-
* On Windows we run npm.cmd, on Linux we run npm
|
|
83
|
-
*/
|
|
84
|
-
cmd += /^win/.test(process.platform) ? '.cmd' : '';
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// save output for handling
|
|
89
|
-
let output = opts.stdio;
|
|
90
|
-
|
|
91
|
-
return await new Promise( (resolve, reject) => {
|
|
92
|
-
let result = [];
|
|
93
|
-
const childProc = spawn(
|
|
94
|
-
cmd,
|
|
95
|
-
args,
|
|
96
|
-
{
|
|
97
|
-
...opts,
|
|
98
|
-
stdio: 'pipe' // output is always piped and handled when stdout receives data.
|
|
99
|
-
},
|
|
100
|
-
spinner
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
childProc.stdout.on( 'data', (data) => {
|
|
104
|
-
// remove new lines from data
|
|
105
|
-
data = data.toString().replace('\n', '');
|
|
106
|
-
|
|
107
|
-
// push all data to results array if piping data
|
|
108
|
-
if( '\n' !== data && '' !== data && data.length ){
|
|
109
|
-
// output accordingly.
|
|
110
|
-
switch( output ){
|
|
111
|
-
case 'initial': // write output to spinner text
|
|
112
|
-
spinner.text = data;
|
|
113
|
-
case 'inherit': // write output to persistent spinner text
|
|
114
|
-
spinner.stopAndPersist({
|
|
115
|
-
text: data
|
|
116
|
-
});
|
|
117
|
-
break;
|
|
118
|
-
case 'pipe': // save output to result array and output on exit
|
|
119
|
-
default:
|
|
120
|
-
result.push( data );
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
childProc.on( 'error', reject );
|
|
127
|
-
childProc.on( 'exit', ( code ) => {
|
|
128
|
-
// resolved with no issues return result array
|
|
129
|
-
if ( code === 0 ) {
|
|
130
|
-
resolve(result.join('\n'));
|
|
131
|
-
// if there was an error
|
|
132
|
-
} else {
|
|
133
|
-
if( debug ){
|
|
134
|
-
// if debugging return exit code
|
|
135
|
-
reject( `Command failed with exit code ${ code }` );
|
|
136
|
-
}else{
|
|
137
|
-
// resolve as false.
|
|
138
|
-
resolve(false);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
} );
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export {
|
|
148
|
-
runCLICmds,
|
|
149
|
-
runCmd
|
|
150
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|