First commit

This commit is contained in:
2025-12-25 11:16:59 +01:00
commit 0c5ca09a63
720 changed files with 329234 additions and 0 deletions

View File

@@ -0,0 +1,160 @@
import filemanager from "../server/filemanager.js";
import simplePath from "../unify/simplePath.js";
import fs from "fs-extra";
import path from "path";
class converter{
replacements = new Array();
createPlatformCachePath( applicationPath ) {
var cachePath = new simplePath();
cachePath.beginWithSlash = false;
cachePath.add( "../../" );
cachePath.add( "application" );
cachePath.add( applicationPath );
return cachePath.resolve();
}
addReplacement( from, to ) {
var replacement = new Object();
replacement.from = from;
replacement.to = to;
this.replacements.push( replacement );
}
constructor() {
this.addReplacement( "list", "userList" );
this.addReplacement( "news", "user" );
}
async loadFiles() {
var path = this.createPlatformCachePath( "demo/userList/cache" )
var files = new filemanager( path );
await files.findApplicationFiles( "./application/demo/userList");
this.saveFiles( files );
}
replaceFileName( filePath, from, to ) {
var parts = filePath.split("/");
var filename = parts.pop().replaceAll( from, to );
return parts.join("/") + "/" + filename;
}
saveFiles( files ) {
var files = files.files;
for (var i = 0; i < files.length; i++) {
var file = files[i];
var filePath = file.filePath;
var fileType = file.type;
var convertPath = path.resolve( "./converted/" + filePath );
for (var j = 0; j < this.replacements.length; j++) {
var replacement = this.replacements[j];
convertPath = this.replaceFileName( convertPath, replacement.from, replacement.to );
}
if( fileType == "directory" ) {
fs.ensureDirSync( convertPath )
}
}
for (var i = 0; i < files.length; i++) {
var file = files[i];
var name = file.name;
var filePath = file.filePath;
var fileType = file.type;
var source = file.source;
var convertPath = path.resolve( "./converted/" + filePath );
for (var j = 0; j < this.replacements.length; j++) {
var replacement = this.replacements[j];
convertPath = this.replaceFileName( convertPath, replacement.from, replacement.to );
}
if( file.type == "file" ) {
var replacedSource = source;
for (var j = 0; j < this.replacements.length; j++) {
var replacement = this.replacements[j];
replacedSource = replacedSource.replaceAll( replacement.from, replacement.to );
}
console.log( "Save file: ", convertPath );
fs.writeFileSync( convertPath, replacedSource )
}
}
}
}
var convert = new converter();
convert.loadFiles();
//files.
//console.log( files );

View File

@@ -0,0 +1,33 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft,
https://unifyjs.org
*/
import esbuild from "../../node_modules/esbuild/node_modules/esbuild/lib/main.js";
import fse from "fs-extra";
esbuild.build({
bundle: true,
entryPoints: ["./framework/server/index.js"],
outfile: "./platforms/android/projectRoot/framework/server/index.js",
platform: "node",
target: "node12",
keepNames: true,
external: ["../node_modules/better-sqlite3/node_modules/better-sqlite3/lib/index.js" ]
});
var uniqueName = Math.floor(Math.random() * 10000000000);
fse.copySync("./assets/bundle.js", "./platforms/android/projectRoot/assets/bundle-" +uniqueName+ ".js");
fse.writeFileSync( "./platforms/android/projectRoot/assets/bundleName.json", JSON.stringify( { uniqueName : uniqueName } ) );

View File

@@ -0,0 +1,34 @@
import binaryName from "../../node_modules/esbuild/getBinaryName.js"
import child_process from 'child_process';
var options = new Object();
options.stdio = 'inherit';
var args = new Array();
args.push("--bundle")
args.push('out1=framework/client/index.js')
args.push("--outfile=assets/bundle.js")
args.push("--keep-names")
args.push('--external:fs, better-sqlite3, process')
args.push('--format=esm')
var child = child_process.spawn( binaryName, args, options );
console.log(binaryName);

View File

@@ -0,0 +1,22 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft,
https://unifyjs.org
*/
import esbuild from "esbuild";
esbuild.buildSync({
bundle: true,
entryPoints: ["node_modules/concurrently/dist/bin/concurrently.js"],
outfile: "concurrently_bundle.js",
keepNames: true,
target: ['node16.7']
});

View File

@@ -0,0 +1,35 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft,
https://unifyjs.org
*/
import esbuild from "../../node_modules/esbuild/node_modules/esbuild/lib/main.js";
import fse from "fs-extra";
esbuild.build({
bundle: true,
entryPoints: ["./framework/server/index.js"],
outfile: "./platforms/hybrid/framework/server/index.js",
platform: "node",
target: "node12",
keepNames: true,
external: [ ]
});
fse.copySync("./framework/configs", "./platforms/hybrid/framework/configs");
fse.copySync("./assets/bundle.js", "./platforms/hybrid/assets/bundle.js");
fse.copySync("framework/node_modules/better-sqlite3/node_modules/better-sqlite3/build/Release/", "./platforms/hybrid/build/");
fse.copySync("./assets/production", "./platforms/hybrid/assets/production");

View File

