Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime committed Apr 28, 2024
1 parent 20a95db commit d860ec3
Show file tree
Hide file tree
Showing 29 changed files with 289 additions and 147 deletions.
6 changes: 3 additions & 3 deletions dev/char-index.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

import { writeFile } from 'node:fs/promises';
import { cpus } from 'node:os';
import { Worker } from 'node:worker_threads';
import JScrewIt from '../lib/jscrewit.js';
import timeUtils from '../tools/time-utils.js';
import progress from './internal/progress.mjs';
import SolutionBookMap, { NICKNAME } from './internal/solution-book-map.mjs';
import chalk from 'chalk';
import { writeFile } from 'fs/promises';
import { cpus } from 'os';
import { Worker } from 'worker_threads';

async function doAdd()
{
Expand Down
2 changes: 1 addition & 1 deletion dev/internal/char-index-worker.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parentPort, workerData } from 'node:worker_threads';
import SolutionBookMap from './solution-book-map.mjs';
import { parentPort, workerData } from 'worker_threads';

const { char, SolutionBookMap: serializedSolutionBookMap } = workerData;
serializedSolutionBookMap.delete(char);
Expand Down
2 changes: 1 addition & 1 deletion dev/internal/choose.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { basename } from 'node:path';
import { formatDuration, timeThis } from '../../tools/time-utils.js';
import inquirer from 'inquirer';
import { basename } from 'path';

