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