Compare commits
16 Commits
v0.8.2-bet
...
v0.8.6-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
48bd1e2015
|
|||
|
304665904f
|
|||
|
56ae3a85a6
|
|||
|
0178cb2194
|
|||
|
a2cb5cd473
|
|||
|
c123427e77
|
|||
|
7ac5ded185
|
|||
|
769d6ae8fc
|
|||
|
afb99ffc70
|
|||
|
46136e77e2
|
|||
|
b460b87318
|
|||
|
e772f0b50d
|
|||
|
187ad55291
|
|||
|
8156a1733f
|
|||
|
d1937fdb63
|
|||
|
3f826cc85d
|
10
.github/workflows/tagged-release.yml
vendored
10
.github/workflows/tagged-release.yml
vendored
@@ -16,15 +16,17 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/gradle-build-action@v2
|
||||||
- name: Clone repository
|
- name: Clone repository
|
||||||
uses: GuillaumeFalourd/clone-github-repo-action@main
|
uses: GuillaumeFalourd/clone-github-repo-action@main
|
||||||
with:
|
with:
|
||||||
branch: 'master' # fuck this political bullshitshit, took me an hour to fix this
|
branch: 'master'
|
||||||
owner: 'TopchetoEU'
|
owner: 'TopchetoEU'
|
||||||
repository: 'java-jscript'
|
repository: 'java-jscript'
|
||||||
- name: "Build"
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
cd java-jscript; node ./build.js release ${{ github.ref }}
|
cd java-jscript; gradle build
|
||||||
|
|
||||||
- uses: "marvinpinto/action-automatic-releases@latest"
|
- uses: "marvinpinto/action-automatic-releases@latest"
|
||||||
with:
|
with:
|
||||||
@@ -32,4 +34,4 @@ jobs:
|
|||||||
prerelease: false
|
prerelease: false
|
||||||
files: |
|
files: |
|
||||||
java-jscript/LICENSE
|
java-jscript/LICENSE
|
||||||
java-jscript/dst/*.jar
|
java-jscript/build/libs/*.jar
|
||||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
!/src
|
!/src
|
||||||
!/src/**/*
|
!/src/**/*
|
||||||
/src/assets/js/ts.js
|
|
||||||
|
|
||||||
!/doc
|
!/doc
|
||||||
!/doc/**/*
|
!/doc/**/*
|
||||||
@@ -10,12 +9,16 @@
|
|||||||
!/tests
|
!/tests
|
||||||
!/tests/**/*
|
!/tests/**/*
|
||||||
|
|
||||||
|
|
||||||
!/.github
|
!/.github
|
||||||
!/.github/**/*
|
!/.github/**/*
|
||||||
|
|
||||||
!/.gitignore
|
!/.gitignore
|
||||||
!/.gitattributes
|
!/.gitattributes
|
||||||
!/build.js
|
|
||||||
!/LICENSE
|
!/LICENSE
|
||||||
!/README.md
|
!/README.md
|
||||||
|
!/settings.gradle
|
||||||
|
!/build.gradle
|
||||||
|
!/gradle.properties
|
||||||
|
!/gradle
|
||||||
|
!/gradle/wrapper
|
||||||
|
!/gradle/wrapper/gradle-wrapper.properties
|
||||||
32
build.gradle
Normal file
32
build.gradle
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
plugins {
|
||||||
|
id "application"
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
toolchain.languageVersion = JavaLanguageVersion.of(11)
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
manifest.attributes["Main-class"] = project.main_class
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs = [ "src/java" ]
|
||||||
|
main.resources.srcDirs = [ "src/assets" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
filesMatching "metadata.json", {
|
||||||
|
expand(
|
||||||
|
version: project.project_version,
|
||||||
|
name: project.project_name
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
base.archivesName = project.project_name
|
||||||
|
version = project.project_version
|
||||||
|
group = project.project_group
|
||||||
193
build.js
193
build.js
@@ -1,193 +0,0 @@
|
|||||||
const { spawn } = require('child_process');
|
|
||||||
const fs = require('fs/promises');
|
|
||||||
const pt = require('path');
|
|
||||||
const { argv, exit } = require('process');
|
|
||||||
const { Readable } = require('stream');
|
|
||||||
|
|
||||||
|
|
||||||
async function* find(src, dst, wildcard) {
|
|
||||||
const stat = await fs.stat(src);
|
|
||||||
|
|
||||||
if (stat.isDirectory()) {
|
|
||||||
for (const el of await fs.readdir(src)) {
|
|
||||||
for await (const res of find(pt.join(src, el), dst ? pt.join(dst, el) : undefined, wildcard)) yield res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (stat.isFile() && wildcard(src)) yield dst ? { src, dst } : src;
|
|
||||||
}
|
|
||||||
async function copy(src, dst, wildcard) {
|
|
||||||
const promises = [];
|
|
||||||
|
|
||||||
for await (const el of find(src, dst, wildcard)) {
|
|
||||||
promises.push((async () => {
|
|
||||||
await fs.mkdir(pt.dirname(el.dst), { recursive: true });
|
|
||||||
await fs.copyFile(el.src, el.dst);
|
|
||||||
})());
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(promises);
|
|
||||||
}
|
|
||||||
|
|
||||||
function run(suppressOutput, cmd, ...args) {
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
const proc = spawn(cmd, args, { stdio: suppressOutput ? 'ignore' : 'inherit' });
|
|
||||||
proc.once('exit', code => {
|
|
||||||
if (code === 0) res(code);
|
|
||||||
else rej(new Error(`Process ${cmd} exited with code ${code}.`));
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function downloadTypescript(outFile) {
|
|
||||||
try {
|
|
||||||
// Import the required libraries, without the need of a package.json
|
|
||||||
console.log('Importing modules...');
|
|
||||||
await run(true, 'npm', 'i', 'tar', 'zlib', 'uglify-js');
|
|
||||||
await fs.mkdir(pt.dirname(outFile), { recursive: true });
|
|
||||||
await fs.mkdir('tmp', { recursive: true });
|
|
||||||
|
|
||||||
const tar = require('tar');
|
|
||||||
const zlib = require('zlib');
|
|
||||||
const { minify } = await import('uglify-js');
|
|
||||||
|
|
||||||
// Download the package.json file of typescript
|
|
||||||
const packageDesc = await (await fetch('https://registry.npmjs.org/typescript/latest')).json();
|
|
||||||
const url = packageDesc.dist.tarball;
|
|
||||||
|
|
||||||
console.log('Extracting typescript...');
|
|
||||||
await new Promise(async (res, rej) => Readable.fromWeb((await fetch(url)).body)
|
|
||||||
.pipe(zlib.createGunzip())
|
|
||||||
.pipe(tar.x({ cwd: 'tmp', filter: v => v === 'package/lib/typescript.js' }))
|
|
||||||
.on('end', res)
|
|
||||||
.on('error', rej)
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('Compiling typescript to ES5...');
|
|
||||||
|
|
||||||
const ts = require('./tmp/package/lib/typescript');
|
|
||||||
const program = ts.createProgram([ 'tmp/package/lib/typescript.js' ], {
|
|
||||||
outFile: "tmp/typescript-es5.js",
|
|
||||||
target: ts.ScriptTarget.ES5,
|
|
||||||
module: ts.ModuleKind.None,
|
|
||||||
downlevelIteration: true,
|
|
||||||
allowJs: true,
|
|
||||||
});
|
|
||||||
program.emit();
|
|
||||||
|
|
||||||
console.log('Minifying typescript...');
|
|
||||||
|
|
||||||
const minified = minify((await fs.readFile('tmp/typescript-es5.js')).toString());
|
|
||||||
// const minified = { code: (await fs.readFile('tmp/typescript-es5.js')).toString() };
|
|
||||||
if (minified.error) throw minified.error;
|
|
||||||
|
|
||||||
// Patch unsupported regex syntax
|
|
||||||
minified.code = minified.code.replaceAll('[-/\\\\^$*+?.()|[\\]{}]', '[-/\\\\^$*+?.()|\\[\\]{}]');
|
|
||||||
|
|
||||||
const stream = await fs.open(outFile, 'w');
|
|
||||||
|
|
||||||
// Write typescript's license
|
|
||||||
await stream.write(new TextEncoder().encode(`
|
|
||||||
/*! *****************************************************************************
|
|
||||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
||||||
this file except in compliance with the License. You may obtain a copy of the
|
|
||||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
||||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
||||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
||||||
|
|
||||||
See the Apache Version 2.0 License for specific language governing permissions
|
|
||||||
and limitations under the License.
|
|
||||||
|
|
||||||
The following is a minified version of the unmodified Typescript 5.2
|
|
||||||
***************************************************************************** */
|
|
||||||
`));
|
|
||||||
|
|
||||||
await stream.write(minified.code);
|
|
||||||
console.log('Typescript bundling done!');
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
// Clean up all stuff left from typescript bundling
|
|
||||||
await fs.rm('tmp', { recursive: true, force: true });
|
|
||||||
await fs.rm('package.json');
|
|
||||||
await fs.rm('package-lock.json');
|
|
||||||
await fs.rm('node_modules', { recursive: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function compileJava(conf) {
|
|
||||||
try {
|
|
||||||
await fs.writeFile('Metadata.java', (await fs.readFile('src/me/topchetoeu/jscript/common/Metadata.java')).toString()
|
|
||||||
.replace('${VERSION}', conf.version)
|
|
||||||
.replace('${NAME}', conf.name)
|
|
||||||
.replace('${AUTHOR}', conf.author)
|
|
||||||
);
|
|
||||||
const args = ['--release', '11', ];
|
|
||||||
if (argv[2] === 'debug') args.push('-g');
|
|
||||||
args.push('-d', 'dst/classes', 'Metadata.java');
|
|
||||||
|
|
||||||
console.log('Compiling java project...');
|
|
||||||
for await (const path of find('src', undefined, v => v.endsWith('.java') && !v.endsWith('Metadata.java'))) args.push(path);
|
|
||||||
await run(false, conf.javahome + 'javac', ...args);
|
|
||||||
console.log('Compiled java project!');
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
await fs.rm('Metadata.java');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function jar(conf, project, mainClass) {
|
|
||||||
const args = [
|
|
||||||
'jar', '-c',
|
|
||||||
'-f', `dst/${project}-v${conf.version}.jar`,
|
|
||||||
];
|
|
||||||
if (mainClass) args.push('-e', mainClass);
|
|
||||||
args.push('-C', 'dst/classes', project.replaceAll('.', '/'));
|
|
||||||
console.log(args.join(' '));
|
|
||||||
|
|
||||||
await run(true, ...args);
|
|
||||||
}
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
if (argv[2] === 'init-ts') {
|
|
||||||
await downloadTypescript('src/me/topchetoeu/jscript/utils/assets/js/ts.js');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const conf = {
|
|
||||||
name: "java-jscript",
|
|
||||||
author: "TopchetoEU",
|
|
||||||
javahome: "",
|
|
||||||
version: argv[3]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (conf.version.startsWith('refs/tags/')) conf.version = conf.version.substring(10);
|
|
||||||
if (conf.version.startsWith('v')) conf.version = conf.version.substring(1);
|
|
||||||
|
|
||||||
try { await fs.rm('dst', { recursive: true }); } catch {}
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
(async () => {
|
|
||||||
await copy('src', 'dst/classes', v => !v.endsWith('.java'));
|
|
||||||
await downloadTypescript('dst/classes/me/topchetoeu/jscript/utils/assets/js/ts.js');
|
|
||||||
})(),
|
|
||||||
compileJava(conf),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
jar(conf, 'me.topchetoeu.jscript.common'),
|
|
||||||
jar(conf, 'me.topchetoeu.jscript.core'),
|
|
||||||
jar(conf, 'me.topchetoeu.jscript.lib'),
|
|
||||||
jar(conf, 'me.topchetoeu.jscript.utils'),
|
|
||||||
jar(conf, 'me.topchetoeu.jscript', 'me.topchetoeu.jscript.utils.JScriptRepl'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
console.log('Done!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
if (argv[2] === 'debug') throw e;
|
|
||||||
console.log(e.toString());
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
4
gradle.properties
Normal file
4
gradle.properties
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
project_group = me.topchetoeu
|
||||||
|
project_name = jscript
|
||||||
|
project_version = 0.8.6-beta
|
||||||
|
main_class = me.topchetoeu.jscript.utils.JScriptRepl
|
||||||
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
5
settings.gradle
Normal file
5
settings.gradle
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
plugins {
|
||||||
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = properties.project_name
|
||||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
5
src/assets/metadata.json
Normal file
5
src/assets/metadata.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"version": "${version}",
|
||||||
|
"name": "${name}",
|
||||||
|
"author": "TopchetoEU"
|
||||||
|
}
|
||||||
@@ -1,9 +1,18 @@
|
|||||||
package me.topchetoeu.jscript.common;
|
package me.topchetoeu.jscript.common;
|
||||||
|
|
||||||
|
import me.topchetoeu.jscript.common.json.JSON;
|
||||||
|
|
||||||
public class Metadata {
|
public class Metadata {
|
||||||
private static final String VERSION = "${VERSION}";
|
private static final String VERSION;
|
||||||
private static final String AUTHOR = "${AUTHOR}";
|
private static final String AUTHOR;
|
||||||
private static final String NAME = "${NAME}";
|
private static final String NAME;
|
||||||
|
|
||||||
|
static {
|
||||||
|
var data = JSON.parse(null, Reading.resourceToString("metadata.json")).map();
|
||||||
|
VERSION = data.string("version");
|
||||||
|
AUTHOR = data.string("author");
|
||||||
|
NAME = data.string("name");
|
||||||
|
}
|
||||||
|
|
||||||
public static String version() {
|
public static String version() {
|
||||||
if (VERSION.equals("$" + "{VERSION}")) return "1337-devel";
|
if (VERSION.equals("$" + "{VERSION}")) return "1337-devel";
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.topchetoeu.jscript.utils.mapping;
|
package me.topchetoeu.jscript.common;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -711,14 +711,14 @@ public class Values {
|
|||||||
res.append("{\n");
|
res.append("{\n");
|
||||||
|
|
||||||
for (var el : obj.values.entrySet()) {
|
for (var el : obj.values.entrySet()) {
|
||||||
for (int i = 0; i < tab + 1; i++) System.out.print(" ");
|
for (int i = 0; i < tab + 1; i++) res.append(" ");
|
||||||
res.append(toReadable(ctx, el.getKey(), passed, tab + 1));
|
res.append(toReadable(ctx, el.getKey(), passed, tab + 1));
|
||||||
res.append(": ");
|
res.append(": ");
|
||||||
res.append(toReadable(ctx, el.getValue(), passed, tab + 1));
|
res.append(toReadable(ctx, el.getValue(), passed, tab + 1));
|
||||||
res.append(",\n");
|
res.append(",\n");
|
||||||
}
|
}
|
||||||
for (var el : obj.properties.entrySet()) {
|
for (var el : obj.properties.entrySet()) {
|
||||||
for (int i = 0; i < tab + 1; i++) System.out.print(" ");
|
for (int i = 0; i < tab + 1; i++) res.append(" ");
|
||||||
res.append(toReadable(ctx, el.getKey(), passed, tab + 1));
|
res.append(toReadable(ctx, el.getKey(), passed, tab + 1));
|
||||||
res.append(": [prop],\n");
|
res.append(": [prop],\n");
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user