@kevinmarrec/create-app 0.10.0 → 0.10.1
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/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevinmarrec/create-app",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.1",
|
|
5
5
|
"packageManager": "bun@1.3.2",
|
|
6
6
|
"description": "CLI that scaffolds an opinionated Bun & Vue fullstack application.",
|
|
7
7
|
"author": "Kevin Marrec <kevin@marrec.io>",
|
|
@@ -7,47 +7,23 @@ import { filesize } from 'filesize'
|
|
|
7
7
|
import { x } from 'tinyexec'
|
|
8
8
|
import { glob } from 'tinyglobby'
|
|
9
9
|
|
|
10
|
-
interface FileStats {
|
|
11
|
-
file: string
|
|
12
|
-
size: number
|
|
13
|
-
}
|
|
14
|
-
|
|
15
10
|
async function getFileStats(directory: string) {
|
|
16
|
-
const fileStats
|
|
17
|
-
|
|
18
|
-
for (const file of await glob(['**/*'], { cwd: directory })) {
|
|
19
|
-
const size = fs.statSync(path.join(directory, file)).size
|
|
20
|
-
fileStats.push({
|
|
11
|
+
const fileStats = await Promise.all(
|
|
12
|
+
(await glob(['**/*'], { cwd: directory })).map(async file => ({
|
|
21
13
|
file,
|
|
22
|
-
size,
|
|
23
|
-
})
|
|
24
|
-
|
|
14
|
+
size: fs.statSync(path.join(directory, file)).size,
|
|
15
|
+
})),
|
|
16
|
+
)
|
|
25
17
|
|
|
26
18
|
fileStats.sort((a, b) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// Within that, files ending with '.js' come first
|
|
32
|
-
if (a.file.endsWith('.js') && !b.file.endsWith('.js')) return -1
|
|
33
|
-
if (!a.file.endsWith('.js') && b.file.endsWith('.js')) return 1
|
|
34
|
-
|
|
35
|
-
// Otherwise sort alphabetically
|
|
36
|
-
return a.file.localeCompare(b.file)
|
|
19
|
+
const scoreA = (a.file.startsWith('assets/') ? 2 : 0) + (a.file.endsWith('.js') ? 1 : 0)
|
|
20
|
+
const scoreB = (b.file.startsWith('assets/') ? 2 : 0) + (b.file.endsWith('.js') ? 1 : 0)
|
|
21
|
+
return scoreB - scoreA || a.file.localeCompare(b.file)
|
|
37
22
|
})
|
|
38
23
|
|
|
39
24
|
return fileStats
|
|
40
25
|
}
|
|
41
26
|
|
|
42
|
-
async function generateFileStatsMarkdown(directory: string) {
|
|
43
|
-
const fileStats = await getFileStats(directory)
|
|
44
|
-
return [
|
|
45
|
-
'| File | Size |',
|
|
46
|
-
'| :--- | ---: |',
|
|
47
|
-
...fileStats.map(file => `| ${file.file} | ${filesize(file.size)} |`),
|
|
48
|
-
].join('\n')
|
|
49
|
-
}
|
|
50
|
-
|
|
51
27
|
async function main() {
|
|
52
28
|
const { positionals: [directory] } = parseArgs({
|
|
53
29
|
args: process.argv.slice(2),
|
|
@@ -61,7 +37,12 @@ async function main() {
|
|
|
61
37
|
|
|
62
38
|
await x('bun', ['run', 'build'], { nodeOptions: { cwd: directory } })
|
|
63
39
|
|
|
64
|
-
const
|
|
40
|
+
const fileStats = await getFileStats(path.join(directory, 'dist'))
|
|
41
|
+
const markdownTable = [
|
|
42
|
+
'| File | Size |',
|
|
43
|
+
'| :--- | ---: |',
|
|
44
|
+
...fileStats.map(file => `| ${file.file} | ${filesize(file.size)} |`),
|
|
45
|
+
].join('\n')
|
|
65
46
|
process.stdout.write(`${markdownTable}\n`)
|
|
66
47
|
}
|
|
67
48
|
|