Skip to content

Commit

Permalink
feat: Remove support for cspell commonjs interface (#4415)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Apr 20, 2023
1 parent b99423c commit 0c27db0
Show file tree
Hide file tree
Showing 23 changed files with 498 additions and 485 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Expand Up @@ -53,7 +53,7 @@ jobs:
- run: pnpm run coverage

- name: Upload coverage Coveralls
uses: coverallsapp/github-action@50c33ad324a9902697adbf2f92c22cf5023eacf1 # 1.2.4
uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d # 2.1.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./lcov.info
Expand Down
5 changes: 0 additions & 5 deletions bin.js

This file was deleted.

2 changes: 1 addition & 1 deletion integration-tests/.vscode/launch.json
Expand Up @@ -6,7 +6,7 @@
"configurations": [
{
"name": "Launch Program",
"program": "${workspaceFolder}/../bin.js",
"program": "${workspaceFolder}/../bin.mjs",
"request": "launch",
"cwd": "${workspaceFolder}/repositories/temp/TheAlgorithms/Python",
"console": "integratedTerminal",
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/check.ts
Expand Up @@ -15,7 +15,7 @@ import type { Logger } from './types';
const config = readConfig();
const cspellArgs =
'-u --no-progress --relative --show-context --gitignore --gitignore-root=. --reporter=default --reporter=${pathReporter}';
const jsCspell = JSON.stringify(Path.resolve(__dirname, '..', '..', 'bin.js'));
const jsCspell = JSON.stringify(Path.resolve(__dirname, '../../bin.mjs'));

const cspellCommand = `node ${jsCspell}`;

Expand Down
15 changes: 7 additions & 8 deletions package.json
Expand Up @@ -2,9 +2,8 @@
"name": "cspell-monorepo",
"version": "1.0.0",
"description": "cspell monorepo.",
"main": "bin.js",
"bin": {
"cspell-monorepo": "bin.js",
"cspell-monorepo": "bin.mjs",
"cspell-monorepo-esm": "bin.mjs"
},
"packageManager": "pnpm@8.1.0",
Expand Down Expand Up @@ -43,12 +42,12 @@
"test": "pnpm -r --stream --workspace-concurrency=1 run test && pnpm run test-schema",
"test:update-snapshots": "pnpm run -r test:update-snapshot",
"test:bin": "pnpm test:bin-spell && pnpm test:bin-spell-cache-content && pnpm test:bin-spell-cache-metadata && pnpm test:bin-trace && pnpm test:bin-check && pnpm test:bin-spell-yarn",
"test:bin-check": "node ./bin.js check README.md",
"test:bin-spell": "node ./bin.js -c cspell.test.json --no-progress",
"test:bin-spell-yarn": "node ./bin.js -c cspell.test.yarn.json --no-progress",
"test:bin-spell-cache-content": "node ./bin.js -c cspell.test.json --cache --cache-strategy content --cache-location temp/.cspellcache-content",
"test:bin-spell-cache-metadata": "node ./bin.js -c cspell.test.json --cache --cache-strategy metadata --cache-location temp/.cspellcache-meta",
"test:bin-trace": "node ./bin.js trace test",
"test:bin-check": "node ./bin.mjs check README.md",
"test:bin-spell": "node ./bin.mjs -c cspell.test.json --no-progress",
"test:bin-spell-yarn": "node ./bin.mjs -c cspell.test.yarn.json --no-progress",
"test:bin-spell-cache-content": "node ./bin.mjs -c cspell.test.json --cache --cache-strategy content --cache-location temp/.cspellcache-content",
"test:bin-spell-cache-metadata": "node ./bin.mjs -c cspell.test.json --cache --cache-strategy metadata --cache-location temp/.cspellcache-meta",
"test:bin-trace": "node ./bin.mjs trace test",
"test-build-docs": "cd doc-generator && pnpm i && pnpm run test-build-docs",
"test-integrations": "cd ./integration-tests && pnpm run integration-tests",
"test-schema": "ajv -s ./cspell.schema.json -d cspell.json -c ./packages/cspell-types/ajv.config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-bundled-dicts/package.json
Expand Up @@ -23,7 +23,7 @@
"clean": "echo clean",
"clean-build": "pnpm run clean && pnpm run build",
"watch": "pnpm run build --watch",
"test": "node ../../bin.js \"**/*.{txt,md,ts}\"",
"test": "node ../../bin.mjs \"**/*.{txt,md,ts}\"",
"update-fix-en-gb": "pnpm add @cspell/dict-en-gb@1.1.33",
"update-dictionaries": "pnpm update --latest \"@cspell/dict-*\" && pnpm run update-fix-en-gb"
},
Expand Down
68 changes: 16 additions & 52 deletions packages/cspell/.vscode/launch.json
Expand Up @@ -8,41 +8,41 @@
"type": "node",
"request": "launch",
"name": "cspell: Run",
"program": "${workspaceRoot}/bin.js",
"program": "${workspaceRoot}/bin.mjs",
"args": ["--cache", "--no-progress", "**"],
"cwd": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"outFiles": ["${workspaceRoot}/dist/**"],
"sourceMaps": true
},
{
"type": "node",
"request": "launch",
"name": "cspell: Run no args",
"program": "${workspaceRoot}/bin.js",
"program": "${workspaceRoot}/bin.mjs",
"args": [],
"cwd": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"outFiles": ["${workspaceRoot}/dist/**"],
"sourceMaps": true
},
{
"type": "node",
"request": "launch",
"name": "cspell: Run CSpell against current file",
"program": "${workspaceRoot}/bin.js",
"program": "${workspaceRoot}/bin.mjs",
"args": ["-v", "${file}"],
"cwd": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"outFiles": ["${workspaceRoot}/dist/**"],
"sourceMaps": true,
"preLaunchTask": "npm: build"
},
{
"type": "node",
"request": "launch",
"name": "cspell: Run CSpell against stdin",
"program": "${workspaceRoot}/bin.js",
"program": "${workspaceRoot}/bin.mjs",
"args": ["-v", "stdin"],
"cwd": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"outFiles": ["${workspaceRoot}/dist/**"],
"sourceMaps": true,
"preLaunchTask": "npm: build",
"console": "integratedTerminal"
Expand All @@ -51,82 +51,46 @@
"type": "node",
"request": "launch",
"name": "cspell: Run Trace",
"program": "${workspaceRoot}/bin.js",
"program": "${workspaceRoot}/bin.mjs",
"args": ["trace", "about"],
"cwd": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"outFiles": ["${workspaceRoot}/dist/**"],
"sourceMaps": true
},
{
"type": "node",
"request": "launch",
"name": "cspell: Run Check",
"program": "${workspaceRoot}/bin.js",
"program": "${workspaceRoot}/bin.mjs",
"args": [
"check",
"--config",
"${workspaceRoot}/samples/.cspell.json",
"${workspaceRoot}/samples/src/sample.c"
],
"cwd": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"outFiles": ["${workspaceRoot}/dist/**"],
"sourceMaps": true
},
{
"type": "node",
"request": "launch",
"name": "cspell: Run Link",
"program": "${workspaceRoot}/bin.js",
"program": "${workspaceRoot}/bin.mjs",
"args": ["link"],
"cwd": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"outFiles": ["${workspaceRoot}/dist/**"],
"sourceMaps": true
},
{
"type": "node",
"request": "launch",
"name": "cspell: Run Link Add",
"program": "${workspaceRoot}/bin.js",
"program": "${workspaceRoot}/bin.mjs",
"args": ["link", "add", "cspell-dict-nl-nl/cspell-ext.json"],
"cwd": "${workspaceRoot}/../cspell-lib",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"outFiles": ["${workspaceRoot}/dist/**"],
"sourceMaps": true
},
{
"type": "node",
"request": "launch",
"name": "cspell: Run bad glob",
"program": "${workspaceRoot}/dist/app.js",
"args": ["-v", "src", "**/*.test.ts"],
"cwd": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"sourceMaps": true
},
{
"type": "node",
"request": "launch",
"name": "cspell: Jest current-file",
"program": "${workspaceFolder}/../../node_modules/jest/bin/jest.js",
"args": ["--runInBand", "${file}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/../../node_modules/jest/bin/jest"
}
},
{
"type": "node",
"request": "launch",
"name": "cspell: Jest All",
"program": "${workspaceFolder}/../../node_modules/jest/bin/jest.js",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/../../node_modules/jest/bin/jest"
}
}
]
}
16 changes: 0 additions & 16 deletions packages/cspell/bin.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/cspell/fixtures/issue-2998/run.sh
@@ -1,3 +1,3 @@
../../bin.js -v --language-id=fix fix-words.txt
../../bin.mjs -v --language-id=fix fix-words.txt

cat fix-words.txt | ../../bin.js -v --language-id=fix "--locale=*" stdin
cat fix-words.txt | ../../bin.mjs -v --language-id=fix "--locale=*" stdin
39 changes: 17 additions & 22 deletions packages/cspell/package.json
Expand Up @@ -4,33 +4,30 @@
"description": "A Spelling Checker for Code!",
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
"bin": {
"cspell": "bin.js",
"cspell": "bin.mjs",
"cspell-esm": "bin.mjs"
},
"type": "commonjs",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"type": "module",
"types": "dist/esm/index.d.mts",
"module": "dist/esm/index.mjs",
"exports": {
".": {
"import": "./dist/esm/index.mjs",
"require": "./dist/cjs/index.js"
"import": "./dist/esm/index.mjs"
},
"./app": {
"import": "./dist/esm/app.mjs",
"require": "./dist/cjs/app.js"
"import": "./dist/esm/app.mjs"
},
"./bin": {
"import": "./bin.mjs",
"require": "./bin.js"
"import": "./bin.mjs"
},
"./bin.mjs": {
"import": "./bin.mjs"
},
"./application": {
"import": "./dist/esm/application.mjs",
"require": "./dist/cjs/application.js"
"import": "./dist/esm/application.mjs"
}
},
"files": [
"bin.js",
"bin.mjs",
"dist",
"!dist/esm/**/*.js",
Expand All @@ -46,14 +43,13 @@
"clean": "shx rm -rf dist coverage temp .tsbuildinfo",
"build": "tsc -b . && ts2mjs dist/esm && pnpm run build:api",
"build:api": "rollup -c rollup.config.mjs",
"build:cjs": "tsc -b tsconfig.cjs.json",
"build:esm": "tsc -b tsconfig.esm.json",
"build:esm:ts2mjs": "tsc -b tsconfig.esm.json && ts2mjs dist/esm",
"build:lib": "tsc -b src/lib/tsconfig.json",
"build:readme": "pnpm build:readme:help",
"build:readme:help": "pnpm build:readme:help:lint && pnpm build:readme:help:trace && inject-markdown README.md && prettier -w README.md",
"build:readme:help:lint": "./bin.js lint --help > static/help-lint.txt",
"build:readme:help:trace": "./bin.js trace --help > static/help-trace.txt",
"build:readme:help:lint": "./bin.mjs lint --help > static/help-lint.txt",
"build:readme:help:trace": "./bin.mjs trace --help > static/help-trace.txt",
"clean-build": "pnpm run clean && pnpm run build",
"coverage": "pnpm coverage:vitest && pnpm coverage:fix",
"coverage:vitest": "vitest run --coverage",
Expand Down Expand Up @@ -90,7 +86,8 @@
"dependencies": {
"@cspell/cspell-pipe": "workspace:*",
"@cspell/dynamic-import": "workspace:*",
"chalk": "^4.1.2",
"chalk": "^5.2.0",
"chalk-template": "^1.0.0",
"commander": "^10.0.1",
"cspell-gitignore": "workspace:*",
"cspell-glob": "workspace:*",
Expand All @@ -99,10 +96,9 @@
"fast-glob": "^3.2.12",
"fast-json-stable-stringify": "^2.1.0",
"file-entry-cache": "^6.0.1",
"get-stdin": "^8.0.0",
"imurmurhash": "^0.1.4",
"get-stdin": "^9.0.0",
"semver": "^7.5.0",
"strip-ansi": "^6.0.1",
"strip-ansi": "^7.0.1",
"vscode-uri": "^3.0.7"
},
"engines": {
Expand All @@ -113,10 +109,9 @@
"@cspell/cspell-types": "workspace:*",
"@types/file-entry-cache": "^5.0.2",
"@types/glob": "^8.1.0",
"@types/imurmurhash": "^0.1.1",
"@types/micromatch": "^4.0.2",
"@types/semver": "^7.3.13",
"micromatch": "^4.0.5",
"minimatch": "^7.4.6"
"minimatch": "^9.0.0"
}
}
6 changes: 3 additions & 3 deletions packages/cspell/rollup.config.mjs
Expand Up @@ -2,17 +2,17 @@ import dts from 'rollup-plugin-dts';

