mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
d88a29e002
Rewrite `hugo mod npm pack` to use npm workspaces. Module deps are now
written to packages/hugoautogen/package.json and the root package.json
gets a "workspaces" reference. A hugo_packagemeta.json sidecar stores a
hash of all input package files so regular commands can warn when npm
deps are out of sync.
Other changes:
- Workspace glob patterns (*, **, {a,b}) are resolved via gobwas/glob.
- Workspaces defined in package.hugo.json are supported.
- package.hugo.json is only recognised at module roots, not in workspaces.
- When package.hugo.json exists, package.json is not mounted or vendored.
- packages/hugoautogen is not mounted or vendored from dependencies.
- Add usePackageJSON import option (auto/always/never) to control whether
a module's npm deps are included. "auto" checks for Hugo config files
or package.hugo.json.
- The staleness check is skipped when running `hugo mod npm pack` itself.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
65 lines
1.3 KiB
Plaintext
65 lines
1.3 KiB
Plaintext
# Test mod npm with existing package.json.
|
|
|
|
# See https://github.com/gohugoio/hugo/issues/13465
|
|
[windows] skip
|
|
|
|
dostounix golden/packages/hugoautogen/package.json
|
|
dostounix golden/package.json
|
|
|
|
hugo mod npm pack
|
|
cmp packages/hugoautogen/package.json golden/packages/hugoautogen/package.json
|
|
cmp package.json golden/package.json
|
|
exists packages/hugoautogen/hugo_packagemeta.json
|
|
|
|
-- hugo.toml --
|
|
baseURL = "https://example.org/"
|
|
[module]
|
|
[[module.imports]]
|
|
path="github.com/gohugoio/hugoTestModule2"
|
|
-- package.json --
|
|
{
|
|
"comments": {
|
|
"foo": {
|
|
"a": "b"
|
|
}
|
|
},
|
|
"devDependencies": {
|
|
"tailwindcss": "2.2.0"
|
|
},
|
|
"name": "mypackage",
|
|
"version": "1.1.0"
|
|
}
|
|
-- golden/packages/hugoautogen/package.json --
|
|
{
|
|
"dependencies": {
|
|
"react-dom": "^16.13.1"
|
|
},
|
|
"devDependencies": {
|
|
"@babel/cli": "7.8.4",
|
|
"@babel/core": "7.9.0",
|
|
"@babel/preset-env": "7.9.5",
|
|
"postcss-cli": "7.1.0"
|
|
},
|
|
"name": "script-mod_npm_withexisting",
|
|
"version": "0.1.0"
|
|
}
|
|
-- golden/package.json --
|
|
{
|
|
"comments": {
|
|
"foo": {
|
|
"a": "b"
|
|
}
|
|
},
|
|
"devDependencies": {
|
|
"tailwindcss": "2.2.0"
|
|
},
|
|
"name": "mypackage",
|
|
"version": "1.1.0",
|
|
"workspaces": [
|
|
"packages/hugoautogen"
|
|
]
|
|
}
|
|
-- go.mod --
|
|
module github.com/gohugoio/hugoTestModule
|
|
go 1.20
|