Compare commits
7 Commits
1969e90394
...
20260221_1
| Author | SHA1 | Date | |
|---|---|---|---|
| f08a579246 | |||
| adb538cbc4 | |||
| d00eb5cf6c | |||
| 247a997353 | |||
| cc14397588 | |||
| d058ba8eed | |||
| 36243c7457 |
@@ -20,6 +20,21 @@ jobs:
|
|||||||
id: timestamp
|
id: timestamp
|
||||||
run: echo "::set-output name=date::$(date +'%Y%m%d_%H%M%S')"
|
run: echo "::set-output name=date::$(date +'%Y%m%d_%H%M%S')"
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm i
|
||||||
|
|
||||||
|
- name: Create JSON Lines
|
||||||
|
run: node ./scripts/ndjson-out.js ./pis/codes.yaml
|
||||||
|
|
||||||
|
- name: Verify JSONL Output
|
||||||
|
run: |
|
||||||
|
if [ ! -s pis-objects.jsonl ]; then
|
||||||
|
echo "Error: pis-objects.jsonl is empty or missong"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "File verified"
|
||||||
|
pwd
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
if: success()
|
if: success()
|
||||||
uses: akkuman/gitea-release-action@v1
|
uses: akkuman/gitea-release-action@v1
|
||||||
@@ -30,3 +45,5 @@ jobs:
|
|||||||
tag_name: ${{ steps.timestamp.outputs.date }}
|
tag_name: ${{ steps.timestamp.outputs.date }}
|
||||||
name: ${{ steps.timestamp.outputs.date }}
|
name: ${{ steps.timestamp.outputs.date }}
|
||||||
token: ${{ secrets.OWLBOT_KEY }}
|
token: ${{ secrets.OWLBOT_KEY }}
|
||||||
|
files: |-
|
||||||
|
pis-objects.jsonl
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const fs = require('fs')
|
const fs = require('fs');
|
||||||
const yaml = require('yaml')
|
const yaml = require('yaml');
|
||||||
|
|
||||||
const directoryPath = './pis/'
|
const directoryPath = './pis/';
|
||||||
|
|
||||||
function sortAndMergeYAMLFiles() {
|
function sortAndMergeYAMLFiles() {
|
||||||
try {
|
try {
|
||||||
@@ -12,15 +12,15 @@ function sortAndMergeYAMLFiles() {
|
|||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
const data = fs.readFileSync(directoryPath + file, 'utf-8');
|
const data = fs.readFileSync(directoryPath + file, 'utf-8');
|
||||||
|
|
||||||
const parsedData = yaml.parse(data)
|
const parsedData = yaml.parse(data);
|
||||||
|
|
||||||
if (parsedData && typeof parsedData === 'object' && parsedData.pis) {
|
if (parsedData && typeof parsedData === 'object' && parsedData.pis) {
|
||||||
mergedData.push(...parsedData.pis)
|
mergedData.push(...parsedData.pis);
|
||||||
} else {
|
} else {
|
||||||
if (Array.isArray(parsedData)) {
|
if (Array.isArray(parsedData)) {
|
||||||
mergedData.push(...parsedData);
|
mergedData.push(...parsedData);
|
||||||
} else {
|
} else {
|
||||||
console.error("Incorrect YAML")
|
console.error("Incorrect YAML");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -29,7 +29,7 @@ function sortAndMergeYAMLFiles() {
|
|||||||
const codeA = parseInt(a.code);
|
const codeA = parseInt(a.code);
|
||||||
const codeB = parseInt(b.code);
|
const codeB = parseInt(b.code);
|
||||||
return codeA - codeB
|
return codeA - codeB
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -41,15 +41,14 @@ function sortAndMergeYAMLFiles() {
|
|||||||
seenCodes.add(item.code);
|
seenCodes.add(item.code);
|
||||||
outputString += ` - code: "${item.code}"\n`;
|
outputString += ` - code: "${item.code}"\n`;
|
||||||
outputString += ` stops: [${item.stops.map(stop => `${stop}`).join(',')}]\n`;
|
outputString += ` stops: [${item.stops.map(stop => `${stop}`).join(',')}]\n`;
|
||||||
outputString += ` toc: "${item.toc || "gw"}"\n`;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync('./pis/codes.yaml', outputString);
|
fs.writeFileSync('./pis/codes.yaml', outputString);
|
||||||
console.log("Overwritten codes.yaml")
|
console.log("Overwritten codes.yaml");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error writing codes.yaml", err)
|
console.error("Error writing codes.yaml", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any new files
|
// Remove any new files
|
||||||
@@ -61,7 +60,7 @@ function sortAndMergeYAMLFiles() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.error('Error merging YAML:', err)
|
console.error('Error merging YAML:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
scripts/ndjson-out.js
Normal file
27
scripts/ndjson-out.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const yaml = require('yaml');
|
||||||
|
|
||||||
|
const inputFile = process.argv[2];
|
||||||
|
const outputFile = 'pis-objects.jsonl';
|
||||||
|
|
||||||
|
if (!inputFile) {
|
||||||
|
console.error('Please provide an input YAML file');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const fileContent = fs.readFileSync(inputFile, 'utf8');
|
||||||
|
const data = yaml.parse(fileContent);
|
||||||
|
|
||||||
|
if (!data || !data.pis || !Array.isArray(data.pis)) {
|
||||||
|
throw new Error('Invalid structure: Expected object with "pis" array.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const jsonl = data.pis.map(item => JSON.stringify(item));
|
||||||
|
|
||||||
|
fs.writeFileSync(outputFile, jsonl.join('\n') + '\n');
|
||||||
|
console.log(`Successfully processed ${data.pis.length} items.`);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Conversion failed: ", e.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
0
scripts/test.yaml
Normal file
0
scripts/test.yaml
Normal file
Reference in New Issue
Block a user