Skip to content

Commit

Permalink
use platfrom.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Metelkin committed Nov 17, 2023
1 parent c4a9b0a commit 7a67fb5
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 25 deletions.
69 changes: 53 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@
"ajv": "^8.12.0",
"heta-compiler": "^0.7.0",
"jquery": "^3.7.0",
"js-yaml": "^4.1.0",
"jszip": "^3.10.1",
"monaco-editor": "^0.41.0",
"semver": "^7.5.4",
"w3-css": "^4.1.0"
},
"engines": {
"node": ">=16.0.0"
}
}
18 changes: 10 additions & 8 deletions src/build.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Container, ModuleSystem, Transpot } from 'heta-compiler/src/webpack';
import { Container, ModuleSystem } from 'heta-compiler/src/webpack';
import path from 'path';
import declarationSchema from 'heta-compiler/src/builder/declaration-schema.json';
import Ajv from 'ajv';
import hetaCompilerPackage from 'heta-compiler/package.json';
import semver from 'semver';

const reader = new FileReaderSync();
import { load as yamlLoad } from 'js-yaml';

let ajv = new Ajv({allErrors: true, useDefaults: true});
ajv.addKeyword({
Expand Down Expand Up @@ -35,17 +34,20 @@ self.onmessage = (evt) => {
let inputDict = evt.data.files;
// first lines in console
postMessage({action: 'console', value: 'heta build'});
postMessage({action: 'console', value: '\nRunning compilation with declaration file "/platform.json"...'});

// create declaration
let declarationBuffer = inputDict['/platform.json'];
// search declaration
let declarationFileName = ['/platform.json', '/platform.json5', '/platform.yml'].find((x) => inputDict[x]);
let declarationBuffer = inputDict[declarationFileName];
if (!declarationBuffer) {
postMessage({action: 'console', value: '\n"platform.json" is not found.\nSTOP!\n\n$ '});
postMessage({action: 'console', value: '\n"platform.*" file is not found.\nSTOP!\n\n$ '});
return; // BRAKE
}

postMessage({action: 'console', value: `\nRunning compilation with declaration file "${declarationFileName}"...`});
let declarationText = new TextDecoder('utf-8').decode(declarationBuffer);
try {
var declaration = JSON.parse(declarationText);
//var declaration = JSON.parse(declarationText);
var declaration = yamlLoad(declarationText);
} catch (e) {
postMessage({action: 'console', value: `\nDeclaration file must be JSON formatted:`});
postMessage({action: 'console', value: `\n\t- ${e.message}`});
Expand Down
5 changes: 4 additions & 1 deletion src/pages-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class PagesCollection {
}
// for loading user files
async addPageFromFile(file) {
let ext = path.extname(file.name);
let {ext, name} = path.parse(file.name);

let formatName = Object.getOwnPropertyNames(FORMATS)
.find((x) => FORMATS[x].extension === ext);
Expand All @@ -61,6 +61,9 @@ export class PagesCollection {
if (format.pageType==='info') {
var page = new InfoPage(filepath, true, false, format.type)
.addTo(this);
} else if (name === 'platform' && ['.json', '.json5', 'yml'].indexOf(ext) ) {
page = new EditorPage(filepath, {language: format.language}, true, true, format.type)
.addTo(this);
} else {
page = new EditorPage(filepath, {language: format.language}, true, false, format.type)
.addTo(this);
Expand Down

0 comments on commit 7a67fb5

Please sign in to comment.