Skip to content

Commit 19b70b0

Browse files
committed
Format generate-config.js using Prettier
1 parent 17acabe commit 19b70b0

File tree

5 files changed

+120
-72
lines changed

5 files changed

+120
-72
lines changed

.github/workflows/master.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
- name: Install dependencies
2424
run: npm ci
2525
- name: Build config.yml
26-
run: npm run build
26+
run: |
27+
npm run format
28+
npm run build
2729
- name: Confirm committed config.yml matches built version
2830
run: git diff --exit-code

config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ vm_config:
604604
cores: 3
605605
general:
606606
db_backup: true
607-
db_restore: true
607+
db_restore: false
608608
db_share: false
609609
vagrant-plugins:
610610
disksize: 65GB

generate-config.js

+64-65
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,103 @@
1-
const fs = require('fs');
2-
const YAML = require('yaml');
1+
const fs = require("fs");
2+
const YAML = require("yaml");
33

4-
const configFileName = 'config.yml';
4+
const configFileName = "config.yml";
55
const defaultPhpVersion = 7.4;
66

77
console.info(`Generating ${configFileName}...`);
88

9-
const sitesConfig = require('./sites.json');
9+
const sitesConfig = require("./sites.json");
1010

1111
const vvvConfig = {
1212
sites: {},
1313
utilities: {
1414
core: [
15-
'tls-ca',
16-
'phpmyadmin',
17-
'memcached-admin',
18-
'opcache-status',
19-
'webgrind',
20-
'php73',
21-
'php74',
22-
'php80',
15+
"tls-ca",
16+
"phpmyadmin",
17+
"memcached-admin",
18+
"opcache-status",
19+
"webgrind",
20+
"php73",
21+
"php74",
22+
"php80",
2323
],
2424
pmc: [
25-
'coretech',
25+
"coretech",
2626
// 'dev-tools',
27-
'http-concat',
28-
'phpcs',
27+
"http-concat",
28+
"phpcs",
2929
],
3030
},
31-
'utility-sources': {
31+
"utility-sources": {
3232
pmc: {
33-
repo: '[email protected]:penske-media-corp/pmc-vvv-utilities.git',
34-
branch: 'main',
33+
repo: "[email protected]:penske-media-corp/pmc-vvv-utilities.git",
34+
branch: "main",
3535
},
3636
},
37-
'vm_config': {
37+
vm_config: {
3838
memory: 4096,
3939
cores: 3,
4040
},
4141
general: {
42-
'db_backup': true,
43-
'db_restore': true,
44-
'db_share': false,
42+
db_backup: true,
43+
db_restore: false,
44+
db_share: false,
4545
},
46-
'vagrant-plugins': {
47-
disksize: '65GB',
46+
"vagrant-plugins": {
47+
disksize: "65GB",
4848
},
4949
};
5050

51-
Object.entries(sitesConfig).forEach(
52-
(entry) => {
53-
const [ liveUrl, config ] = entry;
51+
Object.entries(sitesConfig).forEach((entry) => {
52+
const [liveUrl, config] = entry;
5453

55-
if (! config.theme_repo) {
56-
console.warn(` - Skipping ${liveUrl} due to misconfiguration`);
57-
return;
58-
}
54+
if (!config.theme_repo) {
55+
console.warn(` - Skipping ${liveUrl} due to misconfiguration`);
56+
return;
57+
}
5958

60-
const slugifiedUrl = liveUrl.replace(/\./g,'-');
59+
const slugifiedUrl = liveUrl.replace(/\./g, "-");
6160

62-
const phpVersion = parseFloat(config.php_version ?? defaultPhpVersion).toFixed(1);
63-
const nginxUpstream = `php${phpVersion}`.replace('.', '');
61+
const phpVersion = parseFloat(
62+
config.php_version ?? defaultPhpVersion
63+
).toFixed(1);
64+
const nginxUpstream = `php${phpVersion}`.replace(".", "");
6465

65-
vvvConfig.sites[slugifiedUrl] = {
66-
skip_provisioning: true,
67-
description: liveUrl,
68-
repo: config.provisioner_url ?? '[email protected]:penske-media-corp/pmc-vvv-site-provisioners.git',
69-
branch: config.provisioner_branch ?? 'main',
70-
hosts: [
71-
`${slugifiedUrl}.test`,
72-
],
73-
nginx_upstream: nginxUpstream,
74-
custom: {
75-
live_url: `https://${liveUrl}`,
76-
site_title: `${config.site_title_prefix} (LOCAL)`,
77-
admin_user: 'pmcdev',
78-
admin_password: 'pmcdev',
79-
pmc: {
80-
theme_repo: config.theme_repo,
81-
theme_slug: config.theme_slug ?? '',
82-
parent_theme_slug: config.parent_theme_slug ?? '',
83-
theme_dir_uses_vip: config.theme_dir_uses_vip ?? false,
84-
}
85-
}
86-
};
87-
}
88-
);
66+
vvvConfig.sites[slugifiedUrl] = {
67+
skip_provisioning: true,
68+
description: liveUrl,
69+
repo:
70+
config.provisioner_url ??
71+
"[email protected]:penske-media-corp/pmc-vvv-site-provisioners.git",
72+
branch: config.provisioner_branch ?? "main",
73+
hosts: [`${slugifiedUrl}.test`],
74+
nginx_upstream: nginxUpstream,
75+
custom: {
76+
live_url: `https://${liveUrl}`,
77+
site_title: `${config.site_title_prefix} (LOCAL)`,
78+
admin_user: "pmcdev",
79+
admin_password: "pmcdev",
80+
pmc: {
81+
theme_repo: config.theme_repo,
82+
theme_slug: config.theme_slug ?? "",
83+
parent_theme_slug: config.parent_theme_slug ?? "",
84+
theme_dir_uses_vip: config.theme_dir_uses_vip ?? false,
85+
},
86+
},
87+
};
88+
});
8989

90-
vvvConfig.sites['wordpress-trunk'] = {
90+
vvvConfig.sites["wordpress-trunk"] = {
9191
skip_provisioning: true,
92-
description: "An svn based WP Core trunk dev setup, useful for contributor days, Trac tickets, patches",
93-
repo: 'https://github.com/Varying-Vagrant-Vagrants/custom-site-template-develop.git',
94-
hosts: [
95-
'trunk.wordpress.test',
96-
],
92+
description:
93+
"An svn based WP Core trunk dev setup, useful for contributor days, Trac tickets, patches",
94+
repo: "https://github.com/Varying-Vagrant-Vagrants/custom-site-template-develop.git",
95+
hosts: ["trunk.wordpress.test"],
9796
};
9897

9998
fs.writeFileSync(
10099
configFileName,
101100
YAML.stringify(vvvConfig, null, { lineWidth: 0 })
102101
);
103102

104-
console.info('Done!');
103+
console.info("Done!");

package-lock.json

+30-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
{
2-
"dependencies": {
3-
"yaml": "^2.1.1"
2+
"name": "pmc-vvv",
3+
"description": "Configuration repo for PMC's use of VVV.",
4+
"version": "1.0.0",
5+
"main": "generate-config.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/penske-media-corp/pmc-vvv.git"
9+
},
10+
"keywords": [
11+
"VVV"
12+
],
13+
"author": "Penske Media Corporation, LLC",
14+
"license": "ISC",
15+
"bugs": {
16+
"url": "https://github.com/penske-media-corp/pmc-vvv/issues"
417
},
18+
"homepage": "https://github.com/penske-media-corp/pmc-vvv#readme",
519
"scripts": {
6-
"build": "node generate-config.js"
20+
"build": "node generate-config.js",
21+
"format": "prettier --write generate-config.js"
22+
},
23+
"devDependencies": {
24+
"prettier": "^2.7.1",
25+
"yaml": "^2.1.1"
726
}
827
}

0 commit comments

Comments
 (0)