@aeriajs/compiler 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/compile.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { CompilationOptions, CompilationResult } from './types.js';
2
2
  import { Diagnostic } from './diagnostic.js';
3
+ export declare const FILE_PRECEDENCE: string[];
3
4
  export declare const parseAndCheck: (sources: Record<string, string>, options?: Pick<CompilationOptions, "languageServer">) => Promise<CompilationResult>;
4
5
  export declare const generateScaffolding: (options: CompilationOptions) => Promise<string[]>;
5
6
  export declare const compileFromFiles: (schemaDir: string, options: CompilationOptions) => Promise<CompilationResult | {
package/dist/compile.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.compileFromFiles = exports.generateScaffolding = exports.parseAndCheck = void 0;
36
+ exports.compileFromFiles = exports.generateScaffolding = exports.parseAndCheck = exports.FILE_PRECEDENCE = void 0;
37
37
  const diagnostic_js_1 = require("./diagnostic.js");
38
38
  const lexer_js_1 = require("./lexer.js");
39
39
  const parser_js_1 = require("./parser.js");
@@ -41,6 +41,7 @@ const semantic_js_1 = require("./semantic.js");
41
41
  const codegen_js_1 = require("./codegen.js");
42
42
  const path = __importStar(require("node:path"));
43
43
  const fs = __importStar(require("node:fs"));
44
+ exports.FILE_PRECEDENCE = ['contract'];
44
45
  const parseAndCheck = async (sources, options = {}) => {
45
46
  const errors = [];
46
47
  let errorCount = 0;
@@ -80,10 +81,20 @@ const generateScaffolding = async (options) => {
80
81
  };
81
82
  exports.generateScaffolding = generateScaffolding;
82
83
  const compileFromFiles = async (schemaDir, options) => {
83
- const fileList = await fs.promises.readdir(schemaDir);
84
+ const fileList = await Array.fromAsync(fs.promises.glob(`${schemaDir}/*.aeria`));
85
+ const sortedFileList = fileList.sort((a, b) => {
86
+ const aIndex = exports.FILE_PRECEDENCE.findIndex((file) => a.split('/').at(-1).startsWith(file));
87
+ const bIndex = exports.FILE_PRECEDENCE.findIndex((file) => b.split('/').at(-1).startsWith(file));
88
+ if (!~aIndex && !~bIndex) {
89
+ return 1;
90
+ }
91
+ return aIndex > bIndex
92
+ ? 1
93
+ : -1;
94
+ });
84
95
  const sources = {};
85
- for (const file of fileList) {
86
- sources[file] = await fs.promises.readFile(`${schemaDir}/${file}`, {
96
+ for (const file of sortedFileList) {
97
+ sources[file] = await fs.promises.readFile(file, {
87
98
  encoding: 'utf-8',
88
99
  });
89
100
  }
package/dist/compile.mjs CHANGED
@@ -6,6 +6,7 @@ import { analyze } from "./semantic.mjs";
6
6
  import { generateCode } from "./codegen.mjs";
7
7
  import * as path from "node:path";
8
8
  import * as fs from "node:fs";
9
+ export const FILE_PRECEDENCE = ["contract"];
9
10
  export const parseAndCheck = async (sources, options = {}) => {
10
11
  const errors = [];
11
12
  let errorCount = 0;
@@ -42,10 +43,18 @@ export const generateScaffolding = async (options) => {
42
43
  return directories;
43
44
  };
44
45
  export const compileFromFiles = async (schemaDir, options) => {
45
- const fileList = await fs.promises.readdir(schemaDir);
46
+ const fileList = await Array.fromAsync(fs.promises.glob(`${schemaDir}/*.aeria`));
47
+ const sortedFileList = fileList.sort((a, b) => {
48
+ const aIndex = FILE_PRECEDENCE.findIndex((file) => a.split("/").at(-1).startsWith(file));
49
+ const bIndex = FILE_PRECEDENCE.findIndex((file) => b.split("/").at(-1).startsWith(file));
50
+ if (!~aIndex && !~bIndex) {
51
+ return 1;
52
+ }
53
+ return aIndex > bIndex ? 1 : -1;
54
+ });
46
55
  const sources = {};
47
- for (const file of fileList) {
48
- sources[file] = await fs.promises.readFile(`${schemaDir}/${file}`, {
56
+ for (const file of sortedFileList) {
57
+ sources[file] = await fs.promises.readFile(file, {
49
58
  encoding: "utf-8"
50
59
  });
51
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/compiler",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",