Skip to content
Draft
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
7 changes: 0 additions & 7 deletions build-tools/build-pro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ function use_git {

function cleanup {
if use_git; then
echo -e "\n📦 Restoring core files"
pushd core
git restore .
popd
echo -e "\n📦 Restoring package-lock.json"
git restore package-lock.json
echo -e "\n📦 Removing npm-shrinkwrap.json"
Expand All @@ -37,9 +33,6 @@ fi
echo -e "\n📦 Installing production deps"
npm ci

echo -e "\n📦 Applying Harper Pro branding"
perl -pi -e 's/Harper/Harper Pro/g' ./core/bin/*.js ./core/utility/install/installer.js

echo -e "\n📦 Building project"
npm run build || true

Expand Down
9 changes: 5 additions & 4 deletions cloneNode/cloneNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { decode as cborDecode } from 'cbor-x';
import * as envMgr from '../core/utility/environment/environmentManager.js';
import * as logger from '../core/utility/logging/harper_logger.js';
import { isHdbInstalled } from '../core/utility/installation.js';
import { PRODUCT_NAME } from '../core/utility/packageUtils.js';
import { getConfiguration, flattenConfig, createConfigFile, updateConfigValue } from '../core/config/configUtils.js';
import { composeConfigFromEnv } from '../core/config/harperConfigEnvVars.ts';
import assignCMDENVVariables from '../core/utility/assignCmdEnvVariables.js';
Expand Down Expand Up @@ -264,7 +265,7 @@ export async function cloneNode(): Promise<void> {

// If not a fresh clone, and the existing config shows the instance is already cloned, skip clone process and start normally
if (hdbConfig?.cloned && !forceClone) {
log('Skipping clone, instance already marked as cloned. Starting Harper.');
log(`Skipping clone, instance already marked as cloned. Starting ${PRODUCT_NAME}.`);
envMgr.initSync();
const { main } = await import('../core/bin/run.js');
return main();
Expand Down Expand Up @@ -1462,7 +1463,7 @@ function log(message: string, level: LogLevel = 'notify'): void {
* Installs Harper as the base for the clone operation
*/
async function installHarper(): Promise<void> {
log(`Clone installing Harper at root path: ${rootPath}`);
log(`Clone installing ${PRODUCT_NAME} at root path: ${rootPath}`);

if (usingCertAuth || leaderToken) {
// Set temporary admin credentials if cloning without username/password to allow installation to complete.
Expand Down Expand Up @@ -1601,7 +1602,7 @@ function resolveRootPath(): void {
freshClone = true;
}
} else if (isHdbInstalled(envMgr, logger)) {
log('Existing Harper install found, getting default root path from config');
log(`Existing ${PRODUCT_NAME} install found, getting default root path from config`);
try {
// getConfiguration will get the config file name from the boot properties file and then read the harperdb-config file
const config: Record<string, any> = getConfiguration();
Expand All @@ -1612,7 +1613,7 @@ function resolveRootPath(): void {
);
}
} else {
log('No Harper install found, starting fresh clone');
log(`No ${PRODUCT_NAME} install found, starting fresh clone`);
freshClone = true;
rootPath = join(homedir(), HDB_ROOT_DIR_NAME);
log(`Using default root path: ${rootPath}`);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@harperfast/harper-pro",
"productName": "Harper Pro",
"version": "5.3.1",
"description": "Harper is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use. Harper Pro includes replication, certificate management, profiling.",
"keywords": [
Expand Down
55 changes: 55 additions & 0 deletions unitTests/bin/productName.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Core names the product from the nearest package.json above its packageUtils.js; a shipped
// manifest on that path (e.g. dist/core/package.json) would silently rebrand Harper Pro as "Harper".
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { createRequire } from 'node:module';
import { mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';

const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');

describe('Harper Pro product name', () => {
it('is the PRODUCT_NAME of the compiled core', () => {
const { PRODUCT_NAME } = createRequire(import.meta.url)(join(REPO_ROOT, 'dist/core/utility/packageUtils.js'));
assert.equal(PRODUCT_NAME, 'Harper Pro');
});

it('names the product in the CLI output', function () {
this.timeout(30_000);
const home = mkdtempSync(join(tmpdir(), 'harper-pro-help-'));
try {
const output = execFileSync(process.execPath, [join(REPO_ROOT, 'dist/bin/harper.js'), 'help'], {
encoding: 'utf8',
env: { ...process.env, HOME: home },
timeout: 25_000,
});
assert.match(output, /harper will simply run Harper Pro \(in the foreground\)/);
} finally {
rmSync(home, { recursive: true, force: true, maxRetries: 5 });
}
});

it('is not shadowed by a package.json the published core resolves first', function () {
this.timeout(60_000);
const [{ files }] = JSON.parse(
execFileSync('npm', ['pack', '--dry-run', '--json', '--ignore-scripts'], {
cwd: REPO_ROOT,
encoding: 'utf8',
timeout: 55_000,
})
);
Comment on lines +36 to +42

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

On Windows, npm is a command/batch file (npm.cmd) rather than a direct binary executable. Calling execFileSync('npm', ...) directly without a shell on Windows will result in an ENOENT error. To ensure cross-platform compatibility for the test suite, we should resolve the correct command name based on the platform.

		const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
		const [{ files }] = JSON.parse(
			execFileSync(npmCmd, ['pack', '--dry-run', '--json', '--ignore-scripts'], {
				cwd: REPO_ROOT,
				encoding: 'utf8',
				timeout: 55_000,
			})
		);

const lookupPath = [
'dist/core/utility/package.json',
'dist/core/package.json',
'dist/package.json',
'core/utility/package.json',
'core/package.json',
];
assert.deepEqual(
files.map(({ path }) => path).filter((path) => lookupPath.includes(path)),
[]
);
});
});
Loading