firebase-tools 10.2.1 → 10.3.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/appdistribution/options-parser-util.js +1 -1
- package/lib/auth.js +3 -3
- package/lib/command.js +1 -1
- package/lib/commands/apps-android-sha-create.js +2 -2
- package/lib/commands/apps-sdkconfig.js +1 -1
- package/lib/commands/database-rules-list.js +2 -2
- package/lib/commands/emulators-start.js +1 -1
- package/lib/commands/ext-configure.js +67 -7
- package/lib/commands/ext-dev-init.js +49 -49
- package/lib/commands/ext-export.js +7 -2
- package/lib/commands/ext-install.js +173 -109
- package/lib/commands/ext-uninstall.js +17 -8
- package/lib/commands/ext-update.js +67 -12
- package/lib/commands/functions-config-export.js +1 -1
- package/lib/commands/hosting-clone.js +3 -3
- package/lib/commands/remoteconfig-get.js +1 -1
- package/lib/config.js +6 -3
- package/lib/deploy/extensions/deploymentSummary.js +3 -3
- package/lib/deploy/extensions/planner.js +7 -6
- package/lib/deploy/extensions/tasks.js +1 -1
- package/lib/deploy/functions/backend.js +21 -5
- package/lib/deploy/functions/checkIam.js +5 -5
- package/lib/deploy/functions/containerCleaner.js +3 -3
- package/lib/deploy/functions/ensure.js +3 -3
- package/lib/deploy/functions/functionsDeployHelper.js +2 -2
- package/lib/deploy/functions/prepare.js +5 -3
- package/lib/deploy/functions/pricing.js +1 -1
- package/lib/deploy/functions/prompts.js +2 -2
- package/lib/deploy/functions/release/fabricator.js +7 -7
- package/lib/deploy/functions/release/index.js +1 -1
- package/lib/deploy/functions/release/planner.js +43 -26
- package/lib/deploy/functions/release/reporter.js +3 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +6 -6
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +22 -12
- package/lib/deploy/functions/runtimes/golang/index.js +2 -2
- package/lib/deploy/functions/runtimes/node/index.js +53 -0
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +64 -20
- package/lib/deploy/functions/runtimes/node/versioning.js +2 -2
- package/lib/deploy/functions/services/firebaseAlerts.js +30 -0
- package/lib/deploy/functions/services/index.js +9 -1
- package/lib/deploy/functions/services/storage.js +10 -4
- package/lib/deploy/functions/triggerRegionHelper.js +1 -1
- package/lib/deploy/functions/validate.js +3 -3
- package/lib/deploy/hosting/deploy.js +2 -2
- package/lib/deploy/hosting/hashcache.js +21 -19
- package/lib/deploy/hosting/uploader.js +5 -5
- package/lib/deploy/remoteconfig/functions.js +2 -2
- package/lib/emulator/auth/cloudFunctions.js +1 -1
- package/lib/emulator/auth/operations.js +1 -1
- package/lib/emulator/constants.js +4 -0
- package/lib/emulator/controller.js +54 -24
- package/lib/emulator/download.js +18 -1
- package/lib/emulator/downloadableEmulators.js +1 -1
- package/lib/emulator/emulatorLogger.js +12 -1
- package/lib/emulator/extensions/validation.js +70 -0
- package/lib/emulator/extensionsEmulator.js +175 -0
- package/lib/emulator/functionsEmulator.js +95 -43
- package/lib/emulator/functionsEmulatorRuntime.js +44 -36
- package/lib/emulator/functionsEmulatorShared.js +30 -11
- package/lib/emulator/functionsEmulatorShell.js +1 -1
- package/lib/emulator/functionsEmulatorUtils.js +4 -4
- package/lib/emulator/functionsRuntimeWorker.js +2 -2
- package/lib/emulator/hub.js +4 -3
- package/lib/emulator/loggingEmulator.js +1 -1
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/registry.js +10 -2
- package/lib/emulator/storage/apis/firebase.js +314 -332
- package/lib/emulator/storage/apis/gcloud.js +241 -121
- package/lib/emulator/storage/crc.js +5 -1
- package/lib/emulator/storage/errors.js +9 -0
- package/lib/emulator/storage/files.js +159 -300
- package/lib/emulator/storage/index.js +27 -73
- package/lib/emulator/storage/metadata.js +65 -51
- package/lib/emulator/storage/multipart.js +62 -0
- package/lib/emulator/storage/persistence.js +78 -0
- package/lib/emulator/storage/rules/config.js +33 -0
- package/lib/emulator/storage/rules/manager.js +81 -0
- package/lib/emulator/storage/rules/runtime.js +8 -7
- package/lib/emulator/storage/rules/utils.js +48 -0
- package/lib/emulator/storage/server.js +2 -2
- package/lib/emulator/storage/upload.js +106 -0
- package/lib/emulator/types.js +3 -0
- package/lib/ensureApiEnabled.js +5 -1
- package/lib/error.js +1 -1
- package/lib/extensions/askUserForParam.js +31 -25
- package/lib/extensions/changelog.js +3 -1
- package/lib/extensions/checkProjectBilling.js +1 -1
- package/lib/extensions/displayExtensionInfo.js +1 -1
- package/lib/extensions/emulator/optionsHelper.js +56 -8
- package/lib/extensions/emulator/specHelper.js +10 -23
- package/lib/extensions/export.js +1 -51
- package/lib/extensions/extensionsApi.js +1 -1
- package/lib/extensions/extensionsHelper.js +32 -19
- package/lib/extensions/manifest.js +144 -0
- package/lib/extensions/metricsUtils.js +4 -4
- package/lib/extensions/paramHelper.js +34 -12
- package/lib/extensions/refs.js +1 -1
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/functional.js +1 -1
- package/lib/functions/env.js +6 -7
- package/lib/functions/events/v2.js +11 -0
- package/lib/gcp/cloudfunctions.js +43 -11
- package/lib/gcp/cloudfunctionsv2.js +48 -17
- package/lib/gcp/cloudtasks.js +1 -1
- package/lib/gcp/docker.js +2 -2
- package/lib/gcp/resourceManager.js +4 -4
- package/lib/gcp/run.js +2 -2
- package/lib/hosting/api.js +1 -1
- package/lib/hosting/proxy.js +2 -2
- package/lib/init/features/account.js +1 -1
- package/lib/management/database.js +1 -1
- package/lib/previews.js +1 -1
- package/lib/serve/functions.js +2 -1
- package/lib/utils.js +15 -2
- package/npm-shrinkwrap.json +786 -393
- package/package.json +1 -1
- package/schema/firebase-config.json +5 -0
- package/templates/init/functions/javascript/package.lint.json +3 -3
- package/templates/init/functions/javascript/package.nolint.json +2 -2
- package/templates/init/functions/typescript/package.lint.json +7 -7
- package/templates/init/functions/typescript/package.nolint.json +3 -3
- package/lib/deploy/extensions/params.js +0 -39
- package/lib/deploy/functions/eventTypes.js +0 -10
|
@@ -16,7 +16,7 @@ function getTestersOrGroups(value, file) {
|
|
|
16
16
|
}
|
|
17
17
|
exports.getTestersOrGroups = getTestersOrGroups;
|
|
18
18
|
function getEmails(emails, file) {
|
|
19
|
-
if (emails.length
|
|
19
|
+
if (emails.length === 0) {
|
|
20
20
|
ensureFileExists(file);
|
|
21
21
|
const readFile = fs.readFileSync(file, "utf8");
|
|
22
22
|
return splitter(readFile);
|
package/lib/auth.js
CHANGED
|
@@ -291,7 +291,7 @@ async function loginRemotely(userHint) {
|
|
|
291
291
|
});
|
|
292
292
|
try {
|
|
293
293
|
const tokens = await getTokensFromAuthorizationCode(code, `${api.authProxyOrigin}/complete`, codeVerifier);
|
|
294
|
-
(0, track_1.track)("login", "google_remote");
|
|
294
|
+
void (0, track_1.track)("login", "google_remote");
|
|
295
295
|
return {
|
|
296
296
|
user: jwt.decode(tokens.id_token),
|
|
297
297
|
tokens: tokens,
|
|
@@ -307,7 +307,7 @@ async function loginWithLocalhostGoogle(port, userHint) {
|
|
|
307
307
|
const authUrl = getLoginUrl(callbackUrl, userHint);
|
|
308
308
|
const successTemplate = "../templates/loginSuccess.html";
|
|
309
309
|
const tokens = await loginWithLocalhost(port, callbackUrl, authUrl, successTemplate, getTokensFromAuthorizationCode);
|
|
310
|
-
(0, track_1.track)("login", "google_localhost");
|
|
310
|
+
void (0, track_1.track)("login", "google_localhost");
|
|
311
311
|
return {
|
|
312
312
|
user: jwt.decode(tokens.id_token),
|
|
313
313
|
tokens: tokens,
|
|
@@ -319,7 +319,7 @@ async function loginWithLocalhostGitHub(port) {
|
|
|
319
319
|
const authUrl = getGithubLoginUrl(callbackUrl);
|
|
320
320
|
const successTemplate = "../templates/loginSuccessGithub.html";
|
|
321
321
|
const tokens = await loginWithLocalhost(port, callbackUrl, authUrl, successTemplate, getGithubTokensFromAuthorizationCode);
|
|
322
|
-
(0, track_1.track)("login", "google_localhost");
|
|
322
|
+
void (0, track_1.track)("login", "google_localhost");
|
|
323
323
|
return tokens;
|
|
324
324
|
}
|
|
325
325
|
async function loginWithLocalhost(port, callbackUrl, authUrl, successTemplate, getTokens) {
|
package/lib/command.js
CHANGED
|
@@ -85,7 +85,7 @@ class Command {
|
|
|
85
85
|
}, null, 2));
|
|
86
86
|
}
|
|
87
87
|
const duration = new Date().getTime() - start;
|
|
88
|
-
track(this.name, "success", duration).then(() => process.exit());
|
|
88
|
+
void track(this.name, "success", duration).then(() => process.exit());
|
|
89
89
|
})
|
|
90
90
|
.catch(async (err) => {
|
|
91
91
|
if ((0, utils_1.getInheritedOption)(options, "json")) {
|
|
@@ -9,9 +9,9 @@ const utils_1 = require("../utils");
|
|
|
9
9
|
function getCertHashType(shaHash) {
|
|
10
10
|
shaHash = shaHash.replace(/:/g, "");
|
|
11
11
|
const shaHashCount = shaHash.length;
|
|
12
|
-
if (shaHashCount
|
|
12
|
+
if (shaHashCount === 40)
|
|
13
13
|
return apps_1.ShaCertificateType.SHA_1.toString();
|
|
14
|
-
if (shaHashCount
|
|
14
|
+
if (shaHashCount === 64)
|
|
15
15
|
return apps_1.ShaCertificateType.SHA_256.toString();
|
|
16
16
|
return apps_1.ShaCertificateType.SHA_CERTIFICATE_TYPE_UNSPECIFIED.toString();
|
|
17
17
|
}
|
|
@@ -70,7 +70,7 @@ module.exports = new command_1.Command("apps:sdkconfig [platform] [appId]")
|
|
|
70
70
|
}
|
|
71
71
|
spinner.succeed();
|
|
72
72
|
const fileInfo = (0, apps_1.getAppConfigFile)(configData, appPlatform);
|
|
73
|
-
if (appPlatform
|
|
73
|
+
if (appPlatform === apps_1.AppPlatform.WEB) {
|
|
74
74
|
fileInfo.sdkConfig = configData;
|
|
75
75
|
}
|
|
76
76
|
if (options.out === undefined) {
|
|
@@ -18,10 +18,10 @@ exports.default = new command_1.Command("database:rules:list")
|
|
|
18
18
|
const rulesets = await metadata.listAllRulesets(options.instance);
|
|
19
19
|
for (const ruleset of rulesets) {
|
|
20
20
|
const labels = [];
|
|
21
|
-
if (ruleset.id
|
|
21
|
+
if (ruleset.id === labeled.stable) {
|
|
22
22
|
labels.push("stable");
|
|
23
23
|
}
|
|
24
|
-
if (ruleset.id
|
|
24
|
+
if (ruleset.id === labeled.canary) {
|
|
25
25
|
labels.push("canary");
|
|
26
26
|
}
|
|
27
27
|
logger_1.logger.info(`${ruleset.id} ${ruleset.createdAt} ${labels.join(",")}`);
|
|
@@ -59,9 +59,9 @@ module.exports = new command_1.Command("emulators:start")
|
|
|
59
59
|
emulatorsTable.push(...controller
|
|
60
60
|
.filterEmulatorTargets(options)
|
|
61
61
|
.map((emulator) => {
|
|
62
|
-
const info = registry_1.EmulatorRegistry.getInfo(emulator);
|
|
63
62
|
const emulatorName = constants_1.Constants.description(emulator).replace(/ emulator/i, "");
|
|
64
63
|
const isSupportedByUi = types_1.EMULATORS_SUPPORTED_BY_UI.includes(emulator);
|
|
64
|
+
const info = registry_1.EmulatorRegistry.getInfo(emulator === types_1.Emulators.EXTENSIONS ? types_1.Emulators.FUNCTIONS : emulator);
|
|
65
65
|
if (!info) {
|
|
66
66
|
return [emulatorName, "Failed to initialize (see above)", "", ""];
|
|
67
67
|
}
|
|
@@ -15,6 +15,10 @@ const paramHelper = require("../extensions/paramHelper");
|
|
|
15
15
|
const requirePermissions_1 = require("../requirePermissions");
|
|
16
16
|
const utils = require("../utils");
|
|
17
17
|
const logger_1 = require("../logger");
|
|
18
|
+
const refs = require("../extensions/refs");
|
|
19
|
+
const manifest = require("../extensions/manifest");
|
|
20
|
+
const functional_1 = require("../functional");
|
|
21
|
+
const paramHelper_1 = require("../extensions/paramHelper");
|
|
18
22
|
marked.setOptions({
|
|
19
23
|
renderer: new TerminalRenderer(),
|
|
20
24
|
});
|
|
@@ -22,6 +26,7 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
22
26
|
.description("configure an existing extension instance")
|
|
23
27
|
.withForce()
|
|
24
28
|
.option("--params <paramsFile>", "path of params file with .env format.")
|
|
29
|
+
.option("--local", "save to firebase.json rather than directly install to a Firebase project")
|
|
25
30
|
.before(requirePermissions_1.requirePermissions, [
|
|
26
31
|
"firebaseextensions.instances.update",
|
|
27
32
|
"firebaseextensions.instances.get",
|
|
@@ -29,9 +34,46 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
29
34
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
30
35
|
.before(extensionsHelper_1.diagnoseAndFixProject)
|
|
31
36
|
.action(async (instanceId, options) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
39
|
+
if (options.local) {
|
|
40
|
+
if (options.nonInteractive) {
|
|
41
|
+
throw new error_1.FirebaseError(`Command not supported in non-interactive mode, edit ./extensions/${instanceId}.env directly instead`);
|
|
42
|
+
}
|
|
43
|
+
const config = manifest.loadConfig(options);
|
|
44
|
+
const targetRef = manifest.getInstanceRef(instanceId, config);
|
|
45
|
+
const extensionVersion = await extensionsApi.getExtensionVersion(refs.toExtensionVersionRef(targetRef));
|
|
46
|
+
const oldParamValues = manifest.readInstanceParam({
|
|
47
|
+
instanceId,
|
|
48
|
+
projectDir: config.projectDir,
|
|
49
|
+
});
|
|
50
|
+
const [immutableParams, tbdParams] = (0, functional_1.partition)(extensionVersion.spec.params, (param) => { var _a; return (_a = param.immutable) !== null && _a !== void 0 ? _a : false; });
|
|
51
|
+
infoImmutableParams(immutableParams, oldParamValues);
|
|
52
|
+
paramHelper.setNewDefaults(tbdParams, oldParamValues);
|
|
53
|
+
const mutableParamsBindingOptions = await paramHelper.getParams({
|
|
54
|
+
projectId,
|
|
55
|
+
paramSpecs: tbdParams,
|
|
56
|
+
nonInteractive: false,
|
|
57
|
+
paramsEnvPath: ((_a = options.params) !== null && _a !== void 0 ? _a : ""),
|
|
58
|
+
instanceId,
|
|
59
|
+
reconfiguring: true,
|
|
60
|
+
});
|
|
61
|
+
const newParamValues = Object.assign(Object.assign({}, oldParamValues), (0, paramHelper_1.getBaseParamBindings)(mutableParamsBindingOptions));
|
|
62
|
+
await manifest.writeToManifest([
|
|
63
|
+
{
|
|
64
|
+
instanceId,
|
|
65
|
+
ref: targetRef,
|
|
66
|
+
params: newParamValues,
|
|
67
|
+
},
|
|
68
|
+
], config, {
|
|
69
|
+
nonInteractive: false,
|
|
70
|
+
force: true,
|
|
71
|
+
});
|
|
72
|
+
manifest.showPreviewWarning();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
32
75
|
const spinner = ora(`Configuring ${clc.bold(instanceId)}. This usually takes 3 to 5 minutes...`);
|
|
33
76
|
try {
|
|
34
|
-
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
35
77
|
let existingInstance;
|
|
36
78
|
try {
|
|
37
79
|
existingInstance = await extensionsApi.getInstance(projectId, instanceId);
|
|
@@ -45,10 +87,8 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
45
87
|
throw err;
|
|
46
88
|
}
|
|
47
89
|
const paramSpecWithNewDefaults = paramHelper.getParamsWithCurrentValuesAsDefaults(existingInstance);
|
|
48
|
-
const immutableParams = _.remove(paramSpecWithNewDefaults, (param) =>
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
const params = await paramHelper.getParams({
|
|
90
|
+
const immutableParams = _.remove(paramSpecWithNewDefaults, (param) => param.immutable);
|
|
91
|
+
const paramBindingOptions = await paramHelper.getParams({
|
|
52
92
|
projectId,
|
|
53
93
|
paramSpecs: paramSpecWithNewDefaults,
|
|
54
94
|
nonInteractive: options.nonInteractive,
|
|
@@ -56,13 +96,14 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
56
96
|
instanceId,
|
|
57
97
|
reconfiguring: true,
|
|
58
98
|
});
|
|
99
|
+
const paramBindings = (0, paramHelper_1.getBaseParamBindings)(paramBindingOptions);
|
|
59
100
|
if (immutableParams.length) {
|
|
60
101
|
const plural = immutableParams.length > 1;
|
|
61
102
|
logger_1.logger.info(`The following param${plural ? "s are" : " is"} immutable:`);
|
|
62
103
|
for (const { param } of immutableParams) {
|
|
63
104
|
const value = _.get(existingInstance, `config.params.${param}`);
|
|
64
105
|
logger_1.logger.info(`param: ${param}, value: ${value}`);
|
|
65
|
-
|
|
106
|
+
paramBindings[param] = value;
|
|
66
107
|
}
|
|
67
108
|
logger_1.logger.info((plural
|
|
68
109
|
? "To set different values for these params"
|
|
@@ -70,10 +111,15 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
70
111
|
", uninstall the extension, then install a new instance of this extension.");
|
|
71
112
|
}
|
|
72
113
|
spinner.start();
|
|
73
|
-
const res = await extensionsApi.configureInstance({
|
|
114
|
+
const res = await extensionsApi.configureInstance({
|
|
115
|
+
projectId,
|
|
116
|
+
instanceId,
|
|
117
|
+
params: paramBindings,
|
|
118
|
+
});
|
|
74
119
|
spinner.stop();
|
|
75
120
|
utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `successfully configured ${clc.bold(instanceId)}.`);
|
|
76
121
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`You can view your reconfigured instance in the Firebase console: ${utils.consoleUrl(projectId, `/extensions/instances/${instanceId}?tab=config`)}`));
|
|
122
|
+
manifest.showDeprecationWarning();
|
|
77
123
|
return res;
|
|
78
124
|
}
|
|
79
125
|
catch (err) {
|
|
@@ -88,3 +134,17 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
88
134
|
throw err;
|
|
89
135
|
}
|
|
90
136
|
});
|
|
137
|
+
function infoImmutableParams(immutableParams, paramValues) {
|
|
138
|
+
if (!immutableParams.length) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const plural = immutableParams.length > 1;
|
|
142
|
+
utils.logLabeledWarning(extensionsHelper_1.logPrefix, marked(`The following param${plural ? "s are" : " is"} immutable and won't be changed:`));
|
|
143
|
+
for (const { param } of immutableParams) {
|
|
144
|
+
logger_1.logger.info(`param: ${param}, value: ${paramValues[param]}`);
|
|
145
|
+
}
|
|
146
|
+
logger_1.logger.info((plural
|
|
147
|
+
? "To set different values for these params"
|
|
148
|
+
: "To set a different value for this param") +
|
|
149
|
+
", uninstall the extension, then install a new instance of this extension.");
|
|
150
|
+
}
|
|
@@ -24,6 +24,55 @@ function readCommonTemplates() {
|
|
|
24
24
|
changelogTemplate: fs.readFileSync(path.join(TEMPLATE_ROOT, "CHANGELOG.md"), "utf8"),
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
exports.default = new command_1.Command("ext:dev:init")
|
|
28
|
+
.description("initialize files for writing an extension in the current directory")
|
|
29
|
+
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extDevMinVersion")
|
|
30
|
+
.action(async (options) => {
|
|
31
|
+
const cwd = options.cwd || process.cwd();
|
|
32
|
+
const config = new config_1.Config({}, { projectDir: cwd, cwd: cwd });
|
|
33
|
+
try {
|
|
34
|
+
const lang = await (0, prompt_1.promptOnce)({
|
|
35
|
+
type: "list",
|
|
36
|
+
name: "language",
|
|
37
|
+
message: "In which language do you want to write the Cloud Functions for your extension?",
|
|
38
|
+
default: "javascript",
|
|
39
|
+
choices: [
|
|
40
|
+
{
|
|
41
|
+
name: "JavaScript",
|
|
42
|
+
value: "javascript",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "TypeScript",
|
|
46
|
+
value: "typescript",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
switch (lang) {
|
|
51
|
+
case "javascript": {
|
|
52
|
+
await javascriptSelected(config);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case "typescript": {
|
|
56
|
+
await typescriptSelected(config);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
default: {
|
|
60
|
+
throw new error_1.FirebaseError(`${lang} is not supported.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
await npmDependencies.askInstallDependencies({}, config);
|
|
64
|
+
const welcome = fs.readFileSync(path.join(TEMPLATE_ROOT, lang, "WELCOME.md"), "utf8");
|
|
65
|
+
return logger_1.logger.info("\n" + marked(welcome));
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (!(err instanceof error_1.FirebaseError)) {
|
|
69
|
+
throw new error_1.FirebaseError(`Error occurred when initializing files for new extension: ${err.message}`, {
|
|
70
|
+
original: err,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
27
76
|
async function typescriptSelected(config) {
|
|
28
77
|
const packageLintingTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "package.lint.json"), "utf8");
|
|
29
78
|
const packageNoLintingTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "package.nolint.json"), "utf8");
|
|
@@ -84,52 +133,3 @@ async function javascriptSelected(config) {
|
|
|
84
133
|
}
|
|
85
134
|
await config.askWriteProjectFile("functions/.gitignore", gitignoreTemplate);
|
|
86
135
|
}
|
|
87
|
-
exports.default = new command_1.Command("ext:dev:init")
|
|
88
|
-
.description("initialize files for writing an extension in the current directory")
|
|
89
|
-
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extDevMinVersion")
|
|
90
|
-
.action(async (options) => {
|
|
91
|
-
const cwd = options.cwd || process.cwd();
|
|
92
|
-
const config = new config_1.Config({}, { projectDir: cwd, cwd: cwd });
|
|
93
|
-
try {
|
|
94
|
-
const lang = await (0, prompt_1.promptOnce)({
|
|
95
|
-
type: "list",
|
|
96
|
-
name: "language",
|
|
97
|
-
message: "In which language do you want to write the Cloud Functions for your extension?",
|
|
98
|
-
default: "javascript",
|
|
99
|
-
choices: [
|
|
100
|
-
{
|
|
101
|
-
name: "JavaScript",
|
|
102
|
-
value: "javascript",
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: "TypeScript",
|
|
106
|
-
value: "typescript",
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
});
|
|
110
|
-
switch (lang) {
|
|
111
|
-
case "javascript": {
|
|
112
|
-
await javascriptSelected(config);
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
case "typescript": {
|
|
116
|
-
await typescriptSelected(config);
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
default: {
|
|
120
|
-
throw new error_1.FirebaseError(`${lang} is not supported.`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
await npmDependencies.askInstallDependencies({}, config);
|
|
124
|
-
const welcome = fs.readFileSync(path.join(TEMPLATE_ROOT, lang, "WELCOME.md"), "utf8");
|
|
125
|
-
return logger_1.logger.info("\n" + marked(welcome));
|
|
126
|
-
}
|
|
127
|
-
catch (err) {
|
|
128
|
-
if (!(err instanceof error_1.FirebaseError)) {
|
|
129
|
-
throw new error_1.FirebaseError(`Error occurred when initializing files for new extension: ${err.message}`, {
|
|
130
|
-
original: err,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
throw err;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
@@ -5,6 +5,7 @@ const command_1 = require("../command");
|
|
|
5
5
|
const planner = require("../deploy/extensions/planner");
|
|
6
6
|
const export_1 = require("../extensions/export");
|
|
7
7
|
const extensionsHelper_1 = require("../extensions/extensionsHelper");
|
|
8
|
+
const manifest = require("../extensions/manifest");
|
|
8
9
|
const functional_1 = require("../functional");
|
|
9
10
|
const getProjectNumber_1 = require("../getProjectNumber");
|
|
10
11
|
const logger_1 = require("../logger");
|
|
@@ -24,7 +25,7 @@ module.exports = new command_1.Command("ext:export")
|
|
|
24
25
|
const subbed = await (0, export_1.setSecretParamsToLatest)(i);
|
|
25
26
|
return (0, export_1.parameterizeProject)(projectId, projectNumber, subbed);
|
|
26
27
|
}));
|
|
27
|
-
if (have.length
|
|
28
|
+
if (have.length === 0) {
|
|
28
29
|
logger_1.logger.info(`No extension instances installed on ${projectId}, so there is nothing to export.`);
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
@@ -40,5 +41,9 @@ module.exports = new command_1.Command("ext:export")
|
|
|
40
41
|
logger_1.logger.info("Exiting. No changes made.");
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
+
const existingConfig = manifest.loadConfig(options);
|
|
45
|
+
await manifest.writeToManifest(withRef, existingConfig, {
|
|
46
|
+
nonInteractive: options.nonInteractive,
|
|
47
|
+
force: options.force,
|
|
48
|
+
}, true);
|
|
44
49
|
});
|