Skip to content
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
6 changes: 6 additions & 0 deletions common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @simple-photo-gallery/common

## 2.2.1

### Patch Changes

- Fix bundled theme resolution when the CLI is invoked through a global npm binary symlink.

## 2.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@simple-photo-gallery/common",
"version": "2.2.0",
"version": "2.2.1",
"description": "Shared utilities and types for Simple Photo Gallery",
"license": "MIT",
"author": "Vladimir Haltakov, Tomasz Rusin",
Expand Down
9 changes: 9 additions & 0 deletions gallery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# simple-photo-gallery

## 2.2.1

### Patch Changes

- Fix bundled theme resolution when the CLI is invoked through a global npm binary symlink.
- Updated dependencies
- @simple-photo-gallery/common@2.2.1
- @simple-photo-gallery/theme-modern@2.2.1

## 2.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion gallery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-photo-gallery",
"version": "2.2.0",
"version": "2.2.1",
"description": "Simple Photo Gallery CLI",
"license": "MIT",
"author": "Vladimir Haltakov, Tomasz Rusin",
Expand Down
5 changes: 4 additions & 1 deletion gallery/src/modules/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,10 @@ function isLocalThemePath(theme: string): boolean {
}

function resolvePackageJsonPath(packageName: string): string {
const candidates = [path.join(process.cwd(), 'package.json'), process.argv[1]].filter(Boolean) as string[];
const cliPath = process.argv[1];
// Global npm bins are symlinks, so also resolve from the installed package's real path.
const installedCliPath = cliPath && fs.existsSync(cliPath) ? fs.realpathSync(cliPath) : undefined;
const candidates = [path.join(process.cwd(), 'package.json'), cliPath, installedCliPath].filter(Boolean) as string[];

for (const candidate of candidates) {
try {
Expand Down
27 changes: 26 additions & 1 deletion gallery/tests/cli-e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { execFileSync, spawnSync } from 'node:child_process';
import { copyFileSync, existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
import {
copyFileSync,
existsSync,
mkdirSync,
mkdtempSync,
readFileSync,
readdirSync,
rmSync,
symlinkSync,
writeFileSync,
} from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
Expand Down Expand Up @@ -486,4 +496,19 @@ describe('packaged CLI e2e smoke', () => {
expect(existsSync(path.join(themeDir, 'src', 'pages', 'index.astro'))).toBe(true);
expect(readdirSync(themeDir)).not.toContain('node_modules');
});

test('resolves the bundled theme when invoked through a global-style bin symlink', () => {
const installDir = makeTempDir('dist-global-install');
const binDir = path.join(installDir, 'bin');
const cliSymlinkPath = path.join(binDir, 'spg');
const galleryDir = makeTempDir('dist-global-gallery');
mkdirSync(binDir, { recursive: true });
symlinkSync(distCliPath, cliSymlinkPath);
copySingleFixture(galleryDir);

runCommand(process.execPath, [cliSymlinkPath, 'init', '--default'], { cwd: galleryDir });
runCommand(process.execPath, [cliSymlinkPath, 'build', '--no-scan', '--no-thumbnails'], { cwd: galleryDir });

expect(existsSync(path.join(galleryDir, 'index.html'))).toBe(true);
});
});
6 changes: 6 additions & 0 deletions themes/modern/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @simple-photo-gallery/theme-modern

## 2.2.1

### Patch Changes

- Fix bundled theme resolution when the CLI is invoked through a global npm binary symlink.

## 2.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion themes/modern/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@simple-photo-gallery/theme-modern",
"version": "2.2.0",
"version": "2.2.1",
"description": "Modern theme for Simple Photo Gallery",
"license": "MIT",
"author": "Vladimir Haltakov, Tomasz Rusin",
Expand Down
Loading