Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/doc-generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- uses: oven-sh/setup-bun@v2

- name: Install Dependencies
run: npm i --force

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dtslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- uses: oven-sh/setup-bun@v2
- run: npm i --force
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
node-version: 24
registry-url: 'https://registry.npmjs.org'

- uses: oven-sh/setup-bun@v2
- run: npm install
- run: npm install -g npm@latest

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- uses: oven-sh/setup-bun@v2
- run: npm i
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
Expand Down
161 changes: 14 additions & 147 deletions Bunoshfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import fs from 'node:fs'
import path from 'node:path'
import { execSync } from 'node:child_process'
import axios from 'axios'
import semver from 'semver'

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

const files = fs.readdirSync('lib/plugin').filter(f => path.extname(f) === '.js')
const files = fs.readdirSync('lib/plugin').filter(f => path.extname(f) === '.js').sort()

const sharedPartials = fs.readdirSync('docs/shared').filter(f => path.extname(f) === '.mustache')
const sharedPlaceholders = sharedPartials.map(file => `{{ ${path.basename(file, '.mustache')} }}`)
Expand Down Expand Up @@ -90,7 +88,6 @@ editLink: false
sidebar: auto
title: ${name}
---

`
line.fromFile(pluginMarkDownFile(name))
})
Expand Down Expand Up @@ -140,6 +137,14 @@ export async function docsExternalHelpers() {
cfg.replace(/string \| object/g, 'LocatorOrString')
})

say('Building @codeceptjs/mock-request')
helper = 'MockRequest'
replaceInFile('node_modules/@codeceptjs/mock-request/index.js', cfg => {
cfg.replace(/CodeceptJS.LocatorOrString/g, 'string | object')
cfg.replace(/LocatorOrString/g, 'string | object')
})
await shell`npx documentation build node_modules/@codeceptjs/mock-request/index.js -o ${helperMarkDownFile(helper)} ${documentjsCliArgs}`

await writeToFile(helperMarkDownFile(helper), line => {
line`---\npermalink: /helpers/${helper}\nsidebar: auto\ntitle: ${helper}\n---\n\n# ${helper}\n\n`
line.fromFile(helperMarkDownFile(helper))
Expand Down Expand Up @@ -170,7 +175,7 @@ export async function docsExternalPlugins() {
*/
export async function buildLibWithDocs(forTypings = false) {
task.stopOnFailures()
const files = fs.readdirSync('lib/helper').filter(f => path.extname(f) === '.js')
const files = fs.readdirSync('lib/helper').filter(f => path.extname(f) === '.js').sort()
ensureDir('docs/build')

const partials = fs.readdirSync('docs/webapi').filter(f => path.extname(f) === '.mustache')
Expand Down Expand Up @@ -229,7 +234,7 @@ export async function buildLibWithDocs(forTypings = false) {
*/
export async function docsHelpers() {
task.stopOnFailures()
const files = fs.readdirSync('lib/helper').filter(f => path.extname(f) === '.js')
const files = fs.readdirSync('lib/helper').filter(f => path.extname(f) === '.js').sort()
ensureDir('docs/build')

const ignoreList = ['Polly', 'MockRequest']
Expand Down Expand Up @@ -321,78 +326,12 @@ editLink: false
sidebar: auto
title: ${name}
---

`
line.fromFile(helperMarkDownFile(name))
})
}
}

/**
* Sync wiki pages from the CodeceptJS.wiki repo into website docs.
*/
export async function wiki() {
task.stopOnFailures()
if (!fs.existsSync('docs/wiki/Home.md')) {
await shell`git clone git@github.com:codeceptjs/CodeceptJS.wiki.git docs/wiki`
}
await shell`git pull origin master`.cwd('docs/wiki')

await writeToFile('docs/community-helpers.md', line => {
line`---`
line`permalink: /community-helpers`
line`title: Community Helpers`
line`editLink: false`
line`---`
line``
line`# Community Helpers`
line`> Share your helpers at our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Community-Helpers)`
line``
line.fromFile('docs/wiki/Community-Helpers-&-Plugins.md')
})

await writeToFile('docs/examples.md', line => {
line`---`
line`permalink: /examples`
line`layout: Section`
line`sidebar: false`
line`title: Examples`
line`editLink: false`
line`---`
line``
line`# Examples`
line`> Add your own examples to our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Examples)`
line.fromFile('docs/wiki/Examples.md')
})

await writeToFile('docs/books.md', line => {
line`---`
line`permalink: /books`
line`layout: Section`
line`sidebar: false`
line`title: Books & Posts`
line`editLink: false`
line`---`
line``
line`# Books & Posts`
line`> Add your own books or posts to our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Books-&-Posts)`
line.fromFile('docs/wiki/Books-&-Posts.md')
})

await writeToFile('docs/videos.md', line => {
line`---`
line`permalink: /videos`
line`layout: Section`
line`sidebar: false`
line`title: Videos`
line`editLink: false`
line`---`
line``
line`> Add your own videos to our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Videos)`
line.fromFile('docs/wiki/Videos.md')
})
}

const inheritedHelperDocs = {
Appium: {
parent: 'WebDriver',
Expand Down Expand Up @@ -456,61 +395,13 @@ async function docsHelperMarkdown(name, { parent, exclude = [], excludeConfig =
fs.writeFileSync(helperMarkDownFile(name), output)
}

/**
* Update the codecept.io website: regenerate changelog, sync wiki, push docs and publish.
*/
export async function publishSite() {
await processChangelog()
await wiki()

const dir = 'website'
if (fs.existsSync(dir)) {
await shell`rm -rf ${dir}`
}

await shell`git clone git@github.com:codeceptjs/website.git ${dir}`
copyFile('docs', 'website/docs')

await shell`git add -A`.cwd(dir)
await shell`git commit -m "synchronized with docs"`.cwd(dir)
await shell`git pull`.cwd(dir)
await shell`git push`.cwd(dir)
await shell`./runok.js publish`.cwd(dir)
}

/**
* Run the PHP test app and the REST test server together. Warning! PHP required!
*/
export async function server() {
await Promise.all([shell`php -S 127.0.0.1:8000 -t test/data/app`, testServer()])
}

/**
* Release CodeceptJS to npm. Optionally bump package.json version first.
* @param {string} [releaseType] - "patch", "minor" or "major" to bump before releasing.
*/
export async function release(releaseType = null) {
task.stopOnFailures()
const packageInfo = JSON.parse(fs.readFileSync('package.json'))
if (releaseType) {
packageInfo.version = semver.inc(packageInfo.version, releaseType)
fs.writeFileSync('package.json', JSON.stringify(packageInfo))
await shell`git add package.json`
await shell`git commit -m "version bump"`
}
const version = packageInfo.version
await docs()
await def()
await publishSite()
await shell`git pull`
await shell`git tag ${version}`
await shell`git push origin 3.x --tags`
await shell`rm -rf docs/wiki/.git`
await shell`npm publish`
say('-- RELEASED --')
}


/**
* Update the contributors table in README.md from the GitHub API.
*/
Expand Down Expand Up @@ -569,7 +460,6 @@ export async function contributorFaces() {
}
}


/**
* Scaffold a config, feature test and runner test for a new feature.
* @param {string} featureName - Name of the feature to scaffold tests for.
Expand Down Expand Up @@ -633,28 +523,6 @@ describe('CodeceptJS ${featureName}', function () {
say(`npx mocha test/runner --grep ${featureName}`)
}

async function processChangelog() {
const file = 'CHANGELOG.md'
let changelog = fs.readFileSync(file).toString()

changelog = changelog.replace(/\s@([\w-]+)/gm, ' **[$1](https://github.com/$1)**')
changelog = changelog.replace(/#(\d+)/gm, '[#$1](https://github.com/codeceptjs/CodeceptJS/issues/$1)')
changelog = changelog.replace(/\s\[(\w+)\]\s/gm, ' **[$1]** ')

await writeToFile('docs/changelog.md', line => {
line`---`
line`permalink: /changelog`
line`title: Releases`
line`sidebar: false`
line`layout: Section`
line`---`
line``
line`# Releases`
line``
line`${changelog}`
})
}

/**
* Run the read-only REST test server on port 8010.
*/
Expand Down Expand Up @@ -694,21 +562,21 @@ export async function graphql() {
* Lint the codebase with ESLint.
*/
export async function lint() {
await shell`eslint bin/ examples/ lib/ test/ translations/ runok.cjs`
await shell`eslint bin/ examples/ lib/ test/ translations/ Bunoshfile.js`
}

/**
* Lint and auto-fix the codebase with ESLint.
*/
export async function lintFix() {
await shell`eslint bin/ examples/ lib/ test/ translations/ runok.cjs --fix`
await shell`eslint bin/ examples/ lib/ test/ translations/ Bunoshfile.js --fix`
}

/**
* Format the codebase with Prettier.
*/
export async function prettier() {
await shell`prettier --config prettier.config.js --write bin/**/*.js lib/**/*.js test/**/*.js translations/**/*.js runok.cjs`
await shell`prettier --config prettier.config.js --write bin/**/*.js lib/**/*.js test/**/*.js translations/**/*.js Bunoshfile.js`
}

/**
Expand Down Expand Up @@ -858,7 +726,6 @@ export async function prepare() {
await shell`husky install`
}


function replaceInFile(file, fn) {
let text = fs.readFileSync(file).toString()
fn({
Expand Down
Loading
Loading