function compareChoices(choice1, choice2)
{
Expand Down
40 changes: 40 additions & 0 deletions dev/internal/gherkin-parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';

const { AstBuilder, GherkinClassicTokenMatcher, Parser } = require('@cucumber/gherkin');

function createGherkinParser(options)
{
const builder = new AstBuilder(String);
const tokenMatcher = new GherkinClassicTokenMatcher(options.defaultDialectName);
const parser = new Parser(builder, tokenMatcher);
return parser;
}

module.exports =
{
parse(text, options)
{
const parser = createGherkinParser(options);
try
{
const ast = parser.parse(text);
ast.body = [];
ast.loc = { };
ast.range = [,,];
ast.tokens = [];
ast.type = 'Program';
return ast;
}
catch (error)
{
const [subError] = error.errors;
if (subError)
{
const { location } = subError;
error.lineNumber = location.line;
error.column = location.column;
}
throw error;
}
},
};
32 changes: 20 additions & 12 deletions dev/internal/package-utils.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { rm } from 'fs/promises';
import { createRequire } from 'module';
import { isAbsolute, join, relative, resolve } from 'path';
import { fileURLToPath } from 'url';
import { rm } from 'node:fs/promises';
import { createRequire } from 'node:module';
import { isAbsolute, join, relative, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

async function bundle(inputOptions, outputOptions)
{
Expand Down Expand Up @@ -104,10 +104,7 @@ async function compileTS(pkgPath, source, newOptions, writeFile)

export async function doMakeBrowserSpecRunner(pkgURL)
{
const [{ default: rollupPluginNodeBuiltins }, { default: rollupPluginNodeGlobals }] =
await
Promise.all([import('rollup-plugin-node-builtins'), import('rollup-plugin-node-globals')]);

const { default: rollupPluginPolyfillNode } = await import('rollup-plugin-polyfill-node');
const pkgPath = fileURLToPath(pkgURL);
{
const outDir = join(pkgPath, '.tmp-out');
Expand All @@ -123,7 +120,7 @@ export async function doMakeBrowserSpecRunner(pkgURL)
if (warning.code !== 'THIS_IS_UNDEFINED')
console.error(warning.message);
};
const plugins = [rollupPluginNodeBuiltins(), rollupPluginNodeGlobals({ buffer: false })];
const plugins = [rollupPluginPolyfillNode()];
const inputOptions = { input: inputPath, onwarn, plugins };
const outputPath = join(pkgPath, 'test/browser-spec-runner.js');
const outputOptions = { esModule: false, file: outputPath, format: 'iife' };
Expand Down Expand Up @@ -157,9 +154,20 @@ function getWriteFile(sysWriteFile, declarationDir, dTsFilter)
return writeFile;
}

export async function lintPackage(...configs)
export async function lintPackage(...configData)
{
const { lint } = await import('@fasttime/lint');
const { createConfig } = await import('@origin-1/eslint-config');
const { default: { FlatESLint } } = await import('eslint/use-at-your-own-risk');

await lint(...configs);
const overrideConfig = await createConfig(...configData);
const eslint = new FlatESLint({ overrideConfig, overrideConfigFile: true });
const results = await eslint.lintFiles('.');
const formatter = await eslint.loadFormatter('compact');
const output = await formatter.format(results);
if (output)
{
console.error(output);
const error = 'Lint failed.';
throw error;
}
}
10 changes: 5 additions & 5 deletions dev/internal/prepare-package-legacy-test.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fork, spawn } from 'child_process';
import { mkdir, rm, writeFile } from 'fs/promises';
import { createRequire } from 'module';
import { EOL } from 'os';
import { join } from 'path';
import { fork, spawn } from 'node:child_process';
import { mkdir, rm, writeFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
import { EOL } from 'node:os';
import { join } from 'node:path';

const NODE_LEGACY_DIR = 'test/node-legacy';

Expand Down
2 changes: 1 addition & 1 deletion dev/internal/solution-book-map.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const NICKNAME = 'jscrewit';
const TYPE_KEY = '__type';
const TYPE_VALUE_SOLUTION = 'Solution';

import fs from 'node:fs';
import Analyzer from './optimized-analyzer.mjs';
import SortedMap from './sorted-map.js';
import chalk from 'chalk';
import fs from 'fs';

const mainURL = new URL('../../lib/jscrewit.js', import.meta.url);
const charMapRoot = new URL(`../../.${NICKNAME}.char-map.json`, import.meta.url);
Expand Down
2 changes: 2 additions & 0 deletions dev/make-feature-doc.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global Intl */

import { Feature } from '../lib/jscrewit.js';
import { getAvailabilityByFeature, getDescription } from './internal/engine-data.mjs';

Expand Down
2 changes: 2 additions & 0 deletions dev/make-feature-types.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global Intl */

import { Feature } from '../lib/jscrewit.js';

import { calculateAvailabilityInfo, getAvailabilityByFeature, getDescription }
Expand Down
165 changes: 109 additions & 56 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const { dest, parallel, series, src, task } = require('gulp');
const syncReadable = require('sync-readable');

async function bundle(inputOptions, outputFile, banner)
{
Expand Down Expand Up @@ -33,7 +34,7 @@ async function bundleUI()

async function createFileFromTemplate(createContextModuleId, templateSrcPath, outputPath)
{
const { writeFile } = require('fs/promises');
const { writeFile } = require('node:fs/promises');
const Handlebars = require('handlebars');

const promises = [import(createContextModuleId), readFileAsString(templateSrcPath)];
Expand Down Expand Up @@ -76,7 +77,7 @@ function makeWorker()

function readFileAsString(inputPath)
{
const { readFile } = require('fs/promises');
const { readFile } = require('node:fs/promises');

const promise = readFile(inputPath, 'utf8');
return promise;
Expand Down Expand Up @@ -108,61 +109,112 @@ task
task
(
'lint',
async () =>
{
const { lint } = require('@fasttime/lint');
syncReadable
(
async () =>
{
const gherkinParser = require('./dev/internal/gherkin-parser');
const { createConfig, noParserConfig } = require('@origin-1/eslint-config');
const eslintPluginEBDD = require('eslint-plugin-ebdd');
const { EslintEnvProcessor } = require('eslint-plugin-eslint-env');
const globals = require('globals');
const gulpESLintNew = require('gulp-eslint-new');

await
lint
(
{
src: ['src/**/*.js', '!src/ui/worker.js'],
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
rules:
const ebddPlugins = { ebdd: eslintPluginEBDD };

const overrideConfig =
await createConfig
(
noParserConfig,
{
'lines-around-comment':
[
'error',
{
allowBlockStart: true,
allowObjectStart: true,
ignorePattern: '^\\s*c8 ignore next\\b',
},
],
files: ['src/**/*.js'],
ignores: ['src/ui/worker.js'],
jsVersion: 5,
languageOptions: { ecmaVersion: 2015 },
processor: new EslintEnvProcessor(),
rules:
{
'lines-around-comment':
[
'error',
{
allowBlockStart: true,
allowObjectStart: true,
ignorePattern: '^\\s*c8 ignore next\\b',
},
],
},
},
},
{
src:
['dev/**/*.js', 'gulpfile.js', 'test/patch-cov-source.js', '!dev/legacy/**'],
jsVersion: 2022,
envs: 'node',
},
{
src: ['dev/**/*.mjs'],
jsVersion: 2022,
envs: 'node',
parserOptions: { sourceType: 'module' },
},
{
src: ['dev/legacy/**/*.js', 'screw.js', 'src/ui/worker.js', 'tools/**/*.js'],
rules:
{
// process.exitCode is not supported in Node.js 0.10.
'no-process-exit': 'off',
files: ['dev/**/*.js', 'gulpfile.js', 'test/patch-cov-source.js'],
ignores: ['dev/legacy'],
jsVersion: 2022,
languageOptions: { globals: globals.node, sourceType: 'commonjs' },
},
},
{
src: ['test/**/*.js', '!test/patch-cov-source.js'],
plugins: ['ebdd'],
rules: { '@origin-1/no-extra-new': 'off' },
},
{
src: ['lib/**/*.ts', '!lib/feature-all.d.ts'],
parserOptions: { project: 'tsconfig.json' },
},
{ src: 'test/acceptance/**/*.feature' },
);
},
{
files: ['dev/**/*.mjs'],
jsVersion: 2022,
languageOptions: { globals: globals.node },
},
{
files:
['dev/legacy/**/*.js', 'screw.js', 'src/ui/worker.js', 'tools/**/*.js'],
jsVersion: 5,
languageOptions: { sourceType: 'commonjs' },
processor: new EslintEnvProcessor(),
rules:
{
// process.exitCode is not supported in Node.js 0.10.
'no-process-exit': 'off',
},
},
{
files: ['test/**/*.js'],
jsVersion: 5,
ignores: ['test/patch-cov-source.js'],
languageOptions: { sourceType: 'script' },
plugins: ebddPlugins,
processor: new EslintEnvProcessor({ plugins: ebddPlugins }),
rules: { '@origin-1/no-extra-new': 'off' },
},
{
files: ['lib/**/*.ts'],
ignores: ['lib/feature-all.d.ts'],
tsVersion: 'latest',
languageOptions: { parserOptions: { project: 'tsconfig.json' } },
},
{
files: ['test/acceptance/**/*.feature'],
languageOptions: { parser: gherkinParser },
},
);
const stream =
src
(
[
'*.js',
'{dev,src,test}/**/*.{feature,js,mjs,ts}',
'lib/**/*.ts',
'!lib/feature-all.d.ts',
],
)
.pipe
(
gulpESLintNew
(
{
configType: 'flat',
overrideConfig,
overrideConfigFile: true,
warnIgnored: true,
},
),
)
.pipe(gulpESLintNew.format('compact'))
.pipe(gulpESLintNew.failAfterError());
return stream;
},
),
);

task
Expand Down Expand Up @@ -305,8 +357,8 @@ task
'make-spec-runner',
async () =>
{
const { writeFile } = require('node:fs/promises');
const { glob } = require('glob');
const { writeFile } = require('fs/promises');
const Handlebars = require('handlebars');

async function getSpecs()
Expand Down Expand Up @@ -334,10 +386,10 @@ task
'make-workflows',
async () =>
{
const { writeFile } = require('fs/promises');
const { writeFile } = require('node:fs/promises');
const { join } = require('node:path');
const { glob } = require('glob');
const Handlebars = require('handlebars');
const { join } = require('path');

async function getTemplate()
{
Expand Down Expand Up @@ -365,7 +417,8 @@ task
'default',
series
(
parallel('clean', 'lint'),
'clean',
'lint',
parallel('bundle:lib', 'bundle:ui'),
'test',
parallel
Expand Down
Loading

0 comments on commit d860ec3

Please sign in to comment.