Skip to content

Commit 64e0cef

Browse files
Mykhailo BodnarchukMykhailo Bodnarchuk
authored andcommitted
added readme
1 parent 58b90b0 commit 64e0cef

File tree

4 files changed

+127
-12
lines changed

4 files changed

+127
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Logs
22
logs
33
*.log
4+
examples
5+
package-lock.json
46
npm-debug.log*
57
yarn-debug.log*
68
yarn-error.log*

Readme.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Create CodeceptJS 🚀
2+
3+
Create CodeceptJS project easily, having all dependencies installed with one command.
4+
5+
```
6+
____ ____ _____ ____ _____ _____ ____ ____ ____ _____ ____ _____ ____ _____ _ ____
7+
/ _\/ __\/ __// _ \/__ __\/ __/ / _\/ _ \/ _ \/ __// _\/ __// __\/__ __\ / |/ ___\
8+
| / | \/|| \ | / \ | / \ | \ | / | / \|| | \|| \ | / | \ | \/| / \ | || \
9+
| \__| /| /_ | |-| | | | | /_ | \__| \_/|| |_/|| /_ | \_ | /_ | __/ | |/\_| |\___ |
10+
\____/\_/\_\\____\\_/ \ | \_/ \____\ \____/\____/\____/\____\\____/\____\\_/ \_/\____/\____/
11+
12+
```
13+
14+
## Installation
15+
16+
No installation needed 🤗
17+
18+
## Usage
19+
20+
Install CodeceptJS + Playwright into current project
21+
22+
```
23+
npx create-codeceptjs
24+
```
25+
26+
Install CodeceptJS into "tests" directory
27+
28+
```
29+
npx create-codeceptjs tests
30+
```
31+
32+
Install CodeceptJS + webdriverio:
33+
34+
```
35+
npx create-codeceptjs --webdriverio
36+
```
37+
38+
Install CodeceptJS + webdriverio into "tests" directory
39+
40+
```
41+
npx create-codeceptjs tests --webdriverio
42+
```
43+
44+
Other options:
45+
46+
* `--puppeteer` - install puppeteer as default helper
47+
* `--testcafe` - install testcafe as default helper
48+

index.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ const enginePackages = {
1515
};
1616

