vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.77k stars 1.02k forks source link

Vendure CLI commands for build/testing + JSON-config (similar to what angular.json is) #2953

Open KariNarhi28 opened 4 months ago

KariNarhi28 commented 4 months ago

Is your feature request related to a problem? Please describe.

Currently Vendure (+ Admin UI) build and testing steps require custom scripts.

For example with build, compiling Typescript files and then copying assets into the dist-folder, or using the populate-function script for test-data when testing.

This is error-prone and can be time-consuming if you don't have a pre-existing template to work with.

Describe the solution you'd like

Built-in CLI commands for npx vendure to build and test the Vendure API + Admin UI based on a configuration JSON-file, similar to how Angular handles CLI with angular.json.

Here are some pseudo-examples:

Describe alternatives you've considered An up-to-date and clear step-by-step guide in the docs for setting up production-ready configurations for these processes.

For comparison, Cloud Run example from Pinelab which is linked in the docs, seems a bit dated and abandoned, newest change was a README update 2 months ago, earlier commits from last year, so clearly not the latest Vendure-stuff included in there.

Additional context Currently I have 6 scripts to produce a dist-folder with compiled Typescript and assets and 2 scripts for db-population and 1 for testing:

    "copy-admin-ui-dist": "npx copyfiles -u 1 'src/__admin-ui/dist/**/*' dist",
    "copy-admin-ui-images": "npx copyfiles -u 2 'src/admin-ui/images/**/*' dist/admin-ui",
    "copy-translations": "npx copyfiles -u 1 'src/translations/*' dist",
    "copy-assets": "npm run copy-admin-ui-images && npm run copy-translations",
    "build": "rimraf dist && tsc && npm run copy-admin-ui-dist && npm run copy-assets",
    "build:admin": "rimraf ./src/__admin-ui && ts-node src/admin-ui/compile-admin-ui.ts",
    "populate-db": "ts-node ./src/utils/populate-db.ts",
    "populate-test-data": "ts-node ./src/utils/populate-test-data.ts",
    "test": "jest --preset=\"ts-jest\""

Sure, I could put the assets into one folder (as I probably will), but the issue is there that I have to copy the assets to the tsc-generated dist-folder, since tsc does not recognize other files than .ts or .tsx.

And also that I need to have custom Typescript-scripts using the Vendure-libraries for the db-population, instead of just providing the datafiles for a CLI command.

moussaab-moulim commented 3 months ago

does your pouplate db script support external asset server ?

KariNarhi28 commented 3 months ago

does your pouplate db script support external asset server ?

Don't think so, it's pretty much the same script that is shown on Vendure docs: https://docs.vendure.io/guides/developer-guide/importing-data/#the-populate-function

Haven't really studied the importing-related stuff since our use-case is that users add the product-materials manually by themselves.

michaelbromley commented 3 months ago

We do have plans to expand the scope of the CLI to cover more of the dev experience like building and testing. Right now we are in the early planning stages.