From 8e51b8ed68b4d4aacb7d26d5af422720c3995b3c Mon Sep 17 00:00:00 2001 From: Linus Lundahl Date: Thu, 19 Sep 2024 13:38:33 +0200 Subject: [PATCH] Allow apps to be defined as installer in packaging_info --- .github/workflows/setup/action.yml | 2 +- .nvmrc | 2 +- .../common/src/entities/dbmss/dbmss.local.ts | 4 +++- .../common/src/utils/dbmss/extract-neo4j.ts | 23 ++++++++++++++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/setup/action.yml b/.github/workflows/setup/action.yml index fdb22f828..63e677db2 100644 --- a/.github/workflows/setup/action.yml +++ b/.github/workflows/setup/action.yml @@ -18,7 +18,7 @@ runs: with: node-version: ${{ inputs.NODE_VERSION }} - - uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd # v2.2.4 + - uses: pnpm/action-setup@v4 # v4 id: pnpm-install with: version: ${{ inputs.PNPM_VERSION }} diff --git a/.nvmrc b/.nvmrc index 3c032078a..209e3ef4b 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -18 +20 diff --git a/packages/common/src/entities/dbmss/dbmss.local.ts b/packages/common/src/entities/dbmss/dbmss.local.ts index fb03ff2a8..1fc2ed714 100644 --- a/packages/common/src/entities/dbmss/dbmss.local.ts +++ b/packages/common/src/entities/dbmss/dbmss.local.ts @@ -137,10 +137,12 @@ export class LocalDbmss extends DbmssAbstract { 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( diff --git a/packages/common/src/utils/dbmss/extract-neo4j.ts b/packages/common/src/utils/dbmss/extract-neo4j.ts index 1a80c187d..e92da8dce 100644 --- a/packages/common/src/utils/dbmss/extract-neo4j.ts +++ b/packages/common/src/utils/dbmss/extract-neo4j.ts @@ -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'; @@ -9,9 +12,27 @@ interface IExtractedArchive extends IDbmsVersion { extractedDistPath: string; } -export const extractNeo4j = async (archivePath: string, outputDir: string): Promise => { +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 => { 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...