2024-01-30 11:29:07 -05:00
|
|
|
const { execAsync, monitorFile } = Utils;
|
2024-01-13 16:07:33 -05:00
|
|
|
|
|
|
|
|
2024-01-17 19:18:41 -05:00
|
|
|
/** @param {string} host */
|
|
|
|
const watchAndCompileSass = (host) => {
|
2024-01-13 16:07:33 -05:00
|
|
|
const reloadCss = () => {
|
2024-01-17 19:18:41 -05:00
|
|
|
const scss = `${App.configDir}/scss/${host}.scss`;
|
2024-02-06 12:59:55 -05:00
|
|
|
const css = `/tmp/ags-${host}/style.css`;
|
2024-01-13 16:07:33 -05:00
|
|
|
|
|
|
|
execAsync(`sassc ${scss} ${css}`).then(() => {
|
|
|
|
App.resetCss();
|
|
|
|
App.applyCss(css);
|
2024-01-13 23:38:31 -05:00
|
|
|
}).catch(print);
|
2024-01-13 16:07:33 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
monitorFile(
|
|
|
|
`${App.configDir}/scss`,
|
|
|
|
reloadCss,
|
|
|
|
);
|
|
|
|
reloadCss();
|
|
|
|
};
|
|
|
|
|
2024-01-17 19:18:41 -05:00
|
|
|
/** @param {string} host */
|
|
|
|
export const transpileTypeScript = async(host) => {
|
2024-02-06 12:59:55 -05:00
|
|
|
const outPath = `/tmp/ags-${host}/index.js`;
|
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
await execAsync([
|
2024-02-06 12:59:55 -05:00
|
|
|
'bash', '-c',
|
|
|
|
// Create the dir if it doesn't exist
|
|
|
|
`mkdir -p /tmp/ags-${host}; ` +
|
|
|
|
|
|
|
|
`bun build ${App.configDir}/${host}.ts ` +
|
|
|
|
'--external resource:///* ' +
|
|
|
|
'--external gi://* ' +
|
|
|
|
'--external cairo ' +
|
|
|
|
'--external */fzf.es.js ' +
|
|
|
|
|
|
|
|
// Since bun wants to right in cwd, we just redirect stdin instead
|
|
|
|
`> ${outPath}`,
|
2024-01-13 23:38:31 -05:00
|
|
|
]).catch(print);
|
|
|
|
|
2024-02-05 22:46:43 -05:00
|
|
|
if (host !== 'greeter') {
|
|
|
|
watchAndCompileSass(host);
|
|
|
|
}
|
2024-01-13 23:38:31 -05:00
|
|
|
|
2024-02-06 12:59:55 -05:00
|
|
|
return await import(`file://${outPath}`);
|
2024-01-13 16:07:33 -05:00
|
|
|
};
|