Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const app = await builder
.withReference(cache)
.waitFor(cache)
// {{/redis}}
.withHttpHealthCheck("/health");
.withHttpHealthCheck({ path: "/health" });

// Run the Vite frontend after the API and inject the API URL for local proxying.
const frontend = await builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default defineConfig({
extends: [tseslint.configs.base],
languageOptions: {
parserOptions: {
projectService: true,
project: './tsconfig.apphost.json',
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
Expand Down
16 changes: 10 additions & 6 deletions src/Aspire.Cli/Templating/Templates/py-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
"private": true,
"type": "module",
"scripts": {
"lint": "eslint apphost.ts",
"predev": "npm run lint",
"dev": "aspire run",
"prebuild": "npm run lint",
"build": "tsc",
"watch": "tsc --watch"
"aspire:lint": "eslint apphost.ts",
"aspire:start": "aspire run",
"aspire:build": "tsc -p tsconfig.apphost.json",
"aspire:dev": "tsc --watch -p tsconfig.apphost.json",
"lint": "npm run aspire:lint",
"predev": "npm run aspire:lint",
"dev": "npm run aspire:start",
"prebuild": "npm run aspire:lint",
"build": "npm run aspire:build",
"watch": "npm run aspire:dev"
},
"dependencies": {
"vscode-jsonrpc": "^8.2.0"
Expand Down

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outside your change - but why is this file named tsconfig.json when the TypeScript template names it tsconfig.apphost.json?

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"outDir": "./dist/apphost",
"rootDir": ".",
"strict": true
},
"include": ["apphost.ts", ".modules/**/*.ts"],
"exclude": ["node_modules"]
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default defineConfig({
extends: [tseslint.configs.base],
languageOptions: {
parserOptions: {
projectService: true,
project: './tsconfig.apphost.json',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is different than the python template. Is that intentional?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like python and ts should drop the exact same apphost files, unless there is a specific reason not to.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adapting I should have aligned the two, doing it now, but on the main branch first

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsconfigRootDir: import.meta.dirname,
},
},
rules: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public Dictionary<string, string> Scaffold(ScaffoldRequest request)
extends: [tseslint.configs.base],
languageOptions: {
parserOptions: {
projectService: true,
project: './tsconfig.apphost.json',
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
Expand Down Expand Up @@ -145,7 +146,8 @@ private static string CreatePackageJson(ScaffoldRequest request)
var packageJson = new JsonObject();
var packageJsonPath = Path.Combine(request.TargetPath, PackageJsonFileName);

if (!File.Exists(packageJsonPath))
var isGreenfield = !File.Exists(packageJsonPath);
if (isGreenfield)
{
// Greenfield: include root metadata so the scaffold output is a complete package.json.
var packageName = request.ProjectName?.ToLowerInvariant() ?? "aspire-apphost";
Expand All @@ -168,6 +170,16 @@ private static string CreatePackageJson(ScaffoldRequest request)
scripts["aspire:build"] = $"tsc -p {AppHostTsConfigFileName}";
scripts["aspire:dev"] = $"tsc --watch -p {AppHostTsConfigFileName}";

if (isGreenfield)
{
scripts["lint"] = "npm run aspire:lint";
scripts["predev"] = "npm run aspire:lint";
scripts["dev"] = "npm run aspire:start";
scripts["prebuild"] = "npm run aspire:lint";
scripts["build"] = "npm run aspire:build";
scripts["watch"] = "npm run aspire:dev";
}

EnsureDependency(packageJson, "dependencies", "vscode-jsonrpc", "^8.2.0");
EnsureDependency(packageJson, "devDependencies", "@types/node", "^22.0.0");
EnsureDependency(packageJson, "devDependencies", "eslint", "^10.0.3");
Expand Down
5 changes: 4 additions & 1 deletion tests/Aspire.Cli.EndToEnd.Tests/PythonReactTemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public async Task CreateAndRunPythonReactProject()
await auto.EnterAsync();
await auto.WaitForSuccessPromptAsync(counter);

// Step 3: Start and stop the project
// Step 3: Verify the generated TypeScript AppHost builds successfully.
await auto.RunCommandFailFastAsync("npm run build", counter, TimeSpan.FromMinutes(2));

// Step 4: Start and stop the project
await auto.AspireStartAsync(counter);
await auto.AspireStopAsync(counter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public async Task CreateAndRunTypeScriptEmptyAppHostProject()
await auto.EnterAsync();
await auto.WaitForSuccessPromptAsync(counter);

await auto.RunCommandFailFastAsync("npm run build", counter, TimeSpan.FromMinutes(2));

await auto.AspireStartAsync(counter);
await auto.AspireStopAsync(counter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public async Task CreateAndRunTypeScriptStarterProject()
await auto.EnterAsync();
await auto.WaitForSuccessPromptAsync(counter);

await auto.RunCommandFailFastAsync("npm run build", counter, TimeSpan.FromMinutes(2));

await auto.AspireStartAsync(counter);
await auto.AspireStopAsync(counter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ public void Scaffold_CreatesAppHostSpecificScriptsAndTsConfig_ForNewProject()
Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue<string>());
Assert.Equal("tsc --watch -p tsconfig.apphost.json", scripts["aspire:dev"]?.GetValue<string>());
Assert.Equal("eslint apphost.ts", scripts["aspire:lint"]?.GetValue<string>());
Assert.False(scripts.ContainsKey("start"));
Assert.False(scripts.ContainsKey("build"));
Assert.False(scripts.ContainsKey("dev"));
Assert.Equal("npm run aspire:lint", scripts["lint"]?.GetValue<string>());
Assert.Equal("npm run aspire:lint", scripts["predev"]?.GetValue<string>());
Assert.Equal("npm run aspire:start", scripts["dev"]?.GetValue<string>());
Assert.Equal("npm run aspire:lint", scripts["prebuild"]?.GetValue<string>());
Assert.Equal("npm run aspire:build", scripts["build"]?.GetValue<string>());
Assert.Equal("npm run aspire:dev", scripts["watch"]?.GetValue<string>());
Assert.Equal("^4.21.0", devDependencies["tsx"]?.GetValue<string>());
Assert.Equal("^5.9.3", devDependencies["typescript"]?.GetValue<string>());
Assert.Equal("^10.0.3", devDependencies["eslint"]?.GetValue<string>());
Expand All @@ -53,6 +56,7 @@ public void Scaffold_CreatesAppHostSpecificScriptsAndTsConfig_ForNewProject()
Assert.DoesNotContain("\\u003E", files["package.json"]);

Assert.Contains("eslint.config.mjs", files.Keys);
Assert.Contains("project: './tsconfig.apphost.json'", files["eslint.config.mjs"]);

var tsConfig = ParseJson(files["tsconfig.apphost.json"]);
Assert.Equal("./dist/apphost", tsConfig["compilerOptions"]?["outDir"]?.GetValue<string>());
Expand Down
Loading