Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
389
node_modules/@angular/fire/schematics/deploy/actions.js
generated
vendored
Normal file
389
node_modules/@angular/fire/schematics/deploy/actions.js
generated
vendored
Normal file
|
@ -0,0 +1,389 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.deployToCloudRun = exports.deployToFunction = void 0;
|
||||
const architect_1 = require("@angular-devkit/architect");
|
||||
const fs_1 = require("fs");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const path_1 = require("path");
|
||||
const child_process_1 = require("child_process");
|
||||
const functions_templates_1 = require("./functions-templates");
|
||||
const semver_1 = require("semver");
|
||||
const open_1 = __importDefault(require("open"));
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const versions_json_1 = require("../versions.json");
|
||||
const winston = __importStar(require("winston"));
|
||||
const triple_beam_1 = __importDefault(require("triple-beam"));
|
||||
const inquirer = __importStar(require("inquirer"));
|
||||
const DEFAULT_EMULATOR_PORT = 5000;
|
||||
const DEFAULT_EMULATOR_HOST = 'localhost';
|
||||
const DEFAULT_CLOUD_RUN_OPTIONS = {
|
||||
memory: '1Gi',
|
||||
timeout: 60,
|
||||
maxInstances: 'default',
|
||||
maxConcurrency: 'default',
|
||||
minInstances: 'default',
|
||||
cpus: 1,
|
||||
};
|
||||
const spawnAsync = (command, options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
return new Promise((resolve, reject) => {
|
||||
const [spawnCommand, ...args] = command.split(/\s+/);
|
||||
const spawnProcess = child_process_1.spawn(spawnCommand, args, options);
|
||||
const chunks = [];
|
||||
const errorChunks = [];
|
||||
spawnProcess.stdout.on('data', (data) => {
|
||||
process.stdout.write(data.toString());
|
||||
chunks.push(data);
|
||||
});
|
||||
spawnProcess.stderr.on('data', (data) => {
|
||||
process.stderr.write(data.toString());
|
||||
errorChunks.push(data);
|
||||
});
|
||||
spawnProcess.on('error', (error) => {
|
||||
reject(error);
|
||||
});
|
||||
spawnProcess.on('close', (code) => {
|
||||
if (code === 1) {
|
||||
reject(Buffer.concat(errorChunks).toString());
|
||||
return;
|
||||
}
|
||||
resolve(Buffer.concat(chunks));
|
||||
});
|
||||
});
|
||||
});
|
||||
const escapeRegExp = (str) => str.replace(/[\-\[\]\/{}()*+?.\\^$|]/g, '\\$&');
|
||||
const moveSync = (src, dest) => {
|
||||
fs_extra_1.copySync(src, dest);
|
||||
fs_extra_1.removeSync(src);
|
||||
};
|
||||
const deployToHosting = (firebaseTools, context, workspaceRoot, options, firebaseToken) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const siteTarget = (_a = options.target) !== null && _a !== void 0 ? _a : context.target.project;
|
||||
if (options.preview) {
|
||||
yield firebaseTools.serve({
|
||||
port: DEFAULT_EMULATOR_PORT,
|
||||
host: DEFAULT_EMULATOR_HOST,
|
||||
only: `hosting:${siteTarget}`,
|
||||
nonInteractive: true,
|
||||
projectRoot: workspaceRoot,
|
||||
});
|
||||
const { deployProject } = yield inquirer.prompt({
|
||||
type: 'confirm',
|
||||
name: 'deployProject',
|
||||
message: 'Would you like to deploy your application to Firebase Hosting?'
|
||||
});
|
||||
if (!deployProject) {
|
||||
return;
|
||||
}
|
||||
process.env.FIREBASE_FRAMEWORKS_SKIP_BUILD = 'true';
|
||||
}
|
||||
return yield firebaseTools.deploy({
|
||||
only: `hosting:${siteTarget}`,
|
||||
cwd: workspaceRoot,
|
||||
token: firebaseToken,
|
||||
nonInteractive: true,
|
||||
projectRoot: workspaceRoot,
|
||||
});
|
||||
});
|
||||
const defaultFsHost = {
|
||||
moveSync,
|
||||
writeFileSync: fs_1.writeFileSync,
|
||||
renameSync: fs_1.renameSync,
|
||||
copySync: fs_extra_1.copySync,
|
||||
removeSync: fs_extra_1.removeSync,
|
||||
existsSync: fs_1.existsSync,
|
||||
};
|
||||
const findPackageVersion = (packageManager, name) => {
|
||||
const match = child_process_1.execSync(`${packageManager} list ${name}`).toString().match(`[^|\s]${escapeRegExp(name)}[@| ][^\s]+(\s.+)?$`);
|
||||
return match ? match[0].split(new RegExp(`${escapeRegExp(name)}[@| ]`))[1].split(/\s/)[0] : null;
|
||||
};
|
||||
const getPackageJson = (context, workspaceRoot, options, main) => {
|
||||
var _a, _b, _c, _d, _e;
|
||||
const dependencies = {};
|
||||
const devDependencies = {};
|
||||
if (options.ssr !== 'cloud-run') {
|
||||
Object.keys(versions_json_1.firebaseFunctionsDependencies).forEach(name => {
|
||||
const { version, dev } = versions_json_1.firebaseFunctionsDependencies[name];
|
||||
(dev ? devDependencies : dependencies)[name] = version;
|
||||
});
|
||||
}
|
||||
if (fs_1.existsSync(path_1.join(workspaceRoot, 'angular.json'))) {
|
||||
const angularJson = JSON.parse(fs_1.readFileSync(path_1.join(workspaceRoot, 'angular.json')).toString());
|
||||
const packageManager = (_b = (_a = angularJson.cli) === null || _a === void 0 ? void 0 : _a.packageManager) !== null && _b !== void 0 ? _b : 'npm';
|
||||
const server = angularJson.projects[context.target.project].architect.server;
|
||||
const externalDependencies = ((_c = server === null || server === void 0 ? void 0 : server.options) === null || _c === void 0 ? void 0 : _c.externalDependencies) || [];
|
||||
const bundleDependencies = (_e = (_d = server === null || server === void 0 ? void 0 : server.options) === null || _d === void 0 ? void 0 : _d.bundleDependencies) !== null && _e !== void 0 ? _e : true;
|
||||
if (bundleDependencies) {
|
||||
externalDependencies.forEach(externalDependency => {
|
||||
const packageVersion = findPackageVersion(packageManager, externalDependency);
|
||||
if (packageVersion) {
|
||||
dependencies[externalDependency] = packageVersion;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (fs_1.existsSync(path_1.join(workspaceRoot, 'package.json'))) {
|
||||
const packageJson = JSON.parse(fs_1.readFileSync(path_1.join(workspaceRoot, 'package.json')).toString());
|
||||
Object.keys(packageJson.dependencies).forEach((dependency) => {
|
||||
dependencies[dependency] = packageJson.dependencies[dependency];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return functions_templates_1.defaultPackage(dependencies, devDependencies, options, main);
|
||||
};
|
||||
const deployToFunction = (firebaseTools, context, workspaceRoot, staticBuildTarget, serverBuildTarget, options, firebaseToken, fsHost = defaultFsHost) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var _b;
|
||||
const staticBuildOptions = yield context.getTargetOptions(architect_1.targetFromTargetString(staticBuildTarget.name));
|
||||
if (!staticBuildOptions.outputPath || typeof staticBuildOptions.outputPath !== 'string') {
|
||||
throw new Error(`Cannot read the output path option of the Angular project '${staticBuildTarget.name}' in angular.json`);
|
||||
}
|
||||
const serverBuildOptions = yield context.getTargetOptions(architect_1.targetFromTargetString(serverBuildTarget.name));
|
||||
if (!serverBuildOptions.outputPath || typeof serverBuildOptions.outputPath !== 'string') {
|
||||
throw new Error(`Cannot read the output path option of the Angular project '${serverBuildTarget.name}' in angular.json`);
|
||||
}
|
||||
const staticOut = path_1.join(workspaceRoot, staticBuildOptions.outputPath);
|
||||
const serverOut = path_1.join(workspaceRoot, serverBuildOptions.outputPath);
|
||||
const functionsOut = options.outputPath ? path_1.join(workspaceRoot, options.outputPath) : path_1.dirname(serverOut);
|
||||
const functionName = options.functionName || functions_templates_1.DEFAULT_FUNCTION_NAME;
|
||||
const newStaticOut = path_1.join(functionsOut, staticBuildOptions.outputPath);
|
||||
const newServerOut = path_1.join(functionsOut, serverBuildOptions.outputPath);
|
||||
if (options.outputPath) {
|
||||
fsHost.removeSync(functionsOut);
|
||||
fsHost.copySync(staticOut, newStaticOut);
|
||||
fsHost.copySync(serverOut, newServerOut);
|
||||
}
|
||||
else {
|
||||
fsHost.moveSync(staticOut, newStaticOut);
|
||||
fsHost.moveSync(serverOut, newServerOut);
|
||||
}
|
||||
const packageJson = getPackageJson(context, workspaceRoot, options);
|
||||
const nodeVersion = packageJson.engines.node;
|
||||
if (!semver_1.satisfies(process.versions.node, nodeVersion.toString())) {
|
||||
context.logger.warn(`⚠️ Your Node.js version (${process.versions.node}) does not match the Firebase Functions runtime (${nodeVersion}).`);
|
||||
}
|
||||
const functionsPackageJsonPath = path_1.join(functionsOut, 'package.json');
|
||||
fsHost.writeFileSync(functionsPackageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||
if (options.CF3v2) {
|
||||
fsHost.writeFileSync(path_1.join(functionsOut, 'index.js'), functions_templates_1.functionGen2(serverBuildOptions.outputPath, options, functionName));
|
||||
}
|
||||
else {
|
||||
fsHost.writeFileSync(path_1.join(functionsOut, 'index.js'), functions_templates_1.defaultFunction(serverBuildOptions.outputPath, options, functionName));
|
||||
}
|
||||
if (!options.prerender) {
|
||||
try {
|
||||
fsHost.renameSync(path_1.join(newStaticOut, 'index.html'), path_1.join(newStaticOut, 'index.original.html'));
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
const siteTarget = (_b = options.target) !== null && _b !== void 0 ? _b : context.target.project;
|
||||
if (fsHost.existsSync(functionsPackageJsonPath)) {
|
||||
child_process_1.execSync(`npm --prefix ${functionsOut} install`);
|
||||
}
|
||||
else {
|
||||
console.error(`No package.json exists at ${functionsOut}`);
|
||||
}
|
||||
if (options.preview) {
|
||||
yield firebaseTools.serve({
|
||||
port: DEFAULT_EMULATOR_PORT,
|
||||
host: DEFAULT_EMULATOR_HOST,
|
||||
targets: [`hosting:${siteTarget}`, `functions:${functionName}`],
|
||||
nonInteractive: true,
|
||||
projectRoot: workspaceRoot,
|
||||
});
|
||||
const { deployProject } = yield inquirer.prompt({
|
||||
type: 'confirm',
|
||||
name: 'deployProject',
|
||||
message: 'Would you like to deploy your application to Firebase Hosting & Cloud Functions?'
|
||||
});
|
||||
if (!deployProject) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return yield firebaseTools.deploy({
|
||||
only: `hosting:${siteTarget},functions:${functionName}`,
|
||||
cwd: workspaceRoot,
|
||||
token: firebaseToken,
|
||||
nonInteractive: true,
|
||||
projectRoot: workspaceRoot,
|
||||
});
|
||||
});
|
||||
exports.deployToFunction = deployToFunction;
|
||||
const deployToCloudRun = (firebaseTools, context, workspaceRoot, staticBuildTarget, serverBuildTarget, options, firebaseToken, fsHost = defaultFsHost) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var _c;
|
||||
const staticBuildOptions = yield context.getTargetOptions(architect_1.targetFromTargetString(staticBuildTarget.name));
|
||||
if (!staticBuildOptions.outputPath || typeof staticBuildOptions.outputPath !== 'string') {
|
||||
throw new Error(`Cannot read the output path option of the Angular project '${staticBuildTarget.name}' in angular.json`);
|
||||
}
|
||||
const serverBuildOptions = yield context.getTargetOptions(architect_1.targetFromTargetString(serverBuildTarget.name));
|
||||
if (!serverBuildOptions.outputPath || typeof serverBuildOptions.outputPath !== 'string') {
|
||||
throw new Error(`Cannot read the output path option of the Angular project '${serverBuildTarget.name}' in angular.json`);
|
||||
}
|
||||
const staticOut = path_1.join(workspaceRoot, staticBuildOptions.outputPath);
|
||||
const serverOut = path_1.join(workspaceRoot, serverBuildOptions.outputPath);
|
||||
const cloudRunOut = options.outputPath ? path_1.join(workspaceRoot, options.outputPath) : path_1.join(path_1.dirname(serverOut), 'run');
|
||||
const serviceId = options.functionName || functions_templates_1.DEFAULT_FUNCTION_NAME;
|
||||
const newStaticOut = path_1.join(cloudRunOut, staticBuildOptions.outputPath);
|
||||
const newServerOut = path_1.join(cloudRunOut, serverBuildOptions.outputPath);
|
||||
fsHost.removeSync(cloudRunOut);
|
||||
fsHost.copySync(staticOut, newStaticOut);
|
||||
fsHost.copySync(serverOut, newServerOut);
|
||||
const packageJson = getPackageJson(context, workspaceRoot, options, path_1.join(serverBuildOptions.outputPath, 'main.js'));
|
||||
const nodeVersion = packageJson.engines.node;
|
||||
if (!semver_1.satisfies(process.versions.node, nodeVersion.toString())) {
|
||||
context.logger.warn(`⚠️ Your Node.js version (${process.versions.node}) does not match the Cloud Run runtime (${nodeVersion}).`);
|
||||
}
|
||||
fsHost.writeFileSync(path_1.join(cloudRunOut, 'package.json'), JSON.stringify(packageJson, null, 2));
|
||||
fsHost.writeFileSync(path_1.join(cloudRunOut, 'Dockerfile'), functions_templates_1.dockerfile(options));
|
||||
if (!options.prerender) {
|
||||
try {
|
||||
fsHost.renameSync(path_1.join(newStaticOut, 'index.html'), path_1.join(newStaticOut, 'index.original.html'));
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
if (options.preview) {
|
||||
throw new schematics_1.SchematicsException('Cloud Run preview not supported.');
|
||||
}
|
||||
const deployArguments = [];
|
||||
const cloudRunOptions = options.cloudRunOptions || {};
|
||||
Object.entries(DEFAULT_CLOUD_RUN_OPTIONS).forEach(([k, v]) => {
|
||||
cloudRunOptions[k] || (cloudRunOptions[k] = v);
|
||||
});
|
||||
if (cloudRunOptions.cpus) {
|
||||
deployArguments.push('--cpu', cloudRunOptions.cpus);
|
||||
}
|
||||
if (cloudRunOptions.maxConcurrency) {
|
||||
deployArguments.push('--concurrency', cloudRunOptions.maxConcurrency);
|
||||
}
|
||||
if (cloudRunOptions.maxInstances) {
|
||||
deployArguments.push('--max-instances', cloudRunOptions.maxInstances);
|
||||
}
|
||||
if (cloudRunOptions.memory) {
|
||||
deployArguments.push('--memory', cloudRunOptions.memory);
|
||||
}
|
||||
if (cloudRunOptions.minInstances) {
|
||||
deployArguments.push('--min-instances', cloudRunOptions.minInstances);
|
||||
}
|
||||
if (cloudRunOptions.timeout) {
|
||||
deployArguments.push('--timeout', cloudRunOptions.timeout);
|
||||
}
|
||||
if (cloudRunOptions.vpcConnector) {
|
||||
deployArguments.push('--vpc-connector', cloudRunOptions.vpcConnector);
|
||||
}
|
||||
context.logger.info(`📦 Deploying to Cloud Run`);
|
||||
yield spawnAsync(`gcloud builds submit ${cloudRunOut} --tag gcr.io/${options.firebaseProject}/${serviceId} --project ${options.firebaseProject} --quiet`);
|
||||
yield spawnAsync(`gcloud run deploy ${serviceId} --image gcr.io/${options.firebaseProject}/${serviceId} --project ${options.firebaseProject} ${deployArguments.join(' ')} --platform managed --allow-unauthenticated --region=${options.region} --quiet`);
|
||||
const siteTarget = (_c = options.target) !== null && _c !== void 0 ? _c : context.target.project;
|
||||
return yield firebaseTools.deploy({
|
||||
only: `hosting:${siteTarget}`,
|
||||
cwd: workspaceRoot,
|
||||
token: firebaseToken,
|
||||
nonInteractive: true,
|
||||
projectRoot: workspaceRoot,
|
||||
});
|
||||
});
|
||||
exports.deployToCloudRun = deployToCloudRun;
|
||||
function deploy(firebaseTools, context, staticBuildTarget, serverBuildTarget, prerenderBuildTarget, firebaseProject, options, firebaseToken) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!firebaseToken) {
|
||||
yield firebaseTools.login();
|
||||
const user = yield firebaseTools.login({ projectRoot: context.workspaceRoot });
|
||||
console.log(`Logged into Firebase as ${user.email}.`);
|
||||
}
|
||||
if (options.version && options.version >= 2) {
|
||||
if (semver_1.lt(firebaseTools.cli.version(), '12.2.0')) {
|
||||
throw new schematics_1.SchematicsException('firebase-tools version 12.2+ is required.');
|
||||
}
|
||||
process.env.FIREBASE_FRAMEWORK_BUILD_TARGET = (prerenderBuildTarget || serverBuildTarget || staticBuildTarget).name;
|
||||
}
|
||||
else {
|
||||
if (prerenderBuildTarget) {
|
||||
const run = yield context.scheduleTarget(architect_1.targetFromTargetString(prerenderBuildTarget.name), prerenderBuildTarget.options);
|
||||
yield run.result;
|
||||
}
|
||||
else {
|
||||
if (!context.target) {
|
||||
throw new Error('Cannot execute the build target');
|
||||
}
|
||||
context.logger.info(`📦 Building "${context.target.project}"`);
|
||||
const builders = [
|
||||
context.scheduleTarget(architect_1.targetFromTargetString(staticBuildTarget.name), staticBuildTarget.options).then(run => run.result)
|
||||
];
|
||||
if (serverBuildTarget) {
|
||||
builders.push(context.scheduleTarget(architect_1.targetFromTargetString(serverBuildTarget.name), serverBuildTarget.options).then(run => run.result));
|
||||
}
|
||||
yield Promise.all(builders);
|
||||
}
|
||||
}
|
||||
try {
|
||||
yield firebaseTools.use(firebaseProject, {
|
||||
project: firebaseProject,
|
||||
projectRoot: context.workspaceRoot,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error(`Cannot select firebase project '${firebaseProject}'`);
|
||||
}
|
||||
options.firebaseProject = firebaseProject;
|
||||
const logger = new winston.transports.Console({
|
||||
level: 'info',
|
||||
format: winston.format.printf((info) => {
|
||||
var _a, _b, _c, _d;
|
||||
const emulator = (_c = (_b = (_a = info[triple_beam_1.default.SPLAT]) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.emulator;
|
||||
const text = (_d = info[triple_beam_1.default.SPLAT]) === null || _d === void 0 ? void 0 : _d[0];
|
||||
if (text === null || text === void 0 ? void 0 : text.replace) {
|
||||
const plainText = text.replace(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]/g, '');
|
||||
if ((emulator === null || emulator === void 0 ? void 0 : emulator.name) === 'hosting' && plainText.startsWith('Local server: ')) {
|
||||
open_1.default(plainText.split(': ')[1]);
|
||||
}
|
||||
}
|
||||
return [info.message, ...(info[triple_beam_1.default.SPLAT] || [])]
|
||||
.filter((chunk) => typeof chunk === 'string')
|
||||
.join(' ');
|
||||
})
|
||||
});
|
||||
firebaseTools.logger.logger.add(logger);
|
||||
if ((!options.version || options.version < 2) && serverBuildTarget) {
|
||||
if (options.ssr === 'cloud-run') {
|
||||
yield exports.deployToCloudRun(firebaseTools, context, context.workspaceRoot, staticBuildTarget, serverBuildTarget, options, firebaseToken);
|
||||
}
|
||||
else {
|
||||
yield exports.deployToFunction(firebaseTools, context, context.workspaceRoot, staticBuildTarget, serverBuildTarget, options, firebaseToken);
|
||||
}
|
||||
}
|
||||
else {
|
||||
yield deployToHosting(firebaseTools, context, context.workspaceRoot, options, firebaseToken);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.default = deploy;
|
61
node_modules/@angular/fire/schematics/deploy/builder.js
generated
vendored
Normal file
61
node_modules/@angular/fire/schematics/deploy/builder.js
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const architect_1 = require("@angular-devkit/architect");
|
||||
const actions_1 = __importDefault(require("./actions"));
|
||||
const utils_1 = require("../utils");
|
||||
const firebaseTools_1 = require("../firebaseTools");
|
||||
exports.default = architect_1.createBuilder((options, context) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
if (!context.target) {
|
||||
throw new Error('Cannot deploy the application without a target');
|
||||
}
|
||||
const [defaultFirebaseProject, defulatFirebaseHostingSite] = utils_1.getFirebaseProjectNameFromFs(context.workspaceRoot, context.target.project);
|
||||
const firebaseProject = options.firebaseProject || defaultFirebaseProject;
|
||||
if (!firebaseProject) {
|
||||
throw new Error('Cannot detirmine the Firebase Project from your angular.json or .firebaserc');
|
||||
}
|
||||
if (firebaseProject !== defaultFirebaseProject) {
|
||||
throw new Error('The Firebase Project specified by your angular.json or .firebaserc is in conflict');
|
||||
}
|
||||
const firebaseHostingSite = options.firebaseHostingSite || defulatFirebaseHostingSite;
|
||||
if (!firebaseHostingSite) {
|
||||
throw new Error(`Cannot detirmine the Firebase Hosting Site from your angular.json or .firebaserc`);
|
||||
}
|
||||
if (firebaseHostingSite !== defulatFirebaseHostingSite) {
|
||||
throw new Error('The Firebase Hosting Site specified by your angular.json or .firebaserc is in conflict');
|
||||
}
|
||||
const staticBuildTarget = { name: options.browserTarget || options.buildTarget || `${context.target.project}:build:production` };
|
||||
let prerenderBuildTarget;
|
||||
if (options.prerender) {
|
||||
prerenderBuildTarget = {
|
||||
name: options.prerenderTarget || `${context.target.project}:prerender:production`
|
||||
};
|
||||
}
|
||||
let serverBuildTarget;
|
||||
if (options.ssr) {
|
||||
serverBuildTarget = {
|
||||
name: options.serverTarget || options.universalBuildTarget || `${context.target.project}:server:production`
|
||||
};
|
||||
}
|
||||
try {
|
||||
process.env.FIREBASE_DEPLOY_AGENT = 'angularfire';
|
||||
yield actions_1.default((yield firebaseTools_1.getFirebaseTools()), context, staticBuildTarget, serverBuildTarget, prerenderBuildTarget, firebaseProject, options, process.env.FIREBASE_TOKEN);
|
||||
}
|
||||
catch (e) {
|
||||
console.error('Error when trying to deploy: ');
|
||||
console.error(e.message);
|
||||
return { success: false };
|
||||
}
|
||||
return { success: true };
|
||||
}));
|
57
node_modules/@angular/fire/schematics/deploy/functions-templates.js
generated
vendored
Normal file
57
node_modules/@angular/fire/schematics/deploy/functions-templates.js
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.dockerfile = exports.functionGen2 = exports.defaultFunction = exports.defaultPackage = exports.DEFAULT_FUNCTION_NAME = exports.DEFAULT_NODE_VERSION = void 0;
|
||||
exports.DEFAULT_NODE_VERSION = 14;
|
||||
exports.DEFAULT_FUNCTION_NAME = 'ssr';
|
||||
const DEFAULT_FUNCTION_REGION = 'us-central1';
|
||||
const DEFAULT_RUNTIME_OPTIONS = {
|
||||
timeoutSeconds: 60,
|
||||
memory: '1GB'
|
||||
};
|
||||
const defaultPackage = (dependencies, devDependencies, options, main) => ({
|
||||
name: 'functions',
|
||||
description: 'Angular Universal Application',
|
||||
main: main !== null && main !== void 0 ? main : 'index.js',
|
||||
scripts: {
|
||||
start: main ? `node ${main}` : 'firebase functions:shell',
|
||||
},
|
||||
engines: {
|
||||
node: (options.functionsNodeVersion || exports.DEFAULT_NODE_VERSION).toString()
|
||||
},
|
||||
dependencies,
|
||||
devDependencies,
|
||||
private: true
|
||||
});
|
||||
exports.defaultPackage = defaultPackage;
|
||||
const defaultFunction = (path, options, functionName) => `const functions = require('firebase-functions');
|
||||
|
||||
// Increase readability in Cloud Logging
|
||||
require("firebase-functions/lib/logger/compat");
|
||||
|
||||
const expressApp = require('./${path}/main').app();
|
||||
|
||||
exports.${functionName || exports.DEFAULT_FUNCTION_NAME} = functions
|
||||
.region('${options.region || DEFAULT_FUNCTION_REGION}')
|
||||
.runWith(${JSON.stringify(options.functionsRuntimeOptions || DEFAULT_RUNTIME_OPTIONS)})
|
||||
.https
|
||||
.onRequest(expressApp);
|
||||
`;
|
||||
exports.defaultFunction = defaultFunction;
|
||||
const functionGen2 = (path, options, functionName) => `const { onRequest } = require('firebase-functions/v2/https');
|
||||
|
||||
// Increase readability in Cloud Logging
|
||||
require("firebase-functions/lib/logger/compat");
|
||||
|
||||
const expressApp = require('./${path}/main').app();
|
||||
|
||||
exports.${functionName || exports.DEFAULT_FUNCTION_NAME} = onRequest(${JSON.stringify(Object.assign({ region: options.region || DEFAULT_FUNCTION_REGION }, (options.functionsRuntimeOptions || DEFAULT_RUNTIME_OPTIONS)))}, expressApp);
|
||||
`;
|
||||
exports.functionGen2 = functionGen2;
|
||||
const dockerfile = (options) => `FROM node:${options.functionsNodeVersion || exports.DEFAULT_NODE_VERSION}-slim
|
||||
WORKDIR /usr/src/app
|
||||
COPY package*.json ./
|
||||
RUN npm install --only=production
|
||||
COPY . ./
|
||||
CMD [ "npm", "start" ]
|
||||
`;
|
||||
exports.dockerfile = dockerfile;
|
119
node_modules/@angular/fire/schematics/deploy/schema.json
generated
vendored
Normal file
119
node_modules/@angular/fire/schematics/deploy/schema.json
generated
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "FirebaseDeploySchema",
|
||||
"title": "Firebase Deploy",
|
||||
"description": "Ng Deploy target options for Firebase.",
|
||||
"properties": {
|
||||
"buildTarget": {
|
||||
"type": "string",
|
||||
"description": "Target to build.",
|
||||
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$"
|
||||
},
|
||||
"browserTarget": {
|
||||
"type": "string",
|
||||
"description": "Target to build.",
|
||||
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$"
|
||||
},
|
||||
"prerenderTarget": {
|
||||
"type": "string",
|
||||
"description": "Target to build.",
|
||||
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$"
|
||||
},
|
||||
"serverTarget": {
|
||||
"type": "string",
|
||||
"description": "Target to build.",
|
||||
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$"
|
||||
},
|
||||
"universalBuildTarget": {
|
||||
"type": "string",
|
||||
"description": "Target to build.",
|
||||
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$"
|
||||
},
|
||||
"ssr": {
|
||||
"oneOf": [{ "type": "boolean" }, { "type": "string" }],
|
||||
"description": "Should we attempt to deploy the function to Cloud Functions (true or 'cloud-functions') / Cloud Run ('cloud-run') or just Hosting (false)"
|
||||
},
|
||||
"prerender": {
|
||||
"type": "boolean",
|
||||
"description": "Prerender before deploy?"
|
||||
},
|
||||
"firebaseProject": {
|
||||
"type": "string",
|
||||
"description": "The Firebase project name or project alias to use when deploying"
|
||||
},
|
||||
"target": {
|
||||
"type": "string",
|
||||
"description": "The Firebase hosting target in firebase.json for multi-site"
|
||||
},
|
||||
"firebaseHostingSite": {
|
||||
"type": "string",
|
||||
"description": "The Firebase Hosting site to deploy to"
|
||||
},
|
||||
"functionName": {
|
||||
"type": "string",
|
||||
"description": "The name of the Cloud Function or Cloud Run serviceId to deploy SSR to"
|
||||
},
|
||||
"functionsNodeVersion": {
|
||||
"oneOf": [{ "type": "number" }, { "type": "string" }],
|
||||
"description": "Version of Node.js to run Cloud Functions / Run on"
|
||||
},
|
||||
"CF3v2": {
|
||||
"type": "boolean",
|
||||
"description": "Generation of the Functions product to run on"
|
||||
},
|
||||
"region": {
|
||||
"type": "string",
|
||||
"description": "The region to deploy Cloud Functions or Cloud Run to"
|
||||
},
|
||||
"outputPath": {
|
||||
"type": "string",
|
||||
"description": "Where to output the deploy artifacts"
|
||||
},
|
||||
"functionsRuntimeOptions": {
|
||||
"type": "object",
|
||||
"description": "Runtime options for Cloud Functions, if deploying to Cloud Functions"
|
||||
},
|
||||
"preview": {
|
||||
"type": "boolean",
|
||||
"description": "Do not deploy the application, just set up the Firebase Function in the project output directory. Can be used for testing the Firebase Function with `firebase serve`."
|
||||
},
|
||||
"cloudRunOptions": {
|
||||
"type": "object",
|
||||
"description": "Options passed to Cloud Run, if deploying to Cloud Run.",
|
||||
"properties": {
|
||||
"cpus": {
|
||||
"type": "number",
|
||||
"description": "Set a CPU limit in Kubernetes cpu units."
|
||||
},
|
||||
"maxConcurrency": {
|
||||
"oneOf": [{ "type": "number" }, { "type": "string" }],
|
||||
"pattern": "^(\\d+|default)$",
|
||||
"description": "Set the maximum number of concurrent requests allowed per container instance. If concurrency is unspecified, any number of concurrent requests are allowed. To unset this field, provide the special value default."
|
||||
},
|
||||
"maxInstances": {
|
||||
"oneOf": [{ "type": "number" }, { "type": "string" }],
|
||||
"pattern": "^(\\d+|default)$",
|
||||
"description": "The maximum number of container instances of the Service to run. Use 'default' to unset the limit and use the platform default."
|
||||
},
|
||||
"memory": {
|
||||
"type": "string",
|
||||
"pattern": "^\\d+(G|M)i$",
|
||||
"description": "Set a memory limit. Ex: 1Gi, 512Mi."
|
||||
},
|
||||
"minInstances": {
|
||||
"oneOf": [{ "type": "number" }, { "type": "string" }],
|
||||
"pattern": "^(\\d+|default)$",
|
||||
"description": "The minimum number of container instances of the Service to run or 'default' to remove any minimum."
|
||||
},
|
||||
"timeout": {
|
||||
"type": "number",
|
||||
"description": "Set the maximum request execution time (timeout) in seconds."
|
||||
},
|
||||
"vpcConnector": {
|
||||
"type": "string",
|
||||
"description": "Set a VPC connector for this resource."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue