Skip to content
Open
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
20 changes: 19 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,29 @@
- name: Test
run: npm run lint:quiet

verify_packages:
runs-on: ubuntu-latest
needs: build
name: Verify Packages Installation
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20
check-latest: false
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: Rsync Artifacts
run: rsync -a artifact/ packages
- name: Run verification script
run: node scripts/verify-packages.js

# Break the branch protection test into a separate step, so we can manage the matrix more easily
test_and_contribute:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: ubuntu-latest
name: Branch protection
needs: ["test", "lint"]
needs: ["test", "lint", "verify_packages"]
steps:
- run: true

Expand Down
41 changes: 22 additions & 19 deletions packages/@apphosting/adapter-angular/src/bin/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env node
import {
isMain,
generateBuildOutput,
checkBuildConditions,
validateOutputDirectory,
Expand All @@ -8,27 +9,29 @@ import {
} from "../utils.js";
import { getBuildOptions, runBuild } from "@apphosting/common";

const opts = getBuildOptions();
if (isMain(import.meta)) {
const opts = getBuildOptions();

// Check build conditions, which vary depending on your project structure (standalone or monorepo)
await checkBuildConditions(opts);
// Check build conditions, which vary depending on your project structure (standalone or monorepo)
await checkBuildConditions(opts);

// enable JSON build logs for application builder
process.env.NG_BUILD_LOGS_JSON = "1";
const { stdout: output } = await runBuild();
if (!output) {
throw new Error("No output from Angular build command, expecting a build manifest file.");
}
// enable JSON build logs for application builder
process.env.NG_BUILD_LOGS_JSON = "1";
const { stdout: output } = await runBuild();
if (!output) {
throw new Error("No output from Angular build command, expecting a build manifest file.");
}

const angularVersion = process.env.FRAMEWORK_VERSION || "unspecified";
// Frameworks like nitro, analog, nuxt generate the output bundle during their own build process
// when `npm run build` is called which we don't want to overwrite immediately after.
// We only want to overwrite if the existing output is from a previous framework adapter
// build on a plain angular app.
if (!metaFrameworkOutputBundleExists()) {
const outputBundleOptions = parseOutputBundleOptions(output);
const root = process.cwd();
await generateBuildOutput(root, outputBundleOptions, angularVersion);
const angularVersion = process.env.FRAMEWORK_VERSION || "unspecified";
// Frameworks like nitro, analog, nuxt generate the output bundle during their own build process
// when `npm run build` is called which we don't want to overwrite immediately after.
// We only want to overwrite if the existing output is from a previous framework adapter
// build on a plain angular app.
if (!metaFrameworkOutputBundleExists()) {
const outputBundleOptions = parseOutputBundleOptions(output);
const root = process.cwd();
await generateBuildOutput(root, outputBundleOptions, angularVersion);

await validateOutputDirectory(outputBundleOptions);
await validateOutputDirectory(outputBundleOptions);
}
}
109 changes: 56 additions & 53 deletions packages/@apphosting/adapter-nextjs/src/bin/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env node
import {
isMain,
loadConfig,
populateOutputBundleOptions,
generateBuildOutput,
Expand All @@ -17,64 +18,66 @@ import {
validateNextConfigOverride,
} from "../overrides.js";

const root = process.cwd();
const opts = getBuildOptions();
if (isMain(import.meta)) {
const root = process.cwd();
const opts = getBuildOptions();

// Set standalone mode
process.env.NEXT_PRIVATE_STANDALONE = "true";
// Opt-out sending telemetry to Vercel
process.env.NEXT_TELEMETRY_DISABLED = "1";
// Set standalone mode
process.env.NEXT_PRIVATE_STANDALONE = "true";
// Opt-out sending telemetry to Vercel
process.env.NEXT_TELEMETRY_DISABLED = "1";

checkNextJSVersion(process.env.FRAMEWORK_VERSION);
const nextConfig = await loadConfig(root, opts.projectDirectory);
checkNextJSVersion(process.env.FRAMEWORK_VERSION);
const nextConfig = await loadConfig(root, opts.projectDirectory);

/**
* Override user's Next Config to optimize the app for Firebase App Hosting
* and validate that the override resulted in a valid config that Next.js can
* load.
*
* We restore the user's Next Config at the end of the build, after the config file has been
* copied over to the output directory, so that the user's original code is not modified.
*
* If the app does not have a next.config.[js|mjs|ts] file in the first place,
* then can skip config override.
*
* Note: loadConfig always returns a fileName (default: next.config.js) even if
* one does not exist in the app's root: https://github.com/vercel/next.js/blob/23681508ca34b66a6ef55965c5eac57de20eb67f/packages/next/src/server/config.ts#L1115
*/
const nextConfigPath = join(root, nextConfig.configFileName);
if (await exists(nextConfigPath)) {
await overrideNextConfig(root, nextConfig.configFileName);
await validateNextConfigOverride(root, opts.projectDirectory, nextConfig.configFileName);
}
/**
* Override user's Next Config to optimize the app for Firebase App Hosting
* and validate that the override resulted in a valid config that Next.js can
* load.
*
* We restore the user's Next Config at the end of the build, after the config file has been
* copied over to the output directory, so that the user's original code is not modified.
*
* If the app does not have a next.config.[js|mjs|ts] file in the first place,
* then can skip config override.
*
* Note: loadConfig always returns a fileName (default: next.config.js) even if
* one does not exist in the app's root: https://github.com/vercel/next.js/blob/23681508ca34b66a6ef55965c5eac57de20eb67f/packages/next/src/server/config.ts#L1115
*/
const nextConfigPath = join(root, nextConfig.configFileName);
if (await exists(nextConfigPath)) {
await overrideNextConfig(root, nextConfig.configFileName);
await validateNextConfigOverride(root, opts.projectDirectory, nextConfig.configFileName);
}

try {
await runBuild();
try {
await runBuild();

const adapterMetadata = getAdapterMetadata();
const nextBuildDirectory = join(opts.projectDirectory, nextConfig.distDir);
const outputBundleOptions = populateOutputBundleOptions(
root,
opts.projectDirectory,
nextBuildDirectory,
);
const adapterMetadata = getAdapterMetadata();
const nextBuildDirectory = join(opts.projectDirectory, nextConfig.distDir);
const outputBundleOptions = populateOutputBundleOptions(
root,
opts.projectDirectory,
nextBuildDirectory,
);

await addRouteOverrides(
outputBundleOptions.outputDirectoryAppPath,
nextConfig.distDir,
adapterMetadata,
);
await addRouteOverrides(
outputBundleOptions.outputDirectoryAppPath,
nextConfig.distDir,
adapterMetadata,
);

const nextjsVersion = process.env.FRAMEWORK_VERSION || "unspecified";
await generateBuildOutput(
root,
opts.projectDirectory,
outputBundleOptions,
nextBuildDirectory,
nextjsVersion,
adapterMetadata,
);
await validateOutputDirectory(outputBundleOptions, nextBuildDirectory);
} finally {
await restoreNextConfig(root, nextConfig.configFileName);
const nextjsVersion = process.env.FRAMEWORK_VERSION || "unspecified";
await generateBuildOutput(
root,
opts.projectDirectory,
outputBundleOptions,
nextBuildDirectory,
nextjsVersion,
adapterMetadata,
);
await validateOutputDirectory(outputBundleOptions, nextBuildDirectory);
} finally {
await restoreNextConfig(root, nextConfig.configFileName);
}
}
5 changes: 3 additions & 2 deletions packages/@apphosting/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@
"license": "Apache-2.0",
"dependencies": {
"@apphosting/common": "*",
"@npmcli/promise-spawn": "^3.0.0",
"@npmcli/promise-spawn": "^3.0.0",
"colorette": "^2.0.20",
"commander": "^11.1.0",
"npm-pick-manifest": "^9.0.0",
"ts-node": "^10.9.1"
"ts-node": "^10.9.1",
"yaml": "^2.3.4"
},
"devDependencies": {
"@types/commander": "*",
Expand Down
Loading
Loading