From f7a39c8ae3e95a9a66790d8898e5db50545f963f Mon Sep 17 00:00:00 2001 From: LucaZanni Date: Sat, 5 Dec 2026 22:36:33 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(ci):=20blocca=20i=20microfront?= =?UTF-8?q?end=20il=20cui=20dist=20importa=20ancora=20vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - passo dopo Build in quality-gates e docker-release, solo con dist/mfe-entry.js - ignora gli esempi nei commenti e si autoverifica su casi di prova Fixes #31 @1h30m Claude-Session: https://claude.ai/code/session_018fSA352dm2Px856dGvQfyq --- .gitea/workflows/docker-release.yml | 47 +++++++++++++++++++++++++++++ .gitea/workflows/quality-gates.yml | 47 +++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/.gitea/workflows/docker-release.yml b/.gitea/workflows/docker-release.yml index 7cfb676..b657b6c 100644 --- a/.gitea/workflows/docker-release.yml +++ b/.gitea/workflows/docker-release.yml @@ -69,6 +69,53 @@ jobs: timeout-minutes: 15 run: npm run build + - name: Microfrontend - nessun import di vue nel dist + timeout-minutes: 5 + shell: bash + # BLOCCANTE (devops/shared-actions#31). Nella shell un import di vue rimasto + # nel dist non si risolve e il modulo non si carica, con build e test verdi. + run: | + node - <<'FINE' + const fs = require('fs') + const path = require('path') + + // Solo i microfrontend: la shell fornisce vue, quindi nel loro dist non deve restarne un import. + if (!fs.existsSync('dist/mfe-entry.js')) { + console.log('Nessun dist/mfe-entry.js: controllo non applicabile.') + process.exit(0) + } + + // Ancorata a inizio riga, ';' o '}': un esempio in un commento (' * import ...') non e' un import. + const IMPORT = /(?:^|[;}])[ \t]*(?:import|export)\b[^;"'()=]*?(?:\bfrom\s*)?["'](?:vue|vue-router)["']/m + + const prove = [ + ['import "vue";', true], + ['var a=1;import{ref as r}from"vue";', true], + ["import {\n ref,\n} from 'vue'", true], + ['export * from "vue-router"', true], + [" * import { createApp } from 'vue'", false], + ['// import "vue"', false], + ['const s = "import x from \'vue\'"', false], + ['import{a}from"vue-i18n";', false], + ] + for (const [testo, atteso] of prove) { + if (IMPORT.test(testo) !== atteso) { + console.log(`::error::Controllo non affidabile: caso di prova fallito (${JSON.stringify(testo)}).`) + process.exit(1) + } + } + + const file = fs.readdirSync('dist', { recursive: true }).filter((f) => /\.m?js$/.test(f)) + const difettosi = file.filter((f) => IMPORT.test(fs.readFileSync(path.join('dist', f), 'utf8'))) + if (difettosi.length) { + console.log("::error::Il dist del microfrontend importa ancora 'vue' o 'vue-router': nella shell il modulo non si carica.") + for (const f of difettosi) console.log(' dist/' + f) + console.log('Controllare il plugin external-globals in vite.config: deve trattare anche l\'import senza nomi (import "vue";).') + process.exit(1) + } + console.log(`Nessun import di vue nel dist (${file.length} file JavaScript).`) + FINE + - name: Test timeout-minutes: 20 run: npm run test diff --git a/.gitea/workflows/quality-gates.yml b/.gitea/workflows/quality-gates.yml index 542ffcc..896e68d 100644 --- a/.gitea/workflows/quality-gates.yml +++ b/.gitea/workflows/quality-gates.yml @@ -541,6 +541,53 @@ jobs: timeout-minutes: 15 run: npm run build + - name: Microfrontend - nessun import di vue nel dist + timeout-minutes: 5 + shell: bash + # BLOCCANTE (devops/shared-actions#31). Nella shell un import di vue rimasto + # nel dist non si risolve e il modulo non si carica, con build e test verdi. + run: | + node - <<'FINE' + const fs = require('fs') + const path = require('path') + + // Solo i microfrontend: la shell fornisce vue, quindi nel loro dist non deve restarne un import. + if (!fs.existsSync('dist/mfe-entry.js')) { + console.log('Nessun dist/mfe-entry.js: controllo non applicabile.') + process.exit(0) + } + + // Ancorata a inizio riga, ';' o '}': un esempio in un commento (' * import ...') non e' un import. + const IMPORT = /(?:^|[;}])[ \t]*(?:import|export)\b[^;"'()=]*?(?:\bfrom\s*)?["'](?:vue|vue-router)["']/m + + const prove = [ + ['import "vue";', true], + ['var a=1;import{ref as r}from"vue";', true], + ["import {\n ref,\n} from 'vue'", true], + ['export * from "vue-router"', true], + [" * import { createApp } from 'vue'", false], + ['// import "vue"', false], + ['const s = "import x from \'vue\'"', false], + ['import{a}from"vue-i18n";', false], + ] + for (const [testo, atteso] of prove) { + if (IMPORT.test(testo) !== atteso) { + console.log(`::error::Controllo non affidabile: caso di prova fallito (${JSON.stringify(testo)}).`) + process.exit(1) + } + } + + const file = fs.readdirSync('dist', { recursive: true }).filter((f) => /\.m?js$/.test(f)) + const difettosi = file.filter((f) => IMPORT.test(fs.readFileSync(path.join('dist', f), 'utf8'))) + if (difettosi.length) { + console.log("::error::Il dist del microfrontend importa ancora 'vue' o 'vue-router': nella shell il modulo non si carica.") + for (const f of difettosi) console.log(' dist/' + f) + console.log('Controllare il plugin external-globals in vite.config: deve trattare anche l\'import senza nomi (import "vue";).') + process.exit(1) + } + console.log(`Nessun import di vue nel dist (${file.length} file JavaScript).`) + FINE + - name: Test timeout-minutes: 20 run: npm run test