DEV: Yarn-manage moment and moment-timezone libraries

This commit is contained in:
Penar Musaraj 2019-02-12 13:57:52 -05:00
parent c23411cc69
commit 5cef5b34ef
132 changed files with 34 additions and 15 deletions

View File

@ -6,9 +6,6 @@ app/assets/javascripts/ember-addons/
app/assets/javascripts/discourse/lib/autosize.js.es6
lib/javascripts/locale/
lib/javascripts/messageformat.js
lib/javascripts/moment.js
lib/javascripts/moment-timezone-with-data.js
lib/javascripts/moment_locale/
lib/highlight_js/
plugins/**/lib/javascripts/locale
public/javascripts/

View File

@ -204,8 +204,8 @@ class DiscoursePluginRegistry
end
VENDORED_CORE_PRETTY_TEXT_MAP = {
"moment.js" => "lib/javascripts/moment.js",
"moment-timezone.js" => "lib/javascripts/moment-timezone-with-data.js"
"moment.js" => "vendor/assets/javascripts/moment.js",
"moment-timezone.js" => "vendor/assets/javascripts/moment-timezone-with-data.js"
}
def self.core_asset_for_name(name)
asset = VENDORED_CORE_PRETTY_TEXT_MAP[name]

View File

@ -153,8 +153,8 @@ module JsLocaleHelper
result << "I18n.pluralizationRules.#{locale_str} = MessageFormat.locale.#{mf_locale};\n" if mf_locale != "en"
# moment
result << File.read("#{Rails.root}/lib/javascripts/moment.js")
result << File.read("#{Rails.root}/lib/javascripts/moment-timezone-with-data.js")
result << File.read("#{Rails.root}/vendor/assets/javascripts/moment.js")
result << File.read("#{Rails.root}/vendor/assets/javascripts/moment-timezone-with-data.js")
result << moment_locale(locale_str)
result << moment_formats
@ -162,7 +162,7 @@ module JsLocaleHelper
end
def self.find_moment_locale(locale_chain)
path = "#{Rails.root}/lib/javascripts/moment_locale"
path = "#{Rails.root}/vendor/assets/javascripts/moment-locale"
# moment.js uses a different naming scheme for locale files
locale_chain = locale_chain.map { |l| l.tr('_', '-').downcase }

View File

@ -66,6 +66,13 @@ task 'javascript:update' do
source: 'markdown-it/dist/markdown-it.js'
}, {
source: 'mousetrap/mousetrap.js'
}, {
source: 'moment/moment.js'
}, {
source: 'moment/locale',
destination: 'moment-locale',
}, {
source: 'moment-timezone/builds/moment-timezone-with-data.js'
}, {
source: 'resumablejs/resumable.js'
}, {

View File

@ -23,6 +23,8 @@
"jquery.cookie": "1.4.1",
"magnific-popup": "1.1.0",
"markdown-it": "8.4.1",
"moment": "2.22.1",
"moment-timezone": "0.5.14",
"mousetrap": "https://github.com/discourse/mousetrap#firefox-alt-key",
"pikaday": "1.7.0",
"resumablejs": "1.1.0",

View File

@ -102,7 +102,7 @@ describe Plugin::Instance do
plugin.send :register_assets!
expect(DiscoursePluginRegistry.vendored_core_pretty_text.first).to eq("lib/javascripts/moment.js")
expect(DiscoursePluginRegistry.vendored_core_pretty_text.first).to eq("vendor/assets/javascripts/moment.js")
end
end
@ -390,7 +390,7 @@ describe Plugin::Instance do
expect(locale[:fallbackLocale]).to eq("es")
expect(locale[:message_format]).to eq(["es", "#{Rails.root}/lib/javascripts/locale/es.js"])
expect(locale[:moment_js]).to eq(["es", "#{Rails.root}/lib/javascripts/moment_locale/es.js"])
expect(locale[:moment_js]).to eq(["es", "#{Rails.root}/vendor/assets/javascripts/moment-locale/es.js"])
expect(locale[:plural]).to be_nil
expect(Rails.configuration.assets.precompile).to include("locales/es_MX.js")
@ -404,7 +404,7 @@ describe Plugin::Instance do
expect(locale[:fallbackLocale]).to be_nil
expect(locale[:message_format]).to eq(["tlh", "#{plugin_path}/lib/javascripts/locale/message_format/tlh.js"])
expect(locale[:moment_js]).to eq(["tlh", "#{Rails.root}/lib/javascripts/moment_locale/tlh.js"])
expect(locale[:moment_js]).to eq(["tlh", "#{Rails.root}/vendor/assets/javascripts/moment-locale/tlh.js"])
expect(locale[:plural]).to eq(plural.with_indifferent_access)
expect(Rails.configuration.assets.precompile).to include("locales/tlh.js")

Some files were not shown because too many files have changed in this diff Show More