@adobe/aio-cli-plugin-api-mesh 4.1.1-beta.1 → 5.0.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/oclif.manifest.json +1 -1
- package/package.json +3 -13
- package/src/commands/api-mesh/__tests__/create.test.js +217 -293
- package/src/commands/api-mesh/__tests__/delete.test.js +6 -6
- package/src/commands/api-mesh/__tests__/describe.test.js +2 -17
- package/src/commands/api-mesh/__tests__/get.test.js +9 -78
- package/src/commands/api-mesh/__tests__/log-get-bulk.test.js +1 -1
- package/src/commands/api-mesh/__tests__/run.test.js +22 -25
- package/src/commands/api-mesh/__tests__/status.test.js +1 -1
- package/src/commands/api-mesh/__tests__/update.test.js +8 -9
- package/src/commands/api-mesh/create.js +6 -9
- package/src/commands/api-mesh/delete.js +5 -5
- package/src/commands/api-mesh/describe.js +3 -3
- package/src/commands/api-mesh/get.js +8 -11
- package/src/commands/api-mesh/init.js +0 -2
- package/src/commands/api-mesh/log-get-bulk.js +2 -2
- package/src/commands/api-mesh/log-get.js +2 -2
- package/src/commands/api-mesh/log-list.js +1 -1
- package/src/commands/api-mesh/run.js +9 -35
- package/src/commands/api-mesh/source/install.js +3 -2
- package/src/commands/api-mesh/status.js +4 -6
- package/src/commands/api-mesh/update.js +7 -9
- package/src/constants.js +2 -0
- package/src/helpers.js +4 -71
- package/src/lib/devConsole.js +38 -32
- package/src/server.js +198 -36
- package/src/serverUtils.js +3 -3
- package/src/cors.js +0 -28
- package/src/fixPlugins.js +0 -28
- package/src/hooks/versionCompare.js +0 -23
- package/src/index.js +0 -44
- package/src/plugins/complianceHeaders/complianceHeaders.js +0 -55
- package/src/plugins/complianceHeaders/index.js +0 -2
- package/src/plugins/httpDetailsExtensions/LICENSE +0 -21
- package/src/plugins/httpDetailsExtensions/index.js +0 -81
- package/src/secrets.js +0 -34
- package/src/served.js +0 -22
- package/src/templates/wrangler.toml +0 -14
- package/src/utils/logger.js +0 -42
- package/src/utils/requestId.js +0 -26
- package/src/wranglerServer.js +0 -80
|
@@ -16,7 +16,6 @@ const logger = require('../../classes/logger');
|
|
|
16
16
|
const { initSdk, initRequestId } = require('../../helpers');
|
|
17
17
|
const { ignoreCacheFlag, jsonFlag } = require('../../utils');
|
|
18
18
|
const { getMeshId, getMesh } = require('../../lib/devConsole');
|
|
19
|
-
const { buildMeshUrl } = require('../../urlBuilder');
|
|
20
19
|
|
|
21
20
|
require('dotenv').config();
|
|
22
21
|
class GetCommand extends Command {
|
|
@@ -38,7 +37,7 @@ class GetCommand extends Command {
|
|
|
38
37
|
const ignoreCache = await flags.ignoreCache;
|
|
39
38
|
const json = await flags.json;
|
|
40
39
|
|
|
41
|
-
const {
|
|
40
|
+
const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
|
|
42
41
|
ignoreCache,
|
|
43
42
|
verbose: !json,
|
|
44
43
|
});
|
|
@@ -46,22 +45,20 @@ class GetCommand extends Command {
|
|
|
46
45
|
let meshId = null;
|
|
47
46
|
|
|
48
47
|
try {
|
|
49
|
-
meshId = await getMeshId(
|
|
48
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
50
49
|
} catch (err) {
|
|
51
50
|
this.error(
|
|
52
|
-
`Unable to get mesh ID.
|
|
51
|
+
`Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
|
|
53
52
|
);
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
if (meshId) {
|
|
57
56
|
try {
|
|
58
|
-
const mesh = await getMesh(
|
|
57
|
+
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId);
|
|
59
58
|
|
|
60
59
|
if (mesh) {
|
|
61
60
|
this.log('Successfully retrieved mesh %s', JSON.stringify(mesh, null, 2));
|
|
62
61
|
|
|
63
|
-
const meshUrl = buildMeshUrl(meshId, workspaceName);
|
|
64
|
-
|
|
65
62
|
if (args.file) {
|
|
66
63
|
try {
|
|
67
64
|
const { meshConfig } = mesh;
|
|
@@ -75,10 +72,10 @@ class GetCommand extends Command {
|
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
|
|
78
|
-
return
|
|
75
|
+
return mesh;
|
|
79
76
|
} else {
|
|
80
77
|
logger.error(
|
|
81
|
-
`Unable to get mesh with the ID ${meshId}.
|
|
78
|
+
`Unable to get mesh with the ID ${meshId}. Check the mesh ID and try again. RequestId: ${global.requestId}`,
|
|
82
79
|
{ exit: false },
|
|
83
80
|
);
|
|
84
81
|
}
|
|
@@ -86,12 +83,12 @@ class GetCommand extends Command {
|
|
|
86
83
|
this.log(error.message);
|
|
87
84
|
|
|
88
85
|
this.error(
|
|
89
|
-
`Unable to get mesh.
|
|
86
|
+
`Unable to get mesh. Check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
|
|
90
87
|
);
|
|
91
88
|
}
|
|
92
89
|
} else {
|
|
93
90
|
this.error(
|
|
94
|
-
`Unable to get mesh config. No mesh found for Org(${
|
|
91
|
+
`Unable to get mesh config. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
|
|
95
92
|
{ exit: false },
|
|
96
93
|
);
|
|
97
94
|
}
|
|
@@ -108,7 +108,6 @@ class InitCommand extends Command {
|
|
|
108
108
|
const readmePath = `${getAppRootDir()}/src/templates/readme.md`;
|
|
109
109
|
const sampleMeshConfigPath = `${getAppRootDir()}/src/templates/mesh.json`;
|
|
110
110
|
const newRelicConfigPath = `${getAppRootDir()}/src/templates/newrelic.cjs`;
|
|
111
|
-
const wranglerTomlTemplate = `${getAppRootDir()}/src/templates/wrangler.toml`;
|
|
112
111
|
const shouldCreateWorkspace = await promptConfirm(
|
|
113
112
|
`Do you want to create the workspace in ${absolutePath}`,
|
|
114
113
|
);
|
|
@@ -181,7 +180,6 @@ class InitCommand extends Command {
|
|
|
181
180
|
await this.cloneFile(readmePath, `${absolutePath}/README.md`);
|
|
182
181
|
await this.cloneFile(sampleMeshConfigPath, `${absolutePath}/mesh.json`);
|
|
183
182
|
await this.cloneFile(newRelicConfigPath, `${absolutePath}/newrelic.cjs`);
|
|
184
|
-
await this.cloneFile(wranglerTomlTemplate, `${absolutePath}/wrangler.toml`);
|
|
185
183
|
|
|
186
184
|
this.log(`Installing dependencies`);
|
|
187
185
|
|
|
@@ -147,14 +147,14 @@ class GetBulkLogCommand extends Command {
|
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
logger.info('Calling initSdk...');
|
|
150
|
-
const {
|
|
150
|
+
const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
|
|
151
151
|
ignoreCache,
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
// Retrieve meshId
|
|
155
155
|
let meshId = null;
|
|
156
156
|
try {
|
|
157
|
-
meshId = await getMeshId(
|
|
157
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
158
158
|
} catch (err) {
|
|
159
159
|
this.error(`Unable to get mesh ID: ${err.message}.`);
|
|
160
160
|
}
|
|
@@ -31,13 +31,13 @@ class FetchLogsCommand extends Command {
|
|
|
31
31
|
const ignoreCache = flags.ignoreCache;
|
|
32
32
|
const rayId = args.rayId;
|
|
33
33
|
|
|
34
|
-
const {
|
|
34
|
+
const { imsOrgCode, projectId, workspaceId } = await initSdk({
|
|
35
35
|
ignoreCache,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
let meshId = null;
|
|
39
39
|
try {
|
|
40
|
-
meshId = await getMeshId(
|
|
40
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, meshId);
|
|
41
41
|
if (!meshId) {
|
|
42
42
|
throw new Error('MeshIdNotFound');
|
|
43
43
|
}
|
|
@@ -43,7 +43,7 @@ class ListLogsCommand extends Command {
|
|
|
43
43
|
let meshId = null;
|
|
44
44
|
|
|
45
45
|
try {
|
|
46
|
-
meshId = await getMeshId(
|
|
46
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
47
47
|
} catch (err) {
|
|
48
48
|
this.error(
|
|
49
49
|
`Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
|
|
@@ -26,10 +26,12 @@ const {
|
|
|
26
26
|
} = require('../../utils');
|
|
27
27
|
const meshBuilder = require('@adobe-apimesh/mesh-builder');
|
|
28
28
|
const fs = require('fs');
|
|
29
|
+
const UUID = require('../../uuid');
|
|
29
30
|
const path = require('path');
|
|
30
31
|
const {
|
|
31
32
|
initSdk,
|
|
32
33
|
initRequestId,
|
|
34
|
+
startGraphqlServer,
|
|
33
35
|
importFiles,
|
|
34
36
|
setUpTenantFiles,
|
|
35
37
|
writeSecretsFile,
|
|
@@ -37,8 +39,6 @@ const {
|
|
|
37
39
|
const logger = require('../../classes/logger');
|
|
38
40
|
const { getMeshId, getMeshArtifact } = require('../../lib/devConsole');
|
|
39
41
|
require('dotenv').config();
|
|
40
|
-
const { runServer } = require('../../server');
|
|
41
|
-
const { fixPlugins } = require('../../fixPlugins');
|
|
42
42
|
|
|
43
43
|
const { validateMesh, buildMesh, compileMesh } = meshBuilder.default;
|
|
44
44
|
|
|
@@ -82,10 +82,10 @@ class RunCommand extends Command {
|
|
|
82
82
|
if (fs.existsSync(path.join(process.cwd(), 'package.json'))) {
|
|
83
83
|
//If select flag is present then getMeshId for the specified org
|
|
84
84
|
if (flags.select) {
|
|
85
|
-
const {
|
|
85
|
+
const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({});
|
|
86
86
|
|
|
87
87
|
try {
|
|
88
|
-
meshId = await getMeshId(
|
|
88
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
89
89
|
} catch (err) {
|
|
90
90
|
throw new Error(
|
|
91
91
|
`Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
|
|
@@ -93,7 +93,7 @@ class RunCommand extends Command {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
|
-
await getMeshArtifact(
|
|
96
|
+
await getMeshArtifact(imsOrgCode, projectId, workspaceId, workspaceName, meshId);
|
|
97
97
|
} catch (err) {
|
|
98
98
|
throw new Error(
|
|
99
99
|
`Unable to retrieve mesh. Please check the details and try again. RequestId: ${global.requestId}`,
|
|
@@ -163,12 +163,13 @@ class RunCommand extends Command {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
//Generating unique mesh id
|
|
166
|
-
meshId =
|
|
166
|
+
meshId = UUID.newUuid().toString();
|
|
167
167
|
|
|
168
168
|
await validateMesh(data.meshConfig);
|
|
169
169
|
await buildMesh(meshId, data.meshConfig);
|
|
170
170
|
await compileMesh(meshId);
|
|
171
171
|
}
|
|
172
|
+
|
|
172
173
|
let portNo;
|
|
173
174
|
//secrets management
|
|
174
175
|
if (secretsFilePath) {
|
|
@@ -182,8 +183,6 @@ class RunCommand extends Command {
|
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
|
|
185
|
-
await this.copyMeshContent(meshId);
|
|
186
|
-
|
|
187
186
|
//To set the port number using the environment file
|
|
188
187
|
if (process.env.PORT !== undefined) {
|
|
189
188
|
if (isNaN(process.env.PORT) || !Number.isInteger(parseInt(process.env.PORT))) {
|
|
@@ -202,9 +201,9 @@ class RunCommand extends Command {
|
|
|
202
201
|
if (!portNo) {
|
|
203
202
|
portNo = 5000;
|
|
204
203
|
}
|
|
204
|
+
|
|
205
205
|
this.log(`Starting server on port : ${portNo}`);
|
|
206
|
-
await
|
|
207
|
-
this.log(`Server is running on http://localhost:${portNo}/graphql`);
|
|
206
|
+
await startGraphqlServer(meshId, portNo, flags.debug);
|
|
208
207
|
} else {
|
|
209
208
|
throw new Error(
|
|
210
209
|
'`aio api-mesh run` cannot be executed because there is no package.json file in the current directory. Use `aio api-mesh init` to set up a package.',
|
|
@@ -214,31 +213,6 @@ class RunCommand extends Command {
|
|
|
214
213
|
this.error(error.message);
|
|
215
214
|
}
|
|
216
215
|
}
|
|
217
|
-
|
|
218
|
-
async copyMeshContent(meshId) {
|
|
219
|
-
// Remove mesh artifact directory if exists
|
|
220
|
-
if (fs.existsSync('.mesh')) {
|
|
221
|
-
fs.rmSync('.mesh', { recursive: true });
|
|
222
|
-
}
|
|
223
|
-
// Move built mesh artifact to expect directory
|
|
224
|
-
fs.renameSync(`mesh-artifact/${meshId}`, '.mesh');
|
|
225
|
-
// Remove tenant files directory if exists
|
|
226
|
-
if (fs.existsSync('tenantFiles')) {
|
|
227
|
-
fs.rmSync('tenantFiles', { recursive: true });
|
|
228
|
-
}
|
|
229
|
-
// Move built tenant files if exists
|
|
230
|
-
if (fs.existsSync('mesh-artifact/tenantFiles')) {
|
|
231
|
-
fs.cpSync('mesh-artifact/tenantFiles', '.mesh/tenantFiles', { recursive: true });
|
|
232
|
-
fs.renameSync('mesh-artifact/tenantFiles', 'tenantFiles');
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
await fixPlugins('.mesh/index.js');
|
|
236
|
-
|
|
237
|
-
if (fs.existsSync(`${__dirname}/../../../.mesh`)) {
|
|
238
|
-
fs.rmSync(`${__dirname}/../../../.mesh`, { recursive: true });
|
|
239
|
-
}
|
|
240
|
-
fs.cpSync('.mesh', `${__dirname}/../../../.mesh`, { recursive: true });
|
|
241
|
-
}
|
|
242
216
|
}
|
|
243
217
|
|
|
244
218
|
module.exports = RunCommand;
|
|
@@ -38,6 +38,7 @@ class InstallCommand extends Command {
|
|
|
38
38
|
const ignoreCache = await flags.ignoreCache;
|
|
39
39
|
const {
|
|
40
40
|
imsOrgId,
|
|
41
|
+
imsOrgCode,
|
|
41
42
|
projectId,
|
|
42
43
|
workspaceId,
|
|
43
44
|
organizationName,
|
|
@@ -126,7 +127,7 @@ class InstallCommand extends Command {
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
try {
|
|
129
|
-
meshId = await getMeshId(
|
|
130
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
130
131
|
} catch (err) {
|
|
131
132
|
this.error(
|
|
132
133
|
`Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
|
|
@@ -140,7 +141,7 @@ class InstallCommand extends Command {
|
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
try {
|
|
143
|
-
const mesh = await getMesh(
|
|
144
|
+
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, meshId, workspaceName);
|
|
144
145
|
|
|
145
146
|
if (!mesh) {
|
|
146
147
|
this.error(
|
|
@@ -18,14 +18,14 @@ class StatusCommand extends Command {
|
|
|
18
18
|
|
|
19
19
|
const { flags } = await this.parse(StatusCommand);
|
|
20
20
|
const ignoreCache = await flags.ignoreCache;
|
|
21
|
-
const {
|
|
21
|
+
const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
|
|
22
22
|
ignoreCache,
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
let meshId = null;
|
|
26
26
|
|
|
27
27
|
try {
|
|
28
|
-
meshId = await getMeshId(
|
|
28
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
29
29
|
} catch (err) {
|
|
30
30
|
// API Request failed
|
|
31
31
|
this.log(err.message);
|
|
@@ -37,17 +37,15 @@ class StatusCommand extends Command {
|
|
|
37
37
|
// API Request succeeded, but mesh could not be found
|
|
38
38
|
if (!meshId) {
|
|
39
39
|
this.error(
|
|
40
|
-
`Unable to get mesh status. No mesh found for Org(${
|
|
40
|
+
`Unable to get mesh status. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Check the details and try again.`,
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
try {
|
|
45
|
-
const mesh = await getMesh(
|
|
45
|
+
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId);
|
|
46
46
|
this.log(''.padEnd(102, '*'));
|
|
47
47
|
await this.displayMeshStatus(mesh, imsOrgCode, projectId, workspaceId);
|
|
48
48
|
this.log(''.padEnd(102, '*'));
|
|
49
|
-
|
|
50
|
-
return mesh;
|
|
51
49
|
} catch (err) {
|
|
52
50
|
// Error occurred while fetching/displaying the mesh status
|
|
53
51
|
this.error(
|
|
@@ -73,10 +73,10 @@ class UpdateCommand extends Command {
|
|
|
73
73
|
let meshId = null;
|
|
74
74
|
|
|
75
75
|
try {
|
|
76
|
-
meshId = await getMeshId(
|
|
76
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId);
|
|
77
77
|
} catch (err) {
|
|
78
78
|
this.error(
|
|
79
|
-
`Unable to get mesh ID.
|
|
79
|
+
`Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -90,7 +90,7 @@ class UpdateCommand extends Command {
|
|
|
90
90
|
data = JSON.parse(inputMeshData);
|
|
91
91
|
} catch (err) {
|
|
92
92
|
this.log(err.message);
|
|
93
|
-
this.error('Input mesh file is not a valid JSON.
|
|
93
|
+
this.error('Input mesh file is not a valid JSON. Check the file provided.');
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -109,9 +109,7 @@ class UpdateCommand extends Command {
|
|
|
109
109
|
data = await importFiles(data, filesList, args.file, flags.autoConfirmAction);
|
|
110
110
|
} catch (err) {
|
|
111
111
|
this.log(err.message);
|
|
112
|
-
this.error(
|
|
113
|
-
'Unable to import the files in the mesh config. Please check the file and try again.',
|
|
114
|
-
);
|
|
112
|
+
this.error('Unable to import the files in the mesh config. Check the file and try again.');
|
|
115
113
|
}
|
|
116
114
|
}
|
|
117
115
|
|
|
@@ -125,7 +123,7 @@ class UpdateCommand extends Command {
|
|
|
125
123
|
data.secrets = encryptedSecrets;
|
|
126
124
|
} catch (err) {
|
|
127
125
|
this.log(err.message);
|
|
128
|
-
this.error('Unable to import secrets.
|
|
126
|
+
this.error('Unable to import secrets. Check the file and try again.');
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
129
|
|
|
@@ -141,7 +139,7 @@ class UpdateCommand extends Command {
|
|
|
141
139
|
if (shouldContinue) {
|
|
142
140
|
try {
|
|
143
141
|
const response = await updateMesh(
|
|
144
|
-
|
|
142
|
+
imsOrgCode,
|
|
145
143
|
projectId,
|
|
146
144
|
workspaceId,
|
|
147
145
|
workspaceName,
|
|
@@ -169,7 +167,7 @@ class UpdateCommand extends Command {
|
|
|
169
167
|
this.log(error.message);
|
|
170
168
|
|
|
171
169
|
this.error(
|
|
172
|
-
`Unable to update the mesh.
|
|
170
|
+
`Unable to update the mesh. Check the mesh configuration file and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
|
|
173
171
|
);
|
|
174
172
|
}
|
|
175
173
|
} else {
|
package/src/constants.js
CHANGED
|
@@ -9,6 +9,7 @@ const StageConstants = {
|
|
|
9
9
|
AIO_CLI_API_KEY: 'aio-cli-console-auth-stage',
|
|
10
10
|
SMS_BASE_URL: 'https://graph-stage.adobe.io/api-admin',
|
|
11
11
|
MESH_BASE_URL: 'https://edge-stage-graph.adobe.io/api',
|
|
12
|
+
SMS_API_KEY: 'adobe-graph-stage-onboarding',
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
const ProdConstants = {
|
|
@@ -19,6 +20,7 @@ const ProdConstants = {
|
|
|
19
20
|
SMS_BASE_URL: 'https://graph.adobe.io/api-admin',
|
|
20
21
|
MESH_BASE_URL: 'https://edge-graph.adobe.io/api',
|
|
21
22
|
MESH_SANDBOX_BASE_URL: 'https://edge-sandbox-graph.adobe.io/api',
|
|
23
|
+
SMS_API_KEY: 'adobe-graph-prod',
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
const envConstants = clientEnv === 'stage' ? StageConstants : ProdConstants;
|
package/src/helpers.js
CHANGED
|
@@ -17,17 +17,15 @@ const { getToken, context } = require('@adobe/aio-lib-ims');
|
|
|
17
17
|
const { CLI } = require('@adobe/aio-lib-ims/src/context');
|
|
18
18
|
const libConsoleCLI = require('@adobe/aio-cli-lib-console');
|
|
19
19
|
const { getCliEnv } = require('@adobe/aio-lib-env');
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
const logger = require('../src/classes/logger');
|
|
22
|
+
const { UUID } = require('./classes/UUID');
|
|
23
|
+
const CONSTANTS = require('./constants');
|
|
21
24
|
const path = require('path');
|
|
22
25
|
const { exec } = require('child_process');
|
|
23
26
|
const { stdout, stderr } = require('process');
|
|
24
27
|
const jsmin = require('jsmin').jsmin;
|
|
25
28
|
const { resolve: resolveAbsolutePath } = require('path');
|
|
26
|
-
const { compareVersions } = require('compare-versions');
|
|
27
|
-
|
|
28
|
-
const logger = require('../src/classes/logger');
|
|
29
|
-
const { UUID } = require('./classes/UUID');
|
|
30
|
-
const CONSTANTS = require('./constants');
|
|
31
29
|
|
|
32
30
|
const { DEV_CONSOLE_BASE_URL, DEV_CONSOLE_API_KEY, AIO_CLI_API_KEY } = CONSTANTS;
|
|
33
31
|
|
|
@@ -882,69 +880,6 @@ async function writeSecretsFile(secretsData, meshId) {
|
|
|
882
880
|
}
|
|
883
881
|
}
|
|
884
882
|
|
|
885
|
-
/**
|
|
886
|
-
*
|
|
887
|
-
* This function fetches current installed version the system and the latest version from npm
|
|
888
|
-
*
|
|
889
|
-
* @param {*} installedPlugins
|
|
890
|
-
* @returns { currentVersion: string, latestVersion: string }
|
|
891
|
-
*/
|
|
892
|
-
async function getPluginVersionDetails(installedPlugins) {
|
|
893
|
-
try {
|
|
894
|
-
const meshPlugin = installedPlugins.find(
|
|
895
|
-
({ name }) => name === '@adobe/aio-cli-plugin-api-mesh',
|
|
896
|
-
);
|
|
897
|
-
const currentVersion = meshPlugin.version;
|
|
898
|
-
|
|
899
|
-
let config = {
|
|
900
|
-
method: 'get',
|
|
901
|
-
url: 'https://registry.npmjs.org/@adobe/aio-cli-plugin-api-mesh/latest',
|
|
902
|
-
};
|
|
903
|
-
|
|
904
|
-
const response = await axios.request(config);
|
|
905
|
-
const latestVersion = response.data.version;
|
|
906
|
-
|
|
907
|
-
logger.debug(`Latest mesh plugin version: ${latestVersion}`);
|
|
908
|
-
logger.debug(`Installed mesh plugin version: ${currentVersion}`);
|
|
909
|
-
|
|
910
|
-
return {
|
|
911
|
-
currentVersion,
|
|
912
|
-
latestVersion,
|
|
913
|
-
};
|
|
914
|
-
} catch (err) {
|
|
915
|
-
logger.error('Unable to get package version to compare');
|
|
916
|
-
logger.error(err.message);
|
|
917
|
-
|
|
918
|
-
return {
|
|
919
|
-
currentVersion: null,
|
|
920
|
-
latestVersion: null,
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
/**
|
|
926
|
-
*
|
|
927
|
-
* This function compares current installed version against the latest version from npm and
|
|
928
|
-
* returns true if current version is same as latest. Returns false if the current version
|
|
929
|
-
* is behind the latest version.
|
|
930
|
-
*
|
|
931
|
-
* @param {string} currentVersion
|
|
932
|
-
* @param {string} latestVersion
|
|
933
|
-
* @returns
|
|
934
|
-
*/
|
|
935
|
-
function isCurrentVersionLatest(currentVersion, latestVersion) {
|
|
936
|
-
try {
|
|
937
|
-
logger.debug(`Comparing versions Current: ${currentVersion} against Latest: ${latestVersion}`);
|
|
938
|
-
|
|
939
|
-
return compareVersions(currentVersion, latestVersion) >= 0;
|
|
940
|
-
} catch (err) {
|
|
941
|
-
logger.error('Unable to compare versions');
|
|
942
|
-
logger.error(err.message);
|
|
943
|
-
|
|
944
|
-
return true;
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
|
|
948
883
|
module.exports = {
|
|
949
884
|
objToString,
|
|
950
885
|
promptInput,
|
|
@@ -962,6 +897,4 @@ module.exports = {
|
|
|
962
897
|
startGraphqlServer,
|
|
963
898
|
setUpTenantFiles,
|
|
964
899
|
writeSecretsFile,
|
|
965
|
-
getPluginVersionDetails,
|
|
966
|
-
isCurrentVersionLatest,
|
|
967
900
|
};
|