This commit is contained in:
		
							parent
							
								
									a75e6d6b95
								
							
						
					
					
						commit
						9b59e98470
					
				
							
								
								
									
										1
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							@ -19,6 +19,7 @@ jobs:
 | 
				
			|||||||
            - run: npm run lint:ci
 | 
					            - run: npm run lint:ci
 | 
				
			||||||
            - run: npm run prettier
 | 
					            - run: npm run prettier
 | 
				
			||||||
            - run: npm run update-translations
 | 
					            - run: npm run update-translations
 | 
				
			||||||
 | 
					            - run: npm run fix-imports
 | 
				
			||||||
            - name: Fail if there are uncommitted changes
 | 
					            - name: Fail if there are uncommitted changes
 | 
				
			||||||
              run: |
 | 
					              run: |
 | 
				
			||||||
                  if [[ -n "$(git status --porcelain)" ]]; then
 | 
					                  if [[ -n "$(git status --porcelain)" ]]; then
 | 
				
			||||||
 | 
				
			|||||||
@ -19,7 +19,8 @@
 | 
				
			|||||||
    "lint:ci": "eslint --ext .ts --rule \"prettier/prettier: off\" .",
 | 
					    "lint:ci": "eslint --ext .ts --rule \"prettier/prettier: off\" .",
 | 
				
			||||||
    "lint:fix": "eslint --fix --ext .ts .",
 | 
					    "lint:fix": "eslint --fix --ext .ts .",
 | 
				
			||||||
    "prettier": "prettier --write .",
 | 
					    "prettier": "prettier --write .",
 | 
				
			||||||
    "update-translations": "cd scripts && node update-translations.js"
 | 
					    "update-translations": "cd scripts && node update-translations.js",
 | 
				
			||||||
 | 
					    "fix-imports": "cd scripts && node fix-imports.js"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "license": "GNU",
 | 
					  "license": "GNU",
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										46
									
								
								scripts/fix-imports.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								scripts/fix-imports.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					/* eslint-disable */
 | 
				
			||||||
 | 
					const fs = require("fs");
 | 
				
			||||||
 | 
					const path = require("path");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const root = path.join(process.cwd(), "..");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function listFiles(dir) {
 | 
				
			||||||
 | 
					    const entries = fs.readdirSync(dir, { withFileTypes: true });
 | 
				
			||||||
 | 
					    let results = [];
 | 
				
			||||||
 | 
					    for (const entry of entries) {
 | 
				
			||||||
 | 
					        const fullPath = path.join(dir, entry.name);
 | 
				
			||||||
 | 
					        if (entry.isDirectory()) {
 | 
				
			||||||
 | 
					            results = results.concat(listFiles(fullPath));
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            results.push(fullPath);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return results;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const files = listFiles(path.join(root, "src"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for (const file of files) {
 | 
				
			||||||
 | 
					    let content;
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        content = fs.readFileSync(file, "utf8");
 | 
				
			||||||
 | 
					    } catch (e) {
 | 
				
			||||||
 | 
					        continue;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    const dir = path.dirname(file);
 | 
				
			||||||
 | 
					    const fixedContent = content.replaceAll(/} from "([^"]+)";/g, (sub, importPath) => {
 | 
				
			||||||
 | 
					        if (!importPath.startsWith("@/")) {
 | 
				
			||||||
 | 
					            const fullImportPath = path.resolve(dir, importPath);
 | 
				
			||||||
 | 
					            if (fs.existsSync(fullImportPath + ".ts")) {
 | 
				
			||||||
 | 
					                const relative = path.relative(root, fullImportPath).replace(/\\/g, "/");
 | 
				
			||||||
 | 
					                const fixedPath = "@/" + relative;
 | 
				
			||||||
 | 
					                console.log(`${importPath} -> ${fixedPath}`);
 | 
				
			||||||
 | 
					                return sub.split(importPath).join(fixedPath);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return sub;
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    if (content != fixedContent) {
 | 
				
			||||||
 | 
					        fs.writeFileSync(file, fixedContent, "utf8");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user