@adobe/aio-cli-plugin-api-mesh 3.5.0-beta.1 → 3.6.0-beta.2
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/init.js +30 -15
- package/src/templates/deployWorkflow.yaml +63 -0
- package/src/templates/devcontainer.json +27 -0
- package/src/templates/gitignore +5 -1
- package/src/templates/mesh.json +14 -0
- package/src/templates/package.json +11 -2
- package/src/templates/readme.md +9 -0
- package/src/templates/sample.env +1 -0
- package/src/templates/vscode_launch.json +15 -0
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"3.
|
|
1
|
+
{"version":"3.6.0-beta.2","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: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
|
@@ -10,12 +10,13 @@ governing permissions and limitations under the License.
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const { Command, Flags } = require('@oclif/core');
|
|
13
|
-
const
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const fs = require('fs/promises');
|
|
14
15
|
|
|
15
16
|
const { promptConfirm, promptSelect, runCliCommand } = require('../../helpers');
|
|
16
17
|
const { getAppRootDir } = require('../../utils');
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
+
const { resolve } = path;
|
|
19
20
|
|
|
20
21
|
class InitCommand extends Command {
|
|
21
22
|
static summary = 'Initiate API Mesh workspace';
|
|
@@ -70,16 +71,18 @@ class InitCommand extends Command {
|
|
|
70
71
|
await fs.writeFile(filePath, JSON.stringify(pkgJSON, null, 2), 'utf8', { mode: 'w' });
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
async
|
|
74
|
-
const
|
|
74
|
+
async cloneFile(templatePath, filePath) {
|
|
75
|
+
const templateFileContents = await fs.readFile(templatePath, 'utf8');
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
}
|
|
77
|
+
const dirPath = path.dirname(filePath);
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
try {
|
|
80
|
+
await fs.access(dirPath);
|
|
81
|
+
} catch {
|
|
82
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
83
|
+
}
|
|
81
84
|
|
|
82
|
-
await fs.writeFile(filePath,
|
|
85
|
+
await fs.writeFile(filePath, templateFileContents, 'utf8', { mode: 'w' });
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
async run() {
|
|
@@ -92,8 +95,16 @@ class InitCommand extends Command {
|
|
|
92
95
|
let absolutePath = resolve(flags.path);
|
|
93
96
|
let shouldCreateGit = gitFlagOptions[flags.git];
|
|
94
97
|
let packageManagerChoice = flags.packageManager;
|
|
98
|
+
|
|
95
99
|
const packageJsonTemplate = `${getAppRootDir()}/src/templates/package.json`;
|
|
96
100
|
const dotNpmrcPath = `${getAppRootDir()}/src/templates/npmrc`;
|
|
101
|
+
const vsCodeLaunchJsonPath = `${getAppRootDir()}/src/templates/vscode_launch.json`;
|
|
102
|
+
const devContainerJsonPath = `${getAppRootDir()}/src/templates/devcontainer.json`;
|
|
103
|
+
const sampleENVPath = `${getAppRootDir()}/src/templates/sample.env`;
|
|
104
|
+
const githubWorkflowPath = `${getAppRootDir()}/src/templates/deployWorkflow.yaml`;
|
|
105
|
+
const readmePath = `${getAppRootDir()}/src/templates/readme.md`;
|
|
106
|
+
const sampleMeshConfigPath = `${getAppRootDir()}/src/templates/mesh.json`;
|
|
107
|
+
|
|
97
108
|
const shouldCreateWorkspace = await promptConfirm(
|
|
98
109
|
`Do you want to create the workspace in ${absolutePath}`,
|
|
99
110
|
);
|
|
@@ -140,23 +151,27 @@ class InitCommand extends Command {
|
|
|
140
151
|
const gitIgnoreTemplatePath = `${getAppRootDir()}/src/templates/gitignore`;
|
|
141
152
|
const gitIgnoreFilePath = `${absolutePath}/.gitignore`;
|
|
142
153
|
|
|
143
|
-
await this.
|
|
154
|
+
await this.cloneFile(gitIgnoreTemplatePath, gitIgnoreFilePath);
|
|
155
|
+
await this.cloneFile(githubWorkflowPath, `${absolutePath}/.github/workflows/deploy.yaml`);
|
|
144
156
|
} catch (error) {
|
|
145
157
|
this.error(error);
|
|
146
158
|
}
|
|
147
159
|
}
|
|
148
160
|
|
|
149
|
-
await fs.writeFile(`${absolutePath}/.env`, '', 'utf8', { mode: 'w' });
|
|
150
|
-
|
|
151
|
-
this.log(`Installing dependencies`);
|
|
152
|
-
|
|
153
161
|
await this.createPackageJson(
|
|
154
162
|
packageJsonTemplate,
|
|
155
163
|
`${absolutePath}/package.json`,
|
|
156
164
|
args.projectName,
|
|
157
165
|
);
|
|
158
166
|
|
|
159
|
-
await this.
|
|
167
|
+
await this.cloneFile(dotNpmrcPath, `${absolutePath}/.npmrc`);
|
|
168
|
+
await this.cloneFile(vsCodeLaunchJsonPath, `${absolutePath}/.vscode/launch.json`);
|
|
169
|
+
await this.cloneFile(devContainerJsonPath, `${absolutePath}/.devcontainer/devcontainer.json`);
|
|
170
|
+
await this.cloneFile(sampleENVPath, `${absolutePath}/.env`);
|
|
171
|
+
await this.cloneFile(readmePath, `${absolutePath}/README.md`);
|
|
172
|
+
await this.cloneFile(sampleMeshConfigPath, `${absolutePath}/mesh.json`);
|
|
173
|
+
|
|
174
|
+
this.log(`Installing dependencies`);
|
|
160
175
|
|
|
161
176
|
if (packageManagerChoice === 'npm') {
|
|
162
177
|
try {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: Deploy Mesh
|
|
2
|
+
|
|
3
|
+
# Controls when the workflow will run
|
|
4
|
+
on:
|
|
5
|
+
# Triggers the workflow on push or pull request events but only for the "main" branch
|
|
6
|
+
push:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
# Allows you to run this workflow manually from the Actions tab
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
12
|
+
jobs:
|
|
13
|
+
deploy:
|
|
14
|
+
name: Deploy to Prod
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
strategy:
|
|
17
|
+
max-parallel: 1
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: ["20"]
|
|
20
|
+
os: [ubuntu-latest]
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
25
|
+
uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: ${{ matrix.node-version }}
|
|
28
|
+
- name: Setup CLI
|
|
29
|
+
uses: adobe/aio-cli-setup-action@1.3.0
|
|
30
|
+
with:
|
|
31
|
+
os: ${{ matrix.os }}
|
|
32
|
+
version: 10.x.x
|
|
33
|
+
- name: api-mesh-plugin install
|
|
34
|
+
run: aio plugins:install @adobe/aio-cli-plugin-api-mesh
|
|
35
|
+
- name: Auth
|
|
36
|
+
uses: adobe/aio-apps-action@3.3.0
|
|
37
|
+
with:
|
|
38
|
+
os: ${{ matrix.os }}
|
|
39
|
+
command: oauth_sts
|
|
40
|
+
CLIENTID: ${{ secrets.CLIENTID }}
|
|
41
|
+
CLIENTSECRET: ${{ secrets.CLIENTSECRET }}
|
|
42
|
+
TECHNICALACCOUNTID: ${{ secrets.TECHNICALACCID }}
|
|
43
|
+
TECHNICALACCOUNTEMAIL: ${{ secrets.TECHNICALACCEMAIL }}
|
|
44
|
+
IMSORGID: ${{ secrets.IMSORGID }}
|
|
45
|
+
SCOPES: AdobeID, openid, read_organizations, additional_info.projectedProductContext, additional_info.roles, adobeio_api, read_client_secret, manage_client_secrets
|
|
46
|
+
- name: Set CLI ENV
|
|
47
|
+
run: aio config set cli.env prod
|
|
48
|
+
- name: Select org
|
|
49
|
+
run: aio console:org:select ${{ secrets.ORGID }}
|
|
50
|
+
- name: Select project
|
|
51
|
+
run: aio console:project:select ${{ secrets.PROJECTID }}
|
|
52
|
+
- name: Select workspace
|
|
53
|
+
run: aio console:workspace:select ${{ secrets.WORKSPACEID }}
|
|
54
|
+
- name: "Create env file"
|
|
55
|
+
run: |
|
|
56
|
+
touch .env
|
|
57
|
+
echo API_ENDPOINT="https://xxx.execute-api.us-west-2.amazonaws.com" >> .env
|
|
58
|
+
echo API_KEY=${{ secrets.API_KEY }} >> .env
|
|
59
|
+
cat .env
|
|
60
|
+
- name: Describe
|
|
61
|
+
run: aio api-mesh:describe
|
|
62
|
+
- name: Update
|
|
63
|
+
run: aio api-mesh:update -c mesh.json --env .env
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
2
|
+
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
|
|
3
|
+
{
|
|
4
|
+
"name": "API Mesh Dev Container",
|
|
5
|
+
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bookworm",
|
|
6
|
+
"hostRequirements": {
|
|
7
|
+
"cpus": 2,
|
|
8
|
+
"memory": "8gb",
|
|
9
|
+
"storage": "32gb"
|
|
10
|
+
},
|
|
11
|
+
"forwardPorts": [5000],
|
|
12
|
+
"postAttachCommand": {
|
|
13
|
+
"server": "yarn start mesh.json"
|
|
14
|
+
},
|
|
15
|
+
"postCreateCommand": "yarn install && yarn devcontainer:setup",
|
|
16
|
+
"portsAttributes": {
|
|
17
|
+
"5000": {
|
|
18
|
+
"label": "Mesh GraphQL Server",
|
|
19
|
+
"onAutoForward": "openPreview"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"customizations": {
|
|
23
|
+
"codespaces": {
|
|
24
|
+
"openFiles": ["README.md", "mesh.json"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/templates/gitignore
CHANGED
|
@@ -42,7 +42,16 @@
|
|
|
42
42
|
"api-mesh"
|
|
43
43
|
],
|
|
44
44
|
"license": "Apache-2.0",
|
|
45
|
-
"scripts": {
|
|
45
|
+
"scripts": {
|
|
46
|
+
"start": "nodemon --watch .env -e js,json,yaml node_modules/.bin/aio api-mesh run",
|
|
47
|
+
"debug": "nodemon --watch .env -e js,json,yaml node_modules/.bin/aio api-mesh run --debug",
|
|
48
|
+
"setupTelemetry": "echo {aio-cli-telemetry: {optOut: false}} > ~/.config/aio",
|
|
49
|
+
"devcontainer:setup": "yarn setupTelemetry & aio plugins:install @adobe/aio-cli-plugin-api-mesh"
|
|
50
|
+
},
|
|
46
51
|
"description": "API mesh starter template",
|
|
47
|
-
"author": "Adobe Inc."
|
|
52
|
+
"author": "Adobe Inc.",
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@adobe/aio-cli": "^10.0.0",
|
|
55
|
+
"nodemon": "^3.1.3"
|
|
56
|
+
}
|
|
48
57
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Adobe API Mesh Starter Kit
|
|
2
|
+
|
|
3
|
+
Bootstrap your Adobe API Mesh development with ease.
|
|
4
|
+
|
|
5
|
+
Simply use the template to create a new repo and get started with Github Codespaces to write, test and deploy from the browser.
|
|
6
|
+
|
|
7
|
+
This repo comes with all the files necessary to get started with API Mesh.
|
|
8
|
+
|
|
9
|
+
Check out the [documentation](https://developer.adobe.com/graphql-mesh-gateway/mesh/template) for further details.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
COMMERCE_ENDPOINT=""
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Attach",
|
|
9
|
+
"port": 9229,
|
|
10
|
+
"request": "attach",
|
|
11
|
+
"skipFiles": ["<node_internals>/**"],
|
|
12
|
+
"type": "node"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|