simple-photo-gallery 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,6 @@ import { execSync } from 'node:child_process';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import process from 'node:process';
5
- import { resolveFromCurrentDir } from './utils';
6
5
  import { findGalleries } from '../../utils';
7
6
  function buildGallery(galleryDir, templateDir) {
8
7
  // Make sure the gallery.json file exists
@@ -17,7 +16,7 @@ function buildGallery(galleryDir, templateDir) {
17
16
  // Set the environment variable for the gallery.json path that will be used by the template
18
17
  process.env.GALLERY_JSON_PATH = galleryJsonPath;
19
18
  process.env.GALLERY_OUTPUT_DIR = path.join(galleryDir, 'gallery');
20
- execSync('npm run build', { cwd: templateDir, stdio: 'inherit' });
19
+ execSync('yarn build', { cwd: templateDir, stdio: 'inherit' });
21
20
  }
22
21
  catch (error) {
23
22
  console.error(error);
@@ -41,7 +40,9 @@ function buildGallery(galleryDir, templateDir) {
41
40
  }
42
41
  export async function build(options) {
43
42
  // Get the template directory
44
- const templateDir = path.join(resolveFromCurrentDir('../../../../../'), 'template');
43
+ // Resolve the theme-modern package directory
44
+ const themePath = await import.meta.resolve('@simple-photo-gallery/theme-modern/package.json');
45
+ const themeDir = path.dirname(new URL(themePath).pathname);
45
46
  // Find all gallery directories
46
47
  const galleryDirs = findGalleries(options.path, options.recursive);
47
48
  // If no galleries are found, exit
@@ -51,6 +52,6 @@ export async function build(options) {
51
52
  }
52
53
  // Process each gallery
53
54
  for (const dir of galleryDirs) {
54
- buildGallery(dir, templateDir);
55
+ buildGallery(path.resolve(dir), themeDir);
55
56
  }
56
57
  }
@@ -5,7 +5,7 @@ import process from 'node:process';
5
5
  import { copySync } from 'fs-extra';
6
6
  import { GalleryDataSchema, MediaFileSchema, ThumbnailSchema } from '../src/types';
7
7
  const testDir = process.cwd();
8
- const tsxPath = path.resolve(testDir, 'node_modules', '.bin', 'tsx');
8
+ const tsxPath = path.resolve(testDir, '..', 'node_modules', '.bin', 'tsx');
9
9
  const cliPath = path.resolve(testDir, 'src', 'index.ts');
10
10
  const singleFixturePath = path.resolve(testDir, 'tests', 'fixtures', 'single');
11
11
  const singleTestPath = path.resolve(testDir, 'tests', 'fixtures', 'test', 'single');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-photo-gallery",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Simple Photo Gallery CLI",
5
5
  "license": "MIT",
6
6
  "author": "Vladimir Haltakov, Tomasz Rusin",
@@ -14,7 +14,7 @@
14
14
  "src"
15
15
  ],
16
16
  "bin": {
17
- "gallery": "./dist/index.js"
17
+ "simple-photo-gallery": "./dist/index.js"
18
18
  },
19
19
  "scripts": {
20
20
  "gallery": "tsx src/index.ts",
@@ -24,7 +24,8 @@
24
24
  "lint:fix": "eslint . --fix",
25
25
  "format": "prettier --write .",
26
26
  "format:fix": "prettier --write .",
27
- "test": "jest"
27
+ "test": "jest",
28
+ "prepublish": "npm run build"
28
29
  },
29
30
  "dependencies": {
30
31
  "@simple-photo-gallery/theme-modern": "0.0.1",