@intlayer/config 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://www.npmjs.com/package/intlayer">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/572ae9c9acafb74307b81530c1931a8e98990aef/docs/assets/logo.png" width="500" alt="intlayer" />
|
|
4
|
+
</a>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/intlayer">
|
|
9
|
+
<img alt="npm" src="https://img.shields.io/npm/v/intlayer.svg?labelColor=49516F&color=8994BC" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://npmjs.org/package/intlayer">
|
|
12
|
+
<img alt="downloads" src="https://badgen.net/npm/dm/intlayer?labelColor=49516F&color=8994BC" />
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://npmjs.org/package/intlayer">
|
|
15
|
+
<img alt="types included" src="https://badgen.net/npm/types/intlayer?labelColor=49516F&color=8994BC"
|
|
16
|
+
/>
|
|
17
|
+
</a>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
# @intlayer/config: NPM Package to retrieve Intlayer configuration
|
|
21
|
+
|
|
22
|
+
**Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, React, and Express.js.
|
|
23
|
+
|
|
24
|
+
The **`@intlayer/config`** package is a NPM package that allows you to retrieve the configuration of Intlayer and define the environment variables related to the current environment.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
Install the necessary package using your preferred package manager:
|
|
29
|
+
|
|
30
|
+
```bash packageManager="npm"
|
|
31
|
+
npm install @intlayer/config
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash packageManager="pnpm"
|
|
35
|
+
pnpm add @intlayer/config
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```bash packageManager="yarn"
|
|
39
|
+
yarn add @intlayer/config
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Read the configuration of Intlayer using file system
|
|
45
|
+
|
|
46
|
+
Example:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { getConfiguration, type IntlayerConfig } from "@intlayer/config";
|
|
50
|
+
|
|
51
|
+
const config: IntlayerConfig = getConfiguration();
|
|
52
|
+
|
|
53
|
+
console.log(config);
|
|
54
|
+
// Output:
|
|
55
|
+
// {
|
|
56
|
+
// internationalization: { ... },
|
|
57
|
+
// middleware: { ... },
|
|
58
|
+
// content: { ... },
|
|
59
|
+
// editor: { ... }
|
|
60
|
+
// }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> This function use `fs` packages and will only work on the server side.
|
|
64
|
+
|
|
65
|
+
### Read the configuration of Intlayer using environment variables
|
|
66
|
+
|
|
67
|
+
Example:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { getConfiguration, type IntlayerConfig } from "@intlayer/config/client";
|
|
71
|
+
|
|
72
|
+
const config: IntlayerConfig = getConfiguration({
|
|
73
|
+
env: "production",
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
console.log(config);
|
|
77
|
+
// Output:
|
|
78
|
+
// {
|
|
79
|
+
// internationalization: { ... },
|
|
80
|
+
// middleware: { ... },
|
|
81
|
+
// content: { ... },
|
|
82
|
+
// editor: { ... }
|
|
83
|
+
// }
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
> This function will not return anything if the environment variables are not defined.
|
|
87
|
+
|
|
88
|
+
### Define the environment variables
|
|
89
|
+
|
|
90
|
+
1. Create a configuration file.
|
|
91
|
+
|
|
92
|
+
```ts fileName="intlayer.config.ts"
|
|
93
|
+
import { type IntlayerConfig } from "intlayer";
|
|
94
|
+
|
|
95
|
+
const config: IntlayerConfig = {
|
|
96
|
+
internationalization: {
|
|
97
|
+
/* ... */
|
|
98
|
+
},
|
|
99
|
+
middleware: {
|
|
100
|
+
/* ... */
|
|
101
|
+
},
|
|
102
|
+
content: {
|
|
103
|
+
/* ... */
|
|
104
|
+
},
|
|
105
|
+
editor: {
|
|
106
|
+
/* ... */
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default config;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
> See [Intlayer configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/en/configuration.md) for more details.
|
|
114
|
+
|
|
115
|
+
2. Define the environment variables.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { getConfiguration } from "@intlayer/config";
|
|
119
|
+
|
|
120
|
+
const intlayerConfig = getConfiguration();
|
|
121
|
+
|
|
122
|
+
// Format all configuration values as environment variables
|
|
123
|
+
const env = formatEnvVariable();
|
|
124
|
+
|
|
125
|
+
// Set each formatted environment variable in process.env
|
|
126
|
+
Object.assign(process.env, env);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
3. Import the configuration file.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { getConfiguration } from "@intlayer/config/client";
|
|
133
|
+
|
|
134
|
+
const intlayerConfig = getConfiguration();
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Read about Intlayer
|
|
138
|
+
|
|
139
|
+
- [Intlayer Website](https://intlayer.org)
|
|
140
|
+
- [Intlayer Documentation](https://intlayer.org/docs)
|
|
141
|
+
- [Intlayer GitHub](https://github.com/aymericzip/intlayer)
|
|
142
|
+
|
|
143
|
+
- [Ask your questions to our smart documentation](https://intlayer.org/docs/chat)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/config",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared configuration package for IntLayer - Layer of abstraction between the business logic and the data access layer. Manage internationalization in a simple way, through TypeScript, JavaScript or JSON declaration file.",
|
|
6
6
|
"keywords": [
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"react": ">=16.0.0",
|
|
87
|
-
"intlayer": "4.0.
|
|
87
|
+
"intlayer": "4.0.2"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=14.18"
|