@automattic/vip 2.34.0 → 2.35.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.35.0
4
+
5
+ - #1506 Allow imports for all sites with databases by @chriszarate in https://github.com/Automattic/vip-cli/pull/1507
6
+ - #1497 fix: remove import bypass for TypeScript by @sjinks in https://github.com/Automattic/vip-cli/pull/1497
7
+ - #1496 fix(dev-env): update certificate Common Name by @sjinks in https://github.com/Automattic/vip-cli/pull/1496
8
+ - #1513 refactor: use `semver` instead of `check-node-version` by @sjinks in https://github.com/Automattic/vip-cli/pull/1513
9
+ - #1514 chore(dev-deps): update TypeScript type definitions by @sjinks in https://github.com/Automattic/vip-cli/pull/1514
10
+ - #1508 chore(dev-deps): update jest-related packages to 29.7.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1508
11
+ - #1509 chore(dev-deps): update eslint from 8.47.0 to 8.49.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1509
12
+ - #1510 chore(deps): update uuid from 9.0.0 to 9.0.1 by @sjinks in https://github.com/Automattic/vip-cli/pull/1510
13
+ - #1512 chore(deps): update node-fetch from 2.6.12 to 2.7.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1512
14
+ - #1511 chore(deps): update graphql-tag from 2.12.5 to 2.12.6 by @sjinks in https://github.com/Automattic/vip-cli/pull/1511
15
+ - #1517 chore(dev-deps): update rimraf from 5.0.1 to 5.0.5 by @sjinks in https://github.com/Automattic/vip-cli/pull/1517
16
+ - #1516 chore(dev-deps): update eslint from 8.49.0 to 8.50.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1516
17
+ - #1499 chore(dev-deps): update @automattic/eslint-plugin-wpvip to 0.6.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1499
18
+
3
19
  ### 2.34.0
4
20
 
5
21
  - #1503 chore(dev-deps): update nock to 13.3.3
@@ -1,10 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- /**
4
- *
5
- * @format
6
- */
7
-
8
3
  /**
9
4
  * External dependencies
10
5
  */
