-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pack to ./artifacts, implemented pack:deploy
- Loading branch information
Showing
7 changed files
with
121 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as os from 'os'; | ||
import * as childProcess from 'child_process'; | ||
import { PackageEnumerator, PackagesType } from "../packageEnumerator"; | ||
const tar = require('tar') | ||
|
||
export class BundleEnumerator extends PackageEnumerator { | ||
private artifactPackPath: string; | ||
private artifactDeployPath: string; | ||
|
||
constructor(rootPath: string, artifactPackPath: string, artifactDeployPath: string) { | ||
super(rootPath); | ||
this.artifactPackPath = artifactPackPath; | ||
this.artifactDeployPath = artifactDeployPath; | ||
} | ||
|
||
public async enumeratePackages(): Promise<void> { | ||
await super.enumeratePackages(); | ||
|
||
// Remove artifacts/deploy-temp created by PackEnumerator | ||
this.rimraf(this.artifactPackPath); | ||
} | ||
|
||
protected async processPackage(packagePath: string, packageJson: any, packages: PackagesType): Promise<void> { | ||
console.log("blerf: bundling node_modules"); | ||
|
||
// 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 + "-" + packageJson.version + ".tgz"); | ||
const artifactTarPath = path.join(this.artifactDeployPath, packageJson.name + "-" + packageJson.version + ".tgz"); | ||
|
||
fs.mkdirSync(this.artifactDeployPath, { recursive: true }); | ||
|
||
try { | ||
tar.extract({ file: artifactPackTarPath, cwd: tempPath, sync: true }); | ||
childProcess.execSync("npm install", {stdio: 'inherit', cwd: path.join(tempPath, "package") }); | ||
|
||
tar.create({ file: artifactTarPath, cwd: tempPath, gzip: true, sync: true, }, ["package"]); | ||
} finally { | ||
this.rimraf(tempPath); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters