@automattic/vip 2.7.0-dev1 → 2.7.0-dev2
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/automattic-vip-2.7.0-dev2.tgz +0 -0
- package/dist/bin/vip-logs.js +1 -1
- package/dist/lib/app-logs/app-logs.js +62 -0
- package/package.json +1 -1
- 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
|
Binary file
|
package/dist/bin/vip-logs.js
CHANGED
|
@@ -18,7 +18,7 @@ var _rollbar = require("../lib/rollbar");
|
|
|
18
18
|
|
|
19
19
|
var _tracker = require("../lib/tracker");
|
|
20
20
|
|
|
21
|
-
var logsLib = _interopRequireWildcard(require("../lib/logs/logs"));
|
|
21
|
+
var logsLib = _interopRequireWildcard(require("../lib/app-logs/app-logs"));
|
|
22
22
|
|
|
23
23
|
var exit = _interopRequireWildcard(require("../lib/cli/exit"));
|
|
24
24
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getRecentLogs = getRecentLogs;
|
|
7
|
+
|
|
8
|
+
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
9
|
+
|
|
10
|
+
var _api = _interopRequireDefault(require("../api"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @format
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* External dependencies
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Internal dependencies
|
|
25
|
+
*/
|
|
26
|
+
const QUERY_ENVIRONMENT_LOGS = (0, _graphqlTag.default)`
|
|
27
|
+
query GetAppLogs( $appId: Int, $envId: Int, $type: AppEnvironmentLogType, $limit: Int ) {
|
|
28
|
+
app( id: $appId ) {
|
|
29
|
+
environments( id: $envId ) {
|
|
30
|
+
id
|
|
31
|
+
logs( type: $type, limit: $limit ) {
|
|
32
|
+
nodes {
|
|
33
|
+
timestamp
|
|
34
|
+
message
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
async function getRecentLogs(appId, envId, type, limit) {
|
|
43
|
+
var _response$data, _response$data$app, _response$data$app$en, _response$data$app$en2;
|
|
44
|
+
|
|
45
|
+
const api = await (0, _api.default)();
|
|
46
|
+
const response = await api.query({
|
|
47
|
+
query: QUERY_ENVIRONMENT_LOGS,
|
|
48
|
+
variables: {
|
|
49
|
+
appId,
|
|
50
|
+
envId,
|
|
51
|
+
type,
|
|
52
|
+
limit
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const logs = response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$app = _response$data.app) === null || _response$data$app === void 0 ? void 0 : (_response$data$app$en = _response$data$app.environments[0]) === null || _response$data$app$en === void 0 ? void 0 : (_response$data$app$en2 = _response$data$app$en.logs) === null || _response$data$app$en2 === void 0 ? void 0 : _response$data$app$en2.nodes;
|
|
56
|
+
|
|
57
|
+
if (!logs) {
|
|
58
|
+
throw new Error('Unable to query logs');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return logs;
|
|
62
|
+
}
|
package/package.json
CHANGED
|
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
|
-
}
|