161 lines
2.8 KiB
Markdown
161 lines
2.8 KiB
Markdown
# MacOS con Capacitor Electon (non funziona)
|
|
|
|
creare un foder per esempio launch ed entraci
|
|
|
|
```
|
|
mkdir launch
|
|
cd launch
|
|
```
|
|
crea una cartella per il file statico, in questo caso web
|
|
|
|
```
|
|
mkdir web
|
|
```
|
|
|
|
copia il file statico nella cartella web
|
|
|
|
per esempio
|
|
|
|
```
|
|
/web/index.html
|
|
/web/style.css
|
|
/web/app.js
|
|
```
|
|
|
|
inizializza capacitor
|
|
|
|
```
|
|
npm init -y
|
|
npm install @capacitor/core @capacitor/cli
|
|
npx cap init "MyApps" "it.patachina.myapps" --web-dir=web
|
|
```
|
|
|
|
qui ho chiamato la mia app "MyApps", l'ID della app "it.patachina.myapps" e la webdir quella creata prima "web"
|
|
|
|
ora aggiungo Electron come piattaforma a Capacitor
|
|
|
|
```
|
|
npm install @capacitor-community/electron
|
|
npx cap add @capacitor-community/electron
|
|
```
|
|
|
|
inserisci in capacitor.config.json
|
|
|
|
```
|
|
"bundledWebRuntime": false
|
|
```
|
|
|
|
copia i file statici dentro Electron
|
|
|
|
```
|
|
npx cap copy
|
|
```
|
|
|
|
questo copia i file statici in electron/app
|
|
|
|
entra in electron
|
|
|
|
```
|
|
cd electron
|
|
```
|
|
e se il progetto non è ts ma solo js modifica tsconfig.json
|
|
|
|
```
|
|
nano tsconfig.json
|
|
```
|
|
|
|
inserendo in compileOptions types e skipLibCheck
|
|
|
|
```
|
|
{
|
|
"compilerOptions": {
|
|
"types": ["node"],
|
|
"skipLibCheck": true
|
|
}
|
|
}
|
|
```
|
|
|
|
per creare .dmg file bisogna installare electron build (sempre nella directory electron)
|
|
|
|
```
|
|
npm install -D electron-builder
|
|
```
|
|
in package.json sempre dentro electron aggiungi negli scripts la sezione "electron:build"
|
|
|
|
```
|
|
"scripts": {
|
|
"electron:build": "electron-builder"
|
|
}
|
|
```
|
|
e aggiungi (o verifica) la sezione build (dove ho messo name, ID, risoluzione)
|
|
|
|
inoltre l'icona casina.icns che era nel file statico in web, se non ho l'icona rimuovo "icon" userà quella di default
|
|
|
|
inserito anche identity, per crearla vedi sotto
|
|
|
|
```
|
|
{
|
|
"name": "MyApps",
|
|
"version": "1.0.0",
|
|
"build": {
|
|
"appId": "it.patachina.myapps",
|
|
"files": [
|
|
"build/**/*",
|
|
"package.json"
|
|
],
|
|
"mac": {
|
|
"target": ["dmg", "zip"],
|
|
"category": "public.app-category.productivity",
|
|
"icon": "app/casina.icns",
|
|
"identity": "MyCustomCert",
|
|
"hardenedRuntime": false,
|
|
"gatekeeperAssess": false
|
|
},
|
|
"dmg": {
|
|
"background": null,
|
|
"window": {
|
|
"width": 540,
|
|
"height": 380
|
|
}
|
|
}
|
|
},
|
|
"description": "An Amazing Capacitor App",
|
|
```
|
|
|
|
costruisci il build e fallo partire
|
|
```
|
|
npm run build
|
|
npm run electron:start
|
|
```
|
|
|
|
per creare .dmg file, sempre in electron, eseguire il Comando per generare il DMG
|
|
|
|
```
|
|
npm run electron:build
|
|
```
|
|
|
|
## Crea autocertificato
|
|
|
|
Crea un file di configurazione OpenSSL
|
|
Crea codesign.cnf:
|
|
|
|
```
|
|
cat <<EOF > codesign.cnf
|
|
[ req ]
|
|
default_bits = 2048
|
|
prompt = no
|
|
default_md = sha256
|
|
distinguished_name = dn
|
|
x509_extensions = ext
|
|
|
|
[ dn ]
|
|
CN = MyCustomCert
|
|
|
|
[ ext ]
|
|
keyUsage = critical, digitalSignature
|
|
extendedKeyUsage = critical, codeSigning
|
|
basicConstraints = critical, CA:FALSE
|
|
EOF
|
|
|
|
```
|
|
|