Skip to content

Commit 85e7299

Browse files
committed
Fix import bug
1 parent 426dcf5 commit 85e7299

File tree

3 files changed

+42
-55
lines changed

3 files changed

+42
-55
lines changed

scripts/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ const logError = (error) => {
33
return;
44
};
55

6-
module.exports = {
6+
export default {
77
logError,
88
};

scripts/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const { parseArgs } = require('node:util');
1+
// const { parseArgs } = require('node:util');
22
const concurrently = require('concurrently');
33
const fs = require('fs-extra');
4-
const { logError } = require('./common.js');
4+
const { logError } = require('./common.js').default;
55

66
const defaultTimeout = 5 * 60 * 1000; // 5 minutes
77

scripts/webpack-test.js

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const concurrently = require('concurrently');
2-
const fs = require('fs-extra');
3-
const { logError } = require('./common.js');
1+
import concurrently from 'concurrently';
2+
import { existsSync } from 'fs-extra';
3+
import { logError } from './common.js';
44

55
const defaultTimeout = 5 * 60 * 1000; // 5 minutes
66

@@ -31,10 +31,43 @@ const BUILD_TYPE = {
3131
dev: 'dev',
3232
};
3333

34+
// Read arguments from process.argv, validate them, and assign defaults. Returns the parameter list.
35+
const getParameters = () => {
36+
let {
37+
values: { env },
38+
positionals: [
39+
framework,
40+
testFile,
41+
browser,
42+
build,
43+
backend,
44+
],
45+
} = parseArgs({
46+
options: {
47+
env: {
48+
type: 'string',
49+
},
50+
},
51+
allowPositionals: true,
52+
});
53+
54+
if (!backend) {
55+
backend = 'cli';
56+
}
57+
return {
58+
framework,
59+
testFile,
60+
browser,
61+
build,
62+
backend,
63+
};
64+
};
65+
66+
3467
// bash command for installing node_modules if it is not present
3568
// TODO: remove --ignore-engines when we update the cypress image
3669
const npmInstall = (sampleDir) => {
37-
return fs.existsSync(`${sampleDir}/node_modules`)
70+
return existsSync(`${sampleDir}/node_modules`)
3871
? `echo "Skipping npm install"`
3972
: `npm --prefix ${sampleDir} install`;
4073
};
@@ -43,47 +76,6 @@ const sampleDirectory = ({ framework}) => {
4376
return `packages/e2e-tests/${framework}`;
4477
};
4578

46-
// bash command for serving sample on prod
47-
const runAppOnProd = ({ framework, backend, env }) => {
48-
const sampleDir = sampleDirectory({ framework});
49-
let distDir; // distribution directory
50-
if (framework === FRAMEWORKS.webpack) {
51-
distDir = `${sampleDir}/dist`;
52-
} else {
53-
logError(`unknown framework: ${framework}`);
54-
}
55-
//npm install the dependencies
56-
const install = npmInstall(sampleDir);
57-
//env variables
58-
const envVars = Object.entries(env)
59-
.map(([key, value]) => `${key}=${value}`)
60-
.join(' ');
61-
62-
let buildCommand = 'build';
63-
let startCommand = 'start';
64-
if (backend === 'gen2') {
65-
buildCommand = 'build:gen2';
66-
startCommand = 'start:gen2';
67-
}
68-
const serveCommand =
69-
framework === 'next'
70-
? `npm --prefix ${sampleDir} run ${startCommand}`
71-
: `serve -s ${distDir} -l ${frameworkPort[framework]}`;
72-
73-
const command = [
74-
envVars && `export ${envVars}`,
75-
install,
76-
`npm --prefix ${sampleDir} run ${buildCommand} ${prodFlag}`,
77-
serveCommand,
78-
]
79-
.filter(Boolean)
80-
.join(' && ');
81-
82-
console.log('prod', command);
83-
84-
return command;
85-
};
86-
8779
const getDevStartCommand = ({ framework, backend }) => {
8880
const startWithbackendCmd = backend === 'gen2' ? 'start:gen2' : 'start';
8981
switch (framework) {
@@ -122,18 +114,13 @@ const startSampleAndRun = async () => {
122114
const params = getParameters();
123115
const {
124116
framework,
125-
category,
126117
testFile,
127118
browser,
128119
build,
129-
sample,
130120
} = params;
131-
const sampleDir = sampleDirectory({ framework, category, sample });
121+
const sampleDir = sampleDirectory({ framework});
132122

133-
const waitOnOption =
134-
category === 'geo'
135-
? `http-get://127.0.0.1:${frameworkPort[framework]}`
136-
: `tcp:127.0.0.1:${frameworkPort[framework]}`;
123+
const waitOnOption = `tcp:127.0.0.1:${frameworkPort[framework]}`;
137124

138125
// commands
139126
const runApp =

0 commit comments

Comments
 (0)