@adobe/aio-cli-plugin-api-mesh 3.8.0 → 3.9.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/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/api-mesh/__tests__/log-get-bulk.test.js +2 -2
- package/src/commands/api-mesh/init.js +11 -2
- package/src/templates/convertHTMLToPDF.js +52 -0
- package/src/templates/k6Tests.js +25 -0
- package/src/templates/loadTestWorkflow.yaml +90 -0
- package/src/templates/package.json +4 -2
- package/src/templates/readme.md +2 -0
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"3.
|
|
1
|
+
{"version":"3.9.0","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
|
@@ -22,8 +22,8 @@ describe('GetBulkLogCommand', () => {
|
|
|
22
22
|
// Setup spies and mock functions
|
|
23
23
|
parseSpy = jest.spyOn(GetBulkLogCommand.prototype, 'parse').mockResolvedValue({
|
|
24
24
|
flags: {
|
|
25
|
-
startTime: '2024-
|
|
26
|
-
endTime: '2024-
|
|
25
|
+
startTime: '2024-09-29T12:00:00Z',
|
|
26
|
+
endTime: '2024-09-29T12:30:00Z',
|
|
27
27
|
filename: 'test.csv',
|
|
28
28
|
ignoreCache: false,
|
|
29
29
|
},
|
|
@@ -101,7 +101,10 @@ class InitCommand extends Command {
|
|
|
101
101
|
const vsCodeLaunchJsonPath = `${getAppRootDir()}/src/templates/vscode_launch.json`;
|
|
102
102
|
const devContainerJsonPath = `${getAppRootDir()}/src/templates/devcontainer.json`;
|
|
103
103
|
const sampleENVPath = `${getAppRootDir()}/src/templates/sample.env`;
|
|
104
|
-
const
|
|
104
|
+
const deployWorkflowPath = `${getAppRootDir()}/src/templates/deployWorkflow.yaml`;
|
|
105
|
+
const loadTestWorkflowPath = `${getAppRootDir()}/src/templates/loadTestWorkflow.yaml`;
|
|
106
|
+
const k6TestsPath = `${getAppRootDir()}/src/templates/k6Tests.js`;
|
|
107
|
+
const convertHTMLToPDFPath = `${getAppRootDir()}/src/templates/convertHTMLToPDF.js`;
|
|
105
108
|
const readmePath = `${getAppRootDir()}/src/templates/readme.md`;
|
|
106
109
|
const sampleMeshConfigPath = `${getAppRootDir()}/src/templates/mesh.json`;
|
|
107
110
|
const newRelicConfigPath = `${getAppRootDir()}/src/templates/newrelic.cjs`;
|
|
@@ -152,7 +155,13 @@ class InitCommand extends Command {
|
|
|
152
155
|
const gitIgnoreFilePath = `${absolutePath}/.gitignore`;
|
|
153
156
|
|
|
154
157
|
await this.cloneFile(gitIgnoreTemplatePath, gitIgnoreFilePath);
|
|
155
|
-
await this.cloneFile(
|
|
158
|
+
await this.cloneFile(deployWorkflowPath, `${absolutePath}/.github/workflows/deploy.yaml`);
|
|
159
|
+
await this.cloneFile(
|
|
160
|
+
loadTestWorkflowPath,
|
|
161
|
+
`${absolutePath}/.github/workflows/loadTest.yaml`,
|
|
162
|
+
);
|
|
163
|
+
await this.cloneFile(k6TestsPath, `${absolutePath}/k6Tests.js`);
|
|
164
|
+
await this.cloneFile(convertHTMLToPDFPath, `${absolutePath}/convertHTMLToPDF.js`);
|
|
156
165
|
} catch (error) {
|
|
157
166
|
this.error(error);
|
|
158
167
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const puppeteer = require('puppeteer');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
|
|
4
|
+
const htmlFileName = process.argv[2];
|
|
5
|
+
|
|
6
|
+
if (!htmlFileName) {
|
|
7
|
+
console.error('Please provide the HTML file name to convert to PDF');
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const pdfFileName = htmlFileName.replace('.html', '.pdf');
|
|
12
|
+
|
|
13
|
+
console.log(`Converting ${htmlFileName} to ${pdfFileName}`);
|
|
14
|
+
|
|
15
|
+
async function convertHTMLReportToPDF() {
|
|
16
|
+
// Create a browser instance
|
|
17
|
+
const browser = await puppeteer.launch();
|
|
18
|
+
|
|
19
|
+
// Create a new page
|
|
20
|
+
const page = await browser.newPage();
|
|
21
|
+
|
|
22
|
+
//Get HTML content from HTML file
|
|
23
|
+
const html = fs.readFileSync(htmlFileName, 'utf-8');
|
|
24
|
+
await page.setContent(html, { waitUntil: 'domcontentloaded' });
|
|
25
|
+
|
|
26
|
+
// To reflect CSS used for screens instead of print
|
|
27
|
+
await page.emulateMediaType('screen');
|
|
28
|
+
|
|
29
|
+
// Downlaod the PDF
|
|
30
|
+
await page.pdf({
|
|
31
|
+
path: pdfFileName,
|
|
32
|
+
margin: { top: '100px', right: '50px', bottom: '100px', left: '50px' },
|
|
33
|
+
printBackground: true,
|
|
34
|
+
format: 'A4',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Close the browser instance
|
|
38
|
+
await browser.close();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
convertHTMLReportToPDF()
|
|
42
|
+
.then(() => {
|
|
43
|
+
console.log(`PDF generated at ${pdfFileName}`);
|
|
44
|
+
|
|
45
|
+
// read the PDF file size
|
|
46
|
+
const stats = fs.statSync(pdfFileName);
|
|
47
|
+
const fileSizeInBytes = stats.size;
|
|
48
|
+
console.log(`PDF file size: ${fileSizeInBytes} bytes`);
|
|
49
|
+
})
|
|
50
|
+
.catch(error => {
|
|
51
|
+
console.error(`Error occurred: ${error}`);
|
|
52
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
import http from 'k6/http';
|
|
3
|
+
|
|
4
|
+
if (
|
|
5
|
+
__ENV.MESH_ENDPOINT === undefined ||
|
|
6
|
+
__ENV.MESH_ENDPOINT === null ||
|
|
7
|
+
__ENV.MESH_ENDPOINT === ''
|
|
8
|
+
) {
|
|
9
|
+
throw new Error('MESH_ENDPOINT is required, please add it the test:perf script in package.json');
|
|
10
|
+
} else if (typeof __ENV.MESH_ENDPOINT !== 'string') {
|
|
11
|
+
throw new Error('MESH_ENDPOINT must be a string');
|
|
12
|
+
} else if (!__ENV.MESH_ENDPOINT.startsWith('https')) {
|
|
13
|
+
throw new Error('MESH_ENDPOINT must start with https');
|
|
14
|
+
} else {
|
|
15
|
+
console.log(`Starting Performance Tests against MESH_ENDPOINT: ${__ENV.MESH_ENDPOINT}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default function () {
|
|
19
|
+
http.get(`${__ENV.MESH_ENDPOINT}?query={__schema{queryType{name}}}`, {
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
'Connection': 'keep-alive',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
name: Perform Load Test
|
|
2
|
+
on: workflow_dispatch
|
|
3
|
+
jobs:
|
|
4
|
+
runLoad:
|
|
5
|
+
name: Run K6 Load
|
|
6
|
+
runs-on: ubuntu-latest
|
|
7
|
+
steps:
|
|
8
|
+
- uses: actions/checkout@v3
|
|
9
|
+
with:
|
|
10
|
+
sparse-checkout: |
|
|
11
|
+
script.js
|
|
12
|
+
convert.js
|
|
13
|
+
reports/
|
|
14
|
+
- name: Verify vars are set and fail if not
|
|
15
|
+
run: |
|
|
16
|
+
if [ -z "${{vars.VUS}}" ]; then
|
|
17
|
+
echo "Please set VUS in workflow variables"
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
if [ -z "${{vars.DURATION}}" ]; then
|
|
21
|
+
echo "Please set DURATION in workflow variables"
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
if [ -z "${{vars.MESH_ENDPOINT}}" ]; then
|
|
25
|
+
echo "Please set MESH_ENDPOINT in workflow variables"
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
- name: Install ca-certificates
|
|
29
|
+
run: sudo apt-get install -y ca-certificates
|
|
30
|
+
- name: Install gnupg2
|
|
31
|
+
run: sudo apt-get install -y gnupg2
|
|
32
|
+
- name: Download K6 AMD64 deb file
|
|
33
|
+
run: curl -o k6.deb -L https://github.com/grafana/k6/releases/download/v0.53.0/k6-v0.53.0-linux-amd64.deb
|
|
34
|
+
- name: Install K6
|
|
35
|
+
run: sudo apt-get install ./k6.deb
|
|
36
|
+
- name: Install Yarn
|
|
37
|
+
run: npm install -g yarn
|
|
38
|
+
- name: Install Packages
|
|
39
|
+
run: yarn install
|
|
40
|
+
- name: Create reports directory
|
|
41
|
+
run: mkdir -p reports
|
|
42
|
+
- name: Set FILENAME
|
|
43
|
+
run: echo "FILENAME=./reports/$(date '+%d-%m-%Y-%H:%M:%S')" >> $GITHUB_ENV
|
|
44
|
+
- name: Echo FILENAME
|
|
45
|
+
run: echo $FILENAME
|
|
46
|
+
- name: Run K6
|
|
47
|
+
run: K6_WEB_DASHBOARD=${{vars.UPLOAD_REPORT}} K6_WEB_DASHBOARD_EXPORT=$FILENAME.html k6 run k6Tests.js -e MESH_ENDPOINT=${{vars.MESH_ENDPOINT}} --vus ${{vars.VUS}} --duration ${{vars.DURATION}}s
|
|
48
|
+
- name: Convert HTML to PDF
|
|
49
|
+
run: |
|
|
50
|
+
if [ "${{vars.UPLOAD_REPORT}}" == "true" ]; then
|
|
51
|
+
node ./convertHTMLToPDF.js $FILENAME.html
|
|
52
|
+
else
|
|
53
|
+
exit 0
|
|
54
|
+
fi
|
|
55
|
+
- name: Update git config
|
|
56
|
+
run: |
|
|
57
|
+
if [ "${{vars.UPLOAD_REPORT}}" == "true" ]; then
|
|
58
|
+
git config user.email "dailyRunner@test.com"
|
|
59
|
+
git config user.name "Daily Performance Runner"
|
|
60
|
+
else
|
|
61
|
+
exit 0
|
|
62
|
+
fi
|
|
63
|
+
- name: Run git status
|
|
64
|
+
run: |
|
|
65
|
+
if [ "${{vars.UPLOAD_REPORT}}" == "true" ]; then
|
|
66
|
+
git status
|
|
67
|
+
else
|
|
68
|
+
exit 0
|
|
69
|
+
fi
|
|
70
|
+
- name: Run git add
|
|
71
|
+
run: |
|
|
72
|
+
if [ "${{vars.UPLOAD_REPORT}}" == "true" ]; then
|
|
73
|
+
git add $FILENAME.pdf
|
|
74
|
+
else
|
|
75
|
+
exit 0
|
|
76
|
+
fi
|
|
77
|
+
- name: Run git commit
|
|
78
|
+
run: |
|
|
79
|
+
if [ "${{vars.UPLOAD_REPORT}}" == "true" ]; then
|
|
80
|
+
git commit -am "Pushing Daily Report"
|
|
81
|
+
else
|
|
82
|
+
exit 0
|
|
83
|
+
fi
|
|
84
|
+
- name: Run git push
|
|
85
|
+
run: |
|
|
86
|
+
if [ "${{vars.UPLOAD_REPORT}}" == "true" ]; then
|
|
87
|
+
git push
|
|
88
|
+
else
|
|
89
|
+
exit 0
|
|
90
|
+
fi
|
|
@@ -46,12 +46,14 @@
|
|
|
46
46
|
"start": "nodemon --watch .env -e js,json,yaml node_modules/.bin/aio api-mesh run",
|
|
47
47
|
"debug": "nodemon --watch .env -e js,json,yaml node_modules/.bin/aio api-mesh run --debug",
|
|
48
48
|
"setupTelemetry": "echo {aio-cli-telemetry: {optOut: false}} > ~/.config/aio",
|
|
49
|
-
"devcontainer:setup": "yarn setupTelemetry & aio plugins:install @adobe/aio-cli-plugin-api-mesh"
|
|
49
|
+
"devcontainer:setup": "yarn setupTelemetry & aio plugins:install @adobe/aio-cli-plugin-api-mesh",
|
|
50
|
+
"test:perf": "k6 run k6TestScript.js -e MESH_ENDPOINT=<INSERT_MESH_ENDPOINT_HERE> --vus 1 --duration 60s"
|
|
50
51
|
},
|
|
51
52
|
"description": "API mesh starter template",
|
|
52
53
|
"author": "Adobe Inc.",
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@adobe/aio-cli": "^10.0.0",
|
|
55
|
-
"nodemon": "^3.1.3"
|
|
56
|
+
"nodemon": "^3.1.3",
|
|
57
|
+
"puppeteer": "^23.3.1"
|
|
56
58
|
}
|
|
57
59
|
}
|
package/src/templates/readme.md
CHANGED
|
@@ -16,6 +16,8 @@ This repo comes with all the files and dependencies necessary to get started wit
|
|
|
16
16
|
|
|
17
17
|
`yarn aio api-mesh run mesh.json --debug` - to start the local dev server in non-watch debug mode
|
|
18
18
|
|
|
19
|
+
`yarn test:perf` - to start the Performance Testing process locally for development. Make sure to update the `MESH_ENDPOINT` in the `test:perf` command located in the `package.json`
|
|
20
|
+
|
|
19
21
|
# Documentation
|
|
20
22
|
|
|
21
23
|
Check out the [documentation](https://developer.adobe.com/graphql-mesh-gateway/mesh/basic/create-mesh/) for further details on how to create and maintain meshes.
|