firebase-tools-with-isolate 12.9.1 → 13.0.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/README.md +3 -5
- package/lib/api.js +2 -2
- package/lib/apiv2.js +7 -0
- package/lib/auth.js +8 -4
- package/lib/commands/{frameworks-backends-create.js → apphosting-backends-create.js} +6 -3
- package/lib/commands/{frameworks-backends-delete.js → apphosting-backends-delete.js} +9 -7
- package/lib/commands/{frameworks-backends-get.js → apphosting-backends-get.js} +16 -27
- package/lib/commands/{frameworks-backends-list.js → apphosting-backends-list.js} +9 -19
- package/lib/commands/apphosting-builds-create.js +31 -0
- package/lib/commands/apphosting-builds-get.js +18 -0
- package/lib/commands/apphosting-rollouts-create.js +26 -0
- package/lib/commands/apphosting-rollouts-list.js +18 -0
- package/lib/commands/index.js +12 -7
- package/lib/commands/login-use.js +25 -6
- package/lib/config.js +10 -8
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
- package/lib/deploy/functions/services/firestore.js +11 -1
- package/lib/deploy/lifecycleHooks.js +5 -0
- package/lib/fetchMOTD.js +1 -1
- package/lib/firestore/api.js +6 -6
- package/lib/frameworks/angular/index.js +5 -3
- package/lib/frameworks/angular/utils.js +33 -4
- package/lib/frameworks/astro/index.js +5 -2
- package/lib/frameworks/astro/utils.js +3 -2
- package/lib/frameworks/constants.js +37 -10
- package/lib/frameworks/index.js +12 -7
- package/lib/frameworks/next/index.js +28 -8
- package/lib/frameworks/next/utils.js +7 -3
- package/lib/frameworks/nuxt/index.js +15 -5
- package/lib/frameworks/nuxt2/index.js +5 -4
- package/lib/frameworks/sveltekit/index.js +2 -1
- package/lib/frameworks/utils.js +13 -9
- package/lib/frameworks/vite/index.js +18 -5
- package/lib/functionsShellCommandAction.js +3 -3
- package/lib/gcp/apphosting.js +89 -0
- package/lib/gcp/cloudbuild.js +28 -3
- package/lib/gcp/storage.js +11 -5
- package/lib/hosting/api.js +19 -1
- package/lib/hosting/runTags.js +2 -1
- package/lib/init/features/{frameworks → apphosting}/constants.js +1 -2
- package/lib/init/features/apphosting/index.js +147 -0
- package/lib/init/features/apphosting/repo.js +225 -0
- package/lib/init/features/hosting/index.js +1 -1
- package/lib/init/features/index.js +3 -3
- package/lib/init/index.js +0 -4
- package/lib/localFunction.js +77 -14
- package/lib/utils.js +50 -1
- package/package.json +10 -8
- package/templates/popup.html +64 -0
- package/lib/commands/ext-dev-publish.js +0 -32
- package/lib/gcp/frameworks.js +0 -40
- package/lib/init/features/frameworks/index.js +0 -120
- package/lib/init/features/frameworks/repo.js +0 -132
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBuildConfig = exports.getServerConfig = exports.getBrowserConfig = exports.getContext = exports.getAllTargets = void 0;
|
|
3
|
+
exports.getAngularVersion = exports.getBuildConfig = exports.getServerConfig = exports.getBrowserConfig = exports.getContext = exports.getAllTargets = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const error_1 = require("../../error");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const assert_1 = require("assert");
|
|
8
8
|
const utils_2 = require("../../utils");
|
|
9
|
+
const semver_1 = require("semver");
|
|
9
10
|
async function localesForTarget(dir, architectHost, target, workspaceProject) {
|
|
10
11
|
const { targetStringFromTarget } = (0, utils_1.relativeRequire)(dir, "@angular-devkit/architect");
|
|
11
12
|
const targetOptions = await architectHost.getOptionsForTarget(target);
|
|
@@ -55,6 +56,7 @@ async function localesForTarget(dir, architectHost, target, workspaceProject) {
|
|
|
55
56
|
const DEV_SERVER_TARGETS = [
|
|
56
57
|
"@angular-devkit/build-angular:dev-server",
|
|
57
58
|
"@nguniversal/builders:ssr-dev-server",
|
|
59
|
+
"@angular-devkit/build-angular:ssr-dev-server",
|
|
58
60
|
];
|
|
59
61
|
function getValidBuilders(purpose) {
|
|
60
62
|
return [
|
|
@@ -62,6 +64,7 @@ function getValidBuilders(purpose) {
|
|
|
62
64
|
"@angular-devkit/build-angular:browser-esbuild",
|
|
63
65
|
"@angular/fire:deploy",
|
|
64
66
|
"@angular-devkit/build-angular:browser",
|
|
67
|
+
"@angular-devkit/build-angular:prerender",
|
|
65
68
|
"@nguniversal/builders:prerender",
|
|
66
69
|
...(purpose === "deploy" ? [] : DEV_SERVER_TARGETS),
|
|
67
70
|
];
|
|
@@ -155,11 +158,13 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
155
158
|
case "@angular-devkit/build-angular:browser":
|
|
156
159
|
browserTarget = overrideTarget;
|
|
157
160
|
break;
|
|
161
|
+
case "@angular-devkit/build-angular:prerender":
|
|
158
162
|
case "@nguniversal/builders:prerender":
|
|
159
163
|
prerenderTarget = overrideTarget;
|
|
160
164
|
break;
|
|
161
165
|
case "@angular-devkit/build-angular:dev-server":
|
|
162
166
|
case "@nguniversal/builders:ssr-dev-server":
|
|
167
|
+
case "@angular-devkit/build-angular:ssr-dev-server":
|
|
163
168
|
serveTarget = overrideTarget;
|
|
164
169
|
break;
|
|
165
170
|
default:
|
|
@@ -177,7 +182,9 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
177
182
|
}
|
|
178
183
|
}
|
|
179
184
|
if (deployTarget) {
|
|
180
|
-
const options = await architectHost
|
|
185
|
+
const options = await architectHost
|
|
186
|
+
.getOptionsForTarget(deployTarget)
|
|
187
|
+
.catch(() => workspaceProject.targets.get(deployTarget.target)?.options);
|
|
181
188
|
if (!options)
|
|
182
189
|
throw new error_1.FirebaseError("Unable to get options for ng-deploy.");
|
|
183
190
|
if (options.buildTarget) {
|
|
@@ -196,6 +203,10 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
196
203
|
(0, utils_2.assertIsString)(options.serverTarget);
|
|
197
204
|
serverTarget = targetFromTargetString(options.serverTarget);
|
|
198
205
|
}
|
|
206
|
+
if (options.serveTarget) {
|
|
207
|
+
(0, utils_2.assertIsString)(options.serveTarget);
|
|
208
|
+
serveTarget = targetFromTargetString(options.serveTarget);
|
|
209
|
+
}
|
|
199
210
|
if (options.serveOptimizedImages) {
|
|
200
211
|
serveOptimizedImages = true;
|
|
201
212
|
}
|
|
@@ -298,12 +309,16 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
298
309
|
continue;
|
|
299
310
|
if (target === browserTarget && builder === "@angular-devkit/build-angular:browser")
|
|
300
311
|
continue;
|
|
312
|
+
if (target === prerenderTarget && builder === "@angular-devkit/build-angular:prerender")
|
|
313
|
+
continue;
|
|
301
314
|
if (target === prerenderTarget && builder === "@nguniversal/builders:prerender")
|
|
302
315
|
continue;
|
|
303
316
|
if (target === serverTarget && builder === "@angular-devkit/build-angular:server")
|
|
304
317
|
continue;
|
|
305
318
|
if (target === serveTarget && builder === "@nguniversal/builders:ssr-dev-server")
|
|
306
319
|
continue;
|
|
320
|
+
if (target === serveTarget && builder === "@angular-devkit/build-angular:ssr-dev-server")
|
|
321
|
+
continue;
|
|
307
322
|
if (target === serveTarget && builder === "@angular-devkit/build-angular:dev-server")
|
|
308
323
|
continue;
|
|
309
324
|
throw new error_1.FirebaseError(`${definition.builder} (${targetString}) is not a recognized builder. Please check your angular.json`);
|
|
@@ -359,7 +374,9 @@ async function getServerConfig(sourceDir, configuration) {
|
|
|
359
374
|
}
|
|
360
375
|
const browserTargetOptions = await architectHost.getOptionsForTarget(buildOrBrowserTarget);
|
|
361
376
|
(0, utils_2.assertIsString)(browserTargetOptions?.outputPath);
|
|
362
|
-
const browserOutputPath = (0, path_1.join)(browserTargetOptions.outputPath, buildTarget ? "browser" : "")
|
|
377
|
+
const browserOutputPath = (0, path_1.join)(browserTargetOptions.outputPath, buildTarget ? "browser" : "")
|
|
378
|
+
.split(path_1.sep)
|
|
379
|
+
.join(path_1.posix.sep);
|
|
363
380
|
const packageJson = JSON.parse(await host.readFile((0, path_1.join)(sourceDir, "package.json")));
|
|
364
381
|
if (!ssr) {
|
|
365
382
|
return {
|
|
@@ -382,7 +399,9 @@ async function getServerConfig(sourceDir, configuration) {
|
|
|
382
399
|
const { locales: serverLocales, defaultLocale } = await localesForTarget(sourceDir, architectHost, buildOrServerTarget, workspaceProject);
|
|
383
400
|
const serverTargetOptions = await architectHost.getOptionsForTarget(buildOrServerTarget);
|
|
384
401
|
(0, utils_2.assertIsString)(serverTargetOptions?.outputPath);
|
|
385
|
-
const serverOutputPath = (0, path_1.join)(serverTargetOptions.outputPath, buildTarget ? "server" : "")
|
|
402
|
+
const serverOutputPath = (0, path_1.join)(serverTargetOptions.outputPath, buildTarget ? "server" : "")
|
|
403
|
+
.split(path_1.sep)
|
|
404
|
+
.join(path_1.posix.sep);
|
|
386
405
|
if (serverLocales && !defaultLocale) {
|
|
387
406
|
throw new error_1.FirebaseError("It's required that your source locale to be one of the localize options");
|
|
388
407
|
}
|
|
@@ -427,3 +446,13 @@ async function getBuildConfig(sourceDir, configuration) {
|
|
|
427
446
|
};
|
|
428
447
|
}
|
|
429
448
|
exports.getBuildConfig = getBuildConfig;
|
|
449
|
+
function getAngularVersion(cwd) {
|
|
450
|
+
const dependency = (0, utils_1.findDependency)("@angular/core", { cwd, depth: 0, omitDev: false });
|
|
451
|
+
if (!dependency)
|
|
452
|
+
return undefined;
|
|
453
|
+
const angularVersionSemver = (0, semver_1.coerce)(dependency.version);
|
|
454
|
+
if (!angularVersionSemver)
|
|
455
|
+
return dependency.version;
|
|
456
|
+
return angularVersionSemver.toString();
|
|
457
|
+
}
|
|
458
|
+
exports.getAngularVersion = getAngularVersion;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
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;
|
|
3
|
+
exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.supportedRange = exports.type = exports.support = exports.name = void 0;
|
|
4
4
|
const cross_spawn_1 = require("cross-spawn");
|
|
5
5
|
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -10,15 +10,18 @@ const utils_2 = require("./utils");
|
|
|
10
10
|
exports.name = "Astro";
|
|
11
11
|
exports.support = "experimental";
|
|
12
12
|
exports.type = 2;
|
|
13
|
+
exports.supportedRange = "2 - 3";
|
|
13
14
|
async function discover(dir) {
|
|
14
15
|
if (!(0, fs_extra_1.existsSync)((0, path_1.join)(dir, "package.json")))
|
|
15
16
|
return;
|
|
16
|
-
|
|
17
|
+
const version = (0, utils_2.getAstroVersion)(dir);
|
|
18
|
+
if (!version)
|
|
17
19
|
return;
|
|
18
20
|
const { output, publicDir: publicDirectory } = await (0, utils_2.getConfig)(dir);
|
|
19
21
|
return {
|
|
20
22
|
mayWantBackend: output !== "static",
|
|
21
23
|
publicDirectory,
|
|
24
|
+
version,
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
exports.discover = discover;
|
|
@@ -4,6 +4,7 @@ exports.getAstroVersion = exports.getConfig = exports.getBootstrapScript = void
|
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const semver_1 = require("semver");
|
|
7
|
+
const url_1 = require("url");
|
|
7
8
|
const { dynamicImport } = require(true && "../../dynamicImport");
|
|
8
9
|
function getBootstrapScript() {
|
|
9
10
|
return `const entry = import('./entry.mjs');\nexport const handle = async (req, res) => (await entry).handler(req, res)`;
|
|
@@ -26,8 +27,8 @@ async function getConfig(cwd) {
|
|
|
26
27
|
config = astroConfig;
|
|
27
28
|
}
|
|
28
29
|
return {
|
|
29
|
-
outDir: (0, path_1.relative)(cwd, config.outDir
|
|
30
|
-
publicDir: (0, path_1.relative)(cwd, config.publicDir
|
|
30
|
+
outDir: (0, path_1.relative)(cwd, (0, url_1.fileURLToPath)(config.outDir)),
|
|
31
|
+
publicDir: (0, path_1.relative)(cwd, (0, url_1.fileURLToPath)(config.publicDir)),
|
|
31
32
|
output: config.output,
|
|
32
33
|
adapter: config.adapter,
|
|
33
34
|
};
|
|
@@ -2,32 +2,59 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_SHOULD_USE_DEV_MODE_HANDLE = exports.GET_DEFAULT_BUILD_TARGETS = exports.I18N_ROOT = exports.ALLOWED_SSR_REGIONS = exports.DEFAULT_REGION = exports.VALID_LOCALE_FORMATS = exports.VALID_ENGINES = exports.NODE_VERSION = exports.SHARP_VERSION = exports.FIREBASE_ADMIN_VERSION = exports.FIREBASE_FUNCTIONS_VERSION = exports.FIREBASE_FRAMEWORKS_VERSION = exports.MAILING_LIST_URL = exports.FEATURE_REQUEST_URL = exports.FILE_BUG_URL = exports.DEFAULT_DOCS_URL = exports.SupportLevelWarnings = exports.NPM_COMMAND_TIMEOUT_MILLIES = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
+
const experiments = require("../experiments");
|
|
5
6
|
exports.NPM_COMMAND_TIMEOUT_MILLIES = 10000;
|
|
6
7
|
exports.SupportLevelWarnings = {
|
|
7
8
|
["experimental"]: (framework) => `Thank you for trying our ${clc.italic("experimental")} support for ${framework} on Firebase Hosting.
|
|
8
|
-
${clc.
|
|
9
|
+
${clc.red(`While this integration is maintained by Googlers it is not a supported Firebase product.
|
|
9
10
|
Issues filed on GitHub will be addressed on a best-effort basis by maintainers and other community members.`)}`,
|
|
10
11
|
["preview"]: (framework) => `Thank you for trying our ${clc.italic("early preview")} of ${framework} support on Firebase Hosting.
|
|
11
|
-
${clc.
|
|
12
|
+
${clc.red("During the preview, support is best-effort and breaking changes can be expected. Proceed with caution.")}`,
|
|
12
13
|
};
|
|
13
14
|
exports.DEFAULT_DOCS_URL = "https://firebase.google.com/docs/hosting/frameworks/frameworks-overview";
|
|
14
15
|
exports.FILE_BUG_URL = "https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md";
|
|
15
16
|
exports.FEATURE_REQUEST_URL = "https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md";
|
|
16
17
|
exports.MAILING_LIST_URL = "https://goo.gle/41enW5X";
|
|
17
|
-
|
|
18
|
-
exports.
|
|
19
|
-
|
|
18
|
+
const DEFAULT_FIREBASE_FRAMEWORKS_VERSION = "^0.11.0";
|
|
19
|
+
exports.FIREBASE_FRAMEWORKS_VERSION = (experiments.isEnabled("internaltesting") && process.env.FIREBASE_FRAMEWORKS_VERSION) ||
|
|
20
|
+
DEFAULT_FIREBASE_FRAMEWORKS_VERSION;
|
|
21
|
+
exports.FIREBASE_FUNCTIONS_VERSION = "^4.5.0";
|
|
22
|
+
exports.FIREBASE_ADMIN_VERSION = "^11.11.1";
|
|
20
23
|
exports.SHARP_VERSION = "^0.32.1";
|
|
21
24
|
exports.NODE_VERSION = parseInt(process.versions.node, 10);
|
|
22
25
|
exports.VALID_ENGINES = { node: [16, 18, 20] };
|
|
23
26
|
exports.VALID_LOCALE_FORMATS = [/^ALL_[a-z]+$/, /^[a-z]+_ALL$/, /^[a-z]+(_[a-z]+)?$/];
|
|
24
27
|
exports.DEFAULT_REGION = "us-central1";
|
|
25
28
|
exports.ALLOWED_SSR_REGIONS = [
|
|
26
|
-
{ name: "us-central1 (Iowa)", value: "us-central1" },
|
|
27
|
-
{ name: "us-
|
|
28
|
-
{ name: "us-
|
|
29
|
-
{ name: "
|
|
30
|
-
{ name: "
|
|
29
|
+
{ name: "us-central1 (Iowa)", value: "us-central1", recommended: true },
|
|
30
|
+
{ name: "us-east1 (South Carolina)", value: "us-east1", recommended: true },
|
|
31
|
+
{ name: "us-east4 (Northern Virginia)", value: "us-east4" },
|
|
32
|
+
{ name: "us-west1 (Oregon)", value: "us-west1", recommended: true },
|
|
33
|
+
{ name: "us-west2 (Los Angeles)", value: "us-west2" },
|
|
34
|
+
{ name: "us-west3 (Salt Lake City)", value: "us-west3" },
|
|
35
|
+
{ name: "us-west4 (Las Vegas)", value: "us-west4" },
|
|
36
|
+
{ name: "asia-east1 (Taiwan)", value: "asia-east1", recommended: true },
|
|
37
|
+
{ name: "asia-east2 (Hong Kong)", value: "asia-east2" },
|
|
38
|
+
{ name: "asia-northeast1 (Tokyo)", value: "asia-northeast1" },
|
|
39
|
+
{ name: "asia-northeast2 (Osaka)", value: "asia-northeast2" },
|
|
40
|
+
{ name: "asia-northeast3 (Seoul)", value: "asia-northeast3" },
|
|
41
|
+
{ name: "asia-south1 (Mumbai)", value: "asia-south1" },
|
|
42
|
+
{ name: "asia-south2 (Delhi)", value: "asia-south2" },
|
|
43
|
+
{ name: "asia-southeast1 (Singapore)", value: "asia-southeast1" },
|
|
44
|
+
{ name: "asia-southeast2 (Jakarta)", value: "asia-southeast2" },
|
|
45
|
+
{ name: "australia-southeast1 (Sydney)", value: "australia-southeast1" },
|
|
46
|
+
{ name: "australia-southeast2 (Melbourne)", value: "australia-southeast2" },
|
|
47
|
+
{ name: "europe-central2 (Warsaw)", value: "europe-central2" },
|
|
48
|
+
{ name: "europe-north1 (Finland)", value: "europe-north1" },
|
|
49
|
+
{ name: "europe-west1 (Belgium)", value: "europe-west1", recommended: true },
|
|
50
|
+
{ name: "europe-west2 (London)", value: "europe-west2" },
|
|
51
|
+
{ name: "europe-west3 (Frankfurt)", value: "europe-west3" },
|
|
52
|
+
{ name: "europe-west4 (Netherlands)", value: "europe-west4" },
|
|
53
|
+
{ name: "europe-west6 (Zurich)", value: "europe-west6" },
|
|
54
|
+
{ name: "northamerica-northeast1 (Montreal)", value: "northamerica-northeast1" },
|
|
55
|
+
{ name: "northamerica-northeast2 (Toronto)", value: "northamerica-northeast2" },
|
|
56
|
+
{ name: "southamerica-east1 (São Paulo)", value: "southamerica-east1" },
|
|
57
|
+
{ name: "southamerica-west1 (Santiago)", value: "southamerica-west1" },
|
|
31
58
|
];
|
|
32
59
|
exports.I18N_ROOT = "/";
|
|
33
60
|
function GET_DEFAULT_BUILD_TARGETS() {
|
package/lib/frameworks/index.js
CHANGED
|
@@ -62,14 +62,14 @@ async function discover(dir, warn = true) {
|
|
|
62
62
|
}
|
|
63
63
|
exports.discover = discover;
|
|
64
64
|
const BUILD_MEMO = new Map();
|
|
65
|
-
function memoizeBuild(dir, build, deps, target) {
|
|
65
|
+
function memoizeBuild(dir, build, deps, target, context) {
|
|
66
66
|
const key = [dir, ...deps];
|
|
67
67
|
for (const existingKey of BUILD_MEMO.keys()) {
|
|
68
68
|
if ((0, util_1.isDeepStrictEqual)(existingKey, key)) {
|
|
69
69
|
return BUILD_MEMO.get(existingKey);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
const value = build(dir, target);
|
|
72
|
+
const value = build(dir, target, context);
|
|
73
73
|
BUILD_MEMO.set(key, value);
|
|
74
74
|
return value;
|
|
75
75
|
}
|
|
@@ -118,7 +118,7 @@ async function prepareFrameworks(purpose, targetNames, context, options, emulato
|
|
|
118
118
|
throw new error_1.FirebaseError(`Hosting config for site ${site} places server-side content in region ${ssrRegion} which is not known. Valid regions are ${validRegions}`);
|
|
119
119
|
}
|
|
120
120
|
const getProjectPath = (...args) => (0, path_1.join)(projectRoot, source, ...args);
|
|
121
|
-
const functionId = `ssr${site.toLowerCase().replace(/-/g, "")}`;
|
|
121
|
+
const functionId = `ssr${site.toLowerCase().replace(/-/g, "").substring(0, 20)}`;
|
|
122
122
|
const usesFirebaseAdminSdk = !!(0, utils_1.findDependency)("firebase-admin", { cwd: getProjectPath() });
|
|
123
123
|
const usesFirebaseJsSdk = !!(0, utils_1.findDependency)("@firebase/app", { cwd: getProjectPath() });
|
|
124
124
|
if (usesFirebaseAdminSdk) {
|
|
@@ -189,13 +189,18 @@ async function prepareFrameworks(purpose, targetNames, context, options, emulato
|
|
|
189
189
|
throw new error_1.FirebaseError((0, utils_1.frameworksCallToAction)("Unable to detect the web framework in use, check firebase-debug.log for more info."));
|
|
190
190
|
}
|
|
191
191
|
const { framework, mayWantBackend, publicDirectory } = results;
|
|
192
|
-
const { build, ɵcodegenPublicDirectory, ɵcodegenFunctionsDirectory: codegenProdModeFunctionsDirectory, getDevModeHandle, name, support, docsUrl, getValidBuildTargets = constants_2.GET_DEFAULT_BUILD_TARGETS, shouldUseDevModeHandle = constants_2.DEFAULT_SHOULD_USE_DEV_MODE_HANDLE, } = frameworks_1.WebFrameworks[framework];
|
|
193
|
-
logger_1.logger.info(`\n${(0, utils_1.frameworksCallToAction)(constants_2.SupportLevelWarnings[support](name), docsUrl, " ")}\n`);
|
|
192
|
+
const { build, ɵcodegenPublicDirectory, ɵcodegenFunctionsDirectory: codegenProdModeFunctionsDirectory, getDevModeHandle, name, support, docsUrl, supportedRange, getValidBuildTargets = constants_2.GET_DEFAULT_BUILD_TARGETS, shouldUseDevModeHandle = constants_2.DEFAULT_SHOULD_USE_DEV_MODE_HANDLE, } = frameworks_1.WebFrameworks[framework];
|
|
193
|
+
logger_1.logger.info(`\n${(0, utils_1.frameworksCallToAction)(constants_2.SupportLevelWarnings[support](name), docsUrl, " ", name, results.version, supportedRange, results.vite)}\n`);
|
|
194
194
|
const hostingEmulatorInfo = emulators.find((e) => e.name === types_1.Emulators.HOSTING);
|
|
195
195
|
const validBuildTargets = await getValidBuildTargets(purpose, getProjectPath());
|
|
196
196
|
const frameworksBuildTarget = (0, utils_1.getFrameworksBuildTarget)(purpose, validBuildTargets);
|
|
197
197
|
const useDevModeHandle = purpose !== "deploy" &&
|
|
198
198
|
(await shouldUseDevModeHandle(frameworksBuildTarget, getProjectPath()));
|
|
199
|
+
const frameworkContext = {
|
|
200
|
+
projectId: project,
|
|
201
|
+
site: options.site,
|
|
202
|
+
hostingChannel: context?.hostingChannel,
|
|
203
|
+
};
|
|
199
204
|
let codegenFunctionsDirectory;
|
|
200
205
|
let baseUrl = "";
|
|
201
206
|
const rewrites = [];
|
|
@@ -212,7 +217,7 @@ async function prepareFrameworks(purpose, targetNames, context, options, emulato
|
|
|
212
217
|
}
|
|
213
218
|
}
|
|
214
219
|
else {
|
|
215
|
-
const buildResult = await memoizeBuild(getProjectPath(), build, [firebaseDefaults, frameworksBuildTarget], frameworksBuildTarget);
|
|
220
|
+
const buildResult = await memoizeBuild(getProjectPath(), build, [firebaseDefaults, frameworksBuildTarget], frameworksBuildTarget, frameworkContext);
|
|
216
221
|
const { wantsBackend = false, trailingSlash, i18n = false } = buildResult || {};
|
|
217
222
|
if (buildResult) {
|
|
218
223
|
baseUrl = buildResult.baseUrl ?? baseUrl;
|
|
@@ -281,7 +286,7 @@ async function prepareFrameworks(purpose, targetNames, context, options, emulato
|
|
|
281
286
|
else {
|
|
282
287
|
await (0, fs_extra_1.mkdirp)(functionsDist);
|
|
283
288
|
}
|
|
284
|
-
const { packageJson, bootstrapScript, frameworksEntry = framework, dotEnv = {}, rewriteSource, } = await codegenFunctionsDirectory(getProjectPath(), functionsDist, frameworksBuildTarget);
|
|
289
|
+
const { packageJson, bootstrapScript, frameworksEntry = framework, dotEnv = {}, rewriteSource, } = await codegenFunctionsDirectory(getProjectPath(), functionsDist, frameworksBuildTarget, frameworkContext);
|
|
285
290
|
const rewrite = {
|
|
286
291
|
source: rewriteSource || path_1.posix.join(baseUrl, "**"),
|
|
287
292
|
function: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.init = exports.build = exports.discover = exports.docsUrl = exports.type = exports.support = exports.name = void 0;
|
|
3
|
+
exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.init = exports.build = exports.discover = exports.docsUrl = exports.type = exports.support = exports.name = exports.supportedRange = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const cross_spawn_1 = require("cross-spawn");
|
|
6
6
|
const promises_1 = require("fs/promises");
|
|
@@ -25,6 +25,7 @@ const api_1 = require("../../hosting/api");
|
|
|
25
25
|
const logger_1 = require("../../logger");
|
|
26
26
|
const DEFAULT_BUILD_SCRIPT = ["next build"];
|
|
27
27
|
const PUBLIC_DIR = "public";
|
|
28
|
+
exports.supportedRange = "12 - 14.0";
|
|
28
29
|
exports.name = "Next.js";
|
|
29
30
|
exports.support = "preview";
|
|
30
31
|
exports.type = 2;
|
|
@@ -37,20 +38,28 @@ function getReactVersion(cwd) {
|
|
|
37
38
|
async function discover(dir) {
|
|
38
39
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
39
40
|
return;
|
|
40
|
-
|
|
41
|
+
const version = (0, utils_2.getNextVersion)(dir);
|
|
42
|
+
if (!(await (0, fs_extra_1.pathExists)("next.config.js")) && !version)
|
|
41
43
|
return;
|
|
42
|
-
return { mayWantBackend: true, publicDirectory: (0, path_1.join)(dir, PUBLIC_DIR) };
|
|
44
|
+
return { mayWantBackend: true, publicDirectory: (0, path_1.join)(dir, PUBLIC_DIR), version };
|
|
43
45
|
}
|
|
44
46
|
exports.discover = discover;
|
|
45
|
-
async function build(dir) {
|
|
47
|
+
async function build(dir, target, context) {
|
|
46
48
|
await (0, utils_1.warnIfCustomBuildScript)(dir, exports.name, DEFAULT_BUILD_SCRIPT);
|
|
47
49
|
const reactVersion = getReactVersion(dir);
|
|
48
50
|
if (reactVersion && (0, semver_1.gte)(reactVersion, "18.0.0")) {
|
|
49
51
|
process.env.__NEXT_REACT_ROOT = "true";
|
|
50
52
|
}
|
|
53
|
+
const env = { ...process.env };
|
|
54
|
+
if (context?.projectId && context?.site) {
|
|
55
|
+
const deploymentDomain = await (0, api_1.getDeploymentDomain)(context.projectId, context.site, context.hostingChannel);
|
|
56
|
+
if (deploymentDomain) {
|
|
57
|
+
env["VERCEL_URL"] = deploymentDomain;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
51
60
|
const cli = (0, utils_1.getNodeModuleBin)("next", dir);
|
|
52
61
|
const nextBuild = new Promise((resolve, reject) => {
|
|
53
|
-
const buildProcess = (0, cross_spawn_1.spawn)(cli, ["build"], { cwd: dir });
|
|
62
|
+
const buildProcess = (0, cross_spawn_1.spawn)(cli, ["build"], { cwd: dir, env });
|
|
54
63
|
buildProcess.stdout?.on("data", (data) => logger_1.logger.info(data.toString()));
|
|
55
64
|
buildProcess.stderr?.on("data", (data) => logger_1.logger.info(data.toString()));
|
|
56
65
|
buildProcess.on("error", (err) => {
|
|
@@ -111,6 +120,10 @@ async function build(dir) {
|
|
|
111
120
|
headers.push(...headersFromMetaFiles);
|
|
112
121
|
if (appPathsManifest) {
|
|
113
122
|
const unrenderedServerComponents = (0, utils_2.getNonStaticServerComponents)(appPathsManifest, appPathRoutesManifest, prerenderedRoutes, dynamicRoutes);
|
|
123
|
+
if (unrenderedServerComponents.has("/_not-found") &&
|
|
124
|
+
(await (0, utils_2.hasStaticAppNotFoundComponent)(dir, distDir))) {
|
|
125
|
+
unrenderedServerComponents.delete("/_not-found");
|
|
126
|
+
}
|
|
114
127
|
for (const key of unrenderedServerComponents) {
|
|
115
128
|
reasonsForBackend.add(`non-static component ${key}`);
|
|
116
129
|
}
|
|
@@ -179,7 +192,7 @@ async function init(setup, config) {
|
|
|
179
192
|
message: "What language would you like to use?",
|
|
180
193
|
choices: ["JavaScript", "TypeScript"],
|
|
181
194
|
});
|
|
182
|
-
(0, child_process_1.execSync)(`npx --yes create-next-app@
|
|
195
|
+
(0, child_process_1.execSync)(`npx --yes create-next-app@"${exports.supportedRange}" -e hello-world ${setup.hosting.source} --use-npm ${language === "TypeScript" ? "--ts" : "--js"}`, { stdio: "inherit", cwd: config.projectDir });
|
|
183
196
|
}
|
|
184
197
|
exports.init = init;
|
|
185
198
|
async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
|
|
@@ -297,7 +310,7 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
|
|
|
297
310
|
}));
|
|
298
311
|
}
|
|
299
312
|
exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
|
|
300
|
-
async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
|
|
313
|
+
async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context) {
|
|
301
314
|
const { distDir } = await getConfig(sourceDir);
|
|
302
315
|
const packageJson = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, "package.json"));
|
|
303
316
|
if ((0, fs_1.existsSync)((0, path_1.join)(sourceDir, "next.config.js"))) {
|
|
@@ -347,9 +360,16 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
|
|
|
347
360
|
if (await (0, utils_2.isUsingImageOptimization)(sourceDir, distDir)) {
|
|
348
361
|
packageJson.dependencies["sharp"] = constants_1.SHARP_VERSION;
|
|
349
362
|
}
|
|
363
|
+
const dotEnv = {};
|
|
364
|
+
if (context?.projectId && context?.site) {
|
|
365
|
+
const deploymentDomain = await (0, api_1.getDeploymentDomain)(context.projectId, context.site, context.hostingChannel);
|
|
366
|
+
if (deploymentDomain) {
|
|
367
|
+
dotEnv["VERCEL_URL"] = deploymentDomain;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
350
370
|
await (0, fs_extra_1.mkdirp)((0, path_1.join)(destDir, distDir));
|
|
351
371
|
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir), (0, path_1.join)(destDir, distDir));
|
|
352
|
-
return { packageJson, frameworksEntry: "next.js" };
|
|
372
|
+
return { packageJson, frameworksEntry: "next.js", dotEnv };
|
|
353
373
|
}
|
|
354
374
|
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
355
375
|
async function getDevModeHandle(dir, _, hostingEmulatorInfo) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNextVersion = exports.getBuildId = exports.getHeadersFromMetaFiles = exports.getNonStaticServerComponents = exports.getNonStaticRoutes = exports.getMiddlewareMatcherRegexes = exports.allDependencyNames = exports.isUsingAppDirectory = exports.isUsingNextImageInAppDirectory = exports.isUsingImageOptimization = exports.isUsingMiddleware = exports.hasUnoptimizedImage = exports.usesNextImage = exports.usesAppDirRouter = exports.getNextjsRewritesToUse = exports.isHeaderSupportedByHosting = exports.isRedirectSupportedByHosting = exports.isRewriteSupportedByHosting = exports.cleanI18n = exports.cleanCustomRouteI18n = exports.cleanEscapedChars = exports.I18N_SOURCE = void 0;
|
|
3
|
+
exports.hasStaticAppNotFoundComponent = exports.getNextVersion = exports.getBuildId = exports.getHeadersFromMetaFiles = exports.getNonStaticServerComponents = exports.getNonStaticRoutes = exports.getMiddlewareMatcherRegexes = exports.allDependencyNames = exports.isUsingAppDirectory = exports.isUsingNextImageInAppDirectory = exports.isUsingImageOptimization = exports.isUsingMiddleware = exports.hasUnoptimizedImage = exports.usesNextImage = exports.usesAppDirRouter = exports.getNextjsRewritesToUse = exports.isHeaderSupportedByHosting = exports.isRedirectSupportedByHosting = exports.isRewriteSupportedByHosting = exports.cleanI18n = exports.cleanCustomRouteI18n = exports.cleanEscapedChars = exports.I18N_SOURCE = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -159,13 +159,13 @@ function getNonStaticServerComponents(appPathsManifest, appPathRoutesManifest, p
|
|
|
159
159
|
return !(prerenderedRoutes.includes(path) || dynamicRoutes.includes(path));
|
|
160
160
|
})
|
|
161
161
|
.map(([it]) => it);
|
|
162
|
-
return nonStaticServerComponents;
|
|
162
|
+
return new Set(nonStaticServerComponents);
|
|
163
163
|
}
|
|
164
164
|
exports.getNonStaticServerComponents = getNonStaticServerComponents;
|
|
165
165
|
async function getHeadersFromMetaFiles(sourceDir, distDir, basePath, appPathRoutesManifest) {
|
|
166
166
|
const headers = [];
|
|
167
167
|
await Promise.all(Object.entries(appPathRoutesManifest).map(async ([key, source]) => {
|
|
168
|
-
if ((0, path_1.basename)(key)
|
|
168
|
+
if (!["route", "page"].includes((0, path_1.basename)(key)))
|
|
169
169
|
return;
|
|
170
170
|
const parts = source.split("/").filter((it) => !!it);
|
|
171
171
|
const partsOrIndex = parts.length > 0 ? parts : ["index"];
|
|
@@ -198,3 +198,7 @@ function getNextVersion(cwd) {
|
|
|
198
198
|
return nextVersionSemver.toString();
|
|
199
199
|
}
|
|
200
200
|
exports.getNextVersion = getNextVersion;
|
|
201
|
+
async function hasStaticAppNotFoundComponent(sourceDir, distDir) {
|
|
202
|
+
return (0, fs_extra_1.pathExists)((0, path_1.join)(sourceDir, distDir, "server", "app", "_not-found.html"));
|
|
203
|
+
}
|
|
204
|
+
exports.hasStaticAppNotFoundComponent = hasStaticAppNotFoundComponent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConfig = exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.type = exports.support = exports.name = void 0;
|
|
3
|
+
exports.init = exports.getConfig = exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.supportedRange = 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");
|
|
@@ -11,20 +11,22 @@ const utils_2 = require("./utils");
|
|
|
11
11
|
exports.name = "Nuxt";
|
|
12
12
|
exports.support = "experimental";
|
|
13
13
|
exports.type = 4;
|
|
14
|
+
exports.supportedRange = "3";
|
|
14
15
|
const utils_3 = require("./utils");
|
|
15
16
|
const error_1 = require("../../error");
|
|
17
|
+
const child_process_1 = require("child_process");
|
|
16
18
|
const DEFAULT_BUILD_SCRIPT = ["nuxt build", "nuxi build"];
|
|
17
19
|
async function discover(dir) {
|
|
18
20
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
19
21
|
return;
|
|
20
22
|
const anyConfigFileExists = await (0, utils_3.nuxtConfigFilesExist)(dir);
|
|
21
|
-
const
|
|
22
|
-
if (!anyConfigFileExists && !
|
|
23
|
+
const version = (0, utils_2.getNuxtVersion)(dir);
|
|
24
|
+
if (!anyConfigFileExists && !version)
|
|
23
25
|
return;
|
|
24
|
-
if (
|
|
26
|
+
if (version && (0, semver_1.lt)(version, "3.0.0-0"))
|
|
25
27
|
return;
|
|
26
28
|
const { dir: { public: publicDirectory }, ssr: mayWantBackend, } = await getConfig(dir);
|
|
27
|
-
return { publicDirectory, mayWantBackend };
|
|
29
|
+
return { publicDirectory, mayWantBackend, version };
|
|
28
30
|
}
|
|
29
31
|
exports.discover = discover;
|
|
30
32
|
async function build(cwd) {
|
|
@@ -90,3 +92,11 @@ async function getConfig(dir) {
|
|
|
90
92
|
return await loadNuxtConfig(dir);
|
|
91
93
|
}
|
|
92
94
|
exports.getConfig = getConfig;
|
|
95
|
+
function init(setup, config) {
|
|
96
|
+
(0, child_process_1.execSync)(`npx --yes nuxi@"${exports.supportedRange}" init ${setup.hosting.source}`, {
|
|
97
|
+
stdio: "inherit",
|
|
98
|
+
cwd: config.projectDir,
|
|
99
|
+
});
|
|
100
|
+
return Promise.resolve();
|
|
101
|
+
}
|
|
102
|
+
exports.init = init;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
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;
|
|
3
|
+
exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.supportedRange = 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");
|
|
@@ -12,6 +12,7 @@ const cross_spawn_1 = require("cross-spawn");
|
|
|
12
12
|
exports.name = "Nuxt";
|
|
13
13
|
exports.support = "experimental";
|
|
14
14
|
exports.type = 2;
|
|
15
|
+
exports.supportedRange = "2";
|
|
15
16
|
async function getAndLoadNuxt(options) {
|
|
16
17
|
const nuxt = await (0, utils_1.relativeRequire)(options.rootDir, "nuxt/dist/nuxt.js");
|
|
17
18
|
const app = await nuxt.loadNuxt(options);
|
|
@@ -21,11 +22,11 @@ async function getAndLoadNuxt(options) {
|
|
|
21
22
|
async function discover(rootDir) {
|
|
22
23
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(rootDir, "package.json"))))
|
|
23
24
|
return;
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
25
|
+
const version = (0, utils_2.getNuxtVersion)(rootDir);
|
|
26
|
+
if (!version || (version && (0, semver_1.gte)(version, "3.0.0-0")))
|
|
26
27
|
return;
|
|
27
28
|
const { app } = await getAndLoadNuxt({ rootDir, for: "build" });
|
|
28
|
-
return { mayWantBackend: true, publicDirectory: app.options.dir.static };
|
|
29
|
+
return { mayWantBackend: true, publicDirectory: app.options.dir.static, version };
|
|
29
30
|
}
|
|
30
31
|
exports.discover = discover;
|
|
31
32
|
async function build(rootDir) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
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;
|
|
3
|
+
exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.supportedRange = exports.getDevModeHandle = exports.discover = exports.type = exports.support = exports.name = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const vite_1 = require("../vite");
|
|
@@ -12,6 +12,7 @@ exports.type = 2;
|
|
|
12
12
|
exports.discover = (0, vite_1.viteDiscoverWithNpmDependency)("@sveltejs/kit");
|
|
13
13
|
var vite_2 = require("../vite");
|
|
14
14
|
Object.defineProperty(exports, "getDevModeHandle", { enumerable: true, get: function () { return vite_2.getDevModeHandle; } });
|
|
15
|
+
Object.defineProperty(exports, "supportedRange", { enumerable: true, get: function () { return vite_2.supportedRange; } });
|
|
15
16
|
async function build(root) {
|
|
16
17
|
const config = await getConfig(root);
|
|
17
18
|
const wantsBackend = config.kit.adapter?.name !== "@sveltejs/adapter-static";
|
package/lib/frameworks/utils.js
CHANGED
|
@@ -7,6 +7,7 @@ const promises_1 = require("fs/promises");
|
|
|
7
7
|
const http_1 = require("http");
|
|
8
8
|
const cross_spawn_1 = require("cross-spawn");
|
|
9
9
|
const clc = require("colorette");
|
|
10
|
+
const semver_1 = require("semver");
|
|
10
11
|
const logger_1 = require("../logger");
|
|
11
12
|
const error_1 = require("../error");
|
|
12
13
|
const fsutils_1 = require("../fsutils");
|
|
@@ -209,20 +210,23 @@ function relativeRequire(dir, mod) {
|
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
exports.relativeRequire = relativeRequire;
|
|
212
|
-
function conjoinOptions(
|
|
213
|
-
if (!
|
|
214
|
-
return;
|
|
213
|
+
function conjoinOptions(_opts, conjunction = "and", separator = ",") {
|
|
214
|
+
if (!_opts.length)
|
|
215
|
+
return "";
|
|
216
|
+
const opts = _opts.map((it) => it.toString().trim());
|
|
215
217
|
if (opts.length === 1)
|
|
216
|
-
return opts[0]
|
|
218
|
+
return opts[0];
|
|
217
219
|
if (opts.length === 2)
|
|
218
|
-
return `${opts[0]
|
|
219
|
-
const lastElement = opts.slice(-1)[0]
|
|
220
|
-
const allButLast = opts.slice(0, -1)
|
|
220
|
+
return `${opts[0]} ${conjunction} ${opts[1]}`;
|
|
221
|
+
const lastElement = opts.slice(-1)[0];
|
|
222
|
+
const allButLast = opts.slice(0, -1);
|
|
221
223
|
return `${allButLast.join(`${separator} `)}${separator} ${conjunction} ${lastElement}`;
|
|
222
224
|
}
|
|
223
225
|
exports.conjoinOptions = conjoinOptions;
|
|
224
|
-
function frameworksCallToAction(message, docsUrl = constants_1.DEFAULT_DOCS_URL, prefix = "") {
|
|
225
|
-
return `${prefix}${message}
|
|
226
|
+
function frameworksCallToAction(message, docsUrl = constants_1.DEFAULT_DOCS_URL, prefix = "", framework, version, supportedRange, vite = false) {
|
|
227
|
+
return `${prefix}${message}${framework && supportedRange && (!version || !(0, semver_1.satisfies)(version, supportedRange))
|
|
228
|
+
? clc.yellow(`\n${prefix}The integration is known to work with ${vite ? "Vite" : framework} version ${clc.italic(conjoinOptions(supportedRange.split("||")))}. You may encounter errors.`)
|
|
229
|
+
: ``}
|
|
226
230
|
|
|
227
231
|
${prefix}${clc.bold("Documentation:")} ${docsUrl}
|
|
228
232
|
${prefix}${clc.bold("File a bug:")} ${constants_1.FILE_BUG_URL}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDevModeHandle = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.vitePluginDiscover = exports.viteDiscoverWithNpmDependency = exports.init = exports.initViteTemplate = exports.DEFAULT_BUILD_SCRIPT = exports.type = exports.support = exports.name = void 0;
|
|
3
|
+
exports.getDevModeHandle = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.vitePluginDiscover = exports.viteDiscoverWithNpmDependency = exports.init = exports.initViteTemplate = exports.DEFAULT_BUILD_SCRIPT = exports.supportedRange = exports.type = exports.support = exports.name = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const cross_spawn_1 = require("cross-spawn");
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const fs_extra_1 = require("fs-extra");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
+
const stripAnsi = require("strip-ansi");
|
|
9
10
|
const prompt_1 = require("../../prompt");
|
|
10
11
|
const utils_1 = require("../utils");
|
|
11
12
|
exports.name = "Vite";
|
|
12
13
|
exports.support = "experimental";
|
|
13
14
|
exports.type = 4;
|
|
15
|
+
exports.supportedRange = "3 - 5";
|
|
14
16
|
exports.DEFAULT_BUILD_SCRIPT = ["vite build", "tsc && vite build"];
|
|
15
17
|
const initViteTemplate = (template) => async (setup, config) => await init(setup, config, template);
|
|
16
18
|
exports.initViteTemplate = initViteTemplate;
|
|
@@ -24,7 +26,7 @@ async function init(setup, config, baseTemplate = "vanilla") {
|
|
|
24
26
|
{ name: "TypeScript", value: `${baseTemplate}-ts` },
|
|
25
27
|
],
|
|
26
28
|
});
|
|
27
|
-
(0, child_process_1.execSync)(`npm create vite@
|
|
29
|
+
(0, child_process_1.execSync)(`npm create vite@"${exports.supportedRange}" ${setup.hosting.source} --yes -- --template ${template}`, {
|
|
28
30
|
stdio: "inherit",
|
|
29
31
|
cwd: config.projectDir,
|
|
30
32
|
});
|
|
@@ -45,14 +47,24 @@ async function discover(dir, plugin, npmDependency) {
|
|
|
45
47
|
(0, fs_extra_1.pathExists)((0, path_1.join)(dir, "vite.config.ts")),
|
|
46
48
|
]);
|
|
47
49
|
const anyConfigFileExists = configFilesExist.some((it) => it);
|
|
48
|
-
|
|
50
|
+
const version = (0, utils_1.findDependency)("vite", {
|
|
51
|
+
cwd: dir,
|
|
52
|
+
depth,
|
|
53
|
+
omitDev: false,
|
|
54
|
+
})?.version;
|
|
55
|
+
if (!anyConfigFileExists && !version)
|
|
49
56
|
return;
|
|
50
57
|
if (npmDependency && !additionalDep)
|
|
51
58
|
return;
|
|
52
59
|
const { appType, publicDir: publicDirectory, plugins } = await getConfig(dir);
|
|
53
60
|
if (plugin && !plugins.find(({ name }) => name === plugin))
|
|
54
61
|
return;
|
|
55
|
-
return {
|
|
62
|
+
return {
|
|
63
|
+
mayWantBackend: appType !== "spa",
|
|
64
|
+
publicDirectory,
|
|
65
|
+
version,
|
|
66
|
+
vite: true,
|
|
67
|
+
};
|
|
56
68
|
}
|
|
57
69
|
exports.discover = discover;
|
|
58
70
|
async function build(root) {
|
|
@@ -77,7 +89,8 @@ async function getDevModeHandle(dir) {
|
|
|
77
89
|
const serve = (0, cross_spawn_1.spawn)(cli, [], { cwd: dir });
|
|
78
90
|
serve.stdout.on("data", (data) => {
|
|
79
91
|
process.stdout.write(data);
|
|
80
|
-
const
|
|
92
|
+
const dataWithoutAnsiCodes = stripAnsi(data.toString());
|
|
93
|
+
const match = dataWithoutAnsiCodes.match(/(http:\/\/.+:\d+)/);
|
|
81
94
|
if (match)
|
|
82
95
|
resolve(match[1]);
|
|
83
96
|
});
|