-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·168 lines (142 loc) · 4.98 KB
/
index.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/env node
import { generateCompletionSpec } from "@fig/complete-commander"
import chalk from "chalk"
import { Command } from "commander"
import fs from "fs"
import {
createCdnS3GoDaddy,
updateBucketAccessPolicyAndCreateIAMUser,
updateBucketLicecyclePolicy,
} from "./commands/cdnS3GoDaddy.js"
import cloneLisaProject from "./commands/clone.js"
import configure from "./commands/configure.js"
import dbImport from "./commands/db.js"
import { createGoDaddy } from "./commands/godaddy.js"
import init from "./commands/init.js"
import { kinsta } from "./commands/kinsta.js"
import { createPageComponent } from "./commands/pageComponent.js"
import setupPath from "./commands/path.js"
import { createSendGrid } from "./commands/sendgrid.js"
import writeLisaStatusSummary from "./commands/status.js"
import wpUpdate from "./commands/wordpressComposerUpdate.js"
import { resetConf } from "./lib/conf.js"
import { checkDependencies, checkNodeVersion } from "./lib/dependencies.js"
import exec from "./lib/exec.js"
import { getSitesPath } from "./lib/path.js"
import { set } from "./lib/store.js"
import { checkLisaVersion } from "./lib/versions.js"
import { generateVaultPass } from "./tasks/trellis.js"
export const program = new Command()
export const LISA_VERSION = "2.16.0"
resetConf()
checkNodeVersion()
const command = process.argv[2]
async function initProgram() {
await checkLisaVersion()
await checkDependencies()
const initialPath = await exec("pwd")
set("initialPath", initialPath.stdout.trim())
process.chdir(await getSitesPath())
program.version(LISA_VERSION, "-v, --version", "Output the current version")
program
.command("path")
.description("Run this command to set your global sites path")
.argument(
"[path]",
`Your global sites path, for example ${chalk.bold("~/Sites")}`,
)
.action(setupPath)
program
.command("kinsta")
.description("Output Kinsta configuration file template")
.argument(
"<action>",
"Pass an argument for which action to perform, available actions: show-config, create",
)
.action(kinsta)
program
.command("init")
.description("Create a Lisa project")
.requiredOption(
"-c, --config-file <file>",
`File with configuration options from Kinsta (relative or absolute path). Generate this file with ${chalk.bold(
chalk.underline("lisa kinsta"),
)}`,
)
.action(init)
program
.command("db import")
.description("Import a database from staging/production environment")
.action(dbImport)
program
.command("configure")
.description("Configure all credentials for third party services")
.option(
"--reset",
"Reset the config for one or all services, see argument [service] for available services.",
)
.action(configure)
program
.command("clone")
.description("Clone an existing Lisa project for local development")
.action(cloneLisaProject)
program
.command("status")
.description("Show a status summary of your Lisa site.")
.action(writeLisaStatusSummary)
program
.command("page-component create")
.description("Create a new page component for your frontend app")
.action(createPageComponent)
program.command("pcc", { hidden: true }).action(createPageComponent)
program
.command("cdn create")
.description(
"Create S3 bucket and CloudFront distribution. Also create CNAME recrods in GoDaddy DNS.",
)
.action(createCdnS3GoDaddy)
program
.command("sendgrid create")
.description("Create SendGrid account")
.action(createSendGrid)
program
.command("wp update")
.description(
`Update WordPress and Composer dependencies.
Make sure your standing in the folder where your composer.json file is located.
`,
)
.action(wpUpdate)
program
.command("godaddy create")
.description("Create DNS-records in GoDaddy")
.action(createGoDaddy)
program
.command("aws user create")
.description("Update Bucket Access Policy and create IAM user in AWS")
.action(updateBucketAccessPolicyAndCreateIAMUser)
program
.command("s3 bucket set-lifecycle-policy")
.description("Update Bucket Lifecycle Policy in S3")
.action(updateBucketLicecyclePolicy)
program
.command("vault-pass-generate")
.description(
"Generate a new vault password, use when no existing password is available",
)
.argument(
"[path]",
"Path to where the vault password should be saved",
`${process.cwd()}/.vault_pass`,
)
.action(generateVaultPass)
if (process.env.NODE_ENV === "development") {
const lisaFigSecContent = generateCompletionSpec(program)
const lisaFigSecPath = `${process.env.HOME}/.fig/autocomplete/lisa.ts`
fs.writeFileSync(lisaFigSecPath, lisaFigSecContent, { encoding: "utf8" })
// npx @fig/publish-spec@latest --spec-path ~/.fig/autocomplete/lisa.ts
// npx @fig/publish-spec@latest --spec-path ~/.fig/autocomplete/lisa.ts --team triggerfish
}
program.parse()
}
initProgram()