@@ -0,0 +1,32 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft,
https://unifyjs.org
*/
import esbuild from "../../node_modules/esbuild/node_modules/esbuild/lib/main.js";
import fse from "fs-extra";
esbuild.build({
bundle: true,
entryPoints: ["./framework/server/index.js"],
outfile: "./native/framework/server/index.js",
platform: "node",
target: "node12",
keepNames: true,
external: [ ]
});
fse.copySync("./assets/bundle.js", "./native/assets/bundle.js");
fse.copySync("framework/node_modules/better-sqlite3/node_modules/better-sqlite3/build/Release/", "./native/build/");

View File

@@ -0,0 +1,21 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft,
https://unifyjs.org
*/
import fse from "fs-extra";
import path from 'path';
var __dirname = path.resolve();
fse.copySync( __dirname + "/native_modules/", __dirname + "/android/node_modules/");

View File

@@ -0,0 +1,196 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft,
https://unifyjs.org
*/
import fs from "fs-extra";
//process.chdir('../../');
// Framework
if( fs.existsSync( "framework/node_modules/esbuild/node_modules" ) ) {
fs.rmSync("framework/node_modules/esbuild/node_modules", { recursive: true });
}
if( fs.existsSync( "framework/node_modules/ws/node_modules" ) ) {
fs.rmSync("framework/node_modules/ws/node_modules", { recursive: true });
}
if( fs.existsSync( "framework/node_modules/better-sqlite3/node_modules" ) ) {
fs.rmSync("framework/node_modules/better-sqlite3/node_modules", { recursive: true });
}
if( fs.existsSync( "framework/node_modules/caxa/node_modules" ) ) {
fs.rmSync("framework/node_modules/caxa/node_modules", { recursive: true });
}
if( fs.existsSync( "framework/node_modules/esbuild/package-lock.json" ) ) {
fs.rmSync("framework/node_modules/esbuild/package-lock.json", { recursive: true });
}
if( fs.existsSync( "framework/node_modules/ws/package-lock.json" ) ) {
fs.rmSync("framework/node_modules/ws/package-lock.json", { recursive: true });
}
if( fs.existsSync( "framework/node_modules/better-sqlite3/package-lock.json" ) ) {
fs.rmSync("framework/node_modules/better-sqlite3/package-lock.json", { recursive: true });
}
if( fs.existsSync( "framework/node_modules/caxa/package-lock.json" ) ) {
fs.rmSync("framework/node_modules/caxa/package-lock.json", { recursive: true });
}
if( fs.existsSync( "./node_modules" ) ) {
fs.rmSync("./node_modules", { recursive: true });
}
if( fs.existsSync( "./framework/cache/platforms" ) ) {
fs.rmSync("./framework/cache/platforms", { recursive: true });
}
fs.mkdirSync("./framework/cache/platforms");
if( fs.existsSync( "./framework/cache/server" ) ) {
fs.rmSync("./framework/cache/server", { recursive: true });
}
fs.mkdirSync("./framework/cache/server");
if( fs.existsSync( "./package-lock.json" ) ) {
fs.rmSync("./package-lock.json", { recursive: true });
}
// Native
if( fs.existsSync( "./platforms/hybrid/binaries/nw" ) ) {
fs.rmSync("./platforms/hybrid/binaries/nw", { recursive: true });
}
if( fs.existsSync( "./platforms/hybrid/package-lock.json" ) ) {
fs.rmSync("./platforms/hybrid/package-lock.json", { recursive: true });
}
if( fs.existsSync( "./platforms/hybrid/node_modules" ) ) {
fs.rmSync("./platforms/hybrid/node_modules", { recursive: true });
}
/*
if( fs.existsSync( "./platforms/hybrid/framework/cache/platforms" ) ) {
fs.rmSync("./platforms/hybrid/framework/cache/platforms", { recursive: true });
}
fs.mkdirSync("./platforms/hybrid/framework/cache/platforms");
if( fs.existsSync( "./platforms/hybrid/framework/cache/server" ) ) {
fs.rmSync("./platforms/hybrid/framework/cache/server", { recursive: true });
}
fs.mkdirSync("./platforms/hybrid/framework/cache/server");
*/
// Android
/*
if( fs.existsSync( "./platforms/android/projectRoot//framework/cache/platforms" ) ) {
fs.rmSync("./platforms/android/projectRoot/framework/cache/platforms", { recursive: true });
}
fs.mkdirSync("./platforms/android/projectRoot/framework/cache/platforms");
if( fs.existsSync( "./platforms/android/projectRoot//framework/cache/server" ) ) {
fs.rmSync("./platforms/android/projectRoot/framework/cache/server", { recursive: true });
}
*/
if( fs.existsSync( "./platforms/android/projectRoot//package-lock.json" ) ) {
fs.rmSync("./platforms/android/projectRoot/package-lock.json", { recursive: true });
}
// Executables
if( fs.existsSync( "./executables/application.apk" ) ) {
fs.rmSync("./executables/application.apk", { recursive: true });
}
if( fs.existsSync( "./executables/application" ) ) {
fs.rmSync("./executables/application", { recursive: true });
}
if( fs.existsSync( "./executables/application.exe" ) ) {
fs.rmSync("./executables/application.exe", { recursive: true });
}

View File

@@ -0,0 +1,22 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft,
https://unifyjs.org
*/
import fs from "fs-extra"
if( fs.existsSync( "./framework/node_modules/better-sqlite3/node_modules/" ) ) {
fs.rmSync("./framework/node_modules/better-sqlite3/node_modules/", { recursive: true });
}
fs.mkdirSync("./framework/node_modules/better-sqlite3/node_modules/");