com-pas / compas-open-scd

A substation configuration description editor for projects using SCL IEC 61850-6 Edition 2 or greater
https://openscd.github.io
Apache License 2.0
13 stars 3 forks source link

CoMPAS-Open-SCD should adhere to the new monorepo structure #266

Open pascalwilbrink opened 1 year ago

pascalwilbrink commented 1 year ago

Intro

The Open-SCD project recently went from a monolith to a mono-repo architecture. In order to accomplish this a restructure was needed. This has a severe effect on the Compas-Open-SCD repository. The Compas-Open-SCD repository is a fork of the Open-SCD project and has added functionalities to it. If we want to apply the newest changes of the Open-SCD project, we first have to do some manual labor in order to prevent merge conflicts.

Changes made to the fork

As said above, the Compas-Open-SCD repository is a fork, but with alterations. Before we know how to resolve the coming merge conflicts. We need to make sure we know which files are added and which ones are altered, so we can take those into account. These files are noted in the lists below.

New files added to the project

Files from Open-SCD that are altered

Dependencies from Open-SCD

Suggestions to approach this issue

Step 1: Apply the restructure

Now that the file structure is clear a proof of concept can be made to see if the merge issues can be resolved. There are 2 options here to start.

  1. Apply the restructure manually to the entire Compas-Open-SCD project. This would mean to bump every file up 2 folders (packages/open-scd). This is probably the fastest way to implement the new structure. However the idea is to move out the compas related software to a different package. This can be more challenging with this approach
  2. Create a new fork of Open-SCD and start moving the software to the new package and see what we need from the Open-SCD package. This will probably take a bit more time, but it does leave out the manual labor that needs to be done first in order to get the new Open-SCD version.

Both approaches have merit and can be done. However approach #1 will keep the git history of Compas-Open-SCD in tact. If that's desirable the first approach would be best.

Step 2: Move out compas related software

The idea is that the open-scd package should be completely identical to the open-scd package we fork from. This will mean that The entire list from the new files should be moved to a packages/compas folder. Be sure that this folder has a dependency to the packages/open-scd folder.

Step 3: Move out tests for the Compas software

When the source code is succesfully moved out and the dependencies work correctly the tests can be moved out and run. Be sure all tests are succesful.

Step 4: Make sure the docker container is correctly build

The docker container should eventually be build from the compas package in order to make sure everything is included.

Open questions

Before starting

pascalwilbrink commented 1 year ago

We can split this story up into multiple substories

1) Move everything from CoMPAS-OpenSCD up 1 folder (like has been done for OpenSCD) 2) Extract all the CoMPAS code into /packages/compas (So that /packages/open-scd will be exactly the same as @openscd/open-scd/main:packages/open-scd

3) Make packages/openscd be a dependency of packages/compas 4) Make sure that the docker container is built from packages/compas

pascalwilbrink commented 11 months ago

Changed files ValidateTemplates.test.ts ImportIedsPlugin.test.ts IED.test.ts datasets-container.test.snap.js IED.test.snap.js Setting.test.snap.js open-scd.test.snap.js wizard-textfield.ts Wizard-dialog.ts En.ts de.ts Setting.ts Plugging.ts open-scd.ts UpdateSubstation.ts OpenProject.ts Merge.ts ImportIEDs.ts Logging.ts Hosting.ts foundation.ts IED.ts Editing.ts

pascalwilbrink commented 11 months ago

Questions:

Should openSCD be able to import ISD files? if so: Update OpenProject.ts and Merge.ts and ImportIEDs.ts in OpenSCD to allow ISD files. if not: Should ComPas be able to? if so: make fileExtensions configurable in OpenSCD (bigger refactoring) if not: Remove ISD file from CoMPAS-OpenSCD/OpenProject.ts and Merge.ts and ImportIEDs.ts

pascalwilbrink commented 11 months ago

Things to do:

pascalwilbrink commented 11 months ago

How to migrate:

Steps that we need to take

1) Move (almost) everything from (CoMPAS-Open-SCD)[https://github.com/com-pas/compas-open-scd] up 2 folders: packages/compas-open-scd.

Move the following:

2) Update .github folder

A) Update .github/dependabot.yml The package-ecosystem docker should have directory packages/compas-open-scd/, instead of /

B) Update .github/build-project.yml Update the steps Test application with npm, Build application with npm, Build docker image: cd packages/compas-open-scd && ..

C) Update .github/release-project.yml Update the steps Build application with npm, Build and push docker image to Docker Hub: cd packages/compas-open-scd && ..

D) Update .github/test-and-build.yml Update the step Install and Build: cd packages/compas-open-scd && ..

E) Update .github/test.yml Update the step Install and Test: cd packages/compas-open-scd && ..

3) Create new Files in the repository root

A) Create a new README.md explaining about the monorepository and point to packages/compas-open-scd/README.md (See (OpenSCD README)[https://github.com/openscd/open-scd/blob/main/README.md] as an example)

B) Create a new .gitignore

C) Create a new package.json

{
  "name": "compas-openscd-monorepo",
  "version": "0.0.1",
  "description": "CoMPAS OpenSCD base distribution and plugins",
  "private": true,
  "workspaces": [
    "packages/*"
  ],
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/com-pas/compas-open-scd.git"
  },
  "license": "Apache-2.0"
}

4) Sync com-pas/CoMPAS-Open-SCD with main from openscd/open-scd.

5) Make sure that CoMPAS-Open-SCD and OpenSCD are build correctly. For CoMPAS-Open-SCD, we can easily check if it's build correctly (npm start). Since CoMPAS-Open-SCD will make use of plugins that are maintained by OpenSCD, we need to either Copy those (built) plugins over, or adjust the build process of CoMPAS-Open-SCD.

Copy plugins over: 5A) Create a build script in the root package.json 'build': 'cd packages/open-scd && npm run build && cd packages/compas-openscd && npm run build' 'postbuild': 'cp packages/open-scd/build'

Adjust build process: 5B) Update the snowpack.config.mjs inside packages/compas-openscd. Add the packageOptions.knownEntrypoints inside snowpack configuration to add @openscd/open-scd as a known dependency.

Step 5B will be easiest and cleanest, just some playing around with Snowpack.

6) Update plugin.json in packages/compas-open-scd with OpenSCD plugins that have correct pointers (depending on step 5. See build folder)

7) Remove identical files between packages/compas-open-scd and packages/open-scd.

github-actions[bot] commented 9 months ago

Hello there,

Thank you for opening this issue! We appreciate your interest in our project. However, it seems that this issue hasn't had any activity for a while. To ensure that our issue tracker remains organized and efficient, we occasionally review and address stale issues.

If you believe this issue is still relevant and requires attention, please provide any additional context, updates, or details that might help us understand the problem better. Feel free to continue the conversation here.

If the issue is no longer relevant, you can simply close it. If you're uncertain, you can always reopen it later.

Remember, our project thrives on community contributions, and your input matters. We're here to collaborate and improve. Thank you for being part of this journey!