wp-lemon-create 2.2.0 → 3.0.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/lib/actions/create-bedrock.js +395 -0
- package/lib/actions/create-vanilla.js +286 -0
- package/lib/composer.json +55 -0
- package/lib/index.js +14 -403
- package/package.json +1 -1
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
var shell = require('shelljs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const prompt = require('prompt-sync')();
|
|
4
|
+
const rootPath = path.basename(path.resolve());
|
|
5
|
+
let project_name = rootPath;
|
|
6
|
+
let project_repository = '';
|
|
7
|
+
let project_url = '';
|
|
8
|
+
let username = '';
|
|
9
|
+
let email = '';
|
|
10
|
+
let password = '';
|
|
11
|
+
let DBuser = '';
|
|
12
|
+
let DBpassword = '';
|
|
13
|
+
let is_wsl = false;
|
|
14
|
+
let child_theme_folder = '';
|
|
15
|
+
let plugins_searchwp = false;
|
|
16
|
+
let plugins_wpml = false;
|
|
17
|
+
let is_spinup = false;
|
|
18
|
+
let skipGit = false;
|
|
19
|
+
let branch = false;
|
|
20
|
+
let version_constraints = '*';
|
|
21
|
+
let package_manager = false;
|
|
22
|
+
const hasYarn = shell.which('yarn');
|
|
23
|
+
const hasNpm = shell.which('npm');
|
|
24
|
+
|
|
25
|
+
function createBedrock() {
|
|
26
|
+
if (!shell.which('git')) {
|
|
27
|
+
shell.echo('Sorry, this script requires git');
|
|
28
|
+
shell.exit(1);
|
|
29
|
+
}
|
|
30
|
+
{
|
|
31
|
+
shell.echo('✔️ Git installed');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!shell.which('composer')) {
|
|
35
|
+
shell.echo('Sorry, this script requires composer');
|
|
36
|
+
}
|
|
37
|
+
{
|
|
38
|
+
shell.echo('✔️ Composer installed');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!hasYarn && !hasNpm) {
|
|
42
|
+
shell.echo('Yarn and npm are both missing. Please install one of them.');
|
|
43
|
+
shell.exit(1);
|
|
44
|
+
} else {
|
|
45
|
+
shell.echo(`✔️ ${hasYarn ? 'Yarn' : 'Npm'} installed`);
|
|
46
|
+
package_manager = hasYarn ? 'yarn' : 'npm';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!shell.which('wp')) {
|
|
50
|
+
shell.echo('Sorry, this script requires wp cli');
|
|
51
|
+
shell.exit(1);
|
|
52
|
+
}
|
|
53
|
+
{
|
|
54
|
+
shell.echo('✔️ wp-cli installed');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (shell.exec('wp dotenv --help', { silent: true }).code !== 0) {
|
|
58
|
+
shell.echo('Sorry, this script requires wp-cli dotenv package');
|
|
59
|
+
shell.exit(1);
|
|
60
|
+
}
|
|
61
|
+
{
|
|
62
|
+
shell.echo('✔️ wp-cli dotenv package installed');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (shell.exec('grep -q Microsoft /proc/version', { silent: true }).code == 0) {
|
|
66
|
+
is_wsl = true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
shell.echo('\n');
|
|
70
|
+
project_name = prompt(`What is the project name (only lowercase and -, no spaces. Do not add tld (.local/.test), defaults to ${project_name}:`, project_name);
|
|
71
|
+
const tld = prompt('What is the project tld? (defaults to .local):', '.local');
|
|
72
|
+
|
|
73
|
+
child_theme_folder = project_name; // update child theme folder name
|
|
74
|
+
project_url = project_name + tld; // set project url
|
|
75
|
+
shell.echo('"' + project_name + '" is the project name');
|
|
76
|
+
|
|
77
|
+
const project_type = prompt('Project type? new or existing (defaults to new):', 'new');
|
|
78
|
+
shell.echo('\n');
|
|
79
|
+
|
|
80
|
+
if (project_type == 'new') {
|
|
81
|
+
shell.echo('Please create a new Git repository and fill in the link in ssh format.');
|
|
82
|
+
project_repository = prompt('Git repository link or enter "none" to skip GIT setup:', 'none');
|
|
83
|
+
username = prompt('WordPress username:');
|
|
84
|
+
email = prompt('WordPress email:');
|
|
85
|
+
password = prompt('WordPress password:', { echo: '*' });
|
|
86
|
+
plugins_searchwp = prompt('Add plugin: SearchWP? yes/no (defaults to no)', 'no');
|
|
87
|
+
plugins_wpml = prompt('Add plugin: WPML? yes/no (defaults to no)', 'no');
|
|
88
|
+
is_spinup = prompt('Does the project run on Spinup-wp? (defaults to no)', 'no');
|
|
89
|
+
//is_beta = prompt('Is this a beta project? (defaults to no)', 'no');
|
|
90
|
+
|
|
91
|
+
if (project_repository == 'none') {
|
|
92
|
+
skipGit = true;
|
|
93
|
+
}
|
|
94
|
+
} else if (project_type == 'existing') {
|
|
95
|
+
project_repository = prompt('Existing repository link in ssh format:');
|
|
96
|
+
branch = prompt('Branch to checkout (defaults to master):', 'master');
|
|
97
|
+
} else {
|
|
98
|
+
shell.echo('no valid command. Exiting.');
|
|
99
|
+
shell.exit(1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
DBuser = prompt('Database user. Defaults to root:', 'root');
|
|
103
|
+
DBpassword = prompt('Database password. Defaults to root:', 'root');
|
|
104
|
+
|
|
105
|
+
shell.echo('\n');
|
|
106
|
+
shell.echo(`🎉 Setting up ${project_type} wp-lemon project with url ${project_url} \n`);
|
|
107
|
+
|
|
108
|
+
if (project_type == 'new') {
|
|
109
|
+
|
|
110
|
+
//if (is_beta) {
|
|
111
|
+
// version_constraints = '^4@beta';
|
|
112
|
+
//}
|
|
113
|
+
|
|
114
|
+
shell.echo('⏳ Downloading Bedrock. This may take a minute or so.\n');
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* cloning bedrock and removing unneeded dirs
|
|
118
|
+
*/
|
|
119
|
+
shell.exec('composer create-project roots/bedrock .', { silent: true });
|
|
120
|
+
shell.echo('✔️ Bedrock installed.\n');
|
|
121
|
+
shell.rm('-rf', 'CHANGELOG.MD');
|
|
122
|
+
shell.rm('-rf', 'LICENSE.MD');
|
|
123
|
+
shell.rm('-rf', 'composer.lock');
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Add bulldozer extended config
|
|
127
|
+
*/
|
|
128
|
+
shell.sed('-i', 'env;', 'env;\nuse HighGround\\Bulldozer\\Bulldozer;\n', 'config/application.php');
|
|
129
|
+
shell.exec(`sed -i "/'production');/a Bulldozer::extend_roots_config();" config/application.php`, { silent: true });
|
|
130
|
+
/**
|
|
131
|
+
* configuring composer
|
|
132
|
+
*/
|
|
133
|
+
shell.exec('composer config repositories.1 composer https://packagist.studiolemon.nl/satispress/', { silent: true });
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Add composer packages
|
|
137
|
+
*/
|
|
138
|
+
shell.echo('⏳ Installing plugins, parent theme and packages. This may take a while\n');
|
|
139
|
+
|
|
140
|
+
shell.exec('composer require composer/installers ~1.0', { silent: true });
|
|
141
|
+
shell.exec('"roots/wordpress', { silent: true });
|
|
142
|
+
// Add libraries and parent theme
|
|
143
|
+
shell.exec(`composer require highground/bulldozer giggsey/libphonenumber-for-php timber/timber satispress/wp-lemon:${version_constraints} --with-all-dependencies`, { silent: true });
|
|
144
|
+
|
|
145
|
+
shell.exec(
|
|
146
|
+
'composer require satispress/advanced-custom-fields-pro satispress/fluentformpro satispress/quartermaster satispress/wp-migrate-db-pro wpackagist-plugin/limit-login-attempts-reloaded log1x/acf-editor-palette wpackagist-plugin/fluentform wpackagist-plugin/seo-by-rank-math wpackagist-plugin/simple-custom-post-order wpackagist-plugin/worker wpackagist-plugin/fluent-smtp --with-all-dependencies',
|
|
147
|
+
{ silent: true },
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
shell.exec('composer require roots/wordpress:^6.2', { silent: true });
|
|
151
|
+
shell.exec('composer remove wpackagist-theme/twentytwentythree', { silent: true });
|
|
152
|
+
|
|
153
|
+
shell.exec('composer remove squizlabs/php_codesnifferes roave/security-advisories', { silent: true });
|
|
154
|
+
|
|
155
|
+
if (is_spinup == 'yes') {
|
|
156
|
+
shell.exec('composer require wpackagist-plugin/spinupwp', { silent: true });
|
|
157
|
+
} else {
|
|
158
|
+
shell.exec('composer require satispress/wp-rocket', { silent: true });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (plugins_searchwp == 'yes') {
|
|
162
|
+
shell.exec('composer require satispress/searchwp wpackagist-plugin/searchwp-live-ajax-search', { silent: true });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (plugins_wpml == 'yes') {
|
|
166
|
+
shell.exec('composer require satispress/sitepress-multilingual-cms satispress/acfml satispress/wpml-string-translation', { silent: true });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
shell.echo('✔️ Installing plugins, master theme and packages done \n');
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Git init & add repository
|
|
173
|
+
*/
|
|
174
|
+
if (!skipGit) {
|
|
175
|
+
shell.exec('git init', { silent: true });
|
|
176
|
+
shell.exec(`git remote add origin ${project_repository} `);
|
|
177
|
+
shell.echo(`✔️ Setting up empty local git repository and adding ${project_repository} as remote.\n`);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Git ignore
|
|
182
|
+
*/
|
|
183
|
+
shell.exec("echo '.vscode/*' >> .gitignore");
|
|
184
|
+
shell.exec("echo 'web/app/themes/wp-lemon' >> .gitignore");
|
|
185
|
+
shell.exec("echo 'web/app/wp-rocket-config/' >> .gitignore");
|
|
186
|
+
shell.exec("echo 'web/app/cache' >> .gitignore");
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Downloading child theme
|
|
190
|
+
*/
|
|
191
|
+
shell.echo('⏳ Downloading child theme.\n');
|
|
192
|
+
shell.cd('web/app/themes/');
|
|
193
|
+
|
|
194
|
+
shell.exec(`composer create-project --repository https://packagist.studiolemon.nl/satispress/ satispress/wp-lemon-child:${version_constraints} ${child_theme_folder} --no-dev`, { silent: true });
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
shell.cd(child_theme_folder);
|
|
199
|
+
shell.rm('-rf', '.github');
|
|
200
|
+
shell.echo('✔️ Downloading child theme succesful.');
|
|
201
|
+
} else {
|
|
202
|
+
/**
|
|
203
|
+
* Task: existing project.
|
|
204
|
+
*/
|
|
205
|
+
shell.echo(`Cloning repository from : ${project_repository}`);
|
|
206
|
+
|
|
207
|
+
if (shell.exec(`git clone ${project_repository} .`).code !== 0) {
|
|
208
|
+
shell.echo('Error: Git clone failed');
|
|
209
|
+
shell.exit(1);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (branch) {
|
|
213
|
+
shell.echo(`Checking out branch: ${branch}`);
|
|
214
|
+
shell.exec(`git checkout ${branch}`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
shell.cd('web/app/themes/');
|
|
218
|
+
if (shell.cd(child_theme_folder).code !== 0) {
|
|
219
|
+
shell.echo('Error: Child theme not found');
|
|
220
|
+
child_theme_folder = prompt('Folder name of child theme:');
|
|
221
|
+
shell.cd(child_theme_folder);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Create child theme config file
|
|
226
|
+
*/
|
|
227
|
+
shell.cp('resources/assets/config.json.example', 'resources/assets/config.json');
|
|
228
|
+
shell.sed('-i', 'http://wplemon.local', `http://${project_url}`, 'resources/assets/config.json');
|
|
229
|
+
shell.sed('-i', 'wp-lemon-child', child_theme_folder, 'resources/assets/config.json');
|
|
230
|
+
shell.sed('-i', 'wp-lemon child', project_name, 'style.css');
|
|
231
|
+
shell.echo('✔️ Configuring child theme succesful.\n');
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Installing node modules in child theme and parent theme.
|
|
235
|
+
*/
|
|
236
|
+
shell.echo('⏳ Installing npm dependencies. This may take a while.\n');
|
|
237
|
+
if (shell.exec(`${package_manager} run bootstrap-project`, { silent: true }).code !== 0) {
|
|
238
|
+
shell.echo(`Error: ${package_manager} run bootstrap-project failed. Please install node dependencies manually by running ${package_manager} run bootstrap-project in your child theme.`);
|
|
239
|
+
} else {
|
|
240
|
+
shell.echo('✔️ Installing npm dependencies succesful.');
|
|
241
|
+
shell.exec(`${package_manager} run dev`, { silent: true });
|
|
242
|
+
shell.echo('✔️ First webpack build succesful.\n');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Wait until user adds site and presses a key.
|
|
247
|
+
*/
|
|
248
|
+
prompt('Script will generate .env file. Please add your new site to your AMP stack before pressing enter to continue.');
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* cd back to root folder.
|
|
252
|
+
*/
|
|
253
|
+
shell.cd('../../../../');
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* reload host file so browsersync works without a restart.
|
|
258
|
+
*/
|
|
259
|
+
if (is_wsl) {
|
|
260
|
+
shell.exec('sudo cp /mnt/c/Windows/System32/drivers/etc/hosts /etc/hosts');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Creating .env file
|
|
265
|
+
*/
|
|
266
|
+
shell.echo('Creating .env file\n');
|
|
267
|
+
shell.exec(`wp dotenv init --template=.env.example --with-salts`, { silent: true });
|
|
268
|
+
shell.exec(`wp dotenv set DB_NAME ${project_name}`, { silent: true });
|
|
269
|
+
shell.exec(`wp dotenv set DB_USER ${DBuser}`, { silent: true });
|
|
270
|
+
shell.exec(`wp dotenv set DB_PASSWORD ${DBpassword}`, { silent: true });
|
|
271
|
+
shell.exec(`wp dotenv set WP_HOME http://${project_url}`, { silent: true });
|
|
272
|
+
shell.exec(`wp dotenv salts generate`, { silent: true });
|
|
273
|
+
shell.echo('✔️ Generating .env successful.\n');
|
|
274
|
+
|
|
275
|
+
if (is_wsl) {
|
|
276
|
+
shell.echo('Uncommenting #DB_host and changing to 127.0.0.1 for allowing connection in WSL\n');
|
|
277
|
+
shell.sed('-i', '# DB_HOST', 'DB_HOST', '.env');
|
|
278
|
+
shell.sed('-i', 'localhost', '127.0.0.1', '.env');
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (project_type == 'new') {
|
|
282
|
+
shell.echo('⏳ Installing WordPress.\n');
|
|
283
|
+
|
|
284
|
+
shell.exec(`touch workspace.code-workspace`);
|
|
285
|
+
shell.exec(`echo '{
|
|
286
|
+
"folders": [
|
|
287
|
+
{
|
|
288
|
+
"name": "root",
|
|
289
|
+
"path": "."
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"name": "${project_name}",
|
|
293
|
+
"path": "web/app/themes/${project_name}"
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
}' >> workspace.code-workspace`);
|
|
297
|
+
shell.echo('✔️ .code-workspace file created.\n');
|
|
298
|
+
|
|
299
|
+
if (shell.exec(`wp db create`, { silent: true }).code !== 0) {
|
|
300
|
+
prompt('Database creation failed. Please make sure your server is running. Press enter to continue.');
|
|
301
|
+
createDB();
|
|
302
|
+
} else {
|
|
303
|
+
shell.echo('✔️ Database created');
|
|
304
|
+
setupWordPress();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
} else {
|
|
309
|
+
shell.echo('Creating Database.\n');
|
|
310
|
+
|
|
311
|
+
if (shell.exec(`wp db create`, { silent: true }).code !== 0) {
|
|
312
|
+
prompt('Database creation failed. Please make sure your server is running. Press enter to continue.');
|
|
313
|
+
|
|
314
|
+
} else {
|
|
315
|
+
shell.echo('✔️ Database created.');
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Wait until user adds site and presses a key.
|
|
320
|
+
*/
|
|
321
|
+
shell.echo('You can import your database by placing the .sql dump in the project root and run wp db import databasename.sql.');
|
|
322
|
+
prompt('Please import your database and uploads. After that press enter to continue.');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Flush rewrite rules
|
|
326
|
+
shell.exec(`wp rewrite flush`);
|
|
327
|
+
|
|
328
|
+
shell.echo(`\n`);
|
|
329
|
+
shell.echo(`🎉 All done! Happy developing!`);
|
|
330
|
+
shell.echo(`🌐 You can now navigate to http://${project_url}`);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
exports.createBedrock = createBedrock;
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
function createDB() {
|
|
338
|
+
if (shell.exec(`wp db create`, { silent: true }).code !== 0) {
|
|
339
|
+
prompt('Database creation failed. Please make sure your server is running. Press enter to continue.');
|
|
340
|
+
} else {
|
|
341
|
+
shell.echo('✔️ Database created');
|
|
342
|
+
setupWordPress();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
function setupWordPress() {
|
|
349
|
+
if (
|
|
350
|
+
shell.exec(
|
|
351
|
+
`wp core install --skip-email --url='http://${project_url}' --title='${project_name}' --admin_user='${username}' --admin_password='${password}' --admin_email='${email}'`,
|
|
352
|
+
{ silent: true },
|
|
353
|
+
).code !== 0
|
|
354
|
+
) {
|
|
355
|
+
shell.echo('Error: Installing WordPress failed.');
|
|
356
|
+
shell.exit(1);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
shell.echo('✔️ Installing WordPress succesful.');
|
|
360
|
+
shell.exec(`wp rewrite structure '/%postname%/'`, { silent: true });
|
|
361
|
+
shell.echo('✔️ Setting permalink structure.');
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
// Set language
|
|
365
|
+
shell.exec(`wp language core install nl_NL`, { silent: true });
|
|
366
|
+
shell.exec(`wp language core activate nl_NL`, { silent: true });
|
|
367
|
+
shell.exec(`wp language plugin install nl_NL --all`, { silent: true });
|
|
368
|
+
shell.echo('✔️ Installed Dutch language.');
|
|
369
|
+
|
|
370
|
+
// activate plugins
|
|
371
|
+
shell.exec(`wp plugin activate fluentform`, { silent: true });
|
|
372
|
+
shell.exec(`wp plugin activate fluentformpro`, { silent: true });
|
|
373
|
+
shell.exec(`wp plugin activate advanced-custom-fields-pro`, { silent: true });
|
|
374
|
+
shell.exec(`wp plugin activate quartermaster`, { silent: true });
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
shell.exec(`wp theme activate ${child_theme_folder}`, { silent: true });
|
|
378
|
+
shell.echo(`✔️ Activating child theme ${child_theme_folder}`);
|
|
379
|
+
|
|
380
|
+
shell.exec(`wp post update 2 --post_title='Home'`, { silent: true });
|
|
381
|
+
shell.exec(`wp option update show_on_front 'page'`, { silent: true });
|
|
382
|
+
shell.exec(`wp option update timezone_string 'Europe/Amsterdam'`, { silent: true });
|
|
383
|
+
shell.exec(`wp option update page_on_front 2`, { silent: true });
|
|
384
|
+
shell.exec(`wp post delete 1 --force`, { silent: true });
|
|
385
|
+
shell.exec(`wp comment delete 1 --force`, { silent: true });
|
|
386
|
+
shell.echo('✔️ Create homepage and set as front-page.');
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
// set menu
|
|
390
|
+
shell.exec(`wp menu create "Hoofdmenu"`, { silent: true });
|
|
391
|
+
shell.exec(`wp menu item add-post Hoofdmenu 2`, { silent: true });
|
|
392
|
+
shell.exec(`wp menu location assign Hoofdmenu primary_navigation`, { silent: true });
|
|
393
|
+
shell.echo('✔️ Created primary menu.');
|
|
394
|
+
|
|
395
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
var shell = require('shelljs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const prompt = require('prompt-sync')();
|
|
4
|
+
const rootPath = path.basename(path.resolve());
|
|
5
|
+
|
|
6
|
+
const dirname = path.dirname(__filename);
|
|
7
|
+
const packageRoot = path.resolve(dirname, '../');
|
|
8
|
+
|
|
9
|
+
let project_name = rootPath;
|
|
10
|
+
let project_repository = '';
|
|
11
|
+
let project_url = '';
|
|
12
|
+
let DBuser = '';
|
|
13
|
+
let DBpassword = '';
|
|
14
|
+
let child_theme_folder = '';
|
|
15
|
+
let skipGit = false;
|
|
16
|
+
let branch = false;
|
|
17
|
+
let version_constraints = '*';
|
|
18
|
+
let package_manager = false;
|
|
19
|
+
const hasYarn = shell.which('yarn');
|
|
20
|
+
const hasNpm = shell.which('npm');
|
|
21
|
+
|
|
22
|
+
function createVanilla() {
|
|
23
|
+
if (!shell.which('git')) {
|
|
24
|
+
shell.echo('Sorry, this script requires git');
|
|
25
|
+
shell.exit(1);
|
|
26
|
+
}
|
|
27
|
+
{
|
|
28
|
+
shell.echo('✔️ Git installed');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!shell.which('composer')) {
|
|
32
|
+
shell.echo('Sorry, this script requires composer');
|
|
33
|
+
}
|
|
34
|
+
{
|
|
35
|
+
shell.echo('✔️ Composer installed');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!hasYarn && !hasNpm) {
|
|
39
|
+
shell.echo('Yarn and npm are both missing. Please install one of them.');
|
|
40
|
+
shell.exit(1);
|
|
41
|
+
} else {
|
|
42
|
+
shell.echo(`✔️ ${hasYarn ? 'Yarn' : 'Npm'} installed`);
|
|
43
|
+
package_manager = hasYarn ? 'yarn' : 'npm';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!shell.which('wp')) {
|
|
47
|
+
shell.echo('Sorry, this script requires wp cli');
|
|
48
|
+
shell.exit(1);
|
|
49
|
+
}
|
|
50
|
+
{
|
|
51
|
+
shell.echo('✔️ wp-cli installed');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (shell.exec('wp dotenv --help', { silent: true }).code !== 0) {
|
|
55
|
+
shell.echo('Sorry, this script requires wp-cli dotenv package');
|
|
56
|
+
shell.exit(1);
|
|
57
|
+
}
|
|
58
|
+
{
|
|
59
|
+
shell.echo('✔️ wp-cli dotenv package installed');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
shell.echo('\n');
|
|
63
|
+
project_name = prompt(`What is the project name (only lowercase and -, no spaces. Do not add tld (.local/.test), defaults to ${project_name}:`, project_name);
|
|
64
|
+
const tld = prompt('What is the project tld? (defaults to .local):', '.local');
|
|
65
|
+
|
|
66
|
+
child_theme_folder = project_name; // update child theme folder name
|
|
67
|
+
project_url = project_name + tld; // set project url
|
|
68
|
+
shell.echo('"' + project_name + '" is the project name');
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
const project_type = prompt('Project type? new or existing (defaults to new):', 'new');
|
|
72
|
+
shell.echo('\n');
|
|
73
|
+
|
|
74
|
+
if (project_type == 'new') {
|
|
75
|
+
shell.echo('Please create a new Git repository and fill in the link in ssh format.');
|
|
76
|
+
project_repository = prompt('Git repository link or enter "none" to skip GIT setup:', 'none');
|
|
77
|
+
|
|
78
|
+
if (project_repository == 'none') {
|
|
79
|
+
skipGit = true;
|
|
80
|
+
}
|
|
81
|
+
} else if (project_type == 'existing') {
|
|
82
|
+
project_repository = prompt('Existing repository link in ssh format:');
|
|
83
|
+
branch = prompt('Branch to checkout (defaults to main):', 'main');
|
|
84
|
+
} else {
|
|
85
|
+
shell.echo('no valid command. Exiting.');
|
|
86
|
+
shell.exit(1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
DBuser = prompt('Database user. Defaults to root:', 'root');
|
|
90
|
+
DBpassword = prompt('Database password. Defaults to root:', 'root');
|
|
91
|
+
|
|
92
|
+
shell.echo('\n');
|
|
93
|
+
shell.echo(`🎉 Setting up ${project_type} wp-lemon project with url ${project_url} \n`);
|
|
94
|
+
|
|
95
|
+
if (project_type == 'new') {
|
|
96
|
+
|
|
97
|
+
shell.echo('⏳ Downloading WordPress. This may take a minute or so.\n');
|
|
98
|
+
|
|
99
|
+
shell.exec('wp core download', { silent: true });
|
|
100
|
+
shell.exec('wp config create --dbname=' + project_name + ' --dbuser=' + DBuser + ' --dbpass=' + DBpassword, { silent: true });
|
|
101
|
+
shell.echo('✔️ WordPress installed.\n');
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Git ignore
|
|
105
|
+
*/
|
|
106
|
+
shell.echo('⏳ Setting up .gitignore file.\n');
|
|
107
|
+
shell.exec('touch .gitignore');
|
|
108
|
+
|
|
109
|
+
shell.exec("echo '.vscode/*' >> .gitignore");
|
|
110
|
+
shell.exec("echo 'vendor' >> .gitignore");
|
|
111
|
+
shell.exec("echo 'wp-*.php' >> .gitignore");
|
|
112
|
+
shell.exec("echo 'index.php' >> .gitignore");
|
|
113
|
+
shell.exec("echo 'license.txt' >> .gitignore");
|
|
114
|
+
shell.exec("echo 'readme.html' >> .gitignore");
|
|
115
|
+
shell.exec("echo 'xmlrpc.php' >> .gitignore");
|
|
116
|
+
shell.exec("echo 'wp-content/themes/wp-lemon' >> .gitignore");
|
|
117
|
+
shell.exec("echo 'wp-content/themes/twenty*' >> .gitignore");
|
|
118
|
+
shell.exec("echo 'wp-content/themes/index.php' >> .gitignore");
|
|
119
|
+
shell.exec("echo 'wp-content/wp-rocket-config/' >> .gitignore");
|
|
120
|
+
shell.exec("echo 'wp-content/plugins/*' >> .gitignore");
|
|
121
|
+
shell.exec("echo 'wp-content/cache' >> .gitignore");
|
|
122
|
+
shell.exec("echo 'wp-content/uploads' >> .gitignore");
|
|
123
|
+
shell.exec("echo 'wp-content/upgrade' >> .gitignore");
|
|
124
|
+
shell.exec("echo 'wp-admin' >> .gitignore");
|
|
125
|
+
shell.exec("echo 'wp-includes' >> .gitignore");
|
|
126
|
+
shell.exec("echo 'wp-config.php' >> .gitignore");
|
|
127
|
+
|
|
128
|
+
// copy ../composer.json to rootPath
|
|
129
|
+
shell.cp(path.resolve(packageRoot, 'composer.json'), path.resolve() + '/composer.json');
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Add composer packages
|
|
133
|
+
*/
|
|
134
|
+
shell.echo('⏳ Installing plugins, parent theme and packages. This may take a while\n');
|
|
135
|
+
|
|
136
|
+
// Add libraries and parent theme
|
|
137
|
+
shell.exec(`composer require highground/bulldozer giggsey/libphonenumber-for-php timber/timber satispress/wp-lemon --with-all-dependencies`, { silent: true });
|
|
138
|
+
|
|
139
|
+
shell.exec(
|
|
140
|
+
'composer require satispress/advanced-custom-fields-pro satispress/fluentformpro satispress/quartermaster satispress/wp-migrate-db-pro wpackagist-plugin/limit-login-attempts-reloaded log1x/acf-editor-palette wpackagist-plugin/fluentform wpackagist-plugin/seo-by-rank-math wpackagist-plugin/simple-custom-post-order wpackagist-plugin/worker wpackagist-plugin/fluent-smtp --with-all-dependencies',
|
|
141
|
+
{ silent: true },
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
shell.echo('✔️ Installing plugins, master theme and packages done \n');
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Git init & add repository
|
|
148
|
+
*/
|
|
149
|
+
if (!skipGit) {
|
|
150
|
+
shell.exec('git init', { silent: true });
|
|
151
|
+
shell.exec(`git remote add origin ${project_repository} `);
|
|
152
|
+
shell.echo(`✔️ Setting up empty local git repository and adding ${project_repository} as remote.\n`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
// in index.php add the following line to the top of the file: require_once __DIR__ . '/vendor/autoload.php';
|
|
157
|
+
shell.exec("echo 'require_once __DIR__ . \'/vendor/autoload.php\';' >> index.php");
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Downloading child theme
|
|
162
|
+
*/
|
|
163
|
+
shell.echo('⏳ Downloading child theme.\n');
|
|
164
|
+
shell.cd('wp-content/themes/');
|
|
165
|
+
|
|
166
|
+
shell.exec(`composer create-project --repository https://packagist.studiolemon.nl/satispress/ satispress/wp-lemon-child:${version_constraints} ${child_theme_folder} --no-dev`, { silent: true });
|
|
167
|
+
|
|
168
|
+
shell.cd(child_theme_folder);
|
|
169
|
+
shell.rm('-rf', '.github');
|
|
170
|
+
shell.echo('✔️ Downloading child theme succesful.');
|
|
171
|
+
|
|
172
|
+
shell.sed('-i', '../../../../', '../../../', 'package.json');
|
|
173
|
+
} else {
|
|
174
|
+
/**
|
|
175
|
+
* Task: existing project.
|
|
176
|
+
*/
|
|
177
|
+
shell.echo(`Cloning repository from : ${project_repository}`);
|
|
178
|
+
|
|
179
|
+
if (shell.exec(`git clone ${project_repository} .`).code !== 0) {
|
|
180
|
+
shell.echo('Error: Git clone failed');
|
|
181
|
+
shell.exit(1);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (branch) {
|
|
185
|
+
shell.echo(`Checking out branch: ${branch}`);
|
|
186
|
+
shell.exec(`git checkout ${branch}`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
shell.exec('wp core download', { silent: true });
|
|
190
|
+
shell.exec('wp config create --dbname=' + project_name + ' --dbuser=' + DBuser + ' --dbpass=' + DBpassword, { silent: true });
|
|
191
|
+
|
|
192
|
+
shell.cd('wp-content/themes/');
|
|
193
|
+
if (shell.cd(child_theme_folder).code !== 0) {
|
|
194
|
+
shell.echo('Error: Child theme not found');
|
|
195
|
+
child_theme_folder = prompt('Folder name of child theme:');
|
|
196
|
+
shell.cd(child_theme_folder);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
shell.cp('resources/assets/config.json.example', 'resources/assets/config.json');
|
|
201
|
+
shell.sed('-i', 'http://wplemon.local', `http://${project_url}`, 'resources/assets/config.json');
|
|
202
|
+
shell.sed('-i', 'wp-lemon-child', child_theme_folder, 'resources/assets/config.json');
|
|
203
|
+
shell.sed('-i', 'wp-lemon child', project_name, 'style.css');
|
|
204
|
+
shell.echo('✔️ Configuring child theme succesful.\n');
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Installing node modules in child theme and parent theme.
|
|
208
|
+
*/
|
|
209
|
+
shell.echo('⏳ Installing npm dependencies. This may take a while.\n');
|
|
210
|
+
if (shell.exec(`${package_manager} run bootstrap-project`, { silent: true }).code !== 0) {
|
|
211
|
+
shell.echo(`Error: ${package_manager} run bootstrap-project failed. Please install node dependencies manually by running ${package_manager} run bootstrap-project in your child theme.`);
|
|
212
|
+
} else {
|
|
213
|
+
shell.echo('✔️ Installing npm dependencies succesful.');
|
|
214
|
+
shell.exec(`${package_manager} run dev`, { silent: true });
|
|
215
|
+
shell.echo('✔️ First webpack build succesful.\n');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* cd back to root folder.
|
|
221
|
+
*/
|
|
222
|
+
shell.cd('../../../');
|
|
223
|
+
|
|
224
|
+
if (project_type == 'new') {
|
|
225
|
+
shell.echo('⏳ Installing WordPress.\n');
|
|
226
|
+
|
|
227
|
+
shell.exec(`touch workspace.code-workspace`);
|
|
228
|
+
shell.exec(`echo '{
|
|
229
|
+
"folders": [
|
|
230
|
+
{
|
|
231
|
+
"name": "root",
|
|
232
|
+
"path": "."
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"name": "${project_name}",
|
|
236
|
+
"path": "wp-content/themes/${project_name}"
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}' >> workspace.code-workspace`);
|
|
240
|
+
shell.echo('✔️ .code-workspace file created.\n');
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
shell.echo(`Please navigate to http://${project_url} and finish the WordPress installation.`);
|
|
244
|
+
prompt('Press enter once you are done.');
|
|
245
|
+
|
|
246
|
+
shell.exec(`wp rewrite structure '/%postname%/'`, { silent: true });
|
|
247
|
+
shell.echo('✔️ Setting permalink structure.');
|
|
248
|
+
|
|
249
|
+
shell.exec(`wp language core install nl_NL`, { silent: true });
|
|
250
|
+
shell.exec(`wp language core activate nl_NL`, { silent: true });
|
|
251
|
+
shell.exec(`wp language plugin install nl_NL --all`, { silent: true });
|
|
252
|
+
shell.echo('✔️ Installed Dutch language.');
|
|
253
|
+
|
|
254
|
+
shell.exec(`wp plugin activate fluentform`, { silent: true });
|
|
255
|
+
shell.exec(`wp plugin activate fluentformpro`, { silent: true });
|
|
256
|
+
shell.exec(`wp plugin activate advanced-custom-fields-pro`, { silent: true });
|
|
257
|
+
shell.exec(`wp plugin activate quartermaster`, { silent: true });
|
|
258
|
+
|
|
259
|
+
shell.exec(`wp theme activate ${child_theme_folder}`, { silent: true });
|
|
260
|
+
shell.echo(`✔️ Activating child theme ${child_theme_folder}`);
|
|
261
|
+
|
|
262
|
+
shell.exec(`wp post update 2 --post_title='Home'`, { silent: true });
|
|
263
|
+
shell.exec(`wp option update show_on_front 'page'`, { silent: true });
|
|
264
|
+
shell.exec(`wp option update timezone_string 'Europe/Amsterdam'`, { silent: true });
|
|
265
|
+
shell.exec(`wp option update page_on_front 2`, { silent: true });
|
|
266
|
+
shell.exec(`wp post delete 1 --force`, { silent: true });
|
|
267
|
+
shell.exec(`wp comment delete 1 --force`, { silent: true });
|
|
268
|
+
shell.echo('✔️ Create homepage and set as front-page.');
|
|
269
|
+
|
|
270
|
+
} else {
|
|
271
|
+
/**
|
|
272
|
+
* Wait until user adds site and presses a key.
|
|
273
|
+
*/
|
|
274
|
+
shell.echo('You can import your database by placing the .sql dump in the project root and run wp db import databasename.sql.');
|
|
275
|
+
prompt('Please import your database and uploads. After that press enter to continue.');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Flush rewrite rules
|
|
279
|
+
shell.exec(`wp rewrite flush`);
|
|
280
|
+
|
|
281
|
+
shell.echo(`\n`);
|
|
282
|
+
shell.echo(`🎉 All done! Happy developing!`);
|
|
283
|
+
shell.echo(`🌐 You can now navigate to http://${project_url}`);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
exports.createVanilla = createVanilla;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "project",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure",
|
|
5
|
+
"repositories": [
|
|
6
|
+
{
|
|
7
|
+
"type": "composer",
|
|
8
|
+
"url": "https://wpackagist.org"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "composer",
|
|
12
|
+
"url": "https://packagist.studiolemon.nl/satispress/"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"require": {
|
|
16
|
+
"php": ">=8.1",
|
|
17
|
+
"composer/installers": "^1.0 || ^2.0"
|
|
18
|
+
},
|
|
19
|
+
"require-dev": {
|
|
20
|
+
"phpcompatibility/php-compatibility": "^9.3",
|
|
21
|
+
"squizlabs/php_codesniffer": "^3.6",
|
|
22
|
+
"wpackagist-plugin/fakerpress": "^0.5.0"
|
|
23
|
+
},
|
|
24
|
+
"config": {
|
|
25
|
+
"optimize-autoloader": true,
|
|
26
|
+
"preferred-install": "dist",
|
|
27
|
+
"sort-packages": true,
|
|
28
|
+
"allow-plugins": {
|
|
29
|
+
"composer/installers": true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"prefer-stable": true,
|
|
33
|
+
"extra": {
|
|
34
|
+
"installer-paths": {
|
|
35
|
+
"wp-content/mu-plugins/{$name}/": [
|
|
36
|
+
"type:wordpress-muplugin"
|
|
37
|
+
],
|
|
38
|
+
"wp-content/plugins/{$name}/": [
|
|
39
|
+
"type:wordpress-plugin"
|
|
40
|
+
],
|
|
41
|
+
"wp-content/themes/{$name}/": [
|
|
42
|
+
"type:wordpress-theme"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"post-root-package-install": [
|
|
48
|
+
"php -r \"copy('.env.example', '.env');\""
|
|
49
|
+
],
|
|
50
|
+
"test": [
|
|
51
|
+
"phpcs"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
package/lib/index.js
CHANGED
|
@@ -2,418 +2,29 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
const { program } = require('commander');
|
|
5
|
-
var shell = require('shelljs');
|
|
6
5
|
const commandName = 'wp-lemon-create';
|
|
7
6
|
const { engines, version } = require('../package.json');
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const rootPath = path.basename(path.resolve());
|
|
11
|
-
|
|
12
|
-
let project_name = rootPath;
|
|
13
|
-
let project_repository = '';
|
|
14
|
-
let project_url = '';
|
|
15
|
-
let username = '';
|
|
16
|
-
let email = '';
|
|
17
|
-
let password = '';
|
|
18
|
-
let DBuser = '';
|
|
19
|
-
let DBpassword = '';
|
|
20
|
-
let is_wsl = false;
|
|
21
|
-
let child_theme_folder = '';
|
|
22
|
-
let plugins_searchwp = false;
|
|
23
|
-
let plugins_wpml = false;
|
|
24
|
-
let is_spinup = false;
|
|
25
|
-
let skipGit = false;
|
|
26
|
-
let branch = false;
|
|
27
|
-
let version_constraints = '*';
|
|
28
|
-
let package_manager = false;
|
|
29
|
-
const hasYarn = shell.which('yarn');
|
|
30
|
-
const hasNpm = shell.which('npm');
|
|
7
|
+
const { createBedrock } = require('./actions/create-bedrock');
|
|
8
|
+
const { createVanilla } = require('./actions/create-vanilla');
|
|
31
9
|
|
|
32
10
|
program
|
|
33
11
|
.name(commandName)
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
'[slug] is optional. When provided it triggers the quick mode where ' +
|
|
37
|
-
'it is used as the block slug used for its identification, the output ' +
|
|
38
|
-
'location for scaffolded files, and the name of the WordPress plugin.' +
|
|
39
|
-
'The rest of the configuration is set to all default values unless ' +
|
|
40
|
-
'overridden with some of the options listed below.',
|
|
41
|
-
)
|
|
12
|
+
.command('create', { isDefault: true })
|
|
13
|
+
.description('Create a new environment based on bedrock')
|
|
42
14
|
.version(version)
|
|
43
15
|
.action((name, options, command) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (project_name.endsWith('.local')) {
|
|
47
|
-
project_name = project_name.substring(0, project_name.length - 6);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
16
|
console.log(`Starting $${commandName} @${version}`);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
shell.echo('Sorry, this script requires git');
|
|
54
|
-
shell.exit(1);
|
|
55
|
-
}
|
|
56
|
-
{
|
|
57
|
-
shell.echo('✔️ Git installed');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!shell.which('composer')) {
|
|
61
|
-
shell.echo('Sorry, this script requires composer');
|
|
62
|
-
}
|
|
63
|
-
{
|
|
64
|
-
shell.echo('✔️ Composer installed');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!hasYarn && !hasNpm) {
|
|
68
|
-
shell.echo('Yarn and npm are both missing. Please install one of them.');
|
|
69
|
-
shell.exit(1);
|
|
70
|
-
} else {
|
|
71
|
-
shell.echo(`✔️ ${hasYarn ? 'Yarn' : 'Npm'} installed`);
|
|
72
|
-
package_manager = hasYarn ? 'yarn' : 'npm';
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (!shell.which('wp')) {
|
|
76
|
-
shell.echo('Sorry, this script requires wp cli');
|
|
77
|
-
shell.exit(1);
|
|
78
|
-
}
|
|
79
|
-
{
|
|
80
|
-
shell.echo('✔️ wp-cli installed');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (shell.exec('wp dotenv --help', { silent: true }).code !== 0) {
|
|
84
|
-
shell.echo('Sorry, this script requires wp-cli dotenv package');
|
|
85
|
-
shell.exit(1);
|
|
86
|
-
}
|
|
87
|
-
{
|
|
88
|
-
shell.echo('✔️ wp-cli dotenv package installed');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (shell.exec('grep -q Microsoft /proc/version', { silent: true }).code == 0) {
|
|
92
|
-
is_wsl = true;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
shell.echo('\n');
|
|
96
|
-
project_name = prompt(`What is the project name (only lowercase and -, no spaces. Do not add tld (.local/.test), defaults to ${project_name}:`, project_name);
|
|
97
|
-
const tld = prompt('What is the project tld? (defaults to .local):', '.local');
|
|
98
|
-
|
|
99
|
-
child_theme_folder = project_name; // update child theme folder name
|
|
100
|
-
project_url = project_name + tld; // set project url
|
|
101
|
-
shell.echo('"' + project_name + '" is the project name');
|
|
102
|
-
|
|
103
|
-
const project_type = prompt('Project type? new or existing (defaults to new):', 'new');
|
|
104
|
-
shell.echo('\n');
|
|
105
|
-
|
|
106
|
-
if (project_type == 'new') {
|
|
107
|
-
shell.echo('Please create a new Git repository and fill in the link in ssh format.');
|
|
108
|
-
project_repository = prompt('Git repository link or enter "none" to skip GIT setup:', 'none');
|
|
109
|
-
username = prompt('WordPress username:');
|
|
110
|
-
email = prompt('WordPress email:');
|
|
111
|
-
password = prompt('WordPress password:', { echo: '*' });
|
|
112
|
-
plugins_searchwp = prompt('Add plugin: SearchWP? yes/no (defaults to no)', 'no');
|
|
113
|
-
plugins_wpml = prompt('Add plugin: WPML? yes/no (defaults to no)', 'no');
|
|
114
|
-
is_spinup = prompt('Does the project run on Spinup-wp? (defaults to no)', 'no');
|
|
115
|
-
//is_beta = prompt('Is this a beta project? (defaults to no)', 'no');
|
|
116
|
-
|
|
117
|
-
if (project_repository == 'none') {
|
|
118
|
-
skipGit = true;
|
|
119
|
-
}
|
|
120
|
-
} else if (project_type == 'existing') {
|
|
121
|
-
project_repository = prompt('Existing repository link in ssh format:');
|
|
122
|
-
branch = prompt('Branch to checkout (defaults to master):', 'master');
|
|
123
|
-
} else {
|
|
124
|
-
shell.echo('no valid command. Exiting.');
|
|
125
|
-
shell.exit(1);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
DBuser = prompt('Database user. Defaults to root:', 'root');
|
|
129
|
-
DBpassword = prompt('Database password. Defaults to root:', 'root');
|
|
130
|
-
|
|
131
|
-
shell.echo('\n');
|
|
132
|
-
shell.echo(`🎉 Setting up ${project_type} wp-lemon project with url ${project_url} \n`);
|
|
133
|
-
|
|
134
|
-
if (project_type == 'new') {
|
|
135
|
-
|
|
136
|
-
//if (is_beta) {
|
|
137
|
-
// version_constraints = '^4@beta';
|
|
138
|
-
//}
|
|
139
|
-
|
|
140
|
-
shell.echo('⏳ Downloading Bedrock. This may take a minute or so.\n');
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* cloning bedrock and removing unneeded dirs
|
|
144
|
-
*/
|
|
145
|
-
shell.exec('composer create-project roots/bedrock .', { silent: true });
|
|
146
|
-
shell.echo('✔️ Bedrock installed.\n');
|
|
147
|
-
shell.rm('-rf', 'CHANGELOG.MD');
|
|
148
|
-
shell.rm('-rf', 'LICENSE.MD');
|
|
149
|
-
shell.rm('-rf', 'composer.lock');
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Add bulldozer extended config
|
|
153
|
-
*/
|
|
154
|
-
shell.sed('-i', 'env;', 'env;\nuse HighGround\\Bulldozer\\Bulldozer;\n', 'config/application.php');
|
|
155
|
-
shell.exec(`sed -i "/'production');/a Bulldozer::extend_roots_config();" config/application.php`, { silent: true });
|
|
156
|
-
/**
|
|
157
|
-
* configuring composer
|
|
158
|
-
*/
|
|
159
|
-
shell.exec('composer config repositories.1 composer https://packagist.studiolemon.nl/satispress/', { silent: true });
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Add composer packages
|
|
163
|
-
*/
|
|
164
|
-
shell.echo('⏳ Installing plugins, parent theme and packages. This may take a while\n');
|
|
165
|
-
|
|
166
|
-
shell.exec('composer require composer/installers ~1.0', { silent: true });
|
|
167
|
-
shell.exec('"roots/wordpress', { silent: true });
|
|
168
|
-
// Add libraries and parent theme
|
|
169
|
-
shell.exec(`composer require highground/bulldozer giggsey/libphonenumber-for-php timber/timber satispress/wp-lemon:${version_constraints} --with-all-dependencies`, { silent: true });
|
|
170
|
-
|
|
171
|
-
shell.exec(
|
|
172
|
-
'composer require satispress/advanced-custom-fields-pro satispress/fluentformpro satispress/quartermaster satispress/wp-migrate-db-pro wpackagist-plugin/limit-login-attempts-reloaded log1x/acf-editor-palette wpackagist-plugin/fluentform wpackagist-plugin/seo-by-rank-math wpackagist-plugin/simple-custom-post-order wpackagist-plugin/worker wpackagist-plugin/fluent-smtp --with-all-dependencies',
|
|
173
|
-
{ silent: true },
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
shell.exec('composer require roots/wordpress:^6.2', { silent: true });
|
|
177
|
-
shell.exec('composer remove wpackagist-theme/twentytwentythree', { silent: true });
|
|
178
|
-
|
|
179
|
-
shell.exec('composer remove squizlabs/php_codesnifferes roave/security-advisories', { silent: true });
|
|
180
|
-
|
|
181
|
-
if (is_spinup == 'yes') {
|
|
182
|
-
shell.exec('composer require wpackagist-plugin/spinupwp', { silent: true });
|
|
183
|
-
} else {
|
|
184
|
-
shell.exec('composer require satispress/wp-rocket', { silent: true });
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (plugins_searchwp == 'yes') {
|
|
188
|
-
shell.exec('composer require satispress/searchwp wpackagist-plugin/searchwp-live-ajax-search', { silent: true });
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (plugins_wpml == 'yes') {
|
|
192
|
-
shell.exec('composer require satispress/sitepress-multilingual-cms satispress/acfml satispress/wpml-string-translation', { silent: true });
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
shell.echo('✔️ Installing plugins, master theme and packages done \n');
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Git init & add repository
|
|
199
|
-
*/
|
|
200
|
-
if (!skipGit) {
|
|
201
|
-
shell.exec('git init', { silent: true });
|
|
202
|
-
shell.exec(`git remote add origin ${project_repository} `);
|
|
203
|
-
shell.echo(`✔️ Setting up empty local git repository and adding ${project_repository} as remote.\n`);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Git ignore
|
|
208
|
-
*/
|
|
209
|
-
shell.exec("echo '.vscode/*' >> .gitignore");
|
|
210
|
-
shell.exec("echo 'web/app/themes/wp-lemon' >> .gitignore");
|
|
211
|
-
shell.exec("echo 'web/app/wp-rocket-config/' >> .gitignore");
|
|
212
|
-
shell.exec("echo 'web/app/cache' >> .gitignore");
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Downloading child theme
|
|
216
|
-
*/
|
|
217
|
-
shell.echo('⏳ Downloading child theme.\n');
|
|
218
|
-
shell.cd('web/app/themes/');
|
|
219
|
-
|
|
220
|
-
shell.exec(`composer create-project --repository https://packagist.studiolemon.nl/satispress/ satispress/wp-lemon-child:${version_constraints} ${child_theme_folder} --no-dev`, { silent: true });
|
|
17
|
+
createBedrock();
|
|
18
|
+
});
|
|
221
19
|
|
|
222
20
|
|
|
21
|
+
program
|
|
22
|
+
.command('vanilla')
|
|
23
|
+
.description('Create a new environment based on vanilla WordPress')
|
|
24
|
+
.action(() => {
|
|
25
|
+
console.log(`Starting ${commandName} @${version} - Vanilla`);
|
|
26
|
+
createVanilla();
|
|
27
|
+
});
|
|
223
28
|
|
|
224
|
-
shell.cd(child_theme_folder);
|
|
225
|
-
shell.rm('-rf', '.github');
|
|
226
|
-
shell.echo('✔️ Downloading child theme succesful.');
|
|
227
|
-
} else {
|
|
228
|
-
/**
|
|
229
|
-
* Task: existing project.
|
|
230
|
-
*/
|
|
231
|
-
shell.echo(`Cloning repository from : ${project_repository}`);
|
|
232
|
-
|
|
233
|
-
if (shell.exec(`git clone ${project_repository} .`).code !== 0) {
|
|
234
|
-
shell.echo('Error: Git clone failed');
|
|
235
|
-
shell.exit(1);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (branch) {
|
|
239
|
-
shell.echo(`Checking out branch: ${branch}`);
|
|
240
|
-
shell.exec(`git checkout ${branch}`);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
shell.cd('web/app/themes/');
|
|
244
|
-
if (shell.cd(child_theme_folder).code !== 0) {
|
|
245
|
-
shell.echo('Error: Child theme not found');
|
|
246
|
-
child_theme_folder = prompt('Folder name of child theme:');
|
|
247
|
-
shell.cd(child_theme_folder);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Create child theme config file
|
|
252
|
-
*/
|
|
253
|
-
shell.cp('resources/assets/config.json.example', 'resources/assets/config.json');
|
|
254
|
-
shell.sed('-i', 'http://wplemon.local', `http://${project_url}`, 'resources/assets/config.json');
|
|
255
|
-
shell.sed('-i', 'wp-lemon-child', child_theme_folder, 'resources/assets/config.json');
|
|
256
|
-
shell.sed('-i', 'wp-lemon child', project_name, 'style.css');
|
|
257
|
-
shell.echo('✔️ Configuring child theme succesful.\n');
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Installing node modules in child theme and parent theme.
|
|
261
|
-
*/
|
|
262
|
-
shell.echo('⏳ Installing npm dependencies. This may take a while.\n');
|
|
263
|
-
if (shell.exec(`${package_manager} run bootstrap-project`, { silent: true }).code !== 0) {
|
|
264
|
-
shell.echo(`Error: ${package_manager} run bootstrap-project failed. Please install node dependencies manually by running ${package_manager} run bootstrap-project in your child theme.`);
|
|
265
|
-
} else {
|
|
266
|
-
shell.echo('✔️ Installing npm dependencies succesful.');
|
|
267
|
-
shell.exec(`${package_manager} run dev`, { silent: true });
|
|
268
|
-
shell.echo('✔️ First webpack build succesful.\n');
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Wait until user adds site and presses a key.
|
|
273
|
-
*/
|
|
274
|
-
prompt('Script will generate .env file. Please add your new site to your AMP stack before pressing enter to continue.');
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* cd back to root folder.
|
|
278
|
-
*/
|
|
279
|
-
shell.cd('../../../../');
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* reload host file so browsersync works without a restart.
|
|
284
|
-
*/
|
|
285
|
-
if (is_wsl) {
|
|
286
|
-
shell.exec('sudo cp /mnt/c/Windows/System32/drivers/etc/hosts /etc/hosts');
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Creating .env file
|
|
291
|
-
*/
|
|
292
|
-
shell.echo('Creating .env file\n');
|
|
293
|
-
shell.exec(`wp dotenv init --template=.env.example --with-salts`, { silent: true });
|
|
294
|
-
shell.exec(`wp dotenv set DB_NAME ${project_name}`, { silent: true });
|
|
295
|
-
shell.exec(`wp dotenv set DB_USER ${DBuser}`, { silent: true });
|
|
296
|
-
shell.exec(`wp dotenv set DB_PASSWORD ${DBpassword}`, { silent: true });
|
|
297
|
-
shell.exec(`wp dotenv set WP_HOME http://${project_url}`, { silent: true });
|
|
298
|
-
shell.exec(`wp dotenv salts generate`, { silent: true });
|
|
299
|
-
shell.echo('✔️ Generating .env successful.\n');
|
|
300
|
-
|
|
301
|
-
if (is_wsl) {
|
|
302
|
-
shell.echo('Uncommenting #DB_host and changing to 127.0.0.1 for allowing connection in WSL\n');
|
|
303
|
-
shell.sed('-i', '# DB_HOST', 'DB_HOST', '.env');
|
|
304
|
-
shell.sed('-i', 'localhost', '127.0.0.1', '.env');
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if (project_type == 'new') {
|
|
308
|
-
shell.echo('⏳ Installing WordPress.\n');
|
|
309
|
-
|
|
310
|
-
shell.exec(`touch workspace.code-workspace`);
|
|
311
|
-
shell.exec(`echo '{
|
|
312
|
-
"folders": [
|
|
313
|
-
{
|
|
314
|
-
"name": "root",
|
|
315
|
-
"path": "."
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
"name": "${project_name}",
|
|
319
|
-
"path": "web/app/themes/${project_name}"
|
|
320
|
-
}
|
|
321
|
-
]
|
|
322
|
-
}' >> workspace.code-workspace`);
|
|
323
|
-
shell.echo('✔️ .code-workspace file created.\n');
|
|
324
|
-
|
|
325
|
-
if (shell.exec(`wp db create`, { silent: true }).code !== 0) {
|
|
326
|
-
prompt('Database creation failed. Please make sure your server is running. Press enter to continue.');
|
|
327
|
-
createDB();
|
|
328
|
-
} else {
|
|
329
|
-
shell.echo('✔️ Database created');
|
|
330
|
-
setupWordPress();
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
} else {
|
|
335
|
-
shell.echo('Creating Database.\n');
|
|
336
|
-
|
|
337
|
-
if (shell.exec(`wp db create`, { silent: true }).code !== 0) {
|
|
338
|
-
prompt('Database creation failed. Please make sure your server is running. Press enter to continue.');
|
|
339
|
-
|
|
340
|
-
} else {
|
|
341
|
-
shell.echo('✔️ Database created.');
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Wait until user adds site and presses a key.
|
|
346
|
-
*/
|
|
347
|
-
shell.echo('You can import your database by placing the .sql dump in the project root and run wp db import databasename.sql.');
|
|
348
|
-
prompt('Please import your database and uploads. After that press enter to continue.');
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// Flush rewrite rules
|
|
352
|
-
shell.exec(`wp rewrite flush`);
|
|
353
|
-
|
|
354
|
-
shell.echo(`\n`);
|
|
355
|
-
shell.echo(`🎉 All done! Happy developing!`);
|
|
356
|
-
shell.echo(`🌐 You can now navigate to http://${project_url}`);
|
|
357
|
-
})
|
|
358
|
-
.parse(process.argv);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
function createDB() {
|
|
362
|
-
if (shell.exec(`wp db create`, { silent: true }).code !== 0) {
|
|
363
|
-
prompt('Database creation failed. Please make sure your server is running. Press enter to continue.');
|
|
364
|
-
} else {
|
|
365
|
-
shell.echo('✔️ Database created');
|
|
366
|
-
setupWordPress();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
function setupWordPress() {
|
|
373
|
-
if (
|
|
374
|
-
shell.exec(
|
|
375
|
-
`wp core install --skip-email --url='http://${project_url}' --title='${project_name}' --admin_user='${username}' --admin_password='${password}' --admin_email='${email}'`,
|
|
376
|
-
{ silent: true },
|
|
377
|
-
).code !== 0
|
|
378
|
-
) {
|
|
379
|
-
shell.echo('Error: Installing WordPress failed.');
|
|
380
|
-
shell.exit(1);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
shell.echo('✔️ Installing WordPress succesful.');
|
|
384
|
-
shell.exec(`wp rewrite structure '/%postname%/'`, { silent: true });
|
|
385
|
-
shell.echo('✔️ Setting permalink structure.');
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
// Set language
|
|
389
|
-
shell.exec(`wp language core install nl_NL`, { silent: true });
|
|
390
|
-
shell.exec(`wp language core activate nl_NL`, { silent: true });
|
|
391
|
-
shell.exec(`wp language plugin install nl_NL --all`, { silent: true });
|
|
392
|
-
shell.echo('✔️ Installed Dutch language.');
|
|
393
|
-
|
|
394
|
-
// activate plugins
|
|
395
|
-
shell.exec(`wp plugin activate fluentform`, { silent: true });
|
|
396
|
-
shell.exec(`wp plugin activate fluentformpro`, { silent: true });
|
|
397
|
-
shell.exec(`wp plugin activate advanced-custom-fields-pro`, { silent: true });
|
|
398
|
-
shell.exec(`wp plugin activate quartermaster`, { silent: true });
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
shell.exec(`wp theme activate ${child_theme_folder}`, { silent: true });
|
|
402
|
-
shell.echo(`✔️ Activating child theme ${child_theme_folder}`);
|
|
403
|
-
|
|
404
|
-
shell.exec(`wp post update 2 --post_title='Home'`, { silent: true });
|
|
405
|
-
shell.exec(`wp option update show_on_front 'page'`, { silent: true });
|
|
406
|
-
shell.exec(`wp option update timezone_string 'Europe/Amsterdam'`, { silent: true });
|
|
407
|
-
shell.exec(`wp option update page_on_front 2`, { silent: true });
|
|
408
|
-
shell.exec(`wp post delete 1 --force`, { silent: true });
|
|
409
|
-
shell.exec(`wp comment delete 1 --force`, { silent: true });
|
|
410
|
-
shell.echo('✔️ Create homepage and set as front-page.');
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
// set menu
|
|
414
|
-
shell.exec(`wp menu create "Hoofdmenu"`, { silent: true });
|
|
415
|
-
shell.exec(`wp menu item add-post Hoofdmenu 2`, { silent: true });
|
|
416
|
-
shell.exec(`wp menu location assign Hoofdmenu primary_navigation`, { silent: true });
|
|
417
|
-
shell.echo('✔️ Created primary menu.');
|
|
418
29
|
|
|
419
|
-
|
|
30
|
+
program.parse(process.argv);
|