poops 1.0.13 → 1.0.15

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.
@@ -1,4 +1,4 @@
1
- /* poops v1.0.13 | https://github.com/stamat/poops | MIT License */
1
+ /* poops v1.0.15 | https://github.com/stamat/poops | MIT License */
2
2
  "use strict";
3
3
  (() => {
4
4
  // example/src/js/scripts/utils.ts
@@ -1,2 +1,2 @@
1
- /* poops v1.0.13 | https://github.com/stamat/poops | MIT License */
2
- "use strict";(()=>{var e;new class{constructor(e,t){this.name=e,this.age=t}greet(){console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`)}}("Stamat",(new Date).getFullYear()-1988).greet(),console.log((e="hello").charAt(0).toUpperCase()+e.slice(1)),console.log([1,2,3,4,5].reduce(((e,t)=>e+t),0));var t,a=new Date;console.log(`${(t=a).getFullYear()}-${`${t.getMonth()+1}`.padStart(2,"0")}-${`${t.getDate()}`.padStart(2,"0")}`)})();
1
+ /* poops v1.0.15 | https://github.com/stamat/poops | MIT License */
2
+ "use strict";(()=>{function o(e){return e.charAt(0).toUpperCase()+e.slice(1)}function n(e){return e.reduce((t,a)=>t+a,0)}function r(e){const t=e.getFullYear(),a=`${e.getMonth()+1}`.padStart(2,"0"),u=`${e.getDate()}`.padStart(2,"0");return`${t}-${a}-${u}`}var l=class{constructor(e,t){this.name=e,this.age=t}greet(){console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`)}},s=new l("Stamat",new Date().getFullYear()-1988);s.greet(),console.log(o("hello")),console.log(n([1,2,3,4,5]));var c=new Date;console.log(r(c))})();
@@ -7,12 +7,11 @@
7
7
  <meta name="description" content="{{ site.description }}">
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
- <link rel="stylesheet" href="example/dist/css/styles.css">
10
+ <link rel="stylesheet" href="example/dist/css/styles.min.css">
11
11
  <link href="https://fonts.googleapis.com/css2?family=DM+Sans&family=Poppins:wght@700&display=swap" rel="stylesheet">
12
12
  <script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js"></script>
13
13
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
14
14
  <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
15
- <script type="text/javascript" src="example/dist/js/scripts.js"></script>
16
15
  </head>
17
16
  <body>
18
17
  {% block content %} {% endblock %}
@@ -88,5 +87,6 @@
88
87
  explode();
89
88
  </script>
90
89
  <script>hljs.highlightAll();</script>
90
+ <script async type="text/javascript" src="example/dist/js/scripts.min.js"></script>
91
91
  </body>
92
92
  </html>
@@ -2,6 +2,7 @@
2
2
  <h1><span id="poop"><img src="poop.png" alt="💩" width="160" height="160" class="d-block"></span><br>POOPS v{{package.version}}</h1>
3
3
  <a href="https://www.npmjs.com/package/poops"><img src="https://img.shields.io/badge/npm-CB3837.svg?style=for-the-badge&logo=npm&logoColor=white" alt="npm"></a> <a href="https://github.com/stamat/poops"><img src="https://img.shields.io/badge/GitHub-181717.svg?style=for-the-badge&logo=GitHub&logoColor=white" alt="github"></a>
4
4
  <p class="p2">{{ site.description }}</p>
5
+ <p class="p2">{{ page.subtitle }}</p>
5
6
 
6
7
  <div class="col-12 col-md-8 col-lg-5 mx-auto">
7
8
  <pre><code class="language-js text-left rounded-6 terminal">npm i poops</code></pre>
@@ -1,3 +1,6 @@
1
+ ---
2
+ subtitle: ✨ <strong>Now supports Front Matter!</strong> ✨
3
+ ---
1
4
  {% extends "layout.html" %}
2
5
 
3
6
  {% block content %}
package/index.html CHANGED
@@ -7,19 +7,19 @@
7
7
  <meta name="description" content="Straightforward, no-bullshit bundler for the web.">
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
- <link rel="stylesheet" href="example/dist/css/styles.css">
10
+ <link rel="stylesheet" href="example/dist/css/styles.min.css">
11
11
  <link href="https://fonts.googleapis.com/css2?family=DM+Sans&family=Poppins:wght@700&display=swap" rel="stylesheet">
12
12
  <script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js"></script>
13
13
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
14
14
  <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
15
- <script type="text/javascript" src="example/dist/js/scripts.js"></script>
16
15
  </head>
17
16
  <body>
18
17
 
19
18
  <header class="mt-32 container text-center">
20
- <h1><span id="poop"><img src="poop.png" alt="💩" width="160" height="160" class="d-block"></span><br>POOPS v1.0.13</h1>
19
+ <h1><span id="poop"><img src="poop.png" alt="💩" width="160" height="160" class="d-block"></span><br>POOPS v1.0.15</h1>
21
20
  <a href="https://www.npmjs.com/package/poops"><img src="https://img.shields.io/badge/npm-CB3837.svg?style=for-the-badge&logo=npm&logoColor=white" alt="npm"></a> <a href="https://github.com/stamat/poops"><img src="https://img.shields.io/badge/GitHub-181717.svg?style=for-the-badge&logo=GitHub&logoColor=white" alt="github"></a>
22
21
  <p class="p2">Straightforward, no-bullshit bundler for the web.</p>
22
+ <p class="p2">✨ <strong>Now supports Front Matter!</strong> ✨</p>
23
23
 
24
24
  <div class="col-12 col-md-8 col-lg-5 mx-auto">
25
25
  <pre><code class="language-js text-left rounded-6 terminal">npm i poops</code></pre>
@@ -74,7 +74,7 @@
74
74
 
75
75
  <script>document.write('<script src="http://'
76
76
  + (location.host || 'localhost').split(':')[0]
77
- + ':35730/livereload.js?snipver=1"></'
77
+ + ':35729/livereload.js?snipver=1"></'
78
78
  + 'script>')</script>
79
79
 
80
80
 
@@ -142,5 +142,6 @@
142
142
  explode();
143
143
  </script>
144
144
  <script>hljs.highlightAll();</script>
145
+ <script async type="text/javascript" src="example/dist/js/scripts.min.js"></script>
145
146
  </body>
146
147
  </html>
package/lib/markups.js CHANGED
@@ -29,8 +29,12 @@ class RelativeLoader extends nunjucks.Loader {
29
29
  throw new Error(`Template not found: ${name}`)
30
30
  }
31
31
 
32
- // TODO: Here we can interpret header yaml and pass it as a context, just like Jekyll does
33
- const source = fs.readFileSync(fullPath, 'utf-8')
32
+ let source = fs.readFileSync(fullPath, 'utf-8')
33
+ const match = source.match(/^\s*---\s*([\s\S]*?)---\s*/)
34
+ if (match) {
35
+ source = source.slice(match[0].length) // Remove front matter
36
+ }
37
+
34
38
  return { src: source, path: fullPath, noCache: true }
35
39
  }
