Skip to content

Commit 642f4db

Browse files
committed
Ability to use package.json of nx project apps to make it publishable
1 parent b06446b commit 642f4db

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tools/scripts/artifacts/nx-project.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { JfrogCredentials } from './jfrog-credentials';
88
import { Version } from './version';
99
import { getJfrogUrl } from './configuration';
1010
import { NpmPackage } from './types';
11+
import { existsSync } from 'node:fs';
1112

1213
interface PackageJson {
1314
author: string;
@@ -56,6 +57,9 @@ export class NxProject {
5657
this.isPublishable = true;
5758
}
5859
} else {
60+
console.log(`Path to app package.json ${this.getPackageJsonPathInSource()}`);
61+
this.hasPackageJson = existsSync(this.getPackageJsonPathInSource());
62+
console.log(`App package.json exists ${this.hasPackageJson}`);
5963
this.isPublishable = true;
6064
}
6165
}
@@ -262,14 +266,22 @@ export class NxProject {
262266
console.log('wrote .npmrc to: ' + npmrcPathInDist);
263267
}
264268

269+
private getPackageJsonPath(): string{
270+
let packageJsonPath = this.getPackageJsonPathInDist();
271+
if(!existsSync(packageJsonPath)) {
272+
packageJsonPath = this.getPackageJsonPathInSource();
273+
}
274+
return packageJsonPath;
275+
}
276+
265277
public setVersionOrGeneratePackageJsonInDist(
266278
version: Version,
267279
registry: string
268280
) {
269281
if (this.hasPackageJson) {
270282
try {
271283
this.packageJsonContent = JSON.parse(
272-
fs.readFileSync(this.getPackageJsonPathInDist()).toString()
284+
fs.readFileSync(this.getPackageJsonPath()).toString()
273285
);
274286
this.packageJsonContent.author = 'squad-fe';
275287
this.packageJsonContent.version = version.toString();

0 commit comments

Comments
 (0)