Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 8 additions & 5 deletions packages/@apphosting/adapter-angular/src/bin/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
checkBuildConditions,
validateOutputDirectory,
parseOutputBundleOptions,
outputBundleExists

Check failure on line 7 in packages/@apphosting/adapter-angular/src/bin/build.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `,`
} from "../utils.js";
import { getBuildOptions, runBuild } from "@apphosting/common";

Expand All @@ -21,8 +22,10 @@
if (!output) {
throw new Error("No output from Angular build command, expecting a build manifest file.");
}
const outputBundleOptions = parseOutputBundleOptions(output);
const root = process.cwd();
await generateBuildOutput(root, outputBundleOptions, process.env.FRAMEWORK_VERSION);

await validateOutputDirectory(outputBundleOptions);
if (!outputBundleExists()){

Check failure on line 25 in packages/@apphosting/adapter-angular/src/bin/build.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `·`
const outputBundleOptions = parseOutputBundleOptions(output);
const root = process.cwd();
await generateBuildOutput(root, outputBundleOptions, process.env.FRAMEWORK_VERSION);

Check failure on line 29 in packages/@apphosting/adapter-angular/src/bin/build.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
await validateOutputDirectory(outputBundleOptions);
}
23 changes: 17 additions & 6 deletions packages/@apphosting/adapter-angular/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
const __dirname = dirname(__filename);
const SIMPLE_SERVER_FILE_PATH = join(__dirname, "simple-server", "bundled_server.mjs");

export const REQUIRED_BUILDER = "@angular-devkit/build-angular:application";
export const ALLOWED_BUILDERS = [
"@angular-devkit/build-angular:application",
"@analogjs/platform:vite"

Check failure on line 29 in packages/@apphosting/adapter-angular/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `,`
];

/**
* Check if the following build conditions are satisfied for the workspace:
Expand All @@ -38,10 +41,10 @@
const output = execSync(`npx nx show project ${opts.projectName}`);
const projectJson = JSON.parse(output.toString());
const builder = projectJson.targets.build.executor;
if (builder !== REQUIRED_BUILDER) {
if (!ALLOWED_BUILDERS.includes(builder)) {
throw new Error(
"Only the Angular application builder is supported. Please refer to https://angular.dev/tools/cli/build-system-migration#for-existing-applications guide to upgrade your builder to the Angular application builder. ",
);
`Currently, only the following builders are supported: ${ALLOWED_BUILDERS.join(',')}.`,

Check failure on line 46 in packages/@apphosting/adapter-angular/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `','` with `","`
)

Check failure on line 47 in packages/@apphosting/adapter-angular/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `;`
}
return;
}
Expand Down Expand Up @@ -75,9 +78,9 @@
if (!workspaceProject.targets.has(target)) throw new Error("Could not find build target.");

const { builder } = workspaceProject.targets.get(target)!;
if (builder !== REQUIRED_BUILDER) {
if (!ALLOWED_BUILDERS.includes(builder)) {
throw new Error(
"Only the Angular application builder is supported. Please refer to https://angular.dev/tools/cli/build-system-migration#for-existing-applications guide to upgrade your builder to the Angular application builder. ",
`Currently, only the following builders are supported: ${ALLOWED_BUILDERS.join(',')}.`,

Check failure on line 83 in packages/@apphosting/adapter-angular/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `','` with `","`
);
}
}
Expand Down Expand Up @@ -226,3 +229,11 @@
if (!process.argv[1]) return false;
return process.argv[1] === fileURLToPath(meta.url);
};

export const outputBundleExists = () => {

Check failure on line 233 in packages/@apphosting/adapter-angular/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `·`
const outputBundleDir = resolve(".apphosting");
if (existsSync(outputBundleDir)){

Check failure on line 235 in packages/@apphosting/adapter-angular/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `·`
return true;
}
return false;
}

Check failure on line 239 in packages/@apphosting/adapter-angular/src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `;⏎`
Loading