Skip to content

Commit

Permalink
Tiny update regarding drop of Author
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanlucut committed Sep 18, 2023
1 parent 24e5835 commit c6dc387
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 28 deletions.
2 changes: 1 addition & 1 deletion mocks/songWithSubsections.mock.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[title]
Any title {alternative: {Any other title}, author: {CustomAuthor}, contentHash: {#customHash}, id: {customId}}
Any title {alternative: {Any other title}, composer: {CustomComposer}, contentHash: {#customHash}, id: {customId}}

[sequence]
v1.1,v1.2,c1.1,c1.2,v2.1,v2.2,c1.1,c1.2
Expand Down
6 changes: 3 additions & 3 deletions src/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('core', () => {
it('should work correctly', () => {
expect(
getTitleWithoutMeta(
'Any title {alternative: {Any other title}, author: {CustomAuthor}, contentHash: {#customHash}, id: {customId}}',
'Any title {alternative: {Any other title}, composer: {CustomAuthor}, contentHash: {#customHash}, id: {customId}}',
),
).toMatchInlineSnapshot(`"Any title"`);

Expand All @@ -69,12 +69,12 @@ describe('core', () => {
it('should work correctly', () => {
expect(
getMetaSectionsFromTitle(
'Any title {alternative: {Any other title}, author: {CustomAuthor}, contentHash: {#customHash}, id: {customId}}',
'Any title {alternative: {Any other title}, composer: {CustomAuthor}, contentHash: {#customHash}, id: {customId}}',
),
).toMatchInlineSnapshot(`
{
"alternative": "Any other title",
"author": "CustomAuthor",
"composer": "CustomAuthor",
"contentHash": "#customHash",
"id": "customId",
}
Expand Down
2 changes: 0 additions & 2 deletions src/songsParser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ describe('songsParser', () => {
expect(parseSong(SONG_WITH_SUBSECTIONS_MOCK_FILE_CONTENT))
.toMatchInlineSnapshot(`
{
"author": "CustomAuthor",
"contentHash": "#customHash",
"id": "customId",
"sequence": [
Expand Down Expand Up @@ -290,7 +289,6 @@ describe('songsParser', () => {
expect(parseSong(SONG_WITH_SUBSECTIONS_MOCK_FILE_CONTENT))
.toMatchInlineSnapshot(`
{
"author": "CustomAuthor",
"contentHash": "#customHash",
"id": "customId",
"sequence": [
Expand Down
1 change: 0 additions & 1 deletion src/songsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export const parseSong = (songContent: string): Song => {
{
id: metaSectionsFromTitle[SongMeta.ID],
title: titleContent,
author: metaSectionsFromTitle[SongMeta.AUTHOR],
sequence: definedSequenceWithMarkup,
contentHash: metaSectionsFromTitle[SongMeta.CONTENT_HASH],
verses: sections,
Expand Down
57 changes: 36 additions & 21 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
export enum SequenceChar {
/**
* Simple verse section
*/
VERSE = 'v',

/**
* Pre-chorus section
*/
PRECHORUS = 'p',

/**
* Chorus section
*/
CHORUS = 'c',

/**
* Bridge section
*/
BRIDGE = 'b',

/**
* Ending section
*/
ENDING = 'e',

/**
* Recital section
*/
RECITAL = 's',
}

/**
Expand All @@ -24,9 +48,13 @@ const C_START_INDEX = 1;
/**
* Bridge 1 will always be 1 (cannot be just `b`, thus `b,b2`)
*/

const B_START_INDEX = 1;

/**
* Recital 1 will always be 1 (cannot be just `s`, thus `s,s2`)
*/
const S_START_INDEX = 1;

export const SongSection = {
SEQUENCE: '[sequence]',
TITLE: '[title]',
Expand Down Expand Up @@ -54,30 +82,17 @@ export const SongSection = {
? `${SequenceChar.BRIDGE}${index}`
: SequenceChar.BRIDGE
}]`,
RECITAL: (index = 0) =>
`[${
index > S_START_INDEX
? `${SequenceChar.RECITAL}${index}`
: SequenceChar.RECITAL
}]`,
ENDING: `[${SequenceChar.ENDING}]`,
};

export enum SongMeta {
/**
* Alternative song title
*/
ALTERNATIVE = 'alternative',

/**
* Song author
*/
AUTHOR = 'author',

/**
* Song version (can be multiple / duplicated)
*/
VERSION = 'version',

/**
* Song content hash (used to detect changes between the corrections & do partial deployments)
*/
CONTENT_HASH = 'contentHash',

ID = 'id',
}

Expand All @@ -90,6 +105,7 @@ export enum SectionGroupCategory {
PRECHORUS = 'Prechorus',
CHORUS = 'Chorus',
ENDING = 'Ending',
RECITAL = 'Recital',
}

export type Section = {
Expand All @@ -107,7 +123,6 @@ export type Section = {
};

export type Song = {
author?: string;
contentHash: string;
id: string;
sequence: string[];
Expand Down

0 comments on commit c6dc387

Please sign in to comment.