Skip to content

Commit

Permalink
Version in pack output filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
andersnm committed Apr 23, 2019
1 parent 58965a6 commit 26fad31
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/blerf/src/commands/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class BundleEnumerator extends PackageEnumerator {

// NOTE: assuming file name of tarball; can also get it from the output of npm pack
const tempPath = fs.mkdtempSync(path.join(os.tmpdir(), "blerf-"));
const artifactPackTarPath = path.join(this.artifactPackPath, packageJson.name + ".tgz");
const artifactPackTarPath = path.join(this.artifactPackPath, packageJson.name + "-" + packageJson.version + ".tgz");
const artifactTarPath = path.join(this.artifactDeployPath, packageJson.name + "-" + packageJson.version + ".tgz");

fs.mkdirSync(this.artifactDeployPath, { recursive: true });
Expand Down
6 changes: 3 additions & 3 deletions packages/blerf/src/commands/pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class PackEnumerator extends PackageEnumerator {
const sourcePackageTarPath = path.join(packagePath, packageJson.name + "-" + packageJson.version + ".tgz");
const tempPath = fs.mkdtempSync(path.join(os.tmpdir(), "blerf-"));

const artifactPackTarPath = path.join(this.artifactPackPath, packageJson.name + ".tgz");
const artifactPackTarPath = path.join(this.artifactPackPath, packageJson.name + "-" + packageJson.version + ".tgz");

fs.mkdirSync(this.artifactPackPath, { recursive: true });

Expand All @@ -53,8 +53,8 @@ export class PackEnumerator extends PackageEnumerator {
// Resolve all file:-based dependencies to explicit versions
const packageJson = this.readPackageJson(packageJsonPath);
if (this.isDeploy) {
this.rewriteProjectReferencesFullPath(artifactPackFullPath, packageJson.dependencies, packages);
this.rewriteProjectReferencesFullPath(artifactPackFullPath, packageJson.devDependencies, packages);
this.rewriteProjectReferencesFullPathVersion(artifactPackFullPath, packageJson.dependencies, packages);
this.rewriteProjectReferencesFullPathVersion(artifactPackFullPath, packageJson.devDependencies, packages);
} else {
this.rewriteProjectReferencesVersion(packageJson.dependencies, packages);
this.rewriteProjectReferencesVersion(packageJson.devDependencies, packages);
Expand Down
16 changes: 16 additions & 0 deletions packages/blerf/src/packageEnumerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ export abstract class PackageEnumerator {
}
}

protected rewriteProjectReferencesFullPathVersion(artifactPackFullPath: string, packageDependencies: any, packages: PackagesType) {
if (!packageDependencies) {
return;
}

for (let dependencyName of Object.keys(packageDependencies)) {
const ref = packageDependencies[dependencyName];
if (!ref.startsWith("file:")) {
continue;
}

const dependencyPackageInfo = packages[dependencyName];
packageDependencies[dependencyName] = path.join(artifactPackFullPath, dependencyPackageInfo.packageJson.name + "-" + dependencyPackageInfo.packageJson.version + ".tgz");
}
}

protected rewriteProjectReferencesVersion(packageDependencies: any, packages: PackagesType) {
if (!packageDependencies) {
return;
Expand Down

0 comments on commit 26fad31

Please sign in to comment.