chisel-scripts 2.0.0-alpha.3.1 → 2.0.0-alpha.4
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/CHANGELOG.md +5 -0
- package/index.js +50 -1
- package/lib/commands/wp-config.js +40 -22
- package/lib/template/dev-vhost.chisel-tpl.conf +1 -1
- package/lib/template/wp-config-local.chisel-tpl.php +6 -2
- package/package.json +3 -3
- package/yarn-error.log +15044 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- INSERT-NEW-ENTRIES-HERE -->
|
|
4
4
|
|
|
5
|
+
## 2.0.0-alpha.4 (2024-11-12)
|
|
6
|
+
|
|
7
|
+
- V2: Add Devcontainers (#538) ([b878421](https://github.com/xfiveco/generator-chisel/commit/b878421)), closes [#538](https://github.com/xfiveco/generator-chisel/issues/538)
|
|
8
|
+
- composer, wp-config, plugins list updates ([642f983](https://github.com/xfiveco/generator-chisel/commit/642f983))
|
|
9
|
+
|
|
5
10
|
## 2.0.0-alpha.3.1 (2024-10-31)
|
|
6
11
|
|
|
7
12
|
- add assets index ([fed4fd3](https://github.com/xfiveco/generator-chisel/commit/fed4fd3))
|
package/index.js
CHANGED
|
@@ -37,6 +37,29 @@ function adjustWebpackConfig(baseConfig, directory) {
|
|
|
37
37
|
...entriesFromFiles(stylesFiles),
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const getUrl = (() => {
|
|
41
|
+
let url;
|
|
42
|
+
|
|
43
|
+
return () =>
|
|
44
|
+
(url ||= (() => {
|
|
45
|
+
const { execFileSync } = require('node:child_process');
|
|
46
|
+
try {
|
|
47
|
+
const stdout = execFileSync(
|
|
48
|
+
'npm',
|
|
49
|
+
['run', '--silent', 'wp', 'option', 'get', 'home'],
|
|
50
|
+
{
|
|
51
|
+
cwd: directory,
|
|
52
|
+
encoding: 'utf8',
|
|
53
|
+
shell: true,
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
return stdout.trim();
|
|
57
|
+
} catch (e) {
|
|
58
|
+
throw new Error('Failed to get current website url', { cause: e });
|
|
59
|
+
}
|
|
60
|
+
})());
|
|
61
|
+
})();
|
|
62
|
+
|
|
40
63
|
const updatedConfig = {
|
|
41
64
|
...baseConfig,
|
|
42
65
|
entry,
|
|
@@ -49,7 +72,33 @@ function adjustWebpackConfig(baseConfig, directory) {
|
|
|
49
72
|
},
|
|
50
73
|
devServer: baseConfig.devServer && {
|
|
51
74
|
...baseConfig.devServer,
|
|
52
|
-
allowedHosts: [new URL(
|
|
75
|
+
allowedHosts: [new URL(getUrl()).host],
|
|
76
|
+
...(process.env.CHISEL_PORT && {
|
|
77
|
+
host: '0.0.0.0',
|
|
78
|
+
port: Number(process.env.CHISEL_PORT) + 1,
|
|
79
|
+
...(() => {
|
|
80
|
+
const webSocketURL = new URL(getUrl());
|
|
81
|
+
webSocketURL.protocol = webSocketURL.protocol.replace('http', 'ws');
|
|
82
|
+
webSocketURL.pathname = '/ws';
|
|
83
|
+
const webSocketURLString = webSocketURL.toString();
|
|
84
|
+
|
|
85
|
+
if (!webSocketURLString.includes(process.env.CHISEL_PORT)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
client: {
|
|
91
|
+
...baseConfig.devServer.client,
|
|
92
|
+
webSocketURL: webSocketURL
|
|
93
|
+
.toString()
|
|
94
|
+
.replace(
|
|
95
|
+
process.env.CHISEL_PORT,
|
|
96
|
+
Number(process.env.CHISEL_PORT) + 1,
|
|
97
|
+
),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
})(),
|
|
101
|
+
}),
|
|
53
102
|
},
|
|
54
103
|
optimization: {
|
|
55
104
|
...baseConfig.optimization,
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
+
const devContainerDefaultDatabaseCredentials = {
|
|
2
|
+
databaseHost: 'db',
|
|
3
|
+
databasePort: 3306,
|
|
4
|
+
databaseName: 'mariadb',
|
|
5
|
+
databaseUser: 'mariadb',
|
|
6
|
+
databasePassword: 'mariadb',
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
module.exports = (api, options) => {
|
|
2
10
|
api.registerCommand(
|
|
3
11
|
'wp-config',
|
|
4
12
|
(command) =>
|
|
5
|
-
command
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
command
|
|
14
|
+
.description(
|
|
15
|
+
'configure WP (writes wp/wp-config-local.php an dev-vhost.conf)',
|
|
16
|
+
)
|
|
17
|
+
.option('--devcontainer', 'use default database credentials', false),
|
|
18
|
+
async ({ devcontainer }) => {
|
|
9
19
|
const { runLocal, copy } = require('chisel-shared-utils');
|
|
10
20
|
const wp = (args, opts) =>
|
|
11
21
|
runLocal(['chisel-scripts', 'wp', ...args], {
|
|
@@ -45,7 +55,9 @@ module.exports = (api, options) => {
|
|
|
45
55
|
];
|
|
46
56
|
|
|
47
57
|
const promptAndCreateDB = async () => {
|
|
48
|
-
const answers =
|
|
58
|
+
const answers = devcontainer
|
|
59
|
+
? devContainerDefaultDatabaseCredentials
|
|
60
|
+
: await inquirer.prompt(prompts);
|
|
49
61
|
|
|
50
62
|
answers.databaseHostPort = `${answers.databaseHost}:${answers.databasePort}`;
|
|
51
63
|
|
|
@@ -54,15 +66,17 @@ module.exports = (api, options) => {
|
|
|
54
66
|
console.log('Creating database...');
|
|
55
67
|
console.log(api.resolve());
|
|
56
68
|
|
|
69
|
+
const templateData = {
|
|
70
|
+
...answers,
|
|
71
|
+
documentRoot: api.resolveRoot(),
|
|
72
|
+
tablePrefix,
|
|
73
|
+
codespaces: process.env.CODESPACES === 'true',
|
|
74
|
+
};
|
|
75
|
+
|
|
57
76
|
await copy({
|
|
58
77
|
from: path.join(__dirname, '../template'),
|
|
59
78
|
to: api.resolveRoot(),
|
|
60
|
-
templateData
|
|
61
|
-
...answers,
|
|
62
|
-
documentRoot: api.resolveRoot(),
|
|
63
|
-
serverName: new URL(url).hostname,
|
|
64
|
-
tablePrefix,
|
|
65
|
-
},
|
|
79
|
+
templateData,
|
|
66
80
|
});
|
|
67
81
|
|
|
68
82
|
const res = await wp(['db', 'query', 'SELECT 1'], {
|
|
@@ -81,7 +95,7 @@ module.exports = (api, options) => {
|
|
|
81
95
|
console.log(res.stderr);
|
|
82
96
|
throw res;
|
|
83
97
|
}
|
|
84
|
-
} else {
|
|
98
|
+
} else if (!devcontainer) {
|
|
85
99
|
// exists
|
|
86
100
|
const { useExisting } = await inquirer.prompt([
|
|
87
101
|
{
|
|
@@ -99,16 +113,20 @@ module.exports = (api, options) => {
|
|
|
99
113
|
}
|
|
100
114
|
};
|
|
101
115
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
if (devcontainer) {
|
|
117
|
+
await promptAndCreateDB();
|
|
118
|
+
} else {
|
|
119
|
+
// eslint-disable-next-line no-constant-condition
|
|
120
|
+
while (true) {
|
|
121
|
+
try {
|
|
122
|
+
await promptAndCreateDB();
|
|
123
|
+
break;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
console.log(e); // TODO: remove
|
|
126
|
+
console.log('');
|
|
127
|
+
console.log('Trying again...');
|
|
128
|
+
console.log('');
|
|
129
|
+
}
|
|
112
130
|
}
|
|
113
131
|
}
|
|
114
132
|
},
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
* * External settings when needed
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
<% if (codespaces) { %>
|
|
13
|
+
// Adjustment for Codespaces
|
|
14
|
+
$_SERVER['HTTPS'] = 'on';
|
|
15
|
+
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
|
|
16
|
+
<% } %>
|
|
13
17
|
// ** MySQL settings - You can get this info from your web host ** //
|
|
14
18
|
/** The name of the database for WordPress */
|
|
15
19
|
define( 'DB_NAME', '<%= databaseName %>' );
|
|
@@ -47,9 +51,9 @@ $table_prefix = '<%= tablePrefix %>';
|
|
|
47
51
|
define( 'WP_DEBUG', true );
|
|
48
52
|
define( 'WP_DEBUG_LOG', true );
|
|
49
53
|
define( 'WP_DEBUG_DISPLAY', true );
|
|
50
|
-
define( 'SCRIPT_DEBUG', true );
|
|
51
54
|
|
|
52
55
|
// Required for the theme fast refresh mode.
|
|
56
|
+
define( 'SCRIPT_DEBUG', true );
|
|
53
57
|
define( 'WP_ENVIRONMENT_TYPE', 'development' );
|
|
54
58
|
|
|
55
59
|
/** The Database Collate type. Don't change this if in doubt. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chisel-scripts",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.4",
|
|
4
4
|
"description": "TODO",
|
|
5
5
|
"bin": {
|
|
6
6
|
"chisel-scripts": "bin/chisel-scripts.js"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/xfiveco/generator-chisel/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"chisel-shared-utils": "^2.0.0-alpha.
|
|
28
|
+
"chisel-shared-utils": "^2.0.0-alpha.1",
|
|
29
29
|
"chokidar": "^3.6.0",
|
|
30
30
|
"commander": "^5.1.0",
|
|
31
31
|
"fast-glob": "^3.3.2",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@wordpress/scripts": "^27.9.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "3209b735b8259ad3296f477cfe13ad3a14d130a9"
|
|
42
42
|
}
|