Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow apps to be defined as installer in packaging_info #516

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading