@zumerbox/build 0.2.0 → 0.4.0

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,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ #### [v0.4.0](https://github.com/zumerlab/zumerbox-build/compare/v0.3.0...v0.4.0)
6
+
7
+ > 4 April 2024
8
+
9
+ - Fix package.json path and set minify true as default [`a12d2fb`](https://github.com/zumerlab/zumerbox-build/commit/a12d2fbd10683ea03727e8ef6b1a2ab856fc1653)
10
+ - Bumped version [`05bb751`](https://github.com/zumerlab/zumerbox-build/commit/05bb75106ed737dc2c3f48c1eafadf68a0ee3552)
11
+
12
+ #### [v0.3.0](https://github.com/zumerlab/zumerbox-build/compare/v0.2.0...v0.3.0)
13
+
14
+ > 27 March 2024
15
+
16
+ - feat: add options to bundle code [`b3b8d57`](https://github.com/zumerlab/zumerbox-build/commit/b3b8d571fa0eff711dc181a6f0410cac38bf5831)
17
+ - Bumped version [`4785829`](https://github.com/zumerlab/zumerbox-build/commit/4785829190d0dee78d19d0e39730c222c2597de8)
18
+
5
19
  #### [v0.2.0](https://github.com/zumerlab/zumerbox-build/compare/v0.1.1...v0.2.0)
6
20
 
7
21
  > 25 March 2024
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Juan Martin Muda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @zumerbox/build
2
2
 
3
- A lightweight build tool for compiling and bundling your project assets.
3
+ The Zumerbox build tool is a command-line utility designed to bundle and compile JavaScript and SCSS files into distributable formats. It leverages the esbuild library for efficient bundling and minification, providing developers with a streamlined workflow for frontend development.
4
+
5
+ Refer to the [ZumerBox bundle](https://github.com/zumerlab/zumerbox) for more information and tools.
4
6
 
5
7
  ## Installation
6
8
 
@@ -8,11 +10,31 @@ A lightweight build tool for compiling and bundling your project assets.
8
10
  npm install @zumerbox/build --save-dev
9
11
  ```
10
12
 
11
- ## Usage
13
+ ## Usage:
12
14
 
13
15
  ```bash
14
- npx @zumerbox/build
16
+ npx @zumerbox/build --name <bundler_name> --js <path_to_js_file> --scss <path_to_scss_file> [options]
15
17
  ```
16
18
 
17
- Refer to the [ZumerBox bundle](https://github.com/zumerlab/zumerbox) for more information.
18
- ```
19
+ ## Options:
20
+
21
+ - `--name (-n)`: Specifies the name of the bundler. If not provided, it will attempt to use the name from the package.json file. If the name is not available in package.json, it will default to "MyBundler".
22
+ - `--js (-j)`: Specifies the path to the JavaScript file (optional).
23
+ - `--scss (-s)`: Specifies the path to the SCSS file (optional).
24
+ - `--minify (-m)`: Generates minified output files (JavaScript and CSS) if enabled.
25
+ - `--outdir (-d)`: Specifies the destination folder for the output files. Default is "dist".
26
+ - `--platform (-p)`: Specifies the target platform for esBuild. Default is "browser".
27
+ - `--help (-h)`: Displays the help message.
28
+
29
+
30
+ ## Functionality:
31
+ - **Input files**: Specify the JavaScript and SCSS files to be bundled using the command-line options.
32
+ - **Bundling**: The tool utilizes esbuild to bundle the provided JavaScript and SCSS files into distributable formats.
33
+ - **Minification**: Optionally, the tool can minify the output files by setting the '--minify' flag.
34
+ - **Package information**: The tool reads package.json from the project directory to extract metadata such as name, version, author, and license. This information is included as a banner in the output files.
35
+ - **Output directory**: Output files are saved to the specified output directory ('dist' by default).
36
+ - **Error handling**: The tool gracefully handles errors during the bundling process and exits with an error code if an error occurs.
37
+
38
+ ## Credits:
39
+
40
+ This tools is powered by esbuild (https://esbuild.github.io/)
package/bin/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const esbuild = require('esbuild')
4
- const path = require('path')
5
- const yargs = require('yargs')
6
- const sassPlugin = require('esbuild-plugin-sass')
3
+ const esbuild = require('esbuild');
4
+ const path = require('path');
5
+ const yargs = require('yargs');
6
+ const sassPlugin = require('esbuild-plugin-sass');
7
7
 
8
8
  // Define command-line options using yargs
9
9
  const argv = yargs
@@ -11,26 +11,23 @@ const argv = yargs
11
11
  .option('name', {
12
12
  alias: 'n',
13
13
  describe: 'Name of the bundler',
14
- demandOption: true,
15
14
  type: 'string'
16
15
  })
17
16
  .option('js', {
18
17
  alias: 'j',
19
18
  describe: 'Path to JavaScript file',
20
- demandOption: true,
21
19
  type: 'string'
22
20
  })
23
21
  .option('scss', {
24
22
  alias: 's',
25
23
  describe: 'Path to SCSS file',
26
- demandOption: true,
27
24
  type: 'string'
28
25
  })
29
26
  .option('minify', {
30
27
  alias: 'm',
31
- describe: 'Generate minified output files (JavaScript and CSS)',
28
+ describe: 'Generate minified output files',
32
29
  type: 'boolean',
33
- default: false
30
+ default: true
34
31
  })
35
32
  .option('outdir', {
36
33
  alias: 'd',
@@ -38,46 +35,73 @@ const argv = yargs
38
35
  type: 'string',
39
36
  default: 'dist'
40
37
  })
38
+ .option('platform', {
39
+ alias: 'p',
40
+ describe: 'Target platform for esBuild (e.g., browser, node)',
41
+ type: 'string',
42
+ default: 'browser'
43
+ })
41
44
  .help('h')
42
- .alias('h', 'help').argv
45
+ .alias('h', 'help').argv;
43
46
 
44
47
  // Read package.json from project directory
45
- const packageJsonPath = path.resolve(__dirname, '../package.json')
46
- const pkg = require(packageJsonPath)
48
+ const packageJsonPath = './package.json';
49
+ const pkg = require(packageJsonPath);
50
+
51
+ // Use package name from package.json if no name provided
52
+ const bundlerName = argv.name || pkg.name || 'MyBundler';
47
53
 
48
- // Extract name from package.json
49
- const bundlerName = pkg.name || 'MyBundler'
50
- const setBanner = () => `
54
+ let setBanner
55
+ if (pkg) {
56
+ setBanner = () => `
51
57
  /*
52
- * ${pkg.name}
58
+ * ${bundlerName}
53
59
  * v.${pkg.version}
54
60
  * Author ${pkg.author}
55
61
  * License ${pkg.license}
56
- **/`
62
+ **/`;
63
+
64
+ } else {
65
+ setBanner = () => `
66
+ /*
67
+ * ${bundlerName}
68
+ **/`;
69
+
70
+ }
57
71
 
58
72
  // Configuration for esbuild
59
73
  const options = {
60
- entryPoints: [argv.scss, argv.js],
61
- entryNames: `${argv.name}`,
74
+ entryPoints: [],
75
+ entryNames: bundlerName,
62
76
  bundle: true,
63
77
  banner: {
64
78
  js: setBanner(),
65
79
  css: setBanner()
66
80
  },
67
- outdir: `${argv.outdir}`,
81
+ outdir: argv.outdir,
68
82
  metafile: true,
69
- plugins: [sassPlugin()]
83
+ plugins: [sassPlugin()],
84
+ platform: argv.platform
85
+ };
86
+
87
+ if (argv.js) {
88
+ options.entryPoints.push(argv.js);
89
+ }
90
+
91
+ if (argv.scss) {
92
+ options.entryPoints.push(argv.scss);
70
93
  }
71
94
 
72
95
  const optionsMinify = {
73
- entryPoints: [argv.scss, argv.js],
74
- entryNames: `${argv.name}.min`,
75
- outdir: `${argv.outdir}`,
96
+ entryPoints: options.entryPoints,
97
+ entryNames: `${bundlerName}.min`,
98
+ outdir: argv.outdir,
76
99
  bundle: true,
77
100
  metafile: true,
78
101
  minify: true,
79
- plugins: [sassPlugin()]
80
- }
102
+ plugins: [sassPlugin()],
103
+ platform: argv.platform
104
+ };
81
105
 
82
106
  // Run esbuild
83
107
  esbuild
@@ -87,5 +111,5 @@ esbuild
87
111
  esbuild.build(optionsMinify)
88
112
  : console.log('⚡ Minify skipped ⚡')
89
113
  )
90
- .then(() => console.log('⚡ Styles & Scripts Compiled! ⚡ '))
91
- .catch(() => process.exit(1))
114
+ .then(() => console.log('⚡ Files compiled! ⚡ '))
115
+ .catch(() => process.exit(1));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zumerbox/build",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "",
5
5
  "author": "Juan Martin Muda",
6
6
  "license": "MIT",
@@ -10,8 +10,8 @@
10
10
  },
11
11
  "scripts": {
12
12
  "start": "node bin/index.js",
13
- "release": "npx @zumerbox/release",
14
- "postversion": "npx @zumerbox/changelog && git add CHANGELOG.md && git commit -m \"Bumped version\" && git push --follow-tags"
13
+ "bump": "npx @zumerbox/bump",
14
+ "postbump": "npx @zumerbox/changelog && git add CHANGELOG.md && git commit -m \"Bumped version\" && git push --follow-tags"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",