generated from alexcanessa/template-generic-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
Description
This is to propose and discuss what a 1.0.0 version should look like and how it should work.
migration content type
| Field name | Kentico type | Actual type |
|---|---|---|
| id | string | UUID |
| filename | dateTime | dateTime |
| name | string | string |
id- should be a UUIDfilename- should be the migration file namename- should be the name of the migration
migration files
- Should contain an up and down function in typescript
- Should pass Kentico client to the user
- Kentico client should pass corresponding typescript types
- Should pass a secondary object with element models
- Element models should pass the corresponding typescript types
Setup
the namespace for the project should be: migrate
- Install the package from NPM
- Setup namespace in the bin
Environment variables
| Variable | required | description |
|---|---|---|
| API_KEY | ✓ | Kentico API key |
| PROJECT_ID | ✓ | Kentico project id |
| ENVIRONMENT | ✓ | Kentico environment |
| MIGRATION_FOLDER | ✓ | Kentico migration folder |
| PREVIEW_KEY | ✓ | Kentico preview key |
Commands:
Init migrate init
Initiate the plugin and set up the migration content type on Kentico
Errors
- Should print a message to the user if creating migration content type fails
Flow
- Connect to Kentico and create migration content-type
- if content-type already exists error and log message
Run -- migrate run
Runs all existing migrations that do not exist in Kentico or runs a specific migration passed in the arguments.
arguments:
--id- Pass the id of the migration to run
Errors
- Should print validation messages out to the user
- Should print a message if the individual migration has already been run
Flow
- all migrations
- Get all migrations from Kentico
- Compare with local migrations
- Gather migrations that have not been run
- Run each migration (async)
- If the migration fails log an error message and continues running the next migration.
- If the migration succeeds create a migration record for it in Kentico
- Individual migration
- Check migration has not been run
- Run the migration
- if the migration fails print error messages
- if the migration succeeds create a migration record in Kentico
Rollback -- migrate rollback
Rollback the last migration created in Kentico or rollback a specific migration passed in arguments
arguments:
--id- Pass the id of the migration to run--force- Force the migration if there is data associated with it
Errors
- Should print a message to the user if the content type is in use and should fail if not forced
- Should print an error and stop if the last migration is not present in the file system
Flow
- no arguments
- Get the latest migration
- Compare with local migrations and find migration file
- Fail if migration file not found
- Run rollback
- If the rollback fails log an error message.
- if the migration has associated content check for
--forceargument- If force continue with rollback
- if no force error and inform the user
- If the rollback succeeds delete the migration record on Kentico
--idspecific migration rollback- Get the migration via
id- if the migration cannot be found log error
- Compare with local migrations and find migration file
- Fail if migration file not found
- Run rollback
- If the rollback fails log an error message.
- if the migration has associated content check for
--forceargument- If force continue with rollback
- if no force error and inform the user
- If the rollback succeeds delete the migration record on Kentico
- Get the migration via
make -- migrate make [name]
Create new migration file locally
arguments:
--desc- Pass the description of the model
Errors
- Should print a message to the user if creating migration file fails
Flow
- generate UUID
- concatenate name and title
- create migration file with inserted description if passed
Testing and Release
We should use tooling such as NP
Readme
Should contain a readme with:
- CI badges
- NPM Badges
- description
- setup instructions
- examples
- caveats
- contributors
Unit Tests
- Build functional pieces of code that can be easily tested
- Setup jest with appropriate packages to test
- Should have a coverage threshold of 90%
E2E tests
E2E tests shouldn't be included in version one
Linting
- Should be set up with husky for linting
- Should be up with prettier
- Should be set up with ESLint
- Should be set up with CommitLint
- Should be setup LGTM
Setup CI
- Setup CI to use the above package
- Create a new release on each merge of a PR
- Setup CI to run tests on PR's
The rest is open for discussion on releasing and I will leave this here...
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested