Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
9
Issues
9
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
mycard
Commits
c490908c
Commit
c490908c
authored
Jul 29, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v3-detect-rosetta' into v3
parents
4cd077c0
dac130b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
8 deletions
+64
-8
app/app.ts
app/app.ts
+13
-3
app/apps.service.ts
app/apps.service.ts
+5
-5
app/utility/arch.ts
app/utility/arch.ts
+46
-0
No files found.
app/app.ts
View file @
c490908c
...
@@ -4,6 +4,7 @@ import * as ini from 'ini';
...
@@ -4,6 +4,7 @@ import * as ini from 'ini';
import
*
as
fs
from
'
fs
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
child_process
from
'
child_process
'
;
import
*
as
child_process
from
'
child_process
'
;
import
*
as
Mustache
from
'
mustache
'
;
import
*
as
Mustache
from
'
mustache
'
;
import
{
checkRosetta
}
from
'
./utility/arch
'
;
export
enum
Category
{
export
enum
Category
{
game
,
game
,
...
@@ -35,6 +36,7 @@ export interface BaseAction {
...
@@ -35,6 +36,7 @@ export interface BaseAction {
export
interface
Action
extends
BaseAction
{
export
interface
Action
extends
BaseAction
{
interpreter
?:
string
;
interpreter
?:
string
;
open
?:
App
;
open
?:
App
;
noRosetta
?:
boolean
;
}
}
export
interface
SpawnAction
extends
BaseAction
{
export
interface
SpawnAction
extends
BaseAction
{
...
@@ -333,6 +335,10 @@ export class App {
...
@@ -333,6 +335,10 @@ export class App {
}
}
}
}
env
=
Object
.
assign
(
env
,
action
.
env
);
env
=
Object
.
assign
(
env
,
action
.
env
);
if
(
action
.
noRosetta
&&
await
checkRosetta
())
{
args
=
[
'
-arch
'
,
'
arm64
'
,
execute
].
concat
(
args
);
execute
=
'
arch
'
;
}
return
{
return
{
execute
,
execute
,
args
,
args
,
...
@@ -342,7 +348,6 @@ export class App {
...
@@ -342,7 +348,6 @@ export class App {
}
}
async
spawnApp
(
children
:
App
[],
action_name
=
'
main
'
,
argsTemplate
?:
any
)
{
async
spawnApp
(
children
:
App
[],
action_name
=
'
main
'
,
argsTemplate
?:
any
)
{
if
(
this
.
id
===
'
th123
'
)
{
if
(
this
.
id
===
'
th123
'
)
{
let
th105
=
<
App
>
this
.
references
.
get
(
'
th105
'
);
let
th105
=
<
App
>
this
.
references
.
get
(
'
th105
'
);
if
(
th105
.
isInstalled
())
{
if
(
th105
.
isInstalled
())
{
...
@@ -357,15 +362,20 @@ export class App {
...
@@ -357,15 +362,20 @@ export class App {
}
}
const
appCwd
=
(
<
AppLocal
>
this
.
local
).
path
;
const
appCwd
=
(
<
AppLocal
>
this
.
local
).
path
;
const
{
execute
,
args
,
env
,
cwd
}
=
await
this
.
getSpawnAction
(
children
,
action_name
,
null
,
null
,
null
,
argsTemplate
);
const
spawnAction
=
await
this
.
getSpawnAction
(
children
,
action_name
,
null
,
null
,
null
,
argsTemplate
);
const
{
execute
,
args
,
env
,
cwd
}
=
spawnAction
;
console
.
log
(
execute
,
args
,
env
,
cwd
,
appCwd
);
console
.
log
(
execute
,
args
,
env
,
cwd
,
appCwd
);
return
child_process
.
spawn
(
execute
,
args
,
{
env
:
env
,
cwd
:
cwd
||
appCwd
});
return
child_process
.
spawn
(
execute
,
args
,
{
env
,
cwd
:
cwd
||
appCwd
});
}
}
get
isYGOPro
():
boolean
{
get
isYGOPro
():
boolean
{
return
!!
this
.
ygoproDistroData
;
return
!!
this
.
ygoproDistroData
;
}
}
get
isPreservingArch
()
{
return
!!
this
.
data
.
noRosetta
;
}
get
ygoproDistroData
():
YGOProDistroData
{
get
ygoproDistroData
():
YGOProDistroData
{
if
(
!
this
.
data
)
{
if
(
!
this
.
data
)
{
return
null
;
return
null
;
...
...
app/apps.service.ts
View file @
c490908c
import
{
ApplicationRef
,
EventEmitter
,
Injectable
,
NgZone
}
from
'
@angular/core
'
;
import
{
ApplicationRef
,
EventEmitter
,
Injectable
,
NgZone
}
from
'
@angular/core
'
;
import
{
Http
}
from
'
@angular/http
'
;
import
{
Http
}
from
'
@angular/http
'
;
import
*
as
child_process
from
'
child_process
'
;
import
*
as
child_process
from
'
child_process
'
;
import
{
ChildProcess
}
from
'
child_process
'
;
import
{
ChildProcess
,
execFile
,
execFileSync
}
from
'
child_process
'
;
import
*
as
crypto
from
'
crypto
'
;
import
*
as
crypto
from
'
crypto
'
;
import
{
remote
}
from
'
electron
'
;
import
{
remote
}
from
'
electron
'
;
import
*
as
sudo
from
'
electron-sudo
'
;
import
*
as
sudo
from
'
electron-sudo
'
;
...
@@ -19,8 +19,8 @@ import {LoginService} from './login.service';
...
@@ -19,8 +19,8 @@ import {LoginService} from './login.service';
import
{
SettingsService
}
from
'
./settings.sevices
'
;
import
{
SettingsService
}
from
'
./settings.sevices
'
;
import
{
ComparableSet
}
from
'
./shared/ComparableSet
'
;
import
{
ComparableSet
}
from
'
./shared/ComparableSet
'
;
import
{
AppsJson
}
from
'
./apps-json-type
'
;
import
{
AppsJson
}
from
'
./apps-json-type
'
;
import
*
as
os
from
'
os
'
;
import
Timer
=
NodeJS
.
Timer
;
import
Timer
=
NodeJS
.
Timer
;
import
{
getArch
}
from
'
./utility/arch
'
;
const
Logger
=
{
const
Logger
=
{
info
:
(...
message
:
any
[])
=>
{
info
:
(...
message
:
any
[])
=>
{
...
@@ -657,7 +657,7 @@ export class AppsService {
...
@@ -657,7 +657,7 @@ export class AppsService {
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
locale
=
'
en-US
'
;
locale
=
'
en-US
'
;
}
}
let
updateUrl
=
App
.
updateUrl
(
app
,
process
.
platform
,
locale
,
os
.
a
rch
());
let
updateUrl
=
App
.
updateUrl
(
app
,
process
.
platform
,
locale
,
await
getA
rch
());
let
metalink
=
await
this
.
http
.
post
(
updateUrl
,
changedFiles
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
metalink
=
await
this
.
http
.
post
(
updateUrl
,
changedFiles
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
downloadDir
=
path
.
join
(
path
.
dirname
(
app
.
local
!
.
path
),
'
downloading
'
);
let
downloadDir
=
path
.
join
(
path
.
dirname
(
app
.
local
!
.
path
),
'
downloading
'
);
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
downloadDir
);
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
downloadDir
);
...
@@ -715,7 +715,7 @@ export class AppsService {
...
@@ -715,7 +715,7 @@ export class AppsService {
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
locale
=
'
en-US
'
;
locale
=
'
en-US
'
;
}
}
let
metalinkUrl
=
App
.
downloadUrl
(
_app
,
process
.
platform
,
locale
,
os
.
a
rch
());
let
metalinkUrl
=
App
.
downloadUrl
(
_app
,
process
.
platform
,
locale
,
await
getA
rch
());
_app
.
status
.
status
=
'
downloading
'
;
_app
.
status
.
status
=
'
downloading
'
;
let
metalink
=
await
this
.
http
.
get
(
metalinkUrl
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
metalink
=
await
this
.
http
.
get
(
metalinkUrl
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
dir
);
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
dir
);
...
@@ -1123,7 +1123,7 @@ export class AppsService {
...
@@ -1123,7 +1123,7 @@ export class AppsService {
locale
=
'
en-US
'
;
locale
=
'
en-US
'
;
}
}
let
checksumUrl
=
App
.
checksumUrl
(
app
,
process
.
platform
,
locale
,
os
.
a
rch
());
let
checksumUrl
=
App
.
checksumUrl
(
app
,
process
.
platform
,
locale
,
await
getA
rch
());
return
this
.
http
.
get
(
checksumUrl
)
return
this
.
http
.
get
(
checksumUrl
)
.
map
((
response
)
=>
{
.
map
((
response
)
=>
{
let
map
=
new
Map
<
string
,
string
>
();
let
map
=
new
Map
<
string
,
string
>
();
...
...
app/utility/arch.ts
0 → 100644
View file @
c490908c
import
{
promisify
}
from
'
util
'
;
import
{
execFile
}
from
'
child_process
'
;
import
*
as
os
from
'
os
'
;
export
async
function
checkRosetta
()
{
if
(
process
.
platform
!==
'
darwin
'
)
{
return
false
;
}
const
execFileAsync
=
promisify
(
execFile
);
const
sysctlRosettaInfoKey
=
'
sysctl.proc_translated
'
;
let
isRosetta
=
false
;
try
{
console
.
log
(
'
Checking for macOS Rosetta environment
'
);
const
result
=
await
execFileAsync
(
'
sysctl
'
,
[
sysctlRosettaInfoKey
],
{
encoding
:
'
utf8
'
});
isRosetta
=
result
.
stdout
.
includes
(
`
${
sysctlRosettaInfoKey
}
: 1`
);
console
.
log
(
`Checked for macOS Rosetta environment (isRosetta=
${
isRosetta
}
)`
);
}
catch
(
e
)
{
console
.
error
(
`sysctl shell command to check for macOS Rosetta environment failed:
${
e
}
`
);
}
return
isRosetta
;
}
export
async
function
getArch
()
{
const
execFileAsync
=
promisify
(
execFile
);
const
archFromOs
=
os
.
arch
();
if
(
archFromOs
!==
'
x64
'
||
process
.
platform
!==
'
darwin
'
)
{
// not mac or real x64
return
archFromOs
;
}
const
isRosetta
=
await
checkRosetta
();
let
isArm64Mac
=
false
;
try
{
console
.
log
(
'
Checking for arm64 in uname
'
);
const
result
=
await
execFileAsync
(
'
uname
'
,
[
'
-a
'
],
{
encoding
:
'
utf8
'
});
const
isArm
=
result
.
stdout
.
includes
(
'
ARM
'
);
console
.
log
(
`Checked 'uname -a': arm64=
${
isArm
}
`
);
isArm64Mac
=
isArm64Mac
||
isArm
;
}
catch
(
e
)
{
console
.
error
(
`uname shell command to check for arm64 failed:
${
e
}
`
);
}
isArm64Mac
=
isArm64Mac
||
process
.
arch
===
'
arm64
'
||
isRosetta
;
return
isArm64Mac
?
'
arm64
'
:
archFromOs
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment