@automattic/vip 2.37.0-dev.0 → 2.38.0-dev.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 (40) hide show
  1. package/assets/dev-env.lando.template.yml.ejs +1 -1
  2. package/dist/bin/vip-app-deploy.js +251 -0
  3. package/dist/bin/vip-app.js +1 -1
  4. package/dist/bin/vip-dev-env-create.js +2 -3
  5. package/dist/bin/vip-dev-env-destroy.js +1 -1
  6. package/dist/bin/vip-dev-env-exec.js +1 -1
  7. package/dist/bin/vip-dev-env-import-media.js +1 -1
  8. package/dist/bin/vip-dev-env-import-sql.js +1 -1
  9. package/dist/bin/vip-dev-env-info.js +1 -1
  10. package/dist/bin/vip-dev-env-logs.js +1 -1
  11. package/dist/bin/vip-dev-env-shell.js +1 -1
  12. package/dist/bin/vip-dev-env-start.js +1 -1
  13. package/dist/bin/vip-dev-env-stop.js +1 -1
  14. package/dist/bin/vip-dev-env-sync-sql.js +1 -1
  15. package/dist/bin/vip-dev-env-update.js +1 -1
  16. package/dist/bin/vip-import-sql.js +1 -1
  17. package/dist/bin/vip-wp.js +1 -1
  18. package/dist/commands/dev-env-import-sql.js +18 -15
  19. package/dist/commands/dev-env-sync-sql.js +3 -2
  20. package/dist/commands/phpmyadmin.js +112 -2
  21. package/dist/lib/cli/command.js +28 -19
  22. package/dist/lib/cli/exit.js +7 -2
  23. package/dist/lib/cli/format.js +2 -2
  24. package/dist/lib/client-file-uploader.js +22 -13
  25. package/dist/lib/constants/dev-environment.js +2 -10
  26. package/dist/lib/custom-deploy/custom-deploy.js +95 -0
  27. package/dist/lib/dev-environment/dev-environment-cli.js +13 -5
  28. package/dist/lib/dev-environment/dev-environment-configuration-file.js +57 -34
  29. package/dist/lib/dev-environment/dev-environment-core.js +20 -7
  30. package/dist/lib/dev-environment/docker-utils.js +1 -1
  31. package/dist/lib/env.js +2 -1
  32. package/dist/lib/user-error.js +2 -2
  33. package/dist/lib/validations/custom-deploy.js +39 -0
  34. package/dist/lib/validations/line-by-line.js +3 -1
  35. package/dist/lib/validations/sql.js +1 -1
  36. package/docs/CHANGELOG.md +44 -0
  37. package/npm-shrinkwrap.json +274 -628
  38. package/package.json +7 -5
  39. package/schema.gql +20174 -0
  40. package/tsconfig.json +2 -2
@@ -35,7 +35,7 @@ services:
35
35
  ssl: true
36
36
  sslExpose: false
37
37
  services:
38
- image: ghcr.io/automattic/vip-container-images/nginx:1.23.3
38
+ image: ghcr.io/automattic/vip-container-images/nginx:latest
39
39
  command: nginx -g "daemon off;"
40
40
  environment:
41
41
  LANDO_NO_SCRIPTS: 1
