Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
Structure cleaning for 3.0 (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarletquasar authored Aug 5, 2023
2 parents a94f494 + c8281e2 commit 5c36829
Show file tree
Hide file tree
Showing 261 changed files with 8,631 additions and 8,518 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
projects/melon-runtime/Output
projects/melon-core/babel
projects/melon-core/dist
projects/melon-core/types
projects/native/Output
projects/native/bin
projects/native/obj
projects/core/output
node_modules
projects/melon-tests/dist
projects/melon-tests/babel
projects/tests/dist
projects/tests/babel

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
Expand Down
17 changes: 2 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
{
"scripts": {
"_build_core": "cd ./projects/melon-core && npm run build && cd ../..",
"_build_tests": "cd ./projects/melon-tests && npm run build && cd ../..",
"_apply_core_bundle_windows": "xcopy .\\projects\\melon-core\\dist\\core.js .\\projects\\melon-runtime\\MelonRuntime.Core\\Scripts\\core.js /Y",
"_apply_core_bundle_linux": "cp ./projects/melon-core/dist/core.js ./projects/melon-runtime/Melon.Library/Bundle/core.js",
"_apply_tests_bundle_windows": "xcopy .\\projects\\melon-tests\\dist\\tests.js .\\projects\\melon-runtime\\MelonRuntime.Core\\Scripts\\tests.js /Y",
"_apply_tests_bundle_linux": "cp ./projects/melon-tests/dist/tests.js ./projects/melon-runtime/Melon.Library/Bundle/tests.js",
"_build_runtime": "cd ./projects/melon-runtime && npm run build && cd ../..",
"_run": "cd ./projects/melon-runtime && npm run dev && cd ../..",
"build:win": "npm run _build_core && npm run _apply_core_bundle_windows && npm run _build_tests && npm run _apply_tests_bundle_windows && npm run _build_runtime",
"build:linux": "npm run _build_core && npm run _apply_core_bundle_linux && npm run _build_tests && npm run _apply_tests_bundle_linux && npm run _build_runtime",
"dev:win": "npm run build:win && npm run _run",
"dev:linux": "npm run build:linux && npm run _run",
"install-dev:win": "npm run build:win && cd ./projects/melon-runtime && npm i -g -f && cd ../..",
"install-dev:linux": "npm run build:linux && cd ./projects/melon-runtime && npm i -g -f && cd ../..",
"all-benchmarks": "cd ./projects/melon-benchmarks/ && npm run all-benchmarks"
"build": "cd projects/core && npm run build && cd ../native && npm run build",
"dev": "cd projects/native && npm run dev"
}
}
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions projects/core/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": ["@babel/preset-typescript", "@babel/preset-env"],
"plugins": [
[
"module-resolver",
{
"alias": {
"types": "./types",
"logic": "./logic"
}
}
]
]
}
103 changes: 103 additions & 0 deletions projects/core/build-core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { spawnSync } from "child_process"
import { mkdirSync, cpSync, rmSync, existsSync } from "fs"

/*
:: [core] building Script
:: =========================
:: Warning: "-i" will overwrite the packages '@babel/core',
:: '@babel/cli' and 'webpack-cli' globally.
*/

export const CHILD_SPAWN_OPTIONS: unknown = {
stdio: "inherit",
shell: true
};

const GLOBAL_INSTALLS = [
"@babel/cli",
"@babel/core",
"webpack-cli"
];

const args = process.argv;
const forceGlobalInstalls = args.includes(" -i ");
const keepCache = args.includes(" -kc ");

if (args.includes(" --help ")) {
console.log(" --kc | Keep the previous build cache")
console.log(" -i | Forces global installs")
process.exit(0);
}

console.log("──────────────────────────────────────────────────────");
console.log("Melon Runtime Builder - Core");
console.log("──────────────────────────────────────────────────────");

if (forceGlobalInstalls) {
console.log("──────────────────────────────────────────────────────");
console.log("Installing Global Dependencies");
console.log("──────────────────────────────────────────────────────");

spawnSync("npm", [
"install",
...GLOBAL_INSTALLS,
"-g",
"-f"
], CHILD_SPAWN_OPTIONS);
}

if (!keepCache) {
console.log("──────────────────────────────────────────────────────");
console.log("Cleaning the previous build...");
console.log("──────────────────────────────────────────────────────");

if (existsSync(__dirname + "\\output")) {
rmSync(__dirname + "\\output", { recursive: true, force: true });
}
}

console.log("──────────────────────────────────────────────────────");
console.log("Installing Local Dependencies...");
console.log("──────────────────────────────────────────────────────");

mkdirSync("output");

spawnSync("npm", [
"install",
"-f"
], CHILD_SPAWN_OPTIONS);

console.log("──────────────────────────────────────────────────────");
console.log("Executing transpiler (TypeScript >> JavaScript)...");
console.log("──────────────────────────────────────────────────────");

spawnSync("echo", ["a"])
spawnSync("npx", [
"babel",
"--extensions",
".ts",
__dirname + "\\",
"--out-dir",
__dirname + "\\output\\js-logic"
], CHILD_SPAWN_OPTIONS);

console.log("──────────────────────────────────────────────────────");
console.log("Executing bundler (JavaScript >> Core bundle)...");
console.log("──────────────────────────────────────────────────────");

spawnSync("npx", [
"webpack",
__dirname + "\\output\\js-logic\\logic\\index.js",
"--config webpack.config.json"
], CHILD_SPAWN_OPTIONS);

console.log("──────────────────────────────────────────────────────");
console.log("Copying output files...");
console.log("──────────────────────────────────────────────────────");

cpSync(__dirname + "\\dist", __dirname + "\\output\\final", { recursive: true, force: true });
rmSync(__dirname + "\\dist", { recursive: true, force: true });

console.log("──────────────────────────────────────────────────────");
console.log("Done.");
console.log("──────────────────────────────────────────────────────");
File renamed without changes.
41 changes: 41 additions & 0 deletions projects/core/logic/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Utilitary imports
import { setupEnvironmentVariables } from "logic/runtime/global-environment-core";
import { addPrototypeExtension } from "./partials/utils/generic/addPrototypeExtension";
import { and } from "logic/runtime/global-extensions";

// Isolated imports
import { _Version } from "./partials/constructors/_Version"

// Module imports
import { console as _console } from "logic/partials/modules/console/console"
import { dotnet } from "./partials/modules/dotnet/dotnet"
import { _crypto } from "./partials/statics/_Crypto"
import { _fs } from "./partials/modules/fs/fs"
import { _guards } from "./partials/modules/guards/_guards"
import { http } from "./partials/modules/http/http"
import { _std } from "./partials/modules/std/_std"
import { _data } from "./partials/modules/data/_data"
import { testing } from "./partials/modules/testing/testing"
import { runtime } from "./partials/modules/runtime/runtime"
import { interopCache } from "./runtime/interop-cache-core";

setupEnvironmentVariables();
addPrototypeExtension(Object, "and", and);

const Melon = {
console: _console,
testing,
std: _std,
data: _data,
guards: _guards,
fs: _fs,
http,
dotnet,
crypto: _crypto,
runtime,
Version: _Version
}

globalThis["Melon"] = Melon;

export { Melon }
Loading

0 comments on commit 5c36829

Please sign in to comment.