1
mirror of https://github.com/jakejarvis/hugo-extended.git synced 2026-06-12 08:45:27 -04:00

fix: rename new site to new project to match Hugo v0.156.0

Hugo v0.156.0 renamed the `new site` subcommand to `new project`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 10:33:35 -05:00
parent 5059fcb1d8
commit f111ebd21e
5 changed files with 30 additions and 30 deletions
+7 -7
View File
@@ -78,8 +78,8 @@ export const getHugoBinary = async (): Promise<string> => {
* baseURL: "http://localhost:1313"
* });
*
* // Create a new site
* await exec("new site", ["my-site"], { format: "yaml" });
* // Create a new project
* await exec("new project", ["my-site"], { format: "yaml" });
*
* // Build site for production
* await exec("build", {
@@ -338,14 +338,14 @@ export const hugo = {
}
return exec("new content", pathOrOptions);
},
site: (
pathOrOptions?: string | HugoOptionsFor<"new site">,
options?: HugoOptionsFor<"new site">,
project: (
pathOrOptions?: string | HugoOptionsFor<"new project">,
options?: HugoOptionsFor<"new project">,
) => {
if (typeof pathOrOptions === "string") {
return exec("new site", [pathOrOptions], options);
return exec("new project", [pathOrOptions], options);
}
return exec("new site", pathOrOptions);
return exec("new project", pathOrOptions);
},
theme: (
nameOrOptions?: string | HugoOptionsFor<"new theme">,
+2 -2
View File
@@ -105,8 +105,8 @@ function findFlag(flags: FlagSpec[], propName: string): FlagSpec | undefined {
* // Returns: ["server", "--port", "1313", "--build-drafts"]
*
* @example
* buildArgs("new site", ["my-site"], { format: "yaml" })
* // Returns: ["new", "site", "my-site", "--format", "yaml"]
* buildArgs("new project", ["my-site"], { format: "yaml" })
* // Returns: ["new", "project", "my-site", "--format", "yaml"]
*
* @example
* buildArgs("build", undefined, { theme: ["a", "b"], minify: true })
+13 -13
View File
@@ -17,10 +17,10 @@ describe("New Commands Integration", () => {
await rm(tempDir, { recursive: true, force: true });
});
describe("new.site", () => {
it("should create a new site with default format", async () => {
describe("new.project", () => {
it("should create a new project with default format", async () => {
const sitePath = join(tempDir, "test-site");
await hugo.new.site(sitePath);
await hugo.new.project(sitePath);
// Check that essential directories exist
await expect(
@@ -30,18 +30,18 @@ describe("New Commands Integration", () => {
await expect(access(join(sitePath, "themes"))).resolves.toBeUndefined();
});
it("should create a new site with yaml format", async () => {
it("should create a new project with yaml format", async () => {
const sitePath = join(tempDir, "test-site-yaml");
await hugo.new.site(sitePath, { format: "yaml" });
await hugo.new.project(sitePath, { format: "yaml" });
await expect(
access(join(sitePath, "hugo.yaml")),
).resolves.toBeUndefined();
});
it("should create a new site with json format", async () => {
it("should create a new project with json format", async () => {
const sitePath = join(tempDir, "test-site-json");
await hugo.new.site(sitePath, { format: "json" });
await hugo.new.project(sitePath, { format: "json" });
await expect(
access(join(sitePath, "hugo.json")),
@@ -52,12 +52,12 @@ describe("New Commands Integration", () => {
const sitePath = join(tempDir, "test-site-force");
// Create site first time
await hugo.new.site(sitePath);
await hugo.new.project(sitePath);
// Hugo 0.154.x does not overwrite an existing site config file, even with --force.
// Future versions may change this behavior, so test accepts either outcome.
try {
await hugo.new.site(sitePath, { force: true });
await hugo.new.project(sitePath, { force: true });
// If it succeeds, verify the site still exists
await expect(
access(join(sitePath, "hugo.toml")),
@@ -72,7 +72,7 @@ describe("New Commands Integration", () => {
describe("new.theme", () => {
it("should create a new theme", async () => {
const sitePath = join(tempDir, "test-site");
await hugo.new.site(sitePath);
await hugo.new.project(sitePath);
// Use --source instead of process.chdir (not supported in worker threads)
await hugo.new.theme("test-theme", { source: sitePath });
@@ -86,7 +86,7 @@ describe("New Commands Integration", () => {
it("should create theme with yaml format", async () => {
const sitePath = join(tempDir, "test-site");
await hugo.new.site(sitePath);
await hugo.new.project(sitePath);
await hugo.new.theme("test-theme-yaml", {
format: "yaml",
@@ -103,7 +103,7 @@ describe("New Commands Integration", () => {
describe("new.content", () => {
it("should create new content file", async () => {
const sitePath = join(tempDir, "test-site");
await hugo.new.site(sitePath);
await hugo.new.project(sitePath);
await hugo.new.content("posts/my-post.md", { source: sitePath });
@@ -113,7 +113,7 @@ describe("New Commands Integration", () => {
it("should create content with custom kind", async () => {
const sitePath = join(tempDir, "test-site");
await hugo.new.site(sitePath);
await hugo.new.project(sitePath);
await hugo.new.content("pages/about.md", {
kind: "page",
+4 -4
View File
@@ -16,8 +16,8 @@ describe("buildArgs", () => {
describe("positional arguments", () => {
it("should add positional arguments after command", () => {
const args = buildArgs("new site", ["my-site"]);
expect(args).toEqual(["new", "site", "my-site"]);
const args = buildArgs("new project", ["my-site"]);
expect(args).toEqual(["new", "project", "my-site"]);
});
it("should handle multiple positional arguments", () => {
@@ -26,8 +26,8 @@ describe("buildArgs", () => {
});
it("should handle positional args with options", () => {
const args = buildArgs("new site", ["my-site"], { format: "yaml" });
expect(args).toEqual(["new", "site", "my-site", "--format", "yaml"]);
const args = buildArgs("new project", ["my-site"], { format: "yaml" });
expect(args).toEqual(["new", "project", "my-site", "--format", "yaml"]);
});
});
+4 -4
View File
@@ -6,7 +6,7 @@ describe("Type Safety", () => {
// Check that specific commands are valid HugoCommand values
expectTypeOf<"build">().toExtend<HugoCommand>();
expectTypeOf<"server">().toExtend<HugoCommand>();
expectTypeOf<"new site">().toExtend<HugoCommand>();
expectTypeOf<"new project">().toExtend<HugoCommand>();
expectTypeOf<"new theme">().toExtend<HugoCommand>();
expectTypeOf<"new content">().toExtend<HugoCommand>();
});
@@ -14,7 +14,7 @@ describe("Type Safety", () => {
it("should map commands to correct option types", () => {
type BuildOpts = HugoOptionsFor<"build">;
type ServerOpts = HugoOptionsFor<"server">;
type NewSiteOpts = HugoOptionsFor<"new site">;
type NewProjectOpts = HugoOptionsFor<"new project">;
type NewThemeOpts = HugoOptionsFor<"new theme">;
// Build options should have minify
@@ -23,8 +23,8 @@ describe("Type Safety", () => {
// Server options should have port
expectTypeOf<ServerOpts>().toHaveProperty("port");
// New site options should have format
expectTypeOf<NewSiteOpts>().toHaveProperty("format");
// New project options should have format
expectTypeOf<NewProjectOpts>().toHaveProperty("format");
// New theme options should have format
expectTypeOf<NewThemeOpts>().toHaveProperty("format");