Skip to content

Commit a567e5d

Browse files
committed
So many bugs but at least it runs now
1 parent ac64e97 commit a567e5d

14 files changed

Lines changed: 16394 additions & 9771 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ www/*
88
Orchestra-darwin-x64/**
99
.vscode/.browse.VC.db
1010
.vscode/.browse.VC.db-shm
11-
.vscode/.browse.VC.db-wal
11+
.vscode/.browse.VC.db-wal
12+
.DS_Store

.vscode/tasks.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
{
2-
"version": "0.1.0",
2+
"version": "2.0.0",
33
"command": "npm",
44
"isShellCommand": false,
5-
"args": [ "run", "build-mac" ],
6-
"showOutput": "never",
7-
"echoCommand": false
5+
"args": [
6+
"run",
7+
"build-mac"
8+
],
9+
"echoCommand": false,
10+
"tasks": [
11+
{
12+
"label": "npm",
13+
"type": "shell",
14+
"command": "npm",
15+
"args": [
16+
"run",
17+
"build-mac"
18+
],
19+
"problemMatcher": [],
20+
"group": "build"
21+
}
22+
]
823
}

.vscode/tasks.json.old

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"version": "0.1.0",
3+
"command": "npm",
4+
"isShellCommand": false,
5+
"args": [ "run", "build-mac" ],
6+
"showOutput": "never",
7+
"echoCommand": false
8+
}

gulpfile.js renamed to build.js

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
const darwinInfoPlistBase = require('./build/darwin-info-base.json')
1717
const exec = require('child_process').exec
1818
const fs = require('fs-extra')
19-
const gulp = require('gulp')
2019
const packageJsonFirstLoad = require('./package.json')
2120
const path = require('path')
2221
const plist = require('plist')
@@ -127,7 +126,8 @@
127126
//
128127

129128
/** Copies static resource files into the result directory */
130-
gulp.task( 'copyResourceFiles', callback => {
129+
async function copyResourceFiles ( ) {
130+
console.log("--> Coping resource files")
131131
function copyNodeModules ( handle ) {
132132
const address = path.join( 'node_modules', handle )
133133
copyToBinaryFromDir( address, address )
@@ -140,8 +140,6 @@
140140
copyToBinaryFromDir( 'windows' )
141141
copyToBinaryFromDir( 'winserver' )
142142

143-
144-
145143
// design files
146144
copyToBinaryFromDir( 'resources' )
147145
copyToBinaryFromDir( 'designs/icon/file-icon-darwin/icns' )
@@ -150,93 +148,91 @@
150148
OrchestraNodeModules.forEach( x => copyNodeModules( x ) )
151149

152150
// package
153-
copyFile(
151+
await copyFile(
154152
getLocalPath( 'package.json' ),
155153
getLocalPath( path.join( pathToResultDir , 'package.json' ) )
156154
)
157-
158-
callback()
159-
})
155+
}
160156

161157
//
162158
// ─── GETTING COMMIT COUNT ───────────────────────────────────────────────────────
163159
//
164160

165-
gulp.task( 'get-commit-counts', callback => {
166-
const commitCountFilePath =
167-
`./${pathToResultDir}/about/commit-count.txt`
168-
const githubOrchestraRepositoryAPI =
169-
'https://api.github.com/repos/pmkary/orchestra/stats/contributors'
170-
171-
try {
172-
new Promise (( resolve, reject ) => {
173-
const rejectHandler = ( ) =>
174-
reject('Could not connect to GitHub')
175-
176-
const options = {
177-
url: githubOrchestraRepositoryAPI,
178-
method: 'GET',
179-
headers: {
180-
'User-Agent': 'Super Agent/0.0.1',
181-
'Content-Type': 'application/x-www-form-urlencoded'
182-
},
183-
}
161+
async function getCommitCounts ( ) {
162+
return new Promise ( callback => {
163+
const commitCountFilePath =
164+
`./${pathToResultDir}/about/commit-count.txt`
165+
const githubOrchestraRepositoryAPI =
166+
'https://api.github.com/repos/pmkary/orchestra/stats/contributors'
184167

185-
request( options, ( error, response, body ) => {
186-
if ( !error && response.statusCode == 200 )
187-
try {
188-
const data = JSON.parse( body )[ 0 ].total.toString( )
189-
resolve( data )
190-
} catch ( parseError ) {
168+
try {
169+
new Promise (( resolve, reject ) => {
170+
const rejectHandler = ( ) =>
171+
reject('Could not connect to GitHub')
172+
173+
const options = {
174+
url: githubOrchestraRepositoryAPI,
175+
method: 'GET',
176+
headers: {
177+
'User-Agent': 'Super Agent/0.0.1',
178+
'Content-Type': 'application/x-www-form-urlencoded'
179+
},
180+
}
181+
182+
request( options, ( error, response, body ) => {
183+
if ( !error && response.statusCode == 200 )
184+
try {
185+
const data = JSON.parse( body )[ 0 ].total.toString( )
186+
resolve( data )
187+
} catch ( parseError ) {
188+
rejectHandler( )
189+
}
190+
else
191191
rejectHandler( )
192-
}
193-
else
194-
rejectHandler( )
192+
})
193+
})
194+
.then( GitHubCommitCount => {
195+
fs.writeFileSync( commitCountFilePath, GitHubCommitCount )
196+
callback( )
197+
})
198+
.catch( e => {
199+
callback( e )
195200
})
196-
})
197-
.then( GitHubCommitCount => {
198-
fs.writeFileSync( commitCountFilePath, GitHubCommitCount )
199-
callback( )
200-
})
201-
.catch( e => {
202-
callback( e )
203-
})
204201

205-
} catch ( error ) {
206-
try {
207-
shell( 'git', 'rev-list', '--all', '--count',
208-
'>', commitCountFilePath )
209-
callback( )
202+
} catch ( error ) {
203+
try {
204+
shell( 'git', 'rev-list', '--all', '--count',
205+
'>', commitCountFilePath )
206+
callback( )
210207

211-
} catch ( error2 ) {
212-
callback('Could not save latest commits count')
208+
} catch ( error2 ) {
209+
callback('Could not save latest commits count')
210+
}
213211
}
214-
}
215-
})
212+
})
213+
}
216214

217215
//
218216
// ─── SHEETS ─────────────────────────────────────────────────────────────────────
219217
//
220218

221219
/** Compiles the Less style sheets */
222-
gulp.task( 'sheets', async callback => {
220+
async function sheets ( ) {
221+
console.log("--> Making sheets")
223222
const thisDir = (...x) => path.join( __dirname, ...x )
224223

225-
shell('lessc',
224+
await shell('lessc',
226225
thisDir( 'sheets', 'ui.less' ),
227226
thisDir( '_compiled', 'style.css' )
228-
).then(( ) => {
229-
callback( )
230-
}).catch(( err ) => {
231-
callback( err )
232-
})
233-
})
227+
)
228+
}
234229

235230
//
236231
// ─── ELECTRON PACKER ────────────────────────────────────────────────────────────
237232
//
238233

239234
async function packOrchestraForDarwin ( ) {
235+
console.log( "--> Packing for Darwin" )
240236
const iconFile =
241237
( isProductionBuild ? './designs/icon/icns/icon.icns'
242238
: './designs/icon-nightly/icns/icon.icns'
@@ -248,7 +244,7 @@
248244
' _compiled',
249245
'"' + packageJson.productName + '"',
250246
'--platform=darwin',
251-
'--arch=x64',
247+
'--arch=arm64',
252248
'--overwrite=true',
253249
'--app-bundle-id="us.kary.orchestra"',
254250
'--app-copyright="' + CopyrightNotice + '"',
@@ -267,6 +263,7 @@
267263

268264

269265
function updateDarwinInfoPlistFile ( ) {
266+
console.log( "--> Updating Darwin Info Plist" )
270267
// data
271268
const plistFilePath =
272269
( isProductionBuild ? '_release/Orchestra-darwin-x64/Orchestra.app/Contents/Info.plist'
@@ -293,6 +290,7 @@
293290

294291

295292
async function createMacDMGImage ( ) {
293+
console.log( "--> Creating Mac DMG Image" )
296294
const orchestraMacAppAddress =
297295
"_release/Orchestra-darwin-x64/Orchestra.app"
298296

@@ -315,6 +313,7 @@
315313
//
316314

317315
async function packOrchestraForLinux ( ) {
316+
console.log( "--> Packing for Linux" )
318317
const iconFile =
319318
( isProductionBuild ? './designs/icon/icon.png'
320319
: './designs/icon-nightly/icns/icon.icns'
@@ -344,6 +343,7 @@
344343

345344

346345
async function createDebianDEBInstaller ( ) {
346+
console.log( "--> Create DEB File..." )
347347
await shell(
348348
'electron-installer-debian',
349349
'--src _release/Orchestra-linux-x64',
@@ -360,14 +360,30 @@
360360
// to be continued...
361361
}
362362

363+
//
364+
// ─── COMPILE ────────────────────────────────────────────────────────────────────
365+
//
366+
367+
async function compile ( ) {
368+
console.log( "--> Compiling" )
369+
await copyResourceFiles( )
370+
await sheets( )
371+
}
372+
363373
//
364374
// ─── PACK ───────────────────────────────────────────────────────────────────────
365375
//
366376

367-
gulp.task( 'pack-orchestra', gulp.series('copyResourceFiles', 'sheets', async callback => {
377+
async function packOrchestra ( ) {
378+
console.log ( "--> Packing Orchestra" )
379+
await compile( )
380+
368381
async function packFunctionBody ( ) {
369-
if ( argv.debug )
370-
return await shell( 'npm', 'run', 'electron' )
382+
if ( argv.debug ) {
383+
console.log( "--> Running electron")
384+
await shell( 'npm', 'run', 'electron' )
385+
return
386+
}
371387

372388
if ( argv.pack )
373389
await buildAllPlatforms( )
@@ -376,67 +392,51 @@
376392
await createInstallersForAllPlatforms( )
377393
}
378394

379-
packFunctionBody( )
380-
.then( callback )
381-
.catch( callback )
382-
}))
395+
await packFunctionBody( )
396+
}
383397

384398
//
385399
// ─── BUILD FOR ALL PLATFORMS ────────────────────────────────────────────────────
386400
//
387401

388402
async function buildAllPlatforms ( ) {
403+
console.log( "--> Building all platforms" )
389404
const platformFunctions = [ ]
390405

391406
if ( argv.mac )
392-
platformFunctions.push( packOrchestraForDarwin )
407+
await packOrchestraForDarwin( )
393408

394409
if ( argv.win )
395-
platformFunctions.push( packOrchestraForWindows )
410+
await packOrchestraForWindows( )
396411

397412
if ( argv.linux )
398-
platformFunctions.push( packOrchestraForLinux )
399-
400-
await runAsyncFunctions( platformFunctions )
413+
await packOrchestraForLinux( )
401414
}
402415

403416
//
404417
// ─── CREATE INSTALLERS FOR ALL PLATFORMS ────────────────────────────────────────
405418
//
406419

407420
async function createInstallersForAllPlatforms ( ) {
408-
const platformFunctions = [ ]
421+
console.log( "--> Making Installer" )
409422

410423
if ( argv.mac )
411-
platformFunctions.push( createMacDMGImage )
424+
await createMacDMGImage( )
412425

413426
if ( argv.linux )
414-
platformFunctions.push( createDebianDEBInstaller )
415-
416-
await runAsyncFunctions(platformFunctions)
427+
await createDebianDEBInstaller( )
417428
}
418429

419430
//
420431
// ─── RUN MANY ASYNC FUNCTIONS ───────────────────────────────────────────────────
421432
//
422433

423-
async function runAsyncFunctions ( functions ) {
424-
await Promise.all( functions.map( func => func( ) ) )
434+
main ( ); async function main ( ) {
435+
try {
436+
await packOrchestra( )
437+
} catch ( error ) {
438+
console.error( error )
439+
}
425440
}
426441

427-
//
428-
// ─── AFTER PACK ─────────────────────────────────────────────────────────────────
429-
//
430-
431-
gulp.task( 'build-orchestra', gulp.series('pack-orchestra', ( callback ) => {
432-
callback( )
433-
}))
434-
435-
//
436-
// ─── MAIN ───────────────────────────────────────────────────────────────────────
437-
//
438-
439-
/** Where everything starts */
440-
gulp.task( 'default', gulp.series('build-orchestra', ( ) => { }))
441-
442442
// ────────────────────────────────────────────────────────────────────────────────

config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm install -g less gulp appdmg electron-packager

0 commit comments

Comments
 (0)