@sb1/ffe-core 102.0.3 → 102.0.5
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-core",
|
|
3
|
-
"version": "102.0.
|
|
3
|
+
"version": "102.0.5",
|
|
4
4
|
"description": "Rammeverk for Felles Front End",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SpareBank 1",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"build-colors": "./scripts/build-colors.cjs"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@sb1/ffe-buildtool": "^102.0.
|
|
40
|
+
"@sb1/ffe-buildtool": "^102.0.5",
|
|
41
41
|
"case": "^1.6.3",
|
|
42
42
|
"less": "^4.9.1",
|
|
43
43
|
"postcss": "^8.5.29"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "1760a2b5eb07264cbcf9d014a4a0e97a6e68dd59"
|
|
49
49
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
1
|
import {
|
|
3
2
|
GetLocalVariablesResponse,
|
|
4
3
|
PostVariablesRequestBody,
|
|
@@ -13,29 +12,39 @@ export default class FigmaApi {
|
|
|
13
12
|
this.token = token;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
async
|
|
17
|
-
const resp = await
|
|
18
|
-
|
|
15
|
+
private async request<T>(path: string, init: RequestInit = {}) {
|
|
16
|
+
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
17
|
+
...init,
|
|
19
18
|
headers: {
|
|
20
19
|
Accept: '*/*',
|
|
21
20
|
'X-Figma-Token': this.token,
|
|
21
|
+
...init.headers,
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
if (!resp.ok) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Figma API ${init.method ?? 'GET'} ${path} failed: ${resp.status} ${await resp.text()}`,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (await resp.json()) as T;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async getLocalVariables(fileKey: string) {
|
|
35
|
+
return this.request<GetLocalVariablesResponse>(
|
|
36
|
+
`/v1/files/${fileKey}/variables/local`,
|
|
37
|
+
);
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
async postVariables(fileKey: string, payload: PostVariablesRequestBody) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
return this.request<PostVariablesResponse>(
|
|
42
|
+
`/v1/files/${fileKey}/variables`,
|
|
43
|
+
{
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: { 'Content-Type': 'application/json' },
|
|
46
|
+
body: JSON.stringify(payload),
|
|
35
47
|
},
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return resp.data;
|
|
48
|
+
);
|
|
40
49
|
}
|
|
41
50
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
1
|
import * as fs from 'fs';
|
|
3
2
|
|
|
4
3
|
import FigmaApi from './figma_api';
|
|
@@ -17,6 +16,12 @@ import { tokenFilesFromLocalVariables } from './token_export';
|
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
18
|
async function main() {
|
|
19
|
+
try {
|
|
20
|
+
process.loadEnvFile();
|
|
21
|
+
} catch {
|
|
22
|
+
// .env is optional, the variables can also be set in the environment
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
if (!process.env.PERSONAL_ACCESS_TOKEN || !process.env.FILE_KEY) {
|
|
21
26
|
throw new Error(
|
|
22
27
|
'PERSONAL_ACCESS_TOKEN and FILE_KEY environemnt variables are required',
|