Git Product home page Git Product logo

Comments (1)

Skipants avatar Skipants commented on May 25, 2024

Not sure if anyone cares 4 years later but here's what we did in our fork of ember-cli-rails to get workspaces working:

diff --git a/lib/ember_cli/path_set.rb b/lib/ember_cli/path_set.rb
index 9a30e2c..c246a51 100644
--- a/lib/ember_cli/path_set.rb
+++ b/lib/ember_cli/path_set.rb
@@ -1,3 +1,4 @@
+require "json"
 require "ember_cli/helpers"
 
 module EmberCli
@@ -41,7 +42,7 @@ module EmberCli
 
     def ember
       @ember ||= begin
-        root.join("node_modules", "ember-cli", "bin", "ember").tap do |path|
+        ember_path.tap do |path|
           unless path.executable?
             fail DependencyError.new <<-MSG.strip_heredoc
               No `ember-cli` executable found for `#{app_name}`.
@@ -148,6 +149,31 @@ module EmberCli
       app_options[:yarn] || app_options[:yarn_path]
     end
 
+    def workspace?
+      manifest_path = rails_root.join("package.json")
+      return false unless File.file?(manifest_path)
+
+      workspaces = JSON.parse(File.read(manifest_path)).fetch("workspaces", [])
+
+      workspaces.any? { |workspace| File.fnmatch(workspace, relative_path) }
+    end
+
+    def relative_path
+      @relative_path ||= begin
+        path = app_options.fetch(:path) { default_root }
+        pathname = Pathname.new(path)
+        pathname.relative_path_from(rails_root)
+      end
+    end
+
+    def ember_path
+      if workspace?
+        root.join("node_modules", ".bin", "ember")
+      else
+        root.join("node_modules", "ember-cli", "bin", "ember")
+      end
+    end
+
     def app_name
       app.name
     end

This works because doing a yarn install at the top-level with a package.json that has workspaces drops an ember bin stub in each dir under node_modules/.bin/ember.

I am not confident in making a PR because I'm not totally 100% knowledgeable about this gem and not sure where setup from our app starts and the gem finish. It's also only been tested with yarn (latest), node 14, rails 5, and ruby 2.5. So YMMV.

from ember-cli-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.