@vixoniccom/module-packager 2.11.0-dev.9 → 2.11.0-just4dev.1
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/.babelrc +3 -0
- package/.eslintrc +3 -0
- package/CHANGELOG.md +499 -0
- package/electron.js +50 -0
- package/index.html +64 -0
- package/main.js +182 -0
- package/package.json +94 -51
- package/tsconfig.json +16 -0
- package/webpack.config.js +154 -0
- package/dist/electron.js +0 -58
- package/dist/launcher.html +0 -86
- package/dist/main.js +0 -323
- package/dist/webpack.config.js +0 -153
package/main.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict'
|
|
4
|
+
const commandLineArgs = require('command-line-args')
|
|
5
|
+
const optionDefinitions = [
|
|
6
|
+
{ name: 'externals', type: String, defaultValue: [], multiple: true },
|
|
7
|
+
{ name: 'target', type: String, defaultValue: 'web' },
|
|
8
|
+
{ name: 'src', type: String, defaultValue: './src' },
|
|
9
|
+
{ name: 'build', type: String, defaultValue: './build' },
|
|
10
|
+
{ name: 'confDefinition', type: String, defaultValue: './configuration' },
|
|
11
|
+
{ name: 'config', type: String, defaultValue: './webpack.config.js' },
|
|
12
|
+
{ name: 'port', type: Number, defaultValue: 8080 },
|
|
13
|
+
{ name: 'mode', type: String, defaultValue: 'build' },
|
|
14
|
+
{ name: 'transpileOnly', type: Boolean },
|
|
15
|
+
{ name: 'tsOverride', type: Boolean }
|
|
16
|
+
]
|
|
17
|
+
const options = commandLineArgs(optionDefinitions)
|
|
18
|
+
const path = require('path')
|
|
19
|
+
const webpack = require('webpack')
|
|
20
|
+
const WebpackDevServer = require('webpack-dev-server')
|
|
21
|
+
const { exec } = require('child_process')
|
|
22
|
+
const fs = require('fs')
|
|
23
|
+
const archiver = require('archiver')
|
|
24
|
+
const clc = require('cli-color')
|
|
25
|
+
|
|
26
|
+
var pjson = require('./package.json')
|
|
27
|
+
console.log(`VIXONIC PACKAGER: Version ${pjson.version}`)
|
|
28
|
+
|
|
29
|
+
if (options.target !== 'electron-renderer' && options.externals.length > 0) {
|
|
30
|
+
throw new Error(`Can't use external dependencies if target is not electron-renderer.`)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (options.mode === 'build') {
|
|
34
|
+
pack(() => {
|
|
35
|
+
// Install externals only if not web.
|
|
36
|
+
if (options.target === 'electron-renderer') {
|
|
37
|
+
installExternals(() => {
|
|
38
|
+
zip()
|
|
39
|
+
})
|
|
40
|
+
} else {
|
|
41
|
+
zip()
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
} else if (options.mode === 'watch') {
|
|
45
|
+
watch()
|
|
46
|
+
} else if (options.mode === 'run') {
|
|
47
|
+
run()
|
|
48
|
+
} else if (options.mode === 'generate-configuration') {
|
|
49
|
+
generateConfiguration()
|
|
50
|
+
} else if (options.mode === 'validate-configuration') {
|
|
51
|
+
validateConfiguration()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function pack (callback) {
|
|
55
|
+
console.log(clc.blue('Building module...'))
|
|
56
|
+
validateConfiguration()
|
|
57
|
+
webpack(require(options.config)(options), function (err, stats) {
|
|
58
|
+
if (err) {
|
|
59
|
+
console.log(err)
|
|
60
|
+
throw err
|
|
61
|
+
} else {
|
|
62
|
+
if (stats.hasErrors()) {
|
|
63
|
+
console.log(clc.red(stats.toJson('errors-only')))
|
|
64
|
+
callback && callback(stats)
|
|
65
|
+
} else {
|
|
66
|
+
console.log(clc.green('Build OK.'))
|
|
67
|
+
callback && callback(null)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function installExternals (callback) {
|
|
74
|
+
// Get external versions.
|
|
75
|
+
let externals = options.externals.map(x => {
|
|
76
|
+
return `${x}@${JSON.parse(fs.readFileSync(path.resolve(options.src, '..', 'node_modules', x, 'package.json'))).version}`
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// Install external versions.
|
|
80
|
+
if (externals.length) {
|
|
81
|
+
externals = externals.join(' ')
|
|
82
|
+
console.log(clc.blue(`Installing externals ${externals}...`))
|
|
83
|
+
exec(`npm install --prefix ./ --production ${externals}`, {
|
|
84
|
+
cwd: options.build
|
|
85
|
+
},
|
|
86
|
+
(err, stdout) => {
|
|
87
|
+
if (err) throw err
|
|
88
|
+
console.log(clc.green('Externals installed.'))
|
|
89
|
+
callback && callback(null)
|
|
90
|
+
})
|
|
91
|
+
} else {
|
|
92
|
+
callback && callback(null)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function zip (callback) {
|
|
97
|
+
console.log(clc.blue('Archiving...'))
|
|
98
|
+
let output = fs.createWriteStream(path.resolve(options.build, '../', 'build.zip'))
|
|
99
|
+
let archive = archiver('zip')
|
|
100
|
+
archive.pipe(output)
|
|
101
|
+
archive.directory(path.resolve(options.build), './')
|
|
102
|
+
archive.finalize()
|
|
103
|
+
|
|
104
|
+
output.on('close', function () {
|
|
105
|
+
console.log(clc.green('Generated build.zip.'))
|
|
106
|
+
callback && callback(null)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
archive.on('error', function (err) {
|
|
110
|
+
throw err
|
|
111
|
+
})
|
|
112
|
+
clc.move(-2, 0)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function watch () {
|
|
116
|
+
var server = new WebpackDevServer(webpack(require(options.config)(options)), {
|
|
117
|
+
static: path.join(__dirname, options.src, '..')
|
|
118
|
+
})
|
|
119
|
+
server.listen(options.port)
|
|
120
|
+
|
|
121
|
+
var environment = process.env
|
|
122
|
+
environment.NODE_ENV = 'development'
|
|
123
|
+
|
|
124
|
+
exec(`npm start -- ${path.join(__dirname, 'electron.js')} --src ${path.resolve(options.src)} --build ${path.resolve(options.build)} --port ${options.port} --mode ${options.mode} --config ${options.config} --externals ${options.externals}`,
|
|
125
|
+
{
|
|
126
|
+
cwd: __dirname,
|
|
127
|
+
env: environment
|
|
128
|
+
},
|
|
129
|
+
(err) => {
|
|
130
|
+
if (err) throw err
|
|
131
|
+
process.exit()
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function run () {
|
|
136
|
+
pack((err) => {
|
|
137
|
+
if (err) {
|
|
138
|
+
throw err
|
|
139
|
+
} else {
|
|
140
|
+
exec(`npm start -- ${path.join(__dirname, 'electron.js')} --src ${path.resolve(options.src)} --build ${path.resolve(options.build)} --port ${options.port} --mode ${options.mode} --config ${options.config} --externals ${options.externals}`,
|
|
141
|
+
{
|
|
142
|
+
cwd: __dirname
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function loadConfiguration () {
|
|
149
|
+
require('@vixoniccom/modules')
|
|
150
|
+
require('ts-node').register({compilerOptions: { moduleResolution: 'node', module: 'commonjs', target: 'es2015', checkJs: false }})
|
|
151
|
+
return require(path.resolve(options.confDefinition, 'index.ts')).configuration
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function generateConfiguration () {
|
|
155
|
+
try {
|
|
156
|
+
let configuration = loadConfiguration()
|
|
157
|
+
fs.writeFileSync(path.resolve(options.src, 'parameters.d.ts'), configuration.declarationFileString)
|
|
158
|
+
fs.writeFileSync(path.resolve(options.src, '..', 'configuration.json'), JSON.stringify(configuration, undefined, 2))
|
|
159
|
+
console.log(clc.green(`Configuration generated`))
|
|
160
|
+
} catch (e) {
|
|
161
|
+
console.log(clc.red('Configuration generation failed'))
|
|
162
|
+
throw e
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function validateConfiguration () {
|
|
167
|
+
try {
|
|
168
|
+
const { Configuration } = require('@vixoniccom/modules')
|
|
169
|
+
const json = require(path.resolve(options.src, '../', 'configuration.json'))
|
|
170
|
+
const conf = Configuration.fromJSON(json)
|
|
171
|
+
if (conf.durationFormula) {
|
|
172
|
+
const values = require(path.resolve(options.src, 'test', 'parameters.json'))
|
|
173
|
+
console.log('Validate duration')
|
|
174
|
+
console.log('Duration on undefined:', conf.getDuration({}), 'seconds')
|
|
175
|
+
console.log('Duration:', conf.getDuration(values.parameters), 'seconds')
|
|
176
|
+
}
|
|
177
|
+
console.log(clc.green('Valid configuration'))
|
|
178
|
+
} catch (e) {
|
|
179
|
+
console.log(clc.red('Invalid configuration'))
|
|
180
|
+
throw e
|
|
181
|
+
}
|
|
182
|
+
}
|
package/package.json
CHANGED
|
@@ -1,68 +1,111 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"_args": [
|
|
3
|
+
[
|
|
4
|
+
{
|
|
5
|
+
"raw": "@vixoniccom/module-packager@^1.2.0",
|
|
6
|
+
"scope": "@vixoniccom",
|
|
7
|
+
"escapedName": "@vixoniccom%2fmodule-packager",
|
|
8
|
+
"name": "@vixoniccom/module-packager",
|
|
9
|
+
"rawSpec": "^1.2.0",
|
|
10
|
+
"spec": ">=1.2.0 <2.0.0",
|
|
11
|
+
"type": "range"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
],
|
|
15
|
+
"_from": "@vixoniccom/module-packager@>=1.2.0 <2.0.0",
|
|
16
|
+
"_id": "@vixoniccom/module-packager@1.2.0",
|
|
17
|
+
"_inCache": true,
|
|
18
|
+
"_location": "/@vixoniccom/module-packager",
|
|
19
|
+
"_nodeVersion": "7.6.0",
|
|
20
|
+
"_npmOperationalInternal": {
|
|
21
|
+
"host": "packages-12-west.internal.npmjs.com",
|
|
22
|
+
"tmp": "tmp/module-packager-1.2.0.tgz_1487918846893_0.5388180573936552"
|
|
7
23
|
},
|
|
8
|
-
"
|
|
9
|
-
"
|
|
24
|
+
"_npmUser": {
|
|
25
|
+
"name": "vixonic",
|
|
26
|
+
"email": "tdadone@vixonic.net"
|
|
27
|
+
},
|
|
28
|
+
"_npmVersion": "2.15.9",
|
|
29
|
+
"_phantomChildren": {},
|
|
30
|
+
"_requested": {
|
|
31
|
+
"raw": "@vixoniccom/module-packager@^1.2.0",
|
|
32
|
+
"scope": "@vixonic",
|
|
33
|
+
"escapedName": "@vixonic%2fmodule-packager",
|
|
34
|
+
"name": "@vixoniccom/module-packager",
|
|
35
|
+
"rawSpec": "^1.2.0",
|
|
36
|
+
"spec": ">=1.2.0 <2.0.0",
|
|
37
|
+
"type": "range"
|
|
38
|
+
},
|
|
39
|
+
"_requiredBy": [
|
|
40
|
+
"#DEV:/"
|
|
10
41
|
],
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"dev:watch": "npm run clean && npm-run-all -p watch:renderer watch:main",
|
|
22
|
-
"prerelease-dev": "standard-version --prerelease dev",
|
|
23
|
-
"prerelease-rc": "standard-version --prerelease rc",
|
|
24
|
-
"prerelease-test": "standard-version --prerelease test",
|
|
25
|
-
"release": "standard-version"
|
|
42
|
+
"_resolved": "https://registry.npmjs.org/@vixoniccom/module-packager/-/module-packager-1.2.0.tgz",
|
|
43
|
+
"_shasum": "9735f3bcbf2101d404d7bb058cb8337b0a87c503",
|
|
44
|
+
"_shrinkwrap": null,
|
|
45
|
+
"_spec": "@vixoniccom/module-packager@^1.2.0",
|
|
46
|
+
"_where": "c:\\Development\\menuboard",
|
|
47
|
+
"author": {
|
|
48
|
+
"name": "tdadone"
|
|
49
|
+
},
|
|
50
|
+
"bin": {
|
|
51
|
+
"vixonic-module-packager": "main.js"
|
|
26
52
|
},
|
|
27
53
|
"dependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@vixoniccom/module-controller": "2.0.0-dev.5",
|
|
31
|
-
"@vixoniccom/modules": "2.20.1-dev.0",
|
|
54
|
+
"@vixoniccom/module-controller": "^1.2.2",
|
|
55
|
+
"@vixoniccom/modules": "^2.20.0",
|
|
32
56
|
"archiver": "^5.3.0",
|
|
33
|
-
"
|
|
57
|
+
"babel-core": "^6.14.0",
|
|
58
|
+
"babel-loader": "^6.2.5",
|
|
59
|
+
"babel-polyfill": "^6.26.0",
|
|
60
|
+
"babel-preset-env": "^1.7.0",
|
|
61
|
+
"babel-preset-react": "^6.24.1",
|
|
62
|
+
"clean-webpack-plugin": "^0.1.10",
|
|
34
63
|
"cli-color": "^1.2.0",
|
|
35
64
|
"command-line-args": "^3.0.1",
|
|
36
|
-
"copy-webpack-plugin": "^
|
|
37
|
-
"css-loader": "^
|
|
38
|
-
"electron": "^
|
|
65
|
+
"copy-webpack-plugin": "^4.6.0",
|
|
66
|
+
"css-loader": "^0.24.0",
|
|
67
|
+
"electron": "^11.4.12",
|
|
39
68
|
"electron-debug": "^3.2.0",
|
|
40
|
-
"
|
|
41
|
-
"html-loader": "^
|
|
69
|
+
"file-loader": "^0.9.0",
|
|
70
|
+
"html-loader": "^0.4.3",
|
|
42
71
|
"html-webpack-plugin": "^4.5.2",
|
|
43
72
|
"lodash": "^4.17.21",
|
|
44
|
-
"
|
|
73
|
+
"node-sass": "^6.0.1",
|
|
45
74
|
"raw-loader": "^0.5.1",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
75
|
+
"sass-loader": "^4.0.2",
|
|
76
|
+
"style-loader": "^0.13.1",
|
|
77
|
+
"ts-loader": "^8.2.0",
|
|
48
78
|
"ts-node": "^10.9.1",
|
|
49
|
-
"typescript": "^
|
|
50
|
-
"webpack": "^
|
|
51
|
-
"webpack
|
|
52
|
-
"webpack-dev-server": "^
|
|
53
|
-
|
|
79
|
+
"typescript": "^4.7.3",
|
|
80
|
+
"uglifyjs-webpack-plugin": "^1.3.0",
|
|
81
|
+
"webpack": "^4.46.0",
|
|
82
|
+
"webpack-dev-server": "^4.9.3"
|
|
83
|
+
},
|
|
84
|
+
"directories": {},
|
|
85
|
+
"dist": {
|
|
86
|
+
"shasum": "9735f3bcbf2101d404d7bb058cb8337b0a87c503",
|
|
87
|
+
"tarball": "https://registry.npmjs.org/@vixoniccom/module-packager/-/module-packager-1.2.0.tgz"
|
|
88
|
+
},
|
|
89
|
+
"main": "main.js",
|
|
90
|
+
"maintainers": [
|
|
91
|
+
{
|
|
92
|
+
"name": "vixonic",
|
|
93
|
+
"email": "tdadone@vixonic.net"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"name": "@vixoniccom/module-packager",
|
|
97
|
+
"readme": "ERROR: No README data found!",
|
|
98
|
+
"scripts": {
|
|
99
|
+
"start": "electron --disable-site-isolation-trials",
|
|
100
|
+
"prerelease-dev": "standard-version --prerelease dev",
|
|
101
|
+
"prerelease-rc": "standard-version --prerelease rc",
|
|
102
|
+
"prerelease-test": "standard-version --prerelease test",
|
|
103
|
+
"prerelease-just4dev": "standard-version --prerelease just4dev",
|
|
104
|
+
"release": "standard-version"
|
|
54
105
|
},
|
|
106
|
+
"version": "2.11.0-just4dev.1",
|
|
107
|
+
"license": "ISC",
|
|
55
108
|
"devDependencies": {
|
|
56
|
-
"
|
|
57
|
-
"@types/cli-color": "^2.0.6",
|
|
58
|
-
"@types/command-line-args": "^5.2.3",
|
|
59
|
-
"@types/node": "^20.11.25",
|
|
60
|
-
"@types/webpack-env": "^1.18.8",
|
|
61
|
-
"concurrently": "^9.1.2",
|
|
62
|
-
"npm-run-all": "^4.1.5",
|
|
63
|
-
"sass": "^1.88.0",
|
|
64
|
-
"sass-loader": "^16.0.5",
|
|
65
|
-
"standard-version": "^9.3.1",
|
|
66
|
-
"wait-on": "^8.0.3"
|
|
109
|
+
"standard-version": "^9.3.1"
|
|
67
110
|
}
|
|
68
111
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"module": "es2015",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"jsx": "preserve",
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"checkJs": false,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"sourceMap": true
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"./src/**/*"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const CleanWebpackPlugin = require('clean-webpack-plugin')
|
|
4
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
5
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
6
|
+
const webpack = require('webpack')
|
|
7
|
+
const path = require('path')
|
|
8
|
+
const _ = require('lodash')
|
|
9
|
+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
|
10
|
+
|
|
11
|
+
module.exports = (options) => {
|
|
12
|
+
if (options.target === 'web') {
|
|
13
|
+
options.externals = [...(options.externals || []), 'electron']
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let exclude = [path.resolve(options.src, 'static'), path.resolve(options.src, 'test')]
|
|
17
|
+
|
|
18
|
+
let config = {
|
|
19
|
+
mode: 'production',
|
|
20
|
+
context: __dirname,
|
|
21
|
+
entry: ['babel-polyfill', path.resolve(options.src, 'main')],
|
|
22
|
+
output: {
|
|
23
|
+
path: path.resolve(options.build),
|
|
24
|
+
filename: 'main.js'
|
|
25
|
+
},
|
|
26
|
+
performance: {
|
|
27
|
+
hints: false,
|
|
28
|
+
maxAssetSize: 1000000,
|
|
29
|
+
maxEntrypointSize: 1000000
|
|
30
|
+
},
|
|
31
|
+
node: {
|
|
32
|
+
__dirname: options.mode === 'watch',
|
|
33
|
+
fs: 'empty',
|
|
34
|
+
net: 'empty',
|
|
35
|
+
tls: 'empty'
|
|
36
|
+
},
|
|
37
|
+
resolve: {
|
|
38
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
|
39
|
+
modules: [
|
|
40
|
+
'node_modules',
|
|
41
|
+
'src',
|
|
42
|
+
'static'
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
module: {
|
|
46
|
+
rules: [
|
|
47
|
+
{
|
|
48
|
+
test: /\.(j|t)sx?$/,
|
|
49
|
+
include: [path.resolve(options.src)],
|
|
50
|
+
exclude: exclude,
|
|
51
|
+
rules: [
|
|
52
|
+
{
|
|
53
|
+
loader: 'babel-loader?babelrc=false&extends=' + path.join(__dirname, '/.babelrc')
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
loader: 'ts-loader',
|
|
57
|
+
options: {
|
|
58
|
+
transpileOnly: options.transpileOnly
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
test: /\.scss$/,
|
|
65
|
+
exclude: exclude,
|
|
66
|
+
loaders: ['style', 'css', 'sass']
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
test: /\.css$/,
|
|
70
|
+
exclude: exclude,
|
|
71
|
+
loader: 'style-loader!css-loader'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|mp4)$/,
|
|
75
|
+
exclude: exclude,
|
|
76
|
+
loader: 'file-loader'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
test: /\.html$/,
|
|
80
|
+
loader: 'raw-loader'
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
externals: (_context, request, callback) => {
|
|
85
|
+
if (_.indexOf(options.externals, request) !== -1) {
|
|
86
|
+
if (options.mode !== 'watch' || request === 'electron') {
|
|
87
|
+
return callback(null, "require('" + request + "')")
|
|
88
|
+
} else {
|
|
89
|
+
return callback(null, "require('" + path.resolve(options.src, '..', 'node_modules', request).replace(/\\/g, '\\\\') + "')")
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
callback()
|
|
93
|
+
},
|
|
94
|
+
plugins: [
|
|
95
|
+
new CopyWebpackPlugin([{ from: path.resolve(options.src, 'static'), to: 'static/' }], { copyUnmodified: true }),
|
|
96
|
+
new HtmlWebpackPlugin({
|
|
97
|
+
inject: 'head',
|
|
98
|
+
template: path.resolve(options.src, 'index.html')
|
|
99
|
+
}),
|
|
100
|
+
new webpack.LoaderOptionsPlugin({
|
|
101
|
+
options: {
|
|
102
|
+
test: /\.tsx?$/,
|
|
103
|
+
ts: {
|
|
104
|
+
compiler: 'typescript',
|
|
105
|
+
configFileName: 'tsconfig.json'
|
|
106
|
+
},
|
|
107
|
+
tslint: {
|
|
108
|
+
emitErrors: true,
|
|
109
|
+
failOnHint: true
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
],
|
|
114
|
+
target: options.target
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (options.mode === 'watch') {
|
|
118
|
+
config.entry.unshift(`webpack-dev-server/client?http://localhost:${options.port}/`, 'webpack/hot/dev-server', path.resolve(options.src, 'index.html'))
|
|
119
|
+
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
|
|
120
|
+
config.plugins.unshift(new webpack.HotModuleReplacementPlugin())
|
|
121
|
+
config.output.publicPath = `http://localhost:${options.port}/`
|
|
122
|
+
config.devtool = 'source-map'
|
|
123
|
+
config.devServer = {
|
|
124
|
+
static: path.resolve(options.src),
|
|
125
|
+
publicPath: `http://localhost:${options.port}/`,
|
|
126
|
+
inline: true
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
config.plugins.unshift(
|
|
130
|
+
new CleanWebpackPlugin([path.basename(options.build), path.basename(options.build) + '.zip'], {
|
|
131
|
+
root: path.resolve(options.build, '..'),
|
|
132
|
+
verbose: false
|
|
133
|
+
}),
|
|
134
|
+
new webpack.DefinePlugin({
|
|
135
|
+
'process.env': {
|
|
136
|
+
NODE_ENV: JSON.stringify('production')
|
|
137
|
+
}
|
|
138
|
+
}),
|
|
139
|
+
new UglifyJsPlugin({
|
|
140
|
+
uglifyOptions: {
|
|
141
|
+
warnings: false,
|
|
142
|
+
mangle: true,
|
|
143
|
+
extractComments: false
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
if (options.mode === 'run') {
|
|
149
|
+
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return config
|
|
154
|
+
}
|
package/dist/electron.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { app, BrowserWindow } from 'electron';
|
|
3
|
-
import remoteMain from '@electron/remote/main/index.js';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
import commandLineArgs from 'command-line-args';
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
const optionDefinitions = [
|
|
10
|
-
{ name: 'externals', type: String, defaultValue: [], multiple: true },
|
|
11
|
-
{ name: 'src', type: String, defaultValue: path.join(__dirname, 'src') },
|
|
12
|
-
{ name: 'build', type: String, defaultValue: path.join(__dirname, 'build') },
|
|
13
|
-
{ name: 'config', type: String, defaultValue: './webpack.config.js' },
|
|
14
|
-
{ name: 'port', type: Number, defaultValue: 8080 },
|
|
15
|
-
{ name: 'mode', type: String, defaultValue: 'run' }
|
|
16
|
-
];
|
|
17
|
-
const options = commandLineArgs(optionDefinitions);
|
|
18
|
-
if (options.mode === 'watch') {
|
|
19
|
-
(await import('electron-debug')).default({ showDevTools: true });
|
|
20
|
-
}
|
|
21
|
-
remoteMain.initialize();
|
|
22
|
-
let mainWindow = null;
|
|
23
|
-
function createWindow() {
|
|
24
|
-
mainWindow = new BrowserWindow({
|
|
25
|
-
show: false,
|
|
26
|
-
x: 100,
|
|
27
|
-
y: 100,
|
|
28
|
-
width: 1024,
|
|
29
|
-
height: 768,
|
|
30
|
-
webPreferences: {
|
|
31
|
-
nodeIntegrationInSubFrames: true,
|
|
32
|
-
allowRunningInsecureContent: true,
|
|
33
|
-
nodeIntegration: true,
|
|
34
|
-
contextIsolation: false,
|
|
35
|
-
webSecurity: false,
|
|
36
|
-
webviewTag: true
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
remoteMain.enable(mainWindow.webContents);
|
|
40
|
-
const launcherPath = path.join(__dirname, 'launcher.html');
|
|
41
|
-
const launcherURL = `file://${launcherPath}`;
|
|
42
|
-
mainWindow.loadURL(launcherURL);
|
|
43
|
-
// mainWindow.webContents.openDevTools({ mode: 'detach' })
|
|
44
|
-
mainWindow.webContents.once('did-finish-load', () => {
|
|
45
|
-
mainWindow?.show();
|
|
46
|
-
mainWindow?.webContents.send('init', options);
|
|
47
|
-
});
|
|
48
|
-
mainWindow.on('closed', () => (mainWindow = null));
|
|
49
|
-
}
|
|
50
|
-
app.whenReady().then(() => {
|
|
51
|
-
createWindow();
|
|
52
|
-
app.on('activate', () => {
|
|
53
|
-
if (BrowserWindow.getAllWindows().length === 0) {
|
|
54
|
-
createWindow();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
app.on('window-all-closed', () => app.quit());
|
package/dist/launcher.html
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" xml:lang="en" style="width: 100%; height: 100%; margin: 0; padding: 0;">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<title></title>
|
|
7
|
-
</head>
|
|
8
|
-
|
|
9
|
-
<body style="width: 100%; height: 100%; margin: 0; padding: 0;">
|
|
10
|
-
<webview id="webview" style="width: 100%; height: 100%;" partition="persist:webview"></webview>
|
|
11
|
-
|
|
12
|
-
<script>
|
|
13
|
-
const path = require('path')
|
|
14
|
-
let ModuleController;
|
|
15
|
-
try {
|
|
16
|
-
const moduleControllerModule = require('@vixoniccom/module-controller');
|
|
17
|
-
ModuleController = moduleControllerModule.default;
|
|
18
|
-
} catch (err) {
|
|
19
|
-
console.error('[WEBVIEW] NO se pudo cargar ModuleController', err);
|
|
20
|
-
}
|
|
21
|
-
const { ipcRenderer } = require('electron')
|
|
22
|
-
const remote = require('@electron/remote')
|
|
23
|
-
|
|
24
|
-
ipcRenderer.on('init', (event, options) => {
|
|
25
|
-
const webview = document.getElementById('webview')
|
|
26
|
-
const win = remote.getCurrentWindow()
|
|
27
|
-
|
|
28
|
-
webview.setAttribute('nodeintegration', '')
|
|
29
|
-
webview.setAttribute('webpreferences', 'webSecurity=false, allowRunningInsecureContent=true, nodeIntegration=yes, contextIsolation=no')
|
|
30
|
-
|
|
31
|
-
webview.addEventListener('did-finish-load', () => {
|
|
32
|
-
win.show()
|
|
33
|
-
win.focus()
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const resolvedSrc = options.mode === 'watch'
|
|
37
|
-
? `http://localhost:${options.port}/index.html`
|
|
38
|
-
: `file://${path.join(options.build, 'index.html')}`
|
|
39
|
-
|
|
40
|
-
webview.src = resolvedSrc
|
|
41
|
-
|
|
42
|
-
function getData() {
|
|
43
|
-
const data = {}
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
data.parameters = require(path.join(options.src, '/test/parameters.json')).parameters
|
|
47
|
-
} catch (err) {
|
|
48
|
-
console.log('No parameters:', err.message)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let escaped = path.join(options.mode === 'watch' ? options.src : options.build, 'test', 'downloads')
|
|
52
|
-
|
|
53
|
-
// Add file:// to watch because in this mode the app will be in a localhost hosted environment.
|
|
54
|
-
if (options.mode === 'watch') escaped = `file://${escaped}`
|
|
55
|
-
escaped = escaped.replace(/\\/g, '/')
|
|
56
|
-
|
|
57
|
-
data.downloadsPath = escaped
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
data.services = require(path.join(options.src, '/test/services.json')).services
|
|
62
|
-
} catch (err) {
|
|
63
|
-
console.log('No services:', err.message)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return data
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function getSchema() {
|
|
70
|
-
try {
|
|
71
|
-
return require(path.join(options.src, '../configuration.json')).schema
|
|
72
|
-
} catch (err) {
|
|
73
|
-
console.log('No schema:', err.message)
|
|
74
|
-
return {}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const data = getData()
|
|
79
|
-
const schema = getSchema()
|
|
80
|
-
|
|
81
|
-
ModuleController.init(win, webview, data, schema, options.mode === 'watch')
|
|
82
|
-
})
|
|
83
|
-
</script>
|
|
84
|
-
</body>
|
|
85
|
-
|
|
86
|
-
</html>
|