@jargon/sdk-core
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -0,1 +1,10 @@ | ||
### 1.3.0 | ||
Support alternative resource directories | ||
Adds resourceDirectory to ResourceManagerOptions, with a default value of './resources', | ||
to allow for customizing the directory where resources are loaded from. | ||
The ResourceManagerFactory constructor will throw an error if resourceDirectory doesn't | ||
exist (ENOENT) or isn't a directory (ENOTDIR). | ||
### 1.2.0 | ||
@@ -2,0 +11,0 @@ Expose variation selection logic in ResourceManager |
@@ -60,5 +60,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fs_1 = require("fs"); | ||
var i18n = require("i18next"); | ||
// @ts-ignore Types not available | ||
var syncBackend = require("i18next-sync-fs-backend"); | ||
var path_1 = require("path"); | ||
var icuFormat_1 = require("./icuFormat"); | ||
@@ -224,2 +226,10 @@ var jargonResources_1 = require("./jargonResources"); | ||
} | ||
var rd = this._opts.resourceDirectory; | ||
var stats = fs_1.statSync(rd); | ||
if (!stats.isDirectory()) { | ||
var e = new Error("ENOTDIR: " + rd + " is not a directory"); | ||
e.code = 'ENOTDIR'; | ||
e.path = rd; | ||
throw e; | ||
} | ||
this.baseTranslator = i18n | ||
@@ -230,3 +240,3 @@ .use(syncBackend) | ||
backend: { | ||
loadPath: './resources/{{lng}}.json' | ||
loadPath: path_1.join(rd, '{{lng}}.json') | ||
}, | ||
@@ -233,0 +243,0 @@ debug: false, |
@@ -19,2 +19,4 @@ import { I18NextResourceManagerFactory } from './i18next'; | ||
trackSelectedVariations?: boolean; | ||
/** The directory where resources files are stored; defaults to './resources' */ | ||
resourceDirectory?: string; | ||
} | ||
@@ -21,0 +23,0 @@ export declare const DefaultResourceManagerOptions: Required<ResourceManagerOptions>; |
@@ -22,3 +22,4 @@ "use strict"; | ||
localesToPreload: [], | ||
trackSelectedVariations: true | ||
trackSelectedVariations: true, | ||
resourceDirectory: './resources' | ||
}; | ||
@@ -25,0 +26,0 @@ exports.DefaultRenderOptions = { |
{ | ||
"name": "@jargon/sdk-core", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Core components of Jargon's NodeJS SDK", | ||
@@ -5,0 +5,0 @@ "author": "jargon.com", |
@@ -6,2 +6,21 @@ # `@jargon/sdk-core` | ||
- [`@jargon/sdk-core`](#jargonsdk-core) | ||
- [Core concepts](#core-concepts) | ||
- [Content resources and resource files](#content-resources-and-resource-files) | ||
- [Resource value format](#resource-value-format) | ||
- [Named parameters](#named-parameters) | ||
- [Plural forms](#plural-forms) | ||
- [Gendered forms](#gendered-forms) | ||
- [Variations](#variations) | ||
- [Functionality](#functionality) | ||
- [Resource management and runtime rendering](#resource-management-and-runtime-rendering) | ||
- [Built-in Resources](#built-in-resources) | ||
- [Runtime Interface](#runtime-interface) | ||
- [RenderItem](#renderitem) | ||
- [ResourceManager](#resourcemanager) | ||
- [ResourceManagerFactory](#resourcemanagerfactory) | ||
- [ResourceManagerOptions](#resourcemanageroptions) | ||
- [RenderOptions](#renderoptions) | ||
- [Usage](#usage) | ||
## Core concepts | ||
@@ -236,2 +255,5 @@ | ||
trackSelectedVariations?: boolean | ||
/** The directory where resources files are stored; defaults to './resources' */ | ||
resourceDirectory?: string | ||
} | ||
@@ -242,3 +264,4 @@ | ||
localesToPreload: [], | ||
trackSelectedVariations: true | ||
trackSelectedVariations: true, | ||
resourceDirectory: './resources' | ||
} | ||
@@ -245,0 +268,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70302
745
297
1