Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/scripts/artifacts/artifacts-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class ArtifactsHandler {
if (project.isPublishable) {
if (this.onlyDeleteArtifacts)
await project.deleteArtifact(
this.currentVersion
this.currentVersion, this.jfrogCredentials
);
else {
project.build();
Expand Down
20 changes: 17 additions & 3 deletions tools/scripts/artifacts/nx-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class NxProject {
return npmPackage.versions.includes(version);
}

public async deleteArtifact(version: Version) {
public async deleteArtifact(version: Version, jfrogCredentials: JfrogCredentials = null) {
console.log("Checking if package exists in registry");
const scopedPackage = `${this.scope}/${this.name}`;
if(!this.packageExists(scopedPackage, version.toString())) {
Expand All @@ -197,6 +197,16 @@ export class NxProject {
}@${version.toString()}`
);
try {
const pathToProjectInDist = this.getPathToProjectInDist();
if (!fs.existsSync(pathToProjectInDist) && jfrogCredentials) {
console.log(
`Path to project in dist does not exist, creating it: ${pathToProjectInDist}`
);
this.writeNPMRCInDist(jfrogCredentials, this.scope);
console.log(`Setting version in package.json for ${this.name} to ${version.toString()}`);
this.setVersionOrGeneratePackageJsonInDist(version, jfrogCredentials.url);
console.log(`Generated package.json: ${this.getPrettyPackageJson()}`);
}
console.log(
execSync(`npm unpublish ${this.scope}/${this.name}@${version.toString()}`, {
cwd: `${this.getPathToProjectInDist()}`,
Expand Down Expand Up @@ -229,8 +239,12 @@ export class NxProject {
this.npmrcContent +
`${jfrogCredentials.getJfrogUrlNoHttp()}:email=${jfrogCredentials.user}`;
console.log(this.npmrcContent + '\n\n');
fs.writeFileSync(this.getNpmrcPathInDist(), this.npmrcContent);
console.log('wrote .npmrc to: ' + this.getNpmrcPathInDist());
const npmrcPathInDist = this.getNpmrcPathInDist();
if(!fs.existsSync(npmrcPathInDist)){
fs.mkdirSync(path.dirname(npmrcPathInDist), { recursive: true });
}
fs.writeFileSync(npmrcPathInDist, this.npmrcContent);
console.log('wrote .npmrc to: ' + npmrcPathInDist);
}

public setVersionOrGeneratePackageJsonInDist(version: Version, registry: string) {
Expand Down