@@ -44,6 +44,7 @@ const appQuery = `
44
44
  id,
45
45
  name,
46
46
  type,
47
+ typeId
47
48
  organization { id, name },
48
49
  environments{
49
50
  id
@@ -14,10 +14,12 @@ const debug = (0, _debug.default)('@automattic/vip:lib:cli:config');
14
14
  let configFromFile;
15
15
  try {
16
16
  // Get `local` config first; this will only exist in dev as it's npmignore-d.
17
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
17
18
  configFromFile = require("../../../config/config.local.json");
18
19
  debug('Loaded config data from config.local.json');
19
20
  } catch {
20
21
  // Fall back to `publish` config file.
22
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
21
23
  configFromFile = require("../../../config/config.publish.json");
22
24
  debug('Loaded config data from config.publish.json');
23
25
  }
@@ -4,12 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.StepStatus = exports.ProgressTracker = void 0;
7
+ var _nodeOs = require("node:os");
7
8
  var _singleLineLog = require("single-line-log");
8
9
  var _format = require("../../lib/cli/format");
9
- var _os = _interopRequireDefault(require("os"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- // @format
12
-
13
10
  /**
14
11
  * External dependencies
15
12
  */
@@ -68,7 +65,7 @@ class ProgressTracker {
68
65
  map.set(id, {
69
66
  id,
70
67
  name,
71
- status: status || StepStatus.PENDING
68
+ status: status ?? StepStatus.PENDING
72
69
  });
73
70
  return map;
74
71
  }, new Map());
@@ -104,10 +101,10 @@ class ProgressTracker {
104
101
  }));
105
102
  if (!steps.some(({
106
103
  status
107
- }) => status === 'running')) {
104
+ }) => status === StepStatus.RUNNING)) {
108
105
  const firstPendingStepIndex = steps.findIndex(({
109
106
  status
110
- }) => status === 'pending');
107
+ }) => status === StepStatus.PENDING);
111
108
  if (firstPendingStepIndex !== -1) {
112
109
  // "Promote" the first "pending" to "running"
113
110
  formattedSteps[firstPendingStepIndex].status = StepStatus.RUNNING;
@@ -122,7 +119,7 @@ class ProgressTracker {
122
119
  const steps = [...this.getSteps().values()];
123
120
  return steps.find(({
124
121
  status
125
- }) => status === 'pending');
122
+ }) => status === StepStatus.PENDING);
126
123
  }
127
124
  getCurrentStep() {
128
125
  if (this.allStepsSucceeded()) {
@@ -131,7 +128,7 @@ class ProgressTracker {
131
128
  const steps = [...this.getSteps().values()];
132
129
  return steps.find(({
133
130
  status
134
- }) => status === 'running');
131
+ }) => status === StepStatus.RUNNING);
135
132
  }
136
133
  stepRunning(stepId) {
137
134
  this.setStatusForStepId(stepId, StepStatus.RUNNING);
@@ -153,7 +150,7 @@ class ProgressTracker {
153
150
  allStepsSucceeded() {
154
151
  return [...this.getSteps().values()].every(({
155
152
  status
156
- }) => status === 'success');
153
+ }) => status === StepStatus.SUCCESS);
157
154
  }
158
155
  setStatusForStepId(stepId, status) {
159
156
  const step = this.stepsFromCaller.get(stepId);
@@ -164,7 +161,7 @@ class ProgressTracker {
164
161
  if (COMPLETED_STEP_SLUGS.includes(step.status)) {
165
162
  throw new Error(`Step name ${stepId} is already completed.`);
166
163
  }
167
- if (status === 'failed') {
164
+ if (status === StepStatus.FAILED) {
168
165
  this.hasFailure = true;
169
166
  }
170
167
  this.stepsFromCaller.set(stepId, {
@@ -199,7 +196,7 @@ class ProgressTracker {
199
196
  // without this, any prompt, or any text in between will get overwritten by the progress tracker
200
197
  let linesToSkip = '';
201
198
  for (let iteration = 0; iteration < this.stepsFromCaller.size; iteration++) {
202
- linesToSkip += _os.default.EOL;
199
+ linesToSkip += _nodeOs.EOL;
203
200
  }
204
201
  process.stdout.write(linesToSkip);
205
202
  hasPrintedOnce = true;
@@ -230,7 +227,7 @@ class ProgressTracker {
230
227
  const statusIcon = (0, _format.getGlyphForStatus)(status, this.runningSprite);
231
228
  let suffix = '';
232
229
  if (id === 'upload') {
233
- if (status === 'running' && percentage) {
230
+ if (status === StepStatus.RUNNING && percentage) {
234
231
  suffix = percentage;
235
232
  }
236
233
  } else if (progress) {
@@ -42,11 +42,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
42
42
  // Need to use CommonJS imports here as the `fetch-retry` typedefs are messed up and throwing TypeJS errors when using `import`
43
43
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
44
44
  const fetchWithRetry =
45
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
45
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-var-requires
46
46
  require('fetch-retry')(_nodeFetch.default, {
47
47
  // Set default retry options
48
48
  retries: 3,
49
- retryDelay: (attempt, error, response) => {
49
+ retryDelay: attempt => {
50
50
  return Math.pow(2, attempt) * 1000; // 1000, 2000, 4000
51
51
  }
52
52
  });
@@ -213,7 +213,7 @@ async function uploadUsingPutObject({
213
213
  });
214
214
  const response = await fetchWithRetry(presignedRequest.url, {
215
215
  ...fetchOptions,
216
- body: fileContent ? fileContent : (0, _fs.createReadStream)(fileName).pipe(progressPassThrough)
216
+ body: fileContent ?? (0, _fs.createReadStream)(fileName).pipe(progressPassThrough)
217
217
  });
218
218
  if (response.status === 200) {
219
219
  return 'ok';
@@ -239,8 +239,9 @@ const promptForUpdate = async (appTypeId, opts, softwareSettings) => {
239
239
  const version = await _processComponentVersion(softwareSettings, component, opts.version);
240
240
  const confirm =
241
241
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
242
- opts.force || (await new _enquirer.Confirm({
243
- // NOSONAR
242
+ opts.force || (
243
+ // NOSONAR
244
+ await new _enquirer.Confirm({
244
245
  message: `Are you sure you want to upgrade ${COMPONENT_NAMES[component]} to ${version}?`
245
246
  }).run().catch(() => {
246
247
  throw new _userError.default('Command cancelled by user.');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WORDPRESS_SITE_TYPE_IDS = exports.WORDPRESS_NON_PROD_APPLICATION_TYPE_ID = exports.WORDPRESS_APPLICATION_TYPE_ID = exports.NODEJS_SITE_TYPE_IDS = exports.NODEJS_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_MYSQL_APPLICATION_TYPE_ID = exports.NODEJS_APPLICATION_TYPE_ID = void 0;
6
+ exports.WORDPRESS_SITE_TYPE_IDS = exports.WORDPRESS_NON_PROD_APPLICATION_TYPE_ID = exports.WORDPRESS_APPLICATION_TYPE_ID = exports.NODEJS_SITE_TYPE_IDS = exports.NODEJS_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_MYSQL_APPLICATION_TYPE_ID = exports.NODEJS_APPLICATION_TYPE_ID = exports.DATABASE_APPLICATION_TYPE_IDS = void 0;
7
7
  const WORDPRESS_APPLICATION_TYPE_ID = 2;
8
8
  exports.WORDPRESS_APPLICATION_TYPE_ID = WORDPRESS_APPLICATION_TYPE_ID;
9
9
  const WORDPRESS_NON_PROD_APPLICATION_TYPE_ID = 6;
@@ -19,4 +19,6 @@ exports.NODEJS_REDIS_APPLICATION_TYPE_ID = NODEJS_REDIS_APPLICATION_TYPE_ID;
19
19
  const NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = 8;
20
20
  exports.NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID;
21
21
  const NODEJS_SITE_TYPE_IDS = [NODEJS_APPLICATION_TYPE_ID, NODEJS_MYSQL_APPLICATION_TYPE_ID, NODEJS_REDIS_APPLICATION_TYPE_ID, NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID];
22
- exports.NODEJS_SITE_TYPE_IDS = NODEJS_SITE_TYPE_IDS;
22
+ exports.NODEJS_SITE_TYPE_IDS = NODEJS_SITE_TYPE_IDS;
23
+ const DATABASE_APPLICATION_TYPE_IDS = [WORDPRESS_APPLICATION_TYPE_ID, WORDPRESS_NON_PROD_APPLICATION_TYPE_ID, NODEJS_MYSQL_APPLICATION_TYPE_ID, NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID];
24
+ exports.DATABASE_APPLICATION_TYPE_IDS = DATABASE_APPLICATION_TYPE_IDS;
@@ -91,7 +91,7 @@ async function getLandoConfig() {
91
91
  proxyName: 'vip-dev-env-proxy',
92
92
  userConfRoot: landoDir,
93
93
  home: fakeHomeDir,
94
- domain: 'lndo.site',
94
+ domain: 'vipdev.lndo.site',
95
95
  version: 'unknown'
96
96
  };
97
97
  return (0, _bootstrap.buildConfig)(config);
@@ -101,8 +101,9 @@ async function initLandoApplication(lando, instancePath) {
101
101
  const app = lando.getApp(instancePath);
102
102
  app.events.on('post-init', 1, () => {
103
103
  const initOnly = [];
104
- Object.keys(app.config.services).forEach(serviceName => {
105
- if (app.config.services[serviceName].initOnly) {
104
+ const services = app.config.services;
105
+ Object.keys(services).forEach(serviceName => {
106
+ if (services[serviceName].initOnly) {
106
107
  initOnly.push(serviceName);
107
108
  app.config.services[serviceName].scanner = false;
108
109
  }
@@ -8,11 +8,6 @@ exports.getEnvContext = getEnvContext;
8
8
  var _debug = _interopRequireDefault(require("debug"));
9
9
  var _command = require("../../lib/cli/command");
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- /**
12
- *
13
- * @format
14
- */
15
-
16
11
  /**
17
12
  * External dependencies
18
13
  */
@@ -23,6 +18,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
18
 
24
19
  // Shared debugger.
25
20
  const debug = (0, _debug.default)('@automattic/vip:bin:config:envvar');
21
+
22
+ // FIXME: Replace with a proper type
26
23
  exports.debug = debug;
27
24
  function getEnvContext(app, env) {
28
25
  return `@${app.id}.${(0, _command.getEnvIdentifier)(env)}`;
@@ -19,6 +19,7 @@ let exportValue;
19
19
  const debug = (0, _debug.default)('@automattic/vip:keychain');
20
20
  try {
21
21
  // Try using Secure keychain ("keytar") first
22
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
22
23
  const Secure = require("./keychain/secure");
23
24
  exportValue = new Secure();
24
25
  } catch (error) {
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SYNC_STATUS_NOT_SYNCING = exports.SUPPORTED_DB_FILE_IMPORT_SITE_TYPES = exports.SQL_IMPORT_FILE_SIZE_LIMIT_LAUNCHED = exports.SQL_IMPORT_FILE_SIZE_LIMIT = void 0;
6
+ exports.SYNC_STATUS_NOT_SYNCING = exports.SQL_IMPORT_FILE_SIZE_LIMIT_LAUNCHED = exports.SQL_IMPORT_FILE_SIZE_LIMIT = void 0;
7
7
  exports.currentUserCanImportForApp = currentUserCanImportForApp;
8
8
  exports.isSupportedApp = exports.isImportingBlockedBySync = void 0;
9
9
  var _fileSize = require("../../lib/constants/file-size");
10
+ var _vipgo = require("../../lib/constants/vipgo");
10
11
  /**
11
12
  * Internal dependencies
12
13
  */
@@ -19,11 +20,9 @@ function currentUserCanImportForApp(app) {
19
20
  // TODO: implement
20
21
  return !!app;
21
22
  }
22
- const SUPPORTED_DB_FILE_IMPORT_SITE_TYPES = ['WordPress'];
23
- exports.SUPPORTED_DB_FILE_IMPORT_SITE_TYPES = SUPPORTED_DB_FILE_IMPORT_SITE_TYPES;
24
23
  const isSupportedApp = ({
25
- type
26
- }) => SUPPORTED_DB_FILE_IMPORT_SITE_TYPES.includes(type);
24
+ typeId
25
+ }) => _vipgo.DATABASE_APPLICATION_TYPE_IDS.includes(typeId);
27
26
  exports.isSupportedApp = isSupportedApp;
28
27
  const SYNC_STATUS_NOT_SYNCING = 'not_syncing';
29
28
  exports.SYNC_STATUS_NOT_SYNCING = SYNC_STATUS_NOT_SYNCING;
@@ -9,9 +9,9 @@ var _chalk = _interopRequireDefault(require("chalk"));
9
9
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
10
10
  var _debug = _interopRequireDefault(require("debug"));
11
11
  var _api = _interopRequireDefault(require("../../lib/api"));
12
- var _dbFileImport = require("../../lib/site-import/db-file-import");
13
12
  var exit = _interopRequireWildcard(require("../../lib/cli/exit"));
14
13
  var _format = require("../../lib/cli/format");
14
+ var _dbFileImport = require("./db-file-import");
15
15
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -69,7 +69,7 @@ async function isMultiSiteInSiteMeta(appId, envId) {
69
69
  }
70
70
  if (Array.isArray((_res$data$app = res.data.app) === null || _res$data$app === void 0 ? void 0 : _res$data$app.environments)) {
71
71
  const environments = res.data.app.environments;
72
- if (!environments.length) {
72
+ if (!(environments !== null && environments !== void 0 && environments.length)) {
73
73
  isMultiSite.set(args, false);
74
74
  return false;
75
75
  }
@@ -119,7 +119,7 @@ async function isMultisitePrimaryDomainMapped(appId, envId, primaryDomain) {
119
119
  return false;
120
120
  }
121
121
  const environments = res.data.app.environments;
122
- if (!environments.length) {
122
+ if (!(environments !== null && environments !== void 0 && environments.length)) {
123
123
  return false;
124
124
  }
125
125
  const mappedDomains = ((_environments$ = environments[0]) === null || _environments$ === void 0 || (_environments$ = _environments$.domains) === null || _environments$ === void 0 || (_environments$ = _environments$.nodes) === null || _environments$ === void 0 ? void 0 : _environments$.map(domain => domain === null || domain === void 0 ? void 0 : domain.name)) ?? [];
@@ -1,5 +1,4 @@
1
- const util = require( 'node:util' );
2
- const check = util.promisify( require( 'check-node-version' ) );
1
+ const { minVersion, satisfies, valid } = require( 'semver' );
3
2
  const { exec } = require( 'node:child_process' );
4
3
  const { EOL } = require( 'node:os' );
5
4
  const packageJSON = require( '../package.json' );
@@ -34,11 +33,15 @@ const releaseTag = process.env.npm_config_tag ?? 'latest';
34
33
  }
35
34
 
36
35
  if ( config.nodeEnforceVersion ) {
37
- const { isSatisfied, versions } = await check( { node: config.nodeEnforceVersion } );
36
+ const supported = packageJSON.engines.node;
37
+ const current = process.versions.node ?? process.version;
38
+ const isSatisfied = satisfies( current, supported );
38
39
 
39
40
  if ( ! isSatisfied ) {
40
41
  return bail(
41
- `Node version ${ versions.node.version } is not supported. Please use Node version ${ config.nodeEnforceVersion } or higher.`
42
+ `Node version ${ valid( current ) } is not supported. Please use Node version ${ valid(
43
+ minVersion( supported )
44
+ ) } or higher.`
42
45
  );
43
46
  }
44
47
  }