diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40a754be..54a4dbc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Node.js Build and Test +name: CI on: pull_request: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b6e73bbe..4b3e97f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,16 +22,16 @@ Then, if it appears that it's a real bug, you may report it using Github by foll ### Installing the source version -To install the source version of the API Platform Client Generator in your project and contribute a patch, run the following commands: +To install the source version of Create Client in your project and contribute a patch, run the following commands: ```console -$ git clone git@github.com:api-platform/client-generator.git -$ cd client-generator +$ git clone git@github.com:api-platform/create-client.git +$ cd create-client $ yarn install $ yarn watch ``` -You can now hack in the cloned repository of `client-generator`. If you want to test your work, a `lib/index.js` file containing your last changes will be created each time you invoke `yarn build`. You can also use `yarn watch` to make it created each time a change is performed in your code! +You can now hack in the cloned repository of `create-client`. If you want to test your work, a `lib/index.js` file containing your last changes will be created each time you invoke `yarn build`. You can also use `yarn watch` to make it created each time a change is performed in your code! ### Testing your changes @@ -55,7 +55,7 @@ $ yarn test ### Matching coding standards -The API Platform Client Generator project is inspired by the [Airbnb JavaScript style guide](https://github.com/airbnb/javascript). +The style of the project is inspired by the [Airbnb JavaScript style guide](https://github.com/airbnb/javascript). But don't worry, you can fix CS issues automatically using [ESLint](https://eslint.org/) tool: ```console diff --git a/README.md b/README.md index 3f30710e..03686f0c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# API Platform Client Generator +# API Platform Create Client -[![Build Status](https://travis-ci.org/api-platform/client-generator.svg?branch=master)](https://travis-ci.org/api-platform/client-generator) -[![npm version](https://badge.fury.io/js/%40api-platform%2Fclient-generator.svg)](https://badge.fury.io/js/%40api-platform%2Fclient-generator) +[![GitHub Actions](https://github.com/api-platform/create-client/workflows/CI/badge.svg)](https://github.com/api-platform/create-client/actions?workflow=CI) +[![npm version](https://badge.fury.io/js/%40api-platform%2Fcreate-client.svg)](https://badge.fury.io/js/%40api-platform%2Fcreate-client) -API Platform Client Generator is a generator to scaffold app with Create-Retrieve-Update-Delete features for any API exposing a [Hydra](http://www.hydra-cg.com/spec/latest/core/) or [OpenAPI](https://www.openapis.org/) documentation for: +API Platform Create Client is a generator to scaffold apps with Create-Retrieve-Update-Delete features for any API exposing a [Hydra](http://www.hydra-cg.com/spec/latest/core/) or [OpenAPI](https://www.openapis.org/) documentation for: * Next.js * Nuxt @@ -18,7 +18,7 @@ Works especially well with APIs built with the [API Platform](https://api-platfo ## Documentation -The documentation of API Platform's Client Generator can be browsed [on the official website](https://api-platform.com/docs/client-generator). +The documentation of API Platform Create Client can be browsed [on the official website](https://api-platform.com/docs/create-client). ## Features @@ -27,22 +27,23 @@ The documentation of API Platform's Client Generator can be browsed [on the offi * Creation form * Editing form * Deletion button -* Use the Hydra or OpenAPI documentations to generate the code -* Generate the suitable HTML5 input type (`number`, `date`...) according to the type of the API property +* Use the Hydra or OpenAPI documentation to generate the code +* Generate the suitable input type (`number`, `date`...) according to the type of the API property * Display of the server-side validation errors under the related input (if using API Platform Core) * Client-side validation (`required` attributes) * The generated HTML is compatible with [Bootstrap](https://getbootstrap.com/) and includes mandatory classes * The generated HTML code is accessible to people with disabilities ([ARIA](https://www.w3.org/WAI/intro/aria) support) +* Bring your own templates ## Usage ### Hydra - npx @api-platform/client-generator https://demo.api-platform.com/ output/ --resource Book + npm init @api-platform/client https://demo.api-platform.com/ output/ --resource Book ### OpenAPI 3 - npx @api-platform/client-generator https://demo.api-platform.com/docs.json output/ --resource Book --format openapi3 + npm init @api-platform/client https://demo.api-platform.com/docs.json output/ --resource Book --format openapi3 ## Credits @@ -50,4 +51,4 @@ Created by [Kévin Dunglas](https://dunglas.fr). Sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop). -Commercial support available upon request. +Commercial support is available upon request. diff --git a/package.json b/package.json index 50d6b9f5..70c1f33b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@api-platform/client-generator", + "name": "@api-platform/create-client", "version": "0.8.0", "description": "Generate apps built with Next, Nuxt, Quasar, React, React Native, Vue or Vuetify for any API documented using Hydra or OpenAPI", "files": [ @@ -11,9 +11,9 @@ ], "type": "module", "exports": "./lib/index.js", - "repository": "api-platform/client-generator", - "homepage": "https://github.com/api-platform/client-generator", - "bugs": "https://github.com/api-platform/client-generator/issues", + "repository": "api-platform/create-client", + "homepage": "https://github.com/api-platform/create-client", + "bugs": "https://github.com/api-platform/create-client/issues", "author": "Kévin Dunglas", "license": "MIT", "devDependencies": { @@ -63,7 +63,7 @@ "test-gen": "rm -rf ./tmp && yarn build && ./testgen.sh", "test-gen-openapi3": "rm -rf ./tmp && yarn build && ENTRYPOINT=https://demo.api-platform.com/docs.json FORMAT=openapi3 ./testgen.sh", "test-gen-custom": "rm -rf ./tmp && yarn build && babel src/generators/ReactGenerator.js src/generators/BaseGenerator.js -d ./tmp/gens && cp -r ./templates/react ./templates/react-common ./templates/entrypoint.js ./tmp/gens && ./lib/index.js https://demo.api-platform.com ./tmp/react-custom -g \"$(pwd)/tmp/gens/ReactGenerator.js\" -t ./tmp/gens", - "test-gen-env": "rm -rf ./tmp && yarn build && API_PLATFORM_CLIENT_GENERATOR_ENTRYPOINT=https://demo.api-platform.com API_PLATFORM_CLIENT_GENERATOR_OUTPUT=./tmp ./lib/index.js", + "test-gen-env": "rm -rf ./tmp && yarn build && API_PLATFORM_CREATE_CLIENT_ENTRYPOINT=https://demo.api-platform.com API_PLATFORM_CREATE_CLIENT_OUTPUT=./tmp ./lib/index.js", "test-react-app": "rm -rf ./tmp/app && mkdir -p ./tmp/app && yarn create react-app --template typescript ./tmp/app/reactapp && yarn --cwd ./tmp/app/reactapp add react-router-dom react-hook-form && cp -R ./tmp/react/* ./tmp/app/reactapp/src && cp ./templates/react/index.tsx ./tmp/app/reactapp/src && start-server-and-test 'BROWSER=none yarn --cwd ./tmp/app/reactapp start' http://127.0.0.1:3000/books/ 'yarn playwright test'", "test-next-app": "rm -rf ./tmp/app && mkdir -p ./tmp/app && yarn create next-app --typescript ./tmp/app/next && yarn --cwd ./tmp/app/next add isomorphic-unfetch formik react-query && cp -R ./tmp/next/* ./tmp/app/next && rm ./tmp/app/next/pages/index.tsx && rm -rf ./tmp/app/next/pages/api && yarn --cwd ./tmp/app/next build && start-server-and-test 'yarn --cwd ./tmp/app/next start' http://127.0.0.1:3000/books/ 'yarn playwright test'", "test-vue-app": "rm -rf ./tmp/app && mkdir -p ./tmp/app && cd ./tmp/app && npm init -y vue@2 -- --router vue && cd ../.. && yarn --cwd ./tmp/app/vue add vuex@3 vuex-map-fields lodash && cp -R ./tmp/vue/* ./tmp/app/vue/src && cp ./templates/vue/main.js ./tmp/app/vue/src && yarn --cwd ./tmp/app/vue build && start-server-and-test 'yarn --cwd ./tmp/app/vue vite preview --host 127.0.0.1 --port 3000' http://127.0.0.1:3000/books/ 'yarn playwright test'", diff --git a/src/index.js b/src/index.js index 707d21a7..50853f20 100755 --- a/src/index.js +++ b/src/index.js @@ -56,8 +56,8 @@ async function main() { if ( 2 !== program.args.length && - (!process.env.API_PLATFORM_CLIENT_GENERATOR_ENTRYPOINT || - !process.env.API_PLATFORM_CLIENT_GENERATOR_OUTPUT) + (!process.env.API_PLATFORM_CREATE_CLIENT_ENTRYPOINT || + !process.env.API_PLATFORM_CREATE_CLIENT_OUTPUT) ) { program.help(); } @@ -65,9 +65,9 @@ async function main() { const options = program.opts(); const entrypoint = - program.args[0] || process.env.API_PLATFORM_CLIENT_GENERATOR_ENTRYPOINT; + program.args[0] || process.env.API_PLATFORM_CREATE_CLIENT_ENTRYPOINT; const outputDirectory = - program.args[1] || process.env.API_PLATFORM_CLIENT_GENERATOR_OUTPUT; + program.args[1] || process.env.API_PLATFORM_CREATE_CLIENT_OUTPUT; const entrypointWithSlash = entrypoint.endsWith("/") ? entrypoint