Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
13
node_modules/@angular/fire/schematics/add/index.js
generated
vendored
Normal file
13
node_modules/@angular/fire/schematics/add/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ngAdd = void 0;
|
||||
const common_1 = require("../common");
|
||||
const versions_json_1 = require("../versions.json");
|
||||
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
||||
const ngAdd = (options) => (tree, context) => {
|
||||
common_1.addDependencies(tree, versions_json_1.peerDependencies, context);
|
||||
const npmInstallTaskId = context.addTask(new tasks_1.NodePackageInstallTask());
|
||||
context.addTask(new tasks_1.RunSchematicTask('ng-add-setup-project', options), [npmInstallTaskId]);
|
||||
return tree;
|
||||
};
|
||||
exports.ngAdd = ngAdd;
|
||||
16
node_modules/@angular/fire/schematics/add/schema.json
generated
vendored
Normal file
16
node_modules/@angular/fire/schematics/add/schema.json
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "angular-fire-ng-add",
|
||||
"title": "AngularFire ng-add",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"project": {
|
||||
"type": "string",
|
||||
"description": "The name of the project.",
|
||||
"$default": {
|
||||
"$source": "projectName"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
}
|
||||
10
node_modules/@angular/fire/schematics/builders.json
generated
vendored
Normal file
10
node_modules/@angular/fire/schematics/builders.json
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
||||
"builders": {
|
||||
"deploy": {
|
||||
"implementation": "./deploy/builder",
|
||||
"schema": "./deploy/schema.json",
|
||||
"description": "Deploy builder"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
node_modules/@angular/fire/schematics/collection.json
generated
vendored
Normal file
15
node_modules/@angular/fire/schematics/collection.json
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
||||
"schematics": {
|
||||
"ng-add": {
|
||||
"description": "Add firebase deploy schematic",
|
||||
"factory": "./add#ngAdd",
|
||||
"schema": "./add/schema.json"
|
||||
},
|
||||
"ng-add-setup-project": {
|
||||
"description": "Setup ng deploy",
|
||||
"factory": "./setup#ngAddSetupProject",
|
||||
"schema": "./setup/schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
102
node_modules/@angular/fire/schematics/common.js
generated
vendored
Normal file
102
node_modules/@angular/fire/schematics/common.js
generated
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
"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;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addDependencies = exports.safeReadJSON = exports.generateFirebaseRc = exports.overwriteIfExists = exports.stringifyFormatted = exports.shortSiteName = void 0;
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const semver = __importStar(require("semver"));
|
||||
const shortSiteName = (site) => (site === null || site === void 0 ? void 0 : site.name) && site.name.split('/').pop();
|
||||
exports.shortSiteName = shortSiteName;
|
||||
const stringifyFormatted = (obj) => JSON.stringify(obj, null, 2);
|
||||
exports.stringifyFormatted = stringifyFormatted;
|
||||
const overwriteIfExists = (tree, path, content) => {
|
||||
if (tree.exists(path)) {
|
||||
tree.overwrite(path, content);
|
||||
}
|
||||
else {
|
||||
tree.create(path, content);
|
||||
}
|
||||
};
|
||||
exports.overwriteIfExists = overwriteIfExists;
|
||||
function emptyFirebaseRc() {
|
||||
return {
|
||||
targets: {}
|
||||
};
|
||||
}
|
||||
function generateFirebaseRcTarget(firebaseProject, firebaseHostingSite, project) {
|
||||
var _a;
|
||||
return {
|
||||
hosting: {
|
||||
[project]: [
|
||||
(_a = exports.shortSiteName(firebaseHostingSite)) !== null && _a !== void 0 ? _a : firebaseProject
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
function generateFirebaseRc(tree, path, firebaseProject, firebaseHostingSite, project) {
|
||||
const firebaseRc = tree.exists(path)
|
||||
? safeReadJSON(path, tree)
|
||||
: emptyFirebaseRc();
|
||||
firebaseRc.targets = firebaseRc.targets || {};
|
||||
firebaseRc.targets[firebaseProject] = generateFirebaseRcTarget(firebaseProject, firebaseHostingSite, project);
|
||||
firebaseRc.projects = { default: firebaseProject };
|
||||
exports.overwriteIfExists(tree, path, exports.stringifyFormatted(firebaseRc));
|
||||
}
|
||||
exports.generateFirebaseRc = generateFirebaseRc;
|
||||
function safeReadJSON(path, tree) {
|
||||
try {
|
||||
return JSON.parse(tree.read(path).toString());
|
||||
}
|
||||
catch (e) {
|
||||
throw new schematics_1.SchematicsException(`Error when parsing ${path}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
exports.safeReadJSON = safeReadJSON;
|
||||
const addDependencies = (host, deps, context) => {
|
||||
var _a, _b;
|
||||
const packageJson = host.exists('package.json') && safeReadJSON('package.json', host);
|
||||
if (packageJson === undefined) {
|
||||
throw new schematics_1.SchematicsException('Could not locate package.json');
|
||||
}
|
||||
(_a = packageJson.devDependencies) !== null && _a !== void 0 ? _a : (packageJson.devDependencies = {});
|
||||
(_b = packageJson.dependencies) !== null && _b !== void 0 ? _b : (packageJson.dependencies = {});
|
||||
Object.keys(deps).forEach(depName => {
|
||||
const dep = deps[depName];
|
||||
const existingDeps = dep.dev ? packageJson.devDependencies : packageJson.dependencies;
|
||||
const existingVersion = existingDeps[depName];
|
||||
if (existingVersion) {
|
||||
try {
|
||||
if (!semver.intersects(existingVersion, dep.version)) {
|
||||
context.logger.warn(`⚠️ The ${depName} devDependency specified in your package.json (${existingVersion}) does not fulfill AngularFire's dependency (${dep.version})`);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (existingVersion !== dep.version) {
|
||||
context.logger.warn(`⚠️ The ${depName} devDependency specified in your package.json (${existingVersion}) does not fulfill AngularFire's dependency (${dep.version})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
existingDeps[depName] = dep.version;
|
||||
}
|
||||
});
|
||||
exports.overwriteIfExists(host, 'package.json', exports.stringifyFormatted(packageJson));
|
||||
};
|
||||
exports.addDependencies = addDependencies;
|
||||
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."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
74
node_modules/@angular/fire/schematics/firebaseTools.js
generated
vendored
Normal file
74
node_modules/@angular/fire/schematics/firebaseTools.js
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getFirebaseTools = void 0;
|
||||
const child_process_1 = require("child_process");
|
||||
const ora_1 = __importDefault(require("ora"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const getFirebaseTools = () => globalThis.firebaseTools ?
|
||||
Promise.resolve(globalThis.firebaseTools) :
|
||||
new Promise((resolve, reject) => {
|
||||
var _a;
|
||||
(_a = process.env).FIREBASE_CLI_EXPERIMENTS || (_a.FIREBASE_CLI_EXPERIMENTS = 'webframeworks');
|
||||
try {
|
||||
resolve(require('firebase-tools'));
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
const root = child_process_1.execSync('npm root --location=global').toString().trim();
|
||||
resolve(require(`${root}/firebase-tools`));
|
||||
}
|
||||
catch (e) {
|
||||
const spinner = ora_1.default({
|
||||
text: `Installing firebase-tools...`,
|
||||
discardStdin: process.platform !== 'win32',
|
||||
}).start();
|
||||
child_process_1.spawn('npm', ['i', '--location=global', 'firebase-tools'], {
|
||||
stdio: 'pipe',
|
||||
shell: true,
|
||||
}).on('close', (code) => {
|
||||
if (code === 0) {
|
||||
spinner.succeed('firebase-tools installed globally.');
|
||||
spinner.stop();
|
||||
const root = child_process_1.execSync('npm root -g').toString().trim();
|
||||
resolve(require(`${root}/firebase-tools`));
|
||||
}
|
||||
else {
|
||||
spinner.fail('Package install failed.');
|
||||
reject();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).then(firebaseTools => {
|
||||
globalThis.firebaseTools = firebaseTools;
|
||||
const version = firebaseTools.cli.version();
|
||||
console.log(`Using firebase-tools version ${version}`);
|
||||
if (semver.compare(version, '9.9.0') === -1) {
|
||||
console.error('firebase-tools version 9.9+ is required, please upgrade and run again');
|
||||
return Promise.reject();
|
||||
}
|
||||
return firebaseTools;
|
||||
});
|
||||
exports.getFirebaseTools = getFirebaseTools;
|
||||
15
node_modules/@angular/fire/schematics/interfaces.js
generated
vendored
Normal file
15
node_modules/@angular/fire/schematics/interfaces.js
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.featureOptions = void 0;
|
||||
exports.featureOptions = [
|
||||
{ name: 'ng deploy -- hosting', value: 0 },
|
||||
{ name: 'Authentication', value: 1 },
|
||||
{ name: 'Firestore', value: 7 },
|
||||
{ name: 'Realtime Database', value: 3 },
|
||||
{ name: 'Analytics', value: 2 },
|
||||
{ name: 'Cloud Functions (callable)', value: 4 },
|
||||
{ name: 'Cloud Messaging', value: 5 },
|
||||
{ name: 'Performance Monitoring', value: 6 },
|
||||
{ name: 'Cloud Storage', value: 8 },
|
||||
{ name: 'Remote Config', value: 9 },
|
||||
];
|
||||
15
node_modules/@angular/fire/schematics/migration.json
generated
vendored
Normal file
15
node_modules/@angular/fire/schematics/migration.json
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
||||
"schematics": {
|
||||
"migration-v7": {
|
||||
"version": "7.0.0",
|
||||
"description": "Update @angular/fire to v7",
|
||||
"factory": "./update/v7#ngUpdate"
|
||||
},
|
||||
"ng-post-upgate": {
|
||||
"description": "Print out results after ng-update",
|
||||
"factory": "./update#ngPostUpdate",
|
||||
"private": true
|
||||
}
|
||||
}
|
||||
}
|
||||
155
node_modules/@angular/fire/schematics/setup/index.js
generated
vendored
Normal file
155
node_modules/@angular/fire/schematics/setup/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
"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());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.setupFirebase = exports.generateFirebaseJson = exports.ngAddSetupProject = exports.setupProject = void 0;
|
||||
const core_1 = require("@angular-devkit/core");
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const utils_1 = require("../utils");
|
||||
const prompts_1 = require("./prompts");
|
||||
const firebaseTools_1 = require("../firebaseTools");
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const common_1 = require("../common");
|
||||
const setupProject = (tree, context, features, config) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const { path: workspacePath, workspace } = utils_1.getWorkspace(tree);
|
||||
const { project, projectName } = utils_1.getProject(config, tree);
|
||||
const sourcePath = (_a = project.sourceRoot) !== null && _a !== void 0 ? _a : project.root;
|
||||
utils_1.addIgnoreFiles(tree);
|
||||
const featuresToImport = features.filter(it => it !== 0);
|
||||
if (featuresToImport.length > 0) {
|
||||
utils_1.addToNgModule(tree, { features: featuresToImport, sourcePath });
|
||||
utils_1.addFixesToServer(tree, { features: featuresToImport, sourcePath });
|
||||
}
|
||||
if (config.sdkConfig) {
|
||||
const source = `
|
||||
firebase: {
|
||||
${Object.entries(config.sdkConfig).reduce((c, [k, v]) => c.concat(` ${k}: '${v}'`), []).join(',\n')},
|
||||
}`;
|
||||
const environmentPath = `${sourcePath}/environments/environment.ts`;
|
||||
utils_1.addEnvironmentEntry(tree, `/${environmentPath}`, source);
|
||||
Object.values(project.architect || {}).forEach(builder => {
|
||||
Object.values(builder.configurations || {}).forEach(configuration => {
|
||||
(configuration.fileReplacements || []).forEach((replacement) => {
|
||||
if (replacement.replace === environmentPath) {
|
||||
utils_1.addEnvironmentEntry(tree, `/${replacement.with}`, source);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
const options = {
|
||||
project: projectName,
|
||||
firebaseProject: config.firebaseProject,
|
||||
firebaseApp: config.firebaseApp,
|
||||
firebaseHostingSite: config.firebaseHostingSite,
|
||||
sdkConfig: config.sdkConfig,
|
||||
prerender: undefined,
|
||||
browserTarget: config.browserTarget,
|
||||
serverTarget: config.serverTarget,
|
||||
prerenderTarget: config.prerenderTarget,
|
||||
ssrRegion: config.ssrRegion,
|
||||
};
|
||||
if (features.includes(0)) {
|
||||
return exports.setupFirebase({
|
||||
workspace,
|
||||
workspacePath,
|
||||
options,
|
||||
tree,
|
||||
context,
|
||||
project
|
||||
});
|
||||
}
|
||||
else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
exports.setupProject = setupProject;
|
||||
const ngAddSetupProject = (options) => (host, context) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
let projectRoot = host._backend._root;
|
||||
if (process.platform.startsWith('win32')) {
|
||||
projectRoot = core_1.asWindowsPath(core_1.normalize(projectRoot));
|
||||
}
|
||||
const features = yield prompts_1.featuresPrompt();
|
||||
if (features.length > 0) {
|
||||
const firebaseTools = yield firebaseTools_1.getFirebaseTools();
|
||||
if (!host.exists('/firebase.json')) {
|
||||
fs_1.writeFileSync(path_1.join(projectRoot, 'firebase.json'), '{}');
|
||||
}
|
||||
const user = yield prompts_1.userPrompt({ projectRoot });
|
||||
yield firebaseTools.login.use(user.email, { projectRoot });
|
||||
const { project: ngProject, projectName: ngProjectName } = utils_1.getProject(options, host);
|
||||
const [defaultProjectName] = utils_1.getFirebaseProjectNameFromHost(host, ngProjectName);
|
||||
const firebaseProject = yield prompts_1.projectPrompt(defaultProjectName, { projectRoot, account: user.email });
|
||||
let hosting = {};
|
||||
let firebaseHostingSite;
|
||||
if (features.includes(0)) {
|
||||
const results = yield prompts_1.projectTypePrompt(ngProject, ngProjectName);
|
||||
hosting = Object.assign(Object.assign({}, hosting), results);
|
||||
firebaseHostingSite = yield prompts_1.sitePrompt(firebaseProject, { projectRoot });
|
||||
}
|
||||
let firebaseApp;
|
||||
let sdkConfig;
|
||||
if (features.find(it => it !== 0)) {
|
||||
const defaultAppId = firebaseHostingSite === null || firebaseHostingSite === void 0 ? void 0 : firebaseHostingSite.appId;
|
||||
firebaseApp = yield prompts_1.appPrompt(firebaseProject, defaultAppId, { projectRoot });
|
||||
const result = yield firebaseTools.apps.sdkconfig('web', firebaseApp.appId, { nonInteractive: true, projectRoot });
|
||||
sdkConfig = result.sdkConfig;
|
||||
}
|
||||
yield exports.setupProject(host, context, features, Object.assign(Object.assign(Object.assign({}, options), hosting), { firebaseProject, firebaseApp, firebaseHostingSite, sdkConfig }));
|
||||
}
|
||||
});
|
||||
exports.ngAddSetupProject = ngAddSetupProject;
|
||||
function generateFirebaseJson(tree, path, project, region) {
|
||||
const firebaseJson = tree.exists(path)
|
||||
? common_1.safeReadJSON(path, tree)
|
||||
: {};
|
||||
const newConfig = {
|
||||
target: project,
|
||||
source: '.',
|
||||
frameworksBackend: {
|
||||
region
|
||||
}
|
||||
};
|
||||
if (firebaseJson.hosting === undefined) {
|
||||
firebaseJson.hosting = [newConfig];
|
||||
}
|
||||
else if (Array.isArray(firebaseJson.hosting)) {
|
||||
const existingConfigIndex = firebaseJson.hosting.findIndex(config => config.target === newConfig.target);
|
||||
if (existingConfigIndex > -1) {
|
||||
firebaseJson.hosting.splice(existingConfigIndex, 1, newConfig);
|
||||
}
|
||||
else {
|
||||
firebaseJson.hosting.push(newConfig);
|
||||
}
|
||||
}
|
||||
else {
|
||||
firebaseJson.hosting = [firebaseJson.hosting, newConfig];
|
||||
}
|
||||
common_1.overwriteIfExists(tree, path, common_1.stringifyFormatted(firebaseJson));
|
||||
}
|
||||
exports.generateFirebaseJson = generateFirebaseJson;
|
||||
const setupFirebase = (config) => {
|
||||
const { tree, workspacePath, workspace, options } = config;
|
||||
const project = workspace.projects[options.project];
|
||||
if (!project.architect) {
|
||||
throw new schematics_1.SchematicsException(`Angular project "${options.project}" has a malformed angular.json`);
|
||||
}
|
||||
project.architect.deploy = {
|
||||
builder: '@angular/fire:deploy',
|
||||
options: Object.assign(Object.assign({ version: 2, browserTarget: options.browserTarget }, (options.serverTarget ? { serverTarget: options.serverTarget } : {})), (options.prerenderTarget ? { prerenderTarget: options.prerenderTarget } : {}))
|
||||
};
|
||||
tree.overwrite(workspacePath, JSON.stringify(workspace, null, 2));
|
||||
generateFirebaseJson(tree, 'firebase.json', options.project, options.ssrRegion);
|
||||
common_1.generateFirebaseRc(tree, '.firebaserc', options.firebaseProject.projectId, options.firebaseHostingSite, options.project);
|
||||
return tree;
|
||||
};
|
||||
exports.setupFirebase = setupFirebase;
|
||||
275
node_modules/@angular/fire/schematics/setup/prompts.js
generated
vendored
Normal file
275
node_modules/@angular/fire/schematics/setup/prompts.js
generated
vendored
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
"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());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.projectTypePrompt = exports.sitePrompt = exports.appPrompt = exports.projectPrompt = exports.userPrompt = exports.featuresPrompt = exports.searchSites = exports.searchApps = exports.searchProjects = void 0;
|
||||
const fuzzy = __importStar(require("fuzzy"));
|
||||
const inquirer = __importStar(require("inquirer"));
|
||||
const interfaces_1 = require("../interfaces");
|
||||
const utils_1 = require("../utils");
|
||||
const firebaseTools_1 = require("../firebaseTools");
|
||||
const common_1 = require("../common");
|
||||
inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));
|
||||
const NEW_OPTION = '~~angularfire-new~~';
|
||||
const DEFAULT_SITE_TYPE = 'DEFAULT_SITE';
|
||||
const isProject = (elem) => {
|
||||
return elem.original === undefined;
|
||||
};
|
||||
const isApp = (elem) => {
|
||||
return elem.original === undefined;
|
||||
};
|
||||
const isSite = (elem) => {
|
||||
return elem.original === undefined;
|
||||
};
|
||||
const searchProjects = (projects) => (_, input) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
projects.unshift({
|
||||
projectId: NEW_OPTION,
|
||||
displayName: '[CREATE NEW PROJECT]'
|
||||
});
|
||||
return fuzzy.filter(input, projects, {
|
||||
extract(el) {
|
||||
return `${el.projectId} ${el.displayName}`;
|
||||
}
|
||||
}).map((result) => {
|
||||
let original;
|
||||
if (isProject(result)) {
|
||||
original = result;
|
||||
}
|
||||
else {
|
||||
original = result.original;
|
||||
}
|
||||
return {
|
||||
name: original.displayName,
|
||||
title: original.displayName,
|
||||
value: original.projectId
|
||||
};
|
||||
});
|
||||
});
|
||||
exports.searchProjects = searchProjects;
|
||||
const searchApps = (apps) => (_, input) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
apps.unshift({
|
||||
appId: NEW_OPTION,
|
||||
displayName: '[CREATE NEW APP]',
|
||||
});
|
||||
return fuzzy.filter(input, apps, {
|
||||
extract(el) {
|
||||
return el.displayName;
|
||||
}
|
||||
}).map((result) => {
|
||||
let original;
|
||||
if (isApp(result)) {
|
||||
original = result;
|
||||
}
|
||||
else {
|
||||
original = result.original;
|
||||
}
|
||||
return {
|
||||
name: original.displayName,
|
||||
title: original.displayName,
|
||||
value: utils_1.shortAppId(original),
|
||||
};
|
||||
});
|
||||
});
|
||||
exports.searchApps = searchApps;
|
||||
const searchSites = (sites) => (_, input) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
sites.unshift({
|
||||
name: NEW_OPTION,
|
||||
defaultUrl: '[CREATE NEW SITE]',
|
||||
});
|
||||
return fuzzy.filter(input, sites, {
|
||||
extract(el) {
|
||||
return el.defaultUrl;
|
||||
}
|
||||
}).map((result) => {
|
||||
let original;
|
||||
if (isSite(result)) {
|
||||
original = result;
|
||||
}
|
||||
else {
|
||||
original = result.original;
|
||||
}
|
||||
return {
|
||||
name: original.defaultUrl,
|
||||
title: original.defaultUrl,
|
||||
value: common_1.shortSiteName(original),
|
||||
};
|
||||
});
|
||||
});
|
||||
exports.searchSites = searchSites;
|
||||
const autocomplete = (questions) => inquirer.prompt(questions);
|
||||
const featuresPrompt = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { features } = yield inquirer.prompt({
|
||||
type: 'checkbox',
|
||||
name: 'features',
|
||||
choices: interfaces_1.featureOptions,
|
||||
message: 'What features would you like to setup?',
|
||||
default: [0],
|
||||
});
|
||||
return features;
|
||||
});
|
||||
exports.featuresPrompt = featuresPrompt;
|
||||
const userPrompt = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const firebaseTools = yield firebaseTools_1.getFirebaseTools();
|
||||
const users = yield firebaseTools.login.list();
|
||||
if (!users || users.length === 0) {
|
||||
yield firebaseTools.login();
|
||||
const user = yield firebaseTools.login(options);
|
||||
return user;
|
||||
}
|
||||
else {
|
||||
const defaultUser = yield firebaseTools.login(options);
|
||||
const choices = users.map(({ user }) => ({ name: user.email, value: user }));
|
||||
const newChoice = { name: '[Login in with another account]', value: NEW_OPTION };
|
||||
const { user } = yield inquirer.prompt({
|
||||
type: 'list',
|
||||
name: 'user',
|
||||
choices: [newChoice].concat(choices),
|
||||
message: 'Which Firebase account would you like to use?',
|
||||
default: (_a = choices.find(it => it.value.email === defaultUser.email)) === null || _a === void 0 ? void 0 : _a.value,
|
||||
});
|
||||
if (user === NEW_OPTION) {
|
||||
const { user } = yield firebaseTools.login.add();
|
||||
return user;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
});
|
||||
exports.userPrompt = userPrompt;
|
||||
const projectPrompt = (defaultProject, options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const firebaseTools = yield firebaseTools_1.getFirebaseTools();
|
||||
const projects = yield firebaseTools.projects.list(options);
|
||||
const { projectId } = yield autocomplete({
|
||||
type: 'autocomplete',
|
||||
name: 'projectId',
|
||||
source: exports.searchProjects(projects),
|
||||
message: 'Please select a project:',
|
||||
default: defaultProject,
|
||||
});
|
||||
if (projectId === NEW_OPTION) {
|
||||
const { projectId } = yield inquirer.prompt({
|
||||
type: 'input',
|
||||
name: 'projectId',
|
||||
message: `Please specify a unique project id (cannot be modified afterward) [6-30 characters]:`,
|
||||
});
|
||||
const { displayName } = yield inquirer.prompt({
|
||||
type: 'input',
|
||||
name: 'displayName',
|
||||
message: 'What would you like to call your project?',
|
||||
default: projectId,
|
||||
});
|
||||
return yield firebaseTools.projects.create(projectId, { account: options.account, displayName, nonInteractive: true });
|
||||
}
|
||||
return (yield projects).find(it => it.projectId === projectId);
|
||||
});
|
||||
exports.projectPrompt = projectPrompt;
|
||||
const appPrompt = ({ projectId: project }, defaultAppId, options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const firebaseTools = yield firebaseTools_1.getFirebaseTools();
|
||||
const apps = yield firebaseTools.apps.list('web', Object.assign(Object.assign({}, options), { project }));
|
||||
const { appId } = yield autocomplete({
|
||||
type: 'autocomplete',
|
||||
name: 'appId',
|
||||
source: exports.searchApps(apps),
|
||||
message: 'Please select an app:',
|
||||
default: defaultAppId,
|
||||
});
|
||||
if (appId === NEW_OPTION) {
|
||||
const { displayName } = yield inquirer.prompt({
|
||||
type: 'input',
|
||||
name: 'displayName',
|
||||
message: 'What would you like to call your app?',
|
||||
});
|
||||
return yield firebaseTools.apps.create('web', displayName, Object.assign(Object.assign({}, options), { nonInteractive: true, project }));
|
||||
}
|
||||
return (yield apps).find(it => utils_1.shortAppId(it) === appId);
|
||||
});
|
||||
exports.appPrompt = appPrompt;
|
||||
const sitePrompt = ({ projectId: project }, options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const firebaseTools = yield firebaseTools_1.getFirebaseTools();
|
||||
const sites = yield firebaseTools.hosting.sites.list(Object.assign(Object.assign({}, options), { project })).then(it => {
|
||||
if (it.sites.length === 0) {
|
||||
return [{
|
||||
name: project,
|
||||
defaultUrl: `https://${project}.web.app`,
|
||||
type: DEFAULT_SITE_TYPE,
|
||||
appId: undefined,
|
||||
}];
|
||||
}
|
||||
else {
|
||||
return it.sites;
|
||||
}
|
||||
});
|
||||
const { siteName } = yield autocomplete({
|
||||
type: 'autocomplete',
|
||||
name: 'siteName',
|
||||
source: exports.searchSites(sites),
|
||||
message: 'Please select a hosting site:',
|
||||
default: _ => common_1.shortSiteName(sites.find(site => site.type === DEFAULT_SITE_TYPE)),
|
||||
});
|
||||
if (siteName === NEW_OPTION) {
|
||||
const { subdomain } = yield inquirer.prompt({
|
||||
type: 'input',
|
||||
name: 'subdomain',
|
||||
message: 'Please provide an unique, URL-friendly id for the site (<id>.web.app):',
|
||||
});
|
||||
return yield firebaseTools.hosting.sites.create(subdomain, Object.assign(Object.assign({}, options), { nonInteractive: true, project }));
|
||||
}
|
||||
return (yield sites).find(it => common_1.shortSiteName(it) === siteName);
|
||||
});
|
||||
exports.sitePrompt = sitePrompt;
|
||||
const DEFAULT_REGION = 'us-central1';
|
||||
const ALLOWED_SSR_REGIONS = [
|
||||
{ name: 'us-central1 (Iowa)', value: 'us-central1' },
|
||||
{ name: 'us-west1 (Oregon)', value: 'us-west1' },
|
||||
{ name: 'us-east1 (South Carolina)', value: 'us-east1' },
|
||||
{ name: 'europe-west1 (Belgium)', value: 'europe-west1' },
|
||||
{ name: 'asia-east1 (Taiwan)', value: 'asia-east1' },
|
||||
];
|
||||
const projectTypePrompt = (project, name) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var _b, _c, _d, _e, _f, _g;
|
||||
let serverTarget;
|
||||
let browserTarget = `${name}:build:${((_c = (_b = project.architect) === null || _b === void 0 ? void 0 : _b.build) === null || _c === void 0 ? void 0 : _c.defaultConfiguration) || 'production'}`;
|
||||
let prerenderTarget;
|
||||
if (utils_1.isUniversalApp(project)) {
|
||||
serverTarget = `${name}:server:${((_e = (_d = project.architect) === null || _d === void 0 ? void 0 : _d.server) === null || _e === void 0 ? void 0 : _e.defaultConfiguration) || 'production'}`;
|
||||
browserTarget = `${name}:build:${((_g = (_f = project.architect) === null || _f === void 0 ? void 0 : _f.build) === null || _g === void 0 ? void 0 : _g.defaultConfiguration) || 'production'}`;
|
||||
const prerender = utils_1.hasPrerenderOption(project);
|
||||
prerenderTarget = prerender && `${name}:prerender:${prerender.defaultConfiguration || 'production'}`;
|
||||
const { ssrRegion } = yield inquirer.prompt({
|
||||
type: 'list',
|
||||
name: 'ssrRegion',
|
||||
choices: ALLOWED_SSR_REGIONS,
|
||||
message: 'In which region would you like to host server-side content?',
|
||||
default: DEFAULT_REGION,
|
||||
});
|
||||
return { prerender, projectType: 3, ssrRegion, browserTarget, serverTarget, prerenderTarget };
|
||||
}
|
||||
return { projectType: 3, browserTarget, serverTarget, prerenderTarget };
|
||||
});
|
||||
exports.projectTypePrompt = projectTypePrompt;
|
||||
16
node_modules/@angular/fire/schematics/setup/schema.json
generated
vendored
Normal file
16
node_modules/@angular/fire/schematics/setup/schema.json
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "angular-fire-ng-add",
|
||||
"title": "AngularFire ng-add",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"project": {
|
||||
"type": "string",
|
||||
"description": "The name of the project.",
|
||||
"$default": {
|
||||
"$source": "projectName"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
}
|
||||
7
node_modules/@angular/fire/schematics/update/index.js
generated
vendored
Normal file
7
node_modules/@angular/fire/schematics/update/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ngPostUpdate = void 0;
|
||||
const ngPostUpdate = () => (host, context) => {
|
||||
return host;
|
||||
};
|
||||
exports.ngPostUpdate = ngPostUpdate;
|
||||
67
node_modules/@angular/fire/schematics/update/v7/index.js
generated
vendored
Normal file
67
node_modules/@angular/fire/schematics/update/v7/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ngUpdate = void 0;
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
||||
const common_1 = require("../../common");
|
||||
const versions_json_1 = require("../../versions.json");
|
||||
const path_1 = require("path");
|
||||
const IMPORT_REGEX = /(?<key>import|export)\s+(?:(?<alias>[\w,{}\s\*]+)\s+from)?\s*(?:(?<quote>["'])?(?<ref>[@\w\s\\\/.-]+)\3?)\s*(?<term>[;\n])/g;
|
||||
const ngUpdate = () => (host, context) => {
|
||||
const packageJson = host.exists('package.json') && common_1.safeReadJSON('package.json', host);
|
||||
if (packageJson === undefined) {
|
||||
throw new schematics_1.SchematicsException('Could not locate package.json');
|
||||
}
|
||||
Object.keys(versions_json_1.peerDependencies).forEach(depName => {
|
||||
const dep = versions_json_1.peerDependencies[depName];
|
||||
if (dep) {
|
||||
packageJson[dep.dev ? 'devDependencies' : 'dependencies'][depName] = dep.version;
|
||||
}
|
||||
});
|
||||
Object.keys(versions_json_1.firebaseFunctionsDependencies).forEach(depName => {
|
||||
const dep = versions_json_1.firebaseFunctionsDependencies[depName];
|
||||
if (dep.dev && packageJson.devDependencies[depName]) {
|
||||
packageJson.devDependencies[depName] = dep.version;
|
||||
}
|
||||
else if (packageJson.dependencies[depName]) {
|
||||
packageJson.dependencies[depName] = dep.version;
|
||||
}
|
||||
});
|
||||
common_1.overwriteIfExists(host, 'package.json', common_1.stringifyFormatted(packageJson));
|
||||
context.addTask(new tasks_1.NodePackageInstallTask());
|
||||
const angularJson = host.exists('angular.json') && common_1.safeReadJSON('angular.json', host);
|
||||
if (packageJson === undefined) {
|
||||
throw new schematics_1.SchematicsException('Could not locate angular.json');
|
||||
}
|
||||
const srcRoots = Object.values(angularJson.projects).map((it) => path_1.join(...['/', it.root, it.sourceRoot].filter(it => !!it)));
|
||||
host.visit(filePath => {
|
||||
var _a;
|
||||
if (!filePath.endsWith('.ts') ||
|
||||
filePath.endsWith('.d.ts') ||
|
||||
!srcRoots.find(root => filePath.startsWith(root))) {
|
||||
return;
|
||||
}
|
||||
const content = (_a = host.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
||||
if (!content) {
|
||||
return;
|
||||
}
|
||||
const newContent = content.replace(IMPORT_REGEX, (substring, ...args) => {
|
||||
const { alias, key, ref, quote, term } = args.pop();
|
||||
if (ref.startsWith('@angular/fire') && !ref.startsWith('@angular/fire/compat')) {
|
||||
return `${key} ${alias} from ${quote}${ref.replace('@angular/fire', '@angular/fire/compat')}${quote}${term}`;
|
||||
}
|
||||
if (ref.startsWith('firebase') && !ref.startsWith('firebase/compat')) {
|
||||
return `${key} ${alias} from ${quote}${ref.replace('firebase', 'firebase/compat')}${quote}${term}`;
|
||||
}
|
||||
if (ref.startsWith('@firebase')) {
|
||||
return `${key} ${alias} from ${quote}${ref.replace('@firebase', 'firebase')}${quote}${term}`;
|
||||
}
|
||||
return substring;
|
||||
});
|
||||
if (content !== newContent) {
|
||||
common_1.overwriteIfExists(host, filePath, newContent);
|
||||
}
|
||||
});
|
||||
return host;
|
||||
};
|
||||
exports.ngUpdate = ngUpdate;
|
||||
219
node_modules/@angular/fire/schematics/utils.js
generated
vendored
Normal file
219
node_modules/@angular/fire/schematics/utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addIgnoreFiles = exports.addToNgModule = exports.addFixesToServer = exports.addEnvironmentEntry = exports.getFirebaseProjectNameFromFs = exports.getFirebaseProjectNameFromHost = exports.getProject = exports.getWorkspace = exports.shortAppId = exports.hasPrerenderOption = exports.isUniversalApp = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const typescript_1 = __importDefault(require("@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
||||
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
|
||||
const change_1 = require("@schematics/angular/utility/change");
|
||||
const find_module_1 = require("@schematics/angular/utility/find-module");
|
||||
const common_1 = require("./common");
|
||||
const isUniversalApp = (project) => { var _a; return (_a = project.architect) === null || _a === void 0 ? void 0 : _a.server; };
|
||||
exports.isUniversalApp = isUniversalApp;
|
||||
const hasPrerenderOption = (project) => { var _a; return (_a = project.architect) === null || _a === void 0 ? void 0 : _a.prerender; };
|
||||
exports.hasPrerenderOption = hasPrerenderOption;
|
||||
const shortAppId = (app) => (app === null || app === void 0 ? void 0 : app.appId) && app.appId.split('/').pop();
|
||||
exports.shortAppId = shortAppId;
|
||||
function getWorkspace(host) {
|
||||
const path = '/angular.json';
|
||||
const configBuffer = path && host.read(path);
|
||||
if (!configBuffer) {
|
||||
throw new schematics_1.SchematicsException(`Could not find angular.json`);
|
||||
}
|
||||
const { parse } = require('jsonc-parser');
|
||||
const workspace = parse(configBuffer.toString());
|
||||
if (!workspace) {
|
||||
throw new schematics_1.SchematicsException('Could not parse angular.json');
|
||||
}
|
||||
return {
|
||||
path,
|
||||
workspace
|
||||
};
|
||||
}
|
||||
exports.getWorkspace = getWorkspace;
|
||||
const getProject = (options, host) => {
|
||||
const { workspace } = getWorkspace(host);
|
||||
const projectName = options.project || workspace.defaultProject;
|
||||
if (!projectName) {
|
||||
throw new schematics_1.SchematicsException('No Angular project selected and no default project in the workspace');
|
||||
}
|
||||
const project = workspace.projects[projectName];
|
||||
if (!project) {
|
||||
throw new schematics_1.SchematicsException('The specified Angular project is not defined in this workspace');
|
||||
}
|
||||
if (project.projectType !== 'application') {
|
||||
throw new schematics_1.SchematicsException(`Deploy requires an Angular project type of "application" in angular.json`);
|
||||
}
|
||||
return { project, projectName };
|
||||
};
|
||||
exports.getProject = getProject;
|
||||
function getFirebaseProjectNameFromHost(host, target) {
|
||||
const buffer = host.read('/.firebaserc');
|
||||
if (!buffer) {
|
||||
return [undefined, undefined];
|
||||
}
|
||||
const rc = JSON.parse(buffer.toString());
|
||||
return projectFromRc(rc, target);
|
||||
}
|
||||
exports.getFirebaseProjectNameFromHost = getFirebaseProjectNameFromHost;
|
||||
function getFirebaseProjectNameFromFs(root, target) {
|
||||
const path = path_1.join(root, '.firebaserc');
|
||||
try {
|
||||
const buffer = fs_1.readFileSync(path);
|
||||
const rc = JSON.parse(buffer.toString());
|
||||
return projectFromRc(rc, target);
|
||||
}
|
||||
catch (e) {
|
||||
return [undefined, undefined];
|
||||
}
|
||||
}
|
||||
exports.getFirebaseProjectNameFromFs = getFirebaseProjectNameFromFs;
|
||||
const projectFromRc = (rc, target) => {
|
||||
var _a, _b, _c, _d, _e;
|
||||
const defaultProject = (_a = rc.projects) === null || _a === void 0 ? void 0 : _a.default;
|
||||
const project = Object.keys(rc.targets || {}).find(project => { var _a, _b, _c; return !!((_c = (_b = (_a = rc.targets) === null || _a === void 0 ? void 0 : _a[project]) === null || _b === void 0 ? void 0 : _b.hosting) === null || _c === void 0 ? void 0 : _c[target]); });
|
||||
const site = project && ((_e = (_d = (_c = (_b = rc.targets) === null || _b === void 0 ? void 0 : _b[project]) === null || _c === void 0 ? void 0 : _c.hosting) === null || _d === void 0 ? void 0 : _d[target]) === null || _e === void 0 ? void 0 : _e[0]);
|
||||
return [project || defaultProject, site];
|
||||
};
|
||||
function addEnvironmentEntry(host, filePath, data) {
|
||||
const fileExists = host.exists(filePath);
|
||||
if (fileExists) {
|
||||
const buffer = host.read(filePath);
|
||||
if (!buffer) {
|
||||
throw new schematics_1.SchematicsException(`Cannot read ${filePath}`);
|
||||
}
|
||||
const sourceFile = typescript_1.default.createSourceFile(filePath, buffer.toString('utf-8'), typescript_1.default.ScriptTarget.Latest, true);
|
||||
const envIdentifier = ast_utils_1.findNode(sourceFile, typescript_1.default.SyntaxKind.Identifier, 'environment');
|
||||
if (!envIdentifier || !envIdentifier.parent) {
|
||||
throw new schematics_1.SchematicsException(`Cannot find 'environment' identifier in ${filePath}`);
|
||||
}
|
||||
const envObjectLiteral = envIdentifier.parent.getChildren().find(({ kind }) => kind === typescript_1.default.SyntaxKind.ObjectLiteralExpression);
|
||||
if (!envObjectLiteral) {
|
||||
throw new schematics_1.SchematicsException(`${filePath} is not in the expected format`);
|
||||
}
|
||||
const firebaseIdentifier = ast_utils_1.findNode(envObjectLiteral, typescript_1.default.SyntaxKind.Identifier, 'firebase');
|
||||
const recorder = host.beginUpdate(filePath);
|
||||
if (firebaseIdentifier && firebaseIdentifier.parent) {
|
||||
const change = new change_1.ReplaceChange(filePath, firebaseIdentifier.parent.pos, firebaseIdentifier.parent.getFullText(), data);
|
||||
change_1.applyToUpdateRecorder(recorder, [change]);
|
||||
}
|
||||
else {
|
||||
const openBracketToken = envObjectLiteral.getChildren().find(({ kind }) => kind === typescript_1.default.SyntaxKind.OpenBraceToken);
|
||||
if (openBracketToken) {
|
||||
const change = new change_1.InsertChange(filePath, openBracketToken.end, `${data},`);
|
||||
change_1.applyToUpdateRecorder(recorder, [change]);
|
||||
}
|
||||
else {
|
||||
throw new schematics_1.SchematicsException(`${filePath} is not in the expected format`);
|
||||
}
|
||||
}
|
||||
host.commitUpdate(recorder);
|
||||
}
|
||||
else {
|
||||
host.create(filePath, `export const environment = {${data},
|
||||
};`);
|
||||
}
|
||||
return host;
|
||||
}
|
||||
exports.addEnvironmentEntry = addEnvironmentEntry;
|
||||
function addFixesToServer(host, options) {
|
||||
const serverPath = `/server.ts`;
|
||||
if (!host.exists(serverPath)) {
|
||||
return host;
|
||||
}
|
||||
const text = host.read(serverPath);
|
||||
if (text === null) {
|
||||
throw new schematics_1.SchematicsException(`File ${serverPath} does not exist.`);
|
||||
}
|
||||
const sourceText = text.toString('utf-8');
|
||||
const addZonePatch = !sourceText.includes('import \'zone.js/dist/zone-patch-rxjs\';');
|
||||
if (addZonePatch) {
|
||||
common_1.overwriteIfExists(host, serverPath, sourceText.replace('import \'zone.js/dist/zone-node\';', `import 'zone.js/dist/zone-node';
|
||||
${addZonePatch ? 'import \'zone.js/dist/zone-patch-rxjs\';' : ''}`));
|
||||
}
|
||||
return host;
|
||||
}
|
||||
exports.addFixesToServer = addFixesToServer;
|
||||
function addToNgModule(host, options) {
|
||||
const modulePath = `/${options.sourcePath}/app/app.module.ts`;
|
||||
if (!host.exists(modulePath)) {
|
||||
throw new Error(`Specified module path ${modulePath} does not exist`);
|
||||
}
|
||||
const text = host.read(modulePath);
|
||||
if (text === null) {
|
||||
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
||||
}
|
||||
const sourceText = text.toString('utf-8');
|
||||
const source = typescript_1.default.createSourceFile(modulePath, sourceText, typescript_1.default.ScriptTarget.Latest, true);
|
||||
const environmentsPath = find_module_1.buildRelativePath(modulePath, `/${options.sourcePath}/environments/environment`);
|
||||
const changes = [];
|
||||
if (!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'provideFirebaseApp')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['initializeApp', 'provideFirebaseApp'], '@angular/fire/app'), ast_utils_1.insertImport(source, modulePath, 'environment', environmentsPath), ...ast_utils_1.addImportToModule(source, modulePath, `provideFirebaseApp(() => initializeApp(environment.firebase))`, null));
|
||||
}
|
||||
if (options.features.includes(2) &&
|
||||
!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'provideAnalytics')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['provideAnalytics', 'getAnalytics', 'ScreenTrackingService', 'UserTrackingService'], '@angular/fire/analytics'), ...ast_utils_1.addImportToModule(source, modulePath, `provideAnalytics(() => getAnalytics())`, null), ...ast_utils_1.addProviderToModule(source, modulePath, ['ScreenTrackingService', 'UserTrackingService'], null));
|
||||
}
|
||||
if (options.features.includes(1) &&
|
||||
!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'provideAuth')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['provideAuth', 'getAuth'], '@angular/fire/auth'), ...ast_utils_1.addImportToModule(source, modulePath, `provideAuth(() => getAuth())`, null));
|
||||
}
|
||||
if (options.features.includes(3) &&
|
||||
!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'provideDatabase')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['provideDatabase', 'getDatabase'], '@angular/fire/database'), ...ast_utils_1.addImportToModule(source, modulePath, `provideDatabase(() => getDatabase())`, null));
|
||||
}
|
||||
if (options.features.includes(7) &&
|
||||
!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'provideFirestore')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['provideFirestore', 'getFirestore'], '@angular/fire/firestore'), ...ast_utils_1.addImportToModule(source, modulePath, `provideFirestore(() => getFirestore())`, null));
|
||||
}
|
||||
if (options.features.includes(4) &&
|
||||
!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'provideFunctions')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['provideFunctions', 'getFunctions'], '@angular/fire/functions'), ...ast_utils_1.addImportToModule(source, modulePath, `provideFunctions(() => getFunctions())`, null));
|
||||
}
|
||||
if (options.features.includes(5) &&
|
||||
!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'provideMessaging')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['provideMessaging', 'getMessaging'], '@angular/fire/messaging'), ...ast_utils_1.addImportToModule(source, modulePath, `provideMessaging(() => getMessaging())`, null));
|
||||
}
|
||||
if (options.features.includes(6) &&
|
||||
!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'providePerformance')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['providePerformance', 'getPerformance'], '@angular/fire/performance'), ...ast_utils_1.addImportToModule(source, modulePath, `providePerformance(() => getPerformance())`, null));
|
||||
}
|
||||
if (options.features.includes(9) &&
|
||||
!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'provideRemoteConfig')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['provideRemoteConfig', 'getRemoteConfig'], '@angular/fire/remote-config'), ...ast_utils_1.addImportToModule(source, modulePath, `provideRemoteConfig(() => getRemoteConfig())`, null));
|
||||
}
|
||||
if (options.features.includes(8) &&
|
||||
!ast_utils_1.findNode(source, typescript_1.default.SyntaxKind.Identifier, 'provideStorage')) {
|
||||
changes.push(ast_utils_1.insertImport(source, modulePath, ['provideStorage', 'getStorage'], '@angular/fire/storage'), ...ast_utils_1.addImportToModule(source, modulePath, `provideStorage(() => getStorage())`, null));
|
||||
}
|
||||
const recorder = host.beginUpdate(modulePath);
|
||||
change_1.applyToUpdateRecorder(recorder, changes);
|
||||
host.commitUpdate(recorder);
|
||||
return host;
|
||||
}
|
||||
exports.addToNgModule = addToNgModule;
|
||||
const addIgnoreFiles = (host) => {
|
||||
const path = '/.gitignore';
|
||||
if (!host.exists(path)) {
|
||||
return host;
|
||||
}
|
||||
const buffer = host.read(path);
|
||||
if (!buffer) {
|
||||
return host;
|
||||
}
|
||||
const content = buffer.toString();
|
||||
if (!content.includes('# Firebase')) {
|
||||
common_1.overwriteIfExists(host, path, content.concat(`
|
||||
# Firebase
|
||||
.firebase
|
||||
*-debug.log
|
||||
.runtimeconfig.json
|
||||
`));
|
||||
}
|
||||
return host;
|
||||
};
|
||||
exports.addIgnoreFiles = addIgnoreFiles;
|
||||
13
node_modules/@angular/fire/schematics/versions.json
generated
vendored
Normal file
13
node_modules/@angular/fire/schematics/versions.json
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"peerDependencies": {},
|
||||
"firebaseFunctionsDependencies": {
|
||||
"firebase-admin": {
|
||||
"dev": false,
|
||||
"version": "^9.11.1"
|
||||
},
|
||||
"firebase-functions": {
|
||||
"dev": false,
|
||||
"version": "^3.6.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue