diff --git a/src/cli/init.ts b/src/cli/init.ts index b5b36fa..3c53f09 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -4,23 +4,24 @@ import { Argv, Arguments } from 'yargs'; import os from 'node:os'; import { exec } from 'node:child_process'; -import { access, mkdir, stat, readFile, writeFile } from 'node:fs/promises'; +import { access, mkdir, stat, readFile, writeFile, appendFile } from 'node:fs/promises'; import path from 'node:path'; import log, { Logger } from '../logger.js'; import { checkPackageJsonForNextVideo, updateTSConfigFileContent } from './lib/json-configs.js'; import updateNextConfigFile from './lib/next-config.js'; -const GITIGNORE_CONTENTS = `* -!*.json -!*.js -!*.ts`; - const TYPES_FILE_CONTENTS = `/// \n`; - const DEFAULT_DIR = 'videos'; const DEV_SCRIPT = '& npx next-video sync -w'; +const gitIgnoreContents = (videosDir: string) => ` +${videosDir}/* +${videosDir}/!*.json +${videosDir}/!*.js +${videosDir}/!*.ts +public/_next-video`; + async function preInitCheck(dir: string) { try { await stat(dir); @@ -75,7 +76,7 @@ async function createVideoDir(dir: string) { const fullPath = path.join(process.cwd(), dir); await mkdir(fullPath, { recursive: true }); - await writeFile(path.join(dir, '.gitignore'), GITIGNORE_CONTENTS); + await appendFile('.gitignore', gitIgnoreContents(dir)); return; } diff --git a/src/components/utils.ts b/src/components/utils.ts index 8489c58..57c3546 100644 --- a/src/components/utils.ts +++ b/src/components/utils.ts @@ -13,7 +13,7 @@ const FILES_FOLDER = `${config.folder ?? 'videos'}/`; export const toSymlinkPath = (path?: string) => { if (!path?.startsWith(FILES_FOLDER)) return path; - return path?.replace(FILES_FOLDER, `_${FILES_FOLDER}`); + return path?.replace(FILES_FOLDER, `_next-video/`); } // Note: doesn't get updated when the callback function changes diff --git a/src/components/video.tsx b/src/components/video.tsx index 467afdb..33df029 100644 --- a/src/components/video.tsx +++ b/src/components/video.tsx @@ -127,3 +127,9 @@ export function getVideoProps(allProps: VideoProps, state: { asset?: Asset }) { } export default NextVideo; + +export type { + VideoLoaderProps, + VideoProps, + DefaultPlayerProps, +}; diff --git a/src/with-next-video.ts b/src/with-next-video.ts index 0a38164..143a02d 100644 --- a/src/with-next-video.ts +++ b/src/with-next-video.ts @@ -27,7 +27,7 @@ export default async function withNextVideo(nextConfig: any, videoConfig: VideoC env['NEXT_PUBLIC_DEV_VIDEO_OPTS'] = JSON.stringify({ path, folder }); const VIDEOS_PATH = join(process.cwd(), folder) - const TMP_PUBLIC_VIDEOS_PATH = join(process.cwd(), 'public', `_${folder}`); + const TMP_PUBLIC_VIDEOS_PATH = join(process.cwd(), 'public', `_next-video`); await symlinkDir(VIDEOS_PATH, TMP_PUBLIC_VIDEOS_PATH);