forked from penske-media-corp/pmc-vvv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-config.js
102 lines (90 loc) · 2.36 KB
/
generate-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const fs = require("fs");
const YAML = require("yaml");
const configFileName = "config.yml";
const defaultPhpVersion = 8.0;
console.info(`Generating ${configFileName}...`);
const sitesConfig = require("./sites.json");
const vvvConfig = {
sites: {},
utilities: {
core: [
"tls-ca",
"phpmyadmin",
"memcached-admin",
"opcache-status",
"webgrind",
"php80",
"php81",
],
pmc: [
"coretech",
// 'dev-tools',
"http-concat",
"phpcs",
],
},
"utility-sources": {
pmc: {
repo: "[email protected]:penske-media-corp/pmc-vvv-utilities.git",
branch: "main",
},
},
vm_config: {
memory: 4096,
cores: 3,
},
general: {
db_backup: true,
db_restore: false,
db_share: false,
},
"vagrant-plugins": {
disksize: "65GB",
},
};
Object.entries(sitesConfig).forEach((entry) => {
const [liveUrl, config] = entry;
if (!config.theme_repo) {
console.warn(` - Skipping ${liveUrl} due to misconfiguration`);
return;
}
const slugifiedUrl = liveUrl.replace(/\./g, "-");
const phpVersion = parseFloat(
config.php_version ?? defaultPhpVersion
).toFixed(1);
const nginxUpstream = `php${phpVersion}`.replace(".", "");
vvvConfig.sites[slugifiedUrl] = {
skip_provisioning: true,
description: liveUrl,
repo:
config.provisioner_url ??
"[email protected]:penske-media-corp/pmc-vvv-site-provisioners.git",
branch: config.provisioner_branch ?? "main",
hosts: [`${slugifiedUrl}.test`],
nginx_upstream: nginxUpstream,
custom: {
live_url: `https://${liveUrl}`,
site_title: `${config.site_title_prefix} (LOCAL)`,
admin_user: "pmcdev",
admin_password: "pmcdev",
pmc: {
theme_repo: config.theme_repo,
theme_slug: config.theme_slug ?? "",
parent_theme_slug: config.parent_theme_slug ?? "",
theme_dir_uses_vip: config.theme_dir_uses_vip ?? false,
},
},
};
});
vvvConfig.sites["wordpress-trunk"] = {
skip_provisioning: true,
description:
"An svn based WP Core trunk dev setup, useful for contributor days, Trac tickets, patches",
repo: "https://github.com/Varying-Vagrant-Vagrants/custom-site-template-develop.git",
hosts: ["trunk.wordpress.test"],
};
fs.writeFileSync(
configFileName,
YAML.stringify(vvvConfig, null, { lineWidth: 0 })
);
console.info("Done!");