Skip to content

Commit

Permalink
changed postinstall to pipe out file
Browse files Browse the repository at this point in the history
  • Loading branch information
KenCorma committed Nov 2, 2024
1 parent b92db78 commit 7fbf2bb
Showing 1 changed file with 68 additions and 36 deletions.
104 changes: 68 additions & 36 deletions todesktop-postinstall.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,73 @@
const { spawnSync } = require("child_process");
const { spawnSync } = require('child_process');
const os = require('os');
const process = require("process");
const process = require('process');

async function postInstall() {
const firstInstallOnToDesktopServers =
process.env.TODESKTOP_CI && process.env.TODESKTOP_INITIAL_INSTALL_PHASE;

console.log('Post Install' , os.platform());
if (!firstInstallOnToDesktopServers) return;

if (os.platform() === "win32")
{
// Change stdio to get back the logs if there are issues.
const resultUpgradePip = spawnSync(`py`, ['-3.12', '-m', 'pip' ,'install' ,'--upgrade pip'],{shell:true,stdio: 'ignore'}).toString();
const resultInstallComfyCLI = spawnSync(`py`, ['-3.12 ','-m' ,'pip' ,'install comfy-cli'], {shell:true,stdio: 'ignore'}).toString();
console.log("Finish PIP & ComfyCLI Install");
const resultComfyManagerInstall = spawnSync('set PATH=C:\\hostedtoolcache\\windows\\Python\\3.12.7\\x64\\Scripts;%PATH% && yarn run make:assets:nvidia' ,[''],{shell:true,stdio: 'inherit'}).toString();
console.log("Finish Comfy Manager Install and Rehydration");
}

if (os.platform() === "darwin") {

const resultUpgradePip = spawnSync(`py`, ['-3.12', '-m', 'pip' ,'install' ,'--upgrade pip'],{shell:true,stdio: 'ignore'}).toString();
const resultInstallComfyCLI = spawnSync(`py`, ['-3.12 ','-m' ,'pip' ,'install comfy-cli'], {shell:true,stdio: 'ignore'}).toString();
const resultComfyManagerInstall = spawnSync('yarn run make:assets:macos' ,[''],{shell:true,stdio: 'inherit'}).toString();

// Do not delete, useful if there are build issues with mac
// TODO: Consider making a global build log as ToDesktop logs can be hit or miss
/*
fs.createFileSync('./src/macpip.txt');
fs.writeFileSync('./src/macpip.txt',JSON.stringify({
log: result.stdout.toString(),
err:result.stderr.toString()
}));
*/
console.log("Finish Python & Comfy Install for Mac");
}
};
const firstInstallOnToDesktopServers = process.env.TODESKTOP_CI && process.env.TODESKTOP_INITIAL_INSTALL_PHASE;

console.log('Post Install', os.platform());
if (!firstInstallOnToDesktopServers) return;

if (os.platform() === 'win32') {
// Change stdio to get back the logs if there are issues.
const resultUpgradePip = spawnSync(`py`, ['-3.12', '-m', 'pip', 'install', '--upgrade pip'], {
shell: true,
stdio: 'ignore',
}).toString();
const resultInstallComfyCLI = spawnSync(`py`, ['-3.12 ', '-m', 'pip', 'install comfy-cli'], {
shell: true,
stdio: 'ignore',
}).toString();
console.log('Finish PIP & ComfyCLI Install');
const resultComfyManagerInstall = spawnSync(
'set PATH=C:\\hostedtoolcache\\windows\\Python\\3.12.7\\x64\\Scripts;%PATH% && yarn run make:assets:nvidia',
[''],
{ shell: true, stdio: 'inherit' }
).toString();
console.log('Finish Comfy Manager Install and Rehydration');
}

if (os.platform() === 'darwin') {
const resultUpgradePip = spawnSync(`py`, ['-3.12', '-m', 'pip', 'install', '--upgrade pip'], {
shell: true,
stdio: 'pipe',
encoding: 'utf-8',
});
const resultInstallComfyCLI = spawnSync(`py`, ['-3.12 ', '-m', 'pip', 'install comfy-cli'], {
shell: true,
stdio: 'pipe',
encoding: 'utf-8',
});
const resultComfyManagerInstall = spawnSync('yarn run make:assets:macos', [''], {
shell: true,
stdio: 'pipe',
encoding: 'utf-8',
});

// Do not delete, useful if there are build issues with mac
// TODO: Consider making a global build log as ToDesktop logs can be hit or miss

fs.createFileSync('./assets/macpip.json');
fs.writeFileSync(
'./assets/macpip.json',
JSON.stringify({
upgradeOut: {
log: resultUpgradePip.stdout,
err: resultUpgradePip.stderr,
},
installComfOut: {
log: resultInstallComfyCLI.stdout,
err: resultInstallComfyCLI.stderr,
},
ComfManInstallOut: {
log: resultComfyManagerInstall.stdout,
err: resultComfyManagerInstall.stderr,
},
})
);

console.log('Finish Python & Comfy Install for Mac');
}
}

postInstall();

0 comments on commit 7fbf2bb

Please sign in to comment.