@wasp.sh/wasp-cli-darwin-arm64-unknown 0.21.1 → 0.22.0-rc1
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/data/Cli/starters/skeleton/gitignore +11 -0
- package/data/Cli/starters/ts-minimal/main.wasp.ts +15 -0
- package/data/Cli/starters/ts-minimal/package.json +18 -0
- package/data/Cli/starters/ts-minimal/schema.prisma +10 -0
- package/data/Cli/starters/ts-minimal/src/Main.css +103 -0
- package/data/Cli/starters/ts-minimal/src/MainPage.tsx +37 -0
- package/data/Cli/starters/ts-minimal/src/assets/logo.svg +1 -0
- package/data/Cli/starters/ts-minimal/tsconfig.json +7 -0
- package/data/Cli/starters/ts-minimal/tsconfig.src.json +28 -0
- package/data/Cli/starters/ts-minimal/tsconfig.wasp.json +15 -0
- package/data/Cli/starters/ts-minimal/vite.config.ts +9 -0
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.22.0.tgz +0 -0
- package/data/Generator/templates/Dockerfile +5 -3
- package/data/Generator/templates/sdk/wasp/client/app/components/WaspApp.tsx +7 -1
- package/data/Generator/templates/sdk/wasp/client/app/router/router.tsx +3 -2
- package/data/Generator/templates/sdk/wasp/client/env/schema.ts +28 -11
- package/data/Generator/templates/sdk/wasp/client/env.ts +6 -3
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/validateEnv.ts +25 -26
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/waspConfig.ts +57 -11
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/routes.tsx +26 -7
- package/data/Generator/templates/sdk/wasp/env/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/env/validation.ts +28 -22
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/dummy.ts +23 -25
- package/data/Generator/templates/sdk/wasp/server/env.ts +72 -67
- package/data/Generator/templates/sdk/wasp/universal/ansiColors.ts +55 -11
- package/data/packages/deploy/dist/providers/fly/flyCli.js +1 -4
- package/data/packages/deploy/dist/providers/fly/jsonOutputSchemas.js +6 -2
- package/data/packages/deploy/dist/providers/fly/tomlFile.js +8 -2
- package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +1 -12
- package/data/packages/deploy/dist/providers/railway/env.js +13 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/url.js +1 -1
- package/data/packages/deploy/package-lock.json +2268 -15
- package/data/packages/deploy/package.json +6 -3
- package/data/packages/ts-inspect/dist/exports.js +1 -1
- package/data/packages/ts-inspect/package-lock.json +8 -7
- package/data/packages/ts-inspect/package.json +1 -1
- package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.js +13 -0
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.js +1 -0
- package/data/packages/wasp-config/dist/__tests__/testFixtures.d.ts.map +1 -1
- package/data/packages/wasp-config/dist/__tests__/testFixtures.js +1 -0
- package/data/packages/wasp-config/dist/src/appAnalyzer.js +1 -1
- package/data/packages/wasp-config/dist/src/appSpec.d.ts +1 -0
- package/data/packages/wasp-config/dist/src/appSpec.d.ts.map +1 -1
- package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.d.ts.map +1 -1
- package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.js +2 -1
- package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts +1 -0
- package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts.map +1 -1
- package/data/packages/wasp-config/package.json +5 -4
- package/package.json +1 -1
- package/wasp-bin +0 -0
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.21.1.tgz +0 -0
|
@@ -1,38 +1,44 @@
|
|
|
1
|
-
import * as z from
|
|
1
|
+
import * as z from "zod";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const redColorFormatString = getColorizedConsoleFormatString('red');
|
|
3
|
+
import { colorize } from "wasp/universal/ansiColors";
|
|
6
4
|
|
|
7
5
|
// PRIVATE API (SDK)
|
|
8
|
-
export function ensureEnvSchema<Schema extends z.
|
|
6
|
+
export function ensureEnvSchema<Schema extends z.ZodType>(
|
|
9
7
|
data: unknown,
|
|
10
|
-
schema: Schema
|
|
8
|
+
schema: Schema,
|
|
11
9
|
): z.infer<Schema> {
|
|
12
|
-
const result = getValidatedEnvOrError(data, schema)
|
|
10
|
+
const result = getValidatedEnvOrError(data, schema);
|
|
13
11
|
if (result.success) {
|
|
14
|
-
return result.data
|
|
12
|
+
return result.data;
|
|
15
13
|
} else {
|
|
16
|
-
console.error(
|
|
17
|
-
throw new Error(
|
|
14
|
+
console.error(colorize("red", formatZodEnvError(result.error)));
|
|
15
|
+
throw new Error("Error parsing environment variables");
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
// PRIVATE API (SDK, Vite config)
|
|
22
|
-
export function getValidatedEnvOrError<Schema extends z.
|
|
20
|
+
export function getValidatedEnvOrError<Schema extends z.ZodType>(
|
|
23
21
|
env: unknown,
|
|
24
|
-
schema: Schema
|
|
25
|
-
): z.
|
|
26
|
-
return schema.safeParse(env)
|
|
22
|
+
schema: Schema,
|
|
23
|
+
): z.ZodSafeParseResult<z.infer<Schema>> {
|
|
24
|
+
return schema.safeParse(env);
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
// PRIVATE API (SDK, Vite config)
|
|
30
|
-
export function
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
export function formatZodEnvError(error: z.ZodError): string {
|
|
29
|
+
const flattenedIssues = z.flattenError(error);
|
|
30
|
+
|
|
31
|
+
return [
|
|
32
|
+
"══ Env vars validation failed ══",
|
|
33
|
+
"",
|
|
34
|
+
// Top-level errors
|
|
35
|
+
...flattenedIssues.formErrors,
|
|
36
|
+
"",
|
|
37
|
+
// Errors per field
|
|
38
|
+
...Object.entries(flattenedIssues.fieldErrors).map(
|
|
39
|
+
([prop, error]) => `${prop} - ${error}`,
|
|
40
|
+
),
|
|
41
|
+
"",
|
|
42
|
+
"════════════════════════════════",
|
|
43
|
+
].join("\n");
|
|
38
44
|
}
|
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import { DummyEmailProvider, EmailSender } from "../types";
|
|
2
1
|
import { getDefaultFromField } from "../helpers.js";
|
|
2
|
+
import { DummyEmailProvider, EmailSender } from "../types";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const yellowColorFormatString = getColorizedConsoleFormatString('yellow');
|
|
4
|
+
import { colorize } from "wasp/universal/ansiColors";
|
|
7
5
|
|
|
8
6
|
// PRIVATE API
|
|
9
7
|
export function initDummyEmailSender(
|
|
10
|
-
|
|
8
|
+
_config?: DummyEmailProvider,
|
|
11
9
|
): EmailSender {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const defaultFromField = getDefaultFromField();
|
|
11
|
+
return {
|
|
12
|
+
send: async (email) => {
|
|
13
|
+
const fromField = email.from || defaultFromField;
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
console.log(colorize("yellow", "╔═══════════════════════╗"));
|
|
16
|
+
console.log(colorize("yellow", "║ Dummy email sender ✉️ ║"));
|
|
17
|
+
console.log(colorize("yellow", "╚═══════════════════════╝"));
|
|
18
|
+
console.log(`From: ${fromField.name} <${fromField.email}>`);
|
|
19
|
+
console.log(`To: ${email.to}`);
|
|
20
|
+
console.log(`Subject: ${email.subject}`);
|
|
21
|
+
console.log(colorize("yellow", "═════════ Text ═════════"));
|
|
22
|
+
console.log(email.text);
|
|
23
|
+
console.log(colorize("yellow", "═════════ HTML ═════════"));
|
|
24
|
+
console.log(email.html);
|
|
25
|
+
console.log(colorize("yellow", "════════════════════════"));
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
return {
|
|
28
|
+
success: true,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
34
32
|
}
|
|
@@ -1,175 +1,180 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import * as z from
|
|
3
|
-
|
|
4
|
-
import { ensureEnvSchema } from '../env/validation.js'
|
|
2
|
+
import * as z from "zod"
|
|
5
3
|
|
|
4
|
+
import { ensureEnvSchema } from "../env/validation.js"
|
|
6
5
|
{=# envValidationSchema.isDefined =}
|
|
7
6
|
{=& envValidationSchema.importStatement =}
|
|
8
|
-
const userServerEnvSchema = {= envValidationSchema.importIdentifier =}
|
|
7
|
+
const userServerEnvSchema = {= envValidationSchema.importIdentifier =};
|
|
9
8
|
{=/ envValidationSchema.isDefined =}
|
|
10
9
|
{=^ envValidationSchema.isDefined =}
|
|
11
|
-
const userServerEnvSchema = z.object({})
|
|
10
|
+
const userServerEnvSchema = z.object({});
|
|
12
11
|
{=/ envValidationSchema.isDefined =}
|
|
13
12
|
|
|
14
|
-
const
|
|
13
|
+
const waspCommonServerEnvSchema = z.object({
|
|
15
14
|
PORT: z.coerce.number().default({= defaultServerPort =}),
|
|
16
15
|
{= databaseUrlEnvVarName =}: z.string({
|
|
17
|
-
|
|
16
|
+
error: '{= databaseUrlEnvVarName =} is required',
|
|
18
17
|
}),
|
|
19
18
|
PG_BOSS_NEW_OPTIONS: z.string().optional(),
|
|
20
19
|
{=# isEmailSenderEnabled =}
|
|
21
20
|
{=# enabledEmailSenders.isSmtpProviderEnabled =}
|
|
22
21
|
SMTP_HOST: z.string({
|
|
23
|
-
|
|
22
|
+
error: getRequiredEnvVarErrorMessage('SMTP email sender', 'SMTP_HOST'),
|
|
24
23
|
}),
|
|
25
24
|
SMTP_PORT: z.coerce.number({
|
|
26
|
-
|
|
27
|
-
invalid_type_error: 'SMTP_PORT must be a number',
|
|
25
|
+
error: getRequiredEnvVarErrorMessage('SMTP email sender', 'SMTP_PORT'),
|
|
28
26
|
}),
|
|
29
27
|
SMTP_USERNAME: z.string({
|
|
30
|
-
|
|
28
|
+
error: getRequiredEnvVarErrorMessage('SMTP email sender', 'SMTP_USERNAME'),
|
|
31
29
|
}),
|
|
32
30
|
SMTP_PASSWORD: z.string({
|
|
33
|
-
|
|
31
|
+
error: getRequiredEnvVarErrorMessage('SMTP email sender', 'SMTP_PASSWORD'),
|
|
34
32
|
}),
|
|
35
33
|
{=/ enabledEmailSenders.isSmtpProviderEnabled =}
|
|
36
34
|
{=# enabledEmailSenders.isSendGridProviderEnabled =}
|
|
37
35
|
SENDGRID_API_KEY: z.string({
|
|
38
|
-
|
|
36
|
+
error: getRequiredEnvVarErrorMessage('SendGrid email sender', 'SENDGRID_API_KEY'),
|
|
39
37
|
}),
|
|
40
38
|
{=/ enabledEmailSenders.isSendGridProviderEnabled =}
|
|
41
39
|
{=# enabledEmailSenders.isMailgunProviderEnabled =}
|
|
42
40
|
MAILGUN_API_KEY: z.string({
|
|
43
|
-
|
|
41
|
+
error: getRequiredEnvVarErrorMessage('Mailgun email sender', 'MAILGUN_API_KEY'),
|
|
44
42
|
}),
|
|
45
43
|
MAILGUN_DOMAIN: z.string({
|
|
46
|
-
|
|
44
|
+
error: getRequiredEnvVarErrorMessage('Mailgun email sender', 'MAILGUN_DOMAIN'),
|
|
47
45
|
}),
|
|
48
46
|
MAILGUN_API_URL: z.string().optional(),
|
|
49
47
|
{=/ enabledEmailSenders.isMailgunProviderEnabled =}
|
|
50
48
|
{=/ isEmailSenderEnabled =}
|
|
51
49
|
SKIP_EMAIL_VERIFICATION_IN_DEV: z
|
|
52
50
|
.enum(['true', 'false'], {
|
|
53
|
-
|
|
51
|
+
error: 'SKIP_EMAIL_VERIFICATION_IN_DEV must be either "true" or "false"',
|
|
54
52
|
})
|
|
55
|
-
.
|
|
56
|
-
.
|
|
53
|
+
.default('false')
|
|
54
|
+
.transform((value) => value === 'true'),
|
|
57
55
|
{=# isAuthEnabled =}
|
|
58
56
|
{=# enabledAuthProviders.isGoogleAuthEnabled =}
|
|
59
57
|
GOOGLE_CLIENT_ID: z.string({
|
|
60
|
-
|
|
58
|
+
error: getRequiredEnvVarErrorMessage('Google auth provider', 'GOOGLE_CLIENT_ID'),
|
|
61
59
|
}),
|
|
62
60
|
GOOGLE_CLIENT_SECRET: z.string({
|
|
63
|
-
|
|
61
|
+
error: getRequiredEnvVarErrorMessage('Google auth provider', 'GOOGLE_CLIENT_SECRET'),
|
|
64
62
|
}),
|
|
65
63
|
{=/ enabledAuthProviders.isGoogleAuthEnabled =}
|
|
66
64
|
{=# enabledAuthProviders.isGitHubAuthEnabled =}
|
|
67
65
|
GITHUB_CLIENT_ID: z.string({
|
|
68
|
-
|
|
66
|
+
error: getRequiredEnvVarErrorMessage('GitHub auth provider', 'GITHUB_CLIENT_ID'),
|
|
69
67
|
}),
|
|
70
68
|
GITHUB_CLIENT_SECRET: z.string({
|
|
71
|
-
|
|
69
|
+
error: getRequiredEnvVarErrorMessage('GitHub auth provider', 'GITHUB_CLIENT_SECRET'),
|
|
72
70
|
}),
|
|
73
71
|
{=/ enabledAuthProviders.isGitHubAuthEnabled =}
|
|
74
72
|
{=# enabledAuthProviders.isSlackAuthEnabled =}
|
|
75
73
|
SLACK_CLIENT_ID: z.string({
|
|
76
|
-
|
|
74
|
+
error: getRequiredEnvVarErrorMessage('Slack auth provider', 'SLACK_CLIENT_ID'),
|
|
77
75
|
}),
|
|
78
76
|
SLACK_CLIENT_SECRET: z.string({
|
|
79
|
-
|
|
77
|
+
error: getRequiredEnvVarErrorMessage('Slack auth provider', 'SLACK_CLIENT_SECRET'),
|
|
80
78
|
}),
|
|
81
79
|
{=/ enabledAuthProviders.isSlackAuthEnabled =}
|
|
82
80
|
{=# enabledAuthProviders.isDiscordAuthEnabled =}
|
|
83
81
|
DISCORD_CLIENT_ID: z.string({
|
|
84
|
-
|
|
82
|
+
error: getRequiredEnvVarErrorMessage('Discord auth provider', 'DISCORD_CLIENT_ID'),
|
|
85
83
|
}),
|
|
86
84
|
DISCORD_CLIENT_SECRET: z.string({
|
|
87
|
-
|
|
85
|
+
error: getRequiredEnvVarErrorMessage('Discord auth provider', 'DISCORD_CLIENT_SECRET'),
|
|
88
86
|
}),
|
|
89
87
|
{=/ enabledAuthProviders.isDiscordAuthEnabled =}
|
|
90
88
|
{=# enabledAuthProviders.isKeycloakAuthEnabled =}
|
|
91
89
|
KEYCLOAK_CLIENT_ID: z.string({
|
|
92
|
-
|
|
90
|
+
error: getRequiredEnvVarErrorMessage('Keycloak auth provider', 'KEYCLOAK_CLIENT_ID'),
|
|
93
91
|
}),
|
|
94
92
|
KEYCLOAK_CLIENT_SECRET: z.string({
|
|
95
|
-
|
|
93
|
+
error: getRequiredEnvVarErrorMessage('Keycloak auth provider', 'KEYCLOAK_CLIENT_SECRET'),
|
|
96
94
|
}),
|
|
97
|
-
KEYCLOAK_REALM_URL:
|
|
98
|
-
.string({
|
|
99
|
-
|
|
95
|
+
KEYCLOAK_REALM_URL:
|
|
96
|
+
z.string({
|
|
97
|
+
error: getRequiredEnvVarErrorMessage('Keycloak auth provider', 'KEYCLOAK_REALM_URL'),
|
|
100
98
|
})
|
|
101
|
-
.
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
.pipe(
|
|
100
|
+
z.url({
|
|
101
|
+
error: 'KEYCLOAK_REALM_URL must be a valid URL',
|
|
102
|
+
})
|
|
103
|
+
),
|
|
104
104
|
{=/ enabledAuthProviders.isKeycloakAuthEnabled =}
|
|
105
105
|
{=# enabledAuthProviders.isMicrosoftAuthEnabled =}
|
|
106
106
|
MICROSOFT_TENANT_ID: z.string({
|
|
107
|
-
|
|
107
|
+
error: getRequiredEnvVarErrorMessage('Microsoft auth provider', 'MICROSOFT_TENANT_ID'),
|
|
108
108
|
}),
|
|
109
109
|
MICROSOFT_CLIENT_ID: z.string({
|
|
110
|
-
|
|
110
|
+
error: getRequiredEnvVarErrorMessage('Microsoft auth provider', 'MICROSOFT_CLIENT_ID'),
|
|
111
111
|
}),
|
|
112
112
|
MICROSOFT_CLIENT_SECRET: z.string({
|
|
113
|
-
|
|
113
|
+
error: getRequiredEnvVarErrorMessage('Microsoft auth provider', 'MICROSOFT_CLIENT_SECRET'),
|
|
114
114
|
}),
|
|
115
115
|
{=/ enabledAuthProviders.isMicrosoftAuthEnabled =}
|
|
116
116
|
{=/ isAuthEnabled =}
|
|
117
|
-
})
|
|
117
|
+
});
|
|
118
118
|
|
|
119
|
-
const serverUrlSchema =
|
|
120
|
-
.string({
|
|
121
|
-
|
|
122
|
-
})
|
|
123
|
-
.url({
|
|
124
|
-
message: '{= serverUrlEnvVarName =} must be a valid URL',
|
|
119
|
+
const serverUrlSchema =
|
|
120
|
+
z.string({
|
|
121
|
+
error: '{= serverUrlEnvVarName =} is required',
|
|
125
122
|
})
|
|
123
|
+
.pipe(
|
|
124
|
+
z.url({
|
|
125
|
+
error: '{= serverUrlEnvVarName =} must be a valid URL',
|
|
126
|
+
})
|
|
127
|
+
)
|
|
126
128
|
|
|
127
|
-
const clientUrlSchema =
|
|
128
|
-
.string({
|
|
129
|
-
|
|
130
|
-
})
|
|
131
|
-
.url({
|
|
132
|
-
message: '{= clientUrlEnvVarName =} must be a valid URL',
|
|
129
|
+
const clientUrlSchema =
|
|
130
|
+
z.string({
|
|
131
|
+
error: '{= clientUrlEnvVarName =} is required',
|
|
133
132
|
})
|
|
133
|
+
.pipe(
|
|
134
|
+
z.url({
|
|
135
|
+
error: '{= clientUrlEnvVarName =} must be a valid URL',
|
|
136
|
+
})
|
|
137
|
+
)
|
|
134
138
|
|
|
135
139
|
{=# isAuthEnabled =}
|
|
136
140
|
const jwtTokenSchema = z
|
|
137
141
|
.string({
|
|
138
|
-
|
|
142
|
+
error: '{= jwtSecretEnvVarName =} is required',
|
|
139
143
|
})
|
|
140
144
|
{=/ isAuthEnabled =}
|
|
141
145
|
|
|
142
146
|
// In development, we provide default values for some environment variables
|
|
143
147
|
// to make the development process easier.
|
|
144
|
-
const
|
|
145
|
-
NODE_ENV: z.literal(
|
|
148
|
+
const waspDevServerEnvSchema = z.object({
|
|
149
|
+
NODE_ENV: z.literal("development"),
|
|
146
150
|
"{= serverUrlEnvVarName =}": serverUrlSchema
|
|
147
|
-
.default(
|
|
151
|
+
.default("{= defaultServerUrl =}"),
|
|
148
152
|
"{= clientUrlEnvVarName =}": clientUrlSchema
|
|
149
|
-
.default(
|
|
153
|
+
.default("{= defaultClientUrl =}"),
|
|
150
154
|
{=# isAuthEnabled =}
|
|
151
155
|
"{= jwtSecretEnvVarName =}": jwtTokenSchema
|
|
152
|
-
.default(
|
|
156
|
+
.default("DEVJWTSECRET"),
|
|
153
157
|
{=/ isAuthEnabled =}
|
|
154
|
-
})
|
|
158
|
+
});
|
|
155
159
|
|
|
156
|
-
const
|
|
157
|
-
NODE_ENV: z.literal(
|
|
160
|
+
const waspProdServerEnvSchema = z.object({
|
|
161
|
+
NODE_ENV: z.literal("production"),
|
|
158
162
|
"{= serverUrlEnvVarName =}": serverUrlSchema,
|
|
159
163
|
"{= clientUrlEnvVarName =}": clientUrlSchema,
|
|
160
164
|
{=# isAuthEnabled =}
|
|
161
165
|
"{= jwtSecretEnvVarName =}": jwtTokenSchema,
|
|
162
166
|
{=/ isAuthEnabled =}
|
|
163
|
-
})
|
|
167
|
+
});
|
|
164
168
|
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
const waspServerEnvSchema = z.discriminatedUnion("NODE_ENV", [
|
|
170
|
+
z.object({...waspCommonServerEnvSchema.shape, ...waspDevServerEnvSchema.shape}),
|
|
171
|
+
z.object({...waspCommonServerEnvSchema.shape, ...waspProdServerEnvSchema.shape}),
|
|
172
|
+
]);
|
|
173
|
+
const serverEnvSchema = userServerEnvSchema.and(waspServerEnvSchema);
|
|
170
174
|
|
|
171
|
-
const defaultNodeEnvValue =
|
|
175
|
+
const defaultNodeEnvValue = waspDevServerEnvSchema.shape.NODE_ENV.value;
|
|
172
176
|
const { NODE_ENV: inputNodeEnvValue, ...restEnv } = process.env;
|
|
177
|
+
|
|
173
178
|
// PUBLIC API
|
|
174
179
|
export const env = ensureEnvSchema(
|
|
175
180
|
{
|
|
@@ -177,7 +182,7 @@ export const env = ensureEnvSchema(
|
|
|
177
182
|
...restEnv,
|
|
178
183
|
},
|
|
179
184
|
serverEnvSchema,
|
|
180
|
-
)
|
|
185
|
+
);
|
|
181
186
|
|
|
182
187
|
function getRequiredEnvVarErrorMessage(featureName: string, envVarName: string) {
|
|
183
188
|
return `${envVarName} is required when using ${featureName}`
|
|
@@ -1,14 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// PRIVATE API (SDK, client)
|
|
2
|
+
/**
|
|
3
|
+
* Wraps each line of text with ANSI color codes.
|
|
4
|
+
* Only works in Node.js (server-side), not in the browser.
|
|
5
|
+
*
|
|
6
|
+
* Each line is individually wrapped because Wasp reads child process
|
|
7
|
+
* output line-by-line and re-prints it with a prefix (e.g. `[ Server ]`).
|
|
8
|
+
* A single color code spanning multiple lines would only color the first line.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* console.log(colorize('red', 'This is red text'));
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @internal This is a private API for: SDK, client.
|
|
16
|
+
*/
|
|
17
|
+
export function colorize(
|
|
18
|
+
color: keyof typeof ansiColorCodes,
|
|
19
|
+
text: string,
|
|
20
|
+
): string {
|
|
21
|
+
if (!supportsAnsiFormatting()) {
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
5
24
|
|
|
6
|
-
|
|
25
|
+
const ansiColorCode = ansiColorCodes[color];
|
|
26
|
+
return text
|
|
27
|
+
.split("\n")
|
|
28
|
+
.map((line) => `${ansiColorCode}${line}${ansiResetCode}`)
|
|
29
|
+
.join("\n");
|
|
30
|
+
}
|
|
7
31
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
32
|
+
function supportsAnsiFormatting(): boolean {
|
|
33
|
+
const isBrowser = !!globalThis.window;
|
|
34
|
+
const isNode = !!globalThis.process;
|
|
35
|
+
|
|
36
|
+
if (isBrowser && "chrome" in window) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (isNode) {
|
|
40
|
+
if ("NO_COLOR" in process.env) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
// Wasp runs the server as a child process with piped stdout/stderr,
|
|
44
|
+
// so streams are not TTYs and hasColors() won't exist on them.
|
|
45
|
+
// We default to true for non-browser runtimes because Wasp's CLI
|
|
46
|
+
// handles the final terminal output and supports ANSI codes.
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return false;
|
|
14
51
|
}
|
|
52
|
+
|
|
53
|
+
const ansiColorCodes = {
|
|
54
|
+
red: "\x1b[31m",
|
|
55
|
+
yellow: "\x1b[33m",
|
|
56
|
+
} as const;
|
|
57
|
+
|
|
58
|
+
const ansiResetCode = "\x1b[0m";
|
|
@@ -66,9 +66,6 @@ async function regionExists(regionCode) {
|
|
|
66
66
|
export async function secretExists(secretName) {
|
|
67
67
|
const proc = await $ `flyctl secrets list -j`;
|
|
68
68
|
const secrets = FlySecretListSchema.parse(proc.json());
|
|
69
|
-
return secrets.some((s) =>
|
|
70
|
-
const name = "name" in s ? s.name : s.Name;
|
|
71
|
-
return name === secretName;
|
|
72
|
-
});
|
|
69
|
+
return secrets.some((s) => s.name === secretName);
|
|
73
70
|
}
|
|
74
71
|
//# sourceMappingURL=flyCli.js.map
|
|
@@ -26,9 +26,13 @@ export const FlyRegionListSchema = z.union([
|
|
|
26
26
|
]);
|
|
27
27
|
export const FlySecretListSchema = z.union([
|
|
28
28
|
// current version
|
|
29
|
-
z.array(z
|
|
29
|
+
z.array(z
|
|
30
|
+
.object({
|
|
30
31
|
Name: z.string(),
|
|
31
|
-
})
|
|
32
|
+
})
|
|
33
|
+
.transform((data) => ({
|
|
34
|
+
name: data.Name,
|
|
35
|
+
}))),
|
|
32
36
|
// not the output yet, but just in case they update the command in the future
|
|
33
37
|
z.array(z.object({
|
|
34
38
|
name: z.string(),
|
|
@@ -42,11 +42,17 @@ export function getAppNameFromToml(path) {
|
|
|
42
42
|
}
|
|
43
43
|
export function getInferredBasenameFromServerToml(paths) {
|
|
44
44
|
const serverFlyAppName = getAppNameFromToml(paths.serverTomlPath);
|
|
45
|
-
return serverFlyAppName
|
|
45
|
+
return inferServerBasename(serverFlyAppName);
|
|
46
46
|
}
|
|
47
47
|
export function getInferredBasenameFromClientToml(paths) {
|
|
48
48
|
const clientFlyAppName = getAppNameFromToml(paths.clientTomlPath);
|
|
49
|
-
return clientFlyAppName
|
|
49
|
+
return inferClientBasename(clientFlyAppName);
|
|
50
|
+
}
|
|
51
|
+
export function inferServerBasename(name) {
|
|
52
|
+
return name.replace(/-server$/, "");
|
|
53
|
+
}
|
|
54
|
+
export function inferClientBasename(name) {
|
|
55
|
+
return name.replace(/-client$/, "");
|
|
50
56
|
}
|
|
51
57
|
export function replaceLineInLocalToml(searchValue, replaceValue) {
|
|
52
58
|
const content = fs.readFileSync("fly.toml", "utf8");
|
|
@@ -5,6 +5,7 @@ import { ensureWaspProjectIsBuilt } from "../../../../common/waspBuild.js";
|
|
|
5
5
|
import { getClientDeploymentDir, getServerDeploymentDir, } from "../../../../common/waspProject.js";
|
|
6
6
|
import { createCommandWithCwd } from "../../../../common/zx.js";
|
|
7
7
|
import { createDeploymentInstructions, } from "../../DeploymentInstructions.js";
|
|
8
|
+
import { getRailwayEnvVarValueReference } from "../../env.js";
|
|
8
9
|
import { clientAppPort, serverAppPort } from "../../ports.js";
|
|
9
10
|
import { initRailwayProject, linkRailwayProjectToWaspProjectDir, } from "../../railwayProject/cli.js";
|
|
10
11
|
import { getRailwayProjectStatus, ProjectStatus, } from "../../railwayProject/index.js";
|
|
@@ -142,16 +143,4 @@ async function setupClient({ cmdOptions: options, clientServiceName, }) {
|
|
|
142
143
|
].flat());
|
|
143
144
|
waspSays("Client setup complete!");
|
|
144
145
|
}
|
|
145
|
-
function getRailwayEnvVarValueReference(name, { serviceName } = {}) {
|
|
146
|
-
// Railway variable references have the format ${{VARIABLE}} for local variables
|
|
147
|
-
// or ${{serviceName.VARIABLE}} for cross-service references.
|
|
148
|
-
// When the service name contains special characters (like hyphens with numbers),
|
|
149
|
-
// Railway requires it to be quoted: ${{"service-name".VARIABLE}}
|
|
150
|
-
const parts = [name];
|
|
151
|
-
if (serviceName) {
|
|
152
|
-
// JSON.stringify wraps the string in quotes and escapes any special characters.
|
|
153
|
-
parts.unshift(JSON.stringify(serviceName));
|
|
154
|
-
}
|
|
155
|
-
return "${{" + parts.join(".") + "}}";
|
|
156
|
-
}
|
|
157
146
|
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function getRailwayEnvVarValueReference(name, { serviceName } = {}) {
|
|
2
|
+
// Railway variable references have the format ${{VARIABLE}} for local variables
|
|
3
|
+
// or ${{serviceName.VARIABLE}} for cross-service references.
|
|
4
|
+
// When the service name contains special characters (like hyphens with numbers),
|
|
5
|
+
// Railway requires it to be quoted: ${{"service-name".VARIABLE}}
|
|
6
|
+
const parts = [name];
|
|
7
|
+
if (serviceName) {
|
|
8
|
+
// JSON.stringify handles quoting for service names with special characters.
|
|
9
|
+
parts.unshift(JSON.stringify(serviceName));
|
|
10
|
+
}
|
|
11
|
+
return "${{" + parts.join(".") + "}}";
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -29,7 +29,7 @@ export async function generateServiceUrl(serviceName, port, options) {
|
|
|
29
29
|
return domain;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function extractServiceUrlFromString(text) {
|
|
32
|
+
export function extractServiceUrlFromString(text) {
|
|
33
33
|
const match = text.match(/https:\/\/[^\s]*/);
|
|
34
34
|
if (match === null) {
|
|
35
35
|
throw new Error("Failed to get service domain");
|