oci v5.1 + get package version for file_fetcher

This commit is contained in:
Milos Brzakovic
2021-07-08 20:05:29 +02:00
parent 26cbd7b255
commit b135da504d
2 changed files with 11 additions and 4 deletions

View File

@@ -1,4 +1,7 @@
import { utilFetchJson } from '../util/util';
import parseVersion from 'vparse';
// Double check this resolves to iD's `package.json`
import packageJSON from '../../package.json';
let _mainFileFetcher = coreFileFetcher(); // singleton
@@ -8,6 +11,10 @@ export { _mainFileFetcher as fileFetcher };
// coreFileFetcher asynchronously fetches data from JSON files
//
export function coreFileFetcher() {
const ociVersion = packageJSON.dependencies['osm-community-index'] || packageJSON.devDependencies['osm-community-index'];
const v = parseVersion(ociVersion);
const vMinor = `${v.major}.${v.minor}`;
let _this = {};
let _inflight = {};
let _fileMap = {
@@ -19,9 +26,9 @@ export function coreFileFetcher() {
'keepRight': 'data/keepRight.min.json',
'languages': 'data/languages.min.json',
'locales': 'locales/index.min.json',
'oci_defaults': 'https://cdn.jsdelivr.net/npm/osm-community-index@4/dist/defaults.min.json',
'oci_features': 'https://cdn.jsdelivr.net/npm/osm-community-index@4/dist/featureCollection.min.json',
'oci_resources': 'https://cdn.jsdelivr.net/npm/osm-community-index@4/dist/resources.min.json',
'oci_defaults': `https://cdn.jsdelivr.net/npm/osm-community-index@${vMinor}/dist/defaults.min.json`,
'oci_features': `https://cdn.jsdelivr.net/npm/osm-community-index@${vMinor}/dist/featureCollection.min.json`,
'oci_resources': `https://cdn.jsdelivr.net/npm/osm-community-index@${vMinor}/dist/resources.min.json`,
'preset_categories': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/preset_categories.min.json',
'preset_defaults': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/preset_defaults.min.json',
'preset_fields': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/fields.min.json',

View File

@@ -103,7 +103,7 @@
"node-fetch": "^2.6.1",
"npm-run-all": "^4.0.0",
"object-inspect": "1.10.3",
"osm-community-index": "~4.0.2",
"osm-community-index": "~5.1.0",
"phantomjs-prebuilt": "~2.1.16",
"postcss": "^8.1.1",
"postcss-selector-prepend": "^0.5.0",