-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): install plugins from local tarballs
- Loading branch information
Brian Faust
committed
Oct 9, 2019
1 parent
2d5ea1a
commit 8f7d0d3
Showing
8 changed files
with
75 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
} | ||
extends: ["@commitlint/config-conventional"], | ||
}; |
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,47 @@ | ||
import { Paths } from "env-paths"; | ||
import { existsSync } from "fs"; | ||
import { ensureDirSync, moveSync, removeSync } from "fs-extra"; | ||
import { parse } from "path"; | ||
import { extract } from "tar"; | ||
|
||
import { Source } from "./contracts"; | ||
|
||
export class File implements Source { | ||
private readonly dataPath: string; | ||
|
||
public constructor(private readonly paths: Paths) { | ||
this.dataPath = `${this.paths.data}/plugins`; | ||
|
||
ensureDirSync(this.dataPath); | ||
} | ||
|
||
public async exists(value: string): Promise<boolean> { | ||
return existsSync(value); | ||
} | ||
|
||
public async install(value: string): Promise<void> { | ||
await this.extractPackage(value); | ||
|
||
removeSync(value); | ||
} | ||
|
||
public async update(value: string): Promise<void> { | ||
await this.install(value); | ||
} | ||
|
||
private async extractPackage(file: string): Promise<void> { | ||
removeSync(this.getTargetPath(file)); | ||
|
||
await extract({ | ||
gzip: true, | ||
file, | ||
cwd: this.dataPath, | ||
}); | ||
|
||
moveSync(`${this.dataPath}/package`, this.getTargetPath(file)); | ||
} | ||
|
||
private getTargetPath(value: string): string { | ||
return `${this.dataPath}/${parse(value).name.replace(":", "/")}`; | ||
} | ||
} |
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,5 @@ | ||
export * from "./blockchain"; | ||
export * from "./contracts"; | ||
export * from "./file"; | ||
export * from "./git"; | ||
export * from "./npm"; |
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