shakapacker 6.6.0 → 7.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +4 -8
- data/.github/workflows/dummy.yml +21 -0
- data/.github/workflows/generator.yml +37 -0
- data/.github/workflows/jest.yml +2 -2
- data/.github/workflows/js-lint.yml +2 -2
- data/.github/workflows/rubocop.yml +1 -1
- data/.github/workflows/ruby-backward-compatibility.yml +39 -0
- data/.github/workflows/ruby.yml +2 -6
- data/.gitignore +3 -0
- data/CHANGELOG.md +48 -4
- data/CONTRIBUTING.md +78 -22
- data/Gemfile.development_dependencies +1 -1
- data/README.md +115 -88
- data/Rakefile +46 -5
- data/config/shakapacker.yml +1 -0
- data/docs/deployment.md +11 -10
- data/docs/{developing_webpacker.md → developing_shakapacker.md} +5 -5
- data/docs/react.md +10 -6
- data/docs/style_loader_vs_mini_css.md +2 -2
- data/docs/troubleshooting.md +22 -18
- data/docs/using_esbuild_loader.md +5 -3
- data/docs/using_swc_loader.md +2 -2
- data/docs/v6_upgrade.md +2 -2
- data/docs/v7_upgrade.md +56 -0
- data/lib/install/bin/shakapacker +13 -0
- data/lib/install/bin/shakapacker-dev-server +13 -0
- data/lib/install/binstubs.rb +3 -1
- data/lib/install/config/{webpacker.yml → shakapacker.yml} +13 -8
- data/lib/install/config/webpack/webpack.config.js +3 -2
- data/lib/install/template.rb +30 -18
- data/lib/{webpacker → shakapacker}/base_strategy.rb +2 -2
- data/lib/{webpacker → shakapacker}/commands.rb +4 -4
- data/lib/{webpacker → shakapacker}/compiler.rb +43 -15
- data/lib/{webpacker → shakapacker}/compiler_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/configuration.rb +52 -21
- data/lib/shakapacker/deprecation_helper.rb +87 -0
- data/lib/{webpacker → shakapacker}/dev_server.rb +27 -4
- data/lib/{webpacker → shakapacker}/dev_server_proxy.rb +4 -4
- data/lib/shakapacker/dev_server_runner.rb +104 -0
- data/lib/{webpacker → shakapacker}/digest_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/env.rb +8 -8
- data/lib/{webpacker → shakapacker}/helper.rb +20 -20
- data/lib/{webpacker → shakapacker}/instance.rb +13 -10
- data/lib/{webpacker → shakapacker}/manifest.rb +14 -14
- data/lib/{webpacker → shakapacker}/mtime_strategy.rb +5 -5
- data/lib/shakapacker/railtie.rb +70 -0
- data/lib/shakapacker/runner.rb +28 -0
- data/lib/shakapacker/utils/version_syntax_converter.rb +2 -2
- data/lib/{webpacker → shakapacker}/version.rb +2 -2
- data/lib/{webpacker → shakapacker}/version_checker.rb +8 -8
- data/lib/shakapacker/webpack_runner.rb +67 -0
- data/lib/shakapacker.rb +51 -1
- data/lib/tasks/shakapacker/binstubs.rake +15 -0
- data/lib/tasks/shakapacker/check_binstubs.rake +29 -0
- data/lib/tasks/shakapacker/check_node.rake +31 -0
- data/lib/tasks/shakapacker/check_yarn.rake +33 -0
- data/lib/tasks/shakapacker/clean.rake +23 -0
- data/lib/tasks/shakapacker/clobber.rake +18 -0
- data/lib/tasks/shakapacker/compile.rake +26 -0
- data/lib/tasks/shakapacker/info.rake +21 -0
- data/lib/tasks/shakapacker/install.rake +17 -0
- data/lib/tasks/shakapacker/verify_config.rake +12 -0
- data/lib/tasks/shakapacker/verify_install.rake +4 -0
- data/lib/tasks/shakapacker/yarn_install.rake +24 -0
- data/lib/tasks/shakapacker.rake +18 -0
- data/lib/tasks/webpacker/binstubs.rake +5 -11
- data/lib/tasks/webpacker/check_binstubs.rake +6 -9
- data/lib/tasks/webpacker/check_node.rake +5 -27
- data/lib/tasks/webpacker/check_yarn.rake +5 -29
- data/lib/tasks/webpacker/clean.rake +5 -19
- data/lib/tasks/webpacker/clobber.rake +6 -13
- data/lib/tasks/webpacker/compile.rake +5 -33
- data/lib/tasks/webpacker/info.rake +5 -17
- data/lib/tasks/webpacker/install.rake +5 -13
- data/lib/tasks/webpacker/verify_config.rake +6 -11
- data/lib/tasks/webpacker/verify_install.rake +7 -2
- data/lib/tasks/webpacker/yarn_install.rake +5 -20
- data/lib/tasks/webpacker.rake +15 -13
- data/lib/webpacker/dev_server_runner.rb +9 -96
- data/lib/webpacker/webpack_runner.rb +9 -58
- data/lib/webpacker.rb +3 -47
- data/package/__tests__/config-bc.js +27 -0
- data/package/__tests__/config.js +6 -5
- data/package/__tests__/dev_server-bc.js +46 -0
- data/package/__tests__/dev_server.js +9 -8
- data/package/__tests__/development-bc.js +66 -0
- data/package/__tests__/development.js +36 -5
- data/package/__tests__/env-bc.js +59 -0
- data/package/__tests__/env.js +3 -2
- data/package/__tests__/index.js +13 -0
- data/package/__tests__/production-bc.js +51 -0
- data/package/__tests__/production.js +25 -3
- data/package/__tests__/staging-bc.js +53 -0
- data/package/__tests__/staging.js +27 -4
- data/package/__tests__/test-bc.js +43 -0
- data/package/__tests__/test.js +22 -4
- data/package/babel/preset.js +1 -4
- data/package/config.js +25 -7
- data/package/dev_server.js +7 -4
- data/package/env.js +22 -3
- data/package/environments/__tests__/base-bc.js +107 -0
- data/package/environments/__tests__/base.js +13 -13
- data/package/environments/base.js +1 -1
- data/package/environments/development.js +4 -46
- data/package/environments/production.js +1 -1
- data/package/index.js +27 -4
- data/package/rules/__tests__/__utils__/webpack.js +1 -1
- data/package/rules/__tests__/file.js +27 -0
- data/package/rules/__tests__/swc.js +1 -2
- data/package/rules/file.js +2 -2
- data/package/utils/configPath.js +19 -0
- data/package/utils/defaultConfigPath.js +2 -0
- data/package/utils/get_style_rule.js +5 -2
- data/package/utils/helpers.js +25 -2
- data/package/utils/inliningCss.js +7 -0
- data/package/utils/snakeToCamelCase +7 -0
- data/package/webpackDevServerConfig.js +68 -0
- data/package.json +2 -2
- data/{webpacker.gemspec → shakapacker.gemspec} +3 -3
- data/spec/{command_spec.rb → backward_compatibility_specs/command_spec.rb} +2 -0
- data/spec/{compiler_spec.rb → backward_compatibility_specs/compiler_spec.rb} +6 -4
- data/spec/{compiler_strategy_spec.rb → backward_compatibility_specs/compiler_strategy_spec.rb} +2 -0
- data/spec/{configuration_spec.rb → backward_compatibility_specs/configuration_spec.rb} +25 -20
- data/spec/{dev_server_runner_spec.rb → backward_compatibility_specs/dev_server_runner_spec.rb} +10 -2
- data/spec/{dev_server_spec.rb → backward_compatibility_specs/dev_server_spec.rb} +4 -2
- data/spec/{digest_strategy_spec.rb → backward_compatibility_specs/digest_strategy_spec.rb} +2 -0
- data/spec/{engine_rake_tasks_spec.rb → backward_compatibility_specs/engine_rake_tasks_spec.rb} +12 -15
- data/spec/{env_spec.rb → backward_compatibility_specs/env_spec.rb} +3 -1
- data/spec/{helper_spec.rb → backward_compatibility_specs/helper_spec.rb} +2 -0
- data/spec/backward_compatibility_specs/instance_spec.rb +31 -0
- data/spec/{manifest_spec.rb → backward_compatibility_specs/manifest_spec.rb} +4 -2
- data/spec/{mtime_strategy_spec.rb → backward_compatibility_specs/mtime_strategy_spec.rb} +2 -0
- data/spec/backward_compatibility_specs/rake_tasks_spec.rb +37 -0
- data/spec/backward_compatibility_specs/spec_helper_initializer.rb +24 -0
- data/spec/{webpack_runner_spec.rb → backward_compatibility_specs/webpack_runner_spec.rb} +3 -1
- data/spec/{webpacker_spec.rb → backward_compatibility_specs/webpacker_spec.rb} +3 -23
- data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +2 -0
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/application.js +1 -1
- data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/application.rb +11 -0
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_css_extract_ignore_order_warnings.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_defaults_fallback.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_no_precompile.yml +7 -0
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_other_location.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_public_root.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/package.json +13 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/tmp/shakapacker/last-compilation-digest-production +1 -0
- data/spec/dummy/.browserslistrc +1 -0
- data/spec/dummy/.gitignore +20 -0
- data/spec/dummy/.prettierrc.yaml +4 -0
- data/spec/dummy/Gemfile +63 -0
- data/spec/dummy/Procfile.dev +5 -0
- data/spec/dummy/Procfile.dev-static +9 -0
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/hello_world_controller.rb +9 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/Globals.d.ts +3 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +25 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.tsx +47 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorldServer.tsx +5 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/logo.svg +7 -0
- data/spec/dummy/app/javascript/packs/application.js +17 -0
- data/spec/dummy/app/javascript/packs/hello-world-bundle.ts +8 -0
- data/spec/dummy/app/javascript/packs/server-bundle.ts +8 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/hello_world/index.html.erb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/hello_world.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/babel.config.js +30 -0
- data/spec/dummy/bin/bundle +114 -0
- data/spec/dummy/bin/dev +30 -0
- data/spec/dummy/bin/dev-static +30 -0
- data/spec/dummy/bin/rails +9 -0
- data/spec/dummy/bin/rake +9 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/bin/shakapacker +13 -0
- data/spec/dummy/bin/shakapacker-dev-server +13 -0
- data/spec/dummy/bin/spring +17 -0
- data/spec/dummy/bin/yarn +18 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/credentials.yml.enc +1 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +106 -0
- data/spec/dummy/config/environments/test.rb +49 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/react_on_rails.rb +58 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +38 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/config/shakapacker.yml +62 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config/webpack/ServerClientOrBoth.js +34 -0
- data/spec/dummy/config/webpack/clientWebpackConfig.js +15 -0
- data/spec/dummy/config/webpack/commonWebpackConfig.js +18 -0
- data/spec/dummy/config/webpack/development.js +32 -0
- data/spec/dummy/config/webpack/production.js +9 -0
- data/spec/dummy/config/webpack/serverWebpackConfig.js +116 -0
- data/spec/dummy/config/webpack/test.js +7 -0
- data/spec/dummy/config/webpack/webpack.config.js +24 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/package.json +44 -0
- data/spec/dummy/postcss.config.js +12 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +1 -0
- data/spec/dummy/spec/rails_helper.rb +118 -0
- data/spec/dummy/spec/spec_helper.rb +96 -0
- data/spec/dummy/spec/system/hello_world_spec.rb +19 -0
- data/spec/dummy/tsconfig.json +21 -0
- data/spec/dummy/vendor/.keep +0 -0
- data/spec/dummy/yarn.lock +4697 -0
- data/spec/generator_specs/e2e_template/files/app/controllers/home_controller.rb +4 -0
- data/spec/generator_specs/e2e_template/files/app/javascript/components/App.js +12 -0
- data/spec/generator_specs/e2e_template/files/app/javascript/packs/application.js +10 -0
- data/spec/generator_specs/e2e_template/files/app/views/home/index.html.erb +2 -0
- data/spec/generator_specs/e2e_template/files/app/views/layouts/application.html.erb +17 -0
- data/spec/generator_specs/e2e_template/files/config/routes.rb +3 -0
- data/spec/generator_specs/e2e_template/files/spec/system/test_react_component_renders_spec.rb +13 -0
- data/spec/generator_specs/e2e_template/template.rb +21 -0
- data/spec/generator_specs/generator_spec.rb +169 -0
- data/spec/mounted_app/test/dummy/config/application.rb +1 -1
- data/spec/mounted_app/test/dummy/config/webpacker.yml +3 -3
- data/spec/shakapacker/command_spec.rb +116 -0
- data/spec/shakapacker/compiler_spec.rb +59 -0
- data/spec/shakapacker/compiler_strategy_spec.rb +22 -0
- data/spec/shakapacker/configuration_spec.rb +323 -0
- data/spec/shakapacker/dev_server_runner_spec.rb +72 -0
- data/spec/shakapacker/dev_server_spec.rb +133 -0
- data/spec/shakapacker/digest_strategy_spec.rb +35 -0
- data/spec/shakapacker/engine_rake_tasks_spec.rb +43 -0
- data/spec/shakapacker/env_spec.rb +23 -0
- data/spec/shakapacker/helper_spec.rb +243 -0
- data/spec/shakapacker/instance_spec.rb +31 -0
- data/spec/shakapacker/manifest_spec.rb +100 -0
- data/spec/shakapacker/mtime_strategy_spec.rb +55 -0
- data/spec/shakapacker/rake_tasks_spec.rb +93 -0
- data/spec/shakapacker/shakapacker_spec.rb +41 -0
- data/spec/shakapacker/spec_helper_initializer.rb +24 -0
- data/spec/shakapacker/test_app/.gitignore +2 -0
- data/spec/shakapacker/test_app/Rakefile +3 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/application.js +10 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/generated/something.js +2 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.css +4 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.js +4 -0
- data/spec/{test_app/bin/webpacker-dev-server → shakapacker/test_app/bin/shakapacker} +3 -3
- data/spec/{test_app/bin/webpacker → shakapacker/test_app/bin/shakapacker-dev-server} +3 -3
- data/spec/{test_app → shakapacker/test_app}/config/application.rb +1 -1
- data/spec/shakapacker/test_app/config/environment.rb +4 -0
- data/spec/shakapacker/test_app/config/initializers/inspect_autoload_paths.rb +1 -0
- data/spec/shakapacker/test_app/config/shakapacker.yml +82 -0
- data/spec/shakapacker/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +84 -0
- data/spec/shakapacker/test_app/config/shakapacker_defaults_fallback.yml +11 -0
- data/spec/shakapacker/test_app/config/shakapacker_manifest_path.yml +80 -0
- data/spec/shakapacker/test_app/config/shakapacker_nested_entries.yml +83 -0
- data/spec/shakapacker/test_app/config/shakapacker_no_precompile.yml +7 -0
- data/spec/shakapacker/test_app/config/shakapacker_other_location.yml +85 -0
- data/spec/shakapacker/test_app/config/shakapacker_public_root.yml +18 -0
- data/spec/shakapacker/test_app/config/webpack/webpack.config.js +0 -0
- data/spec/shakapacker/test_app/config.ru +5 -0
- data/spec/shakapacker/test_app/public/packs/manifest.json +58 -0
- data/spec/shakapacker/test_app/some.config.js +0 -0
- data/spec/shakapacker/test_app/yarn.lock +11 -0
- data/spec/{version_checker_spec.rb → shakapacker/version_checker_spec.rb} +25 -24
- data/spec/shakapacker/webpack_runner_spec.rb +55 -0
- data/spec/spec_helper.rb +0 -25
- metadata +253 -72
- data/config/webpacker.yml +0 -1
- data/gemfiles/Gemfile-rails.5.2.x +0 -9
- data/lib/webpacker/railtie.rb +0 -70
- data/lib/webpacker/runner.rb +0 -23
- data/package/configPath.js +0 -3
- data/package/inliningCss.js +0 -7
- data/spec/rake_tasks_spec.rb +0 -32
- data/spec/test_app/config/webpacker_no_precompile.yml +0 -7
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/Rakefile +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/generated/something.js +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.css +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.js +0 -0
- /data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker-dev-server +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/environment.rb +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/initializers/inspect_autoload_paths.rb +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpack/webpack.config.js +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_manifest_path.yml +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_nested_entries.yml +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config.ru +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/public/packs/manifest.json +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/some.config.js +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/yarn.lock +0 -0
- /data/spec/{test_app → shakapacker/test_app}/package.json +0 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require "semantic_range"
|
2
|
+
namespace :shakapacker do
|
3
|
+
desc "Verifies if Yarn is installed"
|
4
|
+
task :check_yarn do
|
5
|
+
begin
|
6
|
+
which_command = Gem.win_platform? ? "where" : "which"
|
7
|
+
raise Errno::ENOENT if `#{which_command} yarn`.strip.empty?
|
8
|
+
|
9
|
+
yarn_version = `yarn --version`.strip
|
10
|
+
raise Errno::ENOENT if yarn_version.blank?
|
11
|
+
|
12
|
+
pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
|
13
|
+
yarn_range = JSON.parse(pkg_path.read)["engines"]["yarn"]
|
14
|
+
is_valid = SemanticRange.satisfies?(yarn_version, yarn_range) rescue false
|
15
|
+
is_unsupported = SemanticRange.satisfies?(yarn_version, ">=4.0.0") rescue false
|
16
|
+
|
17
|
+
unless is_valid
|
18
|
+
$stderr.puts "Shakapacker requires Yarn \"#{yarn_range}\" and you are using #{yarn_version}"
|
19
|
+
if is_unsupported
|
20
|
+
$stderr.puts "This version of Shakapacker does not support Yarn #{yarn_version}. Please downgrade to a supported version of Yarn https://yarnpkg.com/lang/en/docs/install/"
|
21
|
+
else
|
22
|
+
$stderr.puts "Please upgrade Yarn https://yarnpkg.com/lang/en/docs/install/"
|
23
|
+
end
|
24
|
+
$stderr.puts "Exiting!"
|
25
|
+
exit!
|
26
|
+
end
|
27
|
+
rescue Errno::ENOENT
|
28
|
+
$stderr.puts "Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/"
|
29
|
+
$stderr.puts "Exiting!"
|
30
|
+
exit!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$stdout.sync = true
|
2
|
+
|
3
|
+
require "shakapacker/configuration"
|
4
|
+
|
5
|
+
namespace :shakapacker do
|
6
|
+
desc "Remove old compiled bundles"
|
7
|
+
task :clean, [:keep, :age] => ["shakapacker:verify_install", :environment] do |_, args|
|
8
|
+
Shakapacker.ensure_log_goes_to_stdout do
|
9
|
+
Shakapacker.clean(Integer(args.keep || 2), Integer(args.age || 3600))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if Shakapacker.config.shakapacker_precompile?
|
15
|
+
# Run clean if the assets:clean is run
|
16
|
+
if Rake::Task.task_defined?("assets:clean")
|
17
|
+
Rake::Task["assets:clean"].enhance do
|
18
|
+
Rake::Task["shakapacker:clean"].invoke
|
19
|
+
end
|
20
|
+
else
|
21
|
+
Rake::Task.define_task("assets:clean" => "shakapacker:clean")
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "shakapacker/configuration"
|
2
|
+
|
3
|
+
namespace :shakapacker do
|
4
|
+
desc "Remove the webpack compiled output directory"
|
5
|
+
task clobber: ["shakapacker:verify_config", :environment] do
|
6
|
+
Shakapacker.clobber
|
7
|
+
$stdout.puts "Removed webpack output path directory #{Shakapacker.config.public_output_path}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
if Shakapacker.config.shakapacker_precompile?
|
12
|
+
# Run clobber if the assets:clobber is run
|
13
|
+
if Rake::Task.task_defined?("assets:clobber")
|
14
|
+
Rake::Task["assets:clobber"].enhance do
|
15
|
+
Rake::Task["shakapacker:clobber"].invoke
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
$stdout.sync = true
|
2
|
+
|
3
|
+
namespace :shakapacker do
|
4
|
+
desc "Compile JavaScript packs using webpack for production with digests"
|
5
|
+
task compile: ["shakapacker:verify_install", :environment] do
|
6
|
+
Shakapacker.with_node_env(ENV.fetch("NODE_ENV", "production")) do
|
7
|
+
Shakapacker.ensure_log_goes_to_stdout do
|
8
|
+
exit! unless Shakapacker.compile
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def invoke_shakapacker_compile_in_assets_precompile_task
|
15
|
+
Rake::Task["assets:precompile"].enhance do |task|
|
16
|
+
prefix = task.name.split(/#|assets:precompile/).first
|
17
|
+
|
18
|
+
Rake::Task["#{prefix}shakapacker:compile"].invoke
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if Shakapacker.config.shakapacker_precompile?
|
23
|
+
if Rake::Task.task_defined?("assets:precompile")
|
24
|
+
invoke_shakapacker_compile_in_assets_precompile_task
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "shakapacker/version"
|
2
|
+
|
3
|
+
namespace :shakapacker do
|
4
|
+
desc "Provide information on Shakapacker's environment"
|
5
|
+
task :info do
|
6
|
+
Dir.chdir(Rails.root) do
|
7
|
+
$stdout.puts "Ruby: #{`ruby --version`}"
|
8
|
+
$stdout.puts "Rails: #{Rails.version}"
|
9
|
+
$stdout.puts "Shakapacker: #{Shakapacker::VERSION}"
|
10
|
+
$stdout.puts "Node: #{`node --version`}"
|
11
|
+
$stdout.puts "Yarn: #{`yarn --version`}"
|
12
|
+
|
13
|
+
$stdout.puts "\n"
|
14
|
+
$stdout.puts "shakapacker: \n#{`npm list shakapacker version`}"
|
15
|
+
|
16
|
+
$stdout.puts "Is bin/shakapacker present?: #{File.exist? 'bin/shakapacker'}"
|
17
|
+
$stdout.puts "Is bin/shakapacker-dev-server present?: #{File.exist? 'bin/shakapacker-dev-server'}"
|
18
|
+
$stdout.puts "Is bin/yarn present?: #{File.exist? 'bin/yarn'}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
install_template_path = File.expand_path("../../install/template.rb", __dir__).freeze
|
2
|
+
bin_path = ENV["BUNDLE_BIN"] || Rails.root.join("bin")
|
3
|
+
|
4
|
+
namespace :shakapacker do
|
5
|
+
desc "Install Shakapacker in this application"
|
6
|
+
task install: [:check_node, :check_yarn] do |task|
|
7
|
+
Shakapacker::Configuration.installing = true
|
8
|
+
|
9
|
+
prefix = task.name.split(/#|shakapacker:install/).first
|
10
|
+
|
11
|
+
if Rails::VERSION::MAJOR >= 5
|
12
|
+
exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION='#{install_template_path}'"
|
13
|
+
else
|
14
|
+
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{install_template_path}'"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace :shakapacker do
|
2
|
+
desc "Verifies if the Shakapacker config is present"
|
3
|
+
task :verify_config do
|
4
|
+
unless Shakapacker.config.config_path.exist?
|
5
|
+
path = Shakapacker.config.config_path.relative_path_from(Pathname.new(pwd)).to_s
|
6
|
+
$stderr.puts "Configuration #{path} file not found. \n"\
|
7
|
+
"Make sure shakapacker:install is run successfully before " \
|
8
|
+
"running dependent tasks"
|
9
|
+
exit!
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
namespace :shakapacker do
|
2
|
+
desc "Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"
|
3
|
+
task :yarn_install do
|
4
|
+
warn <<~MSG.strip
|
5
|
+
Shakapacker - Automatic installation of yarn packages is deprecated
|
6
|
+
Automatic installation of yarn packages when assets are precompiled is deprecated and will be removed in Shakapacker v7.
|
7
|
+
Please ensure you are installing yarn packages explicitly before the asset compilation.
|
8
|
+
MSG
|
9
|
+
|
10
|
+
valid_node_envs = %w[test development production]
|
11
|
+
node_env = ENV.fetch("NODE_ENV") do
|
12
|
+
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
|
13
|
+
end
|
14
|
+
Dir.chdir(Rails.root) do
|
15
|
+
yarn_flags =
|
16
|
+
if `yarn --version`.start_with?("1")
|
17
|
+
"--no-progress --frozen-lockfile"
|
18
|
+
else
|
19
|
+
"--immutable"
|
20
|
+
end
|
21
|
+
system({ "NODE_ENV" => node_env }, "yarn install #{yarn_flags}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
tasks = {
|
2
|
+
"shakapacker:info" => "Provides information on Shakapacker's environment",
|
3
|
+
"shakapacker:install" => "Installs and setup webpack with Yarn",
|
4
|
+
"shakapacker:compile" => "Compiles webpack bundles based on environment",
|
5
|
+
"shakapacker:clean" => "Remove old compiled bundles",
|
6
|
+
"shakapacker:clobber" => "Removes the webpack compiled output directory",
|
7
|
+
"shakapacker:check_node" => "Verifies if Node.js is installed",
|
8
|
+
"shakapacker:check_yarn" => "Verifies if Yarn is installed",
|
9
|
+
"shakapacker:check_binstubs" => "Verifies that bin/shakapacker is present",
|
10
|
+
"shakapacker:binstubs" => "Installs Shakapacker binstubs in this application",
|
11
|
+
"shakapacker:verify_install" => "Verifies if Shakapacker is installed",
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
desc "Lists all available tasks in Shakapacker"
|
15
|
+
task :shakapacker do
|
16
|
+
puts "Available Shakapacker tasks are:"
|
17
|
+
tasks.each { |task, message| puts task.ljust(30) + message }
|
18
|
+
end
|
@@ -1,15 +1,9 @@
|
|
1
|
-
binstubs_template_path = File.expand_path("../../install/binstubs.rb", __dir__).freeze
|
2
|
-
bin_path = ENV["BUNDLE_BIN"] || Rails.root.join("bin")
|
3
|
-
|
4
1
|
namespace :webpacker do
|
5
|
-
desc "Installs
|
6
|
-
task binstubs
|
7
|
-
|
2
|
+
desc "DEPRECATED - Installs Shakapacker binstubs in this application"
|
3
|
+
task :binstubs do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
else
|
12
|
-
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{binstubs_template_path}'"
|
13
|
-
end
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:binstubs"].invoke
|
14
8
|
end
|
15
9
|
end
|
@@ -1,12 +1,9 @@
|
|
1
1
|
namespace :webpacker do
|
2
|
-
desc "Verifies that bin/
|
3
|
-
task :check_binstubs do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
"Exiting!"
|
9
|
-
exit!
|
10
|
-
end
|
2
|
+
desc "DEPRECATED - Verifies that bin/shakapacker is present"
|
3
|
+
task :check_binstubs do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
5
|
+
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:check_binstubs"].invoke
|
11
8
|
end
|
12
9
|
end
|
@@ -1,31 +1,9 @@
|
|
1
|
-
require "semantic_range"
|
2
1
|
namespace :webpacker do
|
3
|
-
desc "Verifies if Node.js is installed"
|
4
|
-
task :check_node do
|
5
|
-
|
6
|
-
node_version = `node -v || nodejs -v`.strip
|
7
|
-
raise Errno::ENOENT if node_version.blank?
|
2
|
+
desc "DEPRECATED - Verifies if Node.js is installed"
|
3
|
+
task :check_node do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
is_valid = SemanticRange.satisfies?(node_version, node_range) rescue false
|
12
|
-
semver_major = node_version[/\d+/] rescue nil
|
13
|
-
is_unstable = semver_major.to_i.odd? rescue false
|
14
|
-
|
15
|
-
if is_unstable
|
16
|
-
$stderr.puts "Warning: you are using an unstable release of Node.js (#{node_version}). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node"
|
17
|
-
end
|
18
|
-
|
19
|
-
unless is_valid
|
20
|
-
$stderr.puts "Webpacker requires Node.js \"#{node_range}\" and you are using #{node_version}"
|
21
|
-
$stderr.puts "Please upgrade Node.js https://nodejs.org/en/download/"
|
22
|
-
$stderr.puts "Exiting!"
|
23
|
-
exit!
|
24
|
-
end
|
25
|
-
rescue Errno::ENOENT
|
26
|
-
$stderr.puts "Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/"
|
27
|
-
$stderr.puts "Exiting!"
|
28
|
-
exit!
|
29
|
-
end
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:check_node"].invoke
|
30
8
|
end
|
31
9
|
end
|
@@ -1,33 +1,9 @@
|
|
1
|
-
require "semantic_range"
|
2
1
|
namespace :webpacker do
|
3
|
-
desc "Verifies if Yarn is installed"
|
4
|
-
task :check_yarn do
|
5
|
-
|
6
|
-
which_command = Gem.win_platform? ? "where" : "which"
|
7
|
-
raise Errno::ENOENT if `#{which_command} yarn`.strip.empty?
|
2
|
+
desc "DEPRECATED - Verifies if Yarn is installed"
|
3
|
+
task :check_yarn do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
|
13
|
-
yarn_range = JSON.parse(pkg_path.read)["engines"]["yarn"]
|
14
|
-
is_valid = SemanticRange.satisfies?(yarn_version, yarn_range) rescue false
|
15
|
-
is_unsupported = SemanticRange.satisfies?(yarn_version, ">=4.0.0") rescue false
|
16
|
-
|
17
|
-
unless is_valid
|
18
|
-
$stderr.puts "Webpacker requires Yarn \"#{yarn_range}\" and you are using #{yarn_version}"
|
19
|
-
if is_unsupported
|
20
|
-
$stderr.puts "This version of Webpacker does not support Yarn #{yarn_version}. Please downgrade to a supported version of Yarn https://yarnpkg.com/lang/en/docs/install/"
|
21
|
-
else
|
22
|
-
$stderr.puts "Please upgrade Yarn https://yarnpkg.com/lang/en/docs/install/"
|
23
|
-
end
|
24
|
-
$stderr.puts "Exiting!"
|
25
|
-
exit!
|
26
|
-
end
|
27
|
-
rescue Errno::ENOENT
|
28
|
-
$stderr.puts "Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/"
|
29
|
-
$stderr.puts "Exiting!"
|
30
|
-
exit!
|
31
|
-
end
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:check_yarn"].invoke
|
32
8
|
end
|
33
9
|
end
|
@@ -1,23 +1,9 @@
|
|
1
|
-
$stdout.sync = true
|
2
|
-
|
3
|
-
require "webpacker/configuration"
|
4
|
-
|
5
1
|
namespace :webpacker do
|
6
|
-
desc "Remove old compiled
|
7
|
-
task :clean, [:keep, :age]
|
8
|
-
|
9
|
-
Webpacker.clean(Integer(args.keep || 2), Integer(args.age || 3600))
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
2
|
+
desc "DEPRECATED - Remove old compiled bundles"
|
3
|
+
task :clean, [:keep, :age] do |task, args|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
13
5
|
|
14
|
-
|
15
|
-
|
16
|
-
if Rake::Task.task_defined?("assets:clean")
|
17
|
-
Rake::Task["assets:clean"].enhance do
|
18
|
-
Rake::Task["webpacker:clean"].invoke
|
19
|
-
end
|
20
|
-
else
|
21
|
-
Rake::Task.define_task("assets:clean" => "webpacker:clean")
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:clean"].invoke(args.keep, args.age)
|
22
8
|
end
|
23
9
|
end
|
@@ -1,18 +1,11 @@
|
|
1
|
-
require "
|
1
|
+
require "shakapacker/configuration"
|
2
2
|
|
3
3
|
namespace :webpacker do
|
4
|
-
desc "Remove the webpack compiled output directory"
|
5
|
-
task clobber
|
6
|
-
|
7
|
-
$stdout.puts "Removed webpack output path directory #{Webpacker.config.public_output_path}"
|
8
|
-
end
|
9
|
-
end
|
4
|
+
desc "DEPRECATED - Remove the webpack compiled output directory"
|
5
|
+
task :clobber do |task|
|
6
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
if Rake::Task.task_defined?("assets:clobber")
|
14
|
-
Rake::Task["assets:clobber"].enhance do
|
15
|
-
Rake::Task["webpacker:clobber"].invoke
|
16
|
-
end
|
8
|
+
prefix = task.name.split(/#|webpacker:/).first
|
9
|
+
Rake::Task["#{prefix}shakapacker:clobber"].invoke
|
17
10
|
end
|
18
11
|
end
|
@@ -1,37 +1,9 @@
|
|
1
|
-
$stdout.sync = true
|
2
|
-
|
3
|
-
def enhance_assets_precompile
|
4
|
-
Rake::Task["assets:precompile"].enhance do |task|
|
5
|
-
prefix = task.name.split(/#|assets:precompile/).first
|
6
|
-
|
7
|
-
Rake::Task["#{prefix}webpacker:compile"].invoke
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
1
|
namespace :webpacker do
|
12
|
-
desc "Compile JavaScript packs using webpack for production with digests"
|
13
|
-
task compile
|
14
|
-
|
15
|
-
Webpacker.ensure_log_goes_to_stdout do
|
16
|
-
if Webpacker.compile
|
17
|
-
# Successful compilation!
|
18
|
-
else
|
19
|
-
# Failed compilation
|
20
|
-
exit!
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
2
|
+
desc "DEPRECATED - Compile JavaScript packs using webpack for production with digests"
|
3
|
+
task :compile do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
26
5
|
|
27
|
-
|
28
|
-
|
29
|
-
# Rails already adds `yarn install` after 5.2
|
30
|
-
# https://github.com/shakacode/shakapacker/issues/237
|
31
|
-
enhance_assets_precompile
|
32
|
-
else
|
33
|
-
# Only add `yarn install` if Rails was not doing it (precompile was not defined).
|
34
|
-
# TODO: Remove this in Shakapacker 7.0
|
35
|
-
Rake::Task.define_task("assets:precompile" => ["webpacker:yarn_install", "webpacker:compile"])
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:compile"].invoke
|
36
8
|
end
|
37
9
|
end
|
@@ -1,21 +1,9 @@
|
|
1
|
-
require "webpacker/version"
|
2
|
-
|
3
1
|
namespace :webpacker do
|
4
|
-
desc "Provide information on
|
5
|
-
task :info do
|
6
|
-
|
7
|
-
$stdout.puts "Ruby: #{`ruby --version`}"
|
8
|
-
$stdout.puts "Rails: #{Rails.version}"
|
9
|
-
$stdout.puts "Webpacker: #{Webpacker::VERSION}"
|
10
|
-
$stdout.puts "Node: #{`node --version`}"
|
11
|
-
$stdout.puts "Yarn: #{`yarn --version`}"
|
12
|
-
|
13
|
-
$stdout.puts "\n"
|
14
|
-
$stdout.puts "shakapacker: \n#{`npm list shakapacker version`}"
|
2
|
+
desc "DEPRECATED - Provide information on Shakapacker's environment"
|
3
|
+
task :info do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
15
5
|
|
16
|
-
|
17
|
-
|
18
|
-
$stdout.puts "Is bin/yarn present?: #{File.exist? 'bin/yarn'}"
|
19
|
-
end
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:info"].invoke
|
20
8
|
end
|
21
9
|
end
|
@@ -1,17 +1,9 @@
|
|
1
|
-
install_template_path = File.expand_path("../../install/template.rb", __dir__).freeze
|
2
|
-
bin_path = ENV["BUNDLE_BIN"] || Rails.root.join("bin")
|
3
|
-
|
4
1
|
namespace :webpacker do
|
5
|
-
desc "Install
|
6
|
-
task install
|
7
|
-
|
8
|
-
|
9
|
-
prefix = task.name.split(/#|webpacker:install/).first
|
2
|
+
desc "DEPRECATED - Install Shakapacker in this application"
|
3
|
+
task :install do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
10
5
|
|
11
|
-
|
12
|
-
|
13
|
-
else
|
14
|
-
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{install_template_path}'"
|
15
|
-
end
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:install"].invoke
|
16
8
|
end
|
17
9
|
end
|
@@ -1,14 +1,9 @@
|
|
1
|
-
require "webpacker/configuration"
|
2
|
-
|
3
1
|
namespace :webpacker do
|
4
|
-
desc "Verifies if the
|
5
|
-
task :verify_config do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
"running dependent tasks"
|
11
|
-
exit!
|
12
|
-
end
|
2
|
+
desc "DEPRECATED - Verifies if the Shakapacker config is present"
|
3
|
+
task :verify_config do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
5
|
+
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:verify_config"].invoke
|
13
8
|
end
|
14
9
|
end
|
@@ -1,4 +1,9 @@
|
|
1
1
|
namespace :webpacker do
|
2
|
-
desc "Verifies if
|
3
|
-
task verify_install
|
2
|
+
desc "DEPRECATED - Verifies if Shakapacker is installed"
|
3
|
+
task :verify_install do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
5
|
+
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:verify_install"].invoke
|
8
|
+
end
|
4
9
|
end
|
@@ -1,24 +1,9 @@
|
|
1
1
|
namespace :webpacker do
|
2
|
-
desc "Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"
|
3
|
-
task :yarn_install do
|
4
|
-
|
5
|
-
Shakapacker - Automatic installation of yarn packages is deprecated
|
6
|
-
Automatic installation of yarn packages when assets are precompiled is deprecated and will be removed in Shakapacker v7.
|
7
|
-
Please ensure you are installing yarn packages explicitly before the asset compilation.
|
8
|
-
MSG
|
2
|
+
desc "DEPRECATED - Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"
|
3
|
+
task :yarn_install do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
|
13
|
-
end
|
14
|
-
Dir.chdir(Rails.root) do
|
15
|
-
yarn_flags =
|
16
|
-
if `yarn --version`.start_with?("1")
|
17
|
-
"--no-progress --frozen-lockfile"
|
18
|
-
else
|
19
|
-
"--immutable"
|
20
|
-
end
|
21
|
-
system({ "NODE_ENV" => node_env }, "yarn install #{yarn_flags}")
|
22
|
-
end
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:yarn_install"].invoke
|
23
8
|
end
|
24
9
|
end
|
data/lib/tasks/webpacker.rake
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
tasks = {
|
2
|
-
"webpacker:info" => "Provides information on
|
3
|
-
"webpacker:install" => "Installs and setup webpack with Yarn",
|
4
|
-
"webpacker:compile" => "Compiles webpack bundles based on environment",
|
5
|
-
"webpacker:clean" => "Remove old compiled
|
6
|
-
"webpacker:clobber" => "Removes the webpack compiled output directory",
|
7
|
-
"webpacker:check_node" => "Verifies if Node.js is installed",
|
8
|
-
"webpacker:check_yarn" => "Verifies if Yarn is installed",
|
9
|
-
"webpacker:check_binstubs" => "Verifies that bin/
|
10
|
-
"webpacker:binstubs" => "Installs
|
11
|
-
"webpacker:verify_install" => "Verifies if
|
2
|
+
"webpacker:info" => "DEPRECATED - Provides information on Shakapacker's environment",
|
3
|
+
"webpacker:install" => "DEPRECATED - Installs and setup webpack with Yarn",
|
4
|
+
"webpacker:compile" => "DEPRECATED - Compiles webpack bundles based on environment",
|
5
|
+
"webpacker:clean" => "DEPRECATED - Remove old compiled bundles",
|
6
|
+
"webpacker:clobber" => "DEPRECATED - Removes the webpack compiled output directory",
|
7
|
+
"webpacker:check_node" => "DEPRECATED - Verifies if Node.js is installed",
|
8
|
+
"webpacker:check_yarn" => "DEPRECATED - Verifies if Yarn is installed",
|
9
|
+
"webpacker:check_binstubs" => "DEPRECATED - Verifies that bin/shakapacker is present",
|
10
|
+
"webpacker:binstubs" => "DEPRECATED - Installs Shakapacker binstubs in this application",
|
11
|
+
"webpacker:verify_install" => "DEPRECATED - Verifies if Shakapacker is installed",
|
12
12
|
}.freeze
|
13
13
|
|
14
|
-
desc "Lists all available tasks in Webpacker"
|
15
|
-
task :webpacker do
|
16
|
-
puts "Available Webpacker tasks are:"
|
14
|
+
desc "DEPRECATED - Lists all available tasks in Webpacker"
|
15
|
+
task :webpacker do |task|
|
16
|
+
puts "DEPRECATED - Available Webpacker tasks are:"
|
17
17
|
tasks.each { |task, message| puts task.ljust(30) + message }
|
18
|
+
|
19
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
18
20
|
end
|