const config = [
{
input: './dist/cjs/index.d.ts',
input: './dist/esm/index.d.mts',
output: [{ file: './api/index.d.ts', format: 'es' }],
plugins: [dts()],
},
{
input: './dist/cjs/application.d.ts',
input: './dist/esm/application.d.mts',
output: [{ file: './api/application.d.ts', format: 'es' }],
plugins: [dts()],
},
{
input: './dist/cjs/app.d.ts',
input: './dist/esm/app.d.mts',
output: [{ file: './api/app.d.ts', format: 'es' }],
plugins: [dts()],
},
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell/src/app/cli-reporter.ts
Expand Up @@ -7,6 +7,7 @@ import type {
RunResult,
} from '@cspell/cspell-types';
import chalk from 'chalk';
import chalkTemplate from 'chalk-template';
import type { ImportError, SpellingDictionaryLoadError } from 'cspell-lib';
import { isSpellingDictionaryLoadError } from 'cspell-lib';
import * as path from 'path';
Expand Down Expand Up @@ -224,7 +225,7 @@ function formatIssue(templateStr: string, issue: ReporterIssue, maxIssueTextWidt

const t = template(templateStr.replace(/\$message/g, message));

return substitute(chalk(t), substitutions).trimEnd();
return substitute(chalkTemplate(t), substitutions).trimEnd();
}

function formatSuggestions(issue: Issue): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell/tsconfig.json
@@ -1,4 +1,4 @@
{
"files": [],
"references": [{ "path": "./tsconfig.cjs.json" }, { "path": "./tsconfig.esm.json" }, { "path": "./src/lib" }]
"references": [{ "path": "./tsconfig.esm.json" }, { "path": "./src/lib" }]
}
3 changes: 1 addition & 2 deletions packages/cspell/vitest.config.ts
Expand Up @@ -23,7 +23,6 @@ export default mergeConfig(
'**/*.test.*',
'ajv.config.*',
'bin.cjs',
'bin.js',
'bin.mjs',
'coverage',
'dist/**',
Expand All @@ -34,7 +33,7 @@ export default mergeConfig(
],
},
include: ['src/**/*.test.{ts,mts}'],
exclude: ['content/**', 'fixtures/**', 'bin.mjs', 'bin.js', '_snapshots_'],
exclude: ['content/**', 'fixtures/**', 'bin.mjs', '_snapshots_'],
root: __dirname,
testTimeout: 10000,
},
Expand Down

0 comments on commit 0c27db0

Please sign in to comment.