@magidoc/plugin-starter-variables 0.6.0 → 0.7.0
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/build/variable.d.ts +1 -0
- package/build/variable.js +6 -0
- package/build/variable.js.map +1 -1
- package/package.json +1 -1
- package/src/variable.ts +7 -0
package/build/variable.d.ts
CHANGED
package/build/variable.js
CHANGED
|
@@ -2,6 +2,7 @@ function createVariable(key, conversion) {
|
|
|
2
2
|
const viteKey = `VITE_${key.toUpperCase()}`;
|
|
3
3
|
const viteGet = (env) => env[viteKey] !== undefined ? conversion(env[viteKey]) : null;
|
|
4
4
|
return {
|
|
5
|
+
names: [key, toCamelCase(key)],
|
|
5
6
|
vite: {
|
|
6
7
|
key: viteKey,
|
|
7
8
|
get: viteGet,
|
|
@@ -9,6 +10,11 @@ function createVariable(key, conversion) {
|
|
|
9
10
|
},
|
|
10
11
|
};
|
|
11
12
|
}
|
|
13
|
+
function toCamelCase(key) {
|
|
14
|
+
return key.toLowerCase().replace(/([-_][a-z])/gi, ($1) => {
|
|
15
|
+
return $1.toUpperCase().replace('-', '').replace('_', '');
|
|
16
|
+
});
|
|
17
|
+
}
|
|
12
18
|
function stringConversion() {
|
|
13
19
|
return (target) => String(target);
|
|
14
20
|
}
|
package/build/variable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable.js","sources":["../../src/variable.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"variable.js","sources":["../../src/variable.ts"],"sourcesContent":[null],"names":[],"mappings":"AAkBgB,SAAA,cAAc,CAC5B,GAAW,EACX,UAAkC,EAAA;IAElC,MAAM,OAAO,GAAG,CAAQ,KAAA,EAAA,GAAG,CAAC,WAAW,EAAE,EAAE,CAAA;IAC3C,MAAM,OAAO,GAAG,CAAC,GAAY,KAC3B,GAAG,CAAC,OAAO,CAAC,KAAK,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAA;IAE9D,OAAO;QACL,KAAK,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;AAC9B,QAAA,IAAI,EAAE;AACJ,YAAA,GAAG,EAAE,OAAO;AACZ,YAAA,GAAG,EAAE,OAAO;AACZ,YAAA,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG;AAChD,SAAA;KACF,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAA;AAC9B,IAAA,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,EAAE,KAAI;AACvD,QAAA,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AAC3D,KAAC,CAAC,CAAA;AACJ,CAAC;SACe,gBAAgB,GAAA;IAC9B,OAAO,CAAC,MAAe,KAAa,MAAM,CAAC,MAAM,CAAC,CAAA;AACpD;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@magidoc/plugin-starter-variables",
|
|
3
3
|
"description": "A shared library that contains common Magidoc starter environment variables keys.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.7.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "./build/index.js",
|
package/src/variable.ts
CHANGED
|
@@ -6,6 +6,7 @@ interface MetaEnv {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export type Variable<T> = {
|
|
9
|
+
names: string[]
|
|
9
10
|
vite: ViteVariable<T>
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -24,6 +25,7 @@ export function createVariable<T = string | boolean>(
|
|
|
24
25
|
env[viteKey] !== undefined ? conversion(env[viteKey]) : null
|
|
25
26
|
|
|
26
27
|
return {
|
|
28
|
+
names: [key, toCamelCase(key)],
|
|
27
29
|
vite: {
|
|
28
30
|
key: viteKey,
|
|
29
31
|
get: viteGet,
|
|
@@ -32,6 +34,11 @@ export function createVariable<T = string | boolean>(
|
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
function toCamelCase(key: string): string {
|
|
38
|
+
return key.toLowerCase().replace(/([-_][a-z])/gi, ($1) => {
|
|
39
|
+
return $1.toUpperCase().replace('-', '').replace('_', '')
|
|
40
|
+
})
|
|
41
|
+
}
|
|
35
42
|
export function stringConversion() {
|
|
36
43
|
return (target: unknown): string => String(target)
|
|
37
44
|
}
|