@vixoniccom/module-packager 2.7.0-test.6 → 2.7.0-test.7
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/CHANGELOG.md +7 -0
- package/index.html +5 -5
- package/main.js +13 -13
- package/package.json +1 -1
- package/webpack.config.js +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [2.7.0-test.7](https://gitlab.com/mandomedio/vixonic/module-packager/compare/v2.7.0-test.6...v2.7.0-test.7) (2022-07-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **Release:** revert __dirname changes ([bb25fe1](https://gitlab.com/mandomedio/vixonic/module-packager/commit/bb25fe10ed9a9368c145530aecdc91f539877a26))
|
|
11
|
+
|
|
5
12
|
## [2.7.0-test.6](https://gitlab.com/mandomedio/vixonic/module-packager/compare/v2.7.0-test.5...v2.7.0-test.6) (2022-07-15)
|
|
6
13
|
|
|
7
14
|
|
package/index.html
CHANGED
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
win.show()
|
|
19
19
|
win.focus()
|
|
20
20
|
})
|
|
21
|
-
webview.src = options.mode === 'watch' ? `http://localhost:${options.port}/index.html` : `file://${path.join(
|
|
21
|
+
webview.src = options.mode === 'watch' ? `http://localhost:${options.port}/index.html` : `file://${path.join(options.build, 'index.html')}`
|
|
22
22
|
|
|
23
23
|
function getData () {
|
|
24
24
|
let data = {}
|
|
25
25
|
try {
|
|
26
|
-
data.parameters = require(path.join(
|
|
26
|
+
data.parameters = require(path.join(options.src, '/test/parameters.json')).parameters
|
|
27
27
|
} catch (err) {
|
|
28
28
|
console.log('No parameters.')
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
let escaped = path.join(
|
|
31
|
+
let escaped = path.join(options.mode === 'watch' ? options.src : options.build, 'test', 'downloads')
|
|
32
32
|
|
|
33
33
|
// Add file:// to watch because in this mode the app will be in a localhost hosted environment.
|
|
34
34
|
if (options.mode === 'watch') escaped = `file://${escaped}`
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
data.downloadsPath = escaped
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
|
-
data.services = require(path.join(
|
|
40
|
+
data.services = require(path.join(options.src, '/test/services.json')).services
|
|
41
41
|
console.log(data.services)
|
|
42
42
|
} catch (err) {
|
|
43
43
|
console.log('No services.')
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
function getSchema () {
|
|
50
50
|
let data = {}
|
|
51
51
|
try {
|
|
52
|
-
data = require(path.join(
|
|
52
|
+
data = require(path.join(options.src, '../configuration.json')).schema
|
|
53
53
|
} catch (err) {
|
|
54
54
|
console.log('No schema.')
|
|
55
55
|
}
|
package/main.js
CHANGED
|
@@ -5,9 +5,9 @@ const commandLineArgs = require('command-line-args')
|
|
|
5
5
|
const optionDefinitions = [
|
|
6
6
|
{ name: 'externals', type: String, defaultValue: [], multiple: true },
|
|
7
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' },
|
|
8
|
+
{ name: 'src', type: String, defaultValue: './src' },
|
|
9
|
+
{ name: 'build', type: String, defaultValue: './build' },
|
|
10
|
+
{ name: 'confDefinition', type: String, defaultValue: './configuration' },
|
|
11
11
|
{ name: 'config', type: String, defaultValue: './webpack.config.js' },
|
|
12
12
|
{ name: 'port', type: Number, defaultValue: 8080 },
|
|
13
13
|
{ name: 'mode', type: String, defaultValue: 'build' },
|
|
@@ -73,7 +73,7 @@ function pack (callback) {
|
|
|
73
73
|
function installExternals (callback) {
|
|
74
74
|
// Get external versions.
|
|
75
75
|
let externals = options.externals.map(x => {
|
|
76
|
-
return `${x}@${JSON.parse(fs.readFileSync(path.resolve(
|
|
76
|
+
return `${x}@${JSON.parse(fs.readFileSync(path.resolve(options.src, '..', 'node_modules', x, 'package.json'))).version}`
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
// Install external versions.
|
|
@@ -95,10 +95,10 @@ function installExternals (callback) {
|
|
|
95
95
|
|
|
96
96
|
function zip (callback) {
|
|
97
97
|
console.log(clc.blue('Archiving...'))
|
|
98
|
-
let output = fs.createWriteStream(path.resolve(
|
|
98
|
+
let output = fs.createWriteStream(path.resolve(options.build, '../', 'build.zip'))
|
|
99
99
|
let archive = archiver('zip')
|
|
100
100
|
archive.pipe(output)
|
|
101
|
-
archive.directory(path.resolve(
|
|
101
|
+
archive.directory(path.resolve(options.build), './')
|
|
102
102
|
archive.finalize()
|
|
103
103
|
|
|
104
104
|
output.on('close', function () {
|
|
@@ -121,7 +121,7 @@ function watch () {
|
|
|
121
121
|
var environment = process.env
|
|
122
122
|
environment.NODE_ENV = 'development'
|
|
123
123
|
|
|
124
|
-
exec(`npm start -- ${path.join(__dirname, 'electron.js')} --src ${path.resolve(
|
|
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
125
|
{
|
|
126
126
|
cwd: __dirname,
|
|
127
127
|
env: environment
|
|
@@ -137,7 +137,7 @@ function run () {
|
|
|
137
137
|
if (err) {
|
|
138
138
|
throw err
|
|
139
139
|
} else {
|
|
140
|
-
exec(`npm start -- ${path.join(__dirname, 'electron.js')} --src ${path.resolve(
|
|
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
141
|
{
|
|
142
142
|
cwd: __dirname
|
|
143
143
|
})
|
|
@@ -148,14 +148,14 @@ function run () {
|
|
|
148
148
|
function loadConfiguration () {
|
|
149
149
|
require('@vixoniccom/modules')
|
|
150
150
|
require('ts-node').register({compilerOptions: { moduleResolution: 'node', module: 'commonjs', target: 'es2015', checkJs: false }})
|
|
151
|
-
return require(path.resolve(
|
|
151
|
+
return require(path.resolve(options.confDefinition, 'index.ts')).configuration
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
function generateConfiguration () {
|
|
155
155
|
try {
|
|
156
156
|
let configuration = loadConfiguration()
|
|
157
|
-
fs.writeFileSync(path.resolve(
|
|
158
|
-
fs.writeFileSync(path.resolve(
|
|
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
159
|
console.log(clc.green(`Configuration generated`))
|
|
160
160
|
} catch (e) {
|
|
161
161
|
console.log(clc.red('Configuration generation failed'))
|
|
@@ -166,10 +166,10 @@ function generateConfiguration () {
|
|
|
166
166
|
function validateConfiguration () {
|
|
167
167
|
try {
|
|
168
168
|
const { Configuration } = require('@vixoniccom/modules')
|
|
169
|
-
const json = require(path.resolve(
|
|
169
|
+
const json = require(path.resolve(options.src, '../', 'configuration.json'))
|
|
170
170
|
const conf = Configuration.fromJSON(json)
|
|
171
171
|
if (conf.durationFormula) {
|
|
172
|
-
const values = require(path.resolve(
|
|
172
|
+
const values = require(path.resolve(options.src, 'test', 'parameters.json'))
|
|
173
173
|
console.log('Validate duration')
|
|
174
174
|
console.log('Duration on undefined:', conf.getDuration({}), 'seconds')
|
|
175
175
|
console.log('Duration:', conf.getDuration(values.parameters), 'seconds')
|
package/package.json
CHANGED
package/webpack.config.js
CHANGED
|
@@ -19,15 +19,15 @@ module.exports = (options) => {
|
|
|
19
19
|
// const typescript = fs.existsSync(typescriptPath) ? path.join(__dirname, path.relative(__dirname, typescriptPath), '/') : 'typescript'
|
|
20
20
|
|
|
21
21
|
let exclude = options.mode === 'watch'
|
|
22
|
-
? [path.join(
|
|
23
|
-
: [path.resolve(
|
|
22
|
+
? [path.join(options.src, 'static'), path.join(options.src, 'test')]
|
|
23
|
+
: [path.resolve(options.src, 'static'), path.resolve(options.src, 'test')]
|
|
24
24
|
|
|
25
25
|
console.log('Options: ', options, options.src)
|
|
26
26
|
let config = {
|
|
27
27
|
context: __dirname,
|
|
28
|
-
entry: ['babel-polyfill', path.resolve(
|
|
28
|
+
entry: ['babel-polyfill', path.resolve(options.src, 'main')],
|
|
29
29
|
output: {
|
|
30
|
-
path: path.resolve(
|
|
30
|
+
path: path.resolve(options.build),
|
|
31
31
|
filename: 'main.js'
|
|
32
32
|
},
|
|
33
33
|
node: {
|
|
@@ -53,7 +53,7 @@ module.exports = (options) => {
|
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
test: /\.(j|t)sx?$/,
|
|
56
|
-
include: [path.resolve(
|
|
56
|
+
include: [path.resolve(options.src)],
|
|
57
57
|
exclude: exclude,
|
|
58
58
|
rules: [
|
|
59
59
|
{
|
|
@@ -93,16 +93,16 @@ module.exports = (options) => {
|
|
|
93
93
|
if (options.mode !== 'watch' || request === 'electron') {
|
|
94
94
|
return callback(null, "require('" + request + "')")
|
|
95
95
|
} else {
|
|
96
|
-
return callback(null, "require('" + path.resolve(
|
|
96
|
+
return callback(null, "require('" + path.resolve(options.src, '..', 'node_modules', request).replace(/\\/g, '\\\\') + "')")
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
callback()
|
|
100
100
|
},
|
|
101
101
|
plugins: [
|
|
102
|
-
new CopyWebpackPlugin([{ from: path.resolve(
|
|
102
|
+
new CopyWebpackPlugin([{ from: path.resolve(options.src, 'static'), to: 'static/' }], { copyUnmodified: true }),
|
|
103
103
|
new HtmlWebpackPlugin({
|
|
104
104
|
inject: 'head',
|
|
105
|
-
template: path.resolve(
|
|
105
|
+
template: path.resolve(options.src, 'index.html')
|
|
106
106
|
}),
|
|
107
107
|
new webpack.LoaderOptionsPlugin({
|
|
108
108
|
options: {
|
|
@@ -122,20 +122,20 @@ module.exports = (options) => {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
if (options.mode === 'watch') {
|
|
125
|
-
config.entry.unshift(`webpack-dev-server/client?http://localhost:${options.port}/`, 'webpack/hot/dev-server', path.resolve(
|
|
126
|
-
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(
|
|
125
|
+
config.entry.unshift(`webpack-dev-server/client?http://localhost:${options.port}/`, 'webpack/hot/dev-server', path.resolve(options.src, 'index.html'))
|
|
126
|
+
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
|
|
127
127
|
config.plugins.unshift(new webpack.HotModuleReplacementPlugin())
|
|
128
128
|
config.output.publicPath = `http://localhost:${options.port}/`
|
|
129
129
|
config.devtool = 'source-map'
|
|
130
130
|
config.devServer = {
|
|
131
|
-
static: path.resolve(
|
|
131
|
+
static: path.resolve(options.src),
|
|
132
132
|
publicPath: `http://localhost:${options.port}/`,
|
|
133
133
|
inline: true
|
|
134
134
|
}
|
|
135
135
|
} else {
|
|
136
136
|
config.plugins.unshift(
|
|
137
137
|
new CleanWebpackPlugin([path.basename(options.build), path.basename(options.build) + '.zip'], {
|
|
138
|
-
root: path.resolve(
|
|
138
|
+
root: path.resolve(options.build, '..'),
|
|
139
139
|
verbose: false
|
|
140
140
|
}),
|
|
141
141
|
new webpack.DefinePlugin({
|
|
@@ -153,7 +153,7 @@ module.exports = (options) => {
|
|
|
153
153
|
)
|
|
154
154
|
|
|
155
155
|
if (options.mode === 'run') {
|
|
156
|
-
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(
|
|
156
|
+
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|