@steambrew/ttc 2.4.3 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +209 -56823
- package/package.json +53 -53
- package/rollup.config.js +8 -22
- package/src/check-health.ts +41 -0
- package/{index.ts → src/index.ts} +4 -4
- package/{PluginSetup.ts → src/plugin-api.ts} +22 -3
- package/src/query-parser.ts +82 -0
- package/{Compiler.ts → src/transpiler.ts} +3 -3
- package/{VersionMon.ts → src/version-control.ts} +1 -1
- package/tsconfig.json +21 -22
- package/Linter.ts +0 -44
- package/Parameters.ts +0 -72
- /package/{Logger.ts → src/logger.ts} +0 -0
- /package/{StaticEmbed.ts → src/static-embed.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@steambrew/ttc",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"bin": {
|
|
8
|
-
"millennium-ttc": "dist/index.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "rollup -c",
|
|
12
|
-
"prepare": "npm run build"
|
|
13
|
-
},
|
|
14
|
-
"publishConfig": {
|
|
15
|
-
"access": "public"
|
|
16
|
-
},
|
|
17
|
-
"keywords": [],
|
|
18
|
-
"author": "",
|
|
19
|
-
"license": "
|
|
20
|
-
"description": "A tiny typescript compiler for Millennium plugins.",
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@babel/parser": "^7.27.
|
|
23
|
-
"@babel/preset-env": "^7.
|
|
24
|
-
"@babel/preset-react": "^7.
|
|
25
|
-
"@babel/preset-typescript": "^7.27.
|
|
26
|
-
"@babel/traverse": "^7.27.
|
|
27
|
-
"@rollup/plugin-babel": "^6.0.4",
|
|
28
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
29
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
30
|
-
"@rollup/plugin-node-resolve": "^15.3.
|
|
31
|
-
"@rollup/plugin-replace": "^6.0.
|
|
32
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
33
|
-
"@rollup/plugin-typescript": "^12.1.
|
|
34
|
-
"@rollup/plugin-url": "^8.0.2",
|
|
35
|
-
"@rollup/pluginutils": "^5.1.4",
|
|
36
|
-
"chalk": "^5.
|
|
37
|
-
"dotenv": "^16.
|
|
38
|
-
"fs": "
|
|
39
|
-
"glob": "^11.0.2",
|
|
40
|
-
"magic-string": "^0.30.17",
|
|
41
|
-
"rollup": "^4.
|
|
42
|
-
"rollup-plugin-inject-process-env": "^1.3.1",
|
|
43
|
-
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
44
|
-
"rollup-plugin-scss": "^4.0.1",
|
|
45
|
-
"sass": "^1.
|
|
46
|
-
"tslib": "^2.8.1"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@types/babel__traverse": "^7.20.7",
|
|
50
|
-
"@types/glob": "^8.1.0",
|
|
51
|
-
"@types/node": "^22.15.
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@steambrew/ttc",
|
|
3
|
+
"version": "2.6.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"millennium-ttc": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rollup -c",
|
|
12
|
+
"prepare": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"author": "SteamClientHomebrew",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"description": "A tiny typescript compiler for Millennium plugins.",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@babel/parser": "^7.27.5",
|
|
23
|
+
"@babel/preset-env": "^7.27.2",
|
|
24
|
+
"@babel/preset-react": "^7.27.1",
|
|
25
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
26
|
+
"@babel/traverse": "^7.27.4",
|
|
27
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
28
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
29
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
30
|
+
"@rollup/plugin-node-resolve": "^15.3.1",
|
|
31
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
32
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
33
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
34
|
+
"@rollup/plugin-url": "^8.0.2",
|
|
35
|
+
"@rollup/pluginutils": "^5.1.4",
|
|
36
|
+
"chalk": "^5.4.1",
|
|
37
|
+
"dotenv": "^16.5.0",
|
|
38
|
+
"fs": "0.0.1-security",
|
|
39
|
+
"glob": "^11.0.2",
|
|
40
|
+
"magic-string": "^0.30.17",
|
|
41
|
+
"rollup": "^4.42.0",
|
|
42
|
+
"rollup-plugin-inject-process-env": "^1.3.1",
|
|
43
|
+
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
44
|
+
"rollup-plugin-scss": "^4.0.1",
|
|
45
|
+
"sass": "^1.89.1",
|
|
46
|
+
"tslib": "^2.8.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/babel__traverse": "^7.20.7",
|
|
50
|
+
"@types/glob": "^8.1.0",
|
|
51
|
+
"@types/node": "^22.15.30"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/rollup.config.js
CHANGED
|
@@ -2,35 +2,21 @@ import commonjs from '@rollup/plugin-commonjs';
|
|
|
2
2
|
import typescript from '@rollup/plugin-typescript';
|
|
3
3
|
import json from '@rollup/plugin-json';
|
|
4
4
|
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
|
|
7
|
+
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
|
|
5
8
|
|
|
6
9
|
export default {
|
|
7
|
-
input: 'index.ts',
|
|
10
|
+
input: 'src/index.ts',
|
|
8
11
|
context: 'window',
|
|
9
12
|
output: {
|
|
10
13
|
file: 'dist/index.js',
|
|
11
14
|
},
|
|
12
15
|
plugins: [commonjs(), typescript(), json(), nodeResolve()],
|
|
13
16
|
external: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'fs',
|
|
19
|
-
'rollup',
|
|
20
|
-
'@rollup/plugin-json',
|
|
21
|
-
'@rollup/plugin-commonjs',
|
|
22
|
-
'@rollup/plugin-replace',
|
|
23
|
-
'@rollup/plugin-typescript',
|
|
24
|
-
'@rollup/plugin-node-resolve',
|
|
25
|
-
'rollup-plugin-import-css',
|
|
26
|
-
'@rollup/plugin-terser',
|
|
27
|
-
'@rollup/plugin-babel',
|
|
28
|
-
'rollup-plugin-inject-process-env',
|
|
29
|
-
'dotenv',
|
|
30
|
-
'perf_hooks',
|
|
31
|
-
'@rollup/pluginutils',
|
|
32
|
-
'magic-string',
|
|
33
|
-
'rollup-plugin-scss',
|
|
34
|
-
'sass',
|
|
17
|
+
...Object.keys(pkg.dependencies || {}),
|
|
18
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
19
|
+
...Object.keys(pkg.optionalDependencies || {}),
|
|
20
|
+
...Object.keys(pkg.devDependencies || {}),
|
|
35
21
|
],
|
|
36
22
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { existsSync, readFile } from 'fs';
|
|
4
|
+
|
|
5
|
+
export const ValidatePlugin = (target: string): Promise<any> => {
|
|
6
|
+
return new Promise<any>((resolve, reject) => {
|
|
7
|
+
if (!existsSync(target)) {
|
|
8
|
+
console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red('is not a valid system path'));
|
|
9
|
+
reject();
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const pluginModule = path.join(target, 'plugin.json');
|
|
14
|
+
|
|
15
|
+
if (!existsSync(pluginModule)) {
|
|
16
|
+
console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red('is not a valid plugin (missing plugin.json)'));
|
|
17
|
+
reject();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
readFile(pluginModule, 'utf8', (err, data) => {
|
|
22
|
+
if (err) {
|
|
23
|
+
console.error(chalk.red.bold(`\n[-] couldn't read plugin.json from [${pluginModule}]`));
|
|
24
|
+
reject();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
if (!('name' in JSON.parse(data))) {
|
|
30
|
+
console.error(chalk.red.bold(`\n[-] target plugin doesn't contain "name" in plugin.json [${pluginModule}]`));
|
|
31
|
+
reject();
|
|
32
|
+
} else {
|
|
33
|
+
resolve(JSON.parse(data));
|
|
34
|
+
}
|
|
35
|
+
} catch (parseError) {
|
|
36
|
+
console.error(chalk.red.bold(`\n[-] couldn't parse JSON in plugin.json from [${pluginModule}]`));
|
|
37
|
+
reject();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* - typescript transpiler
|
|
6
6
|
* - rollup configurator
|
|
7
7
|
*/
|
|
8
|
-
import { BuildType, ValidateParameters } from './
|
|
9
|
-
import { CheckForUpdates } from './
|
|
10
|
-
import { ValidatePlugin } from './
|
|
11
|
-
import { TranspilerPluginComponent, TranspilerProps } from './
|
|
8
|
+
import { BuildType, ValidateParameters } from './query-parser';
|
|
9
|
+
import { CheckForUpdates } from './version-control';
|
|
10
|
+
import { ValidatePlugin } from './check-health';
|
|
11
|
+
import { TranspilerPluginComponent, TranspilerProps } from './transpiler';
|
|
12
12
|
import { performance } from 'perf_hooks';
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
// import { Logger } from './Logger'
|
|
@@ -10,6 +10,11 @@ declare global {
|
|
|
10
10
|
* It is used to store the plugin settings and the plugin settings parser.
|
|
11
11
|
*/
|
|
12
12
|
MILLENNIUM_PLUGIN_SETTINGS_STORE: any;
|
|
13
|
+
/**
|
|
14
|
+
* @description Used to store the settings for the plugin.
|
|
15
|
+
* Millennium then renders these in the settings panel.
|
|
16
|
+
*/
|
|
17
|
+
MILLENNIUM_SIDEBAR_NAVIGATION_PANELS: any;
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
|
|
@@ -96,7 +101,20 @@ function ExecutePluginModule() {
|
|
|
96
101
|
});
|
|
97
102
|
|
|
98
103
|
/** Run the rolled up plugins default exported function */
|
|
99
|
-
PluginModule.default();
|
|
104
|
+
let pluginProps = PluginModule.default();
|
|
105
|
+
|
|
106
|
+
function isValidSidebarNavComponent(obj: any) {
|
|
107
|
+
return obj && obj.title !== undefined && obj.icon !== undefined && obj.content !== undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (pluginProps && isValidSidebarNavComponent(pluginProps)) {
|
|
111
|
+
window.MILLENNIUM_SIDEBAR_NAVIGATION_PANELS[pluginName] = pluginProps;
|
|
112
|
+
} else {
|
|
113
|
+
console.warn(
|
|
114
|
+
`Plugin ${pluginName} does not contain proper SidebarNavigation props and therefor can't be mounted by Millennium. Please ensure it has a title, icon, and content.`,
|
|
115
|
+
);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
100
118
|
|
|
101
119
|
/** If the current module is a client module, post message id=1 which calls the front_end_loaded method on the backend. */
|
|
102
120
|
if (MILLENNIUM_IS_CLIENT_MODULE) {
|
|
@@ -116,6 +134,7 @@ function InitializePlugins() {
|
|
|
116
134
|
*/
|
|
117
135
|
(window.PLUGIN_LIST ||= {})[pluginName] ||= {};
|
|
118
136
|
(window.MILLENNIUM_PLUGIN_SETTINGS_STORE ||= {})[pluginName] ||= {};
|
|
137
|
+
window.MILLENNIUM_SIDEBAR_NAVIGATION_PANELS ||= {};
|
|
119
138
|
|
|
120
139
|
/**
|
|
121
140
|
* Accepted IPC message types from Millennium backend.
|
|
@@ -154,7 +173,7 @@ function InitializePlugins() {
|
|
|
154
173
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
155
174
|
}
|
|
156
175
|
|
|
157
|
-
MainWindowBrowserManager
|
|
176
|
+
MainWindowBrowserManager?.m_browser?.on('message', (messageId: string, data: string) => {
|
|
158
177
|
if (messageId !== IPCMessageId) {
|
|
159
178
|
return;
|
|
160
179
|
}
|
|
@@ -170,7 +189,7 @@ function InitializePlugins() {
|
|
|
170
189
|
}
|
|
171
190
|
|
|
172
191
|
function WebkitInitializeIPC() {
|
|
173
|
-
SteamClient
|
|
192
|
+
SteamClient?.BrowserView?.RegisterForMessageFromParent((messageId: string, data: string) => {
|
|
174
193
|
if (messageId !== IPCMessageId) {
|
|
175
194
|
return;
|
|
176
195
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { Logger } from './logger';
|
|
3
|
+
|
|
4
|
+
/***
|
|
5
|
+
* @brief print the parameter list to the stdout
|
|
6
|
+
*/
|
|
7
|
+
export const PrintParamHelp = () => {
|
|
8
|
+
console.log(
|
|
9
|
+
'millennium-ttc parameter list:' +
|
|
10
|
+
'\n\t' +
|
|
11
|
+
chalk.magenta('--help') +
|
|
12
|
+
': display parameter list' +
|
|
13
|
+
'\n\t' +
|
|
14
|
+
chalk.bold.red('--build') +
|
|
15
|
+
': ' +
|
|
16
|
+
chalk.bold.red('(required)') +
|
|
17
|
+
': build type [dev, prod] (prod minifies code)' +
|
|
18
|
+
'\n\t' +
|
|
19
|
+
chalk.magenta('--target') +
|
|
20
|
+
': path to plugin, default to cwd',
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export enum BuildType {
|
|
25
|
+
DevBuild,
|
|
26
|
+
ProdBuild,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ParameterProps {
|
|
30
|
+
type: BuildType;
|
|
31
|
+
targetPlugin: string; // path
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const ValidateParameters = (args: Array<string>): ParameterProps => {
|
|
35
|
+
let typeProp: BuildType = BuildType.DevBuild,
|
|
36
|
+
targetProp: string = process.cwd();
|
|
37
|
+
|
|
38
|
+
if (args.includes('--help')) {
|
|
39
|
+
PrintParamHelp();
|
|
40
|
+
process.exit();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// startup args are invalid
|
|
44
|
+
if (!args.includes('--build')) {
|
|
45
|
+
Logger.Error('Received invalid arguments...');
|
|
46
|
+
PrintParamHelp();
|
|
47
|
+
process.exit();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for (let i = 0; i < args.length; i++) {
|
|
51
|
+
if (args[i] === '--build') {
|
|
52
|
+
const BuildMode: string = args[i + 1];
|
|
53
|
+
|
|
54
|
+
switch (BuildMode) {
|
|
55
|
+
case 'dev':
|
|
56
|
+
typeProp = BuildType.DevBuild;
|
|
57
|
+
break;
|
|
58
|
+
case 'prod':
|
|
59
|
+
typeProp = BuildType.ProdBuild;
|
|
60
|
+
break;
|
|
61
|
+
default: {
|
|
62
|
+
Logger.Error('--build parameter must be preceded by build type [dev, prod]');
|
|
63
|
+
process.exit();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (args[i] == '--target') {
|
|
69
|
+
if (args[i + 1] === undefined) {
|
|
70
|
+
Logger.Error('--target parameter must be preceded by system path');
|
|
71
|
+
process.exit();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
targetProp = args[i + 1];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
type: typeProp,
|
|
80
|
+
targetPlugin: targetProp,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -13,13 +13,13 @@ import scss from 'rollup-plugin-scss';
|
|
|
13
13
|
import * as sass from 'sass';
|
|
14
14
|
|
|
15
15
|
import chalk from 'chalk';
|
|
16
|
-
import { Logger } from './
|
|
16
|
+
import { Logger } from './logger';
|
|
17
17
|
import fs from 'fs';
|
|
18
18
|
|
|
19
19
|
import injectProcessEnv from 'rollup-plugin-inject-process-env';
|
|
20
20
|
import dotenv from 'dotenv';
|
|
21
|
-
import { ExecutePluginModule, InitializePlugins } from './
|
|
22
|
-
import constSysfsExpr from './
|
|
21
|
+
import { ExecutePluginModule, InitializePlugins } from './plugin-api';
|
|
22
|
+
import constSysfsExpr from './static-embed';
|
|
23
23
|
|
|
24
24
|
const envConfig = dotenv.config().parsed || {};
|
|
25
25
|
|
|
@@ -2,7 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { readFile } from 'fs/promises';
|
|
4
4
|
import { dirname } from 'path';
|
|
5
|
-
import { Logger } from './
|
|
5
|
+
import { Logger } from './logger';
|
|
6
6
|
|
|
7
7
|
export const CheckForUpdates = async (): Promise<boolean> => {
|
|
8
8
|
return new Promise<boolean>(async (resolve) => {
|
package/tsconfig.json
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "dist",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"jsx": "react",
|
|
7
|
+
"jsxFactory": "window.SP_REACT.createElement",
|
|
8
|
+
"declaration": false,
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"noUnusedLocals": true,
|
|
11
|
+
"noUnusedParameters": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"noImplicitReturns": true,
|
|
14
|
+
"noImplicitThis": true,
|
|
15
|
+
"noImplicitAny": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"ignoreDeprecations": "5.0",
|
|
18
|
+
"allowSyntheticDefaultImports": true,
|
|
19
|
+
"skipLibCheck": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["./src/**/*"],
|
|
22
|
+
"exclude": ["node_modules"]
|
|
23
23
|
}
|
|
24
|
-
|
package/Linter.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { existsSync, readFile } from 'fs'
|
|
4
|
-
|
|
5
|
-
export const ValidatePlugin = (target: string): Promise<any> => {
|
|
6
|
-
|
|
7
|
-
return new Promise<any>((resolve, reject) => {
|
|
8
|
-
if (!existsSync(target)) {
|
|
9
|
-
console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red("is not a valid system path"))
|
|
10
|
-
reject()
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const pluginModule = path.join(target, "plugin.json")
|
|
15
|
-
|
|
16
|
-
if (!existsSync(pluginModule)) {
|
|
17
|
-
console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red("is not a valid plugin (missing plugin.json)"))
|
|
18
|
-
reject()
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
readFile(pluginModule, 'utf8', (err, data) => {
|
|
23
|
-
if (err) {
|
|
24
|
-
console.error(chalk.red.bold(`\n[-] couldn't read plugin.json from [${pluginModule}]`))
|
|
25
|
-
reject()
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
if (!("name" in JSON.parse(data))) {
|
|
31
|
-
console.error(chalk.red.bold(`\n[-] target plugin doesn't contain "name" in plugin.json [${pluginModule}]`))
|
|
32
|
-
reject()
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
resolve(JSON.parse(data))
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (parseError) {
|
|
39
|
-
console.error(chalk.red.bold(`\n[-] couldn't parse JSON in plugin.json from [${pluginModule}]`))
|
|
40
|
-
reject()
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
})
|
|
44
|
-
}
|
package/Parameters.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import { Logger } from "./Logger"
|
|
3
|
-
|
|
4
|
-
/***
|
|
5
|
-
* @brief print the parameter list to the stdout
|
|
6
|
-
*/
|
|
7
|
-
export const PrintParamHelp = () => {
|
|
8
|
-
|
|
9
|
-
console.log(
|
|
10
|
-
"millennium-ttc parameter list:" +
|
|
11
|
-
"\n\t" + chalk.magenta("--help") + ": display parameter list" +
|
|
12
|
-
"\n\t" + chalk.bold.red("--build") + ": " + chalk.bold.red("(required)") + ": build type [dev, prod] (prod minifies code)" +
|
|
13
|
-
"\n\t" + chalk.magenta("--target") + ": path to plugin, default to cwd"
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export enum BuildType {
|
|
18
|
-
DevBuild, ProdBuild
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ParameterProps {
|
|
22
|
-
type: BuildType,
|
|
23
|
-
targetPlugin: string // path
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const ValidateParameters = (args: Array<string>): ParameterProps => {
|
|
27
|
-
|
|
28
|
-
let typeProp: BuildType = BuildType.DevBuild, targetProp: string = process.cwd()
|
|
29
|
-
|
|
30
|
-
if (args.includes("--help")) {
|
|
31
|
-
PrintParamHelp()
|
|
32
|
-
process.exit();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// startup args are invalid
|
|
36
|
-
if (!args.includes("--build")) {
|
|
37
|
-
Logger.Error("Received invalid arguments...");
|
|
38
|
-
PrintParamHelp();
|
|
39
|
-
process.exit();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
for (let i = 0; i < args.length; i++)
|
|
43
|
-
{
|
|
44
|
-
if (args[i] === "--build")
|
|
45
|
-
{
|
|
46
|
-
const BuildMode: string = args[i + 1]
|
|
47
|
-
|
|
48
|
-
switch (BuildMode) {
|
|
49
|
-
case "dev": typeProp = BuildType.DevBuild; break
|
|
50
|
-
case "prod": typeProp = BuildType.ProdBuild; break
|
|
51
|
-
default: {
|
|
52
|
-
Logger.Error('--build parameter must be preceded by build type [dev, prod]');
|
|
53
|
-
process.exit();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (args[i] == "--target") {
|
|
59
|
-
if (args[i + 1] === undefined) {
|
|
60
|
-
Logger.Error('--target parameter must be preceded by system path');
|
|
61
|
-
process.exit();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
targetProp = args[i + 1]
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
type: typeProp,
|
|
70
|
-
targetPlugin: targetProp
|
|
71
|
-
}
|
|
72
|
-
}
|
|
File without changes
|
|
File without changes
|