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

Minimal Support for JavaScript Modification in CLI Generator #181

Closed
shahryarjb opened this issue Dec 13, 2024 · 1 comment · Fixed by #254
Closed

Minimal Support for JavaScript Modification in CLI Generator #181

shahryarjb opened this issue Dec 13, 2024 · 1 comment · Fixed by #254

Comments

@shahryarjb
Copy link
Member

shahryarjb commented Dec 13, 2024

We must keep app.js very clean and edit the mishka_chelekom_components.js file.

For example:

// assets/vendor/components.js

import CopyMixInstallationHook from "./mixCopy.js";
import CopyColorInstallationHook from "./colorCopy.js";

const Components = {
  CopyMixInstallationHook,
  CopyColorInstallationHook,
};

export default Components;

And inside app.js

// assets/js/app.js

import Components from "../vendor/components.js";

let liveSocket = new LiveSocket("/live", Socket, {
  hooks: { ...Hooks, ...Components },

What we need from igniter_js project

  1. Can check the module name is imported or not
  2. If it is imported, it is assigned to components object or not
  3. Check the app.js has this module as an imported module or not
  4. And check the hooks has the components module like Spreaded object?
  5. If not, so we need to add it
  6. We need to delete all the top numbers from the files

What functions we have now

  • exist_live_socket/2
  • exist_live_socket?/2
  • extend_hook_object/3
  • insert_imports/3
  • module_imported/3
  • module_imported?/3
  • remove_imports/3
  • remove_objects_from_hooks/3
  • statistics/2

exs config for adding js file

[
  some_component: [
    name: "some_component",
    args: [
      variant: [],
      color: [],
      size: [],
      rounded: [],
      type: [],
      only: [],
      helpers: [],
      module: ""
    ],
    optional: [],
    necessary: [],
    scripts: [
      %{type: :file, file: "some_component.js", imports: "SomeComponent"},
      %{type: :file, file: "another_component.js", imports: "SomeComponent"},
      %{type: :npm, name: "some-npm-package", imports: "SomeComponent"}
    ]
  ]
]
@shahryarjb
Copy link
Member Author

The exs file should be like this:

[
  combobox: [
    name: "combobox",
    args: [
      color: [
        "base",
        "white",
        "primary",
        "secondary",
        "dark",
        "success",
        "warning",
        "danger",
        "info",
        "silver",
        "misc",
        "dawn"
      ],
      size: ["extra_small", "small", "medium", "large", "extra_large"],
      rounded: ["extra_small", "small", "medium", "large", "extra_large"],
      only: ["combobox"],
      helpers: [],
      module: ""
    ],
    optional: [],
    necessary: [],
    scripts: [
      %{
        type: "file",
        file: "combobox.js",
        module: "Combobox",
        imports: "import Combobox from \"./combobox.js\";"
      }
    ]
  ]
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant