Skip to content

Commit aa409d8

Browse files
author
CI
committed
πŸ› Fix auto install via astro add
1 parent ba53350 commit aa409d8

File tree

10 files changed

+86
-44
lines changed

10 files changed

+86
-44
lines changed

β€Ž.editorconfigβ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.{json,md}]
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{json,md,ts}]
1215
indent_style = space
1316

1417
[*.{cjs,json,mjs,svg,yaml,yml}]

β€Ž.vscode/extensions.jsonβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"recommendations": [
3-
"astro-build.astro-vscode"
3+
"astro-build.astro-vscode",
4+
"biomejs.biome"
45
]
56
}

β€Ž.vscode/settings.jsonβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"cSpell.words": [
3+
"astro",
34
"Astro",
45
"astrojs",
6+
"biomejs",
7+
"Codespaces",
58
"commitlint",
69
"lightningcss",
710
"minifier",
@@ -10,6 +13,7 @@
1013
"Redwerkz",
1114
"tsconfigs",
1215
"tsup",
16+
"volta",
1317
"withastro"
1418
],
1519
"json.schemas": [

β€Žbun.lockbβ€Ž

3.43 KB
Binary file not shown.

β€Ždemo/package.jsonβ€Ž

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
{
22
"name": "demo",
3-
"type": "module",
43
"version": "0.0.1",
54
"private": true,
5+
"type": "module",
66
"scripts": {
7+
"astro": "astro",
8+
"build": "astro check && astro build",
79
"dev": "astro dev",
8-
"start": "astro dev",
9-
"build": "astro build",
1010
"preview": "astro preview",
11-
"astro": "astro"
11+
"start": "astro dev"
1212
},
1313
"dependencies": {
14-
"astro-min": "workspace:^",
15-
"astro": "^4.2.4"
14+
"astro-min": "workspace:^"
1615
},
1716
"devDependencies": {
1817
"@astrojs/check": "^0.4.1",
19-
"typescript": "5.1.6"
18+
"astro": "^4.3.5"
2019
}
2120
}

β€Ždemo/public/favicon.svgβ€Ž

Lines changed: 3 additions & 1 deletion
Loading

β€Žpackage.jsonβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
22
"name": "root",
3-
"private": true,
43
"version": "0.0.0",
4+
"private": true,
55
"type": "module",
66
"scripts": {
77
"build": "pnpm --filter astro-min --filter demo run build",
88
"format": "ts-standard --fix packages",
99
"prepack": "npmignore --auto",
10-
"version": "changeset version && pnpm install --no-frozen-lockfile --lockfile-only",
10+
"publish": "pnpm publish --filter astro-min --no-git-checks",
1111
"publish:dry": "pnpm publish --dry-run --filter astro-min --no-git-checks",
12-
"publish": "pnpm publish --filter astro-min --no-git-checks"
12+
"version": "changeset version && pnpm install --no-frozen-lockfile --lockfile-only"
1313
},
14-
"packageManager": "pnpm@8.14.1",
1514
"dependencies": {
1615
"@changesets/changelog-github": "^0.5.0",
1716
"@changesets/cli": "^2.27.1"
1817
},
1918
"devDependencies": {
2019
"npmignore": "^0.3.1",
2120
"ts-standard": "^12.0.2"
22-
}
21+
},
22+
"packageManager": "bun@1.0.26"
2323
}

β€Žpackages/min/README.mdβ€Ž

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# astro-min
1+
# `astro-min`
22

3-
> Extremely Fast and Smart Minification of 🟠 HTML 🟑 JS πŸ”΅ CSS 🟣 SVG
3+
> Extremely Fast and Smart Minification of 🟠 HTML 🟑 JS πŸ”΅ CSS 🟣 SVG
44
> Meticulously optimized for Speed πŸ₯‡ and Effectiveness πŸ…
55
6-
![astro](https://img.shields.io/badge/astro-%238d46e7.svg?style=flat-square&logo=astro&logoColor=white)
7-
[![npm version](https://img.shields.io/npm/v/astro-min?style=flat-square)](https://www.npmjs.com/package/astro-min)
8-
[![install size](https://packagephobia.com/badge?p=astro-min&style=flat-square)](https://packagephobia.com/result?p=astro-min)
9-
[![license: mit][license-src]][license-href]
10-
[![style: ts-standard][codestyle-src]][codestyle-href]
6+
[![Built with Astro](https://astro.badg.es/v2/built-with-astro/tiny.svg)](https://astro.build)
7+
[![NPM Package Version](https://img.shields.io/npm/v/astro-min?style=flat-square)](https://www.npmjs.com/package/astro-min)
8+
[![Package Install Size](https://packagephobia.com/badge?p=astro-min&style=flat-square)](https://packagephobia.com/result?p=astro-min)
9+
[![License: MIT][license-src]][license-href]
10+
[![Style: TS-Standard][codestyle-src]][codestyle-href]
11+
[![GitHub Repo Stars][gh-repo-stars-img]][gh-repo-url]
1112

1213
## Feature Highlights ✨
1314

@@ -22,6 +23,7 @@
2223
- [x] Static Site Minification
2324

2425
- [ ] Support SSR / Hybrid Rendering
26+
- [ ] Remove Comments from external CSS/JS
2527

2628
## Getting started 🎯
2729

@@ -86,6 +88,13 @@ export default defineConfig({
8688
})
8789
```
8890

91+
## Development
92+
93+
[![Open in StackBlitz][open-in-sb]](https://stackblitz.com/github/advanced-astro/astro-min)
94+
[![Open with CodeSandbox][open-in-csb]](https://codesandbox.io/p/sandbox/github/advanced-astro/astro-min)
95+
[![Open in GitHub Codespaces][open-in-ghc]](https://codespaces.new/advanced-astro/astro-min?devcontainer_path=.devcontainer/minimal/devcontainer.json)
96+
[![Open in Gitpod][open-in-gp]](https://gitpod.io/#https://github.com/advanced-astro/astro-min)
97+
8998
## Learn more πŸ”–
9099

91100
- <https://warpspeed-world.github.io/css-minification-benchmark/>
@@ -99,5 +108,16 @@ export default defineConfig({
99108

100109
[codestyle-src]: https://flat.badgen.net/badge/code%20style/ts-standard/blue?icon=typescript
101110
[codestyle-href]: https://github.com/standard/ts-standard
111+
112+
[gh-repo-stars-img]: https://img.shields.io/github/stars/advanced-astro/astro-min
113+
[gh-repo-url]: https://github.com/advanced-astro/astro-min
114+
102115
[license-src]: https://flat.badgen.net/github/license/amio/badgen
103116
[license-href]: https://opensource.org/license/isc-license-txt/
117+
118+
[open-in-csb]: https://assets.codesandbox.io/github/button-edit-lime.svg
119+
[open-in-ghc]: https://github.com/codespaces/badge.svg
120+
[open-in-gp]: https://gitpod.io/button/open-in-gitpod.svg
121+
[open-in-sb]: https://developer.stackblitz.com/img/open_in_stackblitz.svg
122+
123+
## Changelog

β€Žpackages/min/package.jsonβ€Ž

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "astro-min",
3-
"version": "1.1.0-dev.1",
3+
"version": "1.1.0",
44
"description": "Extremely ⚑ Fast πŸŒ€ Smart β­• HTML 🟠 JS 🟑 CSS πŸ”΅ SVG 🟣 Minification πŸ’ ",
55
"keywords": [
66
"astro",
@@ -18,6 +18,11 @@
1818
"svgo",
1919
"withastro"
2020
],
21+
"homepage": "https://github.com/advanced-astro/astro-min#readme",
22+
"repository": {
23+
"type": "git",
24+
"url": "git+https://github.com/advanced-astro/astro-min.git"
25+
},
2126
"license": "ISC",
2227
"author": "Marc Redwerkz",
2328
"type": "module",
@@ -34,26 +39,21 @@
3439
],
3540
"scripts": {
3641
"build": "tsup",
37-
"prepublishOnly": "pnpm build",
42+
"prepublishOnly": "tsup",
3843
"watch": "tsup --watch"
3944
},
4045
"dependencies": {
4146
"@minify-html/node": "^0.15.0",
4247
"svgo": "^3.2.0"
4348
},
4449
"devDependencies": {
45-
"@types/node": "^20.11.6",
46-
"astro": "^4.2.4",
50+
"@types/node": "^20.11.16",
51+
"astro": "^4.3.5",
4752
"glob": "^10.3.10",
4853
"tsup": "^8.0.1",
49-
"typescript": "5.2.0"
54+
"typescript": "5.3.3"
5055
},
5156
"peerDependencies": {
5257
"astro": "^4.0.0 || ^3.0.0 || ^2.0.0 || ^1.0.0"
53-
},
54-
"homepage": "https://github.com/advanced-astro/astro-min#readme",
55-
"repository": {
56-
"type": "git",
57-
"url": "git+https://github.com/advanced-astro/astro-min.git"
5858
}
5959
}

β€Žpackages/min/src/integration.tsβ€Ž

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Options } from './utils/options'
1616
* @param {Options} [options] - The options for the integration.
1717
* @return {AstroIntegration} - The created integration.
1818
*/
19-
export function createIntegration (options?: Options): AstroIntegration {
19+
export function createIntegration(options?: Options): AstroIntegration {
2020
return {
2121
name: 'astro-min',
2222
hooks: {
@@ -41,7 +41,10 @@ export function createIntegration (options?: Options): AstroIntegration {
4141
const filePath = join(cwd, filename)
4242

4343
const htmlOrg = await fs.promises.readFile(filePath, 'utf8')
44-
const htmlMin = minifyHtml.minify(Buffer.from(htmlOrg), (options != null) ? options : {})
44+
const htmlMin = minifyHtml.minify(
45+
Buffer.from(htmlOrg),
46+
options != null ? options : {},
47+
)
4548

4649
await fs.promises.writeFile(filePath, htmlMin, 'utf-8')
4750

@@ -62,28 +65,38 @@ export function createIntegration (options?: Options): AstroIntegration {
6265
name: 'preset-default',
6366
params: {
6467
overrides: {
65-
removeViewBox: false
66-
}
67-
}
68-
}
69-
]
68+
removeViewBox: false,
69+
},
70+
},
71+
},
72+
],
7073
})
7174

7275
await fs.promises.writeFile(filePath, svgMin.data, 'utf-8')
7376
}
7477

7578
// const humanSizeOld = sizeOld < 100 ? sizeOld.toFixed(1) + ' Bytes' : (sizeOld / 1000).toFixed(2) + ' KB'
76-
const humanSizeMin = sizeNew < 100 ? sizeNew.toFixed(1) + ' Bytes' : (sizeNew / 1000).toFixed(2) + ' KB'
79+
const humanSizeMin =
80+
sizeNew < 100
81+
? `${sizeNew.toFixed(1)} Bytes`
82+
: `${(sizeNew / 1000).toFixed(2)} KB`
7783

7884
const end = performance.now()
7985
const deltaT = end - start
80-
const humanTime = deltaT < 1000 ? deltaT.toFixed(0) + 'ms' : (deltaT / 1000).toFixed(1) + 's'
86+
const humanTime =
87+
deltaT < 1000
88+
? `${deltaT.toFixed(0)}ms`
89+
: `${(deltaT / 1000).toFixed(1)}s`
8190

8291
logServerMessage(`βœ“ Completed in ${humanTime}`)
83-
logServerMessage(`${htmlFiles.length + svgFiles.length} files minified (-${relative}) ${humanSizeMin}`)
92+
logServerMessage(
93+
`${
94+
htmlFiles.length + svgFiles.length
95+
} files minified (-${relative}) ${humanSizeMin}`,
96+
)
8497
// logServerMessage(`${htmlFiles.length} files minified from ${humanSizeOld} down to ${humanSizeMin}`)
85-
}
86-
}
98+
},
99+
},
87100
}
88101
}
89102

0 commit comments

Comments
Β (0)