@automattic/vip 2.7.0-dev1 → 2.8.0-alpha
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/README.md +7 -0
- package/automattic-vip-2.8.0-alpha.tgz +0 -0
- package/dist/bin/vip-config-envvar-set.js +8 -1
- package/dist/bin/vip-dev-env-list.js +37 -0
- package/dist/bin/vip-dev-env.js +1 -1
- package/dist/bin/vip-logs.js +96 -20
- package/dist/bin/vip-whoami.js +67 -0
- package/dist/bin/vip.js +1 -1
- package/dist/lib/api/user.js +58 -0
- package/dist/lib/api.js +7 -2
- package/dist/lib/app-logs/app-logs.js +70 -0
- package/dist/lib/dev-environment/dev-environment-cli.js +1 -1
- package/dist/lib/site-import/status.js +16 -9
- package/npm-shrinkwrap.json +14454 -0
- package/package.json +5 -3
- package/automattic-vip-2.7.0-dev1.tgz +0 -0
- package/dist/bin/vip-dev-environment-start.js +0 -41
- package/dist/bin/vip-dev-environment.js +0 -23
- package/dist/lib/dev-environment.js +0 -194
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/vip",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0-alpha",
|
|
4
4
|
"description": "The VIP Javascript library & CLI",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"vip-dev-env-import-media": "dist/bin/vip-dev-env-import-media.js",
|
|
24
24
|
"vip-dev-env-import-sql": "dist/bin/vip-dev-env-import-sql.js",
|
|
25
25
|
"vip-dev-env-info": "dist/bin/vip-dev-env-info.js",
|
|
26
|
+
"vip-dev-env-list": "dist/bin/vip-dev-env-list.js",
|
|
26
27
|
"vip-dev-env-start": "dist/bin/vip-dev-env-start.js",
|
|
27
28
|
"vip-dev-env-stop": "dist/bin/vip-dev-env-stop.js",
|
|
28
29
|
"vip-import": "dist/bin/vip-import.js",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"vip-logs": "dist/bin/vip-logs.js",
|
|
37
38
|
"vip-search-replace": "dist/bin/vip-search-replace.js",
|
|
38
39
|
"vip-sync": "dist/bin/vip-sync.js",
|
|
40
|
+
"vip-whoami": "dist/bin/vip-whoami.js",
|
|
39
41
|
"vip-wp": "dist/bin/vip-wp.js"
|
|
40
42
|
},
|
|
41
43
|
"scripts": {
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
"cli-columns": "^4.0.0",
|
|
110
112
|
"cli-table": "github:automattic/cli-table#7b14232",
|
|
111
113
|
"configstore": "5.0.1",
|
|
112
|
-
"debug": "4.3.
|
|
114
|
+
"debug": "4.3.3",
|
|
113
115
|
"ejs": "^3.1.6",
|
|
114
116
|
"enquirer": "2.3.6",
|
|
115
117
|
"graphql": "15.5.1",
|
|
@@ -117,7 +119,7 @@
|
|
|
117
119
|
"ini": "2.0.0",
|
|
118
120
|
"json2csv": "5.0.6",
|
|
119
121
|
"jwt-decode": "2.2.0",
|
|
120
|
-
"lando": "git+https://github.com/Automattic/lando-cli.git#v3.5.1-
|
|
122
|
+
"lando": "git+https://github.com/Automattic/lando-cli.git#v3.5.1-patch2021_12_06",
|
|
121
123
|
"node-fetch": "^2.6.1",
|
|
122
124
|
"opn": "5.5.0",
|
|
123
125
|
"rollbar": "2.22.0",
|
|
Binary file
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @fomat
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
14
|
-
|
|
15
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
-
|
|
17
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
-
|
|
19
|
-
var _devEnvironment = require("../lib/dev-environment");
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Internal dependencies
|
|
25
|
-
*/
|
|
26
|
-
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment'); // Command examples
|
|
27
|
-
|
|
28
|
-
const examples = [{
|
|
29
|
-
usage: 'vip dev-environment start',
|
|
30
|
-
description: 'Starts local dev environment\n' + ' * If the environment isn\'t built yet it will build it as well'
|
|
31
|
-
}];
|
|
32
|
-
(0, _command.default)().option('slug', `Custom name of the dev environment (default: "${_devEnvironment.defaults.environmentSlug}")`).option('title', 'Title for the WordPress site (default: "VIP Dev")').option('multisite', 'Enable multisite install').option('php', 'Use a specific PHP version').option('wordpress', 'Use a specific WordPress version or local directory (default: last stable)').option('mu-plugins', 'Use a specific mu-plugins changeset or local directory (default: "auto": last commit in master)').option('jetpack', 'Use a specific Jetpack from a local directory (default: "mu": use the version in mu-plugins)').option('client-code', 'Use the client code from a local directory or VIP skeleton (default: use the VIP skeleton)').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
33
|
-
const slug = opt.slug || _devEnvironment.defaults.environmentSlug;
|
|
34
|
-
debug('Args: ', arg, 'Options: ', opt);
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
await (0, _devEnvironment.startEnvironment)(slug, opt);
|
|
38
|
-
} catch (e) {
|
|
39
|
-
console.log(_chalk.default.red('Error:'), e.message);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @fomat
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
-
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
|
-
(0, _command.default)({
|
|
22
|
-
requiredArgs: 1
|
|
23
|
-
}).command('start', 'Start the local dev environment').argv(process.argv);
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.startEnvironment = startEnvironment;
|
|
7
|
-
exports.generateInstanceData = generateInstanceData;
|
|
8
|
-
exports.getEnvironmentPath = getEnvironmentPath;
|
|
9
|
-
exports.defaults = void 0;
|
|
10
|
-
|
|
11
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
12
|
-
|
|
13
|
-
var _xdgBasedir = _interopRequireDefault(require("xdg-basedir"));
|
|
14
|
-
|
|
15
|
-
var _os = _interopRequireDefault(require("os"));
|
|
16
|
-
|
|
17
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
18
|
-
|
|
19
|
-
var _ejs = _interopRequireDefault(require("ejs"));
|
|
20
|
-
|
|
21
|
-
var _path = _interopRequireDefault(require("path"));
|
|
22
|
-
|
|
23
|
-
var _lando = _interopRequireDefault(require("lando/lib/lando"));
|
|
24
|
-
|
|
25
|
-
var _utils = _interopRequireDefault(require("lando/plugins/lando-core/lib/utils"));
|
|
26
|
-
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @format
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* External dependencies
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Internal dependencies
|
|
40
|
-
*/
|
|
41
|
-
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
42
|
-
const containerImages = {
|
|
43
|
-
wordpress: {
|
|
44
|
-
image: 'wpvipdev/wordpress',
|
|
45
|
-
tag: '5.6'
|
|
46
|
-
},
|
|
47
|
-
jetpack: {
|
|
48
|
-
image: 'wpvipdev/jetpack'
|
|
49
|
-
},
|
|
50
|
-
muPlugins: {
|
|
51
|
-
image: 'wpvipdev/mu-plugins',
|
|
52
|
-
tag: 'auto'
|
|
53
|
-
},
|
|
54
|
-
clientCode: {
|
|
55
|
-
image: 'wpvipdev/skeleton',
|
|
56
|
-
tag: '181a17d9aedf7da73730d65ccef3d8dbf172a5c5'
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const defaults = {
|
|
60
|
-
environmentSlug: 'vip-local',
|
|
61
|
-
title: 'VIP Dev',
|
|
62
|
-
multisite: false,
|
|
63
|
-
phpVersion: '7.3',
|
|
64
|
-
jetpack: {
|
|
65
|
-
mode: 'inherit'
|
|
66
|
-
},
|
|
67
|
-
wordpress: {},
|
|
68
|
-
muPlugins: {},
|
|
69
|
-
clientCode: {}
|
|
70
|
-
};
|
|
71
|
-
exports.defaults = defaults;
|
|
72
|
-
['wordpress', 'muPlugins', 'clientCode'].forEach(type => {
|
|
73
|
-
defaults[type] = {
|
|
74
|
-
mode: 'image',
|
|
75
|
-
image: containerImages[type].image,
|
|
76
|
-
tag: containerImages[type].tag
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
const landoFileTemplatePath = 'assets/dev-environment.lando.template.yml.ejs';
|
|
80
|
-
const landoFileName = '.lando.yml';
|
|
81
|
-
|
|
82
|
-
async function startEnvironment(slug, options) {
|
|
83
|
-
debug('Will start an environment', slug, 'with options: ', options);
|
|
84
|
-
const instancePath = getEnvironmentPath(slug);
|
|
85
|
-
|
|
86
|
-
const alreadyExists = _fs.default.existsSync(instancePath);
|
|
87
|
-
|
|
88
|
-
if (alreadyExists) {
|
|
89
|
-
const parameters = Object.keys(options || {}).filter(key => key !== 'slug');
|
|
90
|
-
|
|
91
|
-
if (parameters && parameters.length) {
|
|
92
|
-
throw new Error(`The environment ${slug} already exists and we can not change its configuration` + ` ( configuration parameters - ${parameters.join(', ')} found ).` + ' Destroy the environment first if you would like to recreate it.');
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
const instanceData = generateInstanceData(slug, options);
|
|
96
|
-
debug('Instance data to create a new environment:', instanceData);
|
|
97
|
-
await prepareLandoEnv(instanceData, instancePath);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
await landoStart(instancePath);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function getLandoConfig() {
|
|
104
|
-
const landoPath = _path.default.join(__dirname, '..', '..', 'node_modules', 'lando');
|
|
105
|
-
|
|
106
|
-
debug(`Getting lando config, using path '${landoPath}' for plugins`);
|
|
107
|
-
return {
|
|
108
|
-
logLevelConsole: 'warn',
|
|
109
|
-
landoFile: '.lando.yml',
|
|
110
|
-
preLandoFiles: ['.lando.base.yml', '.lando.dist.yml', '.lando.upstream.yml'],
|
|
111
|
-
postLandoFiles: ['.lando.local.yml'],
|
|
112
|
-
pluginDirs: [landoPath, {
|
|
113
|
-
path: _path.default.join(landoPath, 'integrations'),
|
|
114
|
-
subdir: '.'
|
|
115
|
-
}]
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function landoStart(instancePath) {
|
|
120
|
-
debug('Will start lando app on path:', instancePath);
|
|
121
|
-
const lando = new _lando.default(getLandoConfig());
|
|
122
|
-
await lando.bootstrap();
|
|
123
|
-
const app = lando.getApp(instancePath);
|
|
124
|
-
await app.init();
|
|
125
|
-
await app.start();
|
|
126
|
-
console.log(lando.cli.formatData(_utils.default.startTable(app), {
|
|
127
|
-
format: 'table'
|
|
128
|
-
}, {
|
|
129
|
-
border: false
|
|
130
|
-
}));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async function prepareLandoEnv(instanceData, instancePath) {
|
|
134
|
-
const landoFile = await _ejs.default.renderFile(landoFileTemplatePath, instanceData);
|
|
135
|
-
|
|
136
|
-
const landoFileTargetPath = _path.default.join(instancePath, landoFileName);
|
|
137
|
-
|
|
138
|
-
_fs.default.mkdirSync(instancePath, {
|
|
139
|
-
recursive: true
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
_fs.default.writeFileSync(landoFileTargetPath, landoFile);
|
|
143
|
-
|
|
144
|
-
debug(`Lando file created in ${landoFileTargetPath}`);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function generateInstanceData(slug, options) {
|
|
148
|
-
const instanceData = {
|
|
149
|
-
siteSlug: slug,
|
|
150
|
-
wpTitle: options.title || defaults.title,
|
|
151
|
-
multisite: options.multisite || defaults.multisite,
|
|
152
|
-
phpVersion: options.phpVersion || defaults.phpVersion,
|
|
153
|
-
wordpress: getParamInstanceData(options.wordpress, 'wordpress'),
|
|
154
|
-
muPlugins: getParamInstanceData(options.muPlugins, 'muPlugins'),
|
|
155
|
-
jetpack: getParamInstanceData(options.jetpack, 'jetpack'),
|
|
156
|
-
clientCode: getParamInstanceData(options.clientCode, 'clientCode')
|
|
157
|
-
};
|
|
158
|
-
return instanceData;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function getParamInstanceData(param, type) {
|
|
162
|
-
if (param) {
|
|
163
|
-
if (param.includes('/')) {
|
|
164
|
-
return {
|
|
165
|
-
mode: 'local',
|
|
166
|
-
dir: param
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (type === 'jetpack' && param === 'mu') {
|
|
171
|
-
return {
|
|
172
|
-
mode: 'inherit'
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
mode: 'image',
|
|
178
|
-
image: containerImages[type].image,
|
|
179
|
-
tag: param
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return defaults[type];
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function getEnvironmentPath(name) {
|
|
187
|
-
if (!name) {
|
|
188
|
-
throw new Error('Name was not provided');
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const mainEnvironmentPath = _xdgBasedir.default.data || _os.default.tmpdir();
|
|
192
|
-
|
|
193
|
-
return _path.default.join(mainEnvironmentPath, 'vip', 'dev-environment', name);
|
|
194
|
-
}
|