Skip to content

Commit

Permalink
Allow apps to be defined as installer in packaging_info
Browse files Browse the repository at this point in the history
  • Loading branch information
linuslundahl committed Sep 24, 2024
1 parent 6877e89 commit 282b682
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
4 changes: 3 additions & 1 deletion packages/common/src/entities/dbmss/dbmss.local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ export class LocalDbmss extends DbmssAbstract<LocalEnvironment> {
throw new DbmsExistsError(`DBMS with name "${name}" already exists`);
}

const installer = this.environment.name.replace('_', '');

// version as a file path.
if ((await fse.pathExists(version)) && (await fse.stat(version)).isFile()) {
const tmpPath = path.join(this.environment.dirPaths.tmp, uuidv4());
const {extractedDistPath} = await extractNeo4j(version, tmpPath);
const {extractedDistPath} = await extractNeo4j(version, tmpPath, installer);
const {version: semverVersion} = await getDistributionVersion(extractedDistPath);

const dbms = await this.installNeo4j(
Expand Down
23 changes: 22 additions & 1 deletion packages/common/src/utils/dbmss/extract-neo4j.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import fse from 'fs-extra';
import path from 'path';

import {HOOK_EVENTS} from '../../constants';
import {FileStructureError} from '../../errors';
import {IDbmsVersion} from '../../models';
Expand All @@ -9,9 +12,27 @@ interface IExtractedArchive extends IDbmsVersion {
extractedDistPath: string;
}

export const extractNeo4j = async (archivePath: string, outputDir: string): Promise<IExtractedArchive> => {
const addPackageInfo = async (dir: string, installer?: string) => {
if (installer === undefined) {
return;
}

const packageInfoFile = path.join(dir, 'packaging_info');
const packageInfo = await fse.readFile(packageInfoFile, 'utf8');
const newPackageInfo = packageInfo.replace(/Package Type: (.*)/gm, `Package Type: ${installer}`);
await fse.writeFile(packageInfoFile, newPackageInfo, 'utf8');
};

export const extractNeo4j = async (
archivePath: string,
outputDir: string,
installer?: string,
): Promise<IExtractedArchive> => {
await emitHookEvent(HOOK_EVENTS.NEO4J_EXTRACT_START, 'extracting neo4j');
const extractedDistPath = await extract(archivePath, outputDir);
await addPackageInfo(extractedDistPath, installer).catch(() => {
// Do nothing
});
await emitHookEvent(HOOK_EVENTS.NEO4J_EXTRACT_STOP, null);

// check if this is neo4j...
Expand Down

0 comments on commit 282b682

Please sign in to comment.