firebase-tools 11.25.3 → 11.27.0
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/commands/ext-dev-publish.js +28 -10
- package/lib/commands/ext-install.js +1 -2
- package/lib/deploy/functions/backend.js +1 -5
- package/lib/deploy/functions/release/fabricator.js +16 -6
- package/lib/emulator/functionsEmulator.js +18 -11
- package/lib/emulator/storage/apis/gcloud.js +1 -1
- package/lib/extensions/extensionsApi.js +8 -5
- package/lib/extensions/extensionsHelper.js +230 -32
- package/lib/extensions/localHelper.js +4 -4
- package/lib/extensions/warnings.js +3 -16
- package/lib/frameworks/angular/index.js +6 -3
- package/lib/frameworks/astro/index.js +76 -0
- package/lib/frameworks/astro/utils.js +22 -0
- package/lib/frameworks/index.js +25 -7
- package/lib/frameworks/nuxt/index.js +34 -14
- package/lib/frameworks/nuxt/utils.js +11 -1
- package/lib/frameworks/nuxt2/index.js +3 -9
- package/lib/frameworks/sveltekit/index.js +54 -0
- package/lib/frameworks/sveltekit/interfaces.js +2 -0
- package/lib/frameworks/utils.js +2 -2
- package/lib/frameworks/vite/index.js +12 -5
- package/lib/gcp/cloudfunctions.js +3 -0
- package/lib/gcp/cloudfunctionsv2.js +39 -26
- package/lib/track.js +19 -13
- package/npm-shrinkwrap.json +14 -14
- package/package.json +1 -1
|
@@ -3,13 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.outOfBandChangesWarning = exports.displayWarningsForDeploy = exports.displayWarningPrompts = void 0;
|
|
4
4
|
const marked_1 = require("marked");
|
|
5
5
|
const clc = require("colorette");
|
|
6
|
-
const types_1 = require("./types");
|
|
7
6
|
const displayExtensionInfo_1 = require("./displayExtensionInfo");
|
|
8
7
|
const extensionsHelper_1 = require("./extensionsHelper");
|
|
9
8
|
const resolveSource_1 = require("./resolveSource");
|
|
10
9
|
const deploymentSummary_1 = require("../deploy/extensions/deploymentSummary");
|
|
11
10
|
const planner_1 = require("../deploy/extensions/planner");
|
|
12
|
-
const functional_1 = require("../functional");
|
|
13
11
|
const utils = require("../utils");
|
|
14
12
|
const logger_1 = require("../logger");
|
|
15
13
|
function displayEAPWarning({ publisherId, sourceDownloadUri, githubLink, }) {
|
|
@@ -19,10 +17,7 @@ function displayEAPWarning({ publisherId, sourceDownloadUri, githubLink, }) {
|
|
|
19
17
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, (0, marked_1.marked)(warningMsg + legalMsg));
|
|
20
18
|
(0, displayExtensionInfo_1.printSourceDownloadLink)(sourceDownloadUri);
|
|
21
19
|
}
|
|
22
|
-
function
|
|
23
|
-
utils.logLabeledBullet(extensionsHelper_1.logPrefix, (0, marked_1.marked)(`${clc.yellow(clc.bold("Important"))}: This extension is ${clc.bold("experimental")} and may not be production-ready. Its functionality might change in backward-incompatible ways before its official release, or it may be discontinued.`));
|
|
24
|
-
}
|
|
25
|
-
async function displayWarningPrompts(publisherId, launchStage, extensionVersion) {
|
|
20
|
+
async function displayWarningPrompts(publisherId, extensionVersion) {
|
|
26
21
|
const trustedPublishers = await (0, resolveSource_1.getTrustedPublishers)();
|
|
27
22
|
if (!trustedPublishers.includes(publisherId)) {
|
|
28
23
|
displayEAPWarning({
|
|
@@ -31,9 +26,6 @@ async function displayWarningPrompts(publisherId, launchStage, extensionVersion)
|
|
|
31
26
|
githubLink: extensionVersion.spec.sourceUrl,
|
|
32
27
|
});
|
|
33
28
|
}
|
|
34
|
-
else if (launchStage === types_1.RegistryLaunchStage.EXPERIMENTAL) {
|
|
35
|
-
displayExperimentalWarning();
|
|
36
|
-
}
|
|
37
29
|
else {
|
|
38
30
|
return;
|
|
39
31
|
}
|
|
@@ -54,19 +46,14 @@ async function displayWarningsForDeploy(instancesToCreate) {
|
|
|
54
46
|
for (const i of publishedExtensionInstances) {
|
|
55
47
|
await (0, planner_1.getExtension)(i);
|
|
56
48
|
}
|
|
57
|
-
const
|
|
58
|
-
const experimental = nonEapExtensions.filter((i) => i.extension.registryLaunchStage === types_1.RegistryLaunchStage.EXPERIMENTAL);
|
|
59
|
-
if (experimental.length) {
|
|
60
|
-
const humanReadableList = experimental.map((i) => `\t${(0, deploymentSummary_1.humanReadable)(i)}`).join("\n");
|
|
61
|
-
utils.logLabeledBullet(extensionsHelper_1.logPrefix, (0, marked_1.marked)(`The following are instances of ${clc.bold("experimental")} extensions.They may not be production-ready. Their functionality may change in backward-incompatible ways before their official release, or they may be discontinued.\n${humanReadableList}\n`, { gfm: false }));
|
|
62
|
-
}
|
|
49
|
+
const eapExtensions = publishedExtensionInstances.filter((i) => { var _a, _b; return !trustedPublishers.includes((_b = (_a = i.ref) === null || _a === void 0 ? void 0 : _a.publisherId) !== null && _b !== void 0 ? _b : ""); });
|
|
63
50
|
if (eapExtensions.length) {
|
|
64
51
|
const humanReadableList = eapExtensions.map(toListEntry).join("\n");
|
|
65
52
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, (0, marked_1.marked)(`These extensions are in preview and are built by a developer in the Extensions Publisher Early Access Program (http://bit.ly/firex-provider). Their functionality might change in backwards-incompatible ways. Since these extensions aren't built by Firebase, reach out to their publisher with questions about them.` +
|
|
66
53
|
` They are provided “AS IS”, without any warranty, express or implied, from Google.` +
|
|
67
54
|
` Google disclaims all liability for any damages, direct or indirect, resulting from the use of these extensions\n${humanReadableList}`, { gfm: false }));
|
|
68
55
|
}
|
|
69
|
-
return
|
|
56
|
+
return eapExtensions.length > 0;
|
|
70
57
|
}
|
|
71
58
|
exports.displayWarningsForDeploy = displayWarningsForDeploy;
|
|
72
59
|
function outOfBandChangesWarning(instanceIds) {
|
|
@@ -12,7 +12,6 @@ const utils_1 = require("../utils");
|
|
|
12
12
|
exports.name = "Angular";
|
|
13
13
|
exports.support = "experimental";
|
|
14
14
|
exports.type = 3;
|
|
15
|
-
const CLI_COMMAND = (0, path_1.join)("node_modules", ".bin", process.platform === "win32" ? "ng.cmd" : "ng");
|
|
16
15
|
const DEFAULT_BUILD_SCRIPT = ["ng build"];
|
|
17
16
|
async function discover(dir) {
|
|
18
17
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
@@ -55,7 +54,8 @@ async function build(dir) {
|
|
|
55
54
|
if (!browserTarget)
|
|
56
55
|
throw new Error("No build target...");
|
|
57
56
|
if (prerenderTarget) {
|
|
58
|
-
(0,
|
|
57
|
+
const cli = (0, __1.getNodeModuleBin)("ng", dir);
|
|
58
|
+
(0, child_process_1.execSync)(`${cli} run ${targetStringFromTarget(prerenderTarget)}`, {
|
|
59
59
|
cwd: dir,
|
|
60
60
|
stdio: "inherit",
|
|
61
61
|
});
|
|
@@ -75,7 +75,10 @@ async function getDevModeHandle(dir) {
|
|
|
75
75
|
if (!serveTarget)
|
|
76
76
|
return;
|
|
77
77
|
const host = new Promise((resolve) => {
|
|
78
|
-
const
|
|
78
|
+
const cli = (0, __1.getNodeModuleBin)("ng", dir);
|
|
79
|
+
const serve = (0, cross_spawn_1.spawn)(cli, ["run", targetStringFromTarget(serveTarget), "--host", "localhost"], {
|
|
80
|
+
cwd: dir,
|
|
81
|
+
});
|
|
79
82
|
serve.stdout.on("data", (data) => {
|
|
80
83
|
process.stdout.write(data);
|
|
81
84
|
const match = data.toString().match(/(http:\/\/localhost:\d+)/);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.type = exports.support = exports.name = void 0;
|
|
4
|
+
const cross_spawn_1 = require("cross-spawn");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
const error_1 = require("../../error");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const utils_2 = require("./utils");
|
|
11
|
+
exports.name = "Astro";
|
|
12
|
+
exports.support = "experimental";
|
|
13
|
+
exports.type = 2;
|
|
14
|
+
function getAstroVersion(cwd) {
|
|
15
|
+
var _a;
|
|
16
|
+
return (_a = (0, __1.findDependency)("astro", { cwd, depth: 0, omitDev: false })) === null || _a === void 0 ? void 0 : _a.version;
|
|
17
|
+
}
|
|
18
|
+
async function discover(dir) {
|
|
19
|
+
if (!(0, fs_extra_1.existsSync)((0, path_1.join)(dir, "package.json")))
|
|
20
|
+
return;
|
|
21
|
+
if (!getAstroVersion(dir))
|
|
22
|
+
return;
|
|
23
|
+
const { output, publicDir: publicDirectory } = await (0, utils_2.getConfig)(dir);
|
|
24
|
+
return {
|
|
25
|
+
mayWantBackend: output === "server",
|
|
26
|
+
publicDirectory,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.discover = discover;
|
|
30
|
+
const DEFAULT_BUILD_SCRIPT = ["astro build"];
|
|
31
|
+
async function build(cwd) {
|
|
32
|
+
const cli = (0, __1.getNodeModuleBin)("astro", cwd);
|
|
33
|
+
await (0, utils_1.warnIfCustomBuildScript)(cwd, exports.name, DEFAULT_BUILD_SCRIPT);
|
|
34
|
+
const { output, adapter } = await (0, utils_2.getConfig)(cwd);
|
|
35
|
+
if (output === "server" && (adapter === null || adapter === void 0 ? void 0 : adapter.name) !== "@astrojs/node") {
|
|
36
|
+
throw new error_1.FirebaseError("Deploying an Astro application with SSR on Firebase Hosting requires the @astrojs/node adapter.");
|
|
37
|
+
}
|
|
38
|
+
const build = (0, cross_spawn_1.sync)(cli, ["build"], { cwd, stdio: "inherit" });
|
|
39
|
+
if (build.status)
|
|
40
|
+
throw new error_1.FirebaseError("Unable to build your Astro app");
|
|
41
|
+
return { wantsBackend: output === "server" };
|
|
42
|
+
}
|
|
43
|
+
exports.build = build;
|
|
44
|
+
async function ɵcodegenPublicDirectory(root, dest) {
|
|
45
|
+
const { outDir, output } = await (0, utils_2.getConfig)(root);
|
|
46
|
+
const assetPath = (0, path_1.join)(root, outDir, output === "server" ? "client" : "");
|
|
47
|
+
await (0, fs_extra_1.copy)(assetPath, dest);
|
|
48
|
+
}
|
|
49
|
+
exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
|
|
50
|
+
async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
|
|
51
|
+
const { outDir } = await (0, utils_2.getConfig)(sourceDir);
|
|
52
|
+
const packageJson = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, "package.json"));
|
|
53
|
+
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, outDir, "server"), (0, path_1.join)(destDir));
|
|
54
|
+
return {
|
|
55
|
+
packageJson,
|
|
56
|
+
bootstrapScript: (0, utils_2.getBootstrapScript)(),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
60
|
+
async function getDevModeHandle(cwd) {
|
|
61
|
+
const host = new Promise((resolve) => {
|
|
62
|
+
const cli = (0, __1.getNodeModuleBin)("astro", cwd);
|
|
63
|
+
const serve = (0, cross_spawn_1.spawn)(cli, ["dev"], { cwd });
|
|
64
|
+
serve.stdout.on("data", (data) => {
|
|
65
|
+
process.stdout.write(data);
|
|
66
|
+
const match = data.toString().match(/(http:\/\/.+:\d+)/);
|
|
67
|
+
if (match)
|
|
68
|
+
resolve(match[1]);
|
|
69
|
+
});
|
|
70
|
+
serve.stderr.on("data", (data) => {
|
|
71
|
+
process.stderr.write(data);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
return (0, utils_1.simpleProxy)(await host);
|
|
75
|
+
}
|
|
76
|
+
exports.getDevModeHandle = getDevModeHandle;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConfig = exports.getBootstrapScript = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const { dynamicImport } = require(true && "../../dynamicImport");
|
|
6
|
+
function getBootstrapScript() {
|
|
7
|
+
return `const entry = import('./entry.mjs');\nexport const handle = async (req, res) => (await entry).handler(req, res)`;
|
|
8
|
+
}
|
|
9
|
+
exports.getBootstrapScript = getBootstrapScript;
|
|
10
|
+
async function getConfig(cwd) {
|
|
11
|
+
const astroDirectory = (0, path_1.dirname)(require.resolve("astro/package.json", { paths: [cwd] }));
|
|
12
|
+
const { openConfig } = await dynamicImport((0, path_1.join)(astroDirectory, "dist", "core", "config", "config.js"));
|
|
13
|
+
const logging = undefined;
|
|
14
|
+
const { astroConfig: config } = await openConfig({ cmd: "build", cwd, logging });
|
|
15
|
+
return {
|
|
16
|
+
outDir: (0, path_1.relative)(cwd, config.outDir.pathname),
|
|
17
|
+
publicDir: (0, path_1.relative)(cwd, config.publicDir.pathname),
|
|
18
|
+
output: config.output,
|
|
19
|
+
adapter: config.adapter,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.getConfig = getConfig;
|
package/lib/frameworks/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepareFrameworks = exports.findDependency = exports.discover = exports.relativeRequire = exports.WebFrameworks = exports.ALLOWED_SSR_REGIONS = exports.DEFAULT_REGION = exports.NODE_VERSION = exports.FIREBASE_ADMIN_VERSION = exports.FIREBASE_FUNCTIONS_VERSION = exports.FIREBASE_FRAMEWORKS_VERSION = void 0;
|
|
3
|
+
exports.prepareFrameworks = exports.findDependency = exports.getNodeModuleBin = exports.discover = exports.relativeRequire = exports.WebFrameworks = exports.ALLOWED_SSR_REGIONS = exports.DEFAULT_REGION = exports.NODE_VERSION = exports.FIREBASE_ADMIN_VERSION = exports.FIREBASE_FUNCTIONS_VERSION = exports.FIREBASE_FRAMEWORKS_VERSION = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const process_1 = require("process");
|
|
6
6
|
const child_process_1 = require("child_process");
|
|
@@ -28,12 +28,13 @@ const requireHostingSite_1 = require("../requireHostingSite");
|
|
|
28
28
|
const experiments = require("../experiments");
|
|
29
29
|
const ensureTargeted_1 = require("../functions/ensureTargeted");
|
|
30
30
|
const implicitInit_1 = require("../hosting/implicitInit");
|
|
31
|
+
const fsutils_1 = require("../fsutils");
|
|
31
32
|
const { dynamicImport } = require(true && "../dynamicImport");
|
|
32
33
|
const SupportLevelWarnings = {
|
|
33
34
|
["experimental"]: clc.yellow(`This is an experimental integration, proceed with caution.`),
|
|
34
35
|
["community-supported"]: clc.yellow(`This is a community-supported integration, support is best effort.`),
|
|
35
36
|
};
|
|
36
|
-
exports.FIREBASE_FRAMEWORKS_VERSION = "^0.
|
|
37
|
+
exports.FIREBASE_FRAMEWORKS_VERSION = "^0.7.0";
|
|
37
38
|
exports.FIREBASE_FUNCTIONS_VERSION = "^3.23.0";
|
|
38
39
|
exports.FIREBASE_ADMIN_VERSION = "^11.0.1";
|
|
39
40
|
exports.NODE_VERSION = parseInt(process.versions.node, 10).toString();
|
|
@@ -49,7 +50,6 @@ const DEFAULT_FIND_DEP_OPTIONS = {
|
|
|
49
50
|
cwd: process.cwd(),
|
|
50
51
|
omitDev: true,
|
|
51
52
|
};
|
|
52
|
-
const NPM_COMMAND = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
53
53
|
exports.WebFrameworks = Object.fromEntries((0, fs_1.readdirSync)(__dirname)
|
|
54
54
|
.filter((path) => (0, fs_1.statSync)((0, path_1.join)(__dirname, path)).isDirectory())
|
|
55
55
|
.map((path) => [path, require((0, path_1.join)(__dirname, path))])
|
|
@@ -110,11 +110,29 @@ function scanDependencyTree(searchingFor, dependencies = {}) {
|
|
|
110
110
|
}
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
|
+
function getNodeModuleBin(name, cwd) {
|
|
114
|
+
var _a;
|
|
115
|
+
const cantFindExecutable = new error_1.FirebaseError(`Could not find the ${name} executable.`);
|
|
116
|
+
const npmBin = (_a = (0, cross_spawn_1.sync)("npm", ["bin"], { cwd }).stdout) === null || _a === void 0 ? void 0 : _a.toString().trim();
|
|
117
|
+
if (!npmBin) {
|
|
118
|
+
throw cantFindExecutable;
|
|
119
|
+
}
|
|
120
|
+
const path = (0, path_1.join)(npmBin, name);
|
|
121
|
+
if (!(0, fsutils_1.fileExistsSync)(path)) {
|
|
122
|
+
throw cantFindExecutable;
|
|
123
|
+
}
|
|
124
|
+
return path;
|
|
125
|
+
}
|
|
126
|
+
exports.getNodeModuleBin = getNodeModuleBin;
|
|
113
127
|
function findDependency(name, options = {}) {
|
|
114
|
-
|
|
128
|
+
var _a;
|
|
129
|
+
const { cwd: dir, depth, omitDev } = Object.assign(Object.assign({}, DEFAULT_FIND_DEP_OPTIONS), options);
|
|
130
|
+
const cwd = (_a = (0, cross_spawn_1.sync)("npm", ["root"], { cwd: dir }).stdout) === null || _a === void 0 ? void 0 : _a.toString().trim();
|
|
131
|
+
if (!cwd)
|
|
132
|
+
return;
|
|
115
133
|
const env = Object.assign({}, process.env);
|
|
116
134
|
delete env.NODE_ENV;
|
|
117
|
-
const result = (0, cross_spawn_1.sync)(
|
|
135
|
+
const result = (0, cross_spawn_1.sync)("npm", [
|
|
118
136
|
"list",
|
|
119
137
|
name,
|
|
120
138
|
"--json",
|
|
@@ -240,7 +258,7 @@ async function prepareFrameworks(targetNames, context, options, emulators = [])
|
|
|
240
258
|
}
|
|
241
259
|
const results = await discover(getProjectPath());
|
|
242
260
|
if (!results)
|
|
243
|
-
throw new
|
|
261
|
+
throw new error_1.FirebaseError("Unable to detect the web framework in use, check firebase-debug.log for more info.");
|
|
244
262
|
const { framework, mayWantBackend, publicDirectory } = results;
|
|
245
263
|
const { build, ɵcodegenPublicDirectory, ɵcodegenFunctionsDirectory: codegenProdModeFunctionsDirectory, getDevModeHandle, name, support, } = exports.WebFrameworks[framework];
|
|
246
264
|
console.log(`Detected a ${name} codebase. ${SupportLevelWarnings[support] || ""}\n`);
|
|
@@ -371,7 +389,7 @@ ${firebaseDefaults ? `__FIREBASE_DEFAULTS__=${JSON.stringify(firebaseDefaults)}\
|
|
|
371
389
|
resolve(matches);
|
|
372
390
|
}));
|
|
373
391
|
await Promise.all(envs.map((path) => (0, promises_1.copyFile)(path, (0, path_1.join)(functionsDist, (0, path_1.basename)(path)))));
|
|
374
|
-
(0, child_process_1.execSync)(
|
|
392
|
+
(0, child_process_1.execSync)(`npm i --omit dev --no-audit`, {
|
|
375
393
|
cwd: functionsDist,
|
|
376
394
|
stdio: "inherit",
|
|
377
395
|
});
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.type = exports.support = exports.name = void 0;
|
|
3
|
+
exports.getConfig = exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.type = exports.support = exports.name = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const promises_1 = require("fs/promises");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const semver_1 = require("semver");
|
|
8
|
+
const cross_spawn_1 = require("cross-spawn");
|
|
8
9
|
const __1 = require("..");
|
|
9
10
|
const utils_1 = require("../utils");
|
|
11
|
+
const utils_2 = require("./utils");
|
|
10
12
|
exports.name = "Nuxt";
|
|
11
13
|
exports.support = "experimental";
|
|
12
14
|
exports.type = 4;
|
|
13
|
-
const
|
|
14
|
-
const DEFAULT_BUILD_SCRIPT = ["nuxt build"];
|
|
15
|
+
const utils_3 = require("./utils");
|
|
16
|
+
const DEFAULT_BUILD_SCRIPT = ["nuxt build", "nuxi build"];
|
|
15
17
|
async function discover(dir) {
|
|
16
18
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
17
19
|
return;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const version = nuxtDependency === null || nuxtDependency === void 0 ? void 0 : nuxtDependency.version;
|
|
24
|
-
const anyConfigFileExists = await (0, utils_2.nuxtConfigFilesExist)(dir);
|
|
25
|
-
if (!anyConfigFileExists && !nuxtDependency)
|
|
20
|
+
const anyConfigFileExists = await (0, utils_3.nuxtConfigFilesExist)(dir);
|
|
21
|
+
const nuxtVersion = (0, utils_2.getNuxtVersion)(dir);
|
|
22
|
+
if (!anyConfigFileExists && !nuxtVersion)
|
|
23
|
+
return;
|
|
24
|
+
if (nuxtVersion && (0, semver_1.lt)(nuxtVersion, "3.0.0-0"))
|
|
26
25
|
return;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return;
|
|
26
|
+
const { dir: { public: publicDirectory }, } = await getConfig(dir);
|
|
27
|
+
return { publicDirectory, mayWantBackend: true };
|
|
30
28
|
}
|
|
31
29
|
exports.discover = discover;
|
|
32
30
|
async function build(root) {
|
|
@@ -60,3 +58,25 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
|
|
|
60
58
|
return { packageJson: Object.assign(Object.assign({}, packageJson), outputPackageJson), frameworksEntry: "nuxt3" };
|
|
61
59
|
}
|
|
62
60
|
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
61
|
+
async function getDevModeHandle(cwd) {
|
|
62
|
+
const host = new Promise((resolve) => {
|
|
63
|
+
const cli = (0, __1.getNodeModuleBin)("nuxt", cwd);
|
|
64
|
+
const serve = (0, cross_spawn_1.spawn)(cli, ["dev"], { cwd: cwd });
|
|
65
|
+
serve.stdout.on("data", (data) => {
|
|
66
|
+
process.stdout.write(data);
|
|
67
|
+
const match = data.toString().match(/(http:\/\/.+:\d+)/);
|
|
68
|
+
if (match)
|
|
69
|
+
resolve(match[1]);
|
|
70
|
+
});
|
|
71
|
+
serve.stderr.on("data", (data) => {
|
|
72
|
+
process.stderr.write(data);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
return (0, utils_1.simpleProxy)(await host);
|
|
76
|
+
}
|
|
77
|
+
exports.getDevModeHandle = getDevModeHandle;
|
|
78
|
+
async function getConfig(dir) {
|
|
79
|
+
const { loadNuxtConfig } = await (0, __1.relativeRequire)(dir, "@nuxt/kit");
|
|
80
|
+
return await loadNuxtConfig(dir);
|
|
81
|
+
}
|
|
82
|
+
exports.getConfig = getConfig;
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nuxtConfigFilesExist = void 0;
|
|
3
|
+
exports.nuxtConfigFilesExist = exports.getNuxtVersion = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
function getNuxtVersion(cwd) {
|
|
8
|
+
var _a;
|
|
9
|
+
return (_a = (0, __1.findDependency)("nuxt", {
|
|
10
|
+
cwd,
|
|
11
|
+
depth: 0,
|
|
12
|
+
omitDev: false,
|
|
13
|
+
})) === null || _a === void 0 ? void 0 : _a.version;
|
|
14
|
+
}
|
|
15
|
+
exports.getNuxtVersion = getNuxtVersion;
|
|
6
16
|
async function nuxtConfigFilesExist(dir) {
|
|
7
17
|
const configFilesExist = await Promise.all([
|
|
8
18
|
(0, fs_extra_1.pathExists)((0, path_1.join)(dir, "nuxt.config.js")),
|
|
@@ -13,18 +13,12 @@ exports.type = 2;
|
|
|
13
13
|
async function discover(dir) {
|
|
14
14
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
15
15
|
return;
|
|
16
|
-
const
|
|
17
|
-
cwd: dir,
|
|
18
|
-
depth: 0,
|
|
19
|
-
omitDev: false,
|
|
20
|
-
});
|
|
21
|
-
const version = nuxtDependency === null || nuxtDependency === void 0 ? void 0 : nuxtDependency.version;
|
|
16
|
+
const nuxtVersion = (0, utils_1.getNuxtVersion)(dir);
|
|
22
17
|
const anyConfigFileExists = await (0, utils_1.nuxtConfigFilesExist)(dir);
|
|
23
|
-
if (!anyConfigFileExists && !
|
|
18
|
+
if (!anyConfigFileExists && !nuxtVersion)
|
|
24
19
|
return;
|
|
25
|
-
if (
|
|
20
|
+
if (nuxtVersion && (0, semver_1.lt)(nuxtVersion, "3.0.0-0"))
|
|
26
21
|
return { mayWantBackend: true };
|
|
27
|
-
return;
|
|
28
22
|
}
|
|
29
23
|
exports.discover = discover;
|
|
30
24
|
async function getNuxtApp(cwd) {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.getDevModeHandle = exports.discover = exports.type = exports.support = exports.name = void 0;
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const vite_1 = require("../vite");
|
|
7
|
+
const fsutils_1 = require("../../fsutils");
|
|
8
|
+
const { dynamicImport } = require(true && "../../dynamicImport");
|
|
9
|
+
exports.name = "SvelteKit";
|
|
10
|
+
exports.support = "experimental";
|
|
11
|
+
exports.type = 2;
|
|
12
|
+
exports.discover = (0, vite_1.viteDiscoverWithNpmDependency)("@sveltejs/kit");
|
|
13
|
+
var vite_2 = require("../vite");
|
|
14
|
+
Object.defineProperty(exports, "getDevModeHandle", { enumerable: true, get: function () { return vite_2.getDevModeHandle; } });
|
|
15
|
+
async function build(root) {
|
|
16
|
+
var _a;
|
|
17
|
+
const config = await getConfig(root);
|
|
18
|
+
const wantsBackend = ((_a = config.kit.adapter) === null || _a === void 0 ? void 0 : _a.name) !== "@sveltejs/adapter-static";
|
|
19
|
+
await (0, vite_1.build)(root);
|
|
20
|
+
return { wantsBackend };
|
|
21
|
+
}
|
|
22
|
+
exports.build = build;
|
|
23
|
+
async function ɵcodegenPublicDirectory(root, dest) {
|
|
24
|
+
const config = await getConfig(root);
|
|
25
|
+
const output = (0, path_1.join)(root, config.kit.outDir, "output");
|
|
26
|
+
await (0, fs_extra_1.copy)((0, path_1.join)(output, "client"), dest);
|
|
27
|
+
const prerenderedPath = (0, path_1.join)(output, "prerendered", "pages");
|
|
28
|
+
if (await (0, fs_extra_1.pathExists)(prerenderedPath)) {
|
|
29
|
+
await (0, fs_extra_1.copy)(prerenderedPath, dest);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
|
|
33
|
+
async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
|
|
34
|
+
var _a;
|
|
35
|
+
var _b;
|
|
36
|
+
const packageJsonBuffer = await (0, fs_extra_1.readFile)((0, path_1.join)(sourceDir, "package.json"));
|
|
37
|
+
const packageJson = JSON.parse(packageJsonBuffer.toString());
|
|
38
|
+
packageJson.dependencies || (packageJson.dependencies = {});
|
|
39
|
+
(_a = (_b = packageJson.dependencies)["@sveltejs/kit"]) !== null && _a !== void 0 ? _a : (_b["@sveltejs/kit"] = packageJson.devDependencies["@sveltejs/kit"]);
|
|
40
|
+
const config = await getConfig(sourceDir);
|
|
41
|
+
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, config.kit.outDir, "output", "server"), destDir);
|
|
42
|
+
return { packageJson, frameworksEntry: "sveltekit" };
|
|
43
|
+
}
|
|
44
|
+
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
45
|
+
async function getConfig(root) {
|
|
46
|
+
var _a;
|
|
47
|
+
const configPath = ["svelte.config.js", "svelte.config.mjs"]
|
|
48
|
+
.map((filename) => (0, path_1.join)(root, filename))
|
|
49
|
+
.find(fsutils_1.fileExistsSync);
|
|
50
|
+
const config = configPath ? (await dynamicImport(configPath)).default : {};
|
|
51
|
+
config.kit || (config.kit = {});
|
|
52
|
+
(_a = config.kit).outDir || (_a.outDir = ".svelte-kit");
|
|
53
|
+
return config;
|
|
54
|
+
}
|
package/lib/frameworks/utils.js
CHANGED
|
@@ -37,8 +37,8 @@ function simpleProxy(hostOrRequestHandler) {
|
|
|
37
37
|
return next();
|
|
38
38
|
}
|
|
39
39
|
if (typeof hostOrRequestHandler === "string") {
|
|
40
|
-
const
|
|
41
|
-
const {
|
|
40
|
+
const { hostname, port, protocol, username, password } = new URL(hostOrRequestHandler);
|
|
41
|
+
const host = `${hostname}:${port}`;
|
|
42
42
|
const auth = username || password ? `${username}:${password}` : undefined;
|
|
43
43
|
const opts = {
|
|
44
44
|
agent,
|
|
@@ -12,7 +12,6 @@ const utils_1 = require("../utils");
|
|
|
12
12
|
exports.name = "Vite";
|
|
13
13
|
exports.support = "experimental";
|
|
14
14
|
exports.type = 4;
|
|
15
|
-
const CLI_COMMAND = (0, path_1.join)("node_modules", ".bin", process.platform === "win32" ? "vite.cmd" : "vite");
|
|
16
15
|
exports.DEFAULT_BUILD_SCRIPT = ["vite build", "tsc && vite build"];
|
|
17
16
|
const initViteTemplate = (template) => async (setup, config) => await init(setup, config, template);
|
|
18
17
|
exports.initViteTemplate = initViteTemplate;
|
|
@@ -40,7 +39,7 @@ exports.vitePluginDiscover = vitePluginDiscover;
|
|
|
40
39
|
async function discover(dir, plugin, npmDependency) {
|
|
41
40
|
if (!(0, fs_1.existsSync)((0, path_1.join)(dir, "package.json")))
|
|
42
41
|
return;
|
|
43
|
-
const additionalDep = npmDependency && (0, __1.findDependency)(npmDependency, { cwd: dir, depth: 0, omitDev:
|
|
42
|
+
const additionalDep = npmDependency && (0, __1.findDependency)(npmDependency, { cwd: dir, depth: 0, omitDev: false });
|
|
44
43
|
const depth = plugin ? undefined : 0;
|
|
45
44
|
const configFilesExist = await Promise.all([
|
|
46
45
|
(0, fs_extra_1.pathExists)((0, path_1.join)(dir, "vite.config.js")),
|
|
@@ -60,7 +59,10 @@ exports.discover = discover;
|
|
|
60
59
|
async function build(root) {
|
|
61
60
|
const { build } = (0, __1.relativeRequire)(root, "vite");
|
|
62
61
|
await (0, utils_1.warnIfCustomBuildScript)(root, exports.name, exports.DEFAULT_BUILD_SCRIPT);
|
|
63
|
-
|
|
62
|
+
const cwd = process.cwd();
|
|
63
|
+
process.chdir(root);
|
|
64
|
+
await build({ root, mode: "production" });
|
|
65
|
+
process.chdir(cwd);
|
|
64
66
|
}
|
|
65
67
|
exports.build = build;
|
|
66
68
|
async function ɵcodegenPublicDirectory(root, dest) {
|
|
@@ -71,7 +73,8 @@ async function ɵcodegenPublicDirectory(root, dest) {
|
|
|
71
73
|
exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
|
|
72
74
|
async function getDevModeHandle(dir) {
|
|
73
75
|
const host = new Promise((resolve) => {
|
|
74
|
-
const
|
|
76
|
+
const cli = (0, __1.getNodeModuleBin)("vite", dir);
|
|
77
|
+
const serve = (0, cross_spawn_1.spawn)(cli, [], { cwd: dir });
|
|
75
78
|
serve.stdout.on("data", (data) => {
|
|
76
79
|
process.stdout.write(data);
|
|
77
80
|
const match = data.toString().match(/(http:\/\/.+:\d+)/);
|
|
@@ -87,5 +90,9 @@ async function getDevModeHandle(dir) {
|
|
|
87
90
|
exports.getDevModeHandle = getDevModeHandle;
|
|
88
91
|
async function getConfig(root) {
|
|
89
92
|
const { resolveConfig } = (0, __1.relativeRequire)(root, "vite");
|
|
90
|
-
|
|
93
|
+
const cwd = process.cwd();
|
|
94
|
+
process.chdir(root);
|
|
95
|
+
const config = await resolveConfig({ root }, "build", "production");
|
|
96
|
+
process.chdir(cwd);
|
|
97
|
+
return config;
|
|
91
98
|
}
|
|
@@ -44,6 +44,7 @@ exports.generateUploadUrl = generateUploadUrl;
|
|
|
44
44
|
async function createFunction(cloudFunction) {
|
|
45
45
|
const apiPath = cloudFunction.name.substring(0, cloudFunction.name.lastIndexOf("/"));
|
|
46
46
|
const endpoint = `/${apiPath}`;
|
|
47
|
+
cloudFunction.buildEnvironmentVariables = Object.assign(Object.assign({}, cloudFunction.buildEnvironmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
47
48
|
try {
|
|
48
49
|
const res = await client.post(endpoint, cloudFunction);
|
|
49
50
|
return {
|
|
@@ -131,6 +132,8 @@ exports.setInvokerUpdate = setInvokerUpdate;
|
|
|
131
132
|
async function updateFunction(cloudFunction) {
|
|
132
133
|
const endpoint = `/${cloudFunction.name}`;
|
|
133
134
|
const fieldMasks = proto.fieldMasks(cloudFunction, "labels", "environmentVariables", "secretEnvironmentVariables");
|
|
135
|
+
cloudFunction.buildEnvironmentVariables = Object.assign(Object.assign({}, cloudFunction.buildEnvironmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
136
|
+
fieldMasks.push("buildEnvironmentVariables");
|
|
134
137
|
try {
|
|
135
138
|
const res = await client.patch(endpoint, cloudFunction, {
|
|
136
139
|
queryParams: {
|
|
@@ -80,6 +80,7 @@ exports.generateUploadUrl = generateUploadUrl;
|
|
|
80
80
|
async function createFunction(cloudFunction) {
|
|
81
81
|
const components = cloudFunction.name.split("/");
|
|
82
82
|
const functionId = components.splice(-1, 1)[0];
|
|
83
|
+
cloudFunction.buildConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.buildConfig.environmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
83
84
|
try {
|
|
84
85
|
const res = await client.post(components.join("/"), cloudFunction, { queryParams: { functionId } });
|
|
85
86
|
return res.body;
|
|
@@ -133,6 +134,8 @@ async function listFunctionsInternal(projectId, region) {
|
|
|
133
134
|
}
|
|
134
135
|
async function updateFunction(cloudFunction) {
|
|
135
136
|
const fieldMasks = proto.fieldMasks(cloudFunction, "labels", "serviceConfig.environmentVariables", "serviceConfig.secretEnvironmentVariables");
|
|
137
|
+
cloudFunction.buildConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.buildConfig.environmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
138
|
+
fieldMasks.push("buildConfig.buildEnvironmentVariables");
|
|
136
139
|
try {
|
|
137
140
|
const queryParams = {
|
|
138
141
|
updateMask: fieldMasks.join(","),
|
|
@@ -322,39 +325,49 @@ function endpointFromFunction(gcfFunction) {
|
|
|
322
325
|
}
|
|
323
326
|
const endpoint = Object.assign(Object.assign({ platform: "gcfv2", id,
|
|
324
327
|
project,
|
|
325
|
-
region }, trigger), { entryPoint: gcfFunction.buildConfig.entryPoint, runtime: gcfFunction.buildConfig.runtime
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
328
|
+
region }, trigger), { entryPoint: gcfFunction.buildConfig.entryPoint, runtime: gcfFunction.buildConfig.runtime });
|
|
329
|
+
if (gcfFunction.serviceConfig) {
|
|
330
|
+
proto.copyIfPresent(endpoint, gcfFunction.serviceConfig, "ingressSettings", "environmentVariables", "secretEnvironmentVariables", "timeoutSeconds", "uri");
|
|
331
|
+
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "serviceAccount", "serviceAccountEmail");
|
|
332
|
+
proto.convertIfPresent(endpoint, gcfFunction.serviceConfig, "availableMemoryMb", "availableMemory", (prod) => {
|
|
333
|
+
if (prod === null) {
|
|
334
|
+
logger_1.logger.debug("Prod should always return a valid memory amount");
|
|
335
|
+
return prod;
|
|
336
|
+
}
|
|
337
|
+
const mem = mebibytes(prod);
|
|
338
|
+
if (!backend.isValidMemoryOption(mem)) {
|
|
339
|
+
logger_1.logger.warn("Converting a function to an endpoint with an invalid memory option", mem);
|
|
340
|
+
}
|
|
341
|
+
return mem;
|
|
342
|
+
});
|
|
343
|
+
proto.convertIfPresent(endpoint, gcfFunction.serviceConfig, "cpu", "availableCpu", (cpu) => {
|
|
344
|
+
let cpuVal = Number(cpu);
|
|
345
|
+
if (Number.isNaN(cpuVal)) {
|
|
346
|
+
cpuVal = null;
|
|
347
|
+
}
|
|
348
|
+
return cpuVal;
|
|
349
|
+
});
|
|
350
|
+
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "minInstances", "minInstanceCount");
|
|
351
|
+
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "maxInstances", "maxInstanceCount");
|
|
352
|
+
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "concurrency", "maxInstanceRequestConcurrency");
|
|
353
|
+
proto.copyIfPresent(endpoint, gcfFunction, "labels");
|
|
354
|
+
if (gcfFunction.serviceConfig.vpcConnector) {
|
|
355
|
+
endpoint.vpc = { connector: gcfFunction.serviceConfig.vpcConnector };
|
|
356
|
+
proto.renameIfPresent(endpoint.vpc, gcfFunction.serviceConfig, "egressSettings", "vpcConnectorEgressSettings");
|
|
332
357
|
}
|
|
333
|
-
const
|
|
334
|
-
if (!
|
|
335
|
-
logger_1.logger.
|
|
358
|
+
const serviceName = gcfFunction.serviceConfig.service;
|
|
359
|
+
if (!serviceName) {
|
|
360
|
+
logger_1.logger.debug("Got a v2 function without a service name." +
|
|
361
|
+
"Maybe we've migrated to using the v2 API everywhere and missed this code");
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
endpoint.runServiceId = utils.last(serviceName.split("/"));
|
|
336
365
|
}
|
|
337
|
-
return mem;
|
|
338
|
-
});
|
|
339
|
-
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "minInstances", "minInstanceCount");
|
|
340
|
-
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "maxInstances", "maxInstanceCount");
|
|
341
|
-
proto.copyIfPresent(endpoint, gcfFunction, "labels");
|
|
342
|
-
if (gcfFunction.serviceConfig.vpcConnector) {
|
|
343
|
-
endpoint.vpc = { connector: gcfFunction.serviceConfig.vpcConnector };
|
|
344
|
-
proto.renameIfPresent(endpoint.vpc, gcfFunction.serviceConfig, "egressSettings", "vpcConnectorEgressSettings");
|
|
345
366
|
}
|
|
346
367
|
endpoint.codebase = ((_e = gcfFunction.labels) === null || _e === void 0 ? void 0 : _e[constants_1.CODEBASE_LABEL]) || projectConfig.DEFAULT_CODEBASE;
|
|
347
368
|
if ((_f = gcfFunction.labels) === null || _f === void 0 ? void 0 : _f[constants_1.HASH_LABEL]) {
|
|
348
369
|
endpoint.hash = gcfFunction.labels[constants_1.HASH_LABEL];
|
|
349
370
|
}
|
|
350
|
-
const serviceName = gcfFunction.serviceConfig.service;
|
|
351
|
-
if (!serviceName) {
|
|
352
|
-
logger_1.logger.debug("Got a v2 function without a service name." +
|
|
353
|
-
"Maybe we've migrated to using the v2 API everywhere and missed this code");
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
endpoint.runServiceId = utils.last(serviceName.split("/"));
|
|
357
|
-
}
|
|
358
371
|
return endpoint;
|
|
359
372
|
}
|
|
360
373
|
exports.endpointFromFunction = endpointFromFunction;
|