Skip to content

[6.2] Fix: Add method to copy Codemirror license file to builder - #47794

Merged
MacJoom merged 5 commits into
joomla:6.2-devfrom
LadySolveig:6.2/fix/build-licence-codemirror
May 23, 2026
Merged

MacJoom merged 5 commits into
joomla:6.2-devfrom
LadySolveig:6.2/fix/build-licence-codemirror

Conversation

@LadySolveig

@LadySolveig LadySolveig commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request resolves #46879 (comment) .

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

Add method to copy the CodeMirror license file to the builder. This ensures that the required license file is included in the build output if specified in the build settings.

Build process improvements:

  • Added a copy method to CodemirrorModuleBuilder that copies the CodeMirror license file to the target location if specified in the build settings (settings.json). This method first calls the parent copy method, then checks for the license filename in the build settings, resolves its path, and copies it to the build output directory.

Testing Instructions

run npm ci

Issues are currently occurring on Windows - for testing this PR with Windows you have to wait that this PR #47793 is merged before, or apply the patch manually.
To validate the test results, please specify the operating system on which the tests were executed.

Actual result BEFORE applying this Pull Request

No LICENSE file in `media/plg_editors_codemirror

Expected result AFTER applying this Pull Request

media/plg_editors_codemirror/LICENSE is availbale in the media folder after build

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@LadySolveig LadySolveig changed the title fix: Add method to copy Codemirror license file to builder [6.2] Fix: Add method to copy Codemirror license file to builder May 18, 2026
@LadySolveig

Copy link
Copy Markdown
Contributor Author

It would be great if you could take another look at this as well @dgrammatiko

@richard67

richard67 commented May 18, 2026 •

Copy link
Copy Markdown
Member

I have tested this item ✅ successfully on 732952d

I've successfully verified that the media/plg_editors_codemirror/LICENSE file is present after a build with this PR, which is not the case without this PR, and that there are no unexpected other differences compared to a build with the current 6.2-dev branch. I've tested on Linux.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47794.

@richard67

Copy link
Copy Markdown
Member

The failing system tests are not related to this PR.

@brianteeman

Copy link
Copy Markdown
Contributor

why do we need a specific method for inclufing the licence for codemirror but not for all other packages? Surely this is a bandage and not a fix to why the code that works for all other packages doesnt work for codemirror. Or is there something specific about codemirror causing this break? Its important to understand the reason so that when we introduce a new package from a new vendor in the future we know if we need to create a specific code for the licence or not

@richard67

richard67 commented May 18, 2026 •

Copy link
Copy Markdown
Member

why do we need a specific method for inclufing the licence for codemirror but not for all other packages? Surely this is a bandage and not a fix to why the code that works for all other packages doesnt work for codemirror. Or is there something specific about codemirror causing this break? Its important to understand the reason so that when we introduce a new package from a new vendor in the future we know if we need to create a specific code for the licence or not

@brianteeman The reason why codemirror is special here is because in our package.json we do not have one dependency for codemirror but several, and there is no master dependency above it, so we have several source folders in node_modules but onmly one target folder in media/vendor. That's why it needs that special treatment.

See https://github.com/joomla/joomla-cms/blob/6.2-dev/package.json#L37-L51 .

P.S.: The LICENSE file is the same for all of these.

@brianteeman

Copy link
Copy Markdown
Contributor

Thank you for the explanation

@dgrammatiko

Copy link
Copy Markdown
Contributor

LGTM

@heelc29

heelc29 commented May 22, 2026

Copy link
Copy Markdown
Contributor

Wouldn't it be sufficient to align these two?

const destBasePath = 'media/vendor/codemirror/js';

const vendorPath = 'media/vendor/codemirror';

@brianteeman

Copy link
Copy Markdown
Contributor

is this code redundant now?

"@codemirror/view": {
"name": "codemirror",
"licenseFilename": "LICENSE"
},

@LadySolveig

LadySolveig commented May 22, 2026 •

Copy link
Copy Markdown
Contributor Author

I've experimented a bit with your idea. It's possible, but what benefit do we gain from it? @heelc29
If I remove /js from that line, I have to manually re-add it to every call in the compileCodemirror function.

Wouldn't it be sufficient to align these two?

const destBasePath = 'media/vendor/codemirror/js';

If I add /jsadditionally here, I never get a clean starting point again, and the media/vendor/codemirror folder always remains present after the first build.

const vendorPath = 'media/vendor/codemirror';

In this specific builder we are handling two different resources: plg_edtitors_codemirror and vendor/codemirror. The first folder is cleanly removed through the parent call await super.clear();, and then we remove the vendor/codemirror additionally.

@LadySolveig

LadySolveig commented May 22, 2026 •

Copy link
Copy Markdown
Contributor Author

is this code redundant now?

"@codemirror/view": {
"name": "codemirror",
"licenseFilename": "LICENSE"
},

@brianteeman No, see my description of the PR

Added a copy method to CodemirrorModuleBuilder that copies the CodeMirror license file to the target location if specified in the build settings (settings.json).

We could specify the path directly in the method, but since this would be the only instance in the entire build process not to define the license file in the global settings, it would likely create maintenance friction in the long run.

@brianteeman

Copy link
Copy Markdown
Contributor

we could say this is the only licence that needs special handling outside of the global settings but I get your point ;)

@heelc29

heelc29 commented May 22, 2026

Copy link
Copy Markdown
Contributor

I've experimented a bit with your idea. It's possible, but what benefit do we gain from it? @heelc29 If I remove /js from that line, I have to manually re-add it to every call in the compileCodemirror function.

If I add /jsadditionally here, I never get a clean starting point again, and the media/vendor/codemirror folder always remains present after the first build.

const vendorPath = 'media/vendor/codemirror';

In this specific builder we are handling two different resources: plg_edtitors_codemirror and vendor/codemirror. The first folder is cleanly removed through the parent call await super.clear();, and then we remove the vendor/codemirror additionally.

@LadySolveig The advantage would be that you would only need to adjust this line, rather than having to extend the copy method.

The CodemirrorModuleBuilder writes only in the js subfolder of media/vendor/codemirror so it should be enough to clear this folder.

The VendorModuleBuilder already ensures a clean starting point for media/vendor/*.

@LadySolveig

LadySolveig commented May 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@heelc29 I see, you mean that since the entire vendor folder is deleted anyway...IF I run a complete new build with all. However, it will only be cleared up completely then when you run npm run -- --all. Not when you run the individual builder with npm run -- -n plg_editors_codemirror. And also only copied with build all. Or am I missing something?

To be honest, I'm quite pragmatic about this. We can also align the paths like you suggested if we're willing to accept the little inconsistency in that specific case.

@MacJoom MacJoom added this to the Joomla! 6.2.0 milestone May 23, 2026
@MacJoom
MacJoom merged commit 1a249df into joomla:6.2-dev May 23, 2026
52 checks passed
@MacJoom

MacJoom commented May 23, 2026

Copy link
Copy Markdown
Member

Thank you very much!

@richard67

richard67 commented May 24, 2026 •

Copy link
Copy Markdown
Member

Weird ... I had successfully tested this PR, and after that were no changes except of clean branch updates, but now after it has been merged into 6.2-dev it does not work anymore for me on a current 6.2-dev branch which includes this PR on the same environment (Linux) as used for my successful test. The media/vendor/codemirror/LICENSE file does not exist after composer installand npm ci. Same for packages built with build/build.php, the file is not in the package.

Can it be that the Windows fix from the other PR has changed something here? From code reading I would not expect that, but I don't have any other idea now.

@brianteeman

Copy link
Copy Markdown
Contributor

same problem here after a cvlean checkout followed by composer install npm install and i am on windows

@MacJoom

MacJoom commented May 24, 2026

Copy link
Copy Markdown
Member

I have just tested it again on windows and LICENSE is placed into media/plg_editors_codemirror...
Screenshot 2026-05-24 132309

@richard67

richard67 commented May 24, 2026 •

Copy link
Copy Markdown
Member

Ah .. I see .. it's copied to a different place, not the media/vendor/codemirror like it was before but the media/plg_editors_codemirror. So the old place is not a false alarm when I run my deleted files check.

@richard67

Copy link
Copy Markdown
Member

Hmm, but e.g. for TinyMCE, the file license.md is still placed in the media/vendor/tinymce folder and not in the media/plg_editors_tinymce/ folder.

But for Codemirror it is now media/plg_editors_codemirror/ and not media/vendor/codemirror.

That seems inconsistent to me.

@brianteeman

Copy link
Copy Markdown
Contributor

yes I see that - its definitely in the wrong place. the licence must be in the vendor/codemirror folder

@richard67

Copy link
Copy Markdown
Member

@brianteeman Could you test PR #47823 ? For me it fixes the issue witht eh LICENSE file without causing any other differences.

MacJoom pushed a commit that referenced this pull request May 24, 2026
* refactor: Revert changes from #47794 and align paths for clear and compile in plg_system_codemirror

* Revert changes from #47794 - remove copy function from builder

Co-authored-by: Christian Heel <66922325+heelc29@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants