@sentry/wizard 3.34.4 → 3.35.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/CHANGELOG.md +13 -1
- package/dist/e2e-tests/tests/nuxt-3.test.d.ts +1 -0
- package/dist/e2e-tests/tests/nuxt-3.test.js +231 -0
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -0
- package/dist/e2e-tests/tests/nuxt-4.test.d.ts +1 -0
- package/dist/e2e-tests/tests/nuxt-4.test.js +232 -0
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -0
- package/dist/e2e-tests/tests/remix.test.js +92 -27
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +102 -42
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +18 -1
- package/dist/e2e-tests/utils/index.js +31 -2
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +1 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/apple/templates.js +2 -2
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +1 -0
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.d.ts +3 -0
- package/dist/src/nuxt/nuxt-wizard.js +220 -0
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -0
- package/dist/src/nuxt/sdk-example.d.ts +8 -0
- package/dist/src/nuxt/sdk-example.js +179 -0
- package/dist/src/nuxt/sdk-example.js.map +1 -0
- package/dist/src/nuxt/sdk-setup.d.ts +8 -0
- package/dist/src/nuxt/sdk-setup.js +275 -0
- package/dist/src/nuxt/sdk-setup.js.map +1 -0
- package/dist/src/nuxt/templates.d.ts +22 -0
- package/dist/src/nuxt/templates.js +84 -0
- package/dist/src/nuxt/templates.js.map +1 -0
- package/dist/src/nuxt/utils.d.ts +1 -0
- package/dist/src/nuxt/utils.js +71 -0
- package/dist/src/nuxt/utils.js.map +1 -0
- package/dist/src/remix/remix-wizard.js +2 -1
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/run.d.ts +1 -1
- package/dist/src/run.js +30 -23
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/tools/rollup.js +1 -1
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +2 -1
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +6 -2
- package/dist/src/utils/clack-utils.js +30 -10
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/test/nuxt/templates.test.d.ts +1 -0
- package/dist/test/nuxt/templates.test.js +70 -0
- package/dist/test/nuxt/templates.test.js.map +1 -0
- package/e2e-tests/README.md +59 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/README.md +75 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/nuxt.config.ts +5 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/package.json +18 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/public/favicon.ico +0 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/public/robots.txt +1 -0
- package/e2e-tests/tests/nuxt-3.test.ts +169 -0
- package/e2e-tests/tests/nuxt-4.test.ts +168 -0
- package/e2e-tests/tests/remix.test.ts +163 -50
- package/e2e-tests/tests/sveltekit.test.ts +180 -79
- package/e2e-tests/utils/index.ts +31 -1
- package/lib/Constants.ts +1 -0
- package/package.json +1 -1
- package/src/apple/templates.ts +14 -2
- package/src/nextjs/nextjs-wizard.ts +1 -0
- package/src/nuxt/nuxt-wizard.ts +166 -0
- package/src/nuxt/sdk-example.ts +135 -0
- package/src/nuxt/sdk-setup.ts +209 -0
- package/src/nuxt/templates.ts +296 -0
- package/src/nuxt/utils.ts +32 -0
- package/src/remix/remix-wizard.ts +2 -1
- package/src/run.ts +7 -0
- package/src/sourcemaps/tools/rollup.ts +1 -1
- package/src/sveltekit/sveltekit-wizard.ts +2 -1
- package/src/utils/clack-utils.ts +32 -8
- package/test/nuxt/templates.test.ts +228 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nuxt-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "nuxt build",
|
|
7
|
+
"dev": "nuxt dev",
|
|
8
|
+
"generate": "nuxt generate",
|
|
9
|
+
"preview": "nuxt preview",
|
|
10
|
+
"postinstall": "nuxt prepare",
|
|
11
|
+
"start": "node .output/server/index.mjs"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"nuxt": "^3.14.1592",
|
|
15
|
+
"vue": "latest",
|
|
16
|
+
"vue-router": "latest"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import {
|
|
3
|
+
checkEnvBuildPlugin,
|
|
4
|
+
checkFileContents,
|
|
5
|
+
checkFileExists,
|
|
6
|
+
checkIfBuilds,
|
|
7
|
+
checkIfRunsOnProdMode,
|
|
8
|
+
checkPackageJson,
|
|
9
|
+
cleanupGit,
|
|
10
|
+
KEYS,
|
|
11
|
+
revertLocalChanges,
|
|
12
|
+
startWizardInstance,
|
|
13
|
+
TEST_ARGS,
|
|
14
|
+
} from '../utils';
|
|
15
|
+
import { Integration } from '../../lib/Constants';
|
|
16
|
+
|
|
17
|
+
describe('Nuxt-3', () => {
|
|
18
|
+
const projectDir = path.resolve(
|
|
19
|
+
__dirname,
|
|
20
|
+
'../test-applications/nuxt-3-test-app',
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
beforeAll(async () => {
|
|
24
|
+
await runWizardOnNuxtProject(projectDir);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterAll(() => {
|
|
28
|
+
revertLocalChanges(projectDir);
|
|
29
|
+
cleanupGit(projectDir);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
testNuxtProjectSetup(projectDir);
|
|
33
|
+
|
|
34
|
+
testNuxtProjectConfigs(projectDir);
|
|
35
|
+
|
|
36
|
+
testNuxtProjectBuildsAndRuns(projectDir);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
async function runWizardOnNuxtProject(projectDir: string): Promise<void> {
|
|
40
|
+
const integration = Integration.nuxt;
|
|
41
|
+
|
|
42
|
+
const wizardInstance = startWizardInstance(integration, projectDir);
|
|
43
|
+
const packageManagerPrompted = await wizardInstance.waitForOutput(
|
|
44
|
+
'Please select your package manager.',
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const tracingOptionPrompted =
|
|
48
|
+
packageManagerPrompted &&
|
|
49
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
50
|
+
// Selecting `yarn` as the package manager
|
|
51
|
+
[KEYS.DOWN, KEYS.ENTER],
|
|
52
|
+
// "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
|
|
53
|
+
'to track the performance of your application?',
|
|
54
|
+
{
|
|
55
|
+
timeout: 240_000,
|
|
56
|
+
},
|
|
57
|
+
));
|
|
58
|
+
|
|
59
|
+
const replayOptionPrompted =
|
|
60
|
+
tracingOptionPrompted &&
|
|
61
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
62
|
+
[KEYS.ENTER],
|
|
63
|
+
// "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
|
|
64
|
+
'to get a video-like reproduction of errors during a user session?',
|
|
65
|
+
));
|
|
66
|
+
|
|
67
|
+
replayOptionPrompted &&
|
|
68
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
69
|
+
[KEYS.ENTER],
|
|
70
|
+
'Do you want to create an example page',
|
|
71
|
+
{
|
|
72
|
+
optional: true,
|
|
73
|
+
},
|
|
74
|
+
));
|
|
75
|
+
|
|
76
|
+
await wizardInstance.sendStdinAndWaitForOutput(
|
|
77
|
+
[KEYS.ENTER, KEYS.ENTER],
|
|
78
|
+
'Successfully installed the Sentry Nuxt SDK!',
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
wizardInstance.kill();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function testNuxtProjectSetup(projectDir: string) {
|
|
85
|
+
const integration = Integration.nuxt;
|
|
86
|
+
|
|
87
|
+
test('package.json is updated correctly', () => {
|
|
88
|
+
checkPackageJson(projectDir, integration);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('.env-sentry-build-plugin is created and contains the auth token', () => {
|
|
92
|
+
checkEnvBuildPlugin(projectDir);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('config files created', () => {
|
|
96
|
+
checkFileExists(`${projectDir}/sentry.server.config.ts`);
|
|
97
|
+
checkFileExists(`${projectDir}/sentry.client.config.ts`);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('example page exists', () => {
|
|
101
|
+
checkFileExists(`${projectDir}/pages/sentry-example-page.vue`);
|
|
102
|
+
checkFileExists(`${projectDir}/server/api/sentry-example-api.ts`);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function testNuxtProjectConfigs(projectDir: string) {
|
|
107
|
+
test('nuxt config contains sentry module', () => {
|
|
108
|
+
checkFileContents(path.resolve(projectDir, 'nuxt.config.ts'), [
|
|
109
|
+
"modules: ['@sentry/nuxt/module'],",
|
|
110
|
+
'sentry: {',
|
|
111
|
+
' sourceMapsUploadOptions: {',
|
|
112
|
+
` org: '${TEST_ARGS.ORG_SLUG}',`,
|
|
113
|
+
` project: '${TEST_ARGS.PROJECT_SLUG}'`,
|
|
114
|
+
' }',
|
|
115
|
+
'},',
|
|
116
|
+
'sourcemap: {',
|
|
117
|
+
" client: 'hidden'",
|
|
118
|
+
'}',
|
|
119
|
+
]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('sentry.client.config.ts contents', () => {
|
|
123
|
+
checkFileContents(path.resolve(projectDir, 'sentry.client.config.ts'), [
|
|
124
|
+
'import * as Sentry from "@sentry/nuxt";',
|
|
125
|
+
'Sentry.init({',
|
|
126
|
+
' // If set up, you can use your runtime config here',
|
|
127
|
+
' // dsn: useRuntimeConfig().public.sentry.dsn,',
|
|
128
|
+
` dsn: "${TEST_ARGS.PROJECT_DSN}",`,
|
|
129
|
+
' // We recommend adjusting this value in production, or using tracesSampler',
|
|
130
|
+
' // for finer control',
|
|
131
|
+
' tracesSampleRate: 1.0,',
|
|
132
|
+
' // This sets the sample rate to be 10%. You may want this to be 100% while',
|
|
133
|
+
' // in development and sample at a lower rate in production',
|
|
134
|
+
' replaysSessionSampleRate: 0.1,',
|
|
135
|
+
' // If the entire session is not sampled, use the below sample rate to sample',
|
|
136
|
+
' // sessions when an error occurs.',
|
|
137
|
+
' replaysOnErrorSampleRate: 1.0,',
|
|
138
|
+
" // If you don't want to use Session Replay, just remove the line below:",
|
|
139
|
+
' integrations: [Sentry.replayIntegration()],',
|
|
140
|
+
" // Setting this option to true will print useful information to the console while you're setting up Sentry.",
|
|
141
|
+
' debug: false,',
|
|
142
|
+
'});',
|
|
143
|
+
]);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test('sentry.server.config.ts contents', () => {
|
|
147
|
+
checkFileContents(path.resolve(projectDir, 'sentry.server.config.ts'), [
|
|
148
|
+
'import * as Sentry from "@sentry/nuxt";',
|
|
149
|
+
'Sentry.init({',
|
|
150
|
+
` dsn: "${TEST_ARGS.PROJECT_DSN}",`,
|
|
151
|
+
' // We recommend adjusting this value in production, or using tracesSampler',
|
|
152
|
+
' // for finer control',
|
|
153
|
+
' tracesSampleRate: 1.0,',
|
|
154
|
+
" // Setting this option to true will print useful information to the console while you're setting up Sentry.",
|
|
155
|
+
' debug: false,',
|
|
156
|
+
'});',
|
|
157
|
+
]);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function testNuxtProjectBuildsAndRuns(projectDir: string) {
|
|
162
|
+
test('builds successfully', async () => {
|
|
163
|
+
await checkIfBuilds(projectDir, 'preview this build');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('runs on prod mode correctly', async () => {
|
|
167
|
+
await checkIfRunsOnProdMode(projectDir, 'Listening on');
|
|
168
|
+
});
|
|
169
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { Integration } from '../../lib/Constants';
|
|
3
|
+
import { cleanupGit, revertLocalChanges } from '../utils';
|
|
4
|
+
import {
|
|
5
|
+
checkEnvBuildPlugin,
|
|
6
|
+
checkFileContents,
|
|
7
|
+
checkFileExists,
|
|
8
|
+
checkIfBuilds,
|
|
9
|
+
checkIfRunsOnProdMode,
|
|
10
|
+
checkPackageJson,
|
|
11
|
+
KEYS,
|
|
12
|
+
startWizardInstance,
|
|
13
|
+
TEST_ARGS,
|
|
14
|
+
} from '../utils';
|
|
15
|
+
|
|
16
|
+
describe('Nuxt-4', () => {
|
|
17
|
+
const projectDir = path.resolve(
|
|
18
|
+
__dirname,
|
|
19
|
+
'../test-applications/nuxt-4-test-app',
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
beforeAll(async () => {
|
|
23
|
+
await runWizardOnNuxtProject(projectDir);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterAll(() => {
|
|
27
|
+
revertLocalChanges(projectDir);
|
|
28
|
+
cleanupGit(projectDir);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
testNuxtProjectSetup(projectDir);
|
|
32
|
+
|
|
33
|
+
testNuxtProjectConfigs(projectDir);
|
|
34
|
+
|
|
35
|
+
testNuxtProjectBuildsAndRuns(projectDir);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
async function runWizardOnNuxtProject(projectDir: string): Promise<void> {
|
|
39
|
+
const integration = Integration.nuxt;
|
|
40
|
+
|
|
41
|
+
const wizardInstance = startWizardInstance(integration, projectDir);
|
|
42
|
+
const packageManagerPrompted = await wizardInstance.waitForOutput(
|
|
43
|
+
'Please select your package manager.',
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const tracingOptionPrompted =
|
|
47
|
+
packageManagerPrompted &&
|
|
48
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
49
|
+
// Selecting `yarn` as the package manager
|
|
50
|
+
[KEYS.DOWN, KEYS.ENTER],
|
|
51
|
+
// "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
|
|
52
|
+
'to track the performance of your application?',
|
|
53
|
+
{
|
|
54
|
+
timeout: 240_000,
|
|
55
|
+
},
|
|
56
|
+
));
|
|
57
|
+
|
|
58
|
+
const replayOptionPrompted =
|
|
59
|
+
tracingOptionPrompted &&
|
|
60
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
61
|
+
[KEYS.ENTER],
|
|
62
|
+
// "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
|
|
63
|
+
'to get a video-like reproduction of errors during a user session?',
|
|
64
|
+
));
|
|
65
|
+
|
|
66
|
+
replayOptionPrompted &&
|
|
67
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
68
|
+
[KEYS.ENTER],
|
|
69
|
+
'Do you want to create an example page',
|
|
70
|
+
{
|
|
71
|
+
optional: true,
|
|
72
|
+
},
|
|
73
|
+
));
|
|
74
|
+
|
|
75
|
+
await wizardInstance.sendStdinAndWaitForOutput(
|
|
76
|
+
[KEYS.ENTER, KEYS.ENTER],
|
|
77
|
+
'Successfully installed the Sentry Nuxt SDK!',
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
wizardInstance.kill();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function testNuxtProjectSetup(projectDir: string) {
|
|
84
|
+
const integration = Integration.nuxt;
|
|
85
|
+
|
|
86
|
+
test('package.json is updated correctly', () => {
|
|
87
|
+
checkPackageJson(projectDir, integration);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('.env-sentry-build-plugin is created and contains the auth token', () => {
|
|
91
|
+
checkEnvBuildPlugin(projectDir);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('config files created', () => {
|
|
95
|
+
checkFileExists(`${projectDir}/sentry.server.config.ts`);
|
|
96
|
+
checkFileExists(`${projectDir}/sentry.client.config.ts`);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('example page exists', () => {
|
|
100
|
+
checkFileExists(`${projectDir}/app/pages/sentry-example-page.vue`);
|
|
101
|
+
checkFileExists(`${projectDir}/server/api/sentry-example-api.ts`);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function testNuxtProjectConfigs(projectDir: string) {
|
|
106
|
+
test('nuxt config contains sentry module', () => {
|
|
107
|
+
checkFileContents(path.resolve(projectDir, 'nuxt.config.ts'), [
|
|
108
|
+
"modules: ['@sentry/nuxt/module'],",
|
|
109
|
+
'sentry: {',
|
|
110
|
+
' sourceMapsUploadOptions: {',
|
|
111
|
+
` org: '${TEST_ARGS.ORG_SLUG}',`,
|
|
112
|
+
` project: '${TEST_ARGS.PROJECT_SLUG}'`,
|
|
113
|
+
' }',
|
|
114
|
+
'},',
|
|
115
|
+
'sourcemap: {',
|
|
116
|
+
" client: 'hidden'",
|
|
117
|
+
'}',
|
|
118
|
+
]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('sentry.client.config.ts contents', () => {
|
|
122
|
+
checkFileContents(path.resolve(projectDir, 'sentry.client.config.ts'), [
|
|
123
|
+
'import * as Sentry from "@sentry/nuxt";',
|
|
124
|
+
'Sentry.init({',
|
|
125
|
+
' // If set up, you can use your runtime config here',
|
|
126
|
+
' // dsn: useRuntimeConfig().public.sentry.dsn,',
|
|
127
|
+
` dsn: "${TEST_ARGS.PROJECT_DSN}",`,
|
|
128
|
+
' // We recommend adjusting this value in production, or using tracesSampler',
|
|
129
|
+
' // for finer control',
|
|
130
|
+
' tracesSampleRate: 1.0,',
|
|
131
|
+
' // This sets the sample rate to be 10%. You may want this to be 100% while',
|
|
132
|
+
' // in development and sample at a lower rate in production',
|
|
133
|
+
' replaysSessionSampleRate: 0.1,',
|
|
134
|
+
' // If the entire session is not sampled, use the below sample rate to sample',
|
|
135
|
+
' // sessions when an error occurs.',
|
|
136
|
+
' replaysOnErrorSampleRate: 1.0,',
|
|
137
|
+
" // If you don't want to use Session Replay, just remove the line below:",
|
|
138
|
+
' integrations: [Sentry.replayIntegration()],',
|
|
139
|
+
" // Setting this option to true will print useful information to the console while you're setting up Sentry.",
|
|
140
|
+
' debug: false,',
|
|
141
|
+
'});',
|
|
142
|
+
]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('sentry.server.config.ts contents', () => {
|
|
146
|
+
checkFileContents(path.resolve(projectDir, 'sentry.server.config.ts'), [
|
|
147
|
+
'import * as Sentry from "@sentry/nuxt";',
|
|
148
|
+
'Sentry.init({',
|
|
149
|
+
` dsn: "${TEST_ARGS.PROJECT_DSN}",`,
|
|
150
|
+
' // We recommend adjusting this value in production, or using tracesSampler',
|
|
151
|
+
' // for finer control',
|
|
152
|
+
' tracesSampleRate: 1.0,',
|
|
153
|
+
" // Setting this option to true will print useful information to the console while you're setting up Sentry.",
|
|
154
|
+
' debug: false,',
|
|
155
|
+
'});',
|
|
156
|
+
]);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function testNuxtProjectBuildsAndRuns(projectDir: string) {
|
|
161
|
+
test('builds successfully', async () => {
|
|
162
|
+
await checkIfBuilds(projectDir, 'preview this build');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test('runs on prod mode correctly', async () => {
|
|
166
|
+
await checkIfRunsOnProdMode(projectDir, 'Listening on');
|
|
167
|
+
});
|
|
168
|
+
}
|
|
@@ -9,68 +9,122 @@ import {
|
|
|
9
9
|
checkIfRunsOnProdMode,
|
|
10
10
|
checkPackageJson,
|
|
11
11
|
cleanupGit,
|
|
12
|
+
createFile,
|
|
12
13
|
KEYS,
|
|
14
|
+
modifyFile,
|
|
13
15
|
revertLocalChanges,
|
|
14
16
|
startWizardInstance,
|
|
15
17
|
TEST_ARGS,
|
|
16
18
|
} from '../utils';
|
|
17
19
|
import * as path from 'path';
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const SERVER_TEMPLATE = `import { createRequestHandler } from '@remix-run/express';
|
|
22
|
+
import { installGlobals } from '@remix-run/node';
|
|
23
|
+
import compression from 'compression';
|
|
24
|
+
import express from 'express';
|
|
25
|
+
import morgan from 'morgan';
|
|
26
|
+
|
|
27
|
+
installGlobals();
|
|
28
|
+
|
|
29
|
+
const viteDevServer =
|
|
30
|
+
process.env.NODE_ENV === 'production'
|
|
31
|
+
? undefined
|
|
32
|
+
: await import('vite').then(vite =>
|
|
33
|
+
vite.createServer({
|
|
34
|
+
server: { middlewareMode: true },
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const app = express();
|
|
39
|
+
|
|
40
|
+
app.use(compression());
|
|
41
|
+
app.disable('x-powered-by');
|
|
42
|
+
|
|
43
|
+
if (viteDevServer) {
|
|
44
|
+
app.use(viteDevServer.middlewares);
|
|
45
|
+
} else {
|
|
46
|
+
app.use('/assets', express.static('build/client/assets', { immutable: true, maxAge: '1y' }));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
app.use(express.static('build/client', { maxAge: '1h' }));
|
|
50
|
+
app.use(morgan('tiny'));
|
|
51
|
+
|
|
52
|
+
app.all(
|
|
53
|
+
'*',
|
|
54
|
+
createRequestHandler({
|
|
55
|
+
build: viteDevServer
|
|
56
|
+
? () => viteDevServer.ssrLoadModule('virtual:remix/server-build')
|
|
57
|
+
: await import('./build/server/index.js'),
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
app.listen(0, () => console.log('Express server listening'));
|
|
62
|
+
`;
|
|
25
63
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
64
|
+
|
|
65
|
+
async function runWizardOnRemixProject(projectDir: string, integration: Integration, fileModificationFn?: (projectDir: string, integration: Integration) => unknown) {
|
|
66
|
+
const wizardInstance = startWizardInstance(integration, projectDir);
|
|
67
|
+
let packageManagerPrompted = false;
|
|
68
|
+
|
|
69
|
+
if (fileModificationFn) {
|
|
70
|
+
fileModificationFn(projectDir, integration);
|
|
71
|
+
|
|
72
|
+
await wizardInstance.waitForOutput(
|
|
73
|
+
'Do you want to continue anyway?',
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
packageManagerPrompted = await wizardInstance.sendStdinAndWaitForOutput(
|
|
77
|
+
[KEYS.ENTER],
|
|
29
78
|
'Please select your package manager.',
|
|
30
79
|
);
|
|
80
|
+
} else {
|
|
31
81
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
35
|
-
// Selecting `yarn` as the package manager
|
|
36
|
-
[KEYS.DOWN, KEYS.ENTER],
|
|
37
|
-
// "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
|
|
38
|
-
'to track the performance of your application?',
|
|
39
|
-
{
|
|
40
|
-
timeout: 240_000,
|
|
41
|
-
},
|
|
42
|
-
));
|
|
43
|
-
|
|
44
|
-
const replayOptionPrompted =
|
|
45
|
-
tracingOptionPrompted &&
|
|
46
|
-
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
47
|
-
[KEYS.ENTER],
|
|
48
|
-
// "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
|
|
49
|
-
'to get a video-like reproduction of errors during a user session?',
|
|
50
|
-
));
|
|
51
|
-
|
|
52
|
-
replayOptionPrompted &&
|
|
53
|
-
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
54
|
-
[KEYS.ENTER],
|
|
55
|
-
'Do you want to create an example page',
|
|
56
|
-
{
|
|
57
|
-
optional: true,
|
|
58
|
-
},
|
|
59
|
-
));
|
|
60
|
-
|
|
61
|
-
await wizardInstance.sendStdinAndWaitForOutput(
|
|
62
|
-
[KEYS.ENTER, KEYS.ENTER],
|
|
63
|
-
'Sentry has been successfully configured for your Remix project',
|
|
82
|
+
packageManagerPrompted = await wizardInstance.waitForOutput(
|
|
83
|
+
'Please select your package manager.',
|
|
64
84
|
);
|
|
85
|
+
}
|
|
65
86
|
|
|
66
|
-
|
|
67
|
-
|
|
87
|
+
const tracingOptionPrompted =
|
|
88
|
+
packageManagerPrompted &&
|
|
89
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
90
|
+
// Selecting `yarn` as the package manager
|
|
91
|
+
[KEYS.DOWN, KEYS.ENTER],
|
|
92
|
+
// "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
|
|
93
|
+
'to track the performance of your application?',
|
|
94
|
+
{
|
|
95
|
+
timeout: 240_000,
|
|
96
|
+
},
|
|
97
|
+
));
|
|
68
98
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
99
|
+
const replayOptionPrompted =
|
|
100
|
+
tracingOptionPrompted &&
|
|
101
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
102
|
+
[KEYS.ENTER],
|
|
103
|
+
// "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
|
|
104
|
+
'to get a video-like reproduction of errors during a user session?',
|
|
105
|
+
));
|
|
106
|
+
|
|
107
|
+
replayOptionPrompted &&
|
|
108
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
109
|
+
[KEYS.ENTER],
|
|
110
|
+
'Do you want to create an example page',
|
|
111
|
+
{
|
|
112
|
+
optional: true,
|
|
113
|
+
},
|
|
114
|
+
));
|
|
73
115
|
|
|
116
|
+
await wizardInstance.sendStdinAndWaitForOutput(
|
|
117
|
+
[KEYS.ENTER, KEYS.ENTER],
|
|
118
|
+
'Sentry has been successfully configured for your Remix project',
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
wizardInstance.kill();
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
function checkRemixProject(projectDir: string, integration: Integration, options?: {
|
|
125
|
+
devModeExpectedOutput?: string;
|
|
126
|
+
prodModeExpectedOutput?: string;
|
|
127
|
+
}) {
|
|
74
128
|
test('package.json is updated correctly', () => {
|
|
75
129
|
checkPackageJson(projectDir, integration);
|
|
76
130
|
});
|
|
@@ -140,15 +194,74 @@ describe('Remix', () => {
|
|
|
140
194
|
]);
|
|
141
195
|
});
|
|
142
196
|
|
|
143
|
-
test('builds
|
|
197
|
+
test('builds successfully', async () => {
|
|
144
198
|
await checkIfBuilds(projectDir, 'built');
|
|
145
199
|
});
|
|
146
200
|
|
|
147
201
|
test('runs on dev mode correctly', async () => {
|
|
148
|
-
await checkIfRunsOnDevMode(projectDir, 'to expose');
|
|
202
|
+
await checkIfRunsOnDevMode(projectDir, options?.devModeExpectedOutput || 'to expose');
|
|
149
203
|
});
|
|
150
204
|
|
|
151
205
|
test('runs on prod mode correctly', async () => {
|
|
152
|
-
await checkIfRunsOnProdMode(projectDir, '[remix-serve]');
|
|
206
|
+
await checkIfRunsOnProdMode(projectDir, options?.prodModeExpectedOutput || '[remix-serve]');
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
describe('Remix', () => {
|
|
211
|
+
describe('with empty project', () => {
|
|
212
|
+
const integration = Integration.remix;
|
|
213
|
+
const projectDir = path.resolve(
|
|
214
|
+
__dirname,
|
|
215
|
+
'../test-applications/remix-test-app',
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
beforeAll(async () => {
|
|
219
|
+
await runWizardOnRemixProject(projectDir, integration);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
afterAll(() => {
|
|
223
|
+
revertLocalChanges(projectDir);
|
|
224
|
+
cleanupGit(projectDir);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
checkRemixProject(projectDir, integration);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('with existing custom Express server', () => {
|
|
231
|
+
const integration = Integration.remix;
|
|
232
|
+
const projectDir = path.resolve(
|
|
233
|
+
__dirname,
|
|
234
|
+
'../test-applications/remix-test-app',
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
beforeAll(async () => {
|
|
238
|
+
await runWizardOnRemixProject(projectDir, integration, (projectDir) => {
|
|
239
|
+
createFile(
|
|
240
|
+
`${projectDir}/server.mjs`,
|
|
241
|
+
SERVER_TEMPLATE,
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
modifyFile(`${projectDir}/package.json`, {
|
|
245
|
+
'"start": "remix-serve ./build/server/index.js"': '"start": "node ./server.mjs"',
|
|
246
|
+
'"dev": "remix vite:dev"': '"dev": "node ./server.mjs"',
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
afterAll(() => {
|
|
252
|
+
revertLocalChanges(projectDir);
|
|
253
|
+
cleanupGit(projectDir);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
checkRemixProject(projectDir, integration, {
|
|
257
|
+
devModeExpectedOutput: 'Express server listening',
|
|
258
|
+
prodModeExpectedOutput: 'Express server listening',
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test('server.mjs contains instrumentation file import', () => {
|
|
262
|
+
checkFileContents(`${projectDir}/server.mjs`, [
|
|
263
|
+
"import './instrumentation.server.mjs';",
|
|
264
|
+
]);
|
|
265
|
+
});
|
|
153
266
|
});
|
|
154
267
|
});
|