Skip to content

Commit ac3a74b

Browse files
committed
Merge branch '4.x' of https://github.com/codeceptjs/CodeceptJS into feat/moli-helper
2 parents a531ef6 + 1c2d9f3 commit ac3a74b

18 files changed

Lines changed: 1883 additions & 952 deletions

‎.github/workflows/doc-generation.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
with:
2727
node-version: ${{ matrix.node-version }}
2828

29+
- uses: oven-sh/setup-bun@v2
30+
2931
- name: Install Dependencies
3032
run: npm i --force
3133

‎.github/workflows/dtslint.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/setup-node@v6
2525
with:
2626
node-version: ${{ matrix.node-version }}
27+
- uses: oven-sh/setup-bun@v2
2728
- run: npm i --force
2829
env:
2930
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true

‎.github/workflows/publish-beta.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
node-version: 24
2323
registry-url: 'https://registry.npmjs.org'
2424

25+
- uses: oven-sh/setup-bun@v2
2526
- run: npm install
2627
- run: npm install -g npm@latest
2728

‎.github/workflows/test.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
uses: actions/setup-node@v6
9090
with:
9191
node-version: ${{ matrix.node-version }}
92+
- uses: oven-sh/setup-bun@v2
9293
- run: npm i
9394
env:
9495
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true

‎Bunoshfile.js‎

Lines changed: 14 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import fs from 'node:fs'
22
import path from 'node:path'
3-
import { execSync } from 'node:child_process'
43
import axios from 'axios'
5-
import semver from 'semver'
64

75
const { shell, writeToFile, copyFile, task } = global.bunosh
86
const { say, yell } = global.bunosh
@@ -47,7 +45,7 @@ export async function docsPlugins() {
4745
task.stopOnFailures()
4846
ensureDir('docs/plugins')
4947

50-
const files = fs.readdirSync('lib/plugin').filter(f => path.extname(f) === '.js')
48+
const files = fs.readdirSync('lib/plugin').filter(f => path.extname(f) === '.js').sort()
5149

5250
const sharedPartials = fs.readdirSync('docs/shared').filter(f => path.extname(f) === '.mustache')
5351
const sharedPlaceholders = sharedPartials.map(file => `{{ ${path.basename(file, '.mustache')} }}`)
@@ -90,7 +88,6 @@ editLink: false
9088
sidebar: auto
9189
title: ${name}
9290
---
93-
9491
`
9592
line.fromFile(pluginMarkDownFile(name))
9693
})
@@ -140,6 +137,14 @@ export async function docsExternalHelpers() {
140137
cfg.replace(/string \| object/g, 'LocatorOrString')
141138
})
142139

140+
say('Building @codeceptjs/mock-request')
141+
helper = 'MockRequest'
142+
replaceInFile('node_modules/@codeceptjs/mock-request/index.js', cfg => {
143+
cfg.replace(/CodeceptJS.LocatorOrString/g, 'string | object')
144+
cfg.replace(/LocatorOrString/g, 'string | object')
145+
})
146+
await shell`npx documentation build node_modules/@codeceptjs/mock-request/index.js -o ${helperMarkDownFile(helper)} ${documentjsCliArgs}`
147+
143148
await writeToFile(helperMarkDownFile(helper), line => {
144149
line`---\npermalink: /helpers/${helper}\nsidebar: auto\ntitle: ${helper}\n---\n\n# ${helper}\n\n`
145150
line.fromFile(helperMarkDownFile(helper))
@@ -170,7 +175,7 @@ export async function docsExternalPlugins() {
170175
*/
171176
export async function buildLibWithDocs(forTypings = false) {
172177
task.stopOnFailures()
173-
const files = fs.readdirSync('lib/helper').filter(f => path.extname(f) === '.js')
178+
const files = fs.readdirSync('lib/helper').filter(f => path.extname(f) === '.js').sort()
174179
ensureDir('docs/build')
175180

176181
const partials = fs.readdirSync('docs/webapi').filter(f => path.extname(f) === '.mustache')
@@ -229,7 +234,7 @@ export async function buildLibWithDocs(forTypings = false) {
229234
*/
230235
export async function docsHelpers() {
231236
task.stopOnFailures()
232-
const files = fs.readdirSync('lib/helper').filter(f => path.extname(f) === '.js')
237+
const files = fs.readdirSync('lib/helper').filter(f => path.extname(f) === '.js').sort()
233238
ensureDir('docs/build')
234239

235240
const ignoreList = ['Polly', 'MockRequest']
@@ -321,78 +326,12 @@ editLink: false
321326
sidebar: auto
322327
title: ${name}
323328
---
324-
325329
`
326330
line.fromFile(helperMarkDownFile(name))
327331
})
328332
}
329333
}
330334

331-
/**
332-
* Sync wiki pages from the CodeceptJS.wiki repo into website docs.
333-
*/
334-
export async function wiki() {
335-
task.stopOnFailures()
336-
if (!fs.existsSync('docs/wiki/Home.md')) {
337-
await shell`git clone git@github.com:codeceptjs/CodeceptJS.wiki.git docs/wiki`
338-
}
339-
await shell`git pull origin master`.cwd('docs/wiki')
340-
341-
await writeToFile('docs/community-helpers.md', line => {
342-
line`---`
343-
line`permalink: /community-helpers`
344-
line`title: Community Helpers`
345-
line`editLink: false`
346-
line`---`
347-
line``
348-
line`# Community Helpers`
349-
line`> Share your helpers at our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Community-Helpers)`
350-
line``
351-
line.fromFile('docs/wiki/Community-Helpers-&-Plugins.md')
352-
})
353-
354-
await writeToFile('docs/examples.md', line => {
355-
line`---`
356-
line`permalink: /examples`
357-
line`layout: Section`
358-
line`sidebar: false`
359-
line`title: Examples`
360-
line`editLink: false`
361-
line`---`
362-
line``
363-
line`# Examples`
364-
line`> Add your own examples to our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Examples)`
365-
line.fromFile('docs/wiki/Examples.md')
366-
})
367-
368-
await writeToFile('docs/books.md', line => {
369-
line`---`
370-
line`permalink: /books`
371-
line`layout: Section`
372-
line`sidebar: false`
373-
line`title: Books & Posts`
374-
line`editLink: false`
375-
line`---`
376-
line``
377-
line`# Books & Posts`
378-
line`> Add your own books or posts to our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Books-&-Posts)`
379-
line.fromFile('docs/wiki/Books-&-Posts.md')
380-
})
381-
382-
await writeToFile('docs/videos.md', line => {
383-
line`---`
384-
line`permalink: /videos`
385-
line`layout: Section`
386-
line`sidebar: false`
387-
line`title: Videos`
388-
line`editLink: false`
389-
line`---`
390-
line``
391-
line`> Add your own videos to our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Videos)`
392-
line.fromFile('docs/wiki/Videos.md')
393-
})
394-
}
395-
396335
const inheritedHelperDocs = {
397336
Appium: {
398337
parent: 'WebDriver',
@@ -457,61 +396,13 @@ async function docsHelperMarkdown(name, { parent, exclude = [], excludeConfig =
457396
fs.writeFileSync(helperMarkDownFile(name), output)
458397
}
459398

460-
/**
461-
* Update the codecept.io website: regenerate changelog, sync wiki, push docs and publish.
462-
*/
463-
export async function publishSite() {
464-
await processChangelog()
465-
await wiki()
466-
467-
const dir = 'website'
468-
if (fs.existsSync(dir)) {
469-
await shell`rm -rf ${dir}`
470-
}
471-
472-
await shell`git clone git@github.com:codeceptjs/website.git ${dir}`
473-
copyFile('docs', 'website/docs')
474-
475-
await shell`git add -A`.cwd(dir)
476-
await shell`git commit -m "synchronized with docs"`.cwd(dir)
477-
await shell`git pull`.cwd(dir)
478-
await shell`git push`.cwd(dir)
479-
await shell`./runok.js publish`.cwd(dir)
480-
}
481-
482399
/**
483400
* Run the PHP test app and the REST test server together. Warning! PHP required!
484401
*/
485402
export async function server() {
486403
await Promise.all([shell`php -S 127.0.0.1:8000 -t test/data/app`, testServer()])
487404
}
488405

489-
/**
490-
* Release CodeceptJS to npm. Optionally bump package.json version first.
491-
* @param {string} [releaseType] - "patch", "minor" or "major" to bump before releasing.
492-
*/
493-
export async function release(releaseType = null) {
494-
task.stopOnFailures()
495-
const packageInfo = JSON.parse(fs.readFileSync('package.json'))
496-
if (releaseType) {
497-
packageInfo.version = semver.inc(packageInfo.version, releaseType)
498-
fs.writeFileSync('package.json', JSON.stringify(packageInfo))
499-
await shell`git add package.json`
500-
await shell`git commit -m "version bump"`
501-
}
502-
const version = packageInfo.version
503-
await docs()
504-
await def()
505-
await publishSite()
506-
await shell`git pull`
507-
await shell`git tag ${version}`
508-
await shell`git push origin 3.x --tags`
509-
await shell`rm -rf docs/wiki/.git`
510-
await shell`npm publish`
511-
say('-- RELEASED --')
512-
}
513-
514-
515406
/**
516407
* Update the contributors table in README.md from the GitHub API.
517408
*/
@@ -570,7 +461,6 @@ export async function contributorFaces() {
570461
}
571462
}
572463

573-
574464
/**
575465
* Scaffold a config, feature test and runner test for a new feature.
576466
* @param {string} featureName - Name of the feature to scaffold tests for.
@@ -634,28 +524,6 @@ describe('CodeceptJS ${featureName}', function () {
634524
say(`npx mocha test/runner --grep ${featureName}`)
635525
}
636526

637-
async function processChangelog() {
638-
const file = 'CHANGELOG.md'
639-
let changelog = fs.readFileSync(file).toString()
640-
641-
changelog = changelog.replace(/\s@([\w-]+)/gm, ' **[$1](https://github.com/$1)**')
642-
changelog = changelog.replace(/#(\d+)/gm, '[#$1](https://github.com/codeceptjs/CodeceptJS/issues/$1)')
643-
changelog = changelog.replace(/\s\[(\w+)\]\s/gm, ' **[$1]** ')
644-
645-
await writeToFile('docs/changelog.md', line => {
646-
line`---`
647-
line`permalink: /changelog`
648-
line`title: Releases`
649-
line`sidebar: false`
650-
line`layout: Section`
651-
line`---`
652-
line``
653-
line`# Releases`
654-
line``
655-
line`${changelog}`
656-
})
657-
}
658-
659527
/**
660528
* Run the read-only REST test server on port 8010.
661529
*/
@@ -695,21 +563,21 @@ export async function graphql() {
695563
* Lint the codebase with ESLint.
696564
*/
697565
export async function lint() {
698-
await shell`eslint bin/ examples/ lib/ test/ translations/ runok.cjs`
566+
await shell`eslint bin/ examples/ lib/ test/ translations/ Bunoshfile.js`
699567
}
700568

701569
/**
702570
* Lint and auto-fix the codebase with ESLint.
703571
*/
704572
export async function lintFix() {
705-
await shell`eslint bin/ examples/ lib/ test/ translations/ runok.cjs --fix`
573+
await shell`eslint bin/ examples/ lib/ test/ translations/ Bunoshfile.js --fix`
706574
}
707575

708576
/**
709577
* Format the codebase with Prettier.
710578
*/
711579
export async function prettier() {
712-
await shell`prettier --config prettier.config.js --write bin/**/*.js lib/**/*.js test/**/*.js translations/**/*.js runok.cjs`
580+
await shell`prettier --config prettier.config.js --write bin/**/*.js lib/**/*.js test/**/*.js translations/**/*.js Bunoshfile.js`
713581
}
714582

715583
/**
@@ -859,7 +727,6 @@ export async function prepare() {
859727
await shell`husky install`
860728
}
861729

862-
863730
function replaceInFile(file, fn) {
864731
let text = fs.readFileSync(file).toString()
865732
fn({

0 commit comments

Comments
 (0)