wp-lemon-create 1.3.4 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +25 -17
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -5,7 +5,10 @@ const { program } = require('commander');
5
5
  var shell = require('shelljs');
6
6
  const commandName = 'wp-lemon-create';
7
7
  const { engines, version } = require('../package.json');
8
+ const path = require('path');
8
9
  const prompt = require('prompt-sync')();
10
+ const rootPath = path.basename(path.resolve());
11
+
9
12
 
10
13
  program
11
14
  .name(commandName)
@@ -19,7 +22,9 @@ program
19
22
  )
20
23
  .version(version)
21
24
  .action((name, options, command) => {
25
+ var project_name = rootPath;
22
26
  var project_repository = '';
27
+ var project_url = '';
23
28
  var username = '';
24
29
  var email = '';
25
30
  var password = '';
@@ -33,6 +38,7 @@ program
33
38
  var skipGit = false;
34
39
  var branch = false;
35
40
 
41
+
36
42
  console.log(`Starting $${commandName} @${version}`);
37
43
 
38
44
  if (!shell.which('git')) {
@@ -80,14 +86,16 @@ program
80
86
  }
81
87
 
82
88
  shell.echo('\n');
83
- const projectname = prompt('What is the project name (only lowercase and -, no spaces. Do not add tld (.local/.test):');
84
- child_theme_folder = projectname;
89
+ 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);
85
90
  const tld = prompt('What is the project tld? (defaults to .local):', '.local');
86
91
 
87
- const projecttype = prompt('Project type? new or existing (defaults to new):', 'new');
92
+ child_theme_folder = project_name; // update child theme folder name
93
+ project_url = project_name + tld; // set project url
94
+
95
+ const project_type = prompt('Project type? new or existing (defaults to new):', 'new');
88
96
  shell.echo('\n');
89
97
 
90
- if (projecttype == 'new') {
98
+ if (project_type == 'new') {
91
99
  shell.echo('Please create a new Git repository and fill in the link in ssh format.');
92
100
  project_repository = prompt('Git repository link or enter "none" to skip GIT setup:', 'none');
93
101
  username = prompt('WordPress username:');
@@ -100,7 +108,7 @@ program
100
108
  if (project_repository == 'none') {
101
109
  skipGit = true;
102
110
  }
103
- } else if (projecttype == 'existing') {
111
+ } else if (project_type == 'existing') {
104
112
  project_repository = prompt('Existing repository link in ssh format:');
105
113
  branch = prompt('Branch to checkout (defaults to master):', 'master');
106
114
  } else {
@@ -112,9 +120,9 @@ program
112
120
  DBpassword = prompt('Database password. Defaults to root:', 'root');
113
121
 
114
122
  shell.echo('\n');
115
- shell.echo(`🎉 Setting up ${projecttype} wp-lemon project with url ${projectname + tld}\n`);
123
+ shell.echo(`🎉 Setting up ${project_type} wp - lemon project with url ${project_url} \n`);
116
124
 
117
- if (projecttype == 'new') {
125
+ if (project_type == 'new') {
118
126
  shell.echo('Downloading Bedrock. This may take a minute or so.\n');
119
127
 
120
128
  /**
@@ -174,7 +182,7 @@ program
174
182
  */
175
183
  if (!skipGit) {
176
184
  shell.exec('git init', { silent: true });
177
- shell.exec(`git remote add origin ${project_repository}`);
185
+ shell.exec(`git remote add origin ${project_repository} `);
178
186
  shell.echo(`✔️ Setting up empty local git repository and adding ${project_repository} as remote.\n`);
179
187
  }
180
188
 
@@ -192,7 +200,7 @@ program
192
200
  shell.echo('Downloading child theme.\n');
193
201
  shell.cd('web/app/themes/');
194
202
 
195
- shell.exec(`composer create-project --repository https://packagist.studiolemon.nl/satispress/ satispress/wp-lemon-child ${child_theme_folder} --no-dev`, { silent: true });
203
+ shell.exec(`composer create - project--repository https://packagist.studiolemon.nl/satispress/ satispress/wp-lemon-child ${child_theme_folder} --no-dev`, { silent: true });
196
204
 
197
205
  shell.cd(child_theme_folder);
198
206
  shell.rm('-rf', '.github');
@@ -224,9 +232,9 @@ program
224
232
  * Create child theme config file
225
233
  */
226
234
  shell.cp('resources/assets/config.json.example', 'resources/assets/config.json');
227
- shell.sed('-i', 'http://wplemon.local', `http://${projectname + tld}`, 'resources/assets/config.json');
235
+ shell.sed('-i', 'http://wplemon.local', `http://${project_url}`, 'resources/assets/config.json');
228
236
  shell.sed('-i', 'wp-lemon-child', child_theme_folder, 'resources/assets/config.json');
229
- shell.sed('-i', 'wp-lemon child', projectname, 'style.css');
237
+ shell.sed('-i', 'wp-lemon child', project_name, 'style.css');
230
238
  shell.echo('✔️ Configuring child theme succesful.\n');
231
239
 
232
240
  /**
@@ -263,12 +271,12 @@ program
263
271
  */
264
272
  shell.echo('Creating .env file\n');
265
273
  shell.exec(`wp dotenv init --template=.env.example --with-salts`, { silent: true });
266
- shell.exec(`wp dotenv set DB_NAME ${projectname}`, { silent: true });
274
+ shell.exec(`wp dotenv set DB_NAME ${project_name}`, { silent: true });
267
275
  shell.exec(`wp dotenv set DB_USER ${DBuser}`, { silent: true });
268
276
  shell.exec(`wp dotenv set DB_PASSWORD ${DBpassword}`, { silent: true });
269
- shell.exec(`wp dotenv set WP_HOME http://${projectname + tld}`, { silent: true });
277
+ shell.exec(`wp dotenv set WP_HOME http://${project_url}`, { silent: true });
270
278
  shell.exec(`wp dotenv salts generate`, { silent: true });
271
- shell.echo('✔️ Generating .env succesful.\n');
279
+ shell.echo('✔️ Generating .env successful.\n');
272
280
 
273
281
  if (is_wsl) {
274
282
  shell.echo('Uncommenting #DB_host and changing to 127.0.0.1 for allowing connection in WSL\n');
@@ -276,7 +284,7 @@ program
276
284
  shell.sed('-i', 'localhost', '127.0.0.1', '.env');
277
285
  }
278
286
 
279
- if (projecttype == 'new') {
287
+ if (project_type == 'new') {
280
288
  shell.echo('Installing WordPress.\n');
281
289
 
282
290
  if (shell.exec(`wp db create`, { silent: true }).code !== 0) {
@@ -287,7 +295,7 @@ program
287
295
 
288
296
  if (
289
297
  shell.exec(
290
- `wp core install --skip-email --url="http://${projectname + tld}" --title="${projectname}" --admin_user="${username}" --admin_password="${password}" --admin_email="${email}"`,
298
+ `wp core install --skip-email --url="http://${project_url}" --title="${project_name}" --admin_user="${username}" --admin_password="${password}" --admin_email="${email}"`,
291
299
  { silent: true },
292
300
  ).code !== 0
293
301
  ) {
@@ -339,6 +347,6 @@ program
339
347
 
340
348
  shell.echo(`\n`);
341
349
  shell.echo(`🎉 All done! Happy developing!`);
342
- shell.echo(`🌐 You can now navigate to http://${projectname + tld}`);
350
+ shell.echo(`🌐 You can now navigate to http://${project_url}`);
343
351
  })
344
352
  .parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wp-lemon-create",
3
- "version": "1.3.4",
3
+ "version": "1.4.2",
4
4
  "description": "Bootstrap your wp-lemon project",
5
5
  "main": "index.js",
6
6
  "author": "Erik van der bas",