Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oci v5.1 + oci filefetch version from package.json #8575

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions modules/core/file_fetcher.js
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 = {
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down