diff --git a/src/constants.ts b/src/constants.ts index b7263e7..137e553 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -38,3 +38,5 @@ export const EMPTY_SPACE = ' '; export const PRO_EXTENSION = `.pro`; export const MANIFEST_FILE_NAME = 'manifest.json'; + +export const DS_STORE_FILE = '.DS_Store'; diff --git a/src/converterService.ts b/src/converterService.ts index 6cae53d..f93fc98 100644 --- a/src/converterService.ts +++ b/src/converterService.ts @@ -1,12 +1,18 @@ import fs from 'fs'; import path from 'path'; import { isEqual } from 'lodash'; +import recursive from 'recursive-readdir'; import { Presentation } from '../proto/presentation'; import { Config, convertSongToProPresenter7, } from './proPresenter7SongConverter'; -import { MANIFEST_FILE_NAME, PRO_EXTENSION, TXT_EXTENSION } from './constants'; +import { + DS_STORE_FILE, + MANIFEST_FILE_NAME, + PRO_EXTENSION, + TXT_EXTENSION, +} from './constants'; import { getClosestVersionedDir, getVersionedDir, @@ -18,7 +24,6 @@ import { SongManifest, SongsInventoryManifest, } from './types'; -import recursive from 'recursive-readdir'; import { parseSong } from './songsParser'; import { generateManifest } from './manifestGenerator'; @@ -116,7 +121,7 @@ export const getSongDiffFromManifest = ( }; export const getDeployableSongs = async (sourceDir: string) => - (await recursive(sourceDir, ['.DS_Store'])).map((filePath) => { + (await recursive(sourceDir, [DS_STORE_FILE])).map((filePath) => { const fileAsText = fs.readFileSync(filePath).toString(); const fileName = path.basename(filePath); const song = parseSong(fileAsText); diff --git a/src/localConverterRunner.ts b/src/localConverterRunner.ts index ab5df26..e6740c2 100644 --- a/src/localConverterRunner.ts +++ b/src/localConverterRunner.ts @@ -2,9 +2,9 @@ import fs from 'fs'; import fsExtra from 'fs-extra'; import path from 'path'; import assert from 'node:assert'; -import { isEmpty } from 'lodash'; +import { isEmpty, isEqual, negate } from 'lodash'; import { Config } from './proPresenter7SongConverter'; -import { MANIFEST_FILE_NAME } from './constants'; +import { DS_STORE_FILE, MANIFEST_FILE_NAME } from './constants'; import { logFileWithLinkInConsole, logProcessingFile, @@ -54,16 +54,17 @@ export const convertSongsToPP7FormatLocally = async ({ baseLocalDir, config, }: { - sourceDir: string; baseLocalDir: string; config: Config; + sourceDir: string; }) => { const { + currentManifest, + deployableSongs, deploymentDate, deploymentVersionedDir, - deployableSongs, - currentManifest, localManifestFilePath, + versionedDir, } = await getBasicDeploymentInfo(sourceDir, baseLocalDir); assert( @@ -75,24 +76,17 @@ export const convertSongsToPP7FormatLocally = async ({ // Create directory fsExtra.ensureDirSync(deploymentVersionedDir); - if (process.env.FORCE_RELEASE_OF_ALL_SONGS === 'true') { - console.log(`Just debug.`); - - getConvertedAndWrittenToLocalOutDirSongs( - deployableSongs, - deploymentVersionedDir, - config, - ); - - return; - } - fs.writeFileSync(localManifestFilePath, JSON.stringify(currentManifest)); // --- // Existing deployments const allPreviousDeploymentDirs = fsExtra .readdirSync(baseLocalDir) + .filter( + (deploymentDir) => + negate(isEqual)(deploymentDir, DS_STORE_FILE) && + negate(isEqual)(deploymentDir, versionedDir), + ) .map((deploymentDir) => ({ deploymentDir, deploymentDirDate: parseDateFromVersionedDir(deploymentDir),