firebase-tools 15.28.1 → 15.28.2
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 +25 -29
- package/lib/commands/ext-migrate.js +36 -0
- package/lib/commands/functions-kits-install.js +21 -401
- package/lib/commands/functions-kits-uninstall.js +266 -0
- package/lib/commands/index.js +4 -0
- package/lib/config.js +34 -0
- package/lib/dataconnect/client.js +2 -2
- package/lib/deploy/functions/ensure.js +29 -19
- package/lib/deploy/functions/prepare.js +8 -1
- package/lib/deploy/functions/release/fabricator.js +19 -3
- package/lib/deploy/functions/release/planner.js +8 -0
- package/lib/extensions/listExtensions.js +27 -3
- package/lib/extensions/migrate.js +171 -0
- package/lib/extensions/replacementRegistry.js +39 -4
- package/lib/extensions/replacements.json +7 -7
- 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/requireTosAcceptance.js +2 -1
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/schema/firebase-config.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -1,18 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NETWORK_TIMEOUT_MS = exports.REPLACEMENTS_GITHUB_RAW_URL = void 0;
|
|
4
|
+
exports.getReplacementsRegistry = getReplacementsRegistry;
|
|
3
5
|
exports.getExtensionReplacement = getExtensionReplacement;
|
|
6
|
+
exports.getReplacementPackageName = getReplacementPackageName;
|
|
4
7
|
exports.getDeprecationWarningMessage = getDeprecationWarningMessage;
|
|
8
|
+
const logger_1 = require("../logger");
|
|
5
9
|
const replacementsData = require("./replacements.json");
|
|
6
10
|
const DECOMMISSION_DATE_STR = "March 31, 2027";
|
|
7
|
-
|
|
8
|
-
|
|
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) {
|
|
9
34
|
if (!extensionRef) {
|
|
10
35
|
return undefined;
|
|
11
36
|
}
|
|
12
37
|
return registry.replacements?.[extensionRef];
|
|
13
38
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
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);
|
|
16
51
|
if (!replacement) {
|
|
17
52
|
return undefined;
|
|
18
53
|
}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"firebase/delete-user-data": {
|
|
4
4
|
"status": "REPLACEMENT_AVAILABLE",
|
|
5
5
|
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/delete-user-data/README.md",
|
|
6
|
-
"npmPackage": "@firebase/delete-user-data"
|
|
6
|
+
"npmPackage": "@firebase-function-kits/delete-user-data"
|
|
7
7
|
},
|
|
8
8
|
"firebase/firestore-bigquery-export": {
|
|
9
9
|
"status": "REPLACEMENT_AVAILABLE",
|
|
10
10
|
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-bigquery-export/README.md",
|
|
11
|
-
"npmPackage": "@firebase/firestore-bigquery-export"
|
|
11
|
+
"npmPackage": "@firebase-function-kits/firestore-bigquery-export"
|
|
12
12
|
},
|
|
13
13
|
"firebase/firestore-bundle-builder": {
|
|
14
14
|
"status": "PENDING_PUBLISHER",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"firebase/firestore-counter": {
|
|
18
18
|
"status": "REPLACEMENT_AVAILABLE",
|
|
19
19
|
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-counter/README.md",
|
|
20
|
-
"npmPackage": "@firebase/firestore-counter"
|
|
20
|
+
"npmPackage": "@firebase-function-kits/firestore-counter"
|
|
21
21
|
},
|
|
22
22
|
"firebase/firestore-send-email": {
|
|
23
23
|
"status": "REPLACEMENT_AVAILABLE",
|
|
24
24
|
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-send-email/README.md",
|
|
25
|
-
"npmPackage": "@firebase/firestore-send-email"
|
|
25
|
+
"npmPackage": "@firebase-function-kits/firestore-send-email"
|
|
26
26
|
},
|
|
27
27
|
"firebase/firestore-shorten-urls-bitly": {
|
|
28
28
|
"status": "PENDING_PUBLISHER",
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
"firebase/firestore-translate-text": {
|
|
33
33
|
"status": "REPLACEMENT_AVAILABLE",
|
|
34
34
|
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-translate-text/README.md",
|
|
35
|
-
"npmPackage": "@firebase/firestore-translate-text"
|
|
35
|
+
"npmPackage": "@firebase-function-kits/firestore-translate-text"
|
|
36
36
|
},
|
|
37
37
|
"firebase/rtdb-limit-child-nodes": {
|
|
38
38
|
"status": "REPLACEMENT_AVAILABLE",
|
|
39
39
|
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/rtdb-limit-child-nodes/README.md",
|
|
40
|
-
"npmPackage": "@firebase/rtdb-limit-child-nodes"
|
|
40
|
+
"npmPackage": "@firebase-function-kits/rtdb-limit-child-nodes"
|
|
41
41
|
},
|
|
42
42
|
"firebase/storage-resize-images": {
|
|
43
43
|
"status": "REPLACEMENT_AVAILABLE",
|
|
44
44
|
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/storage-resize-images/README.md",
|
|
45
|
-
"npmPackage": "@firebase/storage-resize-images"
|
|
45
|
+
"npmPackage": "@firebase-function-kits/storage-resize-images"
|
|
46
46
|
},
|
|
47
47
|
"googlecloud/bigquery-firestore-export": {
|
|
48
48
|
"status": "PENDING_PUBLISHER",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.seedKitInstanceEnv = seedKitInstanceEnv;
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
const env_1 = require("../env");
|
|
6
|
+
function seedKitInstanceEnv(opts) {
|
|
7
|
+
if (!opts.envs || Object.keys(opts.envs).length === 0) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (!opts.projectId) {
|
|
11
|
+
throw new error_1.FirebaseError("A project ID is required to seed environment variables for a kit instance.");
|
|
12
|
+
}
|
|
13
|
+
const normalizedEnvs = {};
|
|
14
|
+
for (const [key, value] of Object.entries(opts.envs)) {
|
|
15
|
+
if (value === undefined || value === null) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
normalizedEnvs[key] = value.join(",");
|
|
20
|
+
}
|
|
21
|
+
else if ((0, error_1.isObject)(value)) {
|
|
22
|
+
normalizedEnvs[key] = JSON.stringify(value);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
normalizedEnvs[key] = String(value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (Object.keys(normalizedEnvs).length === 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
(0, env_1.writeUserEnvs)(normalizedEnvs, {
|
|
32
|
+
configDir: opts.configDir,
|
|
33
|
+
functionsSource: opts.functionsSource,
|
|
34
|
+
projectDir: opts.projectDir,
|
|
35
|
+
projectId: opts.projectId,
|
|
36
|
+
projectAlias: opts.projectAlias,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config"), exports);
|
|
18
|
+
__exportStar(require("./env"), exports);
|
|
19
|
+
__exportStar(require("./install"), exports);
|