Skip to content
Permalink
Browse files

DEV: Yarn-manage moment and moment-timezone libraries

  • Loading branch information...
pmusaraj committed Feb 12, 2019
1 parent c23411c commit 5cef5b34ef9943161a6fa9c3197c5938da8b6003
Showing with 34 additions and 15 deletions.
  1. +0 −3 .eslintignore
  2. +2 −2 lib/discourse_plugin_registry.rb
  3. +3 −3 lib/js_locale_helper.rb
  4. +7 −0 lib/tasks/javascript.rake
  5. +2 −0 package.json
  6. +3 −3 spec/components/plugin/instance_spec.rb
  7. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/af.js
  8. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ar-dz.js
  9. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ar-kw.js
  10. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ar-ly.js
  11. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ar-ma.js
  12. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ar-sa.js
  13. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ar-tn.js
  14. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ar.js
  15. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/az.js
  16. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/be.js
  17. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/bg.js
  18. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/bm.js
  19. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/bn.js
  20. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/bo.js
  21. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/br.js
  22. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/bs.js
  23. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ca.js
  24. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/cs.js
  25. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/cv.js
  26. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/cy.js
  27. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/da.js
  28. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/de-at.js
  29. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/de-ch.js
  30. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/de.js
  31. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/dv.js
  32. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/el.js
  33. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/en-au.js
  34. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/en-ca.js
  35. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/en-gb.js
  36. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/en-ie.js
  37. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/en-il.js
  38. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/en-nz.js
  39. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/eo.js
  40. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/es-do.js
  41. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/es-us.js
  42. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/es.js
  43. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/et.js
  44. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/eu.js
  45. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/fa.js
  46. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/fi.js
  47. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/fo.js
  48. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/fr-ca.js
  49. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/fr-ch.js
  50. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/fr.js
  51. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/fy.js
  52. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/gd.js
  53. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/gl.js
  54. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/gom-latn.js
  55. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/gu.js
  56. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/he.js
  57. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/hi.js
  58. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/hr.js
  59. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/hu.js
  60. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/hy-am.js
  61. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/id.js
  62. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/is.js
  63. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/it.js
  64. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ja.js
  65. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/jv.js
  66. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ka.js
  67. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/kk.js
  68. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/km.js
  69. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/kn.js
  70. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ko.js
  71. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ky.js
  72. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/lb.js
  73. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/lo.js
  74. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/lt.js
  75. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/lv.js
  76. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/me.js
  77. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/mi.js
  78. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/mk.js
  79. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ml.js
  80. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/mn.js
  81. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/mr.js
  82. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ms-my.js
  83. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ms.js
  84. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/mt.js
  85. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/my.js
  86. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/nb.js
  87. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ne.js
  88. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/nl-be.js
  89. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/nl.js
  90. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/nn.js
  91. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/pa-in.js
  92. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/pl.js
  93. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/pt-br.js
  94. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/pt.js
  95. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ro.js
  96. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ru.js
  97. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/sd.js
  98. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/se.js
  99. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/si.js
  100. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/sk.js
  101. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/sl.js
  102. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/sq.js
  103. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/sr-cyrl.js
  104. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/sr.js
  105. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ss.js
  106. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/sv.js
  107. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/sw.js
  108. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ta.js
  109. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/te.js
  110. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/tet.js
  111. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/tg.js
  112. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/th.js
  113. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/tl-ph.js
  114. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/tlh.js
  115. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/tr.js
  116. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/tzl.js
  117. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/tzm-latn.js
  118. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/tzm.js
  119. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ug-cn.js
  120. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/uk.js
  121. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/ur.js
  122. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/uz-latn.js
  123. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/uz.js
  124. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/vi.js
  125. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/x-pseudo.js
  126. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/yo.js
  127. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/zh-cn.js
  128. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/zh-hk.js
  129. 0 {lib/javascripts/moment_locale → vendor/assets/javascripts/moment-locale}/zh-tw.js
  130. 0 {lib → vendor/assets}/javascripts/moment-timezone-with-data.js
  131. +0 −4 {lib → vendor/assets}/javascripts/moment.js
  132. +17 −0 yarn.lock
@@ -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/
@@ -204,8 +204,8 @@ def self.seed_paths
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]
@@ -153,16 +153,16 @@ def self.output_locale(locale)
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

result
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 }
@@ -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'
}, {
@@ -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",
@@ -102,7 +102,7 @@ def enabled?

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 @@ def register_locale(locale, opts)

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 @@ def register_locale(locale, opts)

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")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,8 +1,4 @@
//! moment.js
//! version : 2.22.1
//! Copyright (c) JS Foundation and other contributors
//! license : MIT
//! github.com/moment/moment

;(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :