class MacOS extends WindowsZIP
{
protected $nwplatform = 'osx';
- protected $arch='x64';
- protected $nwversion = '0.71.0';
+ protected $arch = 'x64';
+ protected $nwversion = '0.72.0';
protected $node_platform = 'mac';
protected $exenameMaxlength = 28;
public $type = 'mac_exe_html';
- protected $packageIconExt='icns';
+ protected $packageIconExt = 'icns';
public function makePackage($zip)
public function getAppPath()
{
- return $this->getFinalPackageDir() . '/' . $this->exeName . '.app';
+ return $this->getFinalPackageDir() . $this->exeName . '.app';
+ }
+
+ /**
+ * @return bool
+ */
+ public function nwBuildOK()
+ {
+ return file_exists($this->getAppPath() . '/Contents/Resources/app.nw/index.html');
}
public function getFinalPackageDir()
{
- $res = parent::getFinalPackageDir();
- return $res;
+ return parent::getFinalPackageDir();
}
$this->signApp();
}
+ public function setIcon()
+ {
+ copy($this->vdir . 'icon.icns', $this->getAppPath() . '/Contents/Resources/app.icns');
+ copy($this->vdir . 'icon.icns', $this->getAppPath() . '/Contents/Resources/document.icns');
+ }
+
function replaceFFMpeg()
{
copy($this->resource_path('_ffmpeg/libffmpeg.dylib'), $this->getAppPath() . '/Contents/Frameworks/nwjs Framework.framework/Versions/Current/libffmpeg.dylib');
$cp->setArg(null, $appPath);
$cp->setArg(null, $path);
$cp->execute();
- $cp->debug();
// Sign app
$cl = new CommandLine($local_root . 'sign');
$cl->setSSH('paris.cubedesigners.com', 'vincent', 'atacama', 22022);
$cl->setArg(null, $local_root . $f);
$cl->execute();
- $cl->debug();
$res = $cl->output;
if ($back) {
$cp->setArg('v');
$cp->setArg(null, $path . '/');
$cp->setArg(null, $appPath . '/');
- $cp->setArg('delete');
$cp->execute();
- $cp->debug();
}
-
- // `rm -rf $path`;
+ //`rm -rf $path`;
return $res;
}
}
protected $buildPath;
protected $nwplatform = 'win';
protected $arch = 'x64';
- protected $nwversion = '0.71.0';
+ protected $nwversion = '0.72.0';
protected $appversion = '';
protected $node_platform = 'win';
protected $exenameMaxlength = 30;
protected $_compileOnConstruct = true;
protected $packageIconExt = 'ico';
protected $nwbuildVersion = '4.0.7';
+ protected $nwCacheDir;
protected $_ext = 'html';
public function __construct($book_id, $vdir = null, $options = [])
{
+ $this->nwCacheDir = Files::mkdir(base_path('cache/nwbuild'));
parent::__construct($book_id, $vdir, $options);
$this->appName = '';
$this->appversion = '1.0.' . $this->_time;
}
}
+ /**
+ * @throws \Exception
+ */
protected function preparePackage()
{
parent::preparePackage();
- $this->makeJSON();
+ $this->buildNW();
- $this->buildPath = Files::mkdir($this->packager_path('/nwbuild/' . $this->type . '/' . $this->book_id));
+ $this->setIcon();
+ $this->replaceFFMpeg();
+ $this->signExe();
+ }
- `umask 0000;sudo rm -rf $this->buildPath;mkdir -p 0777 $this->buildPath;chmod -R 777 $this->vdir;mkdir -p 0777 /application/tmp;chmod -R 777 /application/tmp`;
+ protected function setIcon()
+ {
-// For
-// $cl = new CommandLine('nwbuild');
-// $cl->setArg('platform', $this->nwplatform);
-// $cl->setArg('outDir', $this->buildPath);
-// $cl->setArg('flavour', "normal");
-// $cl->setArg('version', $this->nwversion);
-// $cl->setArg('arch', $this->arch);
-// $cl->setArg(null, $this->vdir);
-// $cl->execute();
+ }
+
+ protected function buildNW()
+ {
+ $this->buildPath = Files::mkdir($this->packager_path('/nwbuild/' . $this->type . '/' . $this->book_id));
+ $this->makeJSON();
+ `umask 0000;sudo rm -rf $this->buildPath;mkdir -p 0777 $this->buildPath;chmod -R 777 $this->vdir;mkdir -p 0777 /application/tmp;chmod -R 777 /application/tmp`;
if (version_compare($this->nwbuildVersion, 4, '<')) {
- $platform = $this->getNWbuilder3Platform();
-
- $cl = new CommandLine('nwbuild');
- $cl->setArg(null, $this->vdir . '**');
- $cl->setLongArgumentSeparator(' ');
- $cl->setArg('platforms', $platform);
- $cl->setArg('buildDir', $this->buildPath);
- $cl->setArg('version', $this->nwversion);
- $cl->setArg('mode', 'build');
- $cl->setArg('flavor', 'normal');
- if ($this->nwplatform === 'win') {
- $cl->setArg('winIco', $this->vdir . 'icon.ico');
- $cl->setArg('useRcedit', 'true');
- } elseif ($this->nwplatform === 'osx') {
- $cl->setArg('macIcns', $this->vdir . 'icon.icns');
- }
- $cl->execute();
+ $cl = $this->_nwbuilder3();
} else {
- $cl = new CommandLine('nwbuild');
- $cl->cd($this->vdir);
- $cl->setArg(null, 'package.json');
- $cl->setArg('platform', $this->nwplatform);
- $cl->setArg('outDir', $this->buildPath);
- $cl->setArg('flavour', "normal");
- $cl->setArg('version', $this->nwversion);
- $cl->setArg('arch', $this->arch);
- $cl->execute();
+ $cl = $this->_nwbuilder4();
}
`sudo chown -R 1001:33 $this->buildPath`;
- if (!file_exists($this->buildPath)) {
+ if (!$this->nwBuildOK()) {
throw new \Exception('Error while making exe : ' . $cl->commande . ' // ' . $cl->output);
}
+ }
- $this->replaceFFMpeg();
+ /**
+ * @return bool
+ */
+ public function nwBuildOK()
+ {
+ return file_exists($this->buildPath);
+ }
- $this->signExe();
+ /**
+ * @return CommandLine
+ */
+ protected function _nwbuilder3()
+ {
+ $platform = $this->getNWbuilder3Platform();
+
+ $cl = new CommandLine('nwbuild');
+ $cl->setArg(null, $this->vdir . '**');
+ $cl->setLongArgumentSeparator(' ');
+ $cl->setArg('platforms', $platform);
+ $cl->setArg('buildDir', $this->buildPath);
+ $cl->setArg('version', $this->nwversion);
+ $cl->setArg('mode', 'build');
+ $cl->setArg('flavor', 'normal');
+ if ($this->nwplatform === 'win') {
+ $cl->setArg('winIco', $this->vdir . 'icon.ico');
+ $cl->setArg('useRcedit', 'true');
+ } elseif ($this->nwplatform === 'osx') {
+ $cl->setArg('macIcns', $this->vdir . 'icon.icns');
+ }
+ $cl->execute();
+ return $cl;
+ }
+
+ /**
+ * @return CommandLine
+ */
+ protected function _nwbuilder4()
+ {
+ $cl = new CommandLine('nwbuild');
+ $cl->cd($this->vdir);
+ $cl->setArg(null, 'package.json *');
+ $cl->setArg('platform', $this->nwplatform);
+ $cl->setArg('outDir', $this->buildPath);
+ $cl->setArg('flavour', "normal");
+ $cl->setArg('version', $this->nwversion);
+ $cl->setArg('arch', $this->arch);
+ $cl->execute();
+ return $cl;
}
protected function getNWBuilder3Platform()
'main' => 'index.html',
'name' => $this->exeName,
'version' => '1.0.' . $this->_time,
- 'icon' => 'icon.' . $this->packageIconExt,
'webkit' => [],
'window' => [
'height' => 768,
'id' => 'main',
'icon' => 'icon.png',
],
+ 'nwbuild' => [
+ 'platform' => $this->nwplatform,
+ 'outDir' => $this->buildPath,
+ 'cacheDir' => $this->nwCacheDir,
+ 'flavour' => 'normal',
+ 'version' => $this->nwversion,
+ 'arch' => $this->arch,
+ 'app' => [
+ 'name' => $this->appName,
+ 'icon' => $this->vdir . 'icon.' . $this->packageIconExt,
+ ],
+ ],
'dependencies' =>
[
'child_process' => "^1.0.2",