@adobe/aio-cli-plugin-api-mesh 4.1.0-beta.3 → 4.1.0-beta.4
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"4.1.0-beta.
|
|
1
|
+
{"version":"4.1.0-beta.4","commands":{"PLUGINNAME":{"id":"PLUGINNAME","description":"Your description here","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio PLUGINNAME:some_command"],"flags":{"someflag":{"name":"someflag","type":"option","char":"f","description":"this is some flag"}},"args":[]},"api-mesh:create":{"id":"api-mesh:create","description":"Create a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file"}]},"api-mesh:delete":{"id":"api-mesh:delete","description":"Delete the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false}},"args":[]},"api-mesh:describe":{"id":"api-mesh:describe","description":"Get details of a mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:get":{"id":"api-mesh:get","description":"Get the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false}},"args":[{"name":"file"}]},"api-mesh:init":{"id":"api-mesh:init","description":"This command will create a workspace where you can organise your API mesh configuration and other files","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[{"description":"API mesh workspace init","command":"aio api-mesh init commerce-mesh"},{"description":"API mesh workspace init with flags","command":"aio api-mesh init commerce-mesh --path ./mesh_projects/test_mesh --git y --packageManager yarn"}],"flags":{"path":{"name":"path","type":"option","char":"p","default":"."},"packageManager":{"name":"packageManager","type":"option","char":"m","options":["npm","yarn"]},"git":{"name":"git","type":"option","char":"g","options":["y","n"]}},"args":[{"name":"projectName","description":"Project name","required":true}]},"api-mesh:log-get-bulk":{"id":"api-mesh:log-get-bulk","description":"Download all mesh logs for a selected time period.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"startTime":{"name":"startTime","type":"option","description":"Start time for the logs in UTC","required":true},"endTime":{"name":"endTime","type":"option","description":"End time for the logs in UTC","required":true},"filename":{"name":"filename","type":"option","description":"Path to the output file for logs","required":true}},"args":[]},"api-mesh:log-get":{"id":"api-mesh:log-get","description":"Get the Log of a given mesh by RayId","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[{"name":"rayId","description":"Fetch a single log by rayID","required":true}]},"api-mesh:log-list":{"id":"api-mesh:log-list","description":"Get recent logs of requests made to the API Mesh.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"filename":{"name":"filename","type":"option","description":"Name of CSV file to export the recent logs to"}},"args":[]},"api-mesh:run":{"id":"api-mesh:run","description":"Run a local development server that builds and compiles a mesh locally","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"Port number for the local dev server"},"debug":{"name":"debug","type":"boolean","description":"Enable debugging mode","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"select":{"name":"select","type":"boolean","description":"Retrieve existing artifacts from the mesh","allowNo":false},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file","description":"Mesh File"}]},"api-mesh:status":{"id":"api-mesh:status","description":"Get a mesh status with a given meshid.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:update":{"id":"api-mesh:update","description":"Update a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file"}]},"api-mesh:source:discover":{"id":"api-mesh:source:discover","description":"Return the list of avaliable sources","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm install action prompt. CLI will not check ask user to install source.","allowNo":false}},"args":[]},"api-mesh:source:get":{"id":"api-mesh:source:get","description":"Command returns the content of a specific source.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:get -s=<version>@<source_name>","$ aio api-mesh:source:get -s<source_name>","$ aio api-mesh:source:get -m"],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm print action prompt. CLI will not check ask user to print source.","allowNo":false},"source":{"name":"source","type":"option","char":"s","description":"Source name"},"multiple":{"name":"multiple","type":"boolean","char":"m","description":"Select multiple sources","allowNo":false}},"args":[]},"api-mesh:source:install":{"id":"api-mesh:source:install","description":"Command to install the source to your API mesh.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:install <version>@<source_name>","$ aio api-mesh:source:install <source_name> -v <variable_name>=<variable_value>","$ aio api-mesh:source:install <source_name> -f <path_to_variables_file>"],"flags":{"source":{"name":"source","type":"option","char":"s","description":"Source name"},"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm override action prompt. CLI will not check ask user to override source.","allowNo":false},"variable":{"name":"variable","type":"option","char":"v","description":"Variables required for the source"},"variable-file":{"name":"variable-file","type":"option","char":"f","description":"Variables file path"},"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[{"name":"source"}]}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/aio-cli-plugin-api-mesh",
|
|
3
|
-
"version": "4.1.0-beta.
|
|
3
|
+
"version": "4.1.0-beta.4",
|
|
4
4
|
"description": "Adobe I/O CLI plugin to develop and manage API mesh sources",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oclif-plugin"
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"source-registry-storage-adapter": "github:devx-services/source-registry-storage-adapter#main",
|
|
97
97
|
"util": "^0.12.5",
|
|
98
98
|
"uuid": "^8.3.2",
|
|
99
|
-
"wrangler": "
|
|
99
|
+
"wrangler": "3.80.4",
|
|
100
100
|
"yaml": "^2.4.2"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
@@ -196,7 +196,7 @@ describe('run command tests', () => {
|
|
|
196
196
|
parseSpy.mockResolvedValue(parseOutput);
|
|
197
197
|
|
|
198
198
|
await RunCommand.run();
|
|
199
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
199
|
+
expect(runServer).toHaveBeenCalledWith(parseOutput.flags.port);
|
|
200
200
|
});
|
|
201
201
|
|
|
202
202
|
test('should use the port number provided in the .env file if there is no port', async () => {
|
|
@@ -213,7 +213,7 @@ describe('run command tests', () => {
|
|
|
213
213
|
parseSpy.mockResolvedValue(parseOutput);
|
|
214
214
|
|
|
215
215
|
await RunCommand.run();
|
|
216
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
216
|
+
expect(runServer).toHaveBeenCalledWith(process.env.PORT);
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
test('should use the default port if port number is not provided explicitly', async () => {
|
|
@@ -229,7 +229,7 @@ describe('run command tests', () => {
|
|
|
229
229
|
parseSpy.mockResolvedValue(parseOutput);
|
|
230
230
|
|
|
231
231
|
await RunCommand.run();
|
|
232
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
232
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
233
233
|
});
|
|
234
234
|
|
|
235
235
|
test('should return error for run command if the mesh has placeholders and env file provided using --env flag is not found', async () => {
|
|
@@ -396,7 +396,7 @@ describe('run command tests', () => {
|
|
|
396
396
|
});
|
|
397
397
|
|
|
398
398
|
await RunCommand.run();
|
|
399
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
399
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
400
400
|
});
|
|
401
401
|
|
|
402
402
|
// file import tests
|
|
@@ -442,7 +442,7 @@ describe('run command tests', () => {
|
|
|
442
442
|
});
|
|
443
443
|
|
|
444
444
|
await RunCommand.run();
|
|
445
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
445
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
446
446
|
});
|
|
447
447
|
|
|
448
448
|
test('should fail if the file name is more than 25 characters', async () => {
|
|
@@ -618,7 +618,7 @@ describe('run command tests', () => {
|
|
|
618
618
|
});
|
|
619
619
|
|
|
620
620
|
await RunCommand.run();
|
|
621
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
621
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
622
622
|
});
|
|
623
623
|
|
|
624
624
|
test('should override if prompt returns Yes, if there is files array', async () => {
|
|
@@ -665,7 +665,7 @@ describe('run command tests', () => {
|
|
|
665
665
|
|
|
666
666
|
await RunCommand.run();
|
|
667
667
|
|
|
668
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
668
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
669
669
|
});
|
|
670
670
|
|
|
671
671
|
test('should pass for a fully-qualified meshConfig even if the file does not exist in fileSystem', async () => {
|
|
@@ -712,7 +712,7 @@ describe('run command tests', () => {
|
|
|
712
712
|
});
|
|
713
713
|
|
|
714
714
|
await RunCommand.run();
|
|
715
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
715
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
716
716
|
});
|
|
717
717
|
|
|
718
718
|
test('should pass if the file is located in subdirectory of mesh directory', async () => {
|
|
@@ -758,7 +758,7 @@ describe('run command tests', () => {
|
|
|
758
758
|
|
|
759
759
|
await RunCommand.run();
|
|
760
760
|
|
|
761
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
761
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
762
762
|
});
|
|
763
763
|
|
|
764
764
|
test('should fail if the file is outside the workspace directory', async () => {
|
|
@@ -929,7 +929,7 @@ describe('run command tests', () => {
|
|
|
929
929
|
|
|
930
930
|
await RunCommand.run();
|
|
931
931
|
expect(writeSecretsFile).toHaveBeenCalled();
|
|
932
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
932
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
933
933
|
});
|
|
934
934
|
|
|
935
935
|
test('should return error if ran with secrets against windows platform with batch variables', async () => {
|
|
@@ -967,7 +967,7 @@ describe('run command tests', () => {
|
|
|
967
967
|
|
|
968
968
|
await RunCommand.run();
|
|
969
969
|
expect(writeSecretsFile).toHaveBeenCalled();
|
|
970
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
970
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
971
971
|
});
|
|
972
972
|
|
|
973
973
|
test('should pass if ran with secrets against darwin(macOS) platform with batch variables', async () => {
|
|
@@ -982,7 +982,7 @@ describe('run command tests', () => {
|
|
|
982
982
|
|
|
983
983
|
await RunCommand.run();
|
|
984
984
|
expect(writeSecretsFile).toHaveBeenCalled();
|
|
985
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
985
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
986
986
|
});
|
|
987
987
|
|
|
988
988
|
test('should escape variables that are preceded by backslash symbol', async () => {
|
|
@@ -999,6 +999,6 @@ describe('run command tests', () => {
|
|
|
999
999
|
'Home: rootPath\nHomeString: $HOME\nHomeWithSlash: \\rootPath\nHomeStringWithSlash: \\$HOME\n',
|
|
1000
1000
|
expect.anything(),
|
|
1001
1001
|
);
|
|
1002
|
-
expect(runServer).toHaveBeenCalledWith(
|
|
1002
|
+
expect(runServer).toHaveBeenCalledWith(defaultPort);
|
|
1003
1003
|
});
|
|
1004
1004
|
});
|
|
@@ -202,8 +202,9 @@ class RunCommand extends Command {
|
|
|
202
202
|
if (!portNo) {
|
|
203
203
|
portNo = 5000;
|
|
204
204
|
}
|
|
205
|
-
|
|
206
|
-
runServer(
|
|
205
|
+
this.log(`Starting server on port : ${portNo}`);
|
|
206
|
+
await runServer(portNo);
|
|
207
|
+
this.log(`Server is running on http://localhost:${portNo}/graphql`);
|
|
207
208
|
} else {
|
|
208
209
|
throw new Error(
|
|
209
210
|
'`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.',
|
|
@@ -217,13 +218,13 @@ class RunCommand extends Command {
|
|
|
217
218
|
async copyMeshContent(meshId) {
|
|
218
219
|
// Remove mesh artifact directory if exists
|
|
219
220
|
if (fs.existsSync('.mesh')) {
|
|
220
|
-
fs.
|
|
221
|
+
fs.rmSync('.mesh', { recursive: true });
|
|
221
222
|
}
|
|
222
223
|
// Move built mesh artifact to expect directory
|
|
223
224
|
fs.renameSync(`mesh-artifact/${meshId}`, '.mesh');
|
|
224
225
|
// Remove tenant files directory if exists
|
|
225
226
|
if (fs.existsSync('tenantFiles')) {
|
|
226
|
-
fs.
|
|
227
|
+
fs.rmSync('tenantFiles', { recursive: true });
|
|
227
228
|
}
|
|
228
229
|
// Move built tenant files if exists
|
|
229
230
|
if (fs.existsSync('mesh-artifact/tenantFiles')) {
|
|
@@ -234,7 +235,7 @@ class RunCommand extends Command {
|
|
|
234
235
|
await fixPlugins('.mesh/index.js');
|
|
235
236
|
|
|
236
237
|
if (fs.existsSync(`${__dirname}/../../../.mesh`)) {
|
|
237
|
-
fs.
|
|
238
|
+
fs.rmSync(`${__dirname}/../../../.mesh`, { recursive: true });
|
|
238
239
|
}
|
|
239
240
|
fs.cpSync('.mesh', `${__dirname}/../../../.mesh`, { recursive: true });
|
|
240
241
|
}
|
package/src/server.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
const { spawn } = require('child_process');
|
|
2
2
|
const { readSecretsFile } = require('./serverUtils');
|
|
3
|
+
const packageData = require('../package.json');
|
|
3
4
|
|
|
4
|
-
const runServer =
|
|
5
|
-
const
|
|
5
|
+
const runServer = portNo => {
|
|
6
|
+
const wranglerPackageNumber = packageData.dependencies.wrangler;
|
|
7
|
+
const wranglerVersion = `wrangler@${wranglerPackageNumber.replace(/^[\^~]/, '')}`;
|
|
6
8
|
const indexFilePath = `${__dirname}/index.js`;
|
|
7
9
|
const filePath = '.mesh';
|
|
8
10
|
const secrets = readSecretsFile(filePath);
|
|
9
11
|
const commandArgs = [
|
|
12
|
+
wranglerVersion,
|
|
10
13
|
'dev',
|
|
11
14
|
indexFilePath,
|
|
12
15
|
'--var',
|
|
13
|
-
`MESH_ID:${meshId}`,
|
|
14
16
|
`Secret:${JSON.stringify(secrets)}`,
|
|
15
17
|
'--port',
|
|
16
18
|
portNo,
|
|
17
19
|
];
|
|
18
20
|
|
|
19
|
-
const wrangler = spawn(
|
|
21
|
+
const wrangler = spawn('npx', commandArgs, {
|
|
20
22
|
stdio: 'inherit',
|
|
21
23
|
});
|
|
22
24
|
|
package/src/wranglerServer.js
CHANGED
|
@@ -41,17 +41,17 @@ async function getBuiltMesh(meshArtifacts, meshConfig) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const buildServer = async (loggerInstance, env, meshArtifacts, meshConfig) => {
|
|
44
|
-
const {
|
|
44
|
+
const { Secret: secret } = env;
|
|
45
45
|
const tenantMesh = await getBuiltMesh(meshArtifacts, meshConfig);
|
|
46
46
|
const meshSecrets = loadMeshSecrets(loggerInstance, secret);
|
|
47
|
-
return await buildYogaServer(env, tenantMesh,
|
|
47
|
+
return await buildYogaServer(env, tenantMesh, meshConfig, meshSecrets);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
async function buildYogaServer(env, tenantMesh,
|
|
50
|
+
async function buildYogaServer(env, tenantMesh, meshConfig, meshSecrets) {
|
|
51
51
|
const secretsProxy = new Proxy(meshSecrets, getSecretsHandler);
|
|
52
52
|
return createYoga({
|
|
53
53
|
plugins: tenantMesh.plugins,
|
|
54
|
-
graphqlEndpoint: `/
|
|
54
|
+
graphqlEndpoint: `/graphql`,
|
|
55
55
|
cors: getCorsOptions(env, meshConfig),
|
|
56
56
|
context: initialContext => ({
|
|
57
57
|
...initialContext,
|