firebase-tools 13.22.0 → 13.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth.js +13 -1
- package/lib/crashlytics/buildToolsJarHelper.js +2 -2
- package/lib/deploy/functions/runtimes/discovery/index.js +6 -2
- package/lib/emulator/apphosting/index.js +3 -2
- package/lib/emulator/apphosting/serve.js +14 -5
- package/lib/emulator/controller.js +15 -4
- package/lib/emulator/downloadableEmulators.js +9 -9
- package/lib/emulator/functionsEmulator.js +2 -0
- package/lib/emulator/functionsRuntimeWorker.js +2 -1
- package/lib/emulator/hubExport.js +10 -3
- package/lib/emulator/storage/persistence.js +2 -2
- package/lib/extensions/extensionsHelper.js +12 -3
- package/lib/frameworks/constants.js +1 -1
- package/lib/frameworks/flutter/index.js +6 -6
- package/lib/frameworks/flutter/utils.js +34 -1
- package/lib/init/features/hosting/index.js +2 -2
- package/lib/init/spawn.js +21 -1
- package/lib/requireAuth.js +11 -1
- package/package.json +1 -2
- package/schema/firebase-config.json +3 -0
- package/templates/extensions/javascript/package.lint.json +2 -2
- package/templates/extensions/javascript/package.nolint.json +2 -2
- package/templates/extensions/typescript/package.lint.json +2 -2
- package/templates/extensions/typescript/package.nolint.json +2 -2
- package/templates/init/functions/javascript/package.lint.json +2 -2
- package/templates/init/functions/javascript/package.nolint.json +2 -2
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +2 -2
package/lib/auth.js
CHANGED
|
@@ -21,6 +21,7 @@ const crypto_1 = require("crypto");
|
|
|
21
21
|
const track_1 = require("./track");
|
|
22
22
|
const api_1 = require("./api");
|
|
23
23
|
const templates_1 = require("./templates");
|
|
24
|
+
const requireAuth_1 = require("./requireAuth");
|
|
24
25
|
portfinder.setBasePort(9005);
|
|
25
26
|
function getGlobalDefaultAccount() {
|
|
26
27
|
const user = configstore_1.configstore.get("user");
|
|
@@ -530,7 +531,18 @@ async function getAccessToken(refreshToken, authScopes) {
|
|
|
530
531
|
if (haveValidTokens(refreshToken, authScopes) && lastAccessToken) {
|
|
531
532
|
return lastAccessToken;
|
|
532
533
|
}
|
|
533
|
-
|
|
534
|
+
if (refreshToken) {
|
|
535
|
+
return refreshTokens(refreshToken, authScopes);
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
try {
|
|
539
|
+
return (0, requireAuth_1.refreshAuth)();
|
|
540
|
+
}
|
|
541
|
+
catch (err) {
|
|
542
|
+
logger_1.logger.debug(`Unable to refresh token: ${err}`);
|
|
543
|
+
}
|
|
544
|
+
throw new error_1.FirebaseError("Unable to getAccessToken");
|
|
545
|
+
}
|
|
534
546
|
}
|
|
535
547
|
exports.getAccessToken = getAccessToken;
|
|
536
548
|
async function logout(refreshToken) {
|
|
@@ -8,7 +8,7 @@ const spawn = require("cross-spawn");
|
|
|
8
8
|
const downloadUtils = require("../downloadUtils");
|
|
9
9
|
const error_1 = require("../error");
|
|
10
10
|
const logger_1 = require("../logger");
|
|
11
|
-
const
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
12
|
const utils = require("../utils");
|
|
13
13
|
const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
|
|
14
14
|
path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
|
|
@@ -26,7 +26,7 @@ async function fetchBuildtoolsJar() {
|
|
|
26
26
|
}
|
|
27
27
|
if (fs.existsSync(JAR_CACHE_DIR)) {
|
|
28
28
|
logger_1.logger.debug(`Deleting Jar cache at ${JAR_CACHE_DIR} because the CLI was run with a newer Jar version`);
|
|
29
|
-
|
|
29
|
+
(0, node_fs_1.rmSync)(JAR_CACHE_DIR, { recursive: true });
|
|
30
30
|
}
|
|
31
31
|
utils.logBullet("Downloading crashlytics-buildtools.jar to " + jarPath);
|
|
32
32
|
utils.logBullet("For open source licenses used by this command, look in the META-INF directory in the buildtools.jar file");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectFromPort = exports.detectFromYaml = exports.yamlToBuild = exports.readFileAsync = void 0;
|
|
3
|
+
exports.detectFromPort = exports.detectFromYaml = exports.yamlToBuild = exports.getFunctionDiscoveryTimeout = exports.readFileAsync = void 0;
|
|
4
4
|
const node_fetch_1 = require("node-fetch");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
@@ -12,6 +12,10 @@ const v1alpha1 = require("./v1alpha1");
|
|
|
12
12
|
const error_1 = require("../../../../error");
|
|
13
13
|
exports.readFileAsync = (0, util_1.promisify)(fs.readFile);
|
|
14
14
|
const TIMEOUT_OVERRIDE_ENV_VAR = "FUNCTIONS_DISCOVERY_TIMEOUT";
|
|
15
|
+
function getFunctionDiscoveryTimeout() {
|
|
16
|
+
return +(process.env[TIMEOUT_OVERRIDE_ENV_VAR] || 0) * 1000;
|
|
17
|
+
}
|
|
18
|
+
exports.getFunctionDiscoveryTimeout = getFunctionDiscoveryTimeout;
|
|
15
19
|
function yamlToBuild(yaml, project, region, runtime) {
|
|
16
20
|
try {
|
|
17
21
|
if (!yaml.specVersion) {
|
|
@@ -51,7 +55,7 @@ async function detectFromPort(port, project, runtime, timeout = 10000) {
|
|
|
51
55
|
const timedOut = new Promise((resolve, reject) => {
|
|
52
56
|
setTimeout(() => {
|
|
53
57
|
reject(new error_1.FirebaseError("User code failed to load. Cannot determine backend specification"));
|
|
54
|
-
},
|
|
58
|
+
}, getFunctionDiscoveryTimeout() || timeout);
|
|
55
59
|
});
|
|
56
60
|
while (true) {
|
|
57
61
|
try {
|
|
@@ -9,8 +9,9 @@ class AppHostingEmulator {
|
|
|
9
9
|
this.args = args;
|
|
10
10
|
}
|
|
11
11
|
async start() {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const { hostname, port } = await (0, serve_1.start)({
|
|
13
|
+
startCommand: this.args.startCommandOverride,
|
|
14
|
+
});
|
|
14
15
|
this.args.options.host = hostname;
|
|
15
16
|
this.args.options.port = port;
|
|
16
17
|
}
|
|
@@ -7,21 +7,30 @@ const utils_1 = require("./utils");
|
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
8
|
const spawn_1 = require("../../init/spawn");
|
|
9
9
|
const config_1 = require("./config");
|
|
10
|
-
|
|
10
|
+
const utils_2 = require("./utils");
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
async function start(options) {
|
|
11
13
|
const hostname = constants_1.DEFAULT_HOST;
|
|
12
14
|
let port = constants_1.DEFAULT_PORTS.apphosting;
|
|
13
15
|
while (!(await availablePort(hostname, port))) {
|
|
14
16
|
port += 1;
|
|
15
17
|
}
|
|
16
|
-
serve(port);
|
|
18
|
+
serve(port, options === null || options === void 0 ? void 0 : options.startCommand);
|
|
17
19
|
return { hostname, port };
|
|
18
20
|
}
|
|
19
21
|
exports.start = start;
|
|
20
|
-
async function serve(port) {
|
|
22
|
+
async function serve(port, startCommand) {
|
|
21
23
|
const rootDir = process.cwd();
|
|
22
|
-
const packageManager = await (0, utils_1.discoverPackageManager)(rootDir);
|
|
23
24
|
const apphostingLocalConfig = await (0, config_1.getLocalAppHostingConfiguration)(rootDir);
|
|
24
|
-
|
|
25
|
+
const environmentVariablesToInject = Object.assign(Object.assign({}, apphostingLocalConfig.environmentVariables), { PORT: port.toString() });
|
|
26
|
+
if (startCommand) {
|
|
27
|
+
utils_2.logger.logLabeled("BULLET", types_1.Emulators.APPHOSTING, `running custom start command: '${startCommand}'`);
|
|
28
|
+
await (0, spawn_1.spawnWithCommandString)(startCommand, rootDir, environmentVariablesToInject);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const packageManager = await (0, utils_1.discoverPackageManager)(rootDir);
|
|
32
|
+
utils_2.logger.logLabeled("BULLET", types_1.Emulators.APPHOSTING, `starting app with: '${packageManager} run dev'`);
|
|
33
|
+
await (0, spawn_1.wrapSpawn)(packageManager, ["run", "dev"], rootDir, environmentVariablesToInject);
|
|
25
34
|
}
|
|
26
35
|
function availablePort(host, port) {
|
|
27
36
|
return (0, portUtils_1.checkListenable)({
|
|
@@ -166,7 +166,7 @@ function findExportMetadata(importPath) {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
async function startAll(options, showUI = true, runningTestScript = false) {
|
|
169
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
169
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
170
170
|
const targets = filterEmulatorTargets(options);
|
|
171
171
|
options.targets = targets;
|
|
172
172
|
const singleProjectModeEnabled = ((_a = options.config.src.emulators) === null || _a === void 0 ? void 0 : _a.singleProjectMode) === undefined ||
|
|
@@ -208,9 +208,18 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
208
208
|
const emulatableBackends = [];
|
|
209
209
|
let extensionEmulator = undefined;
|
|
210
210
|
if (shouldStart(options, types_1.Emulators.EXTENSIONS)) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
let projectNumber = constants_1.Constants.FAKE_PROJECT_NUMBER;
|
|
212
|
+
if (!isDemoProject) {
|
|
213
|
+
try {
|
|
214
|
+
projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.EXTENSIONS).logLabeled("ERROR", types_1.Emulators.EXTENSIONS, `Unable to look up project number for ${options.project}.\n` +
|
|
218
|
+
" If this is a real project, ensure that you are logged in and have access to it.\n" +
|
|
219
|
+
" If this is a fake project, please use a project ID starting with 'demo-' to skip production calls.\n" +
|
|
220
|
+
" Continuing with a fake project number - secrets and other features that require production access may behave unexpectedly.");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
214
223
|
const aliases = (0, projectUtils_1.getAliases)(options, projectId);
|
|
215
224
|
extensionEmulator = new extensionsEmulator_1.ExtensionsEmulator({
|
|
216
225
|
options,
|
|
@@ -592,11 +601,13 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
592
601
|
await startEmulator(hostingEmulator);
|
|
593
602
|
}
|
|
594
603
|
if (experiments.isEnabled("emulatorapphosting")) {
|
|
604
|
+
const apphostingConfig = (_l = options.config.src.emulators) === null || _l === void 0 ? void 0 : _l[types_1.Emulators.APPHOSTING];
|
|
595
605
|
if (listenForEmulator.apphosting) {
|
|
596
606
|
const apphostingAddr = legacyGetFirstAddr(types_1.Emulators.APPHOSTING);
|
|
597
607
|
const apphostingEmulator = new apphosting_1.AppHostingEmulator({
|
|
598
608
|
host: apphostingAddr.host,
|
|
599
609
|
port: apphostingAddr.port,
|
|
610
|
+
startCommandOverride: apphostingConfig === null || apphostingConfig === void 0 ? void 0 : apphostingConfig.startCommandOverride,
|
|
600
611
|
options,
|
|
601
612
|
});
|
|
602
613
|
await startEmulator(apphostingEmulator);
|
|
@@ -48,20 +48,20 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
48
48
|
},
|
|
49
49
|
dataconnect: process.platform === "darwin"
|
|
50
50
|
? {
|
|
51
|
-
version: "1.5.
|
|
52
|
-
expectedSize:
|
|
53
|
-
expectedChecksum: "
|
|
51
|
+
version: "1.5.1",
|
|
52
|
+
expectedSize: 25289472,
|
|
53
|
+
expectedChecksum: "92c425072db66c7e2cfa40b703ed807b",
|
|
54
54
|
}
|
|
55
55
|
: process.platform === "win32"
|
|
56
56
|
? {
|
|
57
|
-
version: "1.5.
|
|
58
|
-
expectedSize:
|
|
59
|
-
expectedChecksum: "
|
|
57
|
+
version: "1.5.1",
|
|
58
|
+
expectedSize: 25720320,
|
|
59
|
+
expectedChecksum: "2a5c654770233b740980d5f98f24be73",
|
|
60
60
|
}
|
|
61
61
|
: {
|
|
62
|
-
version: "1.5.
|
|
63
|
-
expectedSize:
|
|
64
|
-
expectedChecksum: "
|
|
62
|
+
version: "1.5.1",
|
|
63
|
+
expectedSize: 25202840,
|
|
64
|
+
expectedChecksum: "f95156cbcac237268791638ea0eb10e7",
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
exports.DownloadDetails = {
|
|
@@ -256,11 +256,13 @@ class FunctionsEmulator {
|
|
|
256
256
|
}
|
|
257
257
|
async start() {
|
|
258
258
|
const credentialEnv = await this.getCredentialsEnvironment();
|
|
259
|
+
console.log("got creds env");
|
|
259
260
|
for (const e of this.staticBackends) {
|
|
260
261
|
e.env = Object.assign(Object.assign({}, credentialEnv), e.env);
|
|
261
262
|
}
|
|
262
263
|
if (Object.keys(this.adminSdkConfig || {}).length <= 1) {
|
|
263
264
|
const adminSdkConfig = await (0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(this.args.projectId);
|
|
265
|
+
console.log("got admin sdk");
|
|
264
266
|
if (adminSdkConfig) {
|
|
265
267
|
this.adminSdkConfig = adminSdkConfig;
|
|
266
268
|
}
|
|
@@ -7,6 +7,7 @@ const types_1 = require("./types");
|
|
|
7
7
|
const events_1 = require("events");
|
|
8
8
|
const emulatorLogger_1 = require("./emulatorLogger");
|
|
9
9
|
const error_1 = require("../error");
|
|
10
|
+
const discovery_1 = require("../deploy/functions/runtimes/discovery");
|
|
10
11
|
var RuntimeWorkerState;
|
|
11
12
|
(function (RuntimeWorkerState) {
|
|
12
13
|
RuntimeWorkerState["CREATED"] = "CREATED";
|
|
@@ -187,7 +188,7 @@ class RuntimeWorker {
|
|
|
187
188
|
const timeout = new Promise((resolve, reject) => {
|
|
188
189
|
setTimeout(() => {
|
|
189
190
|
reject(new error_1.FirebaseError("Failed to load function."));
|
|
190
|
-
}, 30000);
|
|
191
|
+
}, (0, discovery_1.getFunctionDiscoveryTimeout)() || 30000);
|
|
191
192
|
});
|
|
192
193
|
while (true) {
|
|
193
194
|
try {
|
|
@@ -11,7 +11,7 @@ const registry_1 = require("./registry");
|
|
|
11
11
|
const error_1 = require("../error");
|
|
12
12
|
const hub_1 = require("./hub");
|
|
13
13
|
const downloadableEmulators_1 = require("./downloadableEmulators");
|
|
14
|
-
const
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
15
15
|
const track_1 = require("../track");
|
|
16
16
|
class HubExport {
|
|
17
17
|
constructor(projectId, options) {
|
|
@@ -25,7 +25,14 @@ class HubExport {
|
|
|
25
25
|
if (!fs.existsSync(metadataPath)) {
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
let mdString = "";
|
|
29
|
+
try {
|
|
30
|
+
mdString = fs.readFileSync(metadataPath, "utf8").toString();
|
|
31
|
+
return JSON.parse(mdString);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
throw new error_1.FirebaseError(`Unable to parse metadata file ${metadataPath}: ${mdString}`);
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
37
|
async exportAll() {
|
|
31
38
|
const toExport = types_1.ALL_EMULATORS.filter(shouldExport);
|
|
@@ -74,7 +81,7 @@ class HubExport {
|
|
|
74
81
|
const metadataPath = path.join(this.tmpDir, HubExport.METADATA_FILE_NAME);
|
|
75
82
|
fs.writeFileSync(metadataPath, JSON.stringify(metadata, undefined, 2));
|
|
76
83
|
logger_1.logger.debug(`hubExport: swapping ${this.tmpDir} with ${this.exportPath}`);
|
|
77
|
-
|
|
84
|
+
(0, node_fs_1.rmSync)(this.exportPath, { recursive: true });
|
|
78
85
|
fse.moveSync(this.tmpDir, this.exportPath);
|
|
79
86
|
}
|
|
80
87
|
async exportFirestore(metadata) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Persistence = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
|
-
const
|
|
5
|
+
const promises_1 = require("node:fs/promises");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const fse = require("fs-extra");
|
|
8
8
|
const path = require("path");
|
|
@@ -57,7 +57,7 @@ class Persistence {
|
|
|
57
57
|
this._diskPathMap.delete(fileName);
|
|
58
58
|
}
|
|
59
59
|
async deleteAll() {
|
|
60
|
-
await (0,
|
|
60
|
+
await (0, promises_1.rm)(this._dirPath, { recursive: true });
|
|
61
61
|
this._diskPathMap = new Map();
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
@@ -98,9 +98,18 @@ async function getFirebaseProjectParams(projectId, emulatorMode = false) {
|
|
|
98
98
|
const body = emulatorMode
|
|
99
99
|
? await (0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(projectId)
|
|
100
100
|
: await (0, functionsConfig_1.getFirebaseConfig)({ project: projectId });
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
let projectNumber = constants_1.Constants.FAKE_PROJECT_NUMBER;
|
|
102
|
+
if (!constants_1.Constants.isDemoProject(projectId)) {
|
|
103
|
+
try {
|
|
104
|
+
projectNumber = await (0, getProjectNumber_1.getProjectNumber)({ projectId });
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
(0, utils_2.logLabeledError)("extensions", `Unable to look up project number for ${projectId}.\n` +
|
|
108
|
+
" If this is a real project, ensure that you are logged in and have access to it.\n" +
|
|
109
|
+
" If this is a fake project, please use a project ID starting with 'demo-' to skip production calls.\n" +
|
|
110
|
+
" Continuing with a fake project number - secrets and other features that require production access may behave unexpectedly.");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
104
113
|
const databaseURL = (_a = body === null || body === void 0 ? void 0 : body.databaseURL) !== null && _a !== void 0 ? _a : `https://${projectId}.firebaseio.com`;
|
|
105
114
|
const storageBucket = (_b = body === null || body === void 0 ? void 0 : body.storageBucket) !== null && _b !== void 0 ? _b : `${projectId}.appspot.com`;
|
|
106
115
|
const FIREBASE_CONFIG = JSON.stringify({
|
|
@@ -18,7 +18,7 @@ exports.MAILING_LIST_URL = "https://goo.gle/41enW5X";
|
|
|
18
18
|
const DEFAULT_FIREBASE_FRAMEWORKS_VERSION = "^0.11.0";
|
|
19
19
|
exports.FIREBASE_FRAMEWORKS_VERSION = (experiments.isEnabled("internaltesting") && process.env.FIREBASE_FRAMEWORKS_VERSION) ||
|
|
20
20
|
DEFAULT_FIREBASE_FRAMEWORKS_VERSION;
|
|
21
|
-
exports.FIREBASE_FUNCTIONS_VERSION = "^
|
|
21
|
+
exports.FIREBASE_FUNCTIONS_VERSION = "^6.0.1";
|
|
22
22
|
exports.FIREBASE_ADMIN_VERSION = "^11.11.1";
|
|
23
23
|
exports.SHARP_VERSION = "^0.32 || ^0.33";
|
|
24
24
|
exports.NODE_VERSION = parseInt(process.versions.node, 10);
|
|
@@ -4,8 +4,6 @@ exports.ɵcodegenPublicDirectory = exports.build = exports.init = exports.discov
|
|
|
4
4
|
const cross_spawn_1 = require("cross-spawn");
|
|
5
5
|
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const yaml = require("yaml");
|
|
8
|
-
const promises_1 = require("fs/promises");
|
|
9
7
|
const error_1 = require("../../error");
|
|
10
8
|
const utils_1 = require("./utils");
|
|
11
9
|
const constants_1 = require("./constants");
|
|
@@ -18,8 +16,7 @@ async function discover(dir) {
|
|
|
18
16
|
return;
|
|
19
17
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "web"))))
|
|
20
18
|
return;
|
|
21
|
-
const
|
|
22
|
-
const pubSpec = yaml.parse(pubSpecBuffer.toString());
|
|
19
|
+
const pubSpec = await (0, utils_1.getPubSpec)(dir);
|
|
23
20
|
const usingFlutter = (_a = pubSpec.dependencies) === null || _a === void 0 ? void 0 : _a.flutter;
|
|
24
21
|
if (!usingFlutter)
|
|
25
22
|
return;
|
|
@@ -44,9 +41,12 @@ function init(setup, config) {
|
|
|
44
41
|
return Promise.resolve();
|
|
45
42
|
}
|
|
46
43
|
exports.init = init;
|
|
47
|
-
function build(cwd) {
|
|
44
|
+
async function build(cwd) {
|
|
48
45
|
(0, utils_1.assertFlutterCliExists)();
|
|
49
|
-
const
|
|
46
|
+
const pubSpec = await (0, utils_1.getPubSpec)(cwd);
|
|
47
|
+
const otherArgs = (0, utils_1.getAdditionalBuildArgs)(pubSpec);
|
|
48
|
+
const buildArgs = ["build", "web", ...otherArgs].filter(Boolean);
|
|
49
|
+
const build = (0, cross_spawn_1.sync)("flutter", buildArgs, { cwd, stdio: "inherit" });
|
|
50
50
|
if (build.status !== 0)
|
|
51
51
|
throw new error_1.FirebaseError("Unable to build your Flutter app");
|
|
52
52
|
return Promise.resolve({ wantsBackend: false });
|
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertFlutterCliExists = void 0;
|
|
3
|
+
exports.getPubSpec = exports.getAdditionalBuildArgs = exports.assertFlutterCliExists = void 0;
|
|
4
4
|
const cross_spawn_1 = require("cross-spawn");
|
|
5
5
|
const error_1 = require("../../error");
|
|
6
|
+
const promises_1 = require("fs/promises");
|
|
7
|
+
const fs_extra_1 = require("fs-extra");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const yaml = require("yaml");
|
|
6
10
|
function assertFlutterCliExists() {
|
|
7
11
|
const process = (0, cross_spawn_1.sync)("flutter", ["--version"], { stdio: "ignore" });
|
|
8
12
|
if (process.status !== 0)
|
|
9
13
|
throw new error_1.FirebaseError("Flutter CLI not found, follow the instructions here https://docs.flutter.dev/get-started/install before trying again.");
|
|
10
14
|
}
|
|
11
15
|
exports.assertFlutterCliExists = assertFlutterCliExists;
|
|
16
|
+
function getAdditionalBuildArgs(pubSpec) {
|
|
17
|
+
const treeShakePackages = [
|
|
18
|
+
"material_icons_named",
|
|
19
|
+
"material_symbols_icons",
|
|
20
|
+
"material_design_icons_flutter",
|
|
21
|
+
"flutter_iconpicker",
|
|
22
|
+
"font_awesome_flutter",
|
|
23
|
+
"ionicons_named",
|
|
24
|
+
];
|
|
25
|
+
const hasTreeShakePackage = treeShakePackages.some((pkg) => { var _a; return (_a = pubSpec.dependencies) === null || _a === void 0 ? void 0 : _a[pkg]; });
|
|
26
|
+
const treeShakeFlags = hasTreeShakePackage ? ["--no-tree-shake-icons"] : [];
|
|
27
|
+
return [...treeShakeFlags];
|
|
28
|
+
}
|
|
29
|
+
exports.getAdditionalBuildArgs = getAdditionalBuildArgs;
|
|
30
|
+
async function getPubSpec(dir) {
|
|
31
|
+
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "pubspec.yaml"))))
|
|
32
|
+
return {};
|
|
33
|
+
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "web"))))
|
|
34
|
+
return {};
|
|
35
|
+
try {
|
|
36
|
+
const pubSpecBuffer = await (0, promises_1.readFile)((0, path_1.join)(dir, "pubspec.yaml"));
|
|
37
|
+
return yaml.parse(pubSpecBuffer.toString());
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.info("Failed to read pubspec.yaml");
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.getPubSpec = getPubSpec;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
-
const
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const apiv2_1 = require("../../../apiv2");
|
|
8
8
|
const github_1 = require("./github");
|
|
@@ -116,7 +116,7 @@ async function doSetup(setup, config, options) {
|
|
|
116
116
|
choices,
|
|
117
117
|
}, setup.hosting);
|
|
118
118
|
if (discoveredFramework)
|
|
119
|
-
(0,
|
|
119
|
+
(0, node_fs_1.rmSync)(setup.hosting.source, { recursive: true });
|
|
120
120
|
await frameworks_1.WebFrameworks[setup.hosting.whichFramework].init(setup, config);
|
|
121
121
|
}
|
|
122
122
|
await (0, prompt_1.promptOnce)({
|
package/lib/init/spawn.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapSpawn = void 0;
|
|
3
|
+
exports.spawnWithCommandString = exports.wrapSpawn = void 0;
|
|
4
4
|
const spawn = require("cross-spawn");
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
function wrapSpawn(cmd, args, projectDir, environmentVariables) {
|
|
@@ -22,3 +22,23 @@ function wrapSpawn(cmd, args, projectDir, environmentVariables) {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
exports.wrapSpawn = wrapSpawn;
|
|
25
|
+
function spawnWithCommandString(cmd, projectDir, environmentVariables) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const installer = spawn(cmd, {
|
|
28
|
+
cwd: projectDir,
|
|
29
|
+
stdio: "inherit",
|
|
30
|
+
shell: true,
|
|
31
|
+
env: Object.assign(Object.assign({}, process.env), environmentVariables),
|
|
32
|
+
});
|
|
33
|
+
installer.on("error", (err) => {
|
|
34
|
+
logger_1.logger.log("DEBUG", err.stack);
|
|
35
|
+
});
|
|
36
|
+
installer.on("close", (code) => {
|
|
37
|
+
if (code === 0) {
|
|
38
|
+
return resolve();
|
|
39
|
+
}
|
|
40
|
+
return reject();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.spawnWithCommandString = spawnWithCommandString;
|
package/lib/requireAuth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireAuth = void 0;
|
|
3
|
+
exports.requireAuth = exports.refreshAuth = void 0;
|
|
4
4
|
const google_auth_library_1 = require("google-auth-library");
|
|
5
5
|
const clc = require("colorette");
|
|
6
6
|
const api = require("./api");
|
|
@@ -12,6 +12,7 @@ const scopes = require("./scopes");
|
|
|
12
12
|
const auth_1 = require("./auth");
|
|
13
13
|
const AUTH_ERROR_MESSAGE = `Command requires authentication, please run ${clc.bold("firebase login")}`;
|
|
14
14
|
let authClient;
|
|
15
|
+
let lastOptions;
|
|
15
16
|
function getAuthClient(config) {
|
|
16
17
|
if (authClient) {
|
|
17
18
|
return authClient;
|
|
@@ -46,7 +47,16 @@ async function autoAuth(options, authScopes) {
|
|
|
46
47
|
}
|
|
47
48
|
return clientEmail;
|
|
48
49
|
}
|
|
50
|
+
async function refreshAuth() {
|
|
51
|
+
if (!lastOptions) {
|
|
52
|
+
throw new error_1.FirebaseError("Unable to refresh auth: not yet authenticated.");
|
|
53
|
+
}
|
|
54
|
+
await requireAuth(lastOptions);
|
|
55
|
+
return lastOptions.tokens;
|
|
56
|
+
}
|
|
57
|
+
exports.refreshAuth = refreshAuth;
|
|
49
58
|
async function requireAuth(options) {
|
|
59
|
+
lastOptions = options;
|
|
50
60
|
api.setScopes([scopes.CLOUD_PLATFORM, scopes.FIREBASE_PLATFORM]);
|
|
51
61
|
options.authScopes = api.getScopes();
|
|
52
62
|
const tokens = options.tokens;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "13.22.
|
|
3
|
+
"version": "13.22.1",
|
|
4
4
|
"description": "Command-Line Interface for Firebase",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -110,7 +110,6 @@
|
|
|
110
110
|
"progress": "^2.0.3",
|
|
111
111
|
"proxy-agent": "^6.3.0",
|
|
112
112
|
"retry": "^0.13.1",
|
|
113
|
-
"rimraf": "^5.0.0",
|
|
114
113
|
"semver": "^7.5.2",
|
|
115
114
|
"sql-formatter": "^15.3.0",
|
|
116
115
|
"stream-chain": "^2.2.4",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"main": "lib/index.js",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"firebase-admin": "^12.
|
|
19
|
-
"firebase-functions": "^
|
|
18
|
+
"firebase-admin": "^12.6.0",
|
|
19
|
+
"firebase-functions": "^6.0.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@typescript-eslint/eslint-plugin": "^5.12.0",
|