Skip to content

Conversation

@ToshY
Copy link
Contributor

@ToshY ToshY commented Jan 22, 2025

What does this PR do?

Adds GitHub workflow to automatically publish the JS assets to NPM on new releases. This feature allows the user to separately install the @flasher JS libraries for 2.x and allows containerized tools (like Dependabot) to install (and bump) depedencies without having to depend on assets of the underlying PHP library php-flasher.

Description of Task to be completed

How should this be manually tested?

  1. Create a new release, 2.1.3.
  2. In a Symfony application, separately install assets with NPM.
{
  "dependencies": {
    "@flasher/flasher": "^2.1.3",
    "@flasher/flasher-sweetalert": "^2.1.3",
  }
}
  1. Add it in your javascript files.
import "sweetalert2/dist/sweetalert2.min.css";

import flasher from "@flasher/flasher";
import '@flasher/flasher-sweetalert';

global.flasher = flasher;
  1. In flasher.yaml add config to explicitely disable main_script, styles (and same for plugins scripts and styles).
flasher:
  default: sweetalert
  main_script: ~
  styles: ~
  # inject assets to `true` as this only injects the js snippet to display the flash message (no addition core css or js)
  inject_assets: true
  translate: true
  flash_bag:
    success: [ 'success' ]
    error: [ 'error', 'danger' ]
    warning: [ 'warning', 'alarm' ]
    info: [ 'info', 'notice', 'alert' ]
  filter:
    limit: 5

  plugins:
    sweetalert:
      scripts: ~
      styles: ~

  presets:
    hello:
      type: 'info'
      message: 'Welcome back'
      options: &default-options
        toast: true
        position: bottom-end
        showConfirmButton: false
        timer: 7500
  1. Display flash message from PHP, e.g. sweetalert().
sweetalert()->addPreset('hello');
  1. Check the message being displayed and styled with the specified plugin styling.
    image

Relevant Issues

Background context

Screenshots (Optional)

n/a

Dependencies

n/a

- name: Publish to NPM
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoeunes This requires setting the NPM_TOKEN in your Github repository secrets for actions.

@ToshY
Copy link
Contributor Author

ToshY commented Jan 22, 2025

@yoeunes I have tested this in ToshY#1 and I don't seem to have any issues. The workflow seems kind of straighforward and I did not have to change a lot compared to the example in the docs. Don't worry, I will delete the temporary packages I used for testing in ToshY#1 after this has been merged.

Let me know if you have any further comments or remarks.

@yoeunes
Copy link
Member

yoeunes commented Jan 25, 2025

@ToshY Thank you for your hard work on this

@yoeunes yoeunes merged commit f66382e into php-flasher:2.x Jan 25, 2025
11 checks passed
@ToshY
Copy link
Contributor Author

ToshY commented Jan 25, 2025

Hey @yoeunes

I just saw the release, but the action seems to have failed on the Publish step. Was the NPM_TOKEN added in the repository secrets?

https://github.com/php-flasher/php-flasher/actions/runs/12965460260/job/36165208933

@yoeunes
Copy link
Member

yoeunes commented Jan 25, 2025

Thank you @ToshY

@yoeunes
Copy link
Member

yoeunes commented Jan 25, 2025

Hey @yoeunes

I just saw the release, but the action seems to have failed on the Publish step. Was the NPM_TOKEN added in the repository secrets?

https://github.com/php-flasher/php-flasher/actions/runs/12965460260/job/36165208933

Yes, i've added the NPM_TOKEN secret to the repository, i'm trying to figure out why this is failing

@ToshY
Copy link
Contributor Author

ToshY commented Jan 25, 2025

@yoeunes

Then not correctly it seems, as it's empty: https://github.com/php-flasher/php-flasher/actions/runs/12965460260/job/36165208933#step:5:6

I've ran it in my own repo without problems: https://github.com/ToshY/php-flasher/actions/runs/12965779640/job/36165867881#step:5:6


Did you add it under "Secrets and variables" > "Actions" > "Repository secrets"?

image

@yoeunes
Copy link
Member

yoeunes commented Jan 25, 2025

Oh my bad, thank you

@ToshY
Copy link
Contributor Author

ToshY commented Jan 25, 2025

Oh my bad, thank you

No problem. When you've added it, re-run the failed workflow and it should be fine 👍

@ToshY
Copy link
Contributor Author

ToshY commented Jan 28, 2025

@yoeunes Reminder to add/update the NPM_TOKEN and retrigger the workflow. Thanks in advance.

@yoeunes
Copy link
Member

yoeunes commented Jan 28, 2025

Hello @ToshY , can you install the v2 from npm as i published it from my local machine, i will try to remove the 2FA which is blocks the github workflow right now

@ToshY
Copy link
Contributor Author

ToshY commented Jan 28, 2025

Hello @ToshY , can you install the v2 from npm as i published it from my local machine, i will try to remove the 2FA which is blocks the github workflow right now

Tested, works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BC] ResourceMananger no longer allows nullable main_script / root_script

2 participants