refactor: Move downloaded resources from assets/ to assets_downloaded/
- Changed default download location to assets_downloaded/schematron - Updated all references in SchematronDownloader, integration, and validator - Updated postinstall scripts to use new location - assets_downloaded/ is already in .gitignore to exclude downloaded files from git - Moved existing downloaded files to new location - All functionality tested and working correctly
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -20,4 +20,4 @@ dist_*/
|
|||||||
# custom
|
# custom
|
||||||
test/output
|
test/output
|
||||||
.serena
|
.serena
|
||||||
assets/schematron
|
assets_downloaded/
|
||||||
|
@@ -81,7 +81,7 @@ export class SchematronDownloader {
|
|||||||
private cacheDir: string;
|
private cacheDir: string;
|
||||||
private smartfile: any;
|
private smartfile: any;
|
||||||
|
|
||||||
constructor(cacheDir: string = 'assets/schematron') {
|
constructor(cacheDir: string = 'assets_downloaded/schematron') {
|
||||||
this.cacheDir = cacheDir;
|
this.cacheDir = cacheDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ export const ISO_SCHEMATRON_SKELETONS = {
|
|||||||
/**
|
/**
|
||||||
* Download ISO Schematron skeleton files
|
* Download ISO Schematron skeleton files
|
||||||
*/
|
*/
|
||||||
export async function downloadISOSkeletons(targetDir: string = 'assets/schematron/iso'): Promise<void> {
|
export async function downloadISOSkeletons(targetDir: string = 'assets_downloaded/schematron/iso'): Promise<void> {
|
||||||
await fs.mkdir(targetDir, { recursive: true });
|
await fs.mkdir(targetDir, { recursive: true });
|
||||||
|
|
||||||
console.log('Downloading ISO Schematron skeleton files...');
|
console.log('Downloading ISO Schematron skeleton files...');
|
||||||
|
@@ -75,7 +75,7 @@ export class IntegratedValidator {
|
|||||||
standard: 'EN16931' | 'PEPPOL' | 'XRECHNUNG',
|
standard: 'EN16931' | 'PEPPOL' | 'XRECHNUNG',
|
||||||
format: 'UBL' | 'CII'
|
format: 'UBL' | 'CII'
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
const basePath = 'assets/schematron';
|
const basePath = 'assets_downloaded/schematron';
|
||||||
|
|
||||||
// Map standard and format to file pattern
|
// Map standard and format to file pattern
|
||||||
const patterns: Record<string, Record<string, string>> = {
|
const patterns: Record<string, Record<string, string>> = {
|
||||||
|
@@ -272,19 +272,19 @@ export async function createStandardValidator(
|
|||||||
switch (standard) {
|
switch (standard) {
|
||||||
case 'EN16931':
|
case 'EN16931':
|
||||||
// Would load from ConnectingEurope/eInvoicing-EN16931
|
// Would load from ConnectingEurope/eInvoicing-EN16931
|
||||||
await validator.loadSchematron('assets/schematron/en16931/EN16931-UBL-validation.sch');
|
await validator.loadSchematron('assets_downloaded/schematron/en16931/EN16931-UBL-validation.sch');
|
||||||
break;
|
break;
|
||||||
case 'XRECHNUNG':
|
case 'XRECHNUNG':
|
||||||
// Would load from itplr-kosit/xrechnung-schematron
|
// Would load from itplr-kosit/xrechnung-schematron
|
||||||
await validator.loadSchematron('assets/schematron/xrechnung/XRechnung-UBL-validation.sch');
|
await validator.loadSchematron('assets_downloaded/schematron/xrechnung/XRechnung-UBL-validation.sch');
|
||||||
break;
|
break;
|
||||||
case 'PEPPOL':
|
case 'PEPPOL':
|
||||||
// Would load from OpenPEPPOL/peppol-bis-invoice-3
|
// Would load from OpenPEPPOL/peppol-bis-invoice-3
|
||||||
await validator.loadSchematron('assets/schematron/peppol/PEPPOL-EN16931-UBL.sch');
|
await validator.loadSchematron('assets_downloaded/schematron/peppol/PEPPOL-EN16931-UBL.sch');
|
||||||
break;
|
break;
|
||||||
case 'FACTURX':
|
case 'FACTURX':
|
||||||
// Would load from Factur-X specific Schematron
|
// Would load from Factur-X specific Schematron
|
||||||
await validator.loadSchematron('assets/schematron/facturx/Factur-X-EN16931-validation.sch');
|
await validator.loadSchematron('assets_downloaded/schematron/facturx/Factur-X-EN16931-validation.sch');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ import { SchematronDownloader } from '../dist_ts/formats/validation/schematron.d
|
|||||||
async function main() {
|
async function main() {
|
||||||
console.log('📥 Starting Schematron download...\n');
|
console.log('📥 Starting Schematron download...\n');
|
||||||
|
|
||||||
const downloader = new SchematronDownloader('assets/schematron');
|
const downloader = new SchematronDownloader('assets_downloaded/schematron');
|
||||||
await downloader.initialize();
|
await downloader.initialize();
|
||||||
|
|
||||||
// Download EN16931 Schematron files
|
// Download EN16931 Schematron files
|
||||||
|
@@ -49,7 +49,7 @@ function getFileChecksum(filePath: string): string | null {
|
|||||||
* Check if resources are already downloaded and valid
|
* Check if resources are already downloaded and valid
|
||||||
*/
|
*/
|
||||||
function checkExistingResources(): boolean {
|
function checkExistingResources(): boolean {
|
||||||
const versionFile = path.join('assets', 'schematron', '.version');
|
const versionFile = path.join('assets_downloaded', 'schematron', '.version');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!fs.existsSync(versionFile)) return false;
|
if (!fs.existsSync(versionFile)) return false;
|
||||||
@@ -62,9 +62,9 @@ function checkExistingResources(): boolean {
|
|||||||
|
|
||||||
// Check if key files exist
|
// Check if key files exist
|
||||||
const keyFiles = [
|
const keyFiles = [
|
||||||
'assets/schematron/EN16931-UBL-v1.3.14.sch',
|
'assets_downloaded/schematron/EN16931-UBL-v1.3.14.sch',
|
||||||
'assets/schematron/EN16931-CII-v1.3.14.sch',
|
'assets_downloaded/schematron/EN16931-CII-v1.3.14.sch',
|
||||||
'assets/schematron/PEPPOL-EN16931-UBL-v3.0.17.sch'
|
'assets_downloaded/schematron/PEPPOL-EN16931-UBL-v3.0.17.sch'
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const file of keyFiles) {
|
for (const file of keyFiles) {
|
||||||
@@ -84,7 +84,7 @@ function checkExistingResources(): boolean {
|
|||||||
* Save version file after successful download
|
* Save version file after successful download
|
||||||
*/
|
*/
|
||||||
function saveVersionFile(): void {
|
function saveVersionFile(): void {
|
||||||
const versionFile = path.join('assets', 'schematron', '.version');
|
const versionFile = path.join('assets_downloaded', 'schematron', '.version');
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(path.dirname(versionFile), { recursive: true });
|
fs.mkdirSync(path.dirname(versionFile), { recursive: true });
|
||||||
fs.writeFileSync(versionFile, RESOURCES_VERSION);
|
fs.writeFileSync(versionFile, RESOURCES_VERSION);
|
||||||
@@ -96,7 +96,7 @@ function saveVersionFile(): void {
|
|||||||
async function downloadSchematron() {
|
async function downloadSchematron() {
|
||||||
console.log('📥 Downloading Schematron validation files...\n');
|
console.log('📥 Downloading Schematron validation files...\n');
|
||||||
|
|
||||||
const downloader = new SchematronDownloader('assets/schematron');
|
const downloader = new SchematronDownloader('assets_downloaded/schematron');
|
||||||
await downloader.initialize();
|
await downloader.initialize();
|
||||||
|
|
||||||
let successCount = 0;
|
let successCount = 0;
|
||||||
|
Reference in New Issue
Block a user