|
1 | 1 | import fs from 'node:fs' |
2 | 2 | import path from 'node:path' |
3 | | -import { execSync } from 'node:child_process' |
4 | 3 | import axios from 'axios' |
5 | | -import semver from 'semver' |
6 | 4 |
|
7 | 5 | const { shell, writeToFile, copyFile, task } = global.bunosh |
8 | 6 | const { say, yell } = global.bunosh |
@@ -47,7 +45,7 @@ export async function docsPlugins() { |
47 | 45 | task.stopOnFailures() |
48 | 46 | ensureDir('docs/plugins') |
49 | 47 |
|
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() |
51 | 49 |
|
52 | 50 | const sharedPartials = fs.readdirSync('docs/shared').filter(f => path.extname(f) === '.mustache') |
53 | 51 | const sharedPlaceholders = sharedPartials.map(file => `{{ ${path.basename(file, '.mustache')} }}`) |
@@ -90,7 +88,6 @@ editLink: false |
90 | 88 | sidebar: auto |
91 | 89 | title: ${name} |
92 | 90 | --- |
93 | | -
|
94 | 91 | ` |
95 | 92 | line.fromFile(pluginMarkDownFile(name)) |
96 | 93 | }) |
@@ -140,6 +137,14 @@ export async function docsExternalHelpers() { |
140 | 137 | cfg.replace(/string \| object/g, 'LocatorOrString') |
141 | 138 | }) |
142 | 139 |
|
| 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 | + |
143 | 148 | await writeToFile(helperMarkDownFile(helper), line => { |
144 | 149 | line`---\npermalink: /helpers/${helper}\nsidebar: auto\ntitle: ${helper}\n---\n\n# ${helper}\n\n` |
145 | 150 | line.fromFile(helperMarkDownFile(helper)) |
@@ -170,7 +175,7 @@ export async function docsExternalPlugins() { |
170 | 175 | */ |
171 | 176 | export async function buildLibWithDocs(forTypings = false) { |
172 | 177 | 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() |
174 | 179 | ensureDir('docs/build') |
175 | 180 |
|
176 | 181 | const partials = fs.readdirSync('docs/webapi').filter(f => path.extname(f) === '.mustache') |
@@ -229,7 +234,7 @@ export async function buildLibWithDocs(forTypings = false) { |
229 | 234 | */ |
230 | 235 | export async function docsHelpers() { |
231 | 236 | 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() |
233 | 238 | ensureDir('docs/build') |
234 | 239 |
|
235 | 240 | const ignoreList = ['Polly', 'MockRequest'] |
@@ -321,78 +326,12 @@ editLink: false |
321 | 326 | sidebar: auto |
322 | 327 | title: ${name} |
323 | 328 | --- |
324 | | -
|
325 | 329 | ` |
326 | 330 | line.fromFile(helperMarkDownFile(name)) |
327 | 331 | }) |
328 | 332 | } |
329 | 333 | } |
330 | 334 |
|
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 | | - |
396 | 335 | const inheritedHelperDocs = { |
397 | 336 | Appium: { |
398 | 337 | parent: 'WebDriver', |
@@ -457,61 +396,13 @@ async function docsHelperMarkdown(name, { parent, exclude = [], excludeConfig = |
457 | 396 | fs.writeFileSync(helperMarkDownFile(name), output) |
458 | 397 | } |
459 | 398 |
|
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 | | - |
482 | 399 | /** |
483 | 400 | * Run the PHP test app and the REST test server together. Warning! PHP required! |
484 | 401 | */ |
485 | 402 | export async function server() { |
486 | 403 | await Promise.all([shell`php -S 127.0.0.1:8000 -t test/data/app`, testServer()]) |
487 | 404 | } |
488 | 405 |
|
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 | | - |
515 | 406 | /** |
516 | 407 | * Update the contributors table in README.md from the GitHub API. |
517 | 408 | */ |
@@ -570,7 +461,6 @@ export async function contributorFaces() { |
570 | 461 | } |
571 | 462 | } |
572 | 463 |
|
573 | | - |
574 | 464 | /** |
575 | 465 | * Scaffold a config, feature test and runner test for a new feature. |
576 | 466 | * @param {string} featureName - Name of the feature to scaffold tests for. |
@@ -634,28 +524,6 @@ describe('CodeceptJS ${featureName}', function () { |
634 | 524 | say(`npx mocha test/runner --grep ${featureName}`) |
635 | 525 | } |
636 | 526 |
|
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 | | - |
659 | 527 | /** |
660 | 528 | * Run the read-only REST test server on port 8010. |
661 | 529 | */ |
@@ -695,21 +563,21 @@ export async function graphql() { |
695 | 563 | * Lint the codebase with ESLint. |
696 | 564 | */ |
697 | 565 | 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` |
699 | 567 | } |
700 | 568 |
|
701 | 569 | /** |
702 | 570 | * Lint and auto-fix the codebase with ESLint. |
703 | 571 | */ |
704 | 572 | 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` |
706 | 574 | } |
707 | 575 |
|
708 | 576 | /** |
709 | 577 | * Format the codebase with Prettier. |
710 | 578 | */ |
711 | 579 | 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` |
713 | 581 | } |
714 | 582 |
|
715 | 583 | /** |
@@ -859,7 +727,6 @@ export async function prepare() { |
859 | 727 | await shell`husky install` |
860 | 728 | } |
861 | 729 |
|
862 | | - |
863 | 730 | function replaceInFile(file, fn) { |
864 | 731 | let text = fs.readFileSync(file).toString() |
865 | 732 | fn({ |
|
0 commit comments