@@ -0,0 +1,251 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+ "use strict";
7
+
8
+ exports.__esModule = true;
9
+ exports.appDeployCmd = appDeployCmd;
10
+ exports.promptToContinue = promptToContinue;
11
+ var _chalk = _interopRequireDefault(require("chalk"));
12
+ var _debug = _interopRequireDefault(require("debug"));
13
+ var _enquirer = require("enquirer");
14
+ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
15
+ var _api = _interopRequireDefault(require("../lib/api"));
16
+ var _command = _interopRequireDefault(require("../lib/cli/command"));
17
+ var exit = _interopRequireWildcard(require("../lib/cli/exit"));
18
+ var _format = require("../lib/cli/format");
19
+ var _progress = require("../lib/cli/progress");
20
+ var _clientFileUploader = require("../lib/client-file-uploader");
21
+ var _customDeploy = require("../lib/custom-deploy/custom-deploy");
22
+ var _tracker = require("../lib/tracker");
23
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
24
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+ /**
27
+ * Internal dependencies
28
+ */
29
+ const appQuery = `
30
+ id,
31
+ name,
32
+ type,
33
+ typeId
34
+ organization { id, name },
35
+ environments{
36
+ id
37
+ appId
38
+ type
39
+ name
40
+ launched
41
+ isK8sResident
42
+ syncProgress { status }
43
+ primaryDomain { name }
44
+ wpSites {
45
+ nodes {
46
+ homeUrl
47
+ id
48
+ }
49
+ }
50
+ }
51
+ `;
52
+ const START_DEPLOY_MUTATION = (0, _graphqlTag.default)`
53
+ mutation StartDeploy($input: AppEnvironmentDeployInput) {
54
+ startDeploy(input: $input) {
55
+ app {
56
+ id
57
+ name
58
+ }
59
+ message
60
+ success
61
+ }
62
+ }
63
+ `;
64
+ const debug = (0, _debug.default)('@automattic/vip:bin:vip-app-deploy');
65
+ const DEPLOY_PREFLIGHT_PROGRESS_STEPS = [{
66
+ id: 'upload',
67
+ name: 'Uploading file'
68
+ }, {
69
+ id: 'deploy',
70
+ name: 'Triggering deployment'
71
+ }];
72
+ /**
73
+ * Prompt the user to confirm the environment they are deploying to.
74
+ * @param {PromptToContinueParams} PromptToContinueParams
75
+ */
76
+ async function promptToContinue(params) {
77
+ const promptToMatch = params.domain.toUpperCase();
78
+ const promptResponse = await (0, _enquirer.prompt)({
79
+ type: 'input',
80
+ name: 'confirmedDomain',
81
+ message: `You are about to deploy to a ${params.launched ? 'launched' : 'un-launched'} ${params.formattedEnvironment} site ${_chalk.default.yellow(params.domain)}.\nType '${_chalk.default.yellow(promptToMatch)}' (without the quotes) to continue:\n`
82
+ });
83
+ if (promptResponse.confirmedDomain !== promptToMatch) {
84
+ await params.track('deploy_app_unexpected_input');
85
+ exit.withError('The input did not match the expected environment label. Deploy aborted.');
86
+ }
87
+ }
88
+ async function appDeployCmd(arg = [], opts = {}) {
89
+ const app = opts.app;
90
+ const env = opts.env;
91
+ const [fileName] = arg;
92
+ const fileMeta = await (0, _clientFileUploader.getFileMeta)(fileName);
93
+ const inputBasename = fileMeta.basename;
94
+ debug('Options: ', opts);
95
+ debug('Args: ', arg);
96
+ const appId = env.appId;
97
+ const envId = env.id;
98
+ const track = _tracker.trackEventWithEnv.bind(null, appId, envId);
99
+ await (0, _customDeploy.gates)(app, env, fileMeta);
100
+ await track('deploy_app_command_execute');
101
+
102
+ // Upload file as different name to avoid overwriting existing same named files
103
+ const datePrefix = new Date().toISOString()
104
+ // eslint-disable-next-line no-useless-escape
105
+ .replace(/[\-T:\.Z]/g, '').slice(0, 14);
106
+ fileMeta.basename = `${datePrefix}-${fileMeta.basename}`;
107
+ const deployMessage = opts.message ?? '';
108
+ const forceDeploy = opts.force;
109
+ const domain = env?.primaryDomain?.name ? env.primaryDomain.name : `#${env.id}`;
110
+ if (!forceDeploy) {
111
+ const promptParams = {
112
+ launched: Boolean(env.launched),
113
+ formattedEnvironment: (0, _format.formatEnvironment)(env.type),
114
+ track,
115
+ domain
116
+ };
117
+ await promptToContinue(promptParams);
118
+ }
119
+
120
+ /**
121
+ * =========== WARNING =============
122
+ *
123
+ * NO `console.log` after this point!
124
+ * Yes, even inside called functions.
125
+ * It will break the progress printing.
126
+ *
127
+ * =========== WARNING =============
128
+ */
129
+ const progressTracker = new _progress.ProgressTracker(DEPLOY_PREFLIGHT_PROGRESS_STEPS);
130
+ let status = 'running';
131
+ const setProgressTrackerPrefixAndSuffix = () => {
132
+ progressTracker.prefix = `
133
+ =============================================================
134
+ Processing the file for deployment to your environment...
135
+ `;
136
+ progressTracker.suffix = `\n${(0, _format.getGlyphForStatus)(status, progressTracker.runningSprite)} Running...`;
137
+ };
138
+ const failWithError = failureError => {
139
+ status = 'failed';
140
+ setProgressTrackerPrefixAndSuffix();
141
+ progressTracker.stopPrinting();
142
+ progressTracker.print({
143
+ clearAfter: true
144
+ });
145
+ exit.withError(failureError);
146
+ };
147
+ progressTracker.startPrinting(setProgressTrackerPrefixAndSuffix);
148
+ progressTracker.stepRunning('upload');
149
+
150
+ // Call the Public API
151
+ const api = await (0, _api.default)();
152
+ const progressCallback = percentage => {
153
+ progressTracker.setUploadPercentage(percentage);
154
+ };
155
+ const appInput = {
156
+ id: appId
157
+ };
158
+ const envInput = {
159
+ id: envId
160
+ };
161
+ const uploadParams = {
162
+ app: appInput,
163
+ env: envInput,
164
+ fileMeta,
165
+ progressCallback,
166
+ hashType: 'sha256'
167
+ };
168
+ const startDeployVariables = {
169
+ input: {}
170
+ };
171
+ try {
172
+ const {
173
+ fileMeta: {
174
+ basename
175
+ },
176
+ checksum,
177
+ result
178
+ } = await (0, _clientFileUploader.uploadImportSqlFileToS3)(uploadParams);
179
+ startDeployVariables.input = {
180
+ id: app.id,
181
+ environmentId: env.id,
182
+ basename: fileMeta.basename,
183
+ checksum,
184
+ deployMessage
185
+ };
186
+ debug({
187
+ basename,
188
+ checksum,
189
+ result,
190
+ startDeployVariables
191
+ });
192
+ debug('Upload complete. Initiating the deploy.');
193
+ progressTracker.stepSuccess('upload');
194
+ await track('deploy_app_upload_complete');
195
+ } catch (uploadError) {
196
+ await track('deploy_app_command_error', {
197
+ error_type: 'upload_failed',
198
+ upload_error: uploadError.message
199
+ });
200
+ progressTracker.stepFailed('upload');
201
+ return failWithError(uploadError);
202
+ }
203
+ progressTracker.stepRunning('deploy');
204
+
205
+ // Start the deploy
206
+ try {
207
+ const startDeployResults = await api.mutate({
208
+ mutation: START_DEPLOY_MUTATION,
209
+ variables: startDeployVariables
210
+ });
211
+ debug({
212
+ startDeployResults
213
+ });
214
+ } catch (gqlErr) {
215
+ progressTracker.stepFailed('deploy');
216
+ await track('deploy_app_command_error', {
217
+ error_type: 'StartDeploy-failed',
218
+ gql_err: gqlErr
219
+ });
220
+ progressTracker.stepFailed('deploy');
221
+ return failWithError(`StartDeploy call failed: ${gqlErr.message}`);
222
+ }
223
+ progressTracker.stepSuccess('deploy');
224
+ progressTracker.stopPrinting();
225
+ progressTracker.suffix = '';
226
+ progressTracker.print({
227
+ clearAfter: true
228
+ });
229
+ const deploymentsUrl = `https://dashboard.wpvip.com/apps/${appId}/${env.type}/code/deployments`;
230
+ console.log(`\n✅ ${_chalk.default.bold(_chalk.default.underline(_chalk.default.magenta(inputBasename)))} has been sent for deployment to ${_chalk.default.bold(_chalk.default.blue(domain))}. \nTo check deployment status, go to ${_chalk.default.bold('VIP Dashboard')}: ${deploymentsUrl}`);
231
+ }
232
+
233
+ // Command examples for the `vip deploy app` help prompt
234
+ const examples = [
235
+ // `app` subcommand
236
+ {
237
+ usage: 'vip app @mysite.develop deploy file.zip',
238
+ description: 'Deploy the given compressed file to your site'
239
+ }, {
240
+ usage: 'vip app @mysite.develop deploy file.zip --message "This is a deploy message"',
241
+ description: 'Deploy the given compressed file to your site'
242
+ }, {
243
+ usage: 'vip app @mysite.develop deploy file.zip --force',
244
+ description: 'Deploy the given compressed file to your site without prompting'
245
+ }];
246
+ void (0, _command.default)({
247
+ appContext: true,
248
+ appQuery,
249
+ envContext: true,
250
+ requiredArgs: 1
251
+ }).examples(examples).option('message', 'Custom message for deploy').option('force', 'Skip prompt').argv(process.argv, appDeployCmd);
@@ -11,7 +11,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
11
11
  (0, _command.default)({
12
12
  requiredArgs: 1,
13
13
  format: true
14
- }).example('vip app <app>', 'Pass an app name or ID to get details about that app').example('vip app 123', 'Get details about the app with ID 123').example('vip app vip-test', 'Get details about the app named vip-test').command('list', 'List your VIP applications').argv(process.argv, async arg => {
14
+ }).example('vip app <app>', 'Pass an app name or ID to get details about that app').example('vip app 123', 'Get details about the app with ID 123').example('vip app vip-test', 'Get details about the app named vip-test').example('vip app @mysite.develop deploy <file.zip>', 'Deploy the given compressed file to your site').command('list', 'List your VIP applications').command('deploy', 'Deploy to your app from a file').argv(process.argv, async arg => {
15
15
  await (0, _tracker.trackEvent)('app_command_execute');
16
16
  let res;
17
17
  try {
@@ -34,7 +34,7 @@ const examples = [{
34
34
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --multisite=subdirectory --wordpress="5.8" --app-code="~/git/my_code"`,
35
35
  description: 'Creates a local multisite dev environment with a subdirectory URL structure using WP 5.8 and application code is expected to be in "~/git/my_code"'
36
36
  }];
37
- const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment').option('title', 'Title for the WordPress site').option('multisite', 'Enable multisite install', undefined, _devEnvironmentCli.processStringOrBooleanOption);
37
+ const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).option('title', 'Title for the WordPress site').option('multisite', 'Enable multisite install', undefined, _devEnvironmentCli.processStringOrBooleanOption);
38
38
  (0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
39
39
  cmd.examples(examples);
40
40
  cmd.argv(process.argv, async (arg, opt) => {
@@ -82,8 +82,7 @@ cmd.argv(process.argv, async (arg, opt) => {
82
82
  let preselectedOptions = opt;
83
83
  let suppressPrompts = false;
84
84
  if (Object.keys(configurationFileOptions).length > 0) {
85
- console.log('\nUsing configuration from file.');
86
- (0, _devEnvironmentConfigurationFile.printConfigurationFile)(configurationFileOptions);
85
+ // Merge configuration from file
87
86
  preselectedOptions = (0, _devEnvironmentConfigurationFile.mergeConfigurationFileOptions)(opt, configurationFileOptions);
88
87
  suppressPrompts = true;
89
88
  }
@@ -18,7 +18,7 @@ const examples = [{
18
18
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} destroy --slug=foo`,
19
19
  description: 'Destroys a local dev environment named foo'
20
20
  }];
21
- (0, _command.default)().option('slug', 'Custom name of the dev environment').option('soft', 'Keep config files needed to start an environment intact').examples(examples).argv(process.argv, async (arg, opt) => {
21
+ (0, _command.default)().option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).option('soft', 'Keep config files needed to start an environment intact').examples(examples).argv(process.argv, async (arg, opt) => {
22
22
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
23
23
  const lando = await (0, _devEnvironmentLando.bootstrapLando)();
24
24
  await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
@@ -21,7 +21,7 @@ const examples = [{
21
21
  }];
22
22
  (0, _command.default)({
23
23
  wildcardCommand: true
24
- }).option('slug', 'Custom name of the dev environment').option('force', 'Disable validations before task execution', undefined, _devEnvironmentCli.processBooleanOption).option('quiet', 'Suppress output', undefined, _devEnvironmentCli.processBooleanOption).examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
24
+ }).option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).option('force', 'Disable validations before task execution', undefined, _devEnvironmentCli.processBooleanOption).option('quiet', 'Suppress output', undefined, _devEnvironmentCli.processBooleanOption).examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
25
25
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
26
26
  const lando = await (0, _devEnvironmentLando.bootstrapLando)();
27
27
  await (0, _devEnvironmentCli.validateDependencies)(lando, slug, opt.quiet);
@@ -16,7 +16,7 @@ const examples = [{
16
16
  }];
17
17
  (0, _command.default)({
18
18
  requiredArgs: 1
19
- }).examples(examples).option('slug', 'Custom name of the dev environment').argv(process.argv, async (unmatchedArgs, opt) => {
19
+ }).examples(examples).option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).argv(process.argv, async (unmatchedArgs, opt) => {
20
20
  const [filePath] = unmatchedArgs;
21
21
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
22
22
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
@@ -22,7 +22,7 @@ const examples = [{
22
22
  }];
23
23
  (0, _command.default)({
24
24
  requiredArgs: 1
25
- }).option('slug', 'Custom name of the dev environment').option(['r', 'search-replace'], 'Perform Search and Replace on the specified SQL file').option('in-place', 'Search and Replace explicitly on the given input file').option('skip-validate', 'Do not perform file validation.').examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
25
+ }).option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).option(['r', 'search-replace'], 'Perform Search and Replace on the specified SQL file').option('in-place', 'Search and Replace explicitly on the given input file').option('skip-validate', 'Do not perform file validation').option(['k', 'skip-reindex'], 'Do not reindex data in Elasticsearch after import').option('quiet', 'Suppress prompts and informational messages').examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
26
26
  const [fileName] = unmatchedArgs;
27
27
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
28
28
  const cmd = new _devEnvImportSql.DevEnvImportSQLCommand(fileName, opt, slug);
@@ -17,7 +17,7 @@ const examples = [{
17
17
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} info --slug=my_site`,
18
18
  description: 'Return information about a local dev environment named "my_site"'
19
19
  }];
20
- (0, _command.default)().option('slug', 'Custom name of the dev environment').option('all', 'Show Info for all local dev environments').option('extended', 'Show extended information about the dev environment').examples(examples).argv(process.argv, async (arg, opt) => {
20
+ (0, _command.default)().option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).option('all', 'Show Info for all local dev environments').option('extended', 'Show extended information about the dev environment').examples(examples).argv(process.argv, async (arg, opt) => {
21
21
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
22
22
  const lando = await (0, _devEnvironmentLando.bootstrapLando)();
23
23
  await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
@@ -20,7 +20,7 @@ const examples = [{
20
20
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} logs --slug=my_site --service=elasticsearch -f`,
21
21
  description: 'Follow logs from the "elasticsearch" service from a local dev environment named "my_site"'
22
22
  }];
