Skip to content

Commit b192b53

Browse files
committed
fix: port validation and only install ngx-build-plus when needed
1 parent 15371cd commit b192b53

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

libs/mf-runtime/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@angular-architects/module-federation-runtime",
33
"license": "MIT",
4-
"version": "14.2.1",
4+
"version": "14.2.2",
55
"peerDependencies": {
66
"@angular/common": ">=12.0.0",
77
"@angular/core": ">=12.0.0"

libs/mf-tools/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@angular-architects/module-federation-tools",
3-
"version": "14.2.1",
3+
"version": "14.2.2",
44
"license": "MIT",
55
"peerDependencies": {
66
"@angular/common": ">=11.0.0",
77
"@angular/core": ">=11.0.0",
88
"@angular/router": ">=11.0.0",
9-
"@angular-architects/module-federation": "^14.2.1",
9+
"@angular-architects/module-federation": "^14.2.2",
1010
"@angular/platform-browser": ">=11.0.0",
1111
"rxjs": ">= 6.0.0"
1212
},

libs/mf/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/module-federation",
3-
"version": "14.2.1",
3+
"version": "14.2.2",
44
"license": "MIT",
55
"repository": {
66
"type": "GitHub",
@@ -17,7 +17,7 @@
1717
"schematics": "./collection.json",
1818
"builders": "./builders.json",
1919
"dependencies": {
20-
"@angular-architects/module-federation-runtime": "14.2.1",
20+
"@angular-architects/module-federation-runtime": "14.2.2",
2121
"word-wrap": "^1.2.3",
2222
"callsite": "^1.0.0",
2323
"node-fetch": "^2.6.7",

libs/mf/src/schematics/mf/schema.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface MfSchematicSchema {
22
project: string;
3-
port: number;
3+
port: string;
44
nxBuilders: boolean | undefined;
55
}

libs/mf/src/schematics/mf/schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"x-prompt": "Project name (press enter for default project)"
1515
},
1616
"port": {
17-
"type": "number",
17+
"type": "string",
1818
"description": "The port to use for the federated module (remote, micro frontend, etc.)",
1919
"x-prompt": "Port to use",
2020
"$default": {

libs/mf/src/schematics/mf/schematic.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import { createConfig } from '../../utils/create-config';
1616
import { prodConfig } from './prod-config';
1717
import { MfSchematicSchema } from './schema';
1818

19-
import { addPackageJsonDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';
20-
import { hostname } from 'os';
19+
import { addPackageJsonDependency, getPackageJsonDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';
2120

2221
// export async function npmInstall(packageName: string) {
2322
// await new Promise<boolean>((resolve) => {
@@ -192,7 +191,7 @@ export default function config (options: MfSchematicSchema): Rule {
192191

193192
const configPath = path.join(projectRoot, 'webpack.config.js').replace(/\\/g, '/');
194193
const configProdPath = path.join(projectRoot, 'webpack.prod.config.js').replace(/\\/g, '/');
195-
const port = options.port;
194+
const port = parseInt(options.port);
196195
const main = projectConfig.architect.build.options.main;
197196

198197
const relWorkspaceRoot = path.relative(projectRoot, '');
@@ -285,14 +284,19 @@ export default function config (options: MfSchematicSchema): Rule {
285284

286285
updatePackageJson(tree);
287286

288-
addPackageJsonDependency(tree, {
289-
name: 'ngx-build-plus',
290-
type: NodeDependencyType.Dev,
291-
version: '^13.0.1',
292-
overwrite: true
293-
});
294287

295-
context.addTask(new NodePackageInstallTask());
288+
const dep = getPackageJsonDependency(tree, "ngx-build-plus");
289+
290+
if (!dep) {
291+
addPackageJsonDependency(tree, {
292+
name: 'ngx-build-plus',
293+
type: NodeDependencyType.Dev,
294+
version: '^13.0.1',
295+
overwrite: true
296+
});
297+
298+
context.addTask(new NodePackageInstallTask());
299+
}
296300

297301
return chain([
298302
makeMainAsync(main),

0 commit comments

Comments
 (0)