|
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', |
@@ -456,61 +395,13 @@ async function docsHelperMarkdown(name, { parent, exclude = [], excludeConfig = |
456 | 395 | fs.writeFileSync(helperMarkDownFile(name), output) |
457 | 396 | } |
458 | 397 |
|
459 | | -/** |
460 | | - * Update the codecept.io website: regenerate changelog, sync wiki, push docs and publish. |
461 | | - */ |
462 | | -export async function publishSite() { |
463 | | - await processChangelog() |
464 | | - await wiki() |
465 | | - |
466 | | - const dir = 'website' |
467 | | - if (fs.existsSync(dir)) { |
468 | | - await shell`rm -rf ${dir}` |
469 | | - } |
470 | | - |
471 | | - await shell`git clone git@github.com:codeceptjs/website.git ${dir}` |
472 | | - copyFile('docs', 'website/docs') |
473 | | - |
474 | | - await shell`git add -A`.cwd(dir) |
475 | | - await shell`git commit -m "synchronized with docs"`.cwd(dir) |
476 | | - await shell`git pull`.cwd(dir) |
477 | | - await shell`git push`.cwd(dir) |
478 | | - await shell`./runok.js publish`.cwd(dir) |
479 | | -} |
480 | | - |
481 | 398 | /** |
482 | 399 | * Run the PHP test app and the REST test server together. Warning! PHP required! |
483 | 400 | */ |
484 | 401 | export async function server() { |
485 | 402 | await Promise.all([shell`php -S 127.0.0.1:8000 -t test/data/app`, testServer()]) |
486 | 403 | } |
487 | 404 |
|
488 | | -/** |
489 | | - * Release CodeceptJS to npm. Optionally bump package.json version first. |
490 | | - * @param {string} [releaseType] - "patch", "minor" or "major" to bump before releasing. |
491 | | - */ |
492 | | -export async function release(releaseType = null) { |
493 | | - task.stopOnFailures() |
494 | | - const packageInfo = JSON.parse(fs.readFileSync('package.json')) |
495 | | - if (releaseType) { |
496 | | - packageInfo.version = semver.inc(packageInfo.version, releaseType) |
497 | | - fs.writeFileSync('package.json', JSON.stringify(packageInfo)) |
498 | | - await shell`git add package.json` |
499 | | - await shell`git commit -m "version bump"` |
500 | | - } |
501 | | - const version = packageInfo.version |
502 | | - await docs() |
503 | | - await def() |
504 | | - await publishSite() |
505 | | - await shell`git pull` |
506 | | - await shell`git tag ${version}` |
507 | | - await shell`git push origin 3.x --tags` |
508 | | - await shell`rm -rf docs/wiki/.git` |
509 | | - await shell`npm publish` |
510 | | - say('-- RELEASED --') |
511 | | -} |
512 | | - |
513 | | - |
514 | 405 | /** |
515 | 406 | * Update the contributors table in README.md from the GitHub API. |
516 | 407 | */ |
@@ -569,7 +460,6 @@ export async function contributorFaces() { |
569 | 460 | } |
570 | 461 | } |
571 | 462 |
|
572 | | - |
573 | 463 | /** |
574 | 464 | * Scaffold a config, feature test and runner test for a new feature. |
575 | 465 | * @param {string} featureName - Name of the feature to scaffold tests for. |
@@ -633,28 +523,6 @@ describe('CodeceptJS ${featureName}', function () { |
633 | 523 | say(`npx mocha test/runner --grep ${featureName}`) |
634 | 524 | } |
635 | 525 |
|
636 | | -async function processChangelog() { |
637 | | - const file = 'CHANGELOG.md' |
638 | | - let changelog = fs.readFileSync(file).toString() |
639 | | - |
640 | | - changelog = changelog.replace(/\s@([\w-]+)/gm, ' **[$1](https://github.com/$1)**') |
641 | | - changelog = changelog.replace(/#(\d+)/gm, '[#$1](https://github.com/codeceptjs/CodeceptJS/issues/$1)') |
642 | | - changelog = changelog.replace(/\s\[(\w+)\]\s/gm, ' **[$1]** ') |
643 | | - |
644 | | - await writeToFile('docs/changelog.md', line => { |
645 | | - line`---` |
646 | | - line`permalink: /changelog` |
647 | | - line`title: Releases` |
648 | | - line`sidebar: false` |
649 | | - line`layout: Section` |
650 | | - line`---` |
651 | | - line`` |
652 | | - line`# Releases` |
653 | | - line`` |
654 | | - line`${changelog}` |
655 | | - }) |
656 | | -} |
657 | | - |
658 | 526 | /** |
659 | 527 | * Run the read-only REST test server on port 8010. |
660 | 528 | */ |
@@ -694,21 +562,21 @@ export async function graphql() { |
694 | 562 | * Lint the codebase with ESLint. |
695 | 563 | */ |
696 | 564 | export async function lint() { |
697 | | - await shell`eslint bin/ examples/ lib/ test/ translations/ runok.cjs` |
| 565 | + await shell`eslint bin/ examples/ lib/ test/ translations/ Bunoshfile.js` |
698 | 566 | } |
699 | 567 |
|
700 | 568 | /** |
701 | 569 | * Lint and auto-fix the codebase with ESLint. |
702 | 570 | */ |
703 | 571 | export async function lintFix() { |
704 | | - await shell`eslint bin/ examples/ lib/ test/ translations/ runok.cjs --fix` |
| 572 | + await shell`eslint bin/ examples/ lib/ test/ translations/ Bunoshfile.js --fix` |
705 | 573 | } |
706 | 574 |
|
707 | 575 | /** |
708 | 576 | * Format the codebase with Prettier. |
709 | 577 | */ |
710 | 578 | export async function prettier() { |
711 | | - await shell`prettier --config prettier.config.js --write bin/**/*.js lib/**/*.js test/**/*.js translations/**/*.js runok.cjs` |
| 579 | + await shell`prettier --config prettier.config.js --write bin/**/*.js lib/**/*.js test/**/*.js translations/**/*.js Bunoshfile.js` |
712 | 580 | } |
713 | 581 |
|
714 | 582 | /** |
@@ -858,7 +726,6 @@ export async function prepare() { |
858 | 726 | await shell`husky install` |
859 | 727 | } |
860 | 728 |
|
861 | | - |
862 | 729 | function replaceInFile(file, fn) { |
863 | 730 | let text = fs.readFileSync(file).toString() |
864 | 731 | fn({ |
|
0 commit comments