From 86b489e3d6a9efbefbc62e8531d0f5850934d4e1 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Wed, 9 Jan 2019 08:09:51 -0500 Subject: Move all npm packages to @rails scope Fixes #33083 --- RELEASING_RAILS.md | 15 ++++++++------- actioncable/README.md | 6 +++--- .../channel/templates/javascript/consumer.js.tt | 2 +- actioncable/package.json | 2 +- actiontext/app/javascript/actiontext/attachment_upload.js | 2 +- actiontext/lib/templates/installer.rb | 7 +++---- actiontext/package.json | 6 +++--- actiontext/test/dummy/app/javascript/packs/application.js | 2 +- actiontext/yarn.lock | 11 ----------- actionview/app/assets/javascripts/README.md | 10 +++++----- actionview/package.json | 2 +- activestorage/README.md | 2 +- activestorage/package.json | 2 +- guides/source/action_cable_overview.md | 2 +- guides/source/active_storage_overview.md | 6 +++--- package.json | 1 + .../app/templates/app/javascript/channels/consumer.js | 2 +- .../app/templates/app/javascript/packs/application.js.tt | 4 ++-- .../rails/generators/rails/app/templates/package.json.tt | 8 ++++---- railties/test/generators/shared_generator_tests.rb | 4 ++-- yarn.lock | 5 +++++ 21 files changed, 48 insertions(+), 53 deletions(-) delete mode 100644 actiontext/yarn.lock diff --git a/RELEASING_RAILS.md b/RELEASING_RAILS.md index 287dd4fa12..7fa180cc43 100644 --- a/RELEASING_RAILS.md +++ b/RELEASING_RAILS.md @@ -109,13 +109,14 @@ browser. This will stop you from looking silly when you push an RC to rubygems.org and then realize it is broken. -### Release to RubyGems and NPM. - -IMPORTANT: The Action Cable client and Action View's UJS adapter are released -as NPM packages, so you must have Node.js installed, have an NPM account -(npmjs.com), and be a package owner for `actioncable` and `rails-ujs` (you can -check this via `npm owner ls actioncable` and `npm owner ls rails-ujs`) in -order to do a full release. Do not release until you're set up with NPM! +### Release to RubyGems and npm. + +IMPORTANT: Several gems have JavaScript components that are released as npm +packages, so you must have Node.js installed, have an npm account (npmjs.com), +and be a package owner for `@rails/actioncable`, `@rails/actiontext`, +`@rails/activestorage`, and `@rails/ujs`. You can check this by making sure your +npm user (`npm whoami`) is listed as an owner (`npm owner ls `) of each +package. Do not release until you're set up with npm! The release task will sign the release tag. If you haven't got commit signing set up, use https://git-scm.com/book/tr/v2/Git-Tools-Signing-Your-Work as a diff --git a/actioncable/README.md b/actioncable/README.md index a2783d6f45..84cf817d74 100644 --- a/actioncable/README.md +++ b/actioncable/README.md @@ -504,7 +504,7 @@ WebSocket functionality. ### Installation ``` -npm install actioncable --save +npm install @rails/actioncable --save ``` ### Usage @@ -516,7 +516,7 @@ provided. In JavaScript... ```javascript -ActionCable = require('actioncable') +ActionCable = require('@rails/actioncable') var cable = ActionCable.createConsumer('wss://RAILS-API-PATH.com/cable') @@ -528,7 +528,7 @@ cable.subscriptions.create('AppearanceChannel', { and in CoffeeScript... ```coffeescript -ActionCable = require('actioncable') +ActionCable = require('@rails/actioncable') cable = ActionCable.createConsumer('wss://RAILS-API-PATH.com/cable') diff --git a/actioncable/lib/rails/generators/channel/templates/javascript/consumer.js.tt b/actioncable/lib/rails/generators/channel/templates/javascript/consumer.js.tt index 76ca3d0f2f..eec7e54b8a 100644 --- a/actioncable/lib/rails/generators/channel/templates/javascript/consumer.js.tt +++ b/actioncable/lib/rails/generators/channel/templates/javascript/consumer.js.tt @@ -1,6 +1,6 @@ // Action Cable provides the framework to deal with WebSockets in Rails. // You can generate new channels where WebSocket features live using the `rails generate channel` command. -import ActionCable from "actioncable" +import ActionCable from "@rails/actioncable" export default ActionCable.createConsumer() diff --git a/actioncable/package.json b/actioncable/package.json index db78c1a09a..69a97939fb 100644 --- a/actioncable/package.json +++ b/actioncable/package.json @@ -1,5 +1,5 @@ { - "name": "actioncable", + "name": "@rails/actioncable", "version": "6.0.0-alpha", "description": "WebSocket framework for Ruby on Rails.", "main": "app/assets/javascripts/action_cable.js", diff --git a/actiontext/app/javascript/actiontext/attachment_upload.js b/actiontext/app/javascript/actiontext/attachment_upload.js index a716f1f589..77fbc97df6 100644 --- a/actiontext/app/javascript/actiontext/attachment_upload.js +++ b/actiontext/app/javascript/actiontext/attachment_upload.js @@ -1,4 +1,4 @@ -import { DirectUpload } from "activestorage" +import { DirectUpload } from "@rails/activestorage" export class AttachmentUpload { constructor(attachment, element) { diff --git a/actiontext/lib/templates/installer.rb b/actiontext/lib/templates/installer.rb index dc549a8af3..e7c6c2623e 100644 --- a/actiontext/lib/templates/installer.rb +++ b/actiontext/lib/templates/installer.rb @@ -8,15 +8,14 @@ say "Copying blob rendering partial to app/views/active_storage/blobs/_blob.html copy_file "#{__dir__}/../../app/views/active_storage/blobs/_blob.html.erb", "app/views/active_storage/blobs/_blob.html.erb" -# FIXME: Replace with release version on release say "Installing JavaScript dependency" -run "yarn add https://github.com/rails/actiontext" +run "yarn add @rails/actiontext" APPLICATION_PACK_PATH = "app/javascript/packs/application.js" -if File.exist?(APPLICATION_PACK_PATH) && File.read(APPLICATION_PACK_PATH) !~ /import "actiontext"/ +if File.exist?(APPLICATION_PACK_PATH) && File.read(APPLICATION_PACK_PATH) !~ /import "@rails\/actiontext"/ say "Adding import to default JavaScript pack" append_to_file APPLICATION_PACK_PATH, <<-EOS -import "actiontext" +import "@rails/actiontext" EOS end diff --git a/actiontext/package.json b/actiontext/package.json index b42838b1df..ec8f35fd3c 100644 --- a/actiontext/package.json +++ b/actiontext/package.json @@ -1,5 +1,5 @@ { - "name": "actiontext", + "name": "@rails/actiontext", "version": "6.0.0-alpha", "description": "Edit and display rich text in Rails applications", "main": "app/javascript/actiontext/index.js", @@ -21,7 +21,7 @@ ], "license": "MIT", "dependencies": { - "trix": ">=1.0.0", - "activestorage": "6.0.0-alpha" + "trix": "^1.0.0", + "@rails/activestorage": "^6.0.0-alpha" } } diff --git a/actiontext/test/dummy/app/javascript/packs/application.js b/actiontext/test/dummy/app/javascript/packs/application.js index 90eb1a1841..13ac17ed58 100644 --- a/actiontext/test/dummy/app/javascript/packs/application.js +++ b/actiontext/test/dummy/app/javascript/packs/application.js @@ -1 +1 @@ -import "actiontext" +import "@rails/actiontext" diff --git a/actiontext/yarn.lock b/actiontext/yarn.lock deleted file mode 100644 index f98622eb64..0000000000 --- a/actiontext/yarn.lock +++ /dev/null @@ -1,11 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"activestorage@>= 5.2.0-rc1": - version "5.2.0-rc1" - resolved "https://registry.yarnpkg.com/activestorage/-/activestorage-5.2.0-rc1.tgz#79898996eceb0f13575eff41fb109051fbfa49b0" - -trix@^0.11.1: - version "0.11.1" - resolved "https://registry.yarnpkg.com/trix/-/trix-0.11.1.tgz#ffe54f2757c2c2385b8424fd5c5d2ab712a09acc" diff --git a/actionview/app/assets/javascripts/README.md b/actionview/app/assets/javascripts/README.md index b74fa1afad..2b110e604f 100644 --- a/actionview/app/assets/javascripts/README.md +++ b/actionview/app/assets/javascripts/README.md @@ -17,11 +17,11 @@ Note that the `data` attributes this library adds are a feature of HTML5. If you ### NPM - npm install rails-ujs --save - + npm install @rails/ujs --save + ### Yarn - - yarn add rails-ujs + + yarn add @rails/ujs Ensure that `.yarnclean` does not include `assets` if you use [yarn autoclean](https://yarnpkg.com/lang/en/docs/cli/autoclean/). @@ -40,7 +40,7 @@ In a conventional Rails application that uses the asset pipeline, require `rails If you're using the Webpacker gem or some other JavaScript bundler, add the following to your main JS file: ```javascript -import Rails from 'rails-ujs'; +import Rails from "@rails/ujs" Rails.start() ``` diff --git a/actionview/package.json b/actionview/package.json index 1f74df79d3..d6cf412c6d 100644 --- a/actionview/package.json +++ b/actionview/package.json @@ -1,5 +1,5 @@ { - "name": "rails-ujs", + "name": "@rails/ujs", "version": "6.0.0-alpha", "description": "Ruby on Rails unobtrusive scripting adapter", "main": "lib/assets/compiled/rails-ujs.js", diff --git a/activestorage/README.md b/activestorage/README.md index bd31f0ea58..4a683dd8cd 100644 --- a/activestorage/README.md +++ b/activestorage/README.md @@ -118,7 +118,7 @@ Active Storage, with its included JavaScript library, supports uploading directl ``` Using the npm package: ```js - import * as ActiveStorage from "activestorage" + import * as ActiveStorage from "@rails/activestorage" ActiveStorage.start() ``` 2. Annotate file inputs with the direct upload URL. diff --git a/activestorage/package.json b/activestorage/package.json index 00876985cf..37706efe37 100644 --- a/activestorage/package.json +++ b/activestorage/package.json @@ -1,5 +1,5 @@ { - "name": "activestorage", + "name": "@rails/activestorage", "version": "6.0.0-alpha", "description": "Attach cloud and local files in Rails applications", "main": "app/assets/javascripts/activestorage.js", diff --git a/guides/source/action_cable_overview.md b/guides/source/action_cable_overview.md index 7809607574..77a1b73bae 100644 --- a/guides/source/action_cable_overview.md +++ b/guides/source/action_cable_overview.md @@ -151,7 +151,7 @@ established using the following JavaScript, which is generated by default by Rai // Action Cable provides the framework to deal with WebSockets in Rails. // You can generate new channels where WebSocket features live using the `rails generate channel` command. -import ActionCable from "actioncable" +import ActionCable from "@rails/actioncable" export default ActionCable.createConsumer() ``` diff --git a/guides/source/active_storage_overview.md b/guides/source/active_storage_overview.md index 51f50e8931..6d07d34dd7 100644 --- a/guides/source/active_storage_overview.md +++ b/guides/source/active_storage_overview.md @@ -489,7 +489,7 @@ directly from the client to the cloud. Using the npm package: ```js - import * as ActiveStorage from "activestorage" + import * as ActiveStorage from "@rails/activestorage" ActiveStorage.start() ``` @@ -616,7 +616,7 @@ of choice, instantiate a DirectUpload and call its create method. Create takes a callback to invoke when the upload completes. ```js -import { DirectUpload } from "activestorage" +import { DirectUpload } from "@rails/activestorage" const input = document.querySelector('input[type=file]') @@ -664,7 +664,7 @@ will call the object's `directUploadWillStoreFileWithXHR` method. You can then bind your own progress handler on the XHR. ```js -import { DirectUpload } from "activestorage" +import { DirectUpload } from "@rails/activestorage" class Uploader { constructor(file, url) { diff --git a/package.json b/package.json index 88029de141..43055fa6bc 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "private": true, "workspaces": [ "actioncable", + "actiontext", "activestorage", "actionview", "tmp/templates/app_template", diff --git a/railties/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js b/railties/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js index 76ca3d0f2f..eec7e54b8a 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +++ b/railties/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js @@ -1,6 +1,6 @@ // Action Cable provides the framework to deal with WebSockets in Rails. // You can generate new channels where WebSocket features live using the `rails generate channel` command. -import ActionCable from "actioncable" +import ActionCable from "@rails/actioncable" export default ActionCable.createConsumer() diff --git a/railties/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt b/railties/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt index 4d7a145cd6..de91713546 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +++ b/railties/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt @@ -3,7 +3,7 @@ // a relevant structure within app/javascript and only use these pack files to reference // that code so it'll be compiled. -import Rails from "rails-ujs" +import Rails from "@rails/ujs" Rails.start() <%- unless options[:skip_turbolinks] -%> @@ -12,7 +12,7 @@ Turbolinks.start() <%- end -%> <%- unless skip_active_storage? -%> -import * as ActiveStorage from "activestorage" +import * as ActiveStorage from "@rails/activestorage" ActiveStorage.start() <%- end -%> <%- unless options[:skip_action_cable] -%> diff --git a/railties/lib/rails/generators/rails/app/templates/package.json.tt b/railties/lib/rails/generators/rails/app/templates/package.json.tt index 7174116989..07207e1747 100644 --- a/railties/lib/rails/generators/rails/app/templates/package.json.tt +++ b/railties/lib/rails/generators/rails/app/templates/package.json.tt @@ -2,10 +2,10 @@ "name": "<%= app_name %>", "private": true, "dependencies": { - "rails-ujs": ">=5.2.1"<% unless options[:skip_turbolinks] %>, - "turbolinks": "5.1.1"<% end -%><% unless skip_active_storage? %>, - "activestorage": ">=5.2.1"<% end -%><% unless options[:skip_action_cable] %>, - "actioncable": ">=5.2.1"<% end %> + "@rails/ujs": "^6.0.0-alpha"<% unless options[:skip_turbolinks] %>, + "turbolinks": "^5.2.0"<% end -%><% unless skip_active_storage? %>, + "@rails/activestorage": "^6.0.0-alpha"<% end -%><% unless options[:skip_action_cable] %>, + "@rails/actioncable": "^6.0.0-alpha"<% end %> }, "version": "0.1.0" } diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index 4dfcb35ad9..f673832caa 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -206,7 +206,7 @@ module SharedGeneratorTests unless generator_class.name == "Rails::Generators::PluginGenerator" assert_file "#{application_path}/app/javascript/packs/application.js" do |content| - assert_match(/^import \* as ActiveStorage from "activestorage"\nActiveStorage.start\(\)/, content) + assert_match(/^import \* as ActiveStorage from "@rails\/activestorage"\nActiveStorage.start\(\)/, content) end end @@ -267,7 +267,7 @@ module SharedGeneratorTests assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']active_storage\/engine["']/ assert_file "#{application_path}/app/javascript/packs/application.js" do |content| - assert_no_match(/^import * as ActiveStorage from "activestorage"\nActiveStorage.start\(\)/, content) + assert_no_match(/^import * as ActiveStorage from "@rails\/activestorage"\nActiveStorage.start\(\)/, content) end assert_file "#{application_path}/config/environments/development.rb" do |content| diff --git a/yarn.lock b/yarn.lock index 02d1463723..fdf508b9a3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5692,6 +5692,11 @@ trim-right@^1.0.1: resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= +trix@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trix/-/trix-1.0.0.tgz#e9cc98cf6030c908f8d54e317b5b072f927b0c6b" + integrity sha512-feli9QVXe6gzZOCUfpPGpNDURW9jMciIRVQ5gkDudOctcA1oMtI5K/qEbsL2rFCoGl1rSoeRt+HPhIFGyQscKg== + tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" -- cgit v1.2.3