Skip to content

Commit

Permalink
Allow apps to be defined as installer in packaging_info (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
linuslundahl authored Sep 26, 2024
1 parent 6877e89 commit 2927542
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
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 2927542

Please sign in to comment.