Skip to content

Commit

Permalink
Created a *.mmip build script
Browse files Browse the repository at this point in the history
  • Loading branch information
emptyother committed Jun 11, 2018
0 parents commit eabb38a
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run Build script",
"program": "${workspaceFolder}\\build.js"
}
]
}
35 changes: 35 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const ini = require('multi-ini');
const zipdir = require('zip-dir');
const semver = require('semver');
const packagejson = require('./package.json');

let fullverstring = '';
const version = packagejson.version;
const file = './source/Install.ini';
const content = ini.read(file);

if (
content &&
content.Header &&
content.Header.VersionBuild
) {
const head = content.Header;

head.VersionMajor = `${semver(version).major}`;
head.VersionMinor = `${semver(version).minor}`;
head.VersionRelease = `${semver(version).patch}`;
head.VersionBuild = `${Number(head.VersionBuild) + 1}`;

fullverstring = [
head.VersionMajor,
head.VersionMinor,
head.VersionRelease,
head.VersionBuild
].join('.');
ini.write(file, content);
}
zipdir('./source', {
saveTo: `./dist/Lyrics To Instrumental v${fullverstring}.mmip`
}, () => {

});
66 changes: 66 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "lyrics-to-instrumental",
"version": "1.0.0",
"description": "Mediamonkey plugin: Toolbar button to set lyrics to instrumental for the currently selected songs",
"main": "build.js",
"scripts": {
"build": "node build.js"
},
"author": "Tom A. Vibeto <[email protected]> (https://onlyhuman.dk)",
"license": "ISC",
"dependencies": {
"clean-stacktrace": "^1.1.0",
"multi-ini": "^2.0.0",
"semver": "^5.5.0",
"zip-dir": "^1.0.2"
}
}
Binary file added source/App.ico
Binary file not shown.
15 changes: 15 additions & 0 deletions source/Install.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Header]
ID="LyricsToInstrumental"
Title="Lyrics To Instrumental"
Description="Toolbar button to set lyrics to instrumental for the currently selected songs"
VersionMajor="1"
VersionMinor="0"
VersionRelease="0"
VersionBuild="1"
Type="script"
[Copy]
Src="LyricsToInstrumental.vbs"
Tgt="{app}\Scripts\Auto\LyricsToInstrumental.vbs"
[Execute]
File="{app}\Scripts\Auto\LyricsToInstrumental.vbs"
Function="OnStartup()"
36 changes: 36 additions & 0 deletions source/LyricsToInstrumental.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
' A script adding a button, that sets lyrics to "Instrumental"

Sub OnStartup
Dim btn : Set btn = SDB.Objects("LyricsInsrumentalButton")
If btn Is Nothing Then
Set btn = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard,0,0)
btn.Caption = "Lyrics to Instrumental"
btn.IconIndex = 17
Set SDB.Objects("LyricsInsrumentalButton") = btn
End If
Call Script.UnRegisterHandler("btnClick")
Call Script.RegisterEvent(btn,"OnClick","btnClick")
End Sub

Sub btnClick(btn)
Call LyricsToInstrumental()
End Sub

Sub LyricsToInstrumental
' Define variables
Dim list
Dim itm
Dim i

' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
If list.count>0 Then
' Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)
itm.Lyrics = "Instrumental"
' Update the changes in DB
itm.UpdateDB
Next
End If
End Sub
6 changes: 6 additions & 0 deletions source/Uninstall.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Delete]
File={app}\Scripts\Auto\LyricsToInstrumental.vbs

[Execute]
File=Uninstall.vbs

5 changes: 5 additions & 0 deletions source/Uninstall.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dim but : Set but = SDB.Objects("LyricsInsrumentalButton")
If Not (but Is Nothing) Then
but.Visible = False
Set SDB.Objects("LyricsInsrumentalButton") = Nothing
End If

0 comments on commit eabb38a

Please sign in to comment.