Getting started
CLI usage
To see all the available CLI commands in the terminal, use the --help
flag:
npx elsie --help
gql
The gql
command can generate types and mocks for your GraphQL API. Files will be generated in <domain package root>/src/__generated__/
.
To use it, you must first configure your .elsie.js
with the necessary values:
// For Adobe Commerce Catalog Serviceschema: { endpoint: "https://catalog-service-sandbox.adobe.io/graphql", headers: { "MAGENTO-ENVIRONMENT-ID": "..." "MAGENTO-STORE-VIEW-CODE": "..." "MAGENTO-WEBSITE-CODE": "..." "MAGENTO-STORE-CODE": "..." "MAGENTO-CUSTOMER-GROUP": "..." "API-KEY": "..." }}
// For Adobe Mesh APIschema: { endpoint: "https://graph.adobe.io/api/.../graphql?api_key=...", headers: { "some-mesh-specific-header": "mesh-header-value" }}
// For Adobe Commerce (non-Mesh)schema: { endpoint: "https://commerce-backend-url.test.graphql", headers: {}}
Then the following commands will generate to
npx elsie gql types
npx elsie gql mocks
generate
Summary list of commands for quick copy/paste.
npx elsie generate config --name <Domain>
npx elsie generate component --pathname <MyUIComponent>
npx elsie generate container --pathname <MyContainer>
npx elsie generate api --pathname <myApiFunction>
Add Config
Generate a new .elsie.js
configuration file for the project.
npx elsie generate config --name <Domain>
module.exports = { name: '<Domain>', api: { root: './src/api', importAliasRoot: '@/<Domain>/api', }, components: [ { id: 'Components', root: './src/components', importAliasRoot: '@/<Domain>/components', cssPrefix: 'elsie', default: true, }, ], containers: { root: './src/containers', importAliasRoot: '@/<Domain>/containers', }, schema: { endpoint: process.env.ENDPOINT, // Add necessary headers headers: {}, },};
Add Component
Generate a new UI Component for the project.
npx elsie generate component --pathname <MyUIComponent>
🆕 src/components/LoginForm/LoginForm.css created🆕 src/components/LoginForm/LoginForm.stories.tsx created🆕 src/components/LoginForm/LoginForm.test.tsx created🆕 src/components/LoginForm/LoginForm.tsx created🆕 src/components/LoginForm/index.ts created✍️ src/components/index.ts updated
Add Container
Generate a new Frontend Container for the project.
npx elsie generate container --pathname <MyContainer>
🆕 src/containers/Login/Login.stories.tsx created🆕 src/containers/Login/Login.test.tsx created🆕 src/containers/Login/Login.tsx created🆕 src/containers/Login/index.ts created✍️ src/containers/index.ts updated
Add Function
Generate a new API function for the project.
npx elsie generate api --pathname <myApiFunction>
🆕 src/api/login/login.mdx created🆕 src/api/login/login.test.ts created🆕 src/api/login/login.ts created🆕 src/api/login/index.ts created✍️ src/api/index.ts updated