|
22 | 22 |
|
23 | 23 | const { src, dest, series } = require('gulp'); |
24 | 24 | const fs = require("fs"); |
| 25 | +const path = require('path'); |
25 | 26 |
|
26 | 27 | // removed require('merge-stream') node module. it gives wired glob behavior and some files goes missing |
27 | 28 | const rename = require("gulp-rename"); |
28 | 29 |
|
29 | 30 |
|
30 | 31 | // individual third party copy |
31 | | -function copyLicence(path, name) { |
| 32 | +function copyLicence(filePath, name) { |
32 | 33 | console.log(`Copying licence file ${name}.markdown`); |
33 | | - return src(path) |
| 34 | + return src(filePath) |
34 | 35 | .pipe(rename(`${name}.markdown`)) |
35 | 36 | .pipe(dest('src/thirdparty/licences/')); |
36 | 37 | } |
37 | 38 |
|
38 | | -function renameFile(path, newName, destPath) { |
39 | | - console.log(`Renaming file ${path} to ${newName}`); |
40 | | - return src(path) |
| 39 | +function renameFile(filePath, newName, destPath) { |
| 40 | + console.log(`Renaming file ${filePath} to ${newName}`); |
| 41 | + return src(filePath) |
41 | 42 | .pipe(rename(newName)) |
42 | 43 | .pipe(dest(destPath)); |
43 | 44 | } |
44 | 45 |
|
| 46 | +function ensureDirectoryExists(filePath) { |
| 47 | + const dir = path.dirname(filePath); |
| 48 | + if (!fs.existsSync(dir)) { |
| 49 | + fs.mkdirSync(dir, { recursive: true }); |
| 50 | + } |
| 51 | +} |
| 52 | + |
45 | 53 | function downloadFile(url, outputPath) { |
| 54 | + console.log(`Downloading file ${url} to ${outputPath}`); |
| 55 | + ensureDirectoryExists(outputPath); |
46 | 56 | return fetch(url) |
47 | 57 | .then(x => { |
48 | 58 | if(x.status !== 200){ |
@@ -76,6 +86,11 @@ function _createListDirJson(dirPath, jsonFileName) { |
76 | 86 | fs.writeFileSync(`${dirPath}/${jsonFileName}`, JSON.stringify(filenames)); |
77 | 87 | } |
78 | 88 |
|
| 89 | +function _getConfigJSON() { |
| 90 | + let configPath = "src/config.json"; |
| 91 | + console.log("Reading phoenix Config :", configPath); |
| 92 | + return JSON.parse(fs.readFileSync(configPath, "utf8")); |
| 93 | +} |
79 | 94 |
|
80 | 95 | /** |
81 | 96 | * Add thirdparty libs copied to gitignore except the licence file. |
@@ -107,6 +122,13 @@ let copyThirdPartyLibs = series( |
107 | 122 | 'src/thirdparty/bugsnag-performance.min.js'), |
108 | 123 | downloadFile.bind(downloadFile, 'https://d2wy8f7a9ursnm.cloudfront.net/v2/bugsnag-performance.min.js.map', |
109 | 124 | 'src/thirdparty/bugsnag-performance.min.js.map'), |
| 125 | + // phoenix extension registry cache for first time load |
| 126 | + downloadFile.bind(downloadFile, _getConfigJSON().config.extension_registry, |
| 127 | + 'src/extensions/registry/registry.json'), |
| 128 | + downloadFile.bind(downloadFile, _getConfigJSON().config.extension_registry_version, |
| 129 | + 'src/extensions/registry/registry_version.json'), |
| 130 | + downloadFile.bind(downloadFile, _getConfigJSON().config.extension_registry_popularity, |
| 131 | + 'src/extensions/registry/popularity.json'), |
110 | 132 | // tern js |
111 | 133 | copyFiles.bind(copyFiles, ['node_modules/tern/defs/**/*'], 'src/thirdparty/tern/defs'), |
112 | 134 | copyFiles.bind(copyFiles, ['node_modules/tern/lib/**/*'], 'src/thirdparty/tern/lib'), |
|
0 commit comments