2024-01-13 16:07:33 -05:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
|
|
|
import { execAsync, monitorFile } from 'resource:///com/github/Aylur/ags/utils.js';
|
|
|
|
|
|
|
|
|
|
|
|
export const watchAndCompileSass = () => {
|
|
|
|
const reloadCss = () => {
|
|
|
|
const scss = `${App.configDir}/scss/main.scss`;
|
|
|
|
const css = '/tmp/ags/style.css';
|
|
|
|
|
|
|
|
execAsync(`sassc ${scss} ${css}`).then(() => {
|
|
|
|
App.resetCss();
|
|
|
|
App.applyCss(css);
|
2024-01-13 16:49:40 -05:00
|
|
|
}).catch(reloadCss);
|
2024-01-13 16:07:33 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
monitorFile(
|
|
|
|
`${App.configDir}/scss`,
|
|
|
|
reloadCss,
|
|
|
|
'directory',
|
|
|
|
);
|
|
|
|
reloadCss();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const transpileTypeScript = async(
|
|
|
|
src = App.configDir,
|
|
|
|
out = '/tmp/ags',
|
|
|
|
) => {
|
|
|
|
const promises = [];
|
|
|
|
const files = (await execAsync([
|
|
|
|
'find', `${src}/`,
|
|
|
|
'-wholename', `${src}/services/*.ts`,
|
|
|
|
'-o',
|
|
|
|
'-wholename', `${src}/ts/*.ts`,
|
|
|
|
])).split('\n');
|
|
|
|
|
|
|
|
/** @param {string} p */
|
|
|
|
const getDirectoryPath = (p) => p.substring(0, p.lastIndexOf('/'));
|
|
|
|
|
|
|
|
files.forEach((file) => {
|
|
|
|
const outDir = getDirectoryPath(out + file
|
|
|
|
.replace(`${src}/ts`, '/ts')
|
|
|
|
.replace(`${src}/services`, '/services'));
|
|
|
|
|
|
|
|
promises.push(
|
|
|
|
execAsync([
|
|
|
|
'bun', 'build', file,
|
|
|
|
'--outdir', outDir,
|
|
|
|
'--external', '*',
|
|
|
|
]).catch(print),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
await Promise.all(promises);
|
|
|
|
|
|
|
|
return `file://${out}/ts/main.js`;
|
|
|
|
};
|