poops 1.0.18 → 1.0.20
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/README.md +71 -2
- package/lib/copy.js +121 -0
- package/lib/markups.js +226 -143
- package/lib/styles.js +65 -24
- package/lib/utils/helpers.js +197 -3
- package/package.json +8 -3
- package/poops.js +12 -1
- package/.eslintrc.yml +0 -10
- package/.github/dependabot.yml +0 -9
- package/.github/workflows/npm_publish.yml +0 -17
- package/.nojekyll +0 -1
- package/changelog/blog-functionality.html +0 -58
- package/changelog/feed.rss +0 -31
- package/changelog/front-matter.html +0 -61
- package/changelog/index.html +0 -74
- package/changelog/markdown-support.html +0 -56
- package/example/dist/css/styles.css +0 -7172
- package/example/dist/css/styles.css.map +0 -1
- package/example/dist/css/styles.min.css +0 -2
- package/example/dist/js/scripts.js +0 -35
- package/example/dist/js/scripts.js.map +0 -7
- package/example/dist/js/scripts.min.js +0 -2
- package/example/src/js/main.ts +0 -28
- package/example/src/js/scripts/utils.ts +0 -16
- package/example/src/markup/_data/features.yaml +0 -9
- package/example/src/markup/_data/links.json +0 -10
- package/example/src/markup/_data/poops.yaml +0 -7
- package/example/src/markup/_layouts/blog.html +0 -35
- package/example/src/markup/_layouts/default.html +0 -93
- package/example/src/markup/_partials/heading.html +0 -10
- package/example/src/markup/_partials/site-header.html +0 -17
- package/example/src/markup/changelog/blog-functionality.md +0 -9
- package/example/src/markup/changelog/feed.rss +0 -23
- package/example/src/markup/changelog/front-matter.md +0 -12
- package/example/src/markup/changelog/index.html +0 -30
- package/example/src/markup/changelog/markdown-support.md +0 -7
- package/example/src/markup/index.html +0 -33
- package/example/src/scss/_config.scss +0 -22
- package/example/src/scss/index.scss +0 -4
- package/example/src/scss/style/index.scss +0 -13
- package/example/src/scss/style/test.css +0 -3
- package/index.html +0 -166
- package/poop.png +0 -0
- package/script/build +0 -3
- package/script/publish +0 -138
- package/script/server +0 -3
- package/test.html +0 -96
- package/tsconfig.json +0 -16
- package//360/237/222/251.json +0 -55
package/README.md
CHANGED
|
@@ -41,6 +41,9 @@ It uses a simple config file where you define your input and output paths and it
|
|
|
41
41
|
* Live reloads on file changes (optional)
|
|
42
42
|
|
|
43
43
|
## Quick Start
|
|
44
|
+
|
|
45
|
+
> For a superfast start, you can use the Poops template repository: [💩🌪️Shitstorm](https://github.com/stamat/shitstorm)
|
|
46
|
+
|
|
44
47
|
You can install Poops globally:
|
|
45
48
|
|
|
46
49
|
```bash
|
|
@@ -117,6 +120,12 @@ Just create a `poops.json` file in the root of your project and add the followin
|
|
|
117
120
|
]
|
|
118
121
|
}
|
|
119
122
|
},
|
|
123
|
+
"copy": [
|
|
124
|
+
{
|
|
125
|
+
"in": "example/src/static",
|
|
126
|
+
"out": "example/dist"
|
|
127
|
+
}
|
|
128
|
+
],
|
|
120
129
|
"banner": "/* {{ name }} v{{ version }} | {{ homepage }} | {{ license }} License */",
|
|
121
130
|
"serve" : {
|
|
122
131
|
"port": 4040,
|
|
@@ -235,9 +244,9 @@ Poops can generate static pages for you. This feature is still under development
|
|
|
235
244
|
* `out` - the output path, can be only a directory path (for now)
|
|
236
245
|
* `site` (optional) - global data that will be available to all templates in the markup directory. Like site title, description, social media links, etc. You can then use this data in your templates `{{ site.title }}` for instance.
|
|
237
246
|
* `data` (optional) - is an array of JSON or YAML data files, that once loaded will be available to all templates in the markup directory. If you provide a path to a file for instance `links.json` with a `facebook` property, you can then use this data in your templates `{{ links.facebook }}`. The base name of the file will be used as the variable name, with spaces, dashes and dots replaced with underscores. So `the awesome-links.json` will be available as `{{ the_awesome_links.facebook }}` in your templates. The root directory of the data files is `in` directory. So if you have a `data` directory in your `in` directory, you can specify the data files like this `data: ["data/links.json"]`. The same goes for the YAML files.
|
|
238
|
-
* `includePaths`
|
|
247
|
+
* `includePaths` - an array of paths to directories that will be added to the nunjucks include paths. Useful if you want to separate template partials and layouts. For instance, if you have a `_includes` directory with a `header.njk` partial that you want to include in your markup, you can add it to the include paths and then include the templates like this `{% include "header.njk" %}`, without specifying the full path to the partial. This will change in the future, to provide better ignore and include patterns for the markup directories.
|
|
239
248
|
|
|
240
|
-
**💡 NOTE:** If, for instance, you are building a simple static onepager for your library, and want to pass a version variable from your `package.json`, Poops automatically reads your `package.json` if it exists in your working directory and sets the
|
|
249
|
+
**💡 NOTE:** If, for instance, you are building a simple static onepager for your library, and want to pass a version variable from your `package.json`, Poops automatically reads your `package.json` if it exists in your working directory and sets the global variable `package` to the parsed JSON. So you can use it in your markup files, for example like this: `{{ package.version }}`.
|
|
241
250
|
|
|
242
251
|
|
|
243
252
|
Here is a sample markup configuration:
|
|
@@ -270,6 +279,66 @@ If your project doesn't have markups, you can remove the `markups` property from
|
|
|
270
279
|
|
|
271
280
|
* `slugify` - slugifies a string. Usage: `{{ "My Awesome Title" | slugify }}` will output `my-awesome-title`
|
|
272
281
|
|
|
282
|
+
### Copy
|
|
283
|
+
|
|
284
|
+
Configuration entry to copy files or directories - copy your static files like images and fonts, for instance, from `src` to `dist` directory. This feature was added to enable moving static files if you deploy GitHub pages via a GitHub action. If you don't want to use this feature, simply exclude the `copy` property from your config file.
|
|
285
|
+
|
|
286
|
+
Here is a sample copy configuration which will copy the `static` directory and it's contents to the `dist` directory:
|
|
287
|
+
|
|
288
|
+
```JSON
|
|
289
|
+
{
|
|
290
|
+
"copy": {
|
|
291
|
+
"in": "src/static",
|
|
292
|
+
"out": "dist"
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
You can specify a list of input paths and pass them to an output directory, for instance:
|
|
298
|
+
|
|
299
|
+
```JSON
|
|
300
|
+
{
|
|
301
|
+
"copy": {
|
|
302
|
+
"in": ["src/static/ogimage.jpg", "src/static/favicon.ico", "src/fonts"],
|
|
303
|
+
"out": "dist"
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**💡 NOTE:** Copy property can also accept the list of objects containing `in` and `out` properties. For instance:
|
|
309
|
+
|
|
310
|
+
```JSON
|
|
311
|
+
{
|
|
312
|
+
"copy": [
|
|
313
|
+
{
|
|
314
|
+
"in": ["src/static/ogimage.jpg", "src/static/favicon.ico", "src/fonts"],
|
|
315
|
+
"out": "dist"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"in": "images",
|
|
319
|
+
"out": "dist/static"
|
|
320
|
+
}
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**💡 NOTE:** Copy can also accept some basic **GLOB** as input paths. Does NOT support **EXTGLOB** yet. Don't expect too much of it, but for instance these paths will work:
|
|
326
|
+
|
|
327
|
+
```JSON
|
|
328
|
+
{
|
|
329
|
+
"copy": {
|
|
330
|
+
"in": [
|
|
331
|
+
"images/**/awesome.{jpeg,jpg,png}",
|
|
332
|
+
"notes/info[0-9].txt",
|
|
333
|
+
"notes/doc?.txt",
|
|
334
|
+
"notes/memo*.txt",
|
|
335
|
+
"notes/log[!123a].txt",
|
|
336
|
+
],
|
|
337
|
+
"out": "dist"
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
273
342
|
### Banner (optional)
|
|
274
343
|
|
|
275
344
|
Here you can specify a banner that will be added to the top of the output files. It is templatable via mustache. The following variables are available from your project's `package.json`:
|
package/lib/copy.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const { globSync, hasMagic } = require('glob')
|
|
2
|
+
const helpers = require('./utils/helpers.js')
|
|
3
|
+
const fs = require('node:fs')
|
|
4
|
+
const path = require('node:path')
|
|
5
|
+
const PrintStyle = require('./utils/print-style.js')
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
pathExists,
|
|
9
|
+
pathIsDirectory,
|
|
10
|
+
mkDir,
|
|
11
|
+
copyDirectory,
|
|
12
|
+
buildTime
|
|
13
|
+
} = helpers
|
|
14
|
+
|
|
15
|
+
const pstyle = new PrintStyle()
|
|
16
|
+
|
|
17
|
+
module.exports = class Copy {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = config
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async execute() {
|
|
23
|
+
if (!this.config.copy) return
|
|
24
|
+
const copyStartTime = performance.now()
|
|
25
|
+
this.config.copy = Array.isArray(this.config.copy) ? this.config.copy : [this.config.copy]
|
|
26
|
+
let copyLastPath = ''
|
|
27
|
+
let copyPathCount = 0
|
|
28
|
+
|
|
29
|
+
for (const copyEntry of this.config.copy) {
|
|
30
|
+
if (!copyEntry.in || !copyEntry.out) {
|
|
31
|
+
console.log(`${pstyle.redBright + pstyle.bold}[error]${pstyle.reset}[copy] ${pstyle.dim}Cannot copy. Missing 'in' or 'out' property in copy entry:${pstyle.reset} ${JSON.stringify(copyEntry)}`)
|
|
32
|
+
continue
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const outPath = path.resolve(process.cwd(), copyEntry.out)
|
|
36
|
+
const inEntries = Array.isArray(copyEntry.in) ? copyEntry.in : [copyEntry.in]
|
|
37
|
+
|
|
38
|
+
for (const inEntry of inEntries) {
|
|
39
|
+
const hasGlobMagic = typeof hasMagic === 'function'
|
|
40
|
+
? hasMagic(inEntry)
|
|
41
|
+
: ['*', '?', '[', ']', '{', '}', '(', ')', '!'].some((ch) => inEntry.includes(ch))
|
|
42
|
+
let matches = []
|
|
43
|
+
try {
|
|
44
|
+
if (typeof globSync === 'function') {
|
|
45
|
+
matches = globSync(inEntry, { dot: true, nodir: false })
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
matches = []
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (matches.length > 0) {
|
|
52
|
+
for (const matchedPath of matches) {
|
|
53
|
+
if (pathExists(matchedPath)) {
|
|
54
|
+
await this.copyEntry(matchedPath, outPath)
|
|
55
|
+
copyLastPath = inEntry
|
|
56
|
+
copyPathCount++
|
|
57
|
+
} else {
|
|
58
|
+
console.log(`${pstyle.redBright + pstyle.bold}[error]${pstyle.reset}[copy] ${pstyle.dim}Cannot copy. Source path does not exist:${pstyle.reset} ${matchedPath}`)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (pathExists(inEntry)) {
|
|
65
|
+
await this.copyEntry(inEntry, outPath)
|
|
66
|
+
copyLastPath = inEntry
|
|
67
|
+
copyPathCount++
|
|
68
|
+
} else {
|
|
69
|
+
if (hasGlobMagic) {
|
|
70
|
+
console.log(`${pstyle.redBright + pstyle.bold}[error]${pstyle.reset}[copy] ${pstyle.dim}No files matched glob pattern:${pstyle.reset} ${inEntry}`)
|
|
71
|
+
} else {
|
|
72
|
+
console.log(`${pstyle.redBright + pstyle.bold}[error]${pstyle.reset}[copy] ${pstyle.dim}Cannot copy. Source path does not exist:${pstyle.reset} ${inEntry}`)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const copyEndTime = performance.now()
|
|
79
|
+
if (copyPathCount === 0) return
|
|
80
|
+
if (copyPathCount === 1) {
|
|
81
|
+
console.log(`${pstyle.green + pstyle.bold}[copy]${pstyle.reset} ${pstyle.dim}Copied${pstyle.reset} ${pstyle.italic + pstyle.underline}${copyLastPath}${pstyle.reset} ${pstyle.green}(${buildTime(copyStartTime, copyEndTime)})${pstyle.reset}`)
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log(`${pstyle.green + pstyle.bold}[copy]${pstyle.reset} ${pstyle.dim}Copied${pstyle.reset} ${copyPathCount} paths ${pstyle.green}(${buildTime(copyStartTime, copyEndTime)})${pstyle.reset}`)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async unlink(file, copyPaths) {
|
|
89
|
+
if (!file || !copyPaths) return
|
|
90
|
+
if (!copyPaths.out || !copyPaths.in) return
|
|
91
|
+
if (!pathExists(copyPaths.out) || !pathExists(copyPaths.in)) return
|
|
92
|
+
|
|
93
|
+
if (pathIsDirectory(copyPaths.in)) {
|
|
94
|
+
const inBaseName = path.basename(copyPaths.in)
|
|
95
|
+
copyPaths.out = path.join(copyPaths.out, inBaseName)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
file = file.replace(copyPaths.in, copyPaths.out)
|
|
99
|
+
|
|
100
|
+
const outputFilePath = path.join(process.cwd(), file)
|
|
101
|
+
|
|
102
|
+
if (pathExists(outputFilePath)) {
|
|
103
|
+
if (pathIsDirectory(outputFilePath)) {
|
|
104
|
+
fs.rmdirSync(outputFilePath, { recursive: true })
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
fs.unlinkSync(outputFilePath)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async copyEntry(inFilePath, outFilePath) {
|
|
112
|
+
const baseName = path.basename(inFilePath)
|
|
113
|
+
let outPath = outFilePath
|
|
114
|
+
mkDir(outFilePath)
|
|
115
|
+
|
|
116
|
+
if (pathIsDirectory(outFilePath)) {
|
|
117
|
+
outPath = path.join(outFilePath, baseName)
|
|
118
|
+
}
|
|
119
|
+
copyDirectory(inFilePath, outPath)
|
|
120
|
+
}
|
|
121
|
+
}
|