combo.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. var fs = require('fs')
  18. var path = require('path')
  19. var request = require('request')
  20. var cdnUrl = 'https://s1.analysys.cn/libs/??'
  21. var version = '1.0.0'
  22. // js集合
  23. var jslibs = {
  24. 'es5': [
  25. 'es5-shim/4.5.7/es5-shim.min.js',
  26. 'es5-shim/4.5.7/es5-sham.min.js'
  27. ],
  28. '3rd': [
  29. 'vue/2.5.2/vue.js',
  30. 'vue-router/2.7.0/vue-router.min.js',
  31. 'vuex/3.0.0/vuex.min.js',
  32. 'jquery/3.3.1/jquery.min.js',
  33. 'lodash.js/4.17.5/lodash.min.js',
  34. 'jqueryui/1.12.1/jquery-ui.min.js',
  35. 'twitter-bootstrap/3.3.7/js/bootstrap.min.js',
  36. 'jsPlumb/2.8.5/js/jsplumb.min.js',
  37. 'clipboard.js/2.0.1/clipboard.min.js',
  38. 'd3/3.3.6/d3.min.js',
  39. 'echarts/4.1.0/echarts.min.js',
  40. 'dayjs/1.7.8/dayjs.min.js',
  41. 'codemirror/5.43.0/codemirror.min.js',
  42. 'codemirror/5.43.0/mode/sql/sql.min.js',
  43. 'codemirror/5.43.0/addon/hint/show-hint.min.js',
  44. 'codemirror/5.43.0/addon/hint/sql-hint.min.js',
  45. 'codemirror/5.43.0/mode/textile/textile.min.js',
  46. 'codemirror/5.43.0/mode/shell/shell.min.js',
  47. 'codemirror/5.43.0/mode/python/python.min.js',
  48. 'codemirror/5.43.0/addon/hint/xml-hint.min.js',
  49. 'codemirror/5.43.0/mode/xml/xml.min.js',
  50. 'html2canvas/0.5.0-beta4/html2canvas.min.js',
  51. 'canvg/1.5/canvg.min.js'
  52. ],
  53. 'local': []
  54. }
  55. // css集合
  56. csslibs = {
  57. 'base': [
  58. 'normalize/7.0.0/normalize.min.css',
  59. 'twitter-bootstrap/3.3.7/css/bootstrap.min.css',
  60. '-/@analysys/reset.css@1.0.1',
  61. '-/@vue/animate.css@'
  62. ],
  63. '3rd': [
  64. 'highlight.js/9.13.1/styles/vs.min.css',
  65. 'jsPlumb/2.8.5/css/jsplumbtoolkit-defaults.min.css',
  66. 'codemirror/5.43.0/codemirror.min.css',
  67. 'codemirror/5.20.0/theme/mdn-like.min.css',
  68. 'codemirror/5.43.0/addon/hint/show-hint.min.css'
  69. ]
  70. }
  71. // 创建文件夹目录
  72. var dirPath = path.resolve(__dirname, '..', 'src/combo/' + version)
  73. if (!fs.existsSync(dirPath)) {
  74. fs.mkdirSync(dirPath)
  75. console.log('文件夹创建成功')
  76. } else {
  77. console.log('文件夹已存在')
  78. }
  79. var jsKeys = Object.keys(jslibs)
  80. var jsUrl = jsKeys.map(v => {
  81. return jslibs[v].join()
  82. })
  83. jsUrl.forEach((v, i) => {
  84. var url = cdnUrl + v
  85. console.log(url)
  86. var stream = fs.createWriteStream(path.join(dirPath, jsKeys[i] + '.js'), { encoding: 'utf-8' })
  87. request(url).pipe(stream).on('close', function (err) {
  88. if (!err) {
  89. console.log('文件[' + version + '/' + jsKeys[i] + '.js' + ']下载完毕')
  90. }
  91. })
  92. })
  93. var cssKeys = Object.keys(csslibs)
  94. var cssUrl = cssKeys.map(v => {
  95. return csslibs[v].join()
  96. })
  97. cssUrl.forEach((v, i) => {
  98. var url = cdnUrl + v
  99. console.log(url)
  100. var stream = fs.createWriteStream(path.join(dirPath, cssKeys[i] + '.css'), { encoding: 'utf-8' })
  101. request(url).pipe(stream).on('close', function (err) {
  102. if (!err) {
  103. console.log('文件[' + version + '/' + cssKeys[i] + '.css' + ']下载完毕')
  104. }
  105. })
  106. })