Skip to content

Commit 7bbad49

Browse files
committed
fix: No longer bundle @appland/appmap with this gem
User must install @appland/appmap to the enclosing project. Then in will be invoked using 'npx'. Bundling @appland/appmap is too fragile.
1 parent de04c88 commit 7bbad49

File tree

13 files changed

+3355
-131
lines changed

13 files changed

+3355
-131
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jobs:
3636
env:
3737
# GEM_ALTERNATIVE_NAME only needed for deployment
3838
- GEM_ALTERNATIVE_NAME=''
39-
script: bundle exec rake
4039

4140
before_deploy:
4241
- |
@@ -51,4 +50,4 @@ deploy:
5150
script: ./release.sh
5251
on:
5352
branch: master
54-
condition: "$TRAVIS_RUBY_VERSION = 2.7"
53+
condition: "$TRAVIS_RUBY_VERSION = 3.0"

Rakefile

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,6 @@ Rake::ExtensionTask.new("appmap") do |ext|
1313
ext.lib_dir = "lib/appmap"
1414
end
1515

16-
namespace 'gem' do
17-
require 'bundler/gem_tasks'
18-
19-
module Bundler
20-
class GemHelper
21-
# A handy tip - find the location of any Rake task using `rake -W`.
22-
# rake -W build
23-
# ~/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/gem_helper.rb:39:in `install'
24-
def build_gem
25-
raise "Don't use 'rake gem:build' - use 'yarn install --prod && gem build <gemspec>', because that's what ./release.sh does"
26-
end
27-
end
28-
end
29-
end
30-
3116
RUBY_VERSIONS=%w[2.6 2.7 3.0].select do |version|
3217
travis_ruby_version = ENV['TRAVIS_RUBY_VERSION']
3318
next true unless travis_ruby_version
@@ -72,6 +57,11 @@ def build_app_image(app, ruby_version)
7257
end
7358
end
7459

60+
desc 'Install non-Ruby dependencies'
61+
task :install do
62+
system 'yarn install' or raise 'yarn install failed'
63+
end
64+
7565
namespace :build do
7666
namespace :base do
7767
RUBY_VERSIONS.each do |ruby_version|
@@ -80,7 +70,6 @@ namespace :build do
8070
run_system = ->(cmd) { system(cmd) or raise "Command failed: #{cmd}" }
8171

8272
run_system.call 'mkdir -p pkg'
83-
run_system.call 'yarn install --prod'
8473
run_system.call "gem build appmap.gemspec --output pkg/appmap-#{GEM_VERSION}.gem"
8574
build_base_image(ruby_version)
8675
end.tap do |t|
@@ -139,7 +128,7 @@ end
139128
namespace :spec do
140129
RUBY_VERSIONS.each do |ruby_version|
141130
desc ruby_version
142-
task ruby_version, [:specs] => ["compile", "build:fixtures:#{ruby_version}:all"] do |_, task_args|
131+
task ruby_version, [:specs] => ["install", "compile", "build:fixtures:#{ruby_version}:all"] do |_, task_args|
143132
run_specs(ruby_version, task_args)
144133
end.tap do |t|
145134
desc "Run all specs"

appmap.gemspec

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ Gem::Specification.new do |spec|
2323
spec.bindir = 'exe'
2424
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2525

26-
strip_dir = ->(file) { file.index(Dir.pwd) == 0 ? file[Dir.pwd.length+1...file.length] : file }
27-
Dir.glob(File.join(__dir__, 'node_modules/**/*')).map(&strip_dir).each do |filename|
28-
next if File.directory?(filename) || filename.length > 100
29-
spec.files << filename
30-
end
31-
3226
spec.extensions << "ext/appmap/extconf.rb"
3327
spec.require_paths = ['lib']
3428

lib/appmap/command/index.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def index(arguments)
1616

1717
arguments.unshift 'index'
1818
arguments.unshift APPMAP_JS
19-
arguments.unshift 'node'
19+
arguments.unshift 'npx'
2020

2121
exec(*arguments)
2222
end

lib/appmap/command/inspect.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def inspect(arguments)
1616

1717
arguments.unshift 'inspect'
1818
arguments.unshift APPMAP_JS
19-
arguments.unshift 'node'
19+
arguments.unshift 'npx'
2020

2121
exec(*arguments)
2222
end

lib/appmap/node_cli.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
module AppMap
77
# Utilities for invoking the +@appland/appmap+ CLI.
88
class NodeCLI
9-
APPMAP_JS = Pathname.new(__dir__).join('../../node_modules/@appland/appmap/src/cli.js').expand_path.to_s
9+
APPMAP_JS = '@appland/appmap'
1010

1111
attr_reader :verbose
1212
# Directory to scan for AppMaps.
@@ -32,7 +32,7 @@ def index_appmaps
3232
def command(command, options = {})
3333
command.unshift << '--verbose' if verbose
3434
command.unshift APPMAP_JS
35-
command.unshift 'node'
35+
command.unshift 'npx'
3636

3737
warn command.join(' ') if verbose
3838
stdout, stderr, status = Open3.capture3({ 'NODE_OPTIONS' => '--trace-warnings' }, *command.map(&:shellescape), options)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
},
1818
"homepage": "https://github.com/applandinc/appmap-ruby#readme",
1919
"dependencies": {
20-
"@appland/appmap": "^3.0.0"
20+
"@appland/appmap": "^3.18.3"
2121
}
2222
}

release.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ else
1313
fi
1414

1515
set -ex
16-
yarn install --prod
1716
exec semantic-release $RELEASE_FLAGS

spec/fixtures/rails6_users_app/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@ RUN curl -fsSL https://fnm.vercel.app/install | bash \
1313
&& source /root/.bashrc \
1414
&& fnm install --lts \
1515
&& echo 'fnm default $(fnm current)' >> ~/.bashrc \
16-
&& ln -s $(which node) /usr/local/bin/node
16+
&& ln -s $(which node) /usr/local/bin/ \
17+
&& ln -s $(which npx) /usr/local/bin/ \
18+
&& npm install -g yarn \
19+
&& ln -s $(which yarn) /usr/local/bin/
1720

1821
RUN mkdir /app
1922
WORKDIR /app
2023

2124
RUN gem install -N bundler
2225

26+
COPY package.json .
27+
28+
RUN yarn install
29+
2330
COPY Gemfile .
2431

2532
RUN bundle
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "rails6_users_app",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"devDependencies": {
6+
"@appland/appmap": "^3.18.3"
7+
}
8+
}

0 commit comments

Comments
 (0)