Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KariNarhi28 opened this issue Jul 17, 2024 · 3 comments
Labels
design 📐 This issue deals with high-level design of a feature type: feature ✨ @vendure/cli

Comments

@KariNarhi28
Copy link

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:

  • vendure build
    • Build the API into a dist-folder and copy assets (dist-folder and asset-paths configured in the JSON-file)
    • Also could handle multiple env-files by using the configurations-map of environment-configurations with the fileReplacements-technique that angular.json also has.
  • vendure test
    • Supposing that Vendure could have a pre-defined testing setup with Jest and Cypress?
  • vendure populate
    • This would populate the DB and could take 3 different options:
      • --csv pointing to a CSV-file containing the products-data.
      • --initial-data, pointing to a Typescript -file containing the initialData-object.
      • The 2 options above could be mandatory with each other, or if other is not provided, then the missing data would be from the test-data.
      • Alternatively, --test which would use the test-data from:
        • @vendure/create/assets/products.csv
        • @vendure/create/assets/initial-data.json
      • If all 3 would be provided, then the --csv and --initial-data options would take priority over --test.

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
Copy link

does your pouplate db script support external asset server ?

@KariNarhi28
Copy link
Author

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
Copy link
Member

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.

@michaelbromley michaelbromley moved this to 📅 Planned in Vendure OS Roadmap Aug 1, 2024
@dlhck dlhck moved this from 📅 Planned to 👀 Under consideration in Vendure OS Roadmap Sep 24, 2024
@dlhck dlhck added the design 📐 This issue deals with high-level design of a feature label Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design 📐 This issue deals with high-level design of a feature type: feature ✨ @vendure/cli
Projects
Status: 👀 Under consideration
Development

No branches or pull requests

4 participants