36
40
 
@@ -63,6 +67,10 @@ module.exports = class Markups {
63
67
  return str.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-')
64
68
  })
65
69
 
70
+ this.nunjucksEnv.addFilter('jsonify', obj => {
71
+ return JSON.stringify(obj)
72
+ })
73
+
66
74
  // Load global variables
67
75
 
68
76
  const pkgPath = path.join(process.cwd(), 'package.json')
@@ -82,8 +90,6 @@ module.exports = class Markups {
82
90
 
83
91
  this.loadDataFiles(this.config.markup.data)
84
92
 
85
- this.payload = {} // TODO: still not used. This is where we can store data from data files. Can be used to pass front matter data or even a way to pass data from files to templates
86
-
87
93
  if (!this.config.markup.out) {
88
94
  this.config.markup.out = process.cwd()
89
95
  }
@@ -108,7 +114,7 @@ module.exports = class Markups {
108
114
  const dataDir = pathIsDirectory(this.config.markup.in) ? this.config.markup.in : path.dirname(this.config.markup.in)
109
115
  const data = readDataFile(path.join(process.cwd(), dataDir, dataFile))
110
116
  const globalKeyName = path.basename(dataFile, path.extname(dataFile)).replace(/[.\-\s]/g, '_')
111
- // TODO: should support YAML too. There should be a way to define the data file per template through front matter
117
+
112
118
  promises.push(this.nunjucksEnv.addGlobal(globalKeyName, data))
113
119
  } catch (err) {
114
120
  console.log(`${pstyle.redBright + pstyle.bold}[error]${pstyle.reset}${pstyle.dim} Data file not found:${pstyle.reset} ${pstyle.italic + pstyle.underline}${dataFile}${pstyle.reset}`)
@@ -141,7 +147,19 @@ module.exports = class Markups {
141
147
  return `!(${markupDefaultExcludes.join('|')})/**/*.+(html|njk)`
142
148
  }
143
149
 
144
- compileEntry(templateName, context) {
150
+ compileEntry(templateName) {
151
+ const source = fs.readFileSync(templateName, 'utf-8')
152
+ const match = source.match(/^\s*---\s*([\s\S]*?)---\s*/) // Front matter match
153
+ const context = { page: {} }
154
+ if (match) {
155
+ try {
156
+ context.page = require('yaml').parse(match[1]) // Pass front matter to the template
157
+ } catch (err) {
158
+ console.log(`${pstyle.redBright + pstyle.bold}[error]${pstyle.reset}${pstyle.dim} Failed parsing front matter:${pstyle.reset} ${pstyle.italic + pstyle.underline}${templateName}${pstyle.reset}`)
159
+ console.log(err)
160
+ }
161
+ }
162
+
145
163
  const env = this.nunjucksEnv
146
164
  return new Promise((resolve, reject) => {
147
165
  env.getTemplate(templateName).render(context, (error, result) => {
@@ -176,7 +194,7 @@ module.exports = class Markups {
176
194
  fs.mkdirSync(markupOutDir, { recursive: true })
177
195
  }
178
196
 
179
- const compilePromise = this.compileEntry(file, this.payload).then((result) => {
197
+ const compilePromise = this.compileEntry(file).then((result) => {
180
198
  fs.writeFileSync(markupOut, result)
181
199
  })
182
200
  compilePromises.push(compilePromise)
@@ -193,7 +211,7 @@ module.exports = class Markups {
193
211
  })
194
212
  })
195
213
  } else {
196
- return this.compileEntry(markupIn, this.pkg).then((result) => {
214
+ return this.compileEntry(markupIn).then((result) => {
197
215
  fs.writeFileSync(path.join(process.cwd(), this.config.markup.out, path.basename(markupIn)), result)
198
216
  console.log(`${pstyle.cyanBright + pstyle.bold}[markup]${pstyle.reset} ${pstyle.dim}Compiled:${pstyle.reset} ${pstyle.italic + pstyle.underline}${path.relative(process.cwd(), path.join(process.cwd(), this.config.markup.out, path.basename(markupIn)))}${pstyle.reset}`)
199
217
  }).catch((err) => {
package/lib/scripts.js CHANGED
@@ -1,9 +1,8 @@
1
- const { buildSync } = require('esbuild')
1
+ const { build, transform } = require('esbuild')
2
2
  const deepmerge = require('deepmerge')
3
3
  const helpers = require('./utils/helpers.js')
4
4
  const fs = require('node:fs')
5
5
  const PrintStyle = require('./utils/print-style.js')
6
- const Terser = require('terser')
7
6
 
8
7
  const {
9
8
  pathExists,
@@ -49,10 +48,6 @@ module.exports = class Scripts {
49
48
  nodePaths: this.config.includePaths // Resolve `includePaths`
50
49
  }
51
50
 
52
- const terserOpts = {
53
- mangle: false
54
- }
55
-
56
51
  if (this.banner) {
57
52
  opts.banner = {
58
53
  js: this.banner,
@@ -75,20 +70,16 @@ module.exports = class Scripts {
75
70
  if (options.nodePaths) opts.nodePaths = [...new Set([...opts.nodePaths, ...options.nodePaths])]
76
71
  if (options.sourcemap) opts.sourcemap = options.sourcemap
77
72
 
78
- if (options.mangle) terserOpts.mangle = options.mangle
79
-
80
73
  const optionsClone = { ...options }
81
74
  delete optionsClone.justMinified
82
75
  delete optionsClone.minify
83
- delete optionsClone.mangle
84
76
 
85
77
  // TODO: Use my own implementation of deepmerge to reduce dependencies, and also my own deepclone
86
78
  deepmerge(opts, optionsClone) // ability to pass other esbuild options `node_modules/esbuild/lib/main.d.ts`
87
79
 
88
- // TODO: Actually loop the build process for each entry point!!!
89
80
  const esbuildStart = performance.now()
90
81
  try {
91
- buildSync(opts)
82
+ await build(opts)
92
83
  } catch (err) {
93
84
  console.log(`${pstyle.yellowBright + pstyle.bold}[script]${pstyle.reset} ${pstyle.redBright}[error]${pstyle.reset} ${pstyle.dim}Failed compiling:${pstyle.reset} ${pstyle.italic + pstyle.underline}${outfilePath}${pstyle.reset + pstyle.bell}`)
94
85
  console.log(err)
@@ -103,25 +94,27 @@ module.exports = class Scripts {
103
94
  if (options.sourcemap) console.log(`${pstyle.yellowBright + pstyle.bold}[script]${pstyle.reset} ${pstyle.dim}Compiled:${pstyle.reset} ${pstyle.italic + pstyle.underline}${newOutFilePath}.map${pstyle.reset}`)
104
95
 
105
96
  if (options.minify) {
106
- // TODO: Use esbuild transformSync instead of Terser here. Make sync things great again!
107
- const terserStart = performance.now()
108
- const minifyResult = await Terser.minify(fs.readFileSync(newOutFilePath, 'utf-8'), terserOpts)
109
- const terserEnd = performance.now()
97
+ try {
98
+ const terserStart = performance.now()
99
+ const minifyResult = await transform(fs.readFileSync(newOutFilePath, 'utf-8'), {
100
+ minify: true,
101
+ loader: 'js'
102
+ })
103
+ const terserEnd = performance.now()
110
104
 
111
- if (minifyResult.error) {
112
- console.log(`${pstyle.yellowBright + pstyle.bold}[script]${pstyle.reset} ${pstyle.redBright}[error]${pstyle.reset} ${pstyle.dim}Failed compiling:${pstyle.reset} ${pstyle.italic + pstyle.underline}${minPath}${pstyle.reset + pstyle.bell}`)
113
- console.log(minifyResult.error)
114
- } else {
115
105
  if (this.banner) minifyResult.code = this.banner + '\n' + minifyResult.code
116
106
  fs.writeFileSync(minPath, minifyResult.code)
117
107
  console.log(`${pstyle.yellowBright + pstyle.bold}[script]${pstyle.reset} ${pstyle.dim}Compiled:${pstyle.reset} ${pstyle.italic + pstyle.underline}${minPath}${pstyle.reset} ${pstyle.greenBright}${fileSize(minPath)}${pstyle.reset} ${pstyle.green}(${buildTime(terserStart, terserEnd)})${pstyle.reset}`)
108
+ } catch (err) {
109
+ console.log(`${pstyle.yellowBright + pstyle.bold}[script]${pstyle.reset} ${pstyle.redBright}[error]${pstyle.reset} ${pstyle.dim}Failed compiling:${pstyle.reset} ${pstyle.italic + pstyle.underline}${minPath}${pstyle.reset + pstyle.bell}`)
110
+ console.log(err)
118
111
  }
119
112
 
120
113
  if (options.justMinified) {
121
114
  fs.unlinkSync(newOutFilePath)
122
115
  }
123
116
  } else {
124
- fs.unlinkSync(minPath)
117
+ if (pathExists(minPath)) fs.unlinkSync(minPath)
125
118
  }
126
119
  }
127
120
  }
package/lib/styles.js CHANGED
@@ -1,10 +1,8 @@
1
- const autoprefixer = require('autoprefixer')
2
- const cssnano = require('cssnano')
1
+ const { transform } = require('esbuild')
3
2
  const fs = require('node:fs')
4
3
  const helpers = require('./utils/helpers.js')
5
4
  const path = require('node:path')
6
5
  const { pathToFileURL } = require('node:url')
7
- const postcss = require('postcss')
8
6
  const sass = require('sass')
9
7
  const PrintStyle = require('./utils/print-style.js')
10
8
 
@@ -107,7 +105,7 @@ module.exports = class Styles {
107
105
 
108
106
  outfilePath = buildStyleOutputFilePath(infilePath, outfilePath, options)
109
107
 
110
- const cssStart = performance.now()
108
+ const stylesStart = performance.now()
111
109
  let compiledSass
112
110
  try {
113
111
  compiledSass = sass.compile(infilePath, opts)
@@ -116,39 +114,43 @@ module.exports = class Styles {
116
114
  console.log(err)
117
115
  return
118
116
  }
117
+
119
118
  const mapsrc = options.sourcemap ? `\n/*# sourceMappingURL=${path.basename(outfilePath)}.map */` : ''
120
119
  if (this.banner) compiledSass.css = this.banner + '\n' + compiledSass.css
121
120
  fs.writeFileSync(outfilePath, compiledSass.css + mapsrc)
122
- const cssEnd = performance.now()
123
- if (!options.justMinified) console.log(`${pstyle.magentaBright + pstyle.bold}[style]${pstyle.reset} ${pstyle.dim}Compiled:${pstyle.reset} ${pstyle.italic + pstyle.underline}${outfilePath}${pstyle.reset} ${pstyle.greenBright}${fileSize(outfilePath)}${pstyle.reset} ${pstyle.green}(${buildTime(cssStart, cssEnd)})${pstyle.reset}`)
121
+ const stylesEnd = performance.now()
122
+ if (!options.justMinified) console.log(`${pstyle.magentaBright + pstyle.bold}[style]${pstyle.reset} ${pstyle.dim}Compiled:${pstyle.reset} ${pstyle.italic + pstyle.underline}${outfilePath}${pstyle.reset} ${pstyle.greenBright}${fileSize(outfilePath)}${pstyle.reset} ${pstyle.green}(${buildTime(stylesStart, stylesEnd)})${pstyle.reset}`)
124
123
 
125
124
  if (compiledSass.sourceMap) {
126
125
  if (this.banner) compiledSass.sourceMap.mappings = ';' + compiledSass.sourceMap.mappings
127
126
  fs.writeFileSync(`${outfilePath}.map`, JSON.stringify(compiledSass.sourceMap))
128
127
  console.log(`${pstyle.magentaBright + pstyle.bold}[style]${pstyle.reset} ${pstyle.dim}Compiled:${pstyle.reset} ${pstyle.italic + pstyle.underline}${outfilePath}.map${pstyle.reset}`)
129
128
  }
130
- const cssMinStart = performance.now()
129
+
131
130
  const minPath = insertMinSuffix(outfilePath)
132
131
  if (options.minify) {
133
- // TODO: Consider dropping postcss in favor of esbuild.transformSync. We don't need autoprefixer, let's prefix on our own.
134
- await postcss([autoprefixer, cssnano]).process(compiledSass.css, {
135
- from: outfilePath,
136
- to: minPath
137
- }).then(result => {
138
- if (this.banner) result.css = this.banner + '\n' + result.css
139
- fs.writeFileSync(minPath, result.css)
140
- const cssMinEnd = performance.now()
141
- console.log(`${pstyle.magentaBright + pstyle.bold}[style]${pstyle.reset} ${pstyle.dim}Compiled:${pstyle.reset} ${pstyle.italic + pstyle.underline}${minPath}${pstyle.reset} ${pstyle.greenBright}${fileSize(minPath)}${pstyle.reset} ${pstyle.green}(${buildTime(cssMinStart, cssMinEnd)})${pstyle.reset}`)
142
- }).catch((err) => {
132
+ try {
133
+ const stylesMinStart = !options.justMinified ? performance.now() : stylesStart
134
+
135
+ const minified = await transform(compiledSass.css, {
136
+ loader: 'css',
137
+ minify: true
138
+ })
139
+
140
+ if (this.banner) minified.code = this.banner + '\n' + minified.code
141
+ fs.writeFileSync(minPath, minified.code)
142
+ const stylesMinEnd = performance.now()
143
+ console.log(`${pstyle.magentaBright + pstyle.bold}[style]${pstyle.reset} ${pstyle.dim}Compiled:${pstyle.reset} ${pstyle.italic + pstyle.underline}${minPath}${pstyle.reset} ${pstyle.greenBright}${fileSize(minPath)}${pstyle.reset} ${pstyle.green}(${buildTime(stylesMinStart, stylesMinEnd)})${pstyle.reset}`)
144
+ } catch (err) {
143
145
  console.log(`${pstyle.magentaBright + pstyle.bold}[style]${pstyle.reset} ${pstyle.redBright}[error]${pstyle.reset} ${pstyle.dim}Failed compiling:${pstyle.reset} ${pstyle.italic + pstyle.underline}${minPath}${pstyle.reset + pstyle.bell}`)
144
146
  console.log(err)
145
- })
147
+ }
146
148
 
147
149
  if (options.justMinified) {
148
150
  fs.unlinkSync(outfilePath)
149
151
  }
150
152
  } else {
151
- fs.unlinkSync(minPath)
153
+ if (pathExists(minPath)) fs.unlinkSync(minPath)
152
154
  }
153
155
  }
154
156
  }
@@ -83,16 +83,18 @@ function readDataFile(filePath) {
83
83
  return fs.readFileSync(filePath, 'utf8')
84
84
  }
85
85
 
86
- exports.pathExists = pathExists
87
- exports.pathIsDirectory = pathIsDirectory
88
- exports.mkPath = mkPath
89
- exports.pathForFile = pathForFile
90
- exports.insertMinSuffix = insertMinSuffix
91
- exports.buildStyleOutputFilePath = buildStyleOutputFilePath
92
- exports.buildScriptOutputFilePath = buildScriptOutputFilePath
93
- exports.fillBannerTemplate = fillBannerTemplate
94
- exports.buildTime = buildTime
95
- exports.fileSize = fileSize
96
- exports.readJsonFile = readJsonFile
97
- exports.readYamlFile = readYamlFile
98
- exports.readDataFile = readDataFile
86
+ module.exports = {
87
+ pathExists,
88
+ pathIsDirectory,
89
+ mkPath,
90
+ pathForFile,
91
+ insertMinSuffix,
92
+ buildStyleOutputFilePath,
93
+ buildScriptOutputFilePath,
94
+ fillBannerTemplate,
95
+ buildTime,
96
+ fileSize,
97
+ readJsonFile,
98
+ readYamlFile,
99
+ readDataFile
100
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "poops",
3
3
  "description": "Straightforward, no-bullshit bundler for the web.",
4
- "version": "1.0.13",
4
+ "version": "1.0.15",
5
5
  "license": "MIT",
6
6
  "main": "poops.js",
7
7
  "repository": "https://github.com/stamat/poops.git",
@@ -26,20 +26,16 @@
26
26
  "lint": "eslint ./poops.js"
27
27
  },
28
28
  "dependencies": {
29
- "autoprefixer": "^10.4.14",
30
29
  "chokidar": "^3.5.3",
31
30
  "connect": "^3.7.0",
32
- "cssnano": "^6.0.1",
33
31
  "deepmerge": "^4.3.1",
34
- "esbuild": "^0.18.4",
32
+ "esbuild": "^0.19.3",
35
33
  "glob": "^10.3.1",
36
34
  "livereload": "^0.9.3",
37
35
  "nunjucks": "^3.2.4",
38
36
  "portscanner": "^2.2.0",
39
- "postcss": "^8.4.24",
40
37
  "sass": "^1.63.4",
41
38
  "serve-static": "^1.15.0",
42
- "terser": "^5.18.0",
43
39
  "yaml": "^2.3.1"
44
40
  },
45
41
  "devDependencies": {
package/poops.js CHANGED
@@ -86,7 +86,7 @@ for (let i = 0; i < args.length; i++) {
86
86
  }
87
87
 
88
88
  let configPath = path.join(cwd, defaultConfigPath)
89
- if (!pathExists(configPath)) configPath = path.join(cwd, '💩.json') //TODO: Ok dude, I know it's late, but you can do better than this.
89
+ if (!pathExists(configPath)) configPath = path.join(cwd, '💩.json') // TODO: Ok dude, I know it's late, but you can do better than this.
90
90
 
91
91
  // Main function 💩
92
92
  async function poops() {
@@ -127,7 +127,7 @@ async function poops() {
127
127
  exclusions: [...new Set(lrExcludes)],
128
128
  port: lport
129
129
  })
130
- console.log(`${pstyle.blue + pstyle.bold}[info]${pstyle.reset} ${pstyle.dim}🔃 LiveReload server:${pstyle.reset} ${pstyle.italic + pstyle.underline}http://localhost:${lrserver.config.port}${pstyle.reset}`)
130
+ console.log(`${pstyle.blue + pstyle.bold}[info]${pstyle.reset} ${pstyle.dim}🔃 LiveReload server:${pstyle.reset} ${pstyle.italic + pstyle.underline}http://localhost:${lrserver.config.port}${pstyle.reset}\n`)
131
131
  lrserver.watch(cwd)
132
132
  }
133
133
 
package/script/publish CHANGED
@@ -14,7 +14,7 @@ const readline = require('readline')
14
14
  const { exec } = require('child_process')
15
15
  const fs = require('fs')
16
16
  const path = require('path')
17
- let version = process.argv[2]
17
+ const argVersion = process.argv[2]
18
18
  const packageJson = require(path.join(process.cwd(), './package.json'))
19
19
 
20
20
  function question(prompt) {
@@ -102,29 +102,37 @@ async function init() {
102
102
  process.exit(1)
103
103
  }
104
104
 
105
- if (version && !isValidVersion(version)) {
106
- console.log('Invalid version: ', version)
105
+ if (argVersion && !isValidVersion(argVersion)) {
106
+ console.log('Invalid version: ', argVersion)
107
107
  console.log('Current version: ', packageJson.version)
108
108
  process.exit(1)
109
109
  }
110
110
 
111
- if (version && packageJson.version === version) {
112
- console.log('Version is already ', version)
111
+ if (argVersion && packageJson.version === argVersion) {
112
+ console.log('Version is already ', argVersion)
113
113
  process.exit(1)
114
114
  }
115
115
 
116
- if (!version) {
116
+ if (!argVersion) {
117
117
  console.log('Current version: ', packageJson.version)
118
- version = incrementPatchVersion(packageJson.version)
118
+ const version = incrementPatchVersion(packageJson.version)
119
119
  const answer = await question(`Do you want to increment the version to ${version}? (y/n) `)
120
120
  if (answer === 'y') {
121
121
  publish(version)
122
122
  } else {
123
- console.log('Aborted')
124
- process.exit(0)
123
+ const desiredVersion = await question(`Enter the desired version: (or press enter to use ${packageJson.version})`)
124
+ if (desiredVersion.trim() === '') {
125
+ publish(packageJson.version)
126
+ } else {
127
+ if (!isValidVersion(desiredVersion)) {
128
+ console.log('Invalid version: ', desiredVersion)
129
+ process.exit(1)
130
+ }
131
+ publish(desiredVersion)
132
+ }
125
133
  }
126
134
  } else {
127
- publish(version)
135
+ publish(argVersion)
128
136
  }
129
137
  }
130
138
  init()
@@ -7,8 +7,7 @@
7
7
  "minify": true,
8
8
  "justMinified": false,
9
9
  "format": "iife",
10
- "target": "es2019",
11
- "mangle": true
10
+ "target": "es2019"
12
11
  }
13
12
  }],
14
13
  "styles": [{