@vixoniccom/module-packager 2.7.0-test.2 → 2.7.0-test.4

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 CHANGED
@@ -2,6 +2,15 @@
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.4](https://gitlab.com/mandomedio/vixonic/module-packager/compare/v2.7.0-test.3...v2.7.0-test.4) (2022-07-15)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **release:** __dirname was added to path resolves and joins ([7312c9a](https://gitlab.com/mandomedio/vixonic/module-packager/commit/7312c9a316c4039dd63c979754d97733c6159a90))
11
+
12
+ ## [2.7.0-test.3](https://gitlab.com/mandomedio/vixonic/module-packager/compare/v2.7.0-test.2...v2.7.0-test.3) (2022-07-15)
13
+
5
14
  ## [2.7.0-test.2](https://gitlab.com/mandomedio/vixonic/module-packager/compare/v2.7.0-test.1...v2.7.0-test.2) (2022-07-15)
6
15
 
7
16
 
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(options.build, 'index.html')}`
21
+ webview.src = options.mode === 'watch' ? `http://localhost:${options.port}/index.html` : `file://${path.join(__dirname, options.build, 'index.html')}`
22
22
 
23
23
  function getData () {
24
24
  let data = {}
25
25
  try {
26
- data.parameters = require(path.join(options.src, '/test/parameters.json')).parameters
26
+ data.parameters = require(path.join(__dirname, 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(options.mode === 'watch' ? options.src : options.build, 'test', 'downloads')
31
+ let escaped = path.join(__dirname, 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(options.src, '/test/services.json')).services
40
+ data.services = require(path.join(__dirname, 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(options.src, '../configuration.json')).schema
52
+ data = require(path.join(__dirname, options.src, '../configuration.json')).schema
53
53
  } catch (err) {
54
54
  console.log('No schema.')
55
55
  }
package/main.js CHANGED
@@ -5,10 +5,10 @@ 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' },
11
- { name: 'config', type: String, defaultValue: './webpack.config.js' },
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
12
  { name: 'port', type: Number, defaultValue: 8080 },
13
13
  { name: 'mode', type: String, defaultValue: 'build' },
14
14
  { name: 'transpileOnly', type: Boolean },
@@ -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(options.src, '..', 'node_modules', x, 'package.json'))).version}`
76
+ return `${x}@${JSON.parse(fs.readFileSync(path.resolve(__dirname, 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(options.build, '../', 'build.zip'))
98
+ let output = fs.createWriteStream(path.resolve(__dirname, options.build, '../', 'build.zip'))
99
99
  let archive = archiver('zip')
100
100
  archive.pipe(output)
101
- archive.directory(path.resolve(options.build), './')
101
+ archive.directory(path.resolve(__dirname, 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(options.src)} --build ${path.resolve(options.build)} --port ${options.port} --mode ${options.mode} --config ${options.config} --externals ${options.externals}`,
124
+ exec(`npm start -- ${path.join(__dirname, 'electron.js')} --src ${path.resolve(__dirname, options.src)} --build ${path.resolve(__dirname, 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(options.src)} --build ${path.resolve(options.build)} --port ${options.port} --mode ${options.mode} --config ${options.config} --externals ${options.externals}`,
140
+ exec(`npm start -- ${path.join(__dirname, 'electron.js')} --src ${path.resolve(__dirname, options.src)} --build ${path.resolve(__dirname, 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(options.confDefinition, 'index.ts')).configuration
151
+ return require(path.resolve(__dirname, 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(options.src, 'parameters.d.ts'), configuration.declarationFileString)
158
- fs.writeFileSync(path.resolve(options.src, '..', 'configuration.json'), JSON.stringify(configuration, undefined, 2))
157
+ fs.writeFileSync(path.resolve(__dirname, options.src, 'parameters.d.ts'), configuration.declarationFileString)
158
+ fs.writeFileSync(path.resolve(__dirname, 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(options.src, '../', 'configuration.json'))
169
+ const json = require(path.resolve(__dirname, options.src, '../', 'configuration.json'))
170
170
  const conf = Configuration.fromJSON(json)
171
171
  if (conf.durationFormula) {
172
- const values = require(path.resolve(options.src, 'test', 'parameters.json'))
172
+ const values = require(path.resolve(__dirname, 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
@@ -104,7 +104,7 @@
104
104
  "prerelease-test": "standard-version --prerelease test",
105
105
  "release": "standard-version"
106
106
  },
107
- "version": "2.7.0-test.2",
107
+ "version": "2.7.0-test.4",
108
108
  "devDependencies": {
109
109
  "standard-version": "^9.3.1"
110
110
  }
package/webpack.config.js CHANGED
@@ -19,14 +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(options.src, 'static'), path.join(options.src, 'test')]
23
- : [path.resolve(options.src, 'static'), path.resolve(options.src, 'test')]
22
+ ? [path.join(__dirname, options.src, 'static'), path.join(__dirname, options.src, 'test')]
23
+ : [path.resolve(__dirname, options.src, 'static'), path.resolve(__dirname, options.src, 'test')]
24
24
 
25
+ console.log('Options: ', options, options.src)
25
26
  let config = {
26
27
  context: __dirname,
27
- entry: ['babel-polyfill', path.resolve(options.src, 'main')],
28
+ entry: ['babel-polyfill', path.resolve(__dirname, options.src, 'main')],
28
29
  output: {
29
- path: path.resolve(options.build),
30
+ path: path.resolve(__dirname, options.build),
30
31
  filename: 'main.js'
31
32
  },
32
33
  node: {
@@ -52,9 +53,9 @@ module.exports = (options) => {
52
53
  },
53
54
  {
54
55
  test: /\.(j|t)sx?$/,
55
- include: [path.resolve(options.src)],
56
+ include: [path.resolve(__dirname, options.src)],
56
57
  exclude: exclude,
57
- loaders: [
58
+ rules: [
58
59
  {
59
60
  loader: 'babel-loader?babelrc=false&extends=' + path.join(__dirname, '/.babelrc')
60
61
  },
@@ -92,16 +93,16 @@ module.exports = (options) => {
92
93
  if (options.mode !== 'watch' || request === 'electron') {
93
94
  return callback(null, "require('" + request + "')")
94
95
  } else {
95
- return callback(null, "require('" + path.resolve(options.src, '..', 'node_modules', request).replace(/\\/g, '\\\\') + "')")
96
+ return callback(null, "require('" + path.resolve(__dirname, options.src, '..', 'node_modules', request).replace(/\\/g, '\\\\') + "')")
96
97
  }
97
98
  }
98
99
  callback()
99
100
  },
100
101
  plugins: [
101
- new CopyWebpackPlugin([{ from: path.resolve(options.src, 'static'), to: 'static/' }], { copyUnmodified: true }),
102
+ new CopyWebpackPlugin([{ from: path.resolve(__dirname, options.src, 'static'), to: 'static/' }], { copyUnmodified: true }),
102
103
  new HtmlWebpackPlugin({
103
104
  inject: 'head',
104
- template: path.resolve(options.src, 'index.html')
105
+ template: path.resolve(__dirname, options.src, 'index.html')
105
106
  }),
106
107
  new webpack.LoaderOptionsPlugin({
107
108
  options: {
@@ -121,20 +122,20 @@ module.exports = (options) => {
121
122
  }
122
123
 
123
124
  if (options.mode === 'watch') {
124
- config.entry.unshift(`webpack-dev-server/client?http://localhost:${options.port}/`, 'webpack/hot/dev-server', path.resolve(options.src, 'index.html'))
125
- config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
125
+ config.entry.unshift(`webpack-dev-server/client?http://localhost:${options.port}/`, 'webpack/hot/dev-server', path.resolve(__dirname, options.src, 'index.html'))
126
+ config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(__dirname, options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
126
127
  config.plugins.unshift(new webpack.HotModuleReplacementPlugin())
127
128
  config.output.publicPath = `http://localhost:${options.port}/`
128
129
  config.devtool = 'source-map'
129
130
  config.devServer = {
130
- contentBase: path.resolve(options.src),
131
+ contentBase: path.resolve(__dirname, options.src),
131
132
  publicPath: `http://localhost:${options.port}/`,
132
133
  inline: true
133
134
  }
134
135
  } else {
135
136
  config.plugins.unshift(
136
137
  new CleanWebpackPlugin([path.basename(options.build), path.basename(options.build) + '.zip'], {
137
- root: path.resolve(options.build, '..'),
138
+ root: path.resolve(__dirname, options.build, '..'),
138
139
  verbose: false
139
140
  }),
140
141
  new webpack.DefinePlugin({
@@ -152,7 +153,7 @@ module.exports = (options) => {
152
153
  )
153
154
 
154
155
  if (options.mode === 'run') {
155
- config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
156
+ config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(__dirname, options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
156
157
  }
157
158
  }
158
159