1717
const codeceptPackages = [
18-
'codeceptjs',
19-
'@codeceptjs/configure',
18+
2019
'@codeceptjs/ui',
2120
'@codeceptjs/examples',
2221
'@codeceptjs/configure'
@@ -105,6 +104,7 @@ async function createCodecept(opts) {
105104
const root = path.join(process.cwd(), projectName || '');
106105
fs.ensureDirSync(root);
107106

107+
const currentDir = process.cwd();
108108
process.chdir(root);
109109

110110

@@ -157,7 +157,8 @@ async function createCodecept(opts) {
157157
fs.writeJsonSync('package.json', packageJson);
158158

159159

160-
// await install(deps.flat());
160+
await install(deps.flat());
161+
await chdir();
161162

162163
console.log('Finished installing packages.');
163164

@@ -171,22 +172,36 @@ async function createCodecept(opts) {
171172
console.log('➕', chalk.cyan('npm run codecept:demo:server'), '- starts codeceptjs UI as a webserver for a demo project');
172173
console.log();
173174
console.log('Initialize CodeceptJS for your project:');
174-
console.log('🔨', chalk.yellow('npx codeceptjs init'), '- initialize codeceptjs for current project', chalk.bold('required'));
175+
console.log('🔨', chalk.yellow('npx codeceptjs init'), '- initialize codeceptjs for current project', chalk.bold('(required)'));
175176
console.log('➕', chalk.cyan('npm run codecept'), '- runs codeceptjs tests for current project');
176177
console.log('➕', chalk.cyan('npm run codecept:headless'), '- executes codeceptjs tests headlessly (no window shown)');
177178
console.log('➕', chalk.cyan('npm run codecept:app'), '- starts codeceptjs UI application for current project');
178179
console.log('➕', chalk.cyan('npm run codecept:server'), '- starts codeceptJS UI as webserver');
179-
// if (opts)
180-
// npx create-codeceptjs <> --playwright
181-
// npx create-codeceptjs <> --puppeteer
182-
// npx create-codeceptjs <> --testcafe
183-
// npx create-codeceptjs <>
180+
181+
console.log();
182+
if (root != currentDir) {
183+
console.log('⚠', 'Change directory to', chalk.yellow(root), 'to run these commands');
184+
}
184185
}
185186

186187
// npx create-codeceptjs codecept-tests --playwright && cd codecept-tests && npx codeceptjs init
187188

189+
async function chdir() {
190+
return new Promise((resolve, reject) => {
191+
const child = spawn('cd', process.cwd(), { stdio: 'inherit' });
192+
child.on('close', code => {
193+
if (code !== 0) {
194+
reject({
195+
command: `cd ${process.cwd()}`,
196+
});
197+
return;
198+
}
199+
resolve();
200+
});
201+
})
202+
}
188203

189-
function install(dependencies, verbose) {
204+
async function install(dependencies, verbose) {
190205
return new Promise((resolve, reject) => {
191206
let command;
192207
let args;
@@ -195,7 +210,7 @@ function install(dependencies, verbose) {
195210

196211
if (useYarn) {
197212
command = 'yarnpkg';
198-
args = ['add', '--exact'];
213+
args = ['add','-D', '--exact'];
199214
[].push.apply(args, dependencies);
200215

201216
// Explicitly set cwd() to work around issues like

package.json

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,51 @@
1-
{"name":"create-codeceptjs","version":"0.1.0","description":"Install CodeceptJS with all its dependencies in a single run","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","codecept":"codeceptjs run --steps","codecept:app":"codecept-ui --app","codecept:server":"codecept-ui","codecept:example":"codeceptjs run --steps -c node_modules/@codeceptjs/examples","codecept:example:app":"codecept-ui --app -c node_modules/@codeceptjs/examples","codecept:example:server":"codecept-ui -c node_modules/@codeceptjs/examples","codecept:headless":"HEADLESS=true codeceptjs run --steps","codecept:demo":"codeceptjs run --steps -c node_modules/@codeceptjs/examples","codecept:demo:headless":"HEADLESS=true codeceptjs run --steps -c node_modules/@codeceptjs/examples","codecept:demo:app":"codecept-ui --app -c node_modules/@codeceptjs/examples","codecept:demo:server":"codecept-ui -c node_modules/@codeceptjs/examples"},"repository":{"type":"git","url":"git+https://github.com/codecept-js/create-codeceptjs.git"},"keywords":["codeceptjs","bdd","installer","e2e"],"author":"Michael Bodnarchuk","license":"ISC","bugs":{"url":"https://github.com/codecept-js/create-codeceptjs/issues"},"homepage":"https://github.com/codecept-js/create-codeceptjs#readme","dependencies":{"cfonts":"^2.8.5","chalk":"^4.1.0","commander":"^5.1.0","cross-spawn":"^7.0.3","fs-extra":"^9.0.1","semver":"^7.3.2"},"devDependencies":{"@codeceptjs/configure":"^0.5.2","@codeceptjs/examples":"^1.2.1","@codeceptjs/ui":"^0.3.8","codeceptjs":"^2.6.6","playwright":"^1.2.1"}}
1+
{
2+
"name": "create-codeceptjs",
3+
"version": "0.1.0",
4+
"description": "Install CodeceptJS with all its dependencies in a single run",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"codecept": "codeceptjs run --steps",
9+
"codecept:app": "codecept-ui --app",
10+
"codecept:server": "codecept-ui",
11+
"codecept:example": "codeceptjs run --steps -c node_modules/@codeceptjs/examples",
12+
"codecept:example:app": "codecept-ui --app -c node_modules/@codeceptjs/examples",
13+
"codecept:example:server": "codecept-ui -c node_modules/@codeceptjs/examples",
14+
"codecept:headless": "HEADLESS=true codeceptjs run --steps",
15+
"codecept:demo": "codeceptjs run --steps -c node_modules/@codeceptjs/examples",
16+
"codecept:demo:headless": "HEADLESS=true codeceptjs run --steps -c node_modules/@codeceptjs/examples",
17+
"codecept:demo:app": "codecept-ui --app -c node_modules/@codeceptjs/examples",
18+
"codecept:demo:server": "codecept-ui -c node_modules/@codeceptjs/examples"
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/codecept-js/create-codeceptjs.git"
23+
},
24+
"keywords": [
25+
"codeceptjs",
26+
"bdd",
27+
"installer",
28+
"e2e"
29+
],
30+
"author": "Michael Bodnarchuk",
31+
"license": "ISC",
32+
"bugs": {
33+
"url": "https://github.com/codecept-js/create-codeceptjs/issues"
34+
},
35+
"homepage": "https://github.com/codecept-js/create-codeceptjs#readme",
36+
"dependencies": {
37+
"cfonts": "^2.8.5",
38+
"chalk": "^4.1.0",
39+
"commander": "^5.1.0",
40+
"cross-spawn": "^7.0.3",
41+
"fs-extra": "^9.0.1",
42+
"semver": "^7.3.2"
43+
},
44+
"devDependencies": {
45+
"@codeceptjs/configure": "^0.5.2",
46+
"@codeceptjs/examples": "^1.2.1",
47+
"@codeceptjs/ui": "^0.3.8",
48+
"codeceptjs": "^2.6.6",
49+
"playwright": "^1.2.1"
50+
}
51+
}

0 commit comments

Comments
 (0)