This commit is contained in:
Evert Prants 2020-11-28 22:27:05 +02:00
parent 7ee67544e5
commit a86b912520
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
6 changed files with 15 additions and 14 deletions

3
.npmignore Normal file
View File

@ -0,0 +1,3 @@
/src/
/tsconfig.json
/tslint.json

View File

@ -19,13 +19,13 @@
"devDependencies": { "devDependencies": {
"@types/dateformat": "^3.0.1", "@types/dateformat": "^3.0.1",
"@types/fs-extra": "^9.0.4", "@types/fs-extra": "^9.0.4",
"@types/semver": "^7.3.4",
"@types/node": "^14.14.9", "@types/node": "^14.14.9",
"@types/tar": "^4.0.4", "@types/tar": "^4.0.4",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"typescript": "^4.0.5" "typescript": "^4.0.5"
}, },
"dependencies": { "dependencies": {
"@types/semver": "^7.3.4",
"dateformat": "^4.0.0", "dateformat": "^4.0.0",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",
"semver": "^7.3.2", "semver": "^7.3.2",

View File

@ -49,7 +49,7 @@ export class PluginManager {
} }
public getLoaded(): IPlugin[] { public getLoaded(): IPlugin[] {
const list = [] const list = [];
for (const pl of this.plugins.values()) { for (const pl of this.plugins.values()) {
list.push(pl); list.push(pl);
} }

View File

@ -1,2 +1,2 @@
export * from './manager'; export * from './manager';
export * from './repository'; export * from './repository';

View File

@ -7,10 +7,10 @@ import tar from 'tar';
import { httpGET } from '../../common'; import { httpGET } from '../../common';
import { logger } from '../../core'; import { logger } from '../../core';
import { IEnvironment } from "../../types"; import { IEnvironment } from '../../types';
import { PluginManager } from '../manager'; import { PluginManager } from '../manager';
import { IPlugin, IPluginManifest } from "../plugin"; import { IPlugin, IPluginManifest } from '../plugin';
import { IRepoPluginDef, IRepository } from "./repository"; import { IRepoPluginDef, IRepository } from './repository';
export class RepositoryManager { export class RepositoryManager {
private repositories: Map<string, IRepository> = new Map(); private repositories: Map<string, IRepository> = new Map();
@ -52,7 +52,7 @@ export class RepositoryManager {
} }
public getAll(): IRepository[] { public getAll(): IRepository[] {
const list = [] const list = [];
for (const irep of this.repositories.values()) { for (const irep of this.repositories.values()) {
list.push(irep); list.push(irep);
} }
@ -69,7 +69,7 @@ export class RepositoryManager {
const pluginPath = repo.url + '/' + srcFile; const pluginPath = repo.url + '/' + srcFile;
const tempdir = path.join(this.env.path, await fs.mkdtemp('.sbdl')); const tempdir = path.join(this.env.path, await fs.mkdtemp('.sbdl'));
const tempfile = path.join(tempdir, srcFile); const tempfile = path.join(tempdir, srcFile);
let manifest let manifest;
try { try {
const save = await httpGET(pluginPath, {}, false, tempfile); const save = await httpGET(pluginPath, {}, false, tempfile);
@ -153,7 +153,7 @@ export class RepositoryManager {
remote.url = urlParsed.href; remote.url = urlParsed.href;
await fs.writeJSON(local, remote); await fs.writeJSON(local, remote);
this.repositories.set(remote.name, remote); this.repositories.set(remote.name, remote);
return remote; return remote;
} }
@ -185,7 +185,7 @@ export class RepositoryManager {
// Checking for version differences in the plugins // Checking for version differences in the plugins
// Get locally installed plugins // Get locally installed plugins
let needsUpdates: IPluginManifest[] = []; const needsUpdates: IPluginManifest[] = [];
for (const avail of this.plugins.availablePlugins) { for (const avail of this.plugins.availablePlugins) {
const repoPlugin = this.repoProvidesPlugin(oprep, avail); const repoPlugin = this.repoProvidesPlugin(oprep, avail);
if (repoPlugin) { if (repoPlugin) {
@ -220,7 +220,7 @@ export class RepositoryManager {
public async loadFromFiles(): Promise<void> { public async loadFromFiles(): Promise<void> {
const repos = await fs.readdir(this.env.repositoryPath); const repos = await fs.readdir(this.env.repositoryPath);
let loaded = []; const loaded = [];
for (const rf of repos) { for (const rf of repos) {
const file = path.join(this.env.repositoryPath, rf); const file = path.join(this.env.repositoryPath, rf);
try { try {

View File

@ -1,5 +1,3 @@
import { IPluginManifest } from "../plugin";
export interface IRepoPluginDef { export interface IRepoPluginDef {
name: string; name: string;
version: string; version: string;
@ -11,4 +9,4 @@ export interface IRepository {
url: string; url: string;
plugins: IRepoPluginDef[]; plugins: IRepoPluginDef[];
schema: number; schema: number;
} }