Naming refactor, remove id getter and use index
This commit is contained in:
parent
286fb57415
commit
d5392eafb8
|
@ -277,13 +277,13 @@ router.post('/execute', async (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/runtimes', (req, res) => {
|
router.get('/runtimes', (req, res) => {
|
||||||
const runtimes = runtime.map(rt => {
|
const runtimes = runtime.map((rt, index) => {
|
||||||
return {
|
return {
|
||||||
language: rt.language,
|
language: rt.language,
|
||||||
version: rt.version.raw,
|
version: rt.version.raw,
|
||||||
aliases: rt.aliases,
|
aliases: rt.aliases,
|
||||||
runtime: rt.runtime,
|
runtime: rt.runtime,
|
||||||
id: rt.id,
|
id: index,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,14 @@ expressWs(app);
|
||||||
|
|
||||||
logger.info('Loading packages');
|
logger.info('Loading packages');
|
||||||
|
|
||||||
const runtimes_data = cp.execSync(`nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames`).toString();
|
const runtimes_data = cp
|
||||||
const runtimes = JSON.parse(runtimes_data);
|
.execSync(
|
||||||
|
`nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames`
|
||||||
runtimes.for_each(pkg => runtime.load_runtime(pkg));
|
)
|
||||||
|
.toString();
|
||||||
|
const language_names = JSON.parse(runtimes_data);
|
||||||
|
|
||||||
|
language_names.for_each(language_name => runtime.load_runtime(language_name));
|
||||||
|
|
||||||
logger.info('Starting API Server');
|
logger.info('Starting API Server');
|
||||||
logger.debug('Constructing Express App');
|
logger.debug('Constructing Express App');
|
||||||
|
|
|
@ -120,9 +120,9 @@ class Runtime {
|
||||||
logger.debug(`Finished ensuring ${this} is installed`);
|
logger.debug(`Finished ensuring ${this} is installed`);
|
||||||
}
|
}
|
||||||
|
|
||||||
static load_runtime(flake_key) {
|
static load_runtime(language_name) {
|
||||||
logger.info(`Loading ${flake_key}`);
|
logger.info(`Loading ${language_name}`);
|
||||||
const flake_path = `${config.flake_path}#pistonRuntimeSets.${config.runtime_set}.${flake_key}`;
|
const flake_path = `${config.flake_path}#pistonRuntimeSets.${config.runtime_set}.${language_name}`;
|
||||||
const metadata_command = `nix eval --json ${flake_path}.metadata`;
|
const metadata_command = `nix eval --json ${flake_path}.metadata`;
|
||||||
const metadata = JSON.parse(cp.execSync(metadata_command));
|
const metadata = JSON.parse(cp.execSync(metadata_command));
|
||||||
|
|
||||||
|
@ -139,17 +139,13 @@ class Runtime {
|
||||||
|
|
||||||
runtimes.push(this_runtime);
|
runtimes.push(this_runtime);
|
||||||
|
|
||||||
logger.debug(`Package ${flake_key} was loaded`);
|
logger.debug(`Package ${language_name} was loaded`);
|
||||||
}
|
}
|
||||||
|
|
||||||
get compiled() {
|
get compiled() {
|
||||||
return this.compile !== null;
|
return this.compile !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get id() {
|
|
||||||
return runtimes.indexOf(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
return `${this.language}-${this.version}`;
|
return `${this.language}-${this.version}`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue