firebase-tools-with-isolate 15.27.0 → 15.28.2-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/apphosting/backend.js +44 -10
- package/lib/apphosting/githubConnections.js +1 -1
- package/lib/apphosting/repo.js +1 -1
- package/lib/apphosting/rollout.js +1 -1
- package/lib/commands/ext-export.js +78 -17
- package/lib/commands/ext-migrate.js +36 -0
- package/lib/commands/ext-uninstall.js +35 -1
- package/lib/commands/functions-delete.js +19 -5
- package/lib/commands/functions-kits-install.js +18 -275
- package/lib/commands/functions-kits-list.js +27 -0
- package/lib/commands/functions-kits-uninstall.js +266 -0
- package/lib/commands/index.js +5 -0
- package/lib/config.js +34 -0
- package/lib/dataconnect/client.js +13 -2
- package/lib/dataconnect/schemaMigration.js +16 -5
- package/lib/deploy/extensions/secrets.js +18 -0
- package/lib/deploy/functions/ensure.js +29 -19
- package/lib/deploy/functions/functionsDeployHelper.js +39 -15
- package/lib/deploy/functions/prepare.js +51 -10
- package/lib/deploy/functions/release/fabricator.js +19 -3
- package/lib/deploy/functions/release/planner.js +8 -0
- package/lib/deploy/functions/runtimes/dart/features.js +51 -0
- package/lib/deploy/functions/runtimes/dart/index.js +60 -16
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/functionsEmulator.js +4 -1
- package/lib/experiments.js +6 -0
- package/lib/extensions/export.js +26 -0
- package/lib/extensions/listExtensions.js +27 -3
- package/lib/extensions/migrate.js +171 -0
- package/lib/extensions/replacementRegistry.js +65 -0
- package/lib/extensions/replacements.json +464 -0
- package/lib/fetchMOTD.js +3 -0
- package/lib/functions/env.js +11 -0
- package/lib/functions/iac/export.js +16 -1
- package/lib/functions/kits/config.js +8 -0
- package/lib/functions/kits/env.js +38 -0
- package/lib/functions/kits/index.js +19 -0
- package/lib/functions/kits/install.js +709 -0
- package/lib/gcp/secretManager.js +3 -3
- package/lib/init/features/functions/dart.js +1 -1
- package/lib/mcp/tools/core/deploy.js +2 -0
- package/lib/mcp/tools/core/login.js +59 -4
- package/lib/mcp/tools/dataconnect/compile.js +23 -2
- package/lib/mcp/tools/dataconnect/list_services.js +3 -4
- package/lib/requireTosAcceptance.js +2 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/unzip.js +12 -2
- package/package.json +6 -5
- package/schema/firebase-config.json +1 -1
- package/templates/init/functions/dart/_gitignore +1 -0
- package/templates/init/functions/typescript/index.ts +3 -3
- package/templates/init/functions/typescript/package-ongraphrequest.lint.json +3 -3
- package/templates/init/functions/typescript/package.lint.json +3 -3
- package/templates/init/functions/typescript/tsconfig.dev.json +4 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Delegate = exports.DART_ENTRY_POINT = void 0;
|
|
3
|
+
exports.Delegate = exports.DART_BUNDLE_EXECUTABLE_PATH = exports.DART_COMPILE_EXE_PATH = exports.DART_ENTRY_POINT = void 0;
|
|
4
4
|
exports.tryCreateDelegate = tryCreateDelegate;
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
@@ -14,6 +14,7 @@ const utils_1 = require("../../../../utils");
|
|
|
14
14
|
const registry_1 = require("../../../../emulator/registry");
|
|
15
15
|
const types_1 = require("../../../../emulator/types");
|
|
16
16
|
const experiments = require("../../../../experiments");
|
|
17
|
+
const features_1 = require("./features");
|
|
17
18
|
async function tryCreateDelegate(context) {
|
|
18
19
|
const pubspecYamlPath = path.join(context.sourceDir, "pubspec.yaml");
|
|
19
20
|
if (!(await (0, util_1.promisify)(fs.exists)(pubspecYamlPath))) {
|
|
@@ -30,8 +31,9 @@ async function tryCreateDelegate(context) {
|
|
|
30
31
|
}
|
|
31
32
|
return Promise.resolve(new Delegate(context.projectId, context.sourceDir, runtime));
|
|
32
33
|
}
|
|
33
|
-
const MIN_DART_SDK_VERSION = "3.9.0";
|
|
34
34
|
exports.DART_ENTRY_POINT = "bin/server.dart";
|
|
35
|
+
exports.DART_COMPILE_EXE_PATH = "bin/server";
|
|
36
|
+
exports.DART_BUNDLE_EXECUTABLE_PATH = "build/cli/linux_x64/bundle/bin/server";
|
|
35
37
|
class Delegate {
|
|
36
38
|
constructor(projectId, sourceDir, runtime) {
|
|
37
39
|
this.projectId = projectId;
|
|
@@ -51,18 +53,6 @@ class Delegate {
|
|
|
51
53
|
throw new error_1.FirebaseError(`Could not find a Dart SDK. Make sure the '${this.bin}' command is available on your PATH.`);
|
|
52
54
|
}
|
|
53
55
|
const versionOutput = (result.stdout || result.stderr || "").toString();
|
|
54
|
-
const match = /Dart SDK version:\s*(\d+\.\d+\.\d+)/.exec(versionOutput);
|
|
55
|
-
if (match) {
|
|
56
|
-
const installedVersion = match[1];
|
|
57
|
-
if (installedVersion.localeCompare(MIN_DART_SDK_VERSION, undefined, { numeric: true }) < 0) {
|
|
58
|
-
throw new error_1.FirebaseError(`Dart SDK version ${installedVersion} is not supported. ` +
|
|
59
|
-
`Firebase Functions for Dart requires Dart ${MIN_DART_SDK_VERSION} or later. ` +
|
|
60
|
-
`Please upgrade your Dart SDK.`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
logger_1.logger.debug(`Could not parse Dart SDK version from: ${versionOutput}`);
|
|
65
|
-
}
|
|
66
56
|
const pubspecYamlPath = path.join(this.sourceDir, "pubspec.yaml");
|
|
67
57
|
try {
|
|
68
58
|
await fs.promises.access(pubspecYamlPath, fs.constants.R_OK);
|
|
@@ -107,6 +97,20 @@ class Delegate {
|
|
|
107
97
|
pubGetProcess.on("error", reject);
|
|
108
98
|
});
|
|
109
99
|
}
|
|
100
|
+
const match = /Dart SDK version:\s*(\d+\.\d+\.\d+)/.exec(versionOutput);
|
|
101
|
+
if (match) {
|
|
102
|
+
const installedVersion = match[1];
|
|
103
|
+
const features = await features_1.DartVersionFeatures.detect(this.sourceDir);
|
|
104
|
+
const minVersion = features.minDartSdkVersion;
|
|
105
|
+
if (installedVersion.localeCompare(minVersion, undefined, { numeric: true }) < 0) {
|
|
106
|
+
throw new error_1.FirebaseError(`Dart SDK version ${installedVersion} is not supported. ` +
|
|
107
|
+
`Firebase Functions for Dart requires Dart ${minVersion} or later. ` +
|
|
108
|
+
`Please upgrade your Dart SDK.`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
logger_1.logger.debug(`Could not parse Dart SDK version from: ${versionOutput}`);
|
|
113
|
+
}
|
|
110
114
|
}
|
|
111
115
|
async build() {
|
|
112
116
|
if (Delegate.watchModeActive) {
|
|
@@ -139,6 +143,15 @@ class Delegate {
|
|
|
139
143
|
logger_1.logger.debug("Skipping Dart compilation in emulator mode.");
|
|
140
144
|
return;
|
|
141
145
|
}
|
|
146
|
+
const features = await features_1.DartVersionFeatures.detect(this.sourceDir);
|
|
147
|
+
if (features.isNativeAssetsAvailable) {
|
|
148
|
+
await this.buildCli();
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
await this.compileExe();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async compileExe() {
|
|
142
155
|
const binDir = path.join(this.sourceDir, "bin");
|
|
143
156
|
await fs.promises.mkdir(binDir, { recursive: true });
|
|
144
157
|
(0, utils_1.logLabeledBullet)("functions", "compiling Dart to linux-x64 executable...");
|
|
@@ -147,7 +160,7 @@ class Delegate {
|
|
|
147
160
|
"exe",
|
|
148
161
|
this.entryPoint,
|
|
149
162
|
"-o",
|
|
150
|
-
|
|
163
|
+
exports.DART_COMPILE_EXE_PATH,
|
|
151
164
|
"--target-os=linux",
|
|
152
165
|
"--target-arch=x64",
|
|
153
166
|
], {
|
|
@@ -168,13 +181,43 @@ class Delegate {
|
|
|
168
181
|
else {
|
|
169
182
|
reject(new error_1.FirebaseError(`Dart compilation failed with exit code ${code}. ` +
|
|
170
183
|
`Make sure your Dart project compiles successfully with: ` +
|
|
171
|
-
`dart compile exe ${this.entryPoint} --target-os=linux --target-arch=x64`
|
|
184
|
+
`dart compile exe ${this.entryPoint} --target-os=linux --target-arch=x64\n` +
|
|
185
|
+
`If your dependencies require native build hooks (e.g. sqlite3), bump the ` +
|
|
186
|
+
`SDK constraint in your pubspec.yaml's "environment" section to "^3.13.0" or ` +
|
|
187
|
+
`later to use dart build cli instead.`));
|
|
172
188
|
}
|
|
173
189
|
});
|
|
174
190
|
compileProcess.on("error", reject);
|
|
175
191
|
});
|
|
176
192
|
(0, utils_1.logLabeledBullet)("functions", "Dart compilation complete.");
|
|
177
193
|
}
|
|
194
|
+
async buildCli() {
|
|
195
|
+
(0, utils_1.logLabeledBullet)("functions", "building Dart linux-x64 bundle...");
|
|
196
|
+
const buildProcess = spawn(this.bin, ["build", "cli", "--target", this.entryPoint, "--target-os", "linux", "--target-arch", "x64"], {
|
|
197
|
+
cwd: this.sourceDir,
|
|
198
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
199
|
+
});
|
|
200
|
+
buildProcess.stdout?.on("data", (chunk) => {
|
|
201
|
+
logger_1.logger.debug(`[dart build cli] ${chunk.toString("utf8").trim()}`);
|
|
202
|
+
});
|
|
203
|
+
buildProcess.stderr?.on("data", (chunk) => {
|
|
204
|
+
logger_1.logger.debug(`[dart build cli] ${chunk.toString("utf8").trim()}`);
|
|
205
|
+
});
|
|
206
|
+
await new Promise((resolve, reject) => {
|
|
207
|
+
buildProcess.on("exit", (code) => {
|
|
208
|
+
if (code === 0 || code === null) {
|
|
209
|
+
resolve();
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
reject(new error_1.FirebaseError(`Dart build failed with exit code ${code}. ` +
|
|
213
|
+
`Make sure your Dart project builds successfully with: ` +
|
|
214
|
+
`dart build cli --target ${this.entryPoint} --target-os linux --target-arch x64`));
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
buildProcess.on("error", reject);
|
|
218
|
+
});
|
|
219
|
+
(0, utils_1.logLabeledBullet)("functions", "Dart build complete.");
|
|
220
|
+
}
|
|
178
221
|
async watch(onRebuild) {
|
|
179
222
|
Delegate.watchModeActive = true;
|
|
180
223
|
logger_1.logger.debug("Starting build_runner watch for Dart functions...");
|
|
@@ -245,6 +288,7 @@ class Delegate {
|
|
|
245
288
|
const buildRunnerProcess = spawn(this.bin, ["run", "build_runner", "build"], {
|
|
246
289
|
cwd: this.sourceDir,
|
|
247
290
|
stdio: ["ignore", "pipe", "pipe"],
|
|
291
|
+
env: { ...process.env, ...envs },
|
|
248
292
|
});
|
|
249
293
|
buildRunnerProcess.stdout?.on("data", (chunk) => {
|
|
250
294
|
logger_1.logger.debug(`[build_runner] ${chunk.toString("utf8")}`);
|
|
@@ -44,46 +44,46 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"pubsub": {
|
|
47
|
-
"version": "0.8.
|
|
48
|
-
"expectedSize":
|
|
49
|
-
"expectedChecksum": "
|
|
50
|
-
"expectedChecksumSHA256": "
|
|
51
|
-
"remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/pubsub-emulator-0.8.
|
|
52
|
-
"downloadPathRelativeToCacheDir": "pubsub-emulator-0.8.
|
|
53
|
-
"binaryPathRelativeToCacheDir": "pubsub-emulator-0.8.
|
|
47
|
+
"version": "0.8.35",
|
|
48
|
+
"expectedSize": 53015972,
|
|
49
|
+
"expectedChecksum": "04cb782e3edf7a2b117990af8506453e",
|
|
50
|
+
"expectedChecksumSHA256": "b0f3b73a14b716ecf8925b7b8a0c8c858ffabddcf03df8b2b7fba682f48dc616",
|
|
51
|
+
"remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/pubsub-emulator-0.8.35.zip",
|
|
52
|
+
"downloadPathRelativeToCacheDir": "pubsub-emulator-0.8.35.zip",
|
|
53
|
+
"binaryPathRelativeToCacheDir": "pubsub-emulator-0.8.35/pubsub-emulator/bin/cloud-pubsub-emulator"
|
|
54
54
|
},
|
|
55
55
|
"dataconnect": {
|
|
56
56
|
"darwin": {
|
|
57
|
-
"version": "3.4.
|
|
58
|
-
"expectedSize":
|
|
59
|
-
"expectedChecksum": "
|
|
60
|
-
"expectedChecksumSHA256": "
|
|
61
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.
|
|
62
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
57
|
+
"version": "3.4.18",
|
|
58
|
+
"expectedSize": 33375408,
|
|
59
|
+
"expectedChecksum": "e38f131497fc43df55c3a47ee87e7fd4",
|
|
60
|
+
"expectedChecksumSHA256": "52518fefdd2e52581b0d8d035c6498f304ac493d3757f4fd35851b1f028a9460",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.18",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.18"
|
|
63
63
|
},
|
|
64
64
|
"darwin_arm64": {
|
|
65
|
-
"version": "3.4.
|
|
66
|
-
"expectedSize":
|
|
67
|
-
"expectedChecksum": "
|
|
68
|
-
"expectedChecksumSHA256": "
|
|
69
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.
|
|
70
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
65
|
+
"version": "3.4.18",
|
|
66
|
+
"expectedSize": 31505922,
|
|
67
|
+
"expectedChecksum": "6a7cfdd68a7671bb660eb8489372a890",
|
|
68
|
+
"expectedChecksumSHA256": "96cdec1fd6561af5c10f915f6f3bfd59a7405bf5e9b8fabfedb40cd57d6d5d76",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.18",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.18"
|
|
71
71
|
},
|
|
72
72
|
"win32": {
|
|
73
|
-
"version": "3.4.
|
|
74
|
-
"expectedSize":
|
|
75
|
-
"expectedChecksum": "
|
|
76
|
-
"expectedChecksumSHA256": "
|
|
77
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.
|
|
78
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
73
|
+
"version": "3.4.18",
|
|
74
|
+
"expectedSize": 33414144,
|
|
75
|
+
"expectedChecksum": "d2504c643ac8355b90aa31be7575807c",
|
|
76
|
+
"expectedChecksumSHA256": "a92f2d01950af613d28b92c2cd7baa85e7629fa201b8ff8dddce73d5584dccc5",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.18",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.18.exe"
|
|
79
79
|
},
|
|
80
80
|
"linux": {
|
|
81
|
-
"version": "3.4.
|
|
82
|
-
"expectedSize":
|
|
83
|
-
"expectedChecksum": "
|
|
84
|
-
"expectedChecksumSHA256": "
|
|
85
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.
|
|
86
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
81
|
+
"version": "3.4.18",
|
|
82
|
+
"expectedSize": 32510136,
|
|
83
|
+
"expectedChecksum": "c8b4640f3ea59c813a708814bd2c0f8c",
|
|
84
|
+
"expectedChecksumSHA256": "bb381de594485653812bee518ddae025c13e1050670d6fa186f6003c3c9b71ec",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.18",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.18"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -370,7 +370,10 @@ class FunctionsEmulator {
|
|
|
370
370
|
projectDir: this.args.projectDir,
|
|
371
371
|
};
|
|
372
372
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
373
|
-
const discoveredBuild = await runtimeDelegate.discoverBuild(runtimeConfig,
|
|
373
|
+
const discoveredBuild = await runtimeDelegate.discoverBuild(runtimeConfig, {
|
|
374
|
+
...userEnvs,
|
|
375
|
+
...environment,
|
|
376
|
+
});
|
|
374
377
|
if (discoveredBuild.extensions && this.args.extensionsEmulator) {
|
|
375
378
|
await this.args.extensionsEmulator.addDynamicExtensions(emulatableBackend.codebase, discoveredBuild);
|
|
376
379
|
await this.loadDynamicExtensionBackends();
|
package/lib/experiments.js
CHANGED
|
@@ -221,6 +221,12 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
221
221
|
default: false,
|
|
222
222
|
public: false,
|
|
223
223
|
},
|
|
224
|
+
fdcapimigration: {
|
|
225
|
+
shortDescription: "Enable the FDC API schema migration path.",
|
|
226
|
+
fullDescription: "API based Schema Migration behind experimental flag.",
|
|
227
|
+
default: true,
|
|
228
|
+
public: false,
|
|
229
|
+
},
|
|
224
230
|
});
|
|
225
231
|
function isValidExperiment(name) {
|
|
226
232
|
return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
|
package/lib/extensions/export.js
CHANGED
|
@@ -4,11 +4,14 @@ exports.parameterizeProject = parameterizeProject;
|
|
|
4
4
|
exports.setSecretParamsToLatest = setSecretParamsToLatest;
|
|
5
5
|
exports.displayExportInfo = displayExportInfo;
|
|
6
6
|
exports.functionsEnvFromInstance = functionsEnvFromInstance;
|
|
7
|
+
exports.ejectSecretsFromInstance = ejectSecretsFromInstance;
|
|
7
8
|
const planner_1 = require("../deploy/extensions/planner");
|
|
8
9
|
const deploymentSummary_1 = require("../deploy/extensions/deploymentSummary");
|
|
9
10
|
const logger_1 = require("../logger");
|
|
10
11
|
const secretManager_1 = require("../gcp/secretManager");
|
|
11
12
|
const secretsUtils_1 = require("./secretsUtils");
|
|
13
|
+
const secrets_1 = require("../deploy/extensions/secrets");
|
|
14
|
+
const error_1 = require("../error");
|
|
12
15
|
function parameterizeProject(projectId, projectNumber, spec) {
|
|
13
16
|
const newParams = {};
|
|
14
17
|
for (const [key, val] of Object.entries(spec.params)) {
|
|
@@ -107,3 +110,26 @@ function functionsEnvFromInstance(instance) {
|
|
|
107
110
|
}
|
|
108
111
|
return envs;
|
|
109
112
|
}
|
|
113
|
+
async function ejectSecretsFromInstance(instance) {
|
|
114
|
+
const secretsChanged = [];
|
|
115
|
+
const liveParams = instance.config?.params || {};
|
|
116
|
+
for (const specParam of instance.config?.source?.spec?.params ?? []) {
|
|
117
|
+
if (specParam.type !== "SECRET") {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const secretName = specParam.param;
|
|
121
|
+
const resourceName = liveParams[secretName];
|
|
122
|
+
if (!resourceName) {
|
|
123
|
+
throw new error_1.FirebaseError(`Secret ${secretName} was defined in the extension spec, but is missing in live deployed secrets.`, { exit: 1 });
|
|
124
|
+
}
|
|
125
|
+
const match = resourceName.match(secretManager_1.SECRET_VERSION_NAME_REGEX);
|
|
126
|
+
if (!match?.groups) {
|
|
127
|
+
throw new error_1.FirebaseError(`Invalid secret version resource name [${resourceName}].`);
|
|
128
|
+
}
|
|
129
|
+
const projectId = match.groups.project;
|
|
130
|
+
const secretId = match.groups.secret;
|
|
131
|
+
await (0, secrets_1.transferSecretToKits)(projectId, secretId);
|
|
132
|
+
secretsChanged.push(`${projectId}/${secretId}`);
|
|
133
|
+
}
|
|
134
|
+
return secretsChanged;
|
|
135
|
+
}
|
|
@@ -7,15 +7,32 @@ const extensionsApi_1 = require("./extensionsApi");
|
|
|
7
7
|
const logger_1 = require("../logger");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const extensionsHelper_1 = require("./extensionsHelper");
|
|
10
|
+
const experiments = require("../experiments");
|
|
10
11
|
const extensionsUtils = require("./utils");
|
|
12
|
+
const replacementRegistry_1 = require("./replacementRegistry");
|
|
11
13
|
async function listExtensions(projectId) {
|
|
12
|
-
const
|
|
14
|
+
const showReplacements = experiments.isEnabled("extMigrationFeatures");
|
|
15
|
+
let instances;
|
|
16
|
+
let registry;
|
|
17
|
+
if (showReplacements) {
|
|
18
|
+
[instances, registry] = await Promise.all([
|
|
19
|
+
(0, extensionsApi_1.listInstances)(projectId),
|
|
20
|
+
(0, replacementRegistry_1.getReplacementsRegistry)(),
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
instances = await (0, extensionsApi_1.listInstances)(projectId);
|
|
25
|
+
}
|
|
13
26
|
if (instances.length < 1) {
|
|
14
27
|
(0, utils_1.logLabeledBullet)(extensionsHelper_1.logPrefix, `there are no extensions installed on project ${clc.bold(projectId)}.`);
|
|
15
28
|
return [];
|
|
16
29
|
}
|
|
30
|
+
const head = ["Extension", "Publisher", "Instance ID", "State", "Version", "Your last update"];
|
|
31
|
+
if (showReplacements) {
|
|
32
|
+
head.push("Replacement Kit");
|
|
33
|
+
}
|
|
17
34
|
const table = new Table({
|
|
18
|
-
head
|
|
35
|
+
head,
|
|
19
36
|
style: { head: ["yellow"] },
|
|
20
37
|
});
|
|
21
38
|
const sorted = instances.sort((a, b) => new Date(b.createTime).valueOf() - new Date(a.createTime).valueOf());
|
|
@@ -35,7 +52,13 @@ async function listExtensions(projectId) {
|
|
|
35
52
|
((instance.config.source.state || "ACTIVE") === "DELETED" ? " (UNPUBLISHED)" : "");
|
|
36
53
|
const version = instance?.config?.source?.spec?.version;
|
|
37
54
|
const updateTime = extensionsUtils.formatTimestamp(instance.updateTime);
|
|
38
|
-
|
|
55
|
+
const row = [extension, publisher, instanceId, state, version, updateTime];
|
|
56
|
+
let replacementPackage;
|
|
57
|
+
if (showReplacements && registry) {
|
|
58
|
+
replacementPackage = (0, replacementRegistry_1.getReplacementPackageName)(extension, registry);
|
|
59
|
+
row.push(replacementPackage ? clc.green(replacementPackage) : "");
|
|
60
|
+
}
|
|
61
|
+
table.push(row);
|
|
39
62
|
formatted.push({
|
|
40
63
|
extension,
|
|
41
64
|
publisher,
|
|
@@ -43,6 +66,7 @@ async function listExtensions(projectId) {
|
|
|
43
66
|
state,
|
|
44
67
|
version,
|
|
45
68
|
updateTime,
|
|
69
|
+
...(showReplacements && replacementPackage ? { replacementKit: replacementPackage } : {}),
|
|
46
70
|
params: instance.config.params,
|
|
47
71
|
systemParams: instance.config.systemParams,
|
|
48
72
|
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getKitPackage = getKitPackage;
|
|
4
|
+
exports.getInstanceId = getInstanceId;
|
|
5
|
+
exports.getExtensionRef = getExtensionRef;
|
|
6
|
+
exports.formatExtensionsTable = formatExtensionsTable;
|
|
7
|
+
exports.getMigratableInstances = getMigratableInstances;
|
|
8
|
+
exports.promptInstanceSelection = promptInstanceSelection;
|
|
9
|
+
exports.createMigrationPlan = createMigrationPlan;
|
|
10
|
+
const clc = require("colorette");
|
|
11
|
+
const Table = require("cli-table3");
|
|
12
|
+
const error_1 = require("../error");
|
|
13
|
+
const logger_1 = require("../logger");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
const extensionsHelper_1 = require("./extensionsHelper");
|
|
16
|
+
const extensionsApi_1 = require("./extensionsApi");
|
|
17
|
+
const prompt_1 = require("../prompt");
|
|
18
|
+
const replacements = require("./replacements.json");
|
|
19
|
+
function getKitPackage(extensionRef, packageOverride) {
|
|
20
|
+
if (packageOverride) {
|
|
21
|
+
return packageOverride;
|
|
22
|
+
}
|
|
23
|
+
const data = replacements;
|
|
24
|
+
const map = data.replacements || {};
|
|
25
|
+
let entry = map[extensionRef];
|
|
26
|
+
if (!entry && !extensionRef.includes("/")) {
|
|
27
|
+
entry = map[`firebase/${extensionRef}`];
|
|
28
|
+
}
|
|
29
|
+
if (entry && entry.npmPackage && entry.status === "REPLACEMENT_AVAILABLE") {
|
|
30
|
+
return entry.npmPackage;
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
function getInstanceId(instance) {
|
|
35
|
+
return (0, utils_1.last)(instance.name.split("/")) ?? instance.name;
|
|
36
|
+
}
|
|
37
|
+
function getExtensionRef(instance) {
|
|
38
|
+
return instance.config.extensionRef || instance.config.source?.spec?.name || "";
|
|
39
|
+
}
|
|
40
|
+
function formatExtensionsTable(instances, packageOverride) {
|
|
41
|
+
const table = new Table({
|
|
42
|
+
head: ["Extension", "publisher", "Instances", "kit package"],
|
|
43
|
+
style: { head: ["yellow"] },
|
|
44
|
+
});
|
|
45
|
+
const grouped = new Map();
|
|
46
|
+
instances.forEach((instance) => {
|
|
47
|
+
const ref = getExtensionRef(instance);
|
|
48
|
+
const instanceId = getInstanceId(instance);
|
|
49
|
+
let publisher = "N/A";
|
|
50
|
+
if (ref.includes("/")) {
|
|
51
|
+
publisher = ref.split("/")[0];
|
|
52
|
+
}
|
|
53
|
+
const kitPkg = getKitPackage(ref, packageOverride) ?? "N/A";
|
|
54
|
+
const groupEntry = grouped.get(ref);
|
|
55
|
+
if (!groupEntry) {
|
|
56
|
+
grouped.set(ref, { publisher, instances: [instanceId], kitPackage: kitPkg });
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
groupEntry.instances.push(instanceId);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const rows = [];
|
|
63
|
+
grouped.forEach((data, ref) => {
|
|
64
|
+
table.push([ref, data.publisher, data.instances.join(", "), data.kitPackage]);
|
|
65
|
+
rows.push({
|
|
66
|
+
extension: ref,
|
|
67
|
+
publisher: data.publisher,
|
|
68
|
+
instances: data.instances,
|
|
69
|
+
kitPackage: data.kitPackage,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
return { tableString: table.toString(), rows };
|
|
73
|
+
}
|
|
74
|
+
function getMigratableInstances(instances, packageOverride) {
|
|
75
|
+
const result = [];
|
|
76
|
+
for (const instance of instances) {
|
|
77
|
+
const ref = getExtensionRef(instance);
|
|
78
|
+
const instanceId = getInstanceId(instance);
|
|
79
|
+
const kitPkg = getKitPackage(ref, packageOverride);
|
|
80
|
+
if (kitPkg) {
|
|
81
|
+
result.push({
|
|
82
|
+
instance,
|
|
83
|
+
instanceId,
|
|
84
|
+
extensionRef: ref,
|
|
85
|
+
kitPackage: kitPkg,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
async function promptInstanceSelection(migratableInstances, nonInteractive) {
|
|
92
|
+
const choices = migratableInstances.map((item) => ({
|
|
93
|
+
name: `${item.instanceId} (${item.extensionRef})`,
|
|
94
|
+
value: item,
|
|
95
|
+
}));
|
|
96
|
+
const selected = await (0, prompt_1.select)({
|
|
97
|
+
message: "Which extension instance would you like to migrate?",
|
|
98
|
+
choices,
|
|
99
|
+
nonInteractive,
|
|
100
|
+
});
|
|
101
|
+
return selected;
|
|
102
|
+
}
|
|
103
|
+
async function createMigrationPlan(projectId, options) {
|
|
104
|
+
const instances = await (0, extensionsApi_1.listInstances)(projectId);
|
|
105
|
+
if (options.extInstance) {
|
|
106
|
+
const foundInstance = instances.find((inst) => getInstanceId(inst) === options.extInstance);
|
|
107
|
+
if (!foundInstance) {
|
|
108
|
+
throw new error_1.FirebaseError(`Extension instance ${options.extInstance} was not found on project ${projectId}.`);
|
|
109
|
+
}
|
|
110
|
+
const ref = getExtensionRef(foundInstance);
|
|
111
|
+
const kitPkg = getKitPackage(ref, options.package);
|
|
112
|
+
if (!kitPkg) {
|
|
113
|
+
throw new error_1.FirebaseError("This extension does not have an associated function kit. You can create your own function kit by forking the extension.");
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
instance: foundInstance,
|
|
117
|
+
instanceId: getInstanceId(foundInstance),
|
|
118
|
+
extensionRef: ref,
|
|
119
|
+
kitPackage: kitPkg,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (options.extension) {
|
|
123
|
+
const targetExt = options.extension;
|
|
124
|
+
const matchingInstances = instances.filter((inst) => {
|
|
125
|
+
const ref = getExtensionRef(inst);
|
|
126
|
+
return (ref === targetExt ||
|
|
127
|
+
(ref.includes("/") && ref.split("/")[1] === targetExt) ||
|
|
128
|
+
(targetExt.includes("/") && ref === targetExt.split("/")[1]));
|
|
129
|
+
});
|
|
130
|
+
if (matchingInstances.length === 0) {
|
|
131
|
+
throw new error_1.FirebaseError(`Extension ${options.extension} is not installed on project ${projectId}.`);
|
|
132
|
+
}
|
|
133
|
+
const matchingInstancesWithKit = matchingInstances
|
|
134
|
+
.map((inst) => {
|
|
135
|
+
const ref = getExtensionRef(inst);
|
|
136
|
+
const kitPkg = getKitPackage(ref, options.package);
|
|
137
|
+
return { inst, ref, kitPkg };
|
|
138
|
+
})
|
|
139
|
+
.filter((item) => item.kitPkg !== undefined);
|
|
140
|
+
if (matchingInstancesWithKit.length === 0) {
|
|
141
|
+
throw new error_1.FirebaseError("This extension does not have an associated function kit. You can create your own function kit by forking the extension.");
|
|
142
|
+
}
|
|
143
|
+
if (matchingInstancesWithKit.length === 1) {
|
|
144
|
+
const { inst, ref, kitPkg } = matchingInstancesWithKit[0];
|
|
145
|
+
return {
|
|
146
|
+
instance: inst,
|
|
147
|
+
instanceId: getInstanceId(inst),
|
|
148
|
+
extensionRef: ref,
|
|
149
|
+
kitPackage: kitPkg,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const migratableChoices = matchingInstancesWithKit.map(({ inst, ref, kitPkg }) => ({
|
|
153
|
+
instance: inst,
|
|
154
|
+
instanceId: getInstanceId(inst),
|
|
155
|
+
extensionRef: ref,
|
|
156
|
+
kitPackage: kitPkg,
|
|
157
|
+
}));
|
|
158
|
+
return promptInstanceSelection(migratableChoices, options.nonInteractive);
|
|
159
|
+
}
|
|
160
|
+
if (instances.length === 0) {
|
|
161
|
+
throw new error_1.FirebaseError(`All extensions in project ${clc.bold(projectId)} have already been migrated.`);
|
|
162
|
+
}
|
|
163
|
+
const { tableString } = formatExtensionsTable(instances, options.package);
|
|
164
|
+
(0, utils_1.logLabeledBullet)(extensionsHelper_1.logPrefix, `list of extensions installed in ${clc.bold(projectId)}:`);
|
|
165
|
+
logger_1.logger.info(tableString);
|
|
166
|
+
const migratable = getMigratableInstances(instances, options.package);
|
|
167
|
+
if (migratable.length === 0) {
|
|
168
|
+
throw new error_1.FirebaseError("No remaining Extensions have an associated function kit. You can create your own function kit by forking the extension.");
|
|
169
|
+
}
|
|
170
|
+
return promptInstanceSelection(migratable, options.nonInteractive);
|
|
171
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NETWORK_TIMEOUT_MS = exports.REPLACEMENTS_GITHUB_RAW_URL = void 0;
|
|
4
|
+
exports.getReplacementsRegistry = getReplacementsRegistry;
|
|
5
|
+
exports.getExtensionReplacement = getExtensionReplacement;
|
|
6
|
+
exports.getReplacementPackageName = getReplacementPackageName;
|
|
7
|
+
exports.getDeprecationWarningMessage = getDeprecationWarningMessage;
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
|
+
const replacementsData = require("./replacements.json");
|
|
10
|
+
const DECOMMISSION_DATE_STR = "March 31, 2027";
|
|
11
|
+
exports.REPLACEMENTS_GITHUB_RAW_URL = "https://raw.githubusercontent.com/firebase/firebase-tools/main/src/extensions/replacements.json";
|
|
12
|
+
exports.NETWORK_TIMEOUT_MS = 2000;
|
|
13
|
+
async function getReplacementsRegistry() {
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const timeoutId = setTimeout(() => controller.abort(), exports.NETWORK_TIMEOUT_MS);
|
|
16
|
+
try {
|
|
17
|
+
const res = await fetch(exports.REPLACEMENTS_GITHUB_RAW_URL, { signal: controller.signal });
|
|
18
|
+
if (res.ok) {
|
|
19
|
+
const data = (await res.json());
|
|
20
|
+
if (data?.replacements && typeof data.replacements === "object") {
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
logger_1.logger.debug(`Failed to fetch fresh replacements catalog from GitHub: ${String(err)}`);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
clearTimeout(timeoutId);
|
|
30
|
+
}
|
|
31
|
+
return replacementsData;
|
|
32
|
+
}
|
|
33
|
+
function getExtensionReplacement(extensionRef, registry = replacementsData) {
|
|
34
|
+
if (!extensionRef) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return registry.replacements?.[extensionRef];
|
|
38
|
+
}
|
|
39
|
+
function getReplacementPackageName(extensionRef, registry = replacementsData) {
|
|
40
|
+
if (!extensionRef) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const entry = registry.replacements?.[extensionRef];
|
|
44
|
+
if (entry?.status === "REPLACEMENT_AVAILABLE" && entry.npmPackage) {
|
|
45
|
+
return entry.npmPackage;
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
function getDeprecationWarningMessage(extensionRef, registry) {
|
|
50
|
+
const replacement = getExtensionReplacement(extensionRef, registry);
|
|
51
|
+
if (!replacement) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
switch (replacement.status) {
|
|
55
|
+
case "REPLACEMENT_AVAILABLE":
|
|
56
|
+
return (`Extension '${extensionRef}' is deprecated and will be decommissioned on ${DECOMMISSION_DATE_STR}.\n` +
|
|
57
|
+
` Recommended replacement: ${replacement.npmPackage}`);
|
|
58
|
+
case "CONFIRMED_NO_REPLACEMENT":
|
|
59
|
+
return (`Extension '${extensionRef}' is deprecated and will be decommissioned on ${DECOMMISSION_DATE_STR}.\n` +
|
|
60
|
+
` Note: No npm package replacement is planned for this extension.`);
|
|
61
|
+
case "PENDING_PUBLISHER":
|
|
62
|
+
return (`Extension '${extensionRef}' is deprecated and will be decommissioned on ${DECOMMISSION_DATE_STR}.\n` +
|
|
63
|
+
` A replacement package has not yet been announced by the publisher.`);
|
|
64
|
+
}
|
|
65
|
+
}
|