Skip to content

Commit 3cd8c68

Browse files
authored
Merge pull request #173 from jay-oswald/vehicle_profiles
Building Vehicle Profiles
2 parents f3cb331 + e9ca0ec commit 3cd8c68

File tree

13 files changed

+679
-0
lines changed

13 files changed

+679
-0
lines changed

.github/CODEOWNERS

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# @meatpiHQ Ownes everything by default
2+
* @meatpiHQ
3+
4+
# @jay-oswald owns the vehicle_profiles JS + Action
5+
.vehicle_profiles/ @jay-oswald
6+
.github/workflows/vehicle_profiles.yml @jay-oswald
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build Vehicle Profiles
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'vehicle_profiles/**'
9+
- '.vehicle_profiles/**'
10+
- '.github/workflows/vehicle_profiles.yml'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
repository: ${{ github.event.pull_request.head.repo.full_name }}
20+
ref: ${{ github.event.pull_request.head.ref }}
21+
- name: Setup Node
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20.x'
25+
- run: |
26+
cd .vehicle_profiles
27+
npm ci
28+
npm run build
29+
cd -
30+
- name: Commit
31+
uses: EndBug/add-and-commit@v9
32+
with:
33+
add: 'vehicle_profiles.json'
34+
author_name: Jay Oswald
35+
author_email: jay@oswald.net.au
36+

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ modules.order
5252
Module.symvers
5353
Mkfile.old
5454
dkms.conf
55+
56+
#Vehicle Profiles
57+
.vehicle_profiles/node_modules/

.vehicle_profiles/merge.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { glob } from 'glob'
2+
import { readFile, writeFile } from 'fs/promises';
3+
4+
const source_folder = '../vehicle_profiles';
5+
const target = '../vehicle_profiles.json'
6+
7+
const files = await glob(source_folder + '/**/*.json');
8+
9+
let result = {
10+
'cars': []
11+
};
12+
13+
async function add_json(path){
14+
let data = JSON.parse(await readFile(path));
15+
result.cars.push(data)
16+
}
17+
18+
let promises = [];
19+
files.forEach(file => {
20+
promises.push(add_json(file));
21+
});
22+
23+
await Promise.all(promises);
24+
25+
result.cars.sort((a,b) => {
26+
let first = a.car_model.toLowerCase();
27+
let second = b.car_model.toLowerCase();
28+
return (first < second) ? -1 : (first > second ) ? 1 : 0;
29+
});
30+
31+
result = JSON.stringify(result);
32+
//Use below line instead for generating pretty json
33+
// result = JSON.stringify(result, null, 2);
34+
await writeFile(target, result)

0 commit comments

Comments
 (0)