Compare commits
41
Commits
c3c0b07d32
..
2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f59ef2893e | ||
|
|
6a887d10ff | ||
|
|
6940c65b88 | ||
|
|
0a355ee680 | ||
|
|
bb6d82d538 | ||
|
|
7615dbfc48 | ||
|
|
d079cbaac5 | ||
|
|
b3d1aee9ed | ||
|
|
769127d6f0 | ||
|
|
57f7e88fab | ||
|
|
7f62df2364 | ||
|
|
6622d53167 | ||
|
|
561dd99cba | ||
|
|
bc77380aba | ||
|
|
a20e98d730 | ||
|
|
87fe852f99 | ||
|
|
dfad6d3aba | ||
|
|
bff3cc06ef | ||
|
|
6ff587cb65 | ||
|
|
bf6ff0deb9 | ||
|
|
2605c1bbc8 | ||
|
|
d9e8976e85 | ||
|
|
f417fcac73 | ||
|
|
05be4ab622 | ||
|
|
ce51ab817c | ||
|
|
0672f2a1e0 | ||
|
|
428f9d100e | ||
|
|
fc7f97b520 | ||
|
|
cf3a707a47 | ||
|
|
188fcc8e4c | ||
|
|
c8720102f9 | ||
|
|
e58d63f260 | ||
|
|
f45effe571 | ||
|
|
bf9ac8a8bf | ||
|
|
c522783b75 | ||
|
|
ad6bc17b1b | ||
|
|
a25f223b61 | ||
|
|
84d905dbb3 | ||
|
|
a421d56ec1 | ||
|
|
079cf9d52d | ||
|
|
0edfb12473 |
@@ -4,27 +4,15 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags: ["*"]
|
tags: ["*"]
|
||||||
|
|
||||||
env:
|
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
id-token: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- run: echo '' > requirements.txt
|
- run: echo '' > requirements.txt
|
||||||
- uses: https://git.shmyga.ru/InfernalGames/project-manager@master
|
- uses: https://git.shmyga.ru/InfernalGames/project-manager@master
|
||||||
- run: pm setup:npm -vv
|
|
||||||
- run: pm build:npm -vv
|
|
||||||
- uses: actions/setup-node@v7
|
|
||||||
with:
|
with:
|
||||||
node-version: "24.x"
|
setup-nodejs: true
|
||||||
registry-url: "https://registry.npmjs.org"
|
- run: pm build -vv
|
||||||
#- run: pm publish:npm -vv
|
- run: npm config set //registry.npmjs.org/:_authToken "${{ secrets.NPM_TOKEN }}"
|
||||||
#- run: npm config set //registry.npmjs.org/:_authToken "$NPM_TOKEN"
|
- run: npm publish
|
||||||
- run: npm publish --provenance --access public
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
name: test
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
- run: echo '' > requirements.txt
|
||||||
|
- uses: https://git.shmyga.ru/InfernalGames/project-manager@master
|
||||||
|
with:
|
||||||
|
setup-nodejs: true
|
||||||
|
- run: pm build -vv
|
||||||
|
- run: pm lint -vv
|
||||||
|
- run: pm test -vv
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
target/
|
target/
|
||||||
dist/
|
dist/
|
||||||
|
build/
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
## v0.2.0 (2026-05-15)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- **ruffle**: add alternative ruffle flash target runner
|
|
||||||
|
|
||||||
## 0.1.9 (2021-05-24)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- **android**: up android sdk version
|
|
||||||
|
|
||||||
## 0.1.8 (2020-03-30)
|
|
||||||
|
|
||||||
## 0.1.7 (2020-03-25)
|
|
||||||
|
|
||||||
## 0.1.6 (2020-02-19)
|
|
||||||
|
|
||||||
## 0.1.5 (2020-02-18)
|
|
||||||
|
|
||||||
## 0.1.0 (2019-09-03)
|
|
||||||
|
|
||||||
## 0.0.18 (2019-05-20)
|
|
||||||
|
|
||||||
## 0.0.17 (2019-03-28)
|
|
||||||
|
|
||||||
## 0.0.16 (2019-03-14)
|
|
||||||
|
|
||||||
## 0.0.15 (2019-03-14)
|
|
||||||
@@ -1,197 +1,110 @@
|
|||||||
# Gulp HaXe Tool
|
# HaXeTool
|
||||||
|
|
||||||
|
[](https://git.shmyga.ru/InfernalGames/gulp-haxetool/actions?workflow=test.yaml)
|
||||||
|
|
||||||
## Introducing
|
## Introducing
|
||||||
|
|
||||||
### Dignity
|
Tool for simple building and pack HaXe and OpenFl project
|
||||||
|
|
||||||
* Automatically download HaXe SDK, Neko, FlashPlayer, Android SDK, +(Adobe AIR SDK).
|
## OpenFL Example
|
||||||
* Universal project config for simple HaXe build and OpenFL build.
|
|
||||||
* Branch project config for many build presets (many OpenFL apps in one project).
|
|
||||||
* Packaging linux output in DEB.
|
|
||||||
* Packaging windows output in exe install with InnoSetup.
|
|
||||||
* Create html wrapper for flash output.
|
|
||||||
|
|
||||||
### Flaws
|
[Example project](./example)
|
||||||
|
|
||||||
* Hardcode build output in {projectDir}/target (need param in Project.Config).
|
[`package.json`](./example/package.json)
|
||||||
* HTML5 run output not caught.
|
|
||||||
* Adobe AIR Build System in progress.
|
|
||||||
* Windows target depends Visual Studio 2017 build tools
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### Project.Config
|
|
||||||
|
|
||||||
#### constructor
|
|
||||||
|
|
||||||
* **meta**: meta information
|
|
||||||
* **title**: application title
|
|
||||||
* **filename**: application filename
|
|
||||||
* **icon**: path to icon file
|
|
||||||
* **pack**: package name for OpenFL
|
|
||||||
* **author**: author name for DEB packaging
|
|
||||||
* **company**: company name for OpenFL
|
|
||||||
* **version**: application version
|
|
||||||
* **name**: name for output directory
|
|
||||||
* **libs**: list of haxe dependencies
|
|
||||||
* **sources**: list of HaXe sources
|
|
||||||
* **assets**: list of resources
|
|
||||||
* **main**: main class name
|
|
||||||
* **macros**: list of macros
|
|
||||||
|
|
||||||
### Project
|
|
||||||
|
|
||||||
#### constructor
|
|
||||||
|
|
||||||
* **buildSystem**: Project.BuildSystem
|
|
||||||
* **platforms**: Project.Platform (list supported)
|
|
||||||
* **config**: Project.Config
|
|
||||||
|
|
||||||
#### bind
|
|
||||||
|
|
||||||
* **module**
|
|
||||||
|
|
||||||
create gulp tasks in module:
|
|
||||||
|
|
||||||
```
|
|
||||||
<config.name>:<platform>:build
|
|
||||||
<config.name>:<platform>:run
|
|
||||||
<config.name>:<platform>:test
|
|
||||||
|
|
||||||
<config.name>:flash:html
|
|
||||||
|
|
||||||
<config.name>:linux:archive
|
|
||||||
<config.name>:linux:deb
|
|
||||||
|
|
||||||
<config.name>:windows:archive
|
|
||||||
<config.name>:windows:installer
|
|
||||||
```
|
|
||||||
|
|
||||||
eg: ```gulp app:flash:test```
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
[package.json](example/package.json)
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"name": "app",
|
"name": "example",
|
||||||
|
"type": "module",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
"scripts": {
|
||||||
|
"tasks": "hxt",
|
||||||
|
"build": "hxt default",
|
||||||
|
"dev": "hxt app:flash:test"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^4.0.0",
|
"gulp-haxetool": "^2.0.0"
|
||||||
"gulp-clean": "^0.4.0",
|
|
||||||
"gulp-haxetool": "^0.1.0"
|
|
||||||
},
|
|
||||||
"haxeDependencies": {
|
|
||||||
"lime": "7.6.0",
|
|
||||||
"openfl": "8.9.2",
|
|
||||||
"hxcpp": "4.0.19"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
[src/Main.hx](example/src/Main.hx)
|
[`haxetool.json`](./example/haxetool.json)
|
||||||
```haxe
|
|
||||||
import flash.display.Shape;
|
|
||||||
import flash.Lib;
|
|
||||||
|
|
||||||
class Main {
|
JSON schema: https://shmyga.ru/public/haxetool.schema.json
|
||||||
|
|
||||||
public static function main() {
|
```json
|
||||||
trace("Hello world!");
|
{
|
||||||
var shape = new Shape();
|
"app": {
|
||||||
shape.graphics.beginFill(0x00ff00);
|
"buildSystem": "openfl",
|
||||||
shape.graphics.drawCircle(50, 50, 20);
|
"platforms": ["flash", "html5", "linux", "windows", "android"],
|
||||||
shape.graphics.endFill();
|
"libs": {
|
||||||
Lib.current.addChild(shape);
|
"lime": "8.3.2",
|
||||||
|
"openfl": "9.5.2",
|
||||||
|
"hxcpp": "4.2.1"
|
||||||
|
},
|
||||||
|
"sources": ["src"],
|
||||||
|
"main": "Main"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
[gulpfile.js](example/gulpfile.js)
|
## Commands
|
||||||
```javascript
|
|
||||||
const gulp = require('gulp');
|
|
||||||
const gulpClean = require('gulp-clean');
|
|
||||||
const packageInfo = require('./package.json');
|
|
||||||
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
|
||||||
|
|
||||||
//Sdk.dir = '/opt/sdk';
|
### Display tasks list
|
||||||
|
|
||||||
exports.clean = function clean() {
|
```bash
|
||||||
return gulp.src('target/*', {read: false}).pipe(gulpClean());
|
npx hxt
|
||||||
};
|
```
|
||||||
|
|
||||||
exports.install = function install() {
|
### Build and pack all platform variants
|
||||||
const haxe = new Haxe();
|
|
||||||
return haxe.prepare().then(() => haxe.install(packageInfo.haxeDependencies));
|
|
||||||
};
|
|
||||||
|
|
||||||
const config = new Project.Config({
|
Results places in `target` directory
|
||||||
meta: {
|
|
||||||
title: 'Application',
|
|
||||||
filename: 'app',
|
|
||||||
icon: './resources/icon.jpg',
|
|
||||||
pack: 'com.example',
|
|
||||||
author: 'Anonim <anonim@anonim.com>',
|
|
||||||
company: 'Any company',
|
|
||||||
version: packageInfo.version,
|
|
||||||
},
|
|
||||||
name: 'app',
|
|
||||||
libs: packageInfo.haxeDependencies,
|
|
||||||
sources: ['src'],
|
|
||||||
assets: ['resources'],
|
|
||||||
main: 'Main',
|
|
||||||
});
|
|
||||||
|
|
||||||
const project = new Project(
|
```bash
|
||||||
Project.BuildSystem.OPENFL,
|
npx hxt default
|
||||||
[
|
```
|
||||||
Project.Platform.FLASH,
|
|
||||||
Project.Platform.HTML5,
|
### Build and run platform target
|
||||||
Project.Platform.LINUX,
|
|
||||||
Project.Platform.WINDOWS,
|
```bash
|
||||||
|
npx hxt <preset>:<platform>:test
|
||||||
|
```
|
||||||
|
```bash
|
||||||
|
npx hxt app:flash:test
|
||||||
|
npx hxt app:html5:test
|
||||||
|
npx hxt app:linux:test
|
||||||
|
npx hxt app:android:test
|
||||||
|
npx hxt app:windows:test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dependencies requiring manual installation
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
* Visual Studio 2017 build tools
|
||||||
|
|
||||||
|
### Android
|
||||||
|
|
||||||
|
* Java JDK 17
|
||||||
|
|
||||||
|
## VS Code settings
|
||||||
|
|
||||||
|
### JSON schema for `haxetool.json`
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
...
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": [
|
||||||
|
"/haxetool.json"
|
||||||
],
|
],
|
||||||
config
|
"url": "https://shmyga.ru/public/haxetool.schema.json"
|
||||||
).bind(module);
|
|
||||||
|
|
||||||
|
|
||||||
const defaultSeries = [
|
|
||||||
exports.clean,
|
|
||||||
module.exports['app:flash:build'],
|
|
||||||
module.exports['app:flash:html'],
|
|
||||||
module.exports['app:html5:build'],
|
|
||||||
];
|
|
||||||
|
|
||||||
if (System.isLinux) {
|
|
||||||
defaultSeries.push(
|
|
||||||
module.exports['app:linux:build'],
|
|
||||||
module.exports['app:linux:archive'],
|
|
||||||
module.exports['app:linux:deb'],
|
|
||||||
|
|
||||||
module.exports['app:android:build'],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
],
|
||||||
if (System.isWindows) {
|
"json.schemaDownload.trustedDomains": {
|
||||||
defaultSeries.push(
|
"https://shmyga.ru/": true
|
||||||
module.exports['app:windows:build'],
|
},
|
||||||
module.exports['app:windows:archive'],
|
...
|
||||||
module.exports['app:windows:installer'],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.default = gulp.series(defaultSeries);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Build for all platforms: `gulp default`
|
|
||||||
|
|
||||||
Build app for specific platform: `gulp app:flash:build`
|
|
||||||
|
|
||||||
Build and run flash app in flashplayer: `gulp app:flash:test`
|
|
||||||
|
|
||||||
Build and run html5 app in browser: `gulp app:html5:test`
|
|
||||||
|
|
||||||
Build and run linux app native: `gulp app:linux:test`
|
|
||||||
|
|
||||||
Build and run windows app native: `gulp app:windows:test`
|
|
||||||
|
|
||||||
Build and run android app: `gulp app:android:test`
|
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"$id": "https://shmyga.ru/public/haxetool.schema.json",
|
||||||
|
"title": "Haxe tool",
|
||||||
|
"description": "Haxe tool presets",
|
||||||
|
"type": "object",
|
||||||
|
"patternProperties": {
|
||||||
|
".*": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"buildSystem": { "enum": ["haxe", "openfl"] },
|
||||||
|
"platforms": {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "enum": ["flash", "html5", "linux", "windows", "android", "neko", "cpp"] }
|
||||||
|
},
|
||||||
|
"name": { "type": "string" },
|
||||||
|
"main": { "type": "string" },
|
||||||
|
"preloader": { "type": "string" },
|
||||||
|
"sources": { "type": "array", "items": { "type": "string" } },
|
||||||
|
"assets": { "type": "array", "items": { "type": "string" } },
|
||||||
|
"libs": { "type": "object", "patternProperties": { ".*": { "type": "string" } } },
|
||||||
|
"macros": { "type": "array", "items": { "type": "string" } },
|
||||||
|
"flags": { "type": "array", "items": { "type": "string" } },
|
||||||
|
"meta": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"title": { "type": "string" },
|
||||||
|
"filename": { "type": "string" },
|
||||||
|
"icon": { "type": "string" },
|
||||||
|
"version": { "type": "string" },
|
||||||
|
"pack": { "type": "string" },
|
||||||
|
"author": { "type": "string" },
|
||||||
|
"company": { "type": "string" },
|
||||||
|
"width": { "type": "number" },
|
||||||
|
"height": { "type": "number" },
|
||||||
|
"mobileWidth": { "type": "number" },
|
||||||
|
"mobileHeight": { "type": "number" },
|
||||||
|
"fps": { "type": "number" }
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"store": { "type": "string" },
|
||||||
|
"pass": { "type": "string" }
|
||||||
|
},
|
||||||
|
"required": ["store", "pass"]
|
||||||
|
},
|
||||||
|
"android": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"path": { "type": "string" },
|
||||||
|
"extensions": { "type": "array", "items": { "type": "string" } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"haxe": { "type": "string" }
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -1,71 +0,0 @@
|
|||||||
const gulp = require('gulp');
|
|
||||||
const gulpClean = require('gulp-clean');
|
|
||||||
const packageInfo = require('./package.json');
|
|
||||||
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
|
||||||
|
|
||||||
//Sdk.dir = '/opt/sdk';
|
|
||||||
|
|
||||||
exports.clean = function clean() {
|
|
||||||
return gulp.src('target/*', {read: false}).pipe(gulpClean());
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.install = function install() {
|
|
||||||
const haxe = new Haxe();
|
|
||||||
return haxe.prepare().then(() => haxe.install(packageInfo.haxeDependencies));
|
|
||||||
};
|
|
||||||
|
|
||||||
const config = new Project.Config({
|
|
||||||
meta: {
|
|
||||||
title: 'Application',
|
|
||||||
filename: 'app',
|
|
||||||
icon: './resources/icon.jpg',
|
|
||||||
pack: 'com.example',
|
|
||||||
author: 'Anonim <anonim@anonim.com>',
|
|
||||||
company: 'Any company',
|
|
||||||
version: packageInfo.version,
|
|
||||||
},
|
|
||||||
name: 'app',
|
|
||||||
libs: packageInfo.haxeDependencies,
|
|
||||||
sources: ['src'],
|
|
||||||
assets: ['resources'],
|
|
||||||
main: 'Main',
|
|
||||||
});
|
|
||||||
|
|
||||||
const project = new Project(
|
|
||||||
Project.BuildSystem.OPENFL,
|
|
||||||
[
|
|
||||||
Project.Platform.FLASH,
|
|
||||||
Project.Platform.HTML5,
|
|
||||||
Project.Platform.LINUX,
|
|
||||||
Project.Platform.WINDOWS,
|
|
||||||
],
|
|
||||||
config
|
|
||||||
).bind(module);
|
|
||||||
|
|
||||||
|
|
||||||
const defaultSeries = [
|
|
||||||
exports.clean,
|
|
||||||
module.exports['app:flash:build'],
|
|
||||||
module.exports['app:flash:html'],
|
|
||||||
module.exports['app:html5:build'],
|
|
||||||
];
|
|
||||||
|
|
||||||
if (System.isLinux) {
|
|
||||||
defaultSeries.push(
|
|
||||||
module.exports['app:linux:build'],
|
|
||||||
module.exports['app:linux:archive'],
|
|
||||||
module.exports['app:linux:deb'],
|
|
||||||
|
|
||||||
module.exports['app:android:build'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (System.isWindows) {
|
|
||||||
defaultSeries.push(
|
|
||||||
module.exports['app:windows:build'],
|
|
||||||
module.exports['app:windows:archive'],
|
|
||||||
module.exports['app:windows:installer'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.default = gulp.series(defaultSeries);
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"app": {
|
||||||
|
"buildSystem": "openfl",
|
||||||
|
"platforms": ["flash", "html5", "linux", "windows", "android"],
|
||||||
|
"libs": {
|
||||||
|
"lime": "8.3.2",
|
||||||
|
"openfl": "9.5.2",
|
||||||
|
"hxcpp": "4.2.1"
|
||||||
|
},
|
||||||
|
"sources": ["src"],
|
||||||
|
"main": "Main"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"indentation": {
|
||||||
|
"character": " "
|
||||||
|
},
|
||||||
|
"wrapping": {
|
||||||
|
"maxLineLength": 120
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+7601
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "app",
|
"name": "example",
|
||||||
|
"type": "module",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"devDependencies": {
|
"scripts": {
|
||||||
"gulp": "^4.0.0",
|
"tasks": "hxt",
|
||||||
"gulp-clean": "^0.4.0",
|
"build": "hxt default",
|
||||||
"gulp-haxetool": "^0.1.0"
|
"dev": "hxt app:flash:test"
|
||||||
},
|
},
|
||||||
"haxeDependencies": {
|
"devDependencies": {
|
||||||
"lime": "7.6.0",
|
"gulp-haxetool": "file:.."
|
||||||
"openfl": "8.9.2",
|
|
||||||
"hxcpp": "4.0.19"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import flash.display.Shape;
|
|||||||
import flash.Lib;
|
import flash.Lib;
|
||||||
|
|
||||||
class Main {
|
class Main {
|
||||||
|
|
||||||
public static function main() {
|
public static function main() {
|
||||||
trace("Hello world!");
|
trace("Hello world!");
|
||||||
var shape = new Shape();
|
var shape = new Shape();
|
||||||
|
|||||||
Generated
+2911
-5590
File diff suppressed because it is too large
Load Diff
+43
-32
@@ -1,20 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-haxetool",
|
"name": "gulp-haxetool",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.1.1",
|
"version": "2.1.0",
|
||||||
"description": "HaXe Tool for Gulp",
|
"description": "HaXe Tool with Gulp",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./dist/index.mjs",
|
"./bin/cli": "./dist/bin/cli.mjs",
|
||||||
|
"./lib": "./dist/lib/index.mjs",
|
||||||
"./package.json": "./package.json"
|
"./package.json": "./package.json"
|
||||||
},
|
},
|
||||||
|
"bin": {
|
||||||
|
"hxt": "./dist/bin/cli.mjs"
|
||||||
|
},
|
||||||
|
"types": "./dist/lib/index.d.mts",
|
||||||
"files": [
|
"files": [
|
||||||
"template",
|
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsdown",
|
"build": "tsdown",
|
||||||
"dev": "tsdown --watch",
|
"dev": "tsdown --watch",
|
||||||
"typecheck": "tsc --noEmit"
|
"lint": "tsc --noEmit",
|
||||||
|
"test": "node --test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -28,42 +33,48 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://git.shmyga.ru/InfernalGames/gulp-haxetool#readme",
|
"homepage": "https://git.shmyga.ru/InfernalGames/gulp-haxetool#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ansi-colors": "^1.1.0",
|
"ajv": "^8.20.0",
|
||||||
"async": "^2.6.0",
|
"ansi-colors": "^4.1.3",
|
||||||
"cli-progress": "^3.0.0",
|
"async": "^3.2.6",
|
||||||
"dateformat": "^5.0.4",
|
"cli-progress": "^3.12.0",
|
||||||
"fancy-log": "^1.3.2",
|
"dateformat": "^5.0.5",
|
||||||
"fs-extra": "^5.0.0",
|
"eta": "^4.6.0",
|
||||||
"got": "^9.6.0",
|
"fs-extra": "^11.4.1",
|
||||||
"gulp": "^4.0.0",
|
"got": "^16.1.0",
|
||||||
|
"gulp": "^5.0.1",
|
||||||
"gulp-clean": "^0.4.0",
|
"gulp-clean": "^0.4.0",
|
||||||
|
"gulp-connect": "^5.7.0",
|
||||||
"gulp-debian": "^0.1.9",
|
"gulp-debian": "^0.1.9",
|
||||||
"gulp-gzip": "^1.4.2",
|
"gulp-gzip": "^1.4.2",
|
||||||
"gulp-rename": "^1.2.2",
|
"gulp-rename": "^2.1.0",
|
||||||
"gulp-spawn": "^0.4.0",
|
"gulp-tar": "^5.0.0",
|
||||||
"gulp-tar": "^3.0.0",
|
"gulp-zip": "^6.1.0",
|
||||||
"gulp-webserver": "^0.9.1",
|
|
||||||
"gulp-zip": "^5.0.0",
|
|
||||||
"lodash.defaults": "^4.2.0",
|
|
||||||
"lodash.template": "^4.4.0",
|
|
||||||
"plugin-error": "^1.0.1",
|
|
||||||
"promise-streams": "^2.1.1",
|
"promise-streams": "^2.1.1",
|
||||||
"tail": "^1.2.3",
|
"tail": "^2.2.6",
|
||||||
"tar": "^4.4.10",
|
"tar": "^7.5.22",
|
||||||
"through2": "^2.0.3",
|
"through2": "^5.0.12",
|
||||||
"time-stamp": "^1.1.0",
|
|
||||||
"tmp-file": "^2.0.1",
|
"tmp-file": "^2.0.1",
|
||||||
"unzip-stream": "^0.3.0",
|
"unzipper": "^0.12.5",
|
||||||
"vinyl": "^2.1.0",
|
"vinyl": "^3.0.1",
|
||||||
"vinyl-fs": "^3.0.2"
|
"vinyl-fs": "^4.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/async": "^3.2.26",
|
||||||
|
"@types/cli-progress": "^3.11.6",
|
||||||
|
"@types/dateformat": "^5.0.3",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
|
"@types/gulp": "^4.0.18",
|
||||||
|
"@types/gulp-connect": "^5.0.10",
|
||||||
|
"@types/gulp-gzip": "^0.0.36",
|
||||||
"@types/gulp-rename": "^2.0.7",
|
"@types/gulp-rename": "^2.0.7",
|
||||||
"@types/lodash.template": "^4.5.3",
|
"@types/gulp-tar": "^4.0.1",
|
||||||
"@types/node": "^26.1.1",
|
"@types/gulp-zip": "^4.0.4",
|
||||||
"@types/vinyl-fs": "^3.0.8",
|
"@types/node": "^26.6.5",
|
||||||
"eslint": "^10.12.0",
|
"@types/tail": "^2.2.3",
|
||||||
|
"@types/tar": "^7.0.87",
|
||||||
|
"@types/through2": "^5.0.0",
|
||||||
|
"@types/unzipper": "^0.10.11",
|
||||||
|
"eslint": "^10.13.0",
|
||||||
"prettier": "^3.9.10",
|
"prettier": "^3.9.10",
|
||||||
"tsdown": "0.22.14",
|
"tsdown": "0.22.14",
|
||||||
"typescript": "^7.0.2"
|
"typescript": "^7.0.2"
|
||||||
|
|||||||
Vendored
+9
@@ -0,0 +1,9 @@
|
|||||||
|
declare module "gulp-clean" {
|
||||||
|
import type { WritableStream } from "stream";
|
||||||
|
|
||||||
|
export interface Options {
|
||||||
|
force?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (options?: Options) => WritableStream;
|
||||||
|
}
|
||||||
Vendored
+32
@@ -0,0 +1,32 @@
|
|||||||
|
declare module "gulp-debian" {
|
||||||
|
import type { WritableStream } from "stream";
|
||||||
|
|
||||||
|
export interface Options {
|
||||||
|
package: string;
|
||||||
|
version: string;
|
||||||
|
section: string;
|
||||||
|
priority: string;
|
||||||
|
architecture: string;
|
||||||
|
maintainer?: string;
|
||||||
|
description?: string;
|
||||||
|
preinst?: string[];
|
||||||
|
postinst?: string[];
|
||||||
|
prerm?: string[];
|
||||||
|
postrm?: string[];
|
||||||
|
conffiles?: string;
|
||||||
|
changelog?: {
|
||||||
|
version: string;
|
||||||
|
distribution: string;
|
||||||
|
urgency: string;
|
||||||
|
date: Date;
|
||||||
|
changes: string[];
|
||||||
|
}[];
|
||||||
|
_target?: string;
|
||||||
|
_out?: string;
|
||||||
|
_copyright?: string;
|
||||||
|
_clean?: boolean;
|
||||||
|
_verbose?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (options: Options) => WritableStream;
|
||||||
|
}
|
||||||
Vendored
+46
@@ -0,0 +1,46 @@
|
|||||||
|
declare module "vinyl" {
|
||||||
|
import { type Stats } from "fs";
|
||||||
|
import type Stream from "stream";
|
||||||
|
|
||||||
|
export type Contents = Stream | Buffer | null;
|
||||||
|
|
||||||
|
export interface Options<C extends Contents = Contents> {
|
||||||
|
contents?: C;
|
||||||
|
cwd?: string;
|
||||||
|
base?: string;
|
||||||
|
path?: string;
|
||||||
|
stat?: Stats;
|
||||||
|
history?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class File<C extends Contents = Contents> {
|
||||||
|
contents: C;
|
||||||
|
cwd: string;
|
||||||
|
base: string;
|
||||||
|
relative: string;
|
||||||
|
dirname: string;
|
||||||
|
basename: string;
|
||||||
|
stem: string;
|
||||||
|
extname: string;
|
||||||
|
path: string;
|
||||||
|
symlink: string;
|
||||||
|
stat: Stats;
|
||||||
|
history: string[];
|
||||||
|
|
||||||
|
constructor(options?: Options<C>);
|
||||||
|
isBuffer(): boolean;
|
||||||
|
isStream(): boolean;
|
||||||
|
isNull(): boolean;
|
||||||
|
isDirectory(): boolean;
|
||||||
|
isSymbolic(): boolean;
|
||||||
|
clone(options?: Options<C>);
|
||||||
|
|
||||||
|
static isCustomProp(key: string): boolean;
|
||||||
|
static isVinyl(file: File | any): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StreamFile = File<Stream>;
|
||||||
|
export type BufferFile = File<Buffer>;
|
||||||
|
|
||||||
|
export default File;
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import gulp from "gulp";
|
||||||
|
import { Preset, Task } from ".";
|
||||||
|
import { name, version } from "../package.json" with { type: "json" };
|
||||||
|
|
||||||
|
console.log(`[${name} ${version}]`);
|
||||||
|
|
||||||
|
const showTasks = () => {
|
||||||
|
const tree = gulp.tree({ deep: true });
|
||||||
|
console.log(tree.nodes.map((node) => node.label).join("\n"));
|
||||||
|
};
|
||||||
|
|
||||||
|
const runTask = async (name: string) => {
|
||||||
|
const task = gulp.task(name);
|
||||||
|
if (!task) {
|
||||||
|
throw `task '${name}' not found`;
|
||||||
|
}
|
||||||
|
return await task((error) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const main = async () => {
|
||||||
|
const preset = Preset.loader();
|
||||||
|
Preset.validator(preset);
|
||||||
|
const projects = Preset.compiler(preset);
|
||||||
|
Task.register(Task.compiler(projects));
|
||||||
|
|
||||||
|
if (process.argv.length > 2) {
|
||||||
|
await runTask(process.argv[2]);
|
||||||
|
} else {
|
||||||
|
showTasks();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default main;
|
||||||
|
|
||||||
|
await main();
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
export default (name: string): string => {
|
||||||
|
return path.join(__dirname, "assets", name);
|
||||||
|
};
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
import colors from "ansi-colors";
|
|
||||||
|
|
||||||
const _colors = {
|
|
||||||
"[DEBUG]": colors.white,
|
|
||||||
"[INFO]": colors.cyan,
|
|
||||||
"[ERROR]": colors.red,
|
|
||||||
"Called from ": colors.red,
|
|
||||||
"[WARNING]": colors.yellow,
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Color = (v: string) => string;
|
|
||||||
|
|
||||||
export const getColor = (line: string): Color | null => {
|
|
||||||
for (const [tag, color] of Object.entries(_colors)) {
|
|
||||||
if (line.indexOf(tag) > -1) {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null; // colors.reset;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class Debug {
|
|
||||||
public color: Color;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.color = colors.white;
|
|
||||||
this.log = this.log.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
log(line: string) {
|
|
||||||
const newColor = getColor(line);
|
|
||||||
if (newColor) this.color = newColor;
|
|
||||||
if (line[0] === "\t" || line.startsWith("Called from ")) {
|
|
||||||
console.log(this.color(line));
|
|
||||||
} else {
|
|
||||||
const result = line.split(" ");
|
|
||||||
console.log(colors.gray(result.slice(0, 4).join(" ")) + " " + this.color(result.slice(4).join(" ")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DEBUG = new Debug();
|
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import progress from "cli-progress";
|
||||||
|
import fs from "fs";
|
||||||
|
import fse from "fs-extra";
|
||||||
|
import got, { type Progress, type Request } from "got";
|
||||||
|
import path from "path";
|
||||||
|
import ps from "promise-streams";
|
||||||
|
import { type Stream, type Writable } from "stream";
|
||||||
|
import { x as tarX } from "tar";
|
||||||
|
import unzipper from "unzipper";
|
||||||
|
|
||||||
|
export interface DownloadOptions {
|
||||||
|
progress?: boolean;
|
||||||
|
strip?: number;
|
||||||
|
executable?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DEFAULT_OPTIONS: DownloadOptions = { progress: true, strip: 1, executable: false };
|
||||||
|
|
||||||
|
type Extractor = (stream: Request, dest: string, options: DownloadOptions) => Stream;
|
||||||
|
|
||||||
|
const ZIP_EXTRACTOR: Extractor = (stream: Request, dest: string, options: DownloadOptions): Stream => {
|
||||||
|
return stream.pipe(unzipper.Parse()).on("entry", (entry: unzipper.Entry) => {
|
||||||
|
const filePath = entry.path.split("/").slice(options.strip).join(path.sep);
|
||||||
|
if (filePath.length > 0) {
|
||||||
|
if (entry.type === "Directory") {
|
||||||
|
fse.ensureDirSync(path.join(dest, path.normalize(filePath)));
|
||||||
|
} else if (entry.type === "File") {
|
||||||
|
const fullFilePath = path.join(dest, path.normalize(filePath));
|
||||||
|
const dirPath = path.dirname(fullFilePath);
|
||||||
|
if (!fs.existsSync(dirPath)) {
|
||||||
|
fse.ensureDirSync(dirPath);
|
||||||
|
}
|
||||||
|
entry.pipe(
|
||||||
|
fs.createWriteStream(path.join(dest, path.normalize(filePath)), {
|
||||||
|
// TODO: zip entry file mode?
|
||||||
|
mode: options.executable ? 0o755 : undefined,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entry.autodrain();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const QZ_EXTRACTOR: Extractor = (stream: Request, dest: string, options: DownloadOptions): Stream => {
|
||||||
|
// TODO: cast tar.Unpack to Writable
|
||||||
|
return stream.pipe(tarX({ C: dest, strip: options.strip }) as unknown as Writable);
|
||||||
|
};
|
||||||
|
|
||||||
|
const DEFAULT_EXTRACTOR: Extractor = (stream: Request, dest: string, options: DownloadOptions): Stream => {
|
||||||
|
const filename = String(stream.requestUrl as URL)
|
||||||
|
.split("/")
|
||||||
|
.pop()!;
|
||||||
|
return stream.pipe(fs.createWriteStream(path.join(dest, filename)));
|
||||||
|
};
|
||||||
|
|
||||||
|
const EXTRACTOR_MAP: Record<string, Extractor> = {
|
||||||
|
".zip": ZIP_EXTRACTOR,
|
||||||
|
".gz": QZ_EXTRACTOR,
|
||||||
|
"": DEFAULT_EXTRACTOR,
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProgressBar {
|
||||||
|
private multiBar: progress.MultiBar = new progress.MultiBar(
|
||||||
|
{
|
||||||
|
stopOnComplete: true,
|
||||||
|
},
|
||||||
|
progress.Presets.shades_classic,
|
||||||
|
);
|
||||||
|
|
||||||
|
handle(request: Request): Request {
|
||||||
|
const bar = this.multiBar.create(0, 0);
|
||||||
|
return request
|
||||||
|
.on("request", (request: Request) => {
|
||||||
|
bar.start(1, 0);
|
||||||
|
})
|
||||||
|
.on("downloadProgress", (progress: Progress) => {
|
||||||
|
if (progress.total) {
|
||||||
|
bar.setTotal(progress.total);
|
||||||
|
}
|
||||||
|
bar.update(progress.transferred);
|
||||||
|
if (progress.total === progress.transferred) {
|
||||||
|
bar.render();
|
||||||
|
bar.stop();
|
||||||
|
this.multiBar.remove(bar);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const progressBar = new ProgressBar();
|
||||||
|
|
||||||
|
export const download = async (url: string, dest: string, options?: DownloadOptions): Promise<void> => {
|
||||||
|
options = { ...DEFAULT_OPTIONS, ...options };
|
||||||
|
fse.ensureDirSync(dest);
|
||||||
|
let stream: Request = got.stream(url, { decompress: false });
|
||||||
|
if (options.progress) {
|
||||||
|
stream = progressBar.handle(stream);
|
||||||
|
}
|
||||||
|
const ext = path.extname(url);
|
||||||
|
const extractor = EXTRACTOR_MAP[ext] || EXTRACTOR_MAP[""];
|
||||||
|
return ps.wait(extractor(stream, dest, options));
|
||||||
|
};
|
||||||
|
|
||||||
|
export default download;
|
||||||
+15
-9
@@ -1,19 +1,25 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
export class Env {
|
export class Env {
|
||||||
static set(key: string, value: string) {
|
constructor(private target: Record<string, string | undefined>) {}
|
||||||
process.env[key] = value;
|
|
||||||
|
set(key: string, value: string) {
|
||||||
|
this.target[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get(key: string) {
|
get(key: string) {
|
||||||
return process.env[key];
|
return this.target[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
static addPath(value: string, key = "PATH") {
|
addPath(value: string, key: string = "PATH") {
|
||||||
if (!process.env[key]) {
|
if (!this.target[key]) {
|
||||||
process.env[key] = value;
|
this.target[key] = value;
|
||||||
} else if (process.env[key].split(path.delimiter).indexOf(value) === -1) {
|
} else if (this.target[key].split(path.delimiter).indexOf(value) === -1) {
|
||||||
process.env[key] = [process.env[key], value].join(path.delimiter);
|
this.target[key] = [this.target[key], value].join(path.delimiter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const env = new Env(process.env);
|
||||||
|
|
||||||
|
export default env;
|
||||||
|
|||||||
+17
-5
@@ -1,10 +1,22 @@
|
|||||||
import async from "async";
|
import async, { type ErrorCallback } from "async";
|
||||||
import child_process from "child_process";
|
import child_process from "child_process";
|
||||||
import { Log } from "./log";
|
import { Logger } from "./log";
|
||||||
|
|
||||||
const log = new Log("exec");
|
const log = new Logger("exec");
|
||||||
|
|
||||||
const queue = async.queue((task: any, done: any) => {
|
export interface Result {
|
||||||
|
stdout: string;
|
||||||
|
stderr: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Task {
|
||||||
|
dir: string;
|
||||||
|
command: string;
|
||||||
|
success: (result: Result) => void;
|
||||||
|
failure: (error: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const queue = async.queue((task: Task, done: ErrorCallback) => {
|
||||||
log.d("*%s*", task.command);
|
log.d("*%s*", task.command);
|
||||||
//process.chdir(task.dir);
|
//process.chdir(task.dir);
|
||||||
child_process.exec(task.command, { cwd: task.dir, maxBuffer: 1024 * 10000 }, (err, stdout, stderr) => {
|
child_process.exec(task.command, { cwd: task.dir, maxBuffer: 1024 * 10000 }, (err, stdout, stderr) => {
|
||||||
@@ -19,7 +31,7 @@ const queue = async.queue((task: any, done: any) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export default (dir: string, command: string) => {
|
export default (dir: string, command: string): Promise<Result> => {
|
||||||
return new Promise((success, failure) => {
|
return new Promise((success, failure) => {
|
||||||
queue.push({
|
queue.push({
|
||||||
dir: dir,
|
dir: dir,
|
||||||
|
|||||||
+60
-35
@@ -1,61 +1,86 @@
|
|||||||
import colors from "ansi-colors";
|
import colors from "ansi-colors";
|
||||||
import timestamp from "time-stamp";
|
|
||||||
|
|
||||||
const Level = {
|
export enum Level {
|
||||||
VERBOSE: -1,
|
VERBOSE = -1,
|
||||||
DEBUG: 0,
|
DEBUG = 0,
|
||||||
INFO: 1,
|
INFO = 1,
|
||||||
WARN: 2,
|
WARNING = 2,
|
||||||
ERROR: 3,
|
ERROR = 3,
|
||||||
};
|
}
|
||||||
|
|
||||||
const level = process.argv.indexOf("--verbose") > -1 ? Level.VERBOSE : Level.INFO;
|
export const DEFAULT_LEVEL: Level = process.argv.indexOf("--verbose") > -1 ? Level.VERBOSE : Level.INFO;
|
||||||
|
|
||||||
export class Log {
|
export type FormatPattern = [string, colors.StyleFunction];
|
||||||
static level = level;
|
|
||||||
|
|
||||||
static colorize(pattern: string) {
|
export const DEFAULT_PATTERNS: FormatPattern[] = [
|
||||||
for (const item of [
|
|
||||||
["_", colors.cyan],
|
["_", colors.cyan],
|
||||||
["\\*", colors.magenta],
|
["\\*", colors.magenta],
|
||||||
["!", colors.red],
|
["!", colors.red],
|
||||||
]) {
|
];
|
||||||
|
|
||||||
|
export class Formatter {
|
||||||
|
constructor(
|
||||||
|
private patterns: FormatPattern[] = DEFAULT_PATTERNS,
|
||||||
|
private time: boolean = true,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
colorize(text: string): string {
|
||||||
|
for (const item of this.patterns) {
|
||||||
const r = new RegExp(item[0] + "(.*?)" + item[0], "g");
|
const r = new RegExp(item[0] + "(.*?)" + item[0], "g");
|
||||||
pattern = pattern.replace(r, item[1]("$1"));
|
text = text.replace(r, item[1]("$1"));
|
||||||
}
|
}
|
||||||
return pattern;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
static write(level: number, tag: string, pattern: string, ...args: any) {
|
buildTime(): string {
|
||||||
|
return new Date().toTimeString().split(" ")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
format(message: string, tag: string, level: Level): string {
|
||||||
|
const values = [];
|
||||||
|
if (this.time) {
|
||||||
|
values.push(`[${colors.gray(this.buildTime())}]`);
|
||||||
|
}
|
||||||
|
if (tag) {
|
||||||
|
values.push(colors.green(tag));
|
||||||
|
}
|
||||||
|
values.push(this.colorize(message));
|
||||||
|
return values.join(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_FORMATTER = new Formatter();
|
||||||
|
|
||||||
|
export class Logger {
|
||||||
|
constructor(
|
||||||
|
private tag: string,
|
||||||
|
private level: Level = DEFAULT_LEVEL,
|
||||||
|
private formatter: Formatter = DEFAULT_FORMATTER,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
write(level: Level, message: string, args: any[]) {
|
||||||
if (level >= this.level) {
|
if (level >= this.level) {
|
||||||
const message = `[${colors.gray(timestamp("HH:mm:ss"))}] ${colors.green(tag)} ${this.colorize(pattern)}`;
|
console.log(this.formatter.format(message, this.tag, level), ...args);
|
||||||
console.log(message, ...args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public tag: string;
|
v(message: string, ...args: any) {
|
||||||
|
this.write(Level.VERBOSE, message, args);
|
||||||
constructor(tag: string) {
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v(...args: any) {
|
d(message: string, ...args: any) {
|
||||||
Log.write(-1, this.tag, ...args);
|
this.write(Level.DEBUG, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
d(...args: any) {
|
i(message: string, ...args: any) {
|
||||||
Log.write(0, this.tag, ...args);
|
this.write(Level.INFO, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
i(...args: any) {
|
w(message: string, ...args: any) {
|
||||||
Log.write(1, this.tag, ...args);
|
this.write(Level.WARNING, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
w(...args: any) {
|
e(message: string, ...args: any) {
|
||||||
Log.write(2, this.tag, ...args);
|
this.write(Level.ERROR, message, args);
|
||||||
}
|
|
||||||
|
|
||||||
e(...args: any) {
|
|
||||||
Log.write(3, this.tag, ...args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import colors from "ansi-colors";
|
||||||
|
import { Formatter, Level, Logger } from "./log";
|
||||||
|
|
||||||
|
export class OutputFormatter extends Formatter {
|
||||||
|
private colorMap: Record<Level, colors.StyleFunction> = {
|
||||||
|
[Level.VERBOSE]: colors.white,
|
||||||
|
[Level.DEBUG]: colors.white,
|
||||||
|
[Level.INFO]: colors.cyan,
|
||||||
|
[Level.ERROR]: colors.red,
|
||||||
|
[Level.WARNING]: colors.yellow,
|
||||||
|
};
|
||||||
|
|
||||||
|
format(message: string, tag: string, level: Level): string {
|
||||||
|
const color = this.colorMap[level];
|
||||||
|
if (message[0] === "\t" || message.startsWith("Called from ")) {
|
||||||
|
return color(message);
|
||||||
|
} else {
|
||||||
|
const result = message.split(" ");
|
||||||
|
return colors.gray(result.slice(0, 4).join(" ")) + " " + color(result.slice(4).join(" "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_OUTPUT_FORMATTER = new OutputFormatter();
|
||||||
|
|
||||||
|
export class OutputLogger extends Logger {
|
||||||
|
private levelMap: Record<string, Level> = {
|
||||||
|
"[DEBUG]": Level.DEBUG,
|
||||||
|
"[INFO]": Level.INFO,
|
||||||
|
"[ERROR]": Level.ERROR,
|
||||||
|
"Called from ": Level.ERROR,
|
||||||
|
"[WARNING]": Level.WARNING,
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super("", Level.VERBOSE, DEFAULT_OUTPUT_FORMATTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
detectLevel(line: string): number {
|
||||||
|
for (const [tag, color] of Object.entries(this.levelMap)) {
|
||||||
|
if (line.indexOf(tag) > -1) {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Level.DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
log(line: string) {
|
||||||
|
this.write(this.detectLevel(line), line, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const OUTPUT_LOGGER = new OutputLogger();
|
||||||
|
|
||||||
|
export const output = (line: string) => OUTPUT_LOGGER.log(line);
|
||||||
|
|
||||||
|
export default output;
|
||||||
+28
-45
@@ -1,48 +1,25 @@
|
|||||||
import { Transform, Writable } from "stream";
|
import { Transform, Writable, type TransformCallback, type WritableOptions } from "stream";
|
||||||
import { StringDecoder } from "string_decoder";
|
import { StringDecoder } from "string_decoder";
|
||||||
import { Tail } from "tail";
|
|
||||||
import through from "through2";
|
|
||||||
import Vinyl from "vinyl";
|
|
||||||
|
|
||||||
export class TailVinyl extends Vinyl {
|
export type TailHandler = (line: string) => void;
|
||||||
constructor(params: any) {
|
|
||||||
params.contents = new Transform();
|
|
||||||
super(params);
|
|
||||||
if (params.path) {
|
|
||||||
this.tail = new Tail(params.path);
|
|
||||||
(this.tail.on("line", (line) => {
|
|
||||||
if (params.handler) {
|
|
||||||
line = params.handler(line);
|
|
||||||
}
|
|
||||||
if (line) {
|
|
||||||
this.contents.write(line + "\n");
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
this.tail.on("error", (error: any) => this.contents.write("error: " + error)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose() {
|
export class HandlerWriter extends Writable {
|
||||||
if (this.tail) {
|
private handler: any;
|
||||||
this.tail.unwatch();
|
private decoder: StringDecoder;
|
||||||
}
|
private data: string;
|
||||||
this.contents.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class StringWritable extends Writable {
|
constructor(handler: TailHandler, options?: WritableOptions) {
|
||||||
constructor(handler: any, options?: any) {
|
if (!options) options = {};
|
||||||
|
options.objectMode = true;
|
||||||
super(options);
|
super(options);
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
const state = this._writableState;
|
this.decoder = new StringDecoder(options?.defaultEncoding);
|
||||||
this._decoder = new StringDecoder(state.defaultEncoding);
|
|
||||||
this.data = "";
|
this.data = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
_write(chunk, encoding, callback) {
|
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void {
|
||||||
if (encoding === "buffer") {
|
chunk = this.decoder.write(chunk);
|
||||||
chunk = this._decoder.write(chunk);
|
for (const line of chunk.split("\n")) {
|
||||||
for (const line of chunk.split("\n"))
|
|
||||||
if (line.length) {
|
if (line.length) {
|
||||||
this.handler(line);
|
this.handler(line);
|
||||||
}
|
}
|
||||||
@@ -51,18 +28,24 @@ export class StringWritable extends Writable {
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
_final(callback) {
|
_final(callback: (error?: Error | null) => void): void {
|
||||||
this.data += this._decoder.end();
|
this.data += this.decoder.end();
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tail = (handler: any) => {
|
export class TailTransform extends Transform {
|
||||||
return through.obj(function (file: any, enc: string, callback: any) {
|
constructor(private handler: TailHandler) {
|
||||||
if (file.contents && file.contents.pipe) {
|
super({ objectMode: true });
|
||||||
file.contents.pipe(new StringWritable(handler));
|
|
||||||
}
|
}
|
||||||
this.push(file);
|
|
||||||
|
_transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void {
|
||||||
|
if (chunk.contents && chunk.contents.pipe) {
|
||||||
|
chunk.contents.pipe(new HandlerWriter(this.handler));
|
||||||
|
}
|
||||||
|
this.push(chunk);
|
||||||
callback();
|
callback();
|
||||||
});
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export const tail = (handler: TailHandler) => new TailTransform(handler);
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { Eta } from "eta";
|
||||||
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
export const template = new Eta({
|
||||||
|
autoFilter: true,
|
||||||
|
escapeFunction: (val: unknown): string => String(val),
|
||||||
|
filterFunction: (val: unknown): string => (val === null || val === undefined ? "" : String(val)),
|
||||||
|
useWith: true,
|
||||||
|
views: path.join(__dirname, "template"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default template;
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { Transform, type TransformCallback } from "stream";
|
||||||
|
import { Tail } from "tail";
|
||||||
|
import Vinyl from "vinyl";
|
||||||
|
|
||||||
|
export type WatchHandler = (line: string) => string | undefined;
|
||||||
|
|
||||||
|
export interface WatchParams {
|
||||||
|
source: string;
|
||||||
|
handler?: WatchHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
class BufferingTransform extends Transform {
|
||||||
|
_transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void {
|
||||||
|
this.push(chunk);
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TailVinyl extends Vinyl<BufferingTransform> {
|
||||||
|
private tail?: Tail;
|
||||||
|
|
||||||
|
constructor(params: WatchParams) {
|
||||||
|
super({ path: "out.log", contents: new BufferingTransform() });
|
||||||
|
if (params.source) {
|
||||||
|
this.tail = new Tail(params.source);
|
||||||
|
this.tail.on("line", (line) => {
|
||||||
|
if (params.handler) {
|
||||||
|
line = params.handler(line);
|
||||||
|
}
|
||||||
|
if (line) {
|
||||||
|
this.contents.write(line + "\n");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.tail.on("error", (error) => this.contents.write("error: " + error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clone() {
|
||||||
|
return new Vinyl({
|
||||||
|
cwd: this.cwd,
|
||||||
|
base: this.base,
|
||||||
|
history: this.history.slice(),
|
||||||
|
contents: this.contents,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
this.tail?.unwatch();
|
||||||
|
this.contents.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class WatchVinylTransform extends Transform {
|
||||||
|
constructor(private params: WatchParams) {
|
||||||
|
super({ objectMode: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
_transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void {
|
||||||
|
const log = new TailVinyl(this.params);
|
||||||
|
this.on("end", () => log.dispose());
|
||||||
|
this.push(log);
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const watch = (source: string, handler?: WatchHandler) => new WatchVinylTransform({ source, handler });
|
||||||
+86
-122
@@ -1,143 +1,107 @@
|
|||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import asset from "../common/asset";
|
||||||
|
import { BuildSystem, type Config, type ConfigSource } from "./type";
|
||||||
|
|
||||||
export interface ConfigParams {
|
export const DEFAULT_ICON = asset("icon.jpg");
|
||||||
name?: string;
|
|
||||||
main?: string;
|
|
||||||
preloader?: string;
|
|
||||||
sources?: string[];
|
|
||||||
assets?: string[];
|
|
||||||
libs?: LibDef[] | Record<string, string>;
|
|
||||||
macros?: string[];
|
|
||||||
flags?: string[];
|
|
||||||
meta?: ConfigMeta;
|
|
||||||
key?: SignKey;
|
|
||||||
android?: AndroidPreset[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ConfigMeta {
|
export const DEFAULT_CONFIG: Config = {
|
||||||
title?: string;
|
buildSystem: BuildSystem.HAXE,
|
||||||
filename?: string;
|
platforms: [],
|
||||||
icon?: string;
|
name: "",
|
||||||
version?: string;
|
main: "",
|
||||||
pack?: string;
|
preloader: null,
|
||||||
author?: string;
|
sources: [],
|
||||||
company?: string;
|
assets: [],
|
||||||
width?: number;
|
libs: [],
|
||||||
height?: number;
|
macros: [],
|
||||||
mobileWidth?: number;
|
flags: [],
|
||||||
mobileHeight?: number;
|
icon: DEFAULT_ICON,
|
||||||
fps?: number;
|
meta: {
|
||||||
}
|
|
||||||
|
|
||||||
export interface LibDef {
|
|
||||||
name: string;
|
|
||||||
version: string;
|
|
||||||
git?: string;
|
|
||||||
branch?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AndroidPreset {
|
|
||||||
path: string;
|
|
||||||
extensions: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SignKey {
|
|
||||||
store: string;
|
|
||||||
pass: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Config {
|
|
||||||
public name: string;
|
|
||||||
public main: string;
|
|
||||||
public preloader: string | null;
|
|
||||||
public sources: string[];
|
|
||||||
public assets: string[];
|
|
||||||
public libs: LibDef[];
|
|
||||||
public macros: string[];
|
|
||||||
public flags: string[];
|
|
||||||
public icon: string | null;
|
|
||||||
public meta: ConfigMeta;
|
|
||||||
public key: SignKey | null;
|
|
||||||
public android: AndroidPreset[];
|
|
||||||
|
|
||||||
private _params: ConfigParams[];
|
|
||||||
|
|
||||||
constructor(params?: ConfigParams) {
|
|
||||||
this._params = [];
|
|
||||||
this.name = "";
|
|
||||||
this.main = "";
|
|
||||||
this.preloader = null;
|
|
||||||
this.sources = [];
|
|
||||||
this.assets = [];
|
|
||||||
this.libs = [];
|
|
||||||
this.macros = [];
|
|
||||||
this.flags = [];
|
|
||||||
this.icon = null;
|
|
||||||
this.meta = {
|
|
||||||
title: null,
|
|
||||||
filename: null,
|
|
||||||
icon: null,
|
|
||||||
version: null,
|
|
||||||
pack: null,
|
|
||||||
author: null,
|
|
||||||
company: null,
|
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
mobileWidth: null,
|
|
||||||
mobileHeight: null,
|
|
||||||
fps: 60,
|
fps: 60,
|
||||||
|
},
|
||||||
|
key: null,
|
||||||
|
android: [],
|
||||||
};
|
};
|
||||||
this.key = null;
|
|
||||||
this.android = [];
|
|
||||||
if (params) {
|
|
||||||
this.update(params);
|
|
||||||
this.afterUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static absolutePath(file: string): string {
|
export const absolutePath = (file: string): string => {
|
||||||
const result = path.resolve(process.cwd(), path.normalize(file));
|
const result = path.resolve(process.cwd(), path.normalize(file));
|
||||||
return os.type() === "Windows_NT" ? result.split("\\").join("/") : result;
|
return os.type() === "Windows_NT" ? result.split("\\").join("/") : result;
|
||||||
}
|
};
|
||||||
|
|
||||||
update(params: ConfigParams) {
|
export const compile = (source: ConfigSource): Config => {
|
||||||
this._params.push(params);
|
return branch(DEFAULT_CONFIG, source);
|
||||||
if (params.name !== undefined) this.name = params.name;
|
};
|
||||||
if (params.main !== undefined) this.main = params.main;
|
|
||||||
if (params.preloader !== undefined) this.preloader = params.preloader;
|
export const branch = (config: Config, source: ConfigSource | Config): Config => {
|
||||||
if (params.sources !== undefined) this.sources = this.sources.concat(params.sources.map(Config.absolutePath));
|
const result = structuredClone(config);
|
||||||
if (params.assets !== undefined) this.assets = this.assets.concat(params.assets.map(Config.absolutePath));
|
|
||||||
if (params.libs !== undefined)
|
if (source.buildSystem !== undefined) {
|
||||||
this.libs = this.libs.concat(
|
result.buildSystem = source.buildSystem;
|
||||||
Array.isArray(params.libs)
|
}
|
||||||
? params.libs
|
if (source.platforms !== undefined) {
|
||||||
: Object.entries(params.libs).map(([k, v]) => ({ name: k, version: v })),
|
result.platforms = result.platforms.concat(source.platforms);
|
||||||
|
}
|
||||||
|
if (source.name !== undefined) {
|
||||||
|
result.name = source.name;
|
||||||
|
}
|
||||||
|
if (source.main !== undefined) {
|
||||||
|
result.main = source.main;
|
||||||
|
}
|
||||||
|
if (source.preloader !== undefined) {
|
||||||
|
result.preloader = source.preloader;
|
||||||
|
}
|
||||||
|
if (source.sources !== undefined) {
|
||||||
|
result.sources = result.sources.concat(source.sources.map(absolutePath));
|
||||||
|
}
|
||||||
|
if (source.assets !== undefined) {
|
||||||
|
result.assets = result.assets.concat(source.assets.map(absolutePath));
|
||||||
|
}
|
||||||
|
if (source.libs !== undefined) {
|
||||||
|
result.libs = result.libs.concat(
|
||||||
|
Array.isArray(source.libs) ? source.libs : Object.entries(source.libs).map(([k, v]) => ({ name: k, version: v })),
|
||||||
);
|
);
|
||||||
if (params.macros !== undefined) this.macros = this.macros.concat(params.macros);
|
}
|
||||||
if (params.flags !== undefined) this.flags = this.flags.concat(params.flags);
|
if (source.macros !== undefined) {
|
||||||
if (params.meta !== undefined) this.meta = { ...this.meta, ...params.meta };
|
result.macros = result.macros.concat(source.macros);
|
||||||
if (params.key !== undefined) this.key = params.key;
|
}
|
||||||
if (params.android !== undefined)
|
if (source.flags !== undefined) {
|
||||||
this.android = this.android.concat(
|
result.flags = result.flags.concat(source.flags);
|
||||||
params.android.map((item) => ({ path: Config.absolutePath(item.path), extensions: item.extensions })),
|
}
|
||||||
|
if (source.meta !== undefined) {
|
||||||
|
result.meta = { ...result.meta, ...source.meta };
|
||||||
|
}
|
||||||
|
if (source.key !== undefined) {
|
||||||
|
result.key = source.key;
|
||||||
|
}
|
||||||
|
if (source.android !== undefined) {
|
||||||
|
result.android = result.android.concat(
|
||||||
|
source.android.map((item) => ({ path: absolutePath(item.path), extensions: item.extensions })),
|
||||||
);
|
);
|
||||||
if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon);
|
}
|
||||||
|
if (source.haxe !== undefined) {
|
||||||
|
result.haxe = source.haxe;
|
||||||
|
}
|
||||||
|
if (result.icon) {
|
||||||
|
result.icon = absolutePath(result.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
afterUpdate() {
|
if (!result.meta.mobileWidth) {
|
||||||
if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width;
|
result.meta.mobileWidth = result.meta.width;
|
||||||
if (this.meta.mobileHeight === null && this.meta.mobileWidth)
|
|
||||||
this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 2.222222222);
|
|
||||||
}
|
}
|
||||||
|
if (!result.meta.mobileHeight && result.meta.mobileWidth) {
|
||||||
branch(params: ConfigParams) {
|
result.meta.mobileHeight = Math.round(result.meta.mobileWidth / 2.222222222);
|
||||||
const result = new Config();
|
|
||||||
for (const params of this._params) {
|
|
||||||
result.update(params);
|
|
||||||
}
|
}
|
||||||
result.update(params);
|
|
||||||
result.afterUpdate();
|
|
||||||
return result;
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const hasLib = (config: Config, name: string): boolean => {
|
||||||
|
for (const lib of config.libs) {
|
||||||
|
if (lib.name === name) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import os from "os";
|
||||||
|
import template from "../common/template";
|
||||||
|
|
||||||
|
export type Params = Record<string, any>;
|
||||||
|
|
||||||
|
export interface Link {
|
||||||
|
version?: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DefaultParams: string[][] = [
|
||||||
|
["debug", "<%= false %>"],
|
||||||
|
["os_name", "<%= {Linux:'linux',Windows_NT:'win'}[os.type()] %>"],
|
||||||
|
["os_name_long", "<%= {linux:'linux',win:'windows'}[os_name] %>"],
|
||||||
|
["os_arch", "<%= {x64:'64',ia32:''}[os.arch()] %>"],
|
||||||
|
["os_archive_ext", "<%= {linux:'tar.gz',win:'zip'}[os_name] %>"],
|
||||||
|
];
|
||||||
|
|
||||||
|
export const resolveParams = (source: Params, custom?: Params): Params => {
|
||||||
|
const params: Params = { ...source, os, debug: false };
|
||||||
|
if (custom) {
|
||||||
|
for (const [k, v] of Object.entries(custom)) {
|
||||||
|
params[k] = template.renderString(v, params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const [k, v] of DefaultParams) {
|
||||||
|
if (!Object.hasOwn(params, k)) {
|
||||||
|
params[k] = template.renderString(v, params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const resolveLink = (link: Link | string, params?: Params): string => {
|
||||||
|
if (typeof link === "string") {
|
||||||
|
return template.renderString(link, resolveParams({}, params));
|
||||||
|
} else {
|
||||||
|
return template.renderString(link.url, resolveParams(link, params));
|
||||||
|
}
|
||||||
|
};
|
||||||
+15
-89
@@ -1,92 +1,14 @@
|
|||||||
import progress from "cli-progress";
|
|
||||||
import fs from "fs";
|
|
||||||
import fse from "fs-extra";
|
|
||||||
import got from "got";
|
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import ps from "promise-streams";
|
import download from "../common/download";
|
||||||
import tar from "tar";
|
import { Logger } from "../common/log";
|
||||||
import unzip from "unzip-stream";
|
import { resolveLink, type Link } from "./link";
|
||||||
import { Log } from "../common/log";
|
|
||||||
|
|
||||||
export class Downloader {
|
|
||||||
static bar: progress.MultiBar;
|
|
||||||
|
|
||||||
static createProgressBar() {
|
|
||||||
if (Downloader.bar == null) {
|
|
||||||
Downloader.bar = new progress.MultiBar(
|
|
||||||
{
|
|
||||||
clearOnComplete: true,
|
|
||||||
},
|
|
||||||
progress.Presets.shades_grey,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Downloader.bar.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
static releaseProgressBar(bar: progress.MultiBar) {
|
|
||||||
bar.stop();
|
|
||||||
if (Downloader.bar != null) {
|
|
||||||
Downloader.bar.remove(bar);
|
|
||||||
if (Downloader.bar.bars.length === 0) {
|
|
||||||
Downloader.bar.stop();
|
|
||||||
Downloader.bar = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static download(url: string, dest: string, strip = 1, executable = false) {
|
|
||||||
fse.ensureDirSync(dest);
|
|
||||||
const bar = Downloader.createProgressBar();
|
|
||||||
let stream = got.stream(url);
|
|
||||||
stream = stream
|
|
||||||
.on("request", (r: any) => {
|
|
||||||
if (bar) bar.start(1, 0);
|
|
||||||
})
|
|
||||||
.on("downloadProgress", (p: any) => {
|
|
||||||
if (bar) {
|
|
||||||
bar.setTotal(p.total);
|
|
||||||
bar.update(p.transferred);
|
|
||||||
if (p.total === p.transferred) {
|
|
||||||
Downloader.releaseProgressBar(bar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (url.endsWith(".zip")) {
|
|
||||||
stream = stream.pipe(unzip.Parse()).on("entry", (entry: any) => {
|
|
||||||
const filePath = entry.path.split("/").slice(strip).join(path.sep);
|
|
||||||
if (filePath.length > 0) {
|
|
||||||
if (entry.type === "Directory") {
|
|
||||||
fse.ensureDirSync(path.join(dest, path.normalize(filePath)));
|
|
||||||
} else if (entry.type === "File") {
|
|
||||||
const fullFilePath = path.join(dest, path.normalize(filePath));
|
|
||||||
const dirPath = path.dirname(fullFilePath);
|
|
||||||
if (!fs.existsSync(dirPath)) {
|
|
||||||
fse.ensureDirSync(dirPath);
|
|
||||||
}
|
|
||||||
entry.pipe(
|
|
||||||
fs.createWriteStream(path.join(dest, path.normalize(filePath)), {
|
|
||||||
// ToDo: zip entry file mode?
|
|
||||||
mode: executable ? 0o755 : undefined,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
entry.autodrain();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (url.endsWith("tar.gz")) {
|
|
||||||
stream = stream.pipe(tar.x({ C: dest, strip: strip }));
|
|
||||||
} else {
|
|
||||||
stream = stream.pipe(fs.createWriteStream(path.join(dest, url.split("/").pop()!)));
|
|
||||||
}
|
|
||||||
return ps.wait(stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Sdk {
|
export class Sdk {
|
||||||
static _dir: string;
|
static _dir: string;
|
||||||
|
|
||||||
|
url!: string;
|
||||||
|
|
||||||
static set dir(value) {
|
static set dir(value) {
|
||||||
Sdk._dir = value;
|
Sdk._dir = value;
|
||||||
}
|
}
|
||||||
@@ -101,12 +23,12 @@ export class Sdk {
|
|||||||
|
|
||||||
public name: string;
|
public name: string;
|
||||||
public version: string;
|
public version: string;
|
||||||
public log: Log;
|
public log: Logger;
|
||||||
public path: string;
|
public path: string;
|
||||||
|
|
||||||
constructor(name: string, version: string) {
|
constructor(name: string, version: string) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.log = new Log(name);
|
this.log = new Logger(name);
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.path = Sdk.path(name, version);
|
this.path = Sdk.path(name, version);
|
||||||
}
|
}
|
||||||
@@ -126,8 +48,11 @@ export class Sdk {
|
|||||||
throw "Not implemented";
|
throw "Not implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
get link(): string {
|
get link(): string | Link {
|
||||||
throw "Not implemented";
|
return {
|
||||||
|
version: this.version,
|
||||||
|
url: this.url,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare(strip = 1): Promise<any> {
|
prepare(strip = 1): Promise<any> {
|
||||||
@@ -135,8 +60,9 @@ export class Sdk {
|
|||||||
if (this.prepared) {
|
if (this.prepared) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} else {
|
} else {
|
||||||
this.log.i("download: *%s*", this.link);
|
const url = resolveLink(this.link, { name: this.name, version: this.version });
|
||||||
return Downloader.download(this.link, this.path, strip);
|
this.log.i("download: *%s*", url);
|
||||||
|
return download(url, this.path, { strip });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+92
-14
@@ -1,15 +1,93 @@
|
|||||||
export const BuildSystem = {
|
export enum BuildSystem {
|
||||||
HAXE: "haxe",
|
HAXE = "haxe",
|
||||||
OPENFL: "openfl",
|
OPENFL = "openfl",
|
||||||
ADOBE_AIR: "adobe_air",
|
ADOBE_AIR = "adobe_air",
|
||||||
};
|
}
|
||||||
|
|
||||||
export const Platform = {
|
export enum Platform {
|
||||||
FLASH: "flash",
|
FLASH = "flash",
|
||||||
HTML5: "html5",
|
HTML5 = "html5",
|
||||||
LINUX: "linux",
|
LINUX = "linux",
|
||||||
WINDOWS: "windows",
|
WINDOWS = "windows",
|
||||||
ANDROID: "android",
|
ANDROID = "android",
|
||||||
NEKO: "neko",
|
NEKO = "neko",
|
||||||
CPP: "cpp",
|
CPP = "cpp",
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export interface LibDef {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
git?: string;
|
||||||
|
branch?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConfigMeta {
|
||||||
|
title?: string;
|
||||||
|
filename?: string;
|
||||||
|
version?: string;
|
||||||
|
pack?: string;
|
||||||
|
author?: string;
|
||||||
|
company?: string;
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
mobileWidth?: number;
|
||||||
|
mobileHeight?: number;
|
||||||
|
fps?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AndroidPreset {
|
||||||
|
path: string;
|
||||||
|
extensions: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SignKey {
|
||||||
|
store: string;
|
||||||
|
pass: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConfigSource {
|
||||||
|
buildSystem?: BuildSystem;
|
||||||
|
platforms?: Platform[];
|
||||||
|
name?: string;
|
||||||
|
main?: string;
|
||||||
|
preloader?: string;
|
||||||
|
sources?: string[];
|
||||||
|
assets?: string[];
|
||||||
|
libs?: LibDef[] | Record<string, string>;
|
||||||
|
macros?: string[];
|
||||||
|
flags?: string[];
|
||||||
|
meta?: ConfigMeta;
|
||||||
|
key?: SignKey;
|
||||||
|
android?: AndroidPreset[];
|
||||||
|
haxe?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Config {
|
||||||
|
buildSystem: BuildSystem;
|
||||||
|
platforms: Platform[];
|
||||||
|
name: string;
|
||||||
|
main: string;
|
||||||
|
preloader: string | null;
|
||||||
|
sources: string[];
|
||||||
|
assets: string[];
|
||||||
|
libs: LibDef[];
|
||||||
|
macros: string[];
|
||||||
|
flags: string[];
|
||||||
|
icon: string;
|
||||||
|
meta: ConfigMeta;
|
||||||
|
key: SignKey | null;
|
||||||
|
android: AndroidPreset[];
|
||||||
|
haxe?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PackageJson = Record<string, any>;
|
||||||
|
|
||||||
|
export interface ConfigJson {
|
||||||
|
SdkDir?: string;
|
||||||
|
BuildDir?: string;
|
||||||
|
Develop?: boolean;
|
||||||
|
UseRuffle?: boolean;
|
||||||
|
Key?: SignKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PresetJson = Record<string, ConfigSource>;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// @ts-nocheck
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import through from "through2";
|
import through from "through2";
|
||||||
|
|||||||
+34
-29
@@ -2,29 +2,47 @@ import fs from "fs";
|
|||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import through from "through2";
|
import through from "through2";
|
||||||
import { Env } from "../common/env";
|
import env from "../common/env";
|
||||||
import exec from "../common/exec";
|
import exec from "../common/exec";
|
||||||
import { System } from "../common/system";
|
import { HandlerWriter } from "../common/tail";
|
||||||
import { StringWritable } from "../common/tail";
|
import { Sdk } from "../core/sdk";
|
||||||
import { Downloader, Sdk } from "../core/sdk";
|
|
||||||
import { Command } from "../run/command";
|
import { Command } from "../run/command";
|
||||||
|
|
||||||
|
export class AndroidNdk extends Sdk {
|
||||||
|
static ID = "android-ndk";
|
||||||
|
|
||||||
|
static VERSION_R15C = "r15c";
|
||||||
|
static VERSION_R21E = "r21e";
|
||||||
|
static VERSION = AndroidNdk.VERSION_R21E;
|
||||||
|
|
||||||
|
url = "https://dl.google.com/android/repository/android-ndk-<%= version %>-<%= os_name_long %>-x86_64.zip";
|
||||||
|
|
||||||
|
constructor(version?: string) {
|
||||||
|
super(AndroidNdk.ID, version || AndroidNdk.VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
get prepared(): boolean {
|
||||||
|
try {
|
||||||
|
return fs.existsSync(`${this.path}/build/ndk-build`);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class Android extends Sdk {
|
export class Android extends Sdk {
|
||||||
static ID = "android";
|
static ID = "android";
|
||||||
|
|
||||||
static VERSION_7302050 = "7302050";
|
static VERSION_7302050 = "7302050";
|
||||||
static VERSION = Android.VERSION_7302050;
|
static VERSION = Android.VERSION_7302050;
|
||||||
|
|
||||||
static NDK_VERSION_R15C = "r15c";
|
private ndk: AndroidNdk;
|
||||||
static NDK_VERSION = Android.NDK_VERSION_R15C;
|
|
||||||
|
|
||||||
private ndk_version: string;
|
url = "https://dl.google.com/android/repository/commandlinetools-<%= os_name %>-<%= version %>_latest.zip";
|
||||||
private repository: string;
|
|
||||||
|
|
||||||
constructor(version?: string, ndkVersion?: string) {
|
constructor(version?: string, ndkVersion?: string) {
|
||||||
super(Android.ID, version || Android.VERSION);
|
super(Android.ID, version || Android.VERSION);
|
||||||
this.ndk_version = ndkVersion || Android.NDK_VERSION;
|
this.ndk = new AndroidNdk(ndkVersion);
|
||||||
this.repository = "https://dl.google.com/android/repository";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get prepared(): boolean {
|
get prepared(): boolean {
|
||||||
@@ -35,16 +53,12 @@ export class Android extends Sdk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get link(): string {
|
|
||||||
return `${this.repository}/commandlinetools-${System.os}-${this.version}_latest.zip`;
|
|
||||||
}
|
|
||||||
|
|
||||||
get android_home(): string {
|
get android_home(): string {
|
||||||
return this.path;
|
return this.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
get ndk_home(): string {
|
get ndk_home(): string {
|
||||||
return path.join(this.path, "ndk-bundle");
|
return this.ndk.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
get sdkmanager_bin(): string {
|
get sdkmanager_bin(): string {
|
||||||
@@ -54,19 +68,10 @@ export class Android extends Sdk {
|
|||||||
prepare(): Promise<any> {
|
prepare(): Promise<any> {
|
||||||
const result = [];
|
const result = [];
|
||||||
result.push(super.prepare(0));
|
result.push(super.prepare(0));
|
||||||
if (!fs.existsSync(path.join(this.ndk_home))) {
|
result.push(this.ndk.prepare());
|
||||||
result.push(this.prepare_ndk());
|
|
||||||
}
|
|
||||||
return Promise.all(result);
|
return Promise.all(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_ndk(): Promise<any> {
|
|
||||||
// ToDo: support windows
|
|
||||||
const url = `${this.repository}/android-ndk-${this.ndk_version}-${System.os}-x86_64.zip`;
|
|
||||||
this.log.d("download: *%s*", url);
|
|
||||||
return Downloader.download(url, this.ndk_home, 1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
sdkmanager(packages: string[]) {
|
sdkmanager(packages: string[]) {
|
||||||
this.log.i("sdkmanager: *%s*", packages.join(", "));
|
this.log.i("sdkmanager: *%s*", packages.join(", "));
|
||||||
const installedFile = path.join(this.path, ".installed");
|
const installedFile = path.join(this.path, ".installed");
|
||||||
@@ -100,9 +105,9 @@ export class Android extends Sdk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
Env.set("ANDROID_HOME", this.android_home);
|
env.set("ANDROID_HOME", this.android_home);
|
||||||
Env.set("ANDROID_NDK_HOME", this.ndk_home);
|
env.set("ANDROID_NDK_HOME", this.ndk_home);
|
||||||
Env.set("NDK_HOME", this.ndk_home);
|
env.set("NDK_HOME", this.ndk_home);
|
||||||
}
|
}
|
||||||
|
|
||||||
get adbBin(): string {
|
get adbBin(): string {
|
||||||
@@ -222,7 +227,7 @@ export class Android extends Sdk {
|
|||||||
const command = new Command(cmd).exec();
|
const command = new Command(cmd).exec();
|
||||||
this.push(command);
|
this.push(command);
|
||||||
command.contents.pipe(
|
command.contents.pipe(
|
||||||
new StringWritable((line) => {
|
new HandlerWriter((line: string) => {
|
||||||
if (line.includes("SDL") && (line.includes("onDestroy()") || line.includes("onStop()"))) {
|
if (line.includes("SDL") && (line.includes("onDestroy()") || line.includes("onStop()"))) {
|
||||||
callback();
|
callback();
|
||||||
throw "Exit"; // ToDo:
|
throw "Exit"; // ToDo:
|
||||||
|
|||||||
+10
-32
@@ -2,10 +2,8 @@ import fs from "fs";
|
|||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import through from "through2";
|
|
||||||
import { Env } from "../common/env";
|
|
||||||
import { System } from "../common/system";
|
import { System } from "../common/system";
|
||||||
import { TailVinyl } from "../common/tail";
|
import { watch } from "../common/watch";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
import run from "../run";
|
import run from "../run";
|
||||||
|
|
||||||
@@ -27,12 +25,15 @@ export class FlashPlayer extends Sdk {
|
|||||||
BASE_URL = "https://fpdownload.macromedia.com/pub/flashplayer/updaters";
|
BASE_URL = "https://fpdownload.macromedia.com/pub/flashplayer/updaters";
|
||||||
|
|
||||||
private debug: boolean;
|
private debug: boolean;
|
||||||
protected baseUrl: string;
|
|
||||||
|
url =
|
||||||
|
"https://fpdownload.macromedia.com/pub/flashplayer/updaters/" +
|
||||||
|
"<%= version %>/" +
|
||||||
|
"<%= {linux:'flash_player_sa_linux' + (debug ? '_debug' : '') +'.x86_64.tar.gz','win':'flashplayer_'+version+'_sa'+(debug ? '_debug' : '')+'.exe'}[os_name] %>";
|
||||||
|
|
||||||
constructor(debug: boolean = false, version?: string, playerId = FlashPlayer.ID) {
|
constructor(debug: boolean = false, version?: string, playerId = FlashPlayer.ID) {
|
||||||
super(playerId, version || FlashPlayer.VERSION);
|
super(playerId, version || FlashPlayer.VERSION);
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
this.baseUrl = Env.get("FLASHPLAYER_URL") || this.BASE_URL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
@@ -47,20 +48,8 @@ export class FlashPlayer extends Sdk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get link(): string {
|
|
||||||
const baseUrl = `${this.baseUrl}/${this.version}`;
|
|
||||||
if (System.isWindows) {
|
|
||||||
return baseUrl + `/flashplayer_${this.version}_sa${this.debug ? "_debug" : ""}.exe`;
|
|
||||||
} else if (System.isLinux) {
|
|
||||||
return baseUrl + `/flash_player_sa_linux${this.debug ? "_debug" : ""}.x86_64.tar.gz`;
|
|
||||||
} else {
|
|
||||||
throw `Unsupported os '${os.type()}'`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get flashPlayerBin(): string {
|
get flashPlayerBin(): string {
|
||||||
if (System.isWindows) {
|
if (System.isWindows) {
|
||||||
const v = this.version.split(".");
|
|
||||||
const playerName = `flashplayer_${this.version}_sa${this.debug ? "_debug" : ""}.exe`;
|
const playerName = `flashplayer_${this.version}_sa${this.debug ? "_debug" : ""}.exe`;
|
||||||
return path.join(this.path, playerName);
|
return path.join(this.path, playerName);
|
||||||
} else if (System.isLinux) {
|
} else if (System.isLinux) {
|
||||||
@@ -74,7 +63,7 @@ export class FlashPlayer extends Sdk {
|
|||||||
|
|
||||||
static get flashPlayerDir(): string {
|
static get flashPlayerDir(): string {
|
||||||
if (os.type() === "Windows_NT") {
|
if (os.type() === "Windows_NT") {
|
||||||
return path.join(process.env.APPDATA, "Macromedia", "Flash Player");
|
return path.join(process.env.APPDATA!, "Macromedia", "Flash Player");
|
||||||
} else if (os.type() === "Linux") {
|
} else if (os.type() === "Linux") {
|
||||||
return path.join(os.homedir(), ".macromedia", "Flash_Player");
|
return path.join(os.homedir(), ".macromedia", "Flash_Player");
|
||||||
} else {
|
} else {
|
||||||
@@ -90,7 +79,7 @@ export class FlashPlayer extends Sdk {
|
|||||||
const filename = path.join(os.homedir(), "mm.cfg");
|
const filename = path.join(os.homedir(), "mm.cfg");
|
||||||
const value = "TraceOutputFileEnable=1";
|
const value = "TraceOutputFileEnable=1";
|
||||||
if (fs.existsSync(filename)) {
|
if (fs.existsSync(filename)) {
|
||||||
const data = fs.readFileSync(filename);
|
const data = fs.readFileSync(filename, "utf8");
|
||||||
if (data.indexOf(value) === -1) {
|
if (data.indexOf(value) === -1) {
|
||||||
fs.appendFileSync(filename, `${value}\n`);
|
fs.appendFileSync(filename, `${value}\n`);
|
||||||
}
|
}
|
||||||
@@ -104,7 +93,7 @@ export class FlashPlayer extends Sdk {
|
|||||||
static trust(value: string) {
|
static trust(value: string) {
|
||||||
const filename = path.join(this.flashPlayerDir, "#Security", "FlashPlayerTrust", "gulp.cfg");
|
const filename = path.join(this.flashPlayerDir, "#Security", "FlashPlayerTrust", "gulp.cfg");
|
||||||
if (fs.existsSync(filename)) {
|
if (fs.existsSync(filename)) {
|
||||||
const data = fs.readFileSync(filename);
|
const data = fs.readFileSync(filename, "utf8");
|
||||||
if (data.indexOf(value) === -1) {
|
if (data.indexOf(value) === -1) {
|
||||||
fs.appendFileSync(filename, `${value}\n`);
|
fs.appendFileSync(filename, `${value}\n`);
|
||||||
}
|
}
|
||||||
@@ -120,17 +109,6 @@ export class FlashPlayer extends Sdk {
|
|||||||
this.log.i("_run_ *%s*", filename);
|
this.log.i("_run_ *%s*", filename);
|
||||||
FlashPlayer.trust(filename);
|
FlashPlayer.trust(filename);
|
||||||
FlashPlayer.enableLog();
|
FlashPlayer.enableLog();
|
||||||
return run(`${this.flashPlayerBin} ${filename}`, params)
|
return run(`${this.flashPlayerBin} ${filename}`, params).exec().pipe(watch(FlashPlayer.log));
|
||||||
.exec()
|
|
||||||
.pipe(
|
|
||||||
through.obj(function (file: any, enc: string, callback: any) {
|
|
||||||
const log = new TailVinyl({
|
|
||||||
path: FlashPlayer.log,
|
|
||||||
});
|
|
||||||
this.on("end", () => log.dispose());
|
|
||||||
this.push(log);
|
|
||||||
callback();
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+70
-51
@@ -1,15 +1,16 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import rename from "gulp-rename";
|
import rename from "gulp-rename";
|
||||||
import template from "lodash.template";
|
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import vfs from "vinyl-fs";
|
import vfs from "vinyl-fs";
|
||||||
import { Env } from "../common/env";
|
import env from "../common/env";
|
||||||
import exec from "../common/exec";
|
import exec from "../common/exec";
|
||||||
import { System } from "../common/system";
|
import { System } from "../common/system";
|
||||||
import type { Config, LibDef } from "../core/config";
|
import template from "../common/template";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
|
import type { Config, LibDef } from "../core/type";
|
||||||
|
import { Platform } from "../core/type";
|
||||||
import { Neko } from "./neko";
|
import { Neko } from "./neko";
|
||||||
|
|
||||||
export class Haxe extends Sdk {
|
export class Haxe extends Sdk {
|
||||||
@@ -25,11 +26,18 @@ export class Haxe extends Sdk {
|
|||||||
static VERSION_4_0_2 = "4.0.2";
|
static VERSION_4_0_2 = "4.0.2";
|
||||||
static VERSION_4_0_3 = "4.0.3";
|
static VERSION_4_0_3 = "4.0.3";
|
||||||
static VERSION_4_0_5 = "4.0.5";
|
static VERSION_4_0_5 = "4.0.5";
|
||||||
static VERSION_4 = Haxe.VERSION_4_0_5;
|
static VERSION_4_2_5 = "4.2.5";
|
||||||
|
static VERSION_4_3_7 = "4.3.7";
|
||||||
|
static VERSION_4 = Haxe.VERSION_4_2_5;
|
||||||
static VERSION = Haxe.VERSION_4;
|
static VERSION = Haxe.VERSION_4;
|
||||||
|
|
||||||
static buildDir = path.join(process.cwd(), "build");
|
static buildDir = path.join(process.cwd(), "build");
|
||||||
|
|
||||||
|
url =
|
||||||
|
"https://github.com/HaxeFoundation/haxe/releases/download/" +
|
||||||
|
"<%= version %>/" +
|
||||||
|
"haxe-<%= version %>-<%= os_name %><%= os_arch %>.<%= os_archive_ext %>";
|
||||||
|
|
||||||
getBin(name: string) {
|
getBin(name: string) {
|
||||||
if (System.isWindows) {
|
if (System.isWindows) {
|
||||||
return path.join(this.path, name + ".exe");
|
return path.join(this.path, name + ".exe");
|
||||||
@@ -68,37 +76,37 @@ export class Haxe extends Sdk {
|
|||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
this.neko.activate();
|
this.neko.activate();
|
||||||
Env.set("HAXE_VERSION", this.version);
|
env.set("HAXE_VERSION", this.version);
|
||||||
Env.set("HAXE_STD_PATH", path.join(this.path, "std"));
|
env.set("HAXE_STD_PATH", path.join(this.path, "std"));
|
||||||
Env.set("HAXE_HOME", this.path);
|
env.set("HAXE_HOME", this.path);
|
||||||
Env.addPath(this.path);
|
env.addPath(this.path);
|
||||||
Env.addPath(this.path, "LD_LIBRARY_PATH");
|
env.addPath(this.path, "LD_LIBRARY_PATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
async replaceHaxelib(version: string): Promise<any> {
|
||||||
return Promise.all([this.neko.prepare(), super.prepare()]).then(() => {
|
const haxe = new Haxe(version);
|
||||||
fs.copyFileSync(path.resolve(import.meta.dirname, "..", "template/haxe/activate"), path.resolve(this.path, "activate"));
|
await haxe.prepare();
|
||||||
});
|
fs.copyFileSync(haxe.haxelibBin, this.haxelibBin);
|
||||||
}
|
}
|
||||||
|
|
||||||
get link(): string {
|
async prepare(): Promise<any> {
|
||||||
if (System.isWindows) {
|
await Promise.all([this.neko.prepare(), super.prepare()]);
|
||||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`;
|
fs.copyFileSync(path.resolve(import.meta.dirname, "template/haxe/activate"), path.resolve(this.path, "activate"));
|
||||||
} else if (System.isLinux) {
|
// TODO: old haxelib fail with EOF
|
||||||
let arch = System.archInt;
|
if (this.intVersion < 430) {
|
||||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-linux${arch}.tar.gz`;
|
await this.replaceHaxelib(Haxe.VERSION_4_3_7);
|
||||||
} else {
|
|
||||||
throw `Unsupported os: ${System.os}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
haxe(args: any) {
|
haxe(args: any) {
|
||||||
this.activate();
|
this.activate();
|
||||||
|
this.log.d("_haxe_ *%s*", args.join(" "));
|
||||||
return exec(".", [this.haxeBin].concat(args).join(" "));
|
return exec(".", [this.haxeBin].concat(args).join(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
haxelib(args: any) {
|
haxelib(args: any) {
|
||||||
this.activate();
|
this.activate();
|
||||||
|
this.log.d("_haxelib_ *%s*", args.join(" "));
|
||||||
return exec(".", [this.haxelibBin].concat(args).join(" "));
|
return exec(".", [this.haxelibBin].concat(args).join(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,14 +114,13 @@ export class Haxe extends Sdk {
|
|||||||
return path.join(Haxe.buildDir, config.name);
|
return path.join(Haxe.buildDir, config.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
openfl(command: string, platform: string, config: Config, debug = false) {
|
openfl(command: string, platform: Platform, config: Config, debug = false) {
|
||||||
this.log.i("_openfl_ _build_ *%s*", platform);
|
this.log.i("_openfl_ _build_ *%s*", platform);
|
||||||
this.activate();
|
this.activate();
|
||||||
const buildDir = this.resolveBuildDir(config);
|
const buildDir = this.resolveBuildDir(config);
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
|
|
||||||
const projectTemplate = template(fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/project.xml")));
|
const project = template.render("project.xml", { ...config, buildDir: buildDir });
|
||||||
const project = projectTemplate({ ...config, buildDir: buildDir });
|
|
||||||
fs.writeFileSync(path.resolve(buildDir, "project.xml"), project);
|
fs.writeFileSync(path.resolve(buildDir, "project.xml"), project);
|
||||||
|
|
||||||
const args = ["-cwd", buildDir, "run", "openfl", command, platform];
|
const args = ["-cwd", buildDir, "run", "openfl", command, platform];
|
||||||
@@ -123,39 +130,49 @@ export class Haxe extends Sdk {
|
|||||||
const target = path.resolve(buildDir, platform, "bin");
|
const target = path.resolve(buildDir, platform, "bin");
|
||||||
fse.emptyDirSync(target);
|
fse.emptyDirSync(target);
|
||||||
const result =
|
const result =
|
||||||
|
(
|
||||||
{
|
{
|
||||||
android: `app/build/outputs/**/${config.meta.filename}-debug.apk`,
|
[Platform.ANDROID]: `app/build/outputs/**/${config.meta.filename}-debug.apk`,
|
||||||
flash: "*.swf",
|
[Platform.FLASH]: "*.swf",
|
||||||
}[platform] || "**/*";
|
} as Record<Platform, string>
|
||||||
|
)[platform] || "**/*";
|
||||||
return this.haxelib(args).then(() => {
|
return this.haxelib(args).then(() => {
|
||||||
let r = vfs.src(`${target}/${result}`);
|
let r = vfs.src(`${target}/${result}`, { encoding: false });
|
||||||
if (platform === "android") {
|
if (platform === Platform.ANDROID) {
|
||||||
r = r.pipe(rename(`${config.meta.filename}_${config.meta.version}.apk`));
|
r = r.pipe(rename(`${config.meta.filename}_${config.meta.version}.apk`));
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
build(platform: string, config: Config, debug = false) {
|
build(platform: Platform, config: Config, debug = false) {
|
||||||
this.log.i("_build_ *%s*", platform);
|
this.log.i("_build_ *%s*", platform);
|
||||||
this.activate();
|
this.activate();
|
||||||
const buildDir = this.resolveBuildDir(config);
|
const buildDir = this.resolveBuildDir(config);
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
|
|
||||||
const projectTemplate = template(fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/project.hxml")));
|
|
||||||
|
|
||||||
const ext =
|
const ext =
|
||||||
|
(
|
||||||
{
|
{
|
||||||
flash: ".swf",
|
[Platform.FLASH]: ".swf",
|
||||||
neko: ".n",
|
[Platform.NEKO]: ".n",
|
||||||
}[platform] || "";
|
} as Record<Platform, string>
|
||||||
|
)[platform] || "";
|
||||||
|
|
||||||
const out =
|
const out =
|
||||||
|
(
|
||||||
{
|
{
|
||||||
flash: "swf",
|
[Platform.FLASH]: "swf",
|
||||||
}[platform] || platform;
|
} as Record<Platform, string>
|
||||||
|
)[platform] || platform;
|
||||||
|
|
||||||
const project = projectTemplate({ ...config, buildDir: buildDir, platform: platform, ext: ext, out: out });
|
const project = template.render("project.hxml", {
|
||||||
|
...config,
|
||||||
|
buildDir: buildDir,
|
||||||
|
platform: platform,
|
||||||
|
ext: ext,
|
||||||
|
out: out,
|
||||||
|
});
|
||||||
const projectHXML = path.resolve(buildDir, "project.hxml");
|
const projectHXML = path.resolve(buildDir, "project.hxml");
|
||||||
fs.writeFileSync(projectHXML, project);
|
fs.writeFileSync(projectHXML, project);
|
||||||
|
|
||||||
@@ -164,37 +181,39 @@ export class Haxe extends Sdk {
|
|||||||
args.push("-debug");
|
args.push("-debug");
|
||||||
}
|
}
|
||||||
const target = path.resolve(buildDir, platform, "bin");
|
const target = path.resolve(buildDir, platform, "bin");
|
||||||
if (platform !== "cpp") {
|
if (platform !== Platform.CPP) {
|
||||||
fse.emptyDirSync(target);
|
fse.emptyDirSync(target);
|
||||||
}
|
}
|
||||||
for (const asset of config.assets) {
|
for (const asset of config.assets) {
|
||||||
fse.copySync(asset, path.join(target, asset.split("/").pop()!));
|
fse.copySync(asset, path.join(target, asset.split("/").pop()!));
|
||||||
}
|
}
|
||||||
const result =
|
const result =
|
||||||
|
(
|
||||||
{
|
{
|
||||||
cpp: `${config.meta.filename}/${config.main.split(".").pop()}${debug ? "-debug" : ""}`,
|
[Platform.CPP]: `${config.meta.filename}/${config.main.split(".").pop()}${debug ? "-debug" : ""}`,
|
||||||
}[platform] || "**/*";
|
} as Record<Platform, string>
|
||||||
|
)[platform] || "**/*";
|
||||||
return this.haxe(args).then(() => {
|
return this.haxe(args).then(() => {
|
||||||
let r = vfs.src(`${target}/${result}`);
|
let r = vfs.src(`${target}/${result}`, { encoding: false });
|
||||||
if (platform === "cpp") {
|
if (platform === Platform.CPP) {
|
||||||
r = r.pipe(rename(config.meta.filename));
|
r = r.pipe(rename(config.meta.filename!));
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
install(packages: Record<string, string> | LibDef[]) {
|
install(packages: Record<string, string> | LibDef[]) {
|
||||||
this.activate();
|
|
||||||
let promise = this.haxelib(["setup", path.join(this.path, "lib")]);
|
|
||||||
const next = (args: any) => () => {
|
|
||||||
this.log.i("_haxelib_ _install_ *%s:%s*", args[1], args[2]);
|
|
||||||
return this.haxelib(args);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!Array.isArray(packages)) {
|
if (!Array.isArray(packages)) {
|
||||||
packages = Object.entries(packages).map(([k, v]) => ({ name: k, version: v }));
|
packages = Object.entries(packages).map(([k, v]) => ({ name: k, version: v }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.log.i("_install_ *%s*", packages.map((item) => `${item.name}:${item.version}`).join(" "));
|
||||||
|
this.activate();
|
||||||
|
let promise = this.haxelib(["setup", path.join(this.path, "lib")]);
|
||||||
|
const next = (args: any) => () => {
|
||||||
|
return this.haxelib(args);
|
||||||
|
};
|
||||||
|
|
||||||
for (let pack of packages) {
|
for (let pack of packages) {
|
||||||
const args = [];
|
const args = [];
|
||||||
let version = null;
|
let version = null;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import template from "lodash.template";
|
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import exec from "../common/exec";
|
import exec from "../common/exec";
|
||||||
import type { Config } from "../core/config";
|
import template from "../common/template";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
|
import type { Config } from "../core/type";
|
||||||
|
|
||||||
export class InnoSetup extends Sdk {
|
export class InnoSetup extends Sdk {
|
||||||
static ID = "innosetup";
|
static ID = "innosetup";
|
||||||
@@ -43,8 +43,7 @@ export class InnoSetup extends Sdk {
|
|||||||
|
|
||||||
pack(config: Config, source: string, output: string) {
|
pack(config: Config, source: string, output: string) {
|
||||||
const buildDir = path.join(os.tmpdir(), "build", config.name, "innosetup");
|
const buildDir = path.join(os.tmpdir(), "build", config.name, "innosetup");
|
||||||
const appTemplate = template(fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/windows/app.iss"), "utf8"));
|
const app = template.render("windows/app.iss", { ...config, buildDir: buildDir, output: output });
|
||||||
const app = appTemplate({ ...config, buildDir: buildDir, output: output });
|
|
||||||
|
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
fse.copySync(`${source}`, `${buildDir}`);
|
fse.copySync(`${source}`, `${buildDir}`);
|
||||||
|
|||||||
+13
-48
@@ -1,59 +1,27 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { Env } from "../common/env";
|
import env from "../common/env";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
import run from "../run/index";
|
import run from "../run/index";
|
||||||
|
|
||||||
export class NekoLink {
|
|
||||||
static get type() {
|
|
||||||
switch (os.type()) {
|
|
||||||
case "Linux":
|
|
||||||
return "linux";
|
|
||||||
case "Windows_NT":
|
|
||||||
return "win";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static get arch() {
|
|
||||||
switch (os.arch()) {
|
|
||||||
case "ia32":
|
|
||||||
return "";
|
|
||||||
case "x64":
|
|
||||||
return "64";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static get ext() {
|
|
||||||
switch (os.type()) {
|
|
||||||
case "Linux":
|
|
||||||
return "tar.gz";
|
|
||||||
case "Windows_NT":
|
|
||||||
return "zip";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static get(version: string) {
|
|
||||||
const vv = version.split("\.").join("-");
|
|
||||||
const filename = `neko-${version}-${NekoLink.type}${NekoLink.arch}.${NekoLink.ext}`;
|
|
||||||
return `https://github.com/HaxeFoundation/neko/releases/download/v${vv}/${filename}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Neko extends Sdk {
|
export class Neko extends Sdk {
|
||||||
static ID = "neko";
|
static ID = "neko";
|
||||||
|
|
||||||
static VERSION_2_2_0 = "2.2.0";
|
static VERSION_2_2_0 = "2.2.0";
|
||||||
static VERSION = Neko.VERSION_2_2_0;
|
static VERSION_2_4_0 = "2.4.0";
|
||||||
|
static VERSION_2_4_1 = "2.4.1";
|
||||||
|
static VERSION = Neko.VERSION_2_4_1;
|
||||||
|
|
||||||
|
url =
|
||||||
|
"https://github.com/HaxeFoundation/neko/releases/download/" +
|
||||||
|
"v<%= version.split('.').join('-') %>/" +
|
||||||
|
"neko-<%= version %>-<%= os_name %><%= os_arch %>.<%= os_archive_ext %>";
|
||||||
|
|
||||||
constructor(version?: string) {
|
constructor(version?: string) {
|
||||||
super(Neko.ID, version || Neko.VERSION);
|
super(Neko.ID, version || Neko.VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
get link() {
|
|
||||||
return NekoLink.get(this.version);
|
|
||||||
}
|
|
||||||
|
|
||||||
get prepared() {
|
get prepared() {
|
||||||
try {
|
try {
|
||||||
return fs.existsSync(this.nekoBin);
|
return fs.existsSync(this.nekoBin);
|
||||||
@@ -63,17 +31,14 @@ export class Neko extends Sdk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
Env.set("NEKO_INSTPATH", this.path);
|
env.set("NEKO_INSTPATH", this.path);
|
||||||
Env.addPath(this.path);
|
env.addPath(this.path);
|
||||||
Env.addPath(this.path, "LD_LIBRARY_PATH");
|
env.addPath(this.path, "LD_LIBRARY_PATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
return Promise.all([super.prepare()]).then(() => {
|
return Promise.all([super.prepare()]).then(() => {
|
||||||
fs.copyFileSync(
|
fs.copyFileSync(path.resolve(import.meta.dirname, "template/neko/activate"), path.resolve(this.path, "activate"));
|
||||||
path.resolve(import.meta.dirname, "..", "template/neko/activate"),
|
|
||||||
path.resolve(this.path, "activate"),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-29
@@ -1,39 +1,25 @@
|
|||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import through from "through2";
|
|
||||||
import { Env } from "../common/env";
|
|
||||||
import { System } from "../common/system";
|
import { System } from "../common/system";
|
||||||
import { TailVinyl } from "../common/tail";
|
import { watch } from "../common/watch";
|
||||||
import run from "../run";
|
import run from "../run";
|
||||||
import { FlashPlayer } from "./flashplayer";
|
import { FlashPlayer } from "./flashplayer";
|
||||||
|
|
||||||
export class RufflePlayer extends FlashPlayer {
|
export class RufflePlayer extends FlashPlayer {
|
||||||
static ID = "ruffle";
|
static ID = "ruffle";
|
||||||
|
|
||||||
static VERSION_2026_05_15 = "nightly-2026_05_15";
|
|
||||||
static VERSION_2026_10_13 = "nightly-2026_10_13";
|
|
||||||
static VERSION_0_5_0 = "0.5.0";
|
static VERSION_0_5_0 = "0.5.0";
|
||||||
static VERSION_0_6_0 = "0.6.0";
|
static VERSION_0_6_0 = "0.6.0";
|
||||||
static VERSION_0_7_1 = "0.7.1";
|
static VERSION_0_7_1 = "0.7.1";
|
||||||
static VERSION = RufflePlayer.VERSION_2026_10_13;
|
static VERSION = RufflePlayer.VERSION_0_7_1;
|
||||||
|
|
||||||
BASE_URL = "https://github.com/ruffle-rs/ruffle/releases/download";
|
url =
|
||||||
|
"https://github.com/ruffle-rs/ruffle/releases/download/" +
|
||||||
|
"v<%= version %>/" +
|
||||||
|
"ruffle-<%= version %>-<%= os_name_long %>-x86_64.<%= os_archive_ext %>";
|
||||||
|
|
||||||
constructor(debug: boolean, version: string) {
|
constructor(debug: boolean, version: string) {
|
||||||
super(debug, version || RufflePlayer.VERSION, RufflePlayer.ID);
|
super(debug, version || RufflePlayer.VERSION, RufflePlayer.ID);
|
||||||
this.baseUrl = Env.get("RUFFLE_URL") || this.BASE_URL;
|
|
||||||
}
|
|
||||||
|
|
||||||
get link(): string {
|
|
||||||
const nightly = this.version.includes("nightly");
|
|
||||||
const baseUrl = `${this.baseUrl}/${nightly ? "" : "v"}${this.version.replaceAll("_", "-")}`;
|
|
||||||
if (System.isWindows) {
|
|
||||||
return baseUrl + `/ruffle-${this.version}-windows-x86_64.zip`;
|
|
||||||
} else if (System.isLinux) {
|
|
||||||
return baseUrl + `/ruffle-${this.version}-linux-x86_64.tar.gz`;
|
|
||||||
} else {
|
|
||||||
throw `Unsupported os '${os.type()}'`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get flashPlayerBin(): string {
|
get flashPlayerBin(): string {
|
||||||
@@ -55,18 +41,10 @@ export class RufflePlayer extends FlashPlayer {
|
|||||||
return run(`${this.flashPlayerBin} ${filename}`, params)
|
return run(`${this.flashPlayerBin} ${filename}`, params)
|
||||||
.exec()
|
.exec()
|
||||||
.pipe(
|
.pipe(
|
||||||
through.obj(function (file: any, enc: string, callback: any) {
|
watch(RufflePlayer.log, (line: string) => {
|
||||||
const log = new TailVinyl({
|
|
||||||
path: RufflePlayer.log,
|
|
||||||
handler: (line: string) => {
|
|
||||||
if (line.includes("avm_trace")) {
|
if (line.includes("avm_trace")) {
|
||||||
return line.split("avm_trace: ").pop();
|
return line.split("avm_trace: ").pop();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
});
|
|
||||||
this.on("end", () => log.dispose());
|
|
||||||
this.push(log);
|
|
||||||
callback();
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,10 @@
|
|||||||
|
export * from "./common/download";
|
||||||
|
export * from "./common/log";
|
||||||
|
export * from "./common/output";
|
||||||
export * from "./common/system";
|
export * from "./common/system";
|
||||||
|
export * from "./common/template";
|
||||||
export * from "./core/config";
|
export * from "./core/config";
|
||||||
|
export * from "./core/link";
|
||||||
export * from "./core/sdk";
|
export * from "./core/sdk";
|
||||||
export * from "./core/type";
|
export * from "./core/type";
|
||||||
export * from "./impl/android";
|
export * from "./impl/android";
|
||||||
@@ -8,6 +13,7 @@ export * from "./impl/haxe";
|
|||||||
export * from "./impl/innosetup";
|
export * from "./impl/innosetup";
|
||||||
export * from "./impl/neko";
|
export * from "./impl/neko";
|
||||||
export * from "./impl/ruffle";
|
export * from "./impl/ruffle";
|
||||||
|
export * from "./preset";
|
||||||
export * from "./project";
|
export * from "./project";
|
||||||
export * from "./project/impl";
|
export * from "./project/impl";
|
||||||
export * from "./project/preset";
|
export * from "./task";
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { branch, compile } from "../core/config";
|
||||||
|
import type { Config, PresetJson } from "../core/type";
|
||||||
|
|
||||||
|
export default (preset: PresetJson): Config[] => {
|
||||||
|
const config: Config = compile(preset["default"] || {});
|
||||||
|
const result: Config[] = [];
|
||||||
|
for (const [k, v] of Object.entries(preset)) {
|
||||||
|
if (k == "default") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.push(branch(config, { ...v, name: k }));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import compiler from "./compiler";
|
||||||
|
import loader from "./loader";
|
||||||
|
import validator from "./validator";
|
||||||
|
|
||||||
|
export const Preset = {
|
||||||
|
compiler,
|
||||||
|
loader,
|
||||||
|
validator,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Preset;
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import dateformat from "dateformat";
|
||||||
|
import fs from "fs";
|
||||||
|
import os from "os";
|
||||||
|
import path from "path";
|
||||||
|
import template from "../common/template";
|
||||||
|
import { Sdk } from "../core/sdk";
|
||||||
|
import { Platform, type ConfigJson, type ConfigSource, type PackageJson, type PresetJson } from "../core/type";
|
||||||
|
import { Haxe } from "../impl/haxe";
|
||||||
|
import { RuffleRunner, Runner } from "../project";
|
||||||
|
|
||||||
|
export const DEFAULT_CONFIG_JSON: ConfigJson = {
|
||||||
|
SdkDir: "$HOME/sdk",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const resolvePath = (path: string) => path.replace("$HOME", os.homedir());
|
||||||
|
|
||||||
|
export const applyConfig = (config: ConfigJson) => {
|
||||||
|
// TODO: ruffle kludge
|
||||||
|
if (config.UseRuffle) {
|
||||||
|
Runner.register(Platform.FLASH, RuffleRunner);
|
||||||
|
}
|
||||||
|
if (config.SdkDir) {
|
||||||
|
Sdk.dir = resolvePath(config.SdkDir);
|
||||||
|
}
|
||||||
|
if (config.BuildDir) {
|
||||||
|
Haxe.buildDir = resolvePath(config.BuildDir);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default (basedir: string = "."): PresetJson => {
|
||||||
|
const presetFile = path.join(basedir, "haxetool.json");
|
||||||
|
const configFile = path.join(basedir, "config.json");
|
||||||
|
const packageFile = path.join(basedir, "package.json");
|
||||||
|
const presetJson: PresetJson = JSON.parse(fs.readFileSync(presetFile, "utf8"));
|
||||||
|
const configJson: ConfigJson = {
|
||||||
|
...DEFAULT_CONFIG_JSON,
|
||||||
|
...(fs.existsSync(configFile) ? JSON.parse(fs.readFileSync(configFile, "utf8")) : {}),
|
||||||
|
};
|
||||||
|
applyConfig(configJson);
|
||||||
|
const packageJson: PackageJson = fs.existsSync(packageFile) ? JSON.parse(fs.readFileSync(packageFile, "utf8")) : {};
|
||||||
|
for (const [k, v] of Object.entries(presetJson)) {
|
||||||
|
presetJson[k] = JSON.parse(
|
||||||
|
template.renderString(JSON.stringify(v), {
|
||||||
|
config: configJson,
|
||||||
|
package: packageJson,
|
||||||
|
env: process.env,
|
||||||
|
dateformat: dateformat,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const defaultConfig: ConfigSource = presetJson["default"] || {};
|
||||||
|
defaultConfig.meta = {
|
||||||
|
...{
|
||||||
|
title: packageJson.name,
|
||||||
|
filename: packageJson.name,
|
||||||
|
version: packageJson.version,
|
||||||
|
pack: `com.${packageJson.name}`,
|
||||||
|
author: packageJson.author as string,
|
||||||
|
},
|
||||||
|
...(defaultConfig.meta || {}),
|
||||||
|
};
|
||||||
|
presetJson["default"] = defaultConfig;
|
||||||
|
return presetJson;
|
||||||
|
};
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import Ajv from "ajv";
|
||||||
|
import fs from "fs";
|
||||||
|
import asset from "../common/asset";
|
||||||
|
import type { PresetJson } from "../core/type";
|
||||||
|
|
||||||
|
export default (preset: PresetJson) => {
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const presetSchema = ajv.compile(JSON.parse(fs.readFileSync(asset("haxetool.schema.json"), "utf-8")));
|
||||||
|
const valid = presetSchema(preset);
|
||||||
|
if (!valid) {
|
||||||
|
throw presetSchema.errors;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { Config } from "../../core/config";
|
import { BuildSystem, type Config, Platform } from "../../core/type";
|
||||||
import { Target } from "./target";
|
import { Target } from "./target";
|
||||||
|
|
||||||
export class Builder extends Target {
|
export class Builder extends Target {
|
||||||
@@ -7,7 +7,7 @@ export class Builder extends Target {
|
|||||||
public buildSystem: string;
|
public buildSystem: string;
|
||||||
public debug: boolean;
|
public debug: boolean;
|
||||||
|
|
||||||
constructor(config: Config, platform: string, buildSystem: string, debug: boolean = false) {
|
constructor(config: Config, platform: Platform, buildSystem: BuildSystem, debug: boolean = false) {
|
||||||
super(config, platform);
|
super(config, platform);
|
||||||
this.buildSystem = buildSystem;
|
this.buildSystem = buildSystem;
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
@@ -17,7 +17,7 @@ export class Builder extends Target {
|
|||||||
Builder.factory[buildSystem] = builder;
|
Builder.factory[buildSystem] = builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
static new(config: Config, platform: string, buildSystem: string, debug: boolean = false): Builder {
|
static new(config: Config, platform: Platform, buildSystem: BuildSystem, debug: boolean = false): Builder {
|
||||||
return new Builder.factory[buildSystem](config, platform, buildSystem, debug);
|
return new Builder.factory[buildSystem](config, platform, buildSystem, debug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import type { Config } from "../../core/config";
|
import { type Config, Platform } from "../../core/type";
|
||||||
import { Target } from "./target";
|
import { Target } from "./target";
|
||||||
|
|
||||||
export type PackerFactory = new (config: Config) => Packer;
|
export type PackerFactory = new (config: Config) => Packer;
|
||||||
|
|
||||||
export class Packer extends Target {
|
export class Packer extends Target {
|
||||||
static factory: Record<string, Record<string, PackerFactory>> = {};
|
static factory: Partial<Record<Platform, Record<string, PackerFactory>>> = {};
|
||||||
|
|
||||||
call() {
|
call() {
|
||||||
throw "Not Implemented";
|
throw "Not Implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
static register(platform: string, name: string, packer: PackerFactory) {
|
static register(platform: Platform, name: string, packer: PackerFactory) {
|
||||||
if (!Packer.factory[platform]) Packer.factory[platform] = {};
|
if (!Packer.factory[platform]) Packer.factory[platform] = {};
|
||||||
Packer.factory[platform][name] = packer;
|
Packer.factory[platform][name] = packer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static new(config: Config, platform: string, name: string): Packer {
|
static new(config: Config, platform: Platform, name: string): Packer {
|
||||||
return new Packer.factory[platform][name](config);
|
return new Packer.factory[platform];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import rename from "gulp-rename";
|
import rename from "gulp-rename";
|
||||||
import { DEBUG } from "../../common/debug";
|
import output from "../../common/output";
|
||||||
import { tail } from "../../common/tail";
|
import { tail } from "../../common/tail";
|
||||||
import { Config } from "../../core/config";
|
import { type Config, Platform } from "../../core/type";
|
||||||
import { Target } from "./target";
|
import { Target } from "./target";
|
||||||
|
|
||||||
export type RunnerFactory = new (config: Config, debug: boolean) => Runner;
|
export type RunnerFactory = new (config: Config, debug?: boolean) => Runner;
|
||||||
|
|
||||||
export class Runner extends Target {
|
export class Runner extends Target {
|
||||||
static factory: Record<string, RunnerFactory> = {};
|
static factory: Record<string, RunnerFactory> = {};
|
||||||
|
|
||||||
public debug: boolean;
|
public debug: boolean;
|
||||||
|
|
||||||
constructor(config: Config, platform: string, debug: boolean) {
|
constructor(config: Config, platform: Platform, debug?: boolean) {
|
||||||
super(config, platform);
|
super(config, platform);
|
||||||
this.debug = debug;
|
this.debug = debug || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log(stream: any) {
|
log(stream: any) {
|
||||||
return stream.pipe(tail(DEBUG.log)).pipe(rename("out.log")).pipe(gulp.dest(this.targetPath));
|
return stream.pipe(tail(output)).pipe(rename("out.log")).pipe(gulp.dest(this.targetPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
static register(platform: string, runner: RunnerFactory) {
|
static register(platform: string, runner: RunnerFactory) {
|
||||||
Runner.factory[platform] = runner;
|
Runner.factory[platform] = runner;
|
||||||
}
|
}
|
||||||
|
|
||||||
static new(config: Config, platform: string, debug: boolean): Runner {
|
static new(config: Config, platform: string, debug?: boolean): Runner {
|
||||||
return new Runner.factory[platform](config, debug);
|
return new Runner.factory[platform](config, debug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import type { Config } from "../../core/config";
|
import { type Config, Platform } from "../../core/type";
|
||||||
|
|
||||||
export class Target {
|
export class Target {
|
||||||
public config: Config;
|
public config: Config;
|
||||||
public platform: string;
|
public platform: Platform;
|
||||||
public target: string;
|
public target: string;
|
||||||
|
|
||||||
constructor(config: Config, platform: string) {
|
constructor(config: Config, platform: Platform) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
this.target = "target";
|
this.target = "target";
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare(): Promise<any> {
|
setup(): Promise<any> {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ export class Target {
|
|||||||
throw "Not Implemented";
|
throw "Not Implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveTargetPath(platform = this.platform): string {
|
resolveTargetPath(platform: Platform | string = this.platform): string {
|
||||||
return path.resolve(this.target, this.config.name, platform);
|
return path.resolve(this.target, this.config.name, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import vfs from "vinyl-fs";
|
import vfs from "vinyl-fs";
|
||||||
import exec from "../../../common/exec";
|
import exec from "../../../common/exec";
|
||||||
import { streamToPromise } from "../../../common/util";
|
import { streamToPromise } from "../../../common/util";
|
||||||
import { Config } from "../../../core/config";
|
import { BuildSystem, type Config, Platform } from "../../../core/type";
|
||||||
import { BuildSystem, Platform } from "../../../core/type";
|
|
||||||
import { Android } from "../../../impl/android";
|
import { Android } from "../../../impl/android";
|
||||||
import { Haxe } from "../../../impl/haxe";
|
import { Haxe } from "../../../impl/haxe";
|
||||||
import { Builder } from "../../core/builder";
|
import { Builder } from "../../core/builder";
|
||||||
@@ -11,14 +10,14 @@ export class HaxeBuilder extends Builder {
|
|||||||
public haxe: Haxe;
|
public haxe: Haxe;
|
||||||
public android: Android;
|
public android: Android;
|
||||||
|
|
||||||
constructor(config: Config, platform: string, buildSystem: string, debug: boolean = false) {
|
constructor(config: Config, platform: Platform, buildSystem: BuildSystem, debug: boolean = false) {
|
||||||
super(config, platform, buildSystem, debug);
|
super(config, platform, buildSystem, debug);
|
||||||
this.haxe = new Haxe();
|
this.haxe = new Haxe(config.haxe ? config.haxe : undefined);
|
||||||
this.android = new Android();
|
this.android = new Android();
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
setup() {
|
||||||
let result = this.haxe.prepare().then(() => this.haxe.install(this.config.libs));
|
let result: Promise<any> = this.haxe.prepare().then(() => this.haxe.install(this.config.libs));
|
||||||
if (this.buildSystem === BuildSystem.OPENFL) {
|
if (this.buildSystem === BuildSystem.OPENFL) {
|
||||||
if (this.platform === Platform.ANDROID) {
|
if (this.platform === Platform.ANDROID) {
|
||||||
result = result
|
result = result
|
||||||
@@ -26,13 +25,10 @@ export class HaxeBuilder extends Builder {
|
|||||||
.then(() => this.android.activate())
|
.then(() => this.android.activate())
|
||||||
.then(() =>
|
.then(() =>
|
||||||
this.android.sdkmanager([
|
this.android.sdkmanager([
|
||||||
// ToDo: android sdk dependencies config?
|
// TODO: android sdk dependencies config?
|
||||||
//'tools',
|
|
||||||
"platform-tools",
|
"platform-tools",
|
||||||
"build-tools;27.0.3",
|
"build-tools;27.0.3",
|
||||||
"platforms;android-28", //ToDo: lime version 7.6.0 -> 28; 7.0.0 -> 26
|
"platforms;android-28",
|
||||||
//'ndk-bundle',
|
|
||||||
//'lldb;3.1',
|
|
||||||
"cmake;3.6.4111459",
|
"cmake;3.6.4111459",
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import template from "lodash.template";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import type { Config } from "../../../core/config";
|
import template from "../../../common/template";
|
||||||
import { Platform } from "../../../core/type";
|
import { type Config, Platform } from "../../../core/type";
|
||||||
import { Packer } from "../../core/packer";
|
import { Packer } from "../../core/packer";
|
||||||
|
|
||||||
export class FlashHTMLPacker extends Packer {
|
export class FlashHTMLPacker extends Packer {
|
||||||
@@ -14,12 +13,9 @@ export class FlashHTMLPacker extends Packer {
|
|||||||
|
|
||||||
call() {
|
call() {
|
||||||
const target = this.targetPath;
|
const target = this.targetPath;
|
||||||
const indexTemplate = template(
|
const index = template.render("flash/index.html", this.config);
|
||||||
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/flash/index.html")),
|
|
||||||
);
|
|
||||||
const index = indexTemplate(this.config);
|
|
||||||
fs.writeFileSync(path.resolve(target, "index.html"), index);
|
fs.writeFileSync(path.resolve(target, "index.html"), index);
|
||||||
fs.copyFileSync(path.resolve(import.meta.dirname, "..", "template/flash/swf.js"), path.resolve(target, "swf.js"));
|
fs.copyFileSync(path.resolve(import.meta.dirname, "template/flash/swf.js"), path.resolve(target, "swf.js"));
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import gzip from "gulp-gzip";
|
import gzip from "gulp-gzip";
|
||||||
import tar from "gulp-tar";
|
import tar from "gulp-tar";
|
||||||
import type { Config } from "../../../../core/config";
|
import { type Config, Platform } from "../../../../core/type";
|
||||||
import { Platform } from "../../../../core/type";
|
|
||||||
import { Packer } from "../../../core/packer";
|
import { Packer } from "../../../core/packer";
|
||||||
|
|
||||||
export class LinuxArchivePacker extends Packer {
|
export class LinuxArchivePacker extends Packer {
|
||||||
|
|||||||
@@ -2,13 +2,18 @@ import fs from "fs";
|
|||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import deb from "gulp-debian";
|
import deb from "gulp-debian";
|
||||||
import template from "lodash.template";
|
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { Config } from "../../../../core/config";
|
import template from "../../../../common/template";
|
||||||
import { Platform } from "../../../../core/type";
|
import { type Config, Platform } from "../../../../core/type";
|
||||||
import { Packer } from "../../../core/packer";
|
import { Packer } from "../../../core/packer";
|
||||||
|
|
||||||
|
const UPDATE_MENUS = `
|
||||||
|
if [ "$1" = "configure" ] && [ -x "\`which update-menus 2>/dev/null\`" ] ; then
|
||||||
|
update-menus
|
||||||
|
fi
|
||||||
|
`;
|
||||||
|
|
||||||
export class LinuxDEBPacker extends Packer {
|
export class LinuxDEBPacker extends Packer {
|
||||||
static NAME = "deb";
|
static NAME = "deb";
|
||||||
|
|
||||||
@@ -19,30 +24,24 @@ export class LinuxDEBPacker extends Packer {
|
|||||||
call() {
|
call() {
|
||||||
const target = this.targetPath;
|
const target = this.targetPath;
|
||||||
const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian");
|
const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian");
|
||||||
const iconfile = `${this.config.meta.filename}${path.extname(this.config.meta.icon!)}`;
|
const icon = this.config.icon;
|
||||||
const desktopTemplate = template(
|
const iconfile = `${this.config.meta.filename}${path.extname(icon)}`;
|
||||||
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/linux/app.desktop")),
|
const desktop = template.render("linux/app.desktop", { iconfile: iconfile, ...this.config });
|
||||||
);
|
|
||||||
const desktop = desktopTemplate(Object.assign({ iconfile: iconfile }, this.config));
|
|
||||||
fse.ensureDirSync(`${buildDir}/usr/share/applications`);
|
fse.ensureDirSync(`${buildDir}/usr/share/applications`);
|
||||||
fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop);
|
fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop);
|
||||||
fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`);
|
fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`);
|
||||||
fse.copySync(this.config.meta.icon!, `${buildDir}/usr/share/${this.config.meta.filename}/${iconfile}`);
|
fse.copySync(icon, `${buildDir}/usr/share/${this.config.meta.filename}/${iconfile}`);
|
||||||
return gulp.src(`${buildDir}/*`).pipe(
|
return gulp.src(`${buildDir}/*`).pipe(
|
||||||
deb({
|
deb({
|
||||||
package: this.config.meta.filename,
|
package: this.config.meta.filename!,
|
||||||
version: this.config.meta.version,
|
version: this.config.meta.version!,
|
||||||
section: "base",
|
section: "base",
|
||||||
priority: "optional",
|
priority: "optional",
|
||||||
architecture: "all",
|
architecture: "all",
|
||||||
maintainer: this.config.meta.author,
|
maintainer: this.config.meta.author,
|
||||||
description: this.config.meta.title,
|
description: this.config.meta.title,
|
||||||
changelog: [],
|
changelog: [],
|
||||||
postinst: [
|
postinst: [UPDATE_MENUS],
|
||||||
'if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ] ; then\n' +
|
|
||||||
" update-menus\n" +
|
|
||||||
"fi",
|
|
||||||
],
|
|
||||||
_target: "/",
|
_target: "/",
|
||||||
_out: this.resolveTargetPath("debian"),
|
_out: this.resolveTargetPath("debian"),
|
||||||
_clean: true,
|
_clean: true,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import zip from "gulp-zip";
|
import zip from "gulp-zip";
|
||||||
import { Config } from "../../../../core/config";
|
import { type Config, Platform } from "../../../../core/type";
|
||||||
import { Platform } from "../../../../core/type";
|
|
||||||
import { Packer } from "../../../core/packer";
|
import { Packer } from "../../../core/packer";
|
||||||
|
|
||||||
export class WindowsArchivePacker extends Packer {
|
export class WindowsArchivePacker extends Packer {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Config } from "../../../../core/config";
|
import { type Config, Platform } from "../../../../core/type";
|
||||||
import { Platform } from "../../../../core/type";
|
|
||||||
import { InnoSetup } from "../../../../impl/innosetup";
|
import { InnoSetup } from "../../../../impl/innosetup";
|
||||||
import { Packer } from "../../../core/packer";
|
import { Packer } from "../../../core/packer";
|
||||||
|
|
||||||
@@ -13,7 +12,7 @@ export class WindowsInstallerPacker extends Packer {
|
|||||||
this.innosetup = new InnoSetup();
|
this.innosetup = new InnoSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
setup() {
|
||||||
return this.innosetup.prepare();
|
return this.innosetup.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import type { Config } from "../../../core/config";
|
import { type Config, Platform } from "../../../core/type";
|
||||||
import { Platform } from "../../../core/type";
|
|
||||||
import { Android } from "../../../impl/android";
|
import { Android } from "../../../impl/android";
|
||||||
import { Runner } from "../../core/runner";
|
import { Runner } from "../../core/runner";
|
||||||
|
|
||||||
export class AndroidRunner extends Runner {
|
export class AndroidRunner extends Runner {
|
||||||
protected android: Android;
|
protected android: Android;
|
||||||
|
|
||||||
constructor(config: Config, debug: boolean) {
|
constructor(config: Config, debug?: boolean) {
|
||||||
super(config, Platform.ANDROID, debug);
|
super(config, Platform.ANDROID, debug);
|
||||||
this.android = new Android();
|
this.android = new Android();
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
setup() {
|
||||||
return this.android.prepare();
|
return this.android.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { Config } from "../../../core/config";
|
import { type Config, Platform } from "../../../core/type";
|
||||||
import { Platform } from "../../../core/type";
|
|
||||||
import { FlashPlayer } from "../../../impl/flashplayer";
|
import { FlashPlayer } from "../../../impl/flashplayer";
|
||||||
import { Runner } from "../../core/runner";
|
import { Runner } from "../../core/runner";
|
||||||
|
|
||||||
export class FlashRunner extends Runner {
|
export class FlashRunner extends Runner {
|
||||||
public player: FlashPlayer;
|
public player: FlashPlayer;
|
||||||
|
|
||||||
constructor(config: Config, debug: boolean, player: typeof FlashPlayer = FlashPlayer) {
|
constructor(config: Config, debug?: boolean, player: typeof FlashPlayer = FlashPlayer) {
|
||||||
super(config, Platform.FLASH, debug);
|
super(config, Platform.FLASH, debug);
|
||||||
this.player = new player(debug);
|
this.player = new player(debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
setup() {
|
||||||
return this.player.prepare();
|
return this.player.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
import gulp from "gulp";
|
import connect from "gulp-connect";
|
||||||
import webserver from "gulp-webserver";
|
import { type Config, Platform } from "../../../core/type";
|
||||||
import { Config } from "../../../core/config";
|
|
||||||
import { Platform } from "../../../core/type";
|
|
||||||
import { Runner } from "../../core/runner";
|
import { Runner } from "../../core/runner";
|
||||||
|
|
||||||
export class Html5Runner extends Runner {
|
export class Html5Runner extends Runner {
|
||||||
constructor(config: Config, debug: boolean) {
|
constructor(config: Config, debug?: boolean) {
|
||||||
super(config, Platform.HTML5, debug);
|
super(config, Platform.HTML5, debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
call() {
|
call() {
|
||||||
return gulp.src(this.targetPath).pipe(
|
return connect.server({
|
||||||
webserver({
|
root: this.targetPath,
|
||||||
// TODO: config?
|
|
||||||
host: "0.0.0.0",
|
host: "0.0.0.0",
|
||||||
port: 3000,
|
port: 3000,
|
||||||
open: true,
|
|
||||||
fallback: "index.html",
|
fallback: "index.html",
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { Config } from "../../../core/config";
|
import { type Config, Platform } from "../../../core/type";
|
||||||
import { Platform } from "../../../core/type";
|
|
||||||
import run from "../../../run";
|
import run from "../../../run";
|
||||||
import { Runner } from "../../core/runner";
|
import { Runner } from "../../core/runner";
|
||||||
|
|
||||||
export class LinuxRunner extends Runner {
|
export class LinuxRunner extends Runner {
|
||||||
constructor(config: Config, debug: boolean) {
|
constructor(config: Config, debug?: boolean) {
|
||||||
super(config, Platform.LINUX, debug);
|
super(config, Platform.LINUX, debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ export class LinuxRunner extends Runner {
|
|||||||
Runner.register(Platform.LINUX, LinuxRunner);
|
Runner.register(Platform.LINUX, LinuxRunner);
|
||||||
|
|
||||||
export class CPPRunner extends LinuxRunner {
|
export class CPPRunner extends LinuxRunner {
|
||||||
constructor(config: Config, debug: boolean) {
|
constructor(config: Config, debug?: boolean) {
|
||||||
super(config, debug);
|
super(config, debug);
|
||||||
this.platform = Platform.CPP;
|
this.platform = Platform.CPP;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { Config } from "../../../core/config";
|
import { type Config, Platform } from "../../../core/type";
|
||||||
import { Platform } from "../../../core/type";
|
|
||||||
import { Neko } from "../../../impl/neko";
|
import { Neko } from "../../../impl/neko";
|
||||||
import { Runner } from "../../core/runner";
|
import { Runner } from "../../core/runner";
|
||||||
|
|
||||||
export class NekoRunner extends Runner {
|
export class NekoRunner extends Runner {
|
||||||
public neko: Neko;
|
public neko: Neko;
|
||||||
|
|
||||||
constructor(config: Config, debug: boolean) {
|
constructor(config: Config, debug?: boolean) {
|
||||||
super(config, Platform.NEKO, debug);
|
super(config, Platform.NEKO, debug);
|
||||||
this.neko = new Neko();
|
this.neko = new Neko();
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
setup() {
|
||||||
return this.neko.prepare();
|
return this.neko.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import type { Config } from "../../../core/config";
|
import type { Config } from "../../../core/type";
|
||||||
import { RufflePlayer } from "../../../impl/ruffle";
|
import { RufflePlayer } from "../../../impl/ruffle";
|
||||||
import { FlashRunner } from "./flash";
|
import { FlashRunner } from "./flash";
|
||||||
|
|
||||||
export class RuffleRunner extends FlashRunner {
|
export class RuffleRunner extends FlashRunner {
|
||||||
constructor(config: Config, debug: boolean) {
|
constructor(config: Config, debug?: boolean) {
|
||||||
super(config, debug, RufflePlayer);
|
super(config, debug, RufflePlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { Config } from "../../../core/config";
|
import { type Config, Platform } from "../../../core/type";
|
||||||
import { Platform } from "../../../core/type";
|
|
||||||
import run from "../../../run";
|
import run from "../../../run";
|
||||||
import { Runner } from "../../core/runner";
|
import { Runner } from "../../core/runner";
|
||||||
|
|
||||||
export class WindowsRunner extends Runner {
|
export class WindowsRunner extends Runner {
|
||||||
constructor(config: Config, debug: boolean) {
|
constructor(config: Config, debug?: boolean) {
|
||||||
super(config, Platform.WINDOWS, debug);
|
super(config, Platform.WINDOWS, debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-87
@@ -1,88 +1,2 @@
|
|||||||
import gulp from "gulp";
|
|
||||||
import { Config } from "../core/config";
|
|
||||||
import { BuildSystem, Platform } from "../core/type";
|
|
||||||
import { Builder } from "./core/builder";
|
|
||||||
import { Packer } from "./core/packer";
|
|
||||||
import { Runner } from "./core/runner";
|
|
||||||
import { RuffleRunner } from "./impl/runner/ruffle";
|
|
||||||
export * from "./core";
|
export * from "./core";
|
||||||
|
export * from "./impl";
|
||||||
export type Task = any; // TODO: gulp task type
|
|
||||||
|
|
||||||
export class Project {
|
|
||||||
// TODO: compatibility
|
|
||||||
static Config = Config;
|
|
||||||
static BuildSystem = BuildSystem;
|
|
||||||
static Platform = Platform;
|
|
||||||
static Builder = Builder;
|
|
||||||
|
|
||||||
public buildSystem: string;
|
|
||||||
public platforms: string[];
|
|
||||||
public config: Config;
|
|
||||||
|
|
||||||
constructor(buildSystem: string, platforms: string[] | string, config: Config) {
|
|
||||||
this.buildSystem = buildSystem;
|
|
||||||
this.platforms = Array.isArray(platforms) ? platforms : [platforms];
|
|
||||||
this.config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
hasLib(name: string): boolean {
|
|
||||||
for (const lib of this.config.libs) {
|
|
||||||
if (lib.name === name) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
build(platform: string, debug: boolean = false): Task[] {
|
|
||||||
const builder = Builder.new(this.config, platform, this.buildSystem, debug);
|
|
||||||
const tasks: Task[] = [builder.prepare.bind(builder)];
|
|
||||||
tasks.push(builder.call.bind(builder));
|
|
||||||
return tasks;
|
|
||||||
}
|
|
||||||
|
|
||||||
run(platform: string, debug: boolean = false): Task[] {
|
|
||||||
const runner = Runner.new(this.config, platform, debug);
|
|
||||||
return [runner.prepare.bind(runner), runner.call.bind(runner)];
|
|
||||||
}
|
|
||||||
|
|
||||||
test(platform: string, debug: boolean = true): Task[] {
|
|
||||||
return this.build(platform, debug).concat(this.run(platform, debug));
|
|
||||||
}
|
|
||||||
|
|
||||||
pack(platform: string, name: string) {
|
|
||||||
const packer = Packer.new(this.config, platform, name);
|
|
||||||
return [packer.prepare.bind(packer), packer.call.bind(packer)];
|
|
||||||
}
|
|
||||||
|
|
||||||
compile(external_gulp?: any): Record<string, Task> {
|
|
||||||
const result: Record<string, Task> = {};
|
|
||||||
const _gulp = external_gulp || gulp;
|
|
||||||
for (const platform of this.platforms) {
|
|
||||||
result[`${this.config.name}:${platform}:build`] = _gulp.series(this.build(platform));
|
|
||||||
if (Runner.factory[platform]) {
|
|
||||||
result[`${this.config.name}:${platform}:run`] = _gulp.series(this.run(platform));
|
|
||||||
result[`${this.config.name}:${platform}:test`] = _gulp.series(this.test(platform));
|
|
||||||
}
|
|
||||||
if (Packer.factory[platform]) {
|
|
||||||
for (const name of Object.keys(Packer.factory[platform])) {
|
|
||||||
result[`${this.config.name}:${platform}:${name}`] = _gulp.series(this.pack(platform, name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
register(external_gulp?: any) {
|
|
||||||
const _gulp = external_gulp || gulp;
|
|
||||||
for (const [k, v] of Object.entries(this.compile(_gulp))) {
|
|
||||||
_gulp.task(k, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
static useRuffle() {
|
|
||||||
Runner.register(Platform.FLASH, RuffleRunner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,174 +0,0 @@
|
|||||||
import dateformat from "dateformat";
|
|
||||||
import gulp from "gulp";
|
|
||||||
import gulpClean from "gulp-clean";
|
|
||||||
import template from "lodash.template";
|
|
||||||
import os from "os";
|
|
||||||
import { Builder, Project } from ".";
|
|
||||||
import { System } from "../common/system";
|
|
||||||
import { Config, type ConfigParams } from "../core/config";
|
|
||||||
import { Sdk } from "../core/sdk";
|
|
||||||
import { Platform } from "../core/type";
|
|
||||||
import { Haxe } from "../impl/haxe";
|
|
||||||
|
|
||||||
export interface PresetConfig {
|
|
||||||
SdkDir?: string;
|
|
||||||
BuildDir?: string;
|
|
||||||
Develop?: boolean;
|
|
||||||
UseRuffle?: boolean;
|
|
||||||
Key?: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DEFAULT_CONFIG: PresetConfig = {
|
|
||||||
SdkDir: "$HOME/sdk",
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface ProjectPreset {
|
|
||||||
buildSystem?: string;
|
|
||||||
platforms?: string[];
|
|
||||||
config: ConfigParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Preset {
|
|
||||||
public options: Record<string, ProjectPreset>;
|
|
||||||
public config: PresetConfig;
|
|
||||||
public packageInfo: Record<string, any>;
|
|
||||||
|
|
||||||
constructor(options: Record<string, ProjectPreset>, config?: PresetConfig, packageInfo?: Record<string, any>) {
|
|
||||||
this.config = Object.assign(DEFAULT_CONFIG, config || {});
|
|
||||||
this.packageInfo = packageInfo || {};
|
|
||||||
for (const [k, v] of Object.entries(options)) {
|
|
||||||
options[k] = this.fillPreset(v);
|
|
||||||
}
|
|
||||||
this.options = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
private fillPreset(preset: ProjectPreset): ProjectPreset {
|
|
||||||
const configTemplate = template(JSON.stringify(preset));
|
|
||||||
return JSON.parse(
|
|
||||||
configTemplate({ config: this.config, package: this.packageInfo, env: process.env, dateformat: dateformat }),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
compile(): Project[] {
|
|
||||||
const config = new Config(this.options["default"]?.config);
|
|
||||||
if (this.packageInfo.haxeDependencies) {
|
|
||||||
config.update({ libs: this.packageInfo.haxeDependencies });
|
|
||||||
}
|
|
||||||
const projects: Project[] = [];
|
|
||||||
for (const [k, v] of Object.entries(this.options)) {
|
|
||||||
if (k == "default") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const projectConfig = config.branch(Object.assign(v.config, { name: k }));
|
|
||||||
projects.push(new Project(v.buildSystem!, v.platforms!, projectConfig));
|
|
||||||
}
|
|
||||||
return projects;
|
|
||||||
}
|
|
||||||
|
|
||||||
register(external_gulp?: any, additional_tasks?: string[]) {
|
|
||||||
const _gulp = external_gulp || gulp;
|
|
||||||
|
|
||||||
const resolvePath = (path: string) => path.replace("$HOME", os.homedir());
|
|
||||||
|
|
||||||
if (this.config.UseRuffle) {
|
|
||||||
Project.useRuffle();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.packageInfo.haxe) {
|
|
||||||
Haxe.VERSION = this.packageInfo.haxe;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.config.SdkDir) {
|
|
||||||
Sdk.dir = resolvePath(this.config.SdkDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.config.BuildDir) {
|
|
||||||
Haxe.buildDir = resolvePath(this.config.BuildDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
_gulp.task("clean", () => {
|
|
||||||
return _gulp.src("target/*", { read: false }).pipe(gulpClean());
|
|
||||||
});
|
|
||||||
|
|
||||||
const projects = this.compile();
|
|
||||||
const project = projects[0];
|
|
||||||
|
|
||||||
_gulp.task("setup", () => {
|
|
||||||
return Promise.all(
|
|
||||||
project.platforms.map((platform) => Builder.new(project.config, platform, project.buildSystem).prepare()),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
const protohx = project.hasLib("protohx");
|
|
||||||
if (protohx) {
|
|
||||||
_gulp.task("protohx:generate", () =>
|
|
||||||
new Haxe().haxelib(["run", "protohx", "generate", "protohx.json"]).then((result: any) => {
|
|
||||||
if (result.stdout.indexOf("FAIL") > -1) {
|
|
||||||
throw result.stdout;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const project of projects) {
|
|
||||||
project.register(_gulp);
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultSeries = [_gulp.task("clean"), _gulp.task("setup")];
|
|
||||||
|
|
||||||
if (protohx) {
|
|
||||||
defaultSeries.push("protohx:generate");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additional_tasks) {
|
|
||||||
for (const task of additional_tasks) {
|
|
||||||
defaultSeries.push(_gulp.task(task));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const project of projects) {
|
|
||||||
for (const platform of project.platforms) {
|
|
||||||
switch (platform) {
|
|
||||||
case Platform.FLASH:
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:build`));
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:html`));
|
|
||||||
break;
|
|
||||||
case Platform.HTML5:
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:build`));
|
|
||||||
break;
|
|
||||||
case Platform.LINUX:
|
|
||||||
if (System.isLinux) {
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:build`));
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:archive`));
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:deb`));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Platform.CPP:
|
|
||||||
if (System.isLinux) {
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:build`));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Platform.NEKO:
|
|
||||||
if (System.isLinux) {
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:build`));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Platform.ANDROID:
|
|
||||||
if (System.isLinux) {
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:build`));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Platform.WINDOWS:
|
|
||||||
if (System.isWindows) {
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:build`));
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:archive`));
|
|
||||||
defaultSeries.push(_gulp.task(`${project.config.name}:${platform}:installer`));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _gulp.series(defaultSeries);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+55
-78
@@ -1,83 +1,62 @@
|
|||||||
var cp = require('child_process');
|
import colors from "ansi-colors";
|
||||||
var path = require('path');
|
import cp from "child_process";
|
||||||
var stream = require('stream');
|
import path from "path";
|
||||||
var util = require('util');
|
import stream from "stream";
|
||||||
var defaults = require('lodash.defaults');
|
import util from "util";
|
||||||
var applyTemplate = require('lodash.template');
|
import Vinyl from "vinyl";
|
||||||
var Vinyl = require('vinyl');
|
import template from "../common/template";
|
||||||
var colors = require('ansi-colors');
|
|
||||||
|
|
||||||
/**
|
export class Command {
|
||||||
* Creates a new `gulp-run` command.
|
private command: string;
|
||||||
*
|
private isWindows: boolean;
|
||||||
* @param {string} command
|
private options: any;
|
||||||
* @param {object} options
|
|
||||||
*/
|
|
||||||
export function Command(command, options?) {
|
|
||||||
var previousPath;
|
|
||||||
|
|
||||||
|
constructor(command: string, options?: any) {
|
||||||
this.command = command;
|
this.command = command;
|
||||||
|
this.isWindows = process.platform.lastIndexOf("win") === 0;
|
||||||
// We're on Windows if `process.platform` starts with "win", i.e. "win32".
|
this.options = {
|
||||||
this.isWindows = (process.platform.lastIndexOf('win') === 0);
|
|
||||||
|
|
||||||
// the cwd and environment of the command are the same as the main node
|
|
||||||
// process by default.
|
|
||||||
this.options = defaults(options || {}, {
|
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
env: process.env,
|
env: process.env,
|
||||||
verbosity: (options && options.silent) ? 1 : 2,
|
verbosity: options?.silent ? 1 : 2,
|
||||||
usePowerShell: false
|
usePowerShell: false,
|
||||||
});
|
...(options || {}),
|
||||||
|
};
|
||||||
|
|
||||||
// include node_modules/.bin on the path when we execute the command.
|
let previousPath;
|
||||||
previousPath = this.options.env.PATH;
|
previousPath = this.options.env.PATH;
|
||||||
this.options.env.PATH = path.join(this.options.cwd, 'node_modules', '.bin');
|
this.options.env.PATH = path.join(this.options.cwd, "node_modules", ".bin");
|
||||||
this.options.env.PATH += path.delimiter;
|
this.options.env.PATH += path.delimiter;
|
||||||
this.options.env.PATH += previousPath;
|
this.options.env.PATH += previousPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
exec(stdin?: any, callback?: any): Vinyl<stream.Stream> {
|
||||||
* Execute the command, invoking the callback when the command exits.
|
let fileName;
|
||||||
* Returns a Vinyl file wrapping the command's stdout.
|
let directory;
|
||||||
*
|
let subShell;
|
||||||
* @param {string} stdin
|
|
||||||
* @param {function} callback
|
|
||||||
* @return {Stream}
|
|
||||||
*/
|
|
||||||
Command.prototype.exec = function exec(stdin, callback) {
|
|
||||||
var self = this;
|
|
||||||
var command;
|
|
||||||
var fileName;
|
|
||||||
var directory;
|
|
||||||
var subShell;
|
|
||||||
var log;
|
|
||||||
var err;
|
|
||||||
var stdout;
|
|
||||||
|
|
||||||
// parse the arguments, both are optional.
|
// parse the arguments, both are optional.
|
||||||
// after parsing, stdin is a vinyl file to use as standard input to
|
// after parsing, stdin is a vinyl file to use as standard input to
|
||||||
// the command (possibly empty), and callback is a function.
|
// the command (possibly empty), and callback is a function.
|
||||||
if (typeof stdin === 'function') {
|
if (typeof stdin === "function") {
|
||||||
callback = stdin;
|
callback = stdin;
|
||||||
stdin = undefined;
|
stdin = undefined;
|
||||||
} else if (typeof callback !== 'function') {
|
} else if (typeof callback !== "function") {
|
||||||
callback = function noop() {};
|
callback = function noop() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(stdin instanceof Vinyl)) {
|
if (!(stdin instanceof Vinyl)) {
|
||||||
fileName = this.command.split(' ')[0];
|
fileName = this.command.split(" ")[0];
|
||||||
directory = path.join(this.options.cwd, fileName);
|
directory = path.join(this.options.cwd, fileName);
|
||||||
|
|
||||||
if (typeof stdin === 'string') {
|
if (typeof stdin === "string") {
|
||||||
stdin = new Vinyl({
|
stdin = new Vinyl({
|
||||||
path: directory,
|
path: directory,
|
||||||
contents: new Buffer(stdin)
|
contents: new Buffer(stdin),
|
||||||
});
|
});
|
||||||
} else if (stdin instanceof Buffer || stdin instanceof stream.Readable) {
|
} else if (stdin instanceof Buffer || stdin instanceof stream.Readable) {
|
||||||
stdin = new Vinyl({
|
stdin = new Vinyl({
|
||||||
path: directory,
|
path: directory,
|
||||||
contents: stdin
|
contents: stdin,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
stdin = new Vinyl(stdin);
|
stdin = new Vinyl(stdin);
|
||||||
@@ -91,27 +70,27 @@ Command.prototype.exec = function exec(stdin, callback) {
|
|||||||
// execute the command.
|
// execute the command.
|
||||||
// we spawn the command in a subshell, so things like i/o redirection
|
// we spawn the command in a subshell, so things like i/o redirection
|
||||||
// just work. e.g. `echo hello world >> ./hello.txt` works as expected.
|
// just work. e.g. `echo hello world >> ./hello.txt` works as expected.
|
||||||
command = applyTemplate(this.command)({
|
const command = template.renderString(this.command, {
|
||||||
file: stdin
|
file: stdin,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.isWindows && this.options.usePowerShell) {
|
if (this.isWindows && this.options.usePowerShell) {
|
||||||
// windows powershell
|
// windows powershell
|
||||||
subShell = cp.spawn('powershell.exe', ['-NonInteractive', '-NoLogo', '-Command', command], {
|
subShell = cp.spawn("powershell.exe", ["-NonInteractive", "-NoLogo", "-Command", command], {
|
||||||
env: this.options.env,
|
env: this.options.env,
|
||||||
cwd: this.options.cwd
|
cwd: this.options.cwd,
|
||||||
});
|
});
|
||||||
} else if (this.isWindows) {
|
} else if (this.isWindows) {
|
||||||
// windows cmd.exe
|
// windows cmd.exe
|
||||||
subShell = cp.spawn('cmd.exe', ['/c', command], {
|
subShell = cp.spawn("cmd.exe", ["/c", command], {
|
||||||
env: this.options.env,
|
env: this.options.env,
|
||||||
cwd: this.options.cwd
|
cwd: this.options.cwd,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// POSIX shell
|
// POSIX shell
|
||||||
subShell = cp.spawn('sh', ['-c', command], {
|
subShell = cp.spawn("sh", ["-c", command], {
|
||||||
env: this.options.env,
|
env: this.options.env,
|
||||||
cwd: this.options.cwd
|
cwd: this.options.cwd,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,17 +102,17 @@ Command.prototype.exec = function exec(stdin, callback) {
|
|||||||
// prevents overlaping output of multiple commands)
|
// prevents overlaping output of multiple commands)
|
||||||
// - if verbosity equals to 1, the command's stderr is buffered as in 2, but
|
// - if verbosity equals to 1, the command's stderr is buffered as in 2, but
|
||||||
// the stdout is silenced.
|
// the stdout is silenced.
|
||||||
log = new stream.PassThrough();
|
const log = new stream.PassThrough();
|
||||||
|
|
||||||
function sendLog(context) {
|
const sendLog = (context: any) => {
|
||||||
var title = util.format(
|
var title = util.format(
|
||||||
'$ %s%s',
|
"$ %s%s",
|
||||||
colors.blue(command),
|
colors.blue(command),
|
||||||
(self.options.verbosity < 2) ? colors.grey(' # Silenced\n') : '\n'
|
this.options.verbosity < 2 ? colors.grey(" # Silenced\n") : "\n",
|
||||||
);
|
);
|
||||||
|
|
||||||
context.write(title);
|
context.write(title);
|
||||||
}
|
};
|
||||||
|
|
||||||
switch (this.options.verbosity) {
|
switch (this.options.verbosity) {
|
||||||
case 3:
|
case 3:
|
||||||
@@ -151,19 +130,21 @@ Command.prototype.exec = function exec(stdin, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setup the cleanup proceedure for when the command finishes.
|
// setup the cleanup proceedure for when the command finishes.
|
||||||
subShell.once('close', function handleSubShellClose() {
|
subShell.once("close", function handleSubShellClose() {
|
||||||
// write the buffered output to stdout
|
// write the buffered output to stdout
|
||||||
var content = log.read();
|
const content = log.read();
|
||||||
|
|
||||||
if (content !== null) {
|
if (content !== null) {
|
||||||
process.stdout.write(content);
|
process.stdout.write(content);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
subShell.once('exit', function handleSubShellExit(code) {
|
subShell.once("exit", function handleSubShellExit(code) {
|
||||||
// report an error if the command exited with a non-zero exit code.
|
// report an error if the command exited with a non-zero exit code.
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
err = new Error(util.format('Command `%s` exited with code %s', command, code));
|
const err: Error & { status?: number | null } = new Error(
|
||||||
|
util.format("Command `%s` exited with code %s", command, code),
|
||||||
|
);
|
||||||
err.status = code;
|
err.status = code;
|
||||||
|
|
||||||
return callback(err);
|
return callback(err);
|
||||||
@@ -174,20 +155,16 @@ Command.prototype.exec = function exec(stdin, callback) {
|
|||||||
|
|
||||||
// the file wrapping stdout is as the one wrapping stdin (same metadata)
|
// the file wrapping stdout is as the one wrapping stdin (same metadata)
|
||||||
// with different contents.
|
// with different contents.
|
||||||
stdout = stdin.clone();
|
const stdout = stdin.clone({ path: "stdout" });
|
||||||
stdout.contents = subShell.stdout.pipe(new stream.PassThrough());
|
stdout.contents = subShell.stdout.pipe(new stream.PassThrough());
|
||||||
|
|
||||||
// finally, write the input to the process's stdin.
|
// finally, write the input to the process's stdin.
|
||||||
//stdin.pipe(subShell.stdin); //ToDo:
|
//stdin.pipe(subShell.stdin); //TODO:
|
||||||
|
|
||||||
return stdout;
|
return stdout;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
toString() {
|
||||||
* Returns the command template.
|
|
||||||
*
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
Command.prototype.toString = function toString() {
|
|
||||||
return this.command;
|
return this.command;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|||||||
+13
-60
@@ -1,71 +1,24 @@
|
|||||||
/**
|
import { Transform, type TransformCallback } from "stream";
|
||||||
* Pipe shell commands in gulp.
|
|
||||||
* @module gulp-run
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Command } from "./command";
|
import { Command } from "./command";
|
||||||
|
|
||||||
var inherit = require("util").inherits;
|
export class RunTransform extends Transform {
|
||||||
var Transform = require("stream").Transform;
|
private command: Command;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a GulpRunner.
|
|
||||||
*
|
|
||||||
* A GulpRunner is a Vinyl transform stream that spawns a child process to
|
|
||||||
* transform the file. A separate process is spawned to handle each file
|
|
||||||
* passing through the stream.
|
|
||||||
*
|
|
||||||
* @param {string} template
|
|
||||||
* @param {object} options
|
|
||||||
*/
|
|
||||||
function GulpRunner(template, options) {
|
|
||||||
if (!(this instanceof GulpRunner)) {
|
|
||||||
return new GulpRunner(template, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
constructor(template: string, options?: any) {
|
||||||
|
super({ objectMode: true });
|
||||||
this.command = new Command(template, options || {});
|
this.command = new Command(template, options || {});
|
||||||
Transform.call(this, { objectMode: true });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
_transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void {
|
||||||
* @extends {Stream.Transform}
|
const stdout = this.command.exec(chunk, callback);
|
||||||
*/
|
this.push(stdout);
|
||||||
inherit(GulpRunner, Transform);
|
}
|
||||||
|
|
||||||
/**
|
exec(stdin?: any, callback?: any) {
|
||||||
* @param {string} file
|
|
||||||
* @param {string} encoding
|
|
||||||
* @param {function} callback
|
|
||||||
* @return {void}
|
|
||||||
*/
|
|
||||||
GulpRunner.prototype._transform = function _transform(file, encoding, callback) {
|
|
||||||
var newfile = this.command.exec(file, callback);
|
|
||||||
this.push(newfile);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes `stdin` to itself and returns itself.
|
|
||||||
*
|
|
||||||
* Whenever an object is written into the GulpRunner, a new process is
|
|
||||||
* spawned taking that data as standard input, and a Vinyl file wrapping the
|
|
||||||
* process's standard output is pushed downstream.
|
|
||||||
*
|
|
||||||
* `stdin` may be a String, Buffer, Readable stream, or Vinyl file.
|
|
||||||
*
|
|
||||||
* @param {mixed} stdin
|
|
||||||
* @param {function} callback
|
|
||||||
* @return {GulpRunner}
|
|
||||||
*/
|
|
||||||
GulpRunner.prototype.exec = function exec(stdin, callback) {
|
|
||||||
this.write(stdin, callback);
|
this.write(stdin, callback);
|
||||||
this.end();
|
this.end();
|
||||||
return this;
|
return this;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
export default (template: string, options?: any) => new RunTransform(template, options);
|
||||||
* @static
|
|
||||||
* @type {Command}
|
|
||||||
*/
|
|
||||||
GulpRunner.Command = Command;
|
|
||||||
|
|
||||||
export default GulpRunner;
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { branch, compile } from "../core/config";
|
||||||
|
import type { Config } from "../core/type";
|
||||||
|
import type { TaskCompilerType, TaskDef } from "./core";
|
||||||
|
import { CleanTaskCompiler } from "./impl/clean";
|
||||||
|
import { FormatTaskCompiler } from "./impl/format";
|
||||||
|
import { ProjectTaskCompiler } from "./impl/project";
|
||||||
|
import { ProtoTaskCompiler } from "./impl/proto";
|
||||||
|
import { SetupTaskCompiler } from "./impl/setup";
|
||||||
|
|
||||||
|
const COMPILERS: TaskCompilerType[] = [FormatTaskCompiler, CleanTaskCompiler, SetupTaskCompiler, ProtoTaskCompiler];
|
||||||
|
const PROJECT_COMPILERS: TaskCompilerType[] = [ProjectTaskCompiler];
|
||||||
|
|
||||||
|
export default function* (projects: Config[]): Iterable<TaskDef> {
|
||||||
|
const config = projects.reduce((config, project) => branch(config, project), compile({}));
|
||||||
|
for (const compiler of COMPILERS) {
|
||||||
|
yield* new compiler(config).compile();
|
||||||
|
}
|
||||||
|
for (const compiler of PROJECT_COMPILERS) {
|
||||||
|
for (const project of projects) {
|
||||||
|
yield* new compiler(project).compile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import type { TaskFunction } from "gulp";
|
||||||
|
import type { Config } from "../core/type";
|
||||||
|
|
||||||
|
export interface TaskCompiler {
|
||||||
|
config: Config;
|
||||||
|
debug?: boolean;
|
||||||
|
|
||||||
|
compile(): Iterable<TaskDef>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TaskDef = readonly [string, TaskFunction] | readonly [string, TaskFunction, boolean];
|
||||||
|
|
||||||
|
export abstract class TaskCompilerImpl implements TaskCompiler {
|
||||||
|
constructor(
|
||||||
|
public config: Config,
|
||||||
|
public debug?: boolean,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
abstract compile(): Iterable<TaskDef>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TaskCompilerType = new (config: Config, debug?: boolean) => TaskCompiler;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import gulp from "gulp";
|
||||||
|
import gulpClean from "gulp-clean";
|
||||||
|
import { TaskCompilerImpl, type TaskDef } from "../core";
|
||||||
|
|
||||||
|
export class CleanTaskCompiler extends TaskCompilerImpl {
|
||||||
|
*compile(): Iterable<TaskDef> {
|
||||||
|
yield ["clean", () => gulp.src("target/*", { read: false }).pipe(gulpClean()), true];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { Haxe } from "../../impl/haxe";
|
||||||
|
import { TaskCompilerImpl, type TaskDef } from "../core";
|
||||||
|
|
||||||
|
export class FormatTaskCompiler extends TaskCompilerImpl {
|
||||||
|
*compile(): Iterable<TaskDef> {
|
||||||
|
const hxformatFile = path.join(".", "hxformat.json");
|
||||||
|
if (fs.existsSync(hxformatFile)) {
|
||||||
|
yield [
|
||||||
|
"check",
|
||||||
|
async () => {
|
||||||
|
const haxe = new Haxe(this.config.haxe);
|
||||||
|
await haxe.install({ formatter: "" });
|
||||||
|
await haxe.haxelib(
|
||||||
|
["run", "formatter", "--check"].concat(
|
||||||
|
this.config.sources.reduce<string[]>((sources, source) => sources.concat(["-s", source]), []),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
yield [
|
||||||
|
"format",
|
||||||
|
async () => {
|
||||||
|
const haxe = new Haxe(this.config.haxe);
|
||||||
|
await haxe.install({ formatter: "" });
|
||||||
|
await haxe.haxelib(
|
||||||
|
["run", "formatter"].concat(
|
||||||
|
this.config.sources.reduce<string[]>((sources, source) => sources.concat(["-s", source]), []),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import gulp from "gulp";
|
||||||
|
import os from "os";
|
||||||
|
import { Platform } from "../../core/type";
|
||||||
|
import { Builder, Packer, Runner } from "../../project";
|
||||||
|
import { TaskCompilerImpl, type TaskDef } from "../core";
|
||||||
|
|
||||||
|
const isPlatformSupported = (platform: Platform): boolean => {
|
||||||
|
switch (platform) {
|
||||||
|
case Platform.LINUX:
|
||||||
|
return os.type() === "Linux";
|
||||||
|
case Platform.WINDOWS:
|
||||||
|
return os.type() === "Windows_NT";
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export class ProjectTaskCompiler extends TaskCompilerImpl {
|
||||||
|
*compile(): Iterable<TaskDef> {
|
||||||
|
for (const platform of this.config.platforms.filter(isPlatformSupported)) {
|
||||||
|
const builder = Builder.new(this.config, platform, this.config.buildSystem, this.debug);
|
||||||
|
const setupKey = `${this.config.name}:${platform}:setup`;
|
||||||
|
const buildKey = `${this.config.name}:${platform}:build`;
|
||||||
|
yield [setupKey, builder.setup.bind(builder)];
|
||||||
|
yield [buildKey, gulp.series(builder.setup.bind(builder), builder.call.bind(builder)), true];
|
||||||
|
|
||||||
|
if (Runner.factory[platform]) {
|
||||||
|
const testKey = `${this.config.name}:${platform}:test`;
|
||||||
|
const runner = Runner.new(this.config, platform, this.debug);
|
||||||
|
yield [testKey, gulp.series(builder.setup.bind(builder), runner.setup.bind(runner), runner.call.bind(runner))];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Packer.factory[platform]) {
|
||||||
|
for (const name of Object.keys(Packer.factory[platform])) {
|
||||||
|
const packKey = `${this.config.name}:${platform}:${name}`;
|
||||||
|
const packer = Packer.new(this.config, platform, name);
|
||||||
|
yield [packKey, gulp.series(packer.setup.bind(packer), packer.call.bind(packer)), true];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { Haxe } from "../../impl/haxe";
|
||||||
|
import { TaskCompilerImpl, type TaskDef } from "../core";
|
||||||
|
|
||||||
|
export class ProtoTaskCompiler extends TaskCompilerImpl {
|
||||||
|
*compile(): Iterable<TaskDef> {
|
||||||
|
const protohxFile = path.join(".", "protohx.json");
|
||||||
|
if (fs.existsSync(protohxFile)) {
|
||||||
|
yield [
|
||||||
|
"protohx:generate",
|
||||||
|
async () => {
|
||||||
|
const haxe = new Haxe(this.config.haxe);
|
||||||
|
const result = await haxe.haxelib(["run", "protohx", "generate", "protohx.json"]);
|
||||||
|
if (result.stdout.indexOf("FAIL") > -1) {
|
||||||
|
throw result.stdout;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Builder } from "../../project";
|
||||||
|
import { TaskCompilerImpl, type TaskDef } from "../core";
|
||||||
|
|
||||||
|
export class SetupTaskCompiler extends TaskCompilerImpl {
|
||||||
|
*compile(): Iterable<TaskDef> {
|
||||||
|
yield [
|
||||||
|
"setup",
|
||||||
|
() =>
|
||||||
|
Promise.all(
|
||||||
|
this.config.platforms.map((platform) => Builder.new(this.config, platform, this.config.buildSystem).setup()),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import compiler from "./compiler";
|
||||||
|
import register from "./register";
|
||||||
|
export * from "./core";
|
||||||
|
export * from "./impl/format";
|
||||||
|
export * from "./impl/project";
|
||||||
|
|
||||||
|
export const Task = {
|
||||||
|
compiler,
|
||||||
|
register,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Task;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import gulp from "gulp";
|
||||||
|
import type { TaskDef } from "./core";
|
||||||
|
|
||||||
|
export default (tasks: Iterable<TaskDef>) => {
|
||||||
|
const defaultTasks = [];
|
||||||
|
for (const item of tasks) {
|
||||||
|
gulp.task(item[0], item[1]);
|
||||||
|
if (item[2]) {
|
||||||
|
defaultTasks.push(item[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (defaultTasks.length > 0) {
|
||||||
|
gulp.task("default", gulp.series(defaultTasks));
|
||||||
|
}
|
||||||
|
};
|
||||||
+10
-4
@@ -1,11 +1,17 @@
|
|||||||
<% sources.forEach(function(item) { %>
|
<% sources.forEach(function(item) { %>
|
||||||
-cp "<%=item%>"<% }); %>
|
-cp "<%=item%>"
|
||||||
|
<% }); %>
|
||||||
<% libs.forEach(function(item) { %>
|
<% libs.forEach(function(item) { %>
|
||||||
-lib <%=item.name%>:<%=item.version.split('@').shift()%><% }); %>
|
-lib <%=item.name%>:<%=item.version.split('@').shift()%>
|
||||||
|
|
||||||
|
<% }); %>
|
||||||
<% macros.forEach(function(item) { %>
|
<% macros.forEach(function(item) { %>
|
||||||
--macro "<%=item%>"<% }); %>
|
--macro "<%=item%>"
|
||||||
|
<% }); %>
|
||||||
<% flags.forEach(function(item) { %>
|
<% flags.forEach(function(item) { %>
|
||||||
-D <%=item%><% }); %>
|
-D <%=item%>
|
||||||
|
<% }); %>
|
||||||
|
|
||||||
-main <%=main%>
|
-main <%=main%>
|
||||||
|
|
||||||
-<%=out%> "<%=buildDir%>/<%=platform%>/bin/<%=meta.filename%><%=ext%>"
|
-<%=out%> "<%=buildDir%>/<%=platform%>/bin/<%=meta.filename%><%=ext%>"
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { existsSync, mkdtempSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import test from "node:test";
|
||||||
|
import { download } from "../dist/lib/index.mjs";
|
||||||
|
|
||||||
|
const testUrl = async (url, file) => {
|
||||||
|
const target = mkdtempSync(join(tmpdir(), "test-"));
|
||||||
|
await download(url, target);
|
||||||
|
assert(existsSync(join(target, file)));
|
||||||
|
};
|
||||||
|
|
||||||
|
test("zip", async () => await testUrl("https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-win.zip", "haxe.exe"));
|
||||||
|
|
||||||
|
test("tar.gz", async () => await testUrl("https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-linux64.tar.gz", "haxe"));
|
||||||
|
|
||||||
|
test("plain", async () => await testUrl("https://home.shmyga.ru/public/test.txt", "test.txt"));
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import test from "node:test";
|
||||||
|
import { Android, AndroidNdk, FlashPlayer, Haxe, Neko, resolveLink, RufflePlayer } from "../dist/lib/index.mjs";
|
||||||
|
|
||||||
|
const testLink = (link, args) => {
|
||||||
|
for (const [params, targetUrl] of args) {
|
||||||
|
const url = resolveLink(link, params);
|
||||||
|
assert.equal(url, targetUrl);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
test("neko", () =>
|
||||||
|
testLink(new Neko().link, [
|
||||||
|
[{ os_name: "linux" }, "https://github.com/HaxeFoundation/neko/releases/download/v2-4-1/neko-2.4.1-linux64.tar.gz"],
|
||||||
|
[{ os_name: "win" }, "https://github.com/HaxeFoundation/neko/releases/download/v2-4-1/neko-2.4.1-win64.zip"],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("haxe", () =>
|
||||||
|
testLink(new Haxe().link, [
|
||||||
|
[{ os_name: "linux" }, "https://github.com/HaxeFoundation/haxe/releases/download/4.2.5/haxe-4.2.5-linux64.tar.gz"],
|
||||||
|
[{ os_name: "win" }, "https://github.com/HaxeFoundation/haxe/releases/download/4.2.5/haxe-4.2.5-win64.zip"],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("flashplayer", () =>
|
||||||
|
testLink(new FlashPlayer().link, [
|
||||||
|
[
|
||||||
|
{ os_name: "linux" },
|
||||||
|
"https://fpdownload.macromedia.com/pub/flashplayer/updaters/32/flash_player_sa_linux.x86_64.tar.gz",
|
||||||
|
],
|
||||||
|
[{ os_name: "win" }, "https://fpdownload.macromedia.com/pub/flashplayer/updaters/32/flashplayer_32_sa.exe"],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("ruffle", () =>
|
||||||
|
testLink(new RufflePlayer().link, [
|
||||||
|
[
|
||||||
|
{ os_name: "linux" },
|
||||||
|
"https://github.com/ruffle-rs/ruffle/releases/download/v0.7.1/ruffle-0.7.1-linux-x86_64.tar.gz",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ os_name: "win" },
|
||||||
|
"https://github.com/ruffle-rs/ruffle/releases/download/v0.7.1/ruffle-0.7.1-windows-x86_64.zip",
|
||||||
|
],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("android", () =>
|
||||||
|
testLink(new Android().link, [
|
||||||
|
[{ os_name: "linux" }, "https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip"],
|
||||||
|
[{ os_name: "win" }, "https://dl.google.com/android/repository/commandlinetools-win-7302050_latest.zip"],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("android-ndk", () =>
|
||||||
|
testLink(new AndroidNdk().link, [
|
||||||
|
[{ os_name: "linux" }, "https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip"],
|
||||||
|
[{ os_name: "win" }, "https://dl.google.com/android/repository/android-ndk-r21e-windows-x86_64.zip"],
|
||||||
|
]));
|
||||||
+2
-1
@@ -14,7 +14,8 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"verbatimModuleSyntax": true,
|
"verbatimModuleSyntax": true,
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true,
|
||||||
|
"noImplicitThis": false,
|
||||||
},
|
},
|
||||||
"include": ["src"]
|
"include": ["src"]
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -1,9 +1,18 @@
|
|||||||
import { defineConfig } from "tsdown";
|
import { defineConfig } from "tsdown";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
entry: {
|
||||||
|
"bin/cli": "src/cli.ts",
|
||||||
|
"lib/index": "src/index.ts",
|
||||||
|
},
|
||||||
|
copy: ["assets", "template"],
|
||||||
dts: {
|
dts: {
|
||||||
tsgo: true,
|
tsgo: true,
|
||||||
},
|
},
|
||||||
exports: true,
|
exports: {
|
||||||
|
bin: {
|
||||||
|
hxt: "src/cli.ts",
|
||||||
|
},
|
||||||
|
},
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user