diff --git a/package-lock.json b/package-lock.json index 94837bf7..ae064970 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,10 +18,11 @@ "eslint-plugin-unicorn": "^49.0.0", "husky": "^4.3.0", "netlify-cli": "^17.2.0", + "npm-run-all": "^4.1.5", "prettier": "^2.1.2" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.13.0" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 744201b5..cc19afcb 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "eslint-plugin-unicorn": "^49.0.0", "husky": "^4.3.0", "netlify-cli": "^17.2.0", + "npm-run-all": "^4.1.5", "prettier": "^2.1.2" }, "dependencies": { diff --git a/src/helpers/setUpEdgeFunction.js b/src/helpers/setUpEdgeFunction.js index 02e3b97e..6e514db5 100644 --- a/src/helpers/setUpEdgeFunction.js +++ b/src/helpers/setUpEdgeFunction.js @@ -2,6 +2,7 @@ const { Buffer } = require('node:buffer') const { existsSync, readdirSync } = require('node:fs') const { writeFile, mkdir, readFile } = require('node:fs/promises') const { join, relative, sep, posix } = require('node:path') +const process = require('node:process') const { readJson } = require('fs-extra') @@ -20,8 +21,26 @@ const getAllFilesIn = (dir) => const toPosix = (path) => path.split(sep).join(posix.sep) -const getProject = (angularJson) => { - const projectName = angularJson.defaultProject ?? Object.keys(angularJson.projects)[0] +const getProject = (angularJson, failBuild) => { + const selectedProject = process.env.ANGULAR_PROJECT + if (selectedProject) { + const project = angularJson.projects[selectedProject] + if (!project) { + return failBuild( + `Could not find project selected project "${selectedProject}" in angular.json. Please update the ANGULAR_PROJECT environment variable.`, + ) + } + return project + } + + const projectNames = Object.keys(angularJson.projects) + const [projectName] = projectNames + if (projectNames.length > 1) { + console.warn( + `Found multiple projects in angular.json, deploying "${projectName}". To deploy a different one, set the ANGULAR_PROJECT environment variable to the project name.`, + ) + } + return angularJson.projects[projectName] } @@ -62,7 +81,6 @@ const setUpEdgeFunction = async ({ angularJson, constants, failBuild }) => { import process from "node:process" globalThis.process = process - globalThis.global = globalThis globalThis.DenoEvent = globalThis.Event // storing this for fixup-event.mjs `