23
- (0, _command.default)().option('slug', 'Custom name of the dev environment').option(['f', 'follow'], 'Follow logs for a specific service in local dev environment').option('service', 'Show logs for a specific service in local dev environment. Defaults to all if none passed in.').examples(examples).argv(process.argv, async (arg, opt) => {
23
+ (0, _command.default)().option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).option(['f', 'follow'], 'Follow logs for a specific service in local dev environment').option('service', 'Show logs for a specific service in local dev environment. Defaults to all if none passed in.').examples(examples).argv(process.argv, async (arg, opt) => {
24
24
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
25
25
  const lando = await (0, _devEnvironmentLando.bootstrapLando)();
26
26
  await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
@@ -54,7 +54,7 @@ function getCommand(args) {
54
54
  }
55
55
  (0, _command.default)({
56
56
  wildcardCommand: true
57
- }).option('slug', 'Custom name of the dev environment').option('root', 'Spawn a root shell').option('service', 'Spawn a shell in a specific service (php if omitted)').examples(examples).argv(process.argv, async (args, opt) => {
57
+ }).option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).option('root', 'Spawn a root shell').option('service', 'Spawn a shell in a specific service (php if omitted)').examples(examples).argv(process.argv, async (args, opt) => {
58
58
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
59
59
  const lando = await (0, _devEnvironmentLando.bootstrapLando)();
60
60
  await (0, _devEnvironmentCli.validateDependencies)(lando, '', true);
@@ -17,7 +17,7 @@ const examples = [{
17
17
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} start --vscode`,
18
18
  description: 'Start a local environment and generate a Workspace file for developing in Visual Studio Code'
19
19
  }];
20
- (0, _command.default)().option('slug', 'Custom name of the dev environment').option('skip-rebuild', 'Only start stopped services').option(['w', 'skip-wp-versions-check'], 'Skip prompt to update WordPress version if not on latest').option('vscode', 'Generate a Visual Studio Code Workspace file').examples(examples).argv(process.argv, async (arg, opt) => {
20
+ (0, _command.default)().option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).option('skip-rebuild', 'Only start stopped services').option(['w', 'skip-wp-versions-check'], 'Skip prompt to update WordPress version if not on latest').option('vscode', 'Generate a Visual Studio Code Workspace file').examples(examples).argv(process.argv, async (arg, opt) => {
21
21
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
22
22
  const lando = await (0, _devEnvironmentLando.bootstrapLando)();
23
23
  await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
@@ -15,7 +15,7 @@ const examples = [{
15
15
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} stop`,
16
16
  description: 'Stops a local dev environment'
17
17
  }];
18
- (0, _command.default)().option('slug', 'Custom name of the dev environment').examples(examples).argv(process.argv, async (arg, opt) => {
18
+ (0, _command.default)().option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).examples(examples).argv(process.argv, async (arg, opt) => {
19
19
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
20
20
  const lando = await (0, _devEnvironmentLando.bootstrapLando)();
21
21
  await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
@@ -42,7 +42,7 @@ const appQuery = `
42
42
  envContext: true,
43
43
  requiredArgs: 0,
44
44
  module: 'dev-env-sync-sql'
45
- }).option('slug', 'Custom name of the dev environment').option('force', 'Disable validations before running sync', undefined, _devEnvironmentCli.processBooleanOption).examples(examples).argv(process.argv, async (arg, opt) => {
45
+ }).option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug).option('force', 'Disable validations before running sync', undefined, _devEnvironmentCli.processBooleanOption).examples(examples).argv(process.argv, async (arg, opt) => {
46
46
  const {
47
47
  app,
48
48
  env
@@ -16,7 +16,7 @@ const examples = [{
16
16
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} update`,
17
17
  description: 'Retriggers setup wizard in order to change environment configuration'
18
18
  }];
19
- const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment');
19
+ const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment', undefined, _devEnvironmentCli.processSlug);
20
20
  (0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
21
21
  cmd.examples(examples);
22
22
  cmd.argv(process.argv, async (arg, opt) => {
@@ -460,7 +460,7 @@ Processing the SQL import for your environment...
460
460
  fileMeta: {
461
461
  basename
462
462
  },
463
- md5,
463
+ checksum: md5,
464
464
  result
465
465
  } = await (0, _clientFileUploader.uploadImportSqlFileToS3)({
466
466
  app,
@@ -112,7 +112,7 @@ const getTokenForCommand = async (appId, envId, command) => {
112
112
  });
113
113
  };
114
114
 
115
- // eslint-disable-next-line no-unused-vars
115
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
116
116
  const cancelCommand = async guid => {
117
117
  const api = await (0, _api.default)();
118
118
  return api.mutate({
@@ -24,9 +24,9 @@ class DevEnvImportSQLCommand {
24
24
  this.options = options;
25
25
  this.slug = slug;
26
26
  }
27
- async run(silent = false) {
27
+ async run() {
28
28
  const lando = await (0, _devEnvironmentLando.bootstrapLando)();
29
- await (0, _devEnvironmentCli.validateDependencies)(lando, this.slug, silent);
29
+ await (0, _devEnvironmentCli.validateDependencies)(lando, this.slug, this.options.quiet);
30
30
  (0, _sql.validateImportFileExtension)(this.fileName);
31
31
 
32
32
  // Check if file is compressed and if so, extract the
@@ -35,9 +35,13 @@ class DevEnvImportSQLCommand {
35
35
  const tmpDir = (0, _utils.makeTempDir)();
36
36
  const sqlFile = `${tmpDir}/sql-import.sql`;
37
37
  try {
38
- console.log(`Extracting the compressed file ${this.fileName}...`);
38
+ if (!this.options.quiet) {
39
+ console.log(`Extracting the compressed file ${this.fileName}...`);
40
+ }
39
41
  await (0, _clientFileUploader.unzipFile)(this.fileName, sqlFile);
40
- console.log(`${_chalk.default.green('✓')} Extracted to ${sqlFile}`);
42
+ if (!this.options.quiet) {
43
+ console.log(`${_chalk.default.green('✓')} Extracted to ${sqlFile}`);
44
+ }
41
45
  this.fileName = sqlFile;
42
46
  } catch (err) {
43
47
  exit.withError(`Error extracting the SQL file: ${err.message}`);
@@ -62,7 +66,7 @@ class DevEnvImportSQLCommand {
62
66
  });
63
67
  }
64
68
  const fd = await _fs.default.promises.open(resolvedPath, 'r');
65
- const importArg = ['db', '--disable-auto-rehash'];
69
+ const importArg = ['db', '--disable-auto-rehash'].concat(this.options.quiet ? '--silent' : []);
66
70
  const origIsTTY = process.stdin.isTTY;
67
71
  try {
68
72
  /**
@@ -76,27 +80,26 @@ class DevEnvImportSQLCommand {
76
80
  await (0, _devEnvironmentCore.exec)(lando, this.slug, importArg, {
77
81
  stdio: [fd, 'pipe', 'pipe']
78
82
  });
79
- if (!silent) {
83
+ if (!this.options.quiet) {
80
84
  console.log(`${_chalk.default.green.bold('Success:')} Database imported.`);
81
85
  }
82
86
  } finally {
83
87
  process.stdin.isTTY = origIsTTY;
84
88
  }
85
- if (searchReplace && searchReplace.length && !inPlace) {
89
+ if (searchReplace?.length && !inPlace) {
86
90
  _fs.default.unlinkSync(resolvedPath);
87
91
  }
88
- const cacheArg = ['wp', 'cache', 'flush'];
92
+ const cacheArg = ['wp', 'cache', 'flush'].concat(this.options.quiet ? '--quiet' : []);
89
93
  await (0, _devEnvironmentCore.exec)(lando, this.slug, cacheArg);
90
- try {
91
- await (0, _devEnvironmentCore.exec)(lando, this.slug, ['wp', 'cli', 'has-command', 'vip-search']);
92
- const doIndex = await (0, _devEnvironmentCli.promptForBoolean)('Do you want to index data in Elasticsearch (used by Enterprise Search)?', true);
93
- if (doIndex) {
94
+ if (undefined === this.options.skipReindex || !(0, _devEnvironmentCli.processBooleanOption)(this.options.skipReindex)) {
95
+ try {
96
+ await (0, _devEnvironmentCore.exec)(lando, this.slug, ['wp', 'cli', 'has-command', 'vip-search']);
94
97
  await (0, _devEnvironmentCore.exec)(lando, this.slug, ['wp', 'vip-search', 'index', '--setup', '--network-wide', '--skip-confirm']);
98
+ } catch {
99
+ // Exception means they don't have vip-search enabled.
95
100
  }
96
- } catch (err) {
97
- // Exception means they don't have vip-search enabled.
98
101
  }
99
- const addUserArg = ['wp', 'dev-env-add-admin', '--username=vipgo', '--password=password'];
102
+ const addUserArg = ['wp', 'dev-env-add-admin', '--username=vipgo', '--password=password'].concat(this.options.quiet ? '--quiet' : []);
100
103
  await (0, _devEnvironmentCore.exec)(lando, this.slug, addUserArg);
101
104
  }
102
105
  }
@@ -157,10 +157,11 @@ class DevEnvSyncSQLCommand {
157
157
  async runImport() {
158
158
  const importOptions = {
159
159
  inPlace: true,
160
- skipValidate: true
160
+ skipValidate: true,
161
+ quiet: true
161
162
  };
162
163
  const importCommand = new _devEnvImportSql.DevEnvImportSQLCommand(this.sqlFile, importOptions, this.slug);
163
- await importCommand.run(true);
164
+ await importCommand.run();
164
165
  }
165
166
 
166
167
  /**