From 097c80911608542194752eb90b973d9f4f3f016d Mon Sep 17 00:00:00 2001 From: Manfred Steyer Date: Tue, 27 Aug 2024 21:37:50 +0200 Subject: [PATCH] fix(nf): correctly check for public directory in init schematic --- libs/native-federation/package.json | 2 +- libs/native-federation/src/builders/build/builder.ts | 2 +- libs/native-federation/src/patch-angular-build.ts | 4 +++- libs/native-federation/src/schematics/init/schematic.ts | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/native-federation/package.json b/libs/native-federation/package.json index 455edbe..05cd883 100644 --- a/libs/native-federation/package.json +++ b/libs/native-federation/package.json @@ -1,6 +1,6 @@ { "name": "@angular-architects/native-federation", - "version": "18.1.2", + "version": "18.1.3", "main": "src/index.js", "generators": "./collection.json", "builders": "./builders.json", diff --git a/libs/native-federation/src/builders/build/builder.ts b/libs/native-federation/src/builders/build/builder.ts index 4154d22..06d1b54 100644 --- a/libs/native-federation/src/builders/build/builder.ts +++ b/libs/native-federation/src/builders/build/builder.ts @@ -191,7 +191,7 @@ export async function* runBuilder( fedOptions.outputPath, url ); - + const exists = fs.existsSync(fileName); if (url !== '/' && url !== '' && exists) { diff --git a/libs/native-federation/src/patch-angular-build.ts b/libs/native-federation/src/patch-angular-build.ts index ea4723f..a1bd97f 100644 --- a/libs/native-federation/src/patch-angular-build.ts +++ b/libs/native-federation/src/patch-angular-build.ts @@ -3,4 +3,6 @@ // const workspaceRoot = process.cwd(); // patchAngularBuild(workspaceRoot); -console.log('Please remove the postbuild task calling patch-angular-build. This is not needed since Native Federation 18.1 anymore!'); \ No newline at end of file +console.log( + 'Please remove the postbuild task calling patch-angular-build. This is not needed since Native Federation 18.1 anymore!' +); diff --git a/libs/native-federation/src/schematics/init/schematic.ts b/libs/native-federation/src/schematics/init/schematic.ts index c170ac5..82a87b5 100644 --- a/libs/native-federation/src/schematics/init/schematic.ts +++ b/libs/native-federation/src/schematics/init/schematic.ts @@ -283,7 +283,9 @@ function normalizeOptions( let manifestRelPath = 'public/federation.manifest.json'; - if (!tree.exists(publicPath)) { + const hasPublicFolder = tree.getDir(projectRoot).subdirs.map(p => String(p)).includes('public'); + + if (!hasPublicFolder) { manifestPath = path .join(projectRoot, 'src/assets/federation.manifest.json') .replace(/\\/g, '/');