From a4c68314d546b2b4830833153a4ae855f219fdd3 Mon Sep 17 00:00:00 2001 From: Jacob Ley Date: Sun, 5 Jan 2025 03:18:22 +0000 Subject: [PATCH] Remove unused nx plugins (replaced by CLI) --- .../nx-populate-files/.npmignore | 24 --- .../nx-populate-files/CHANGELOG.md | 145 -------------- apps/populate-files/nx-populate-files/LICENSE | 21 -- .../nx-populate-files/README.md | 96 ---------- .../nx-populate-files/eslint.config.js | 4 - .../nx-populate-files/executors.json | 9 - .../nx-populate-files/package.json | 54 ------ .../nx-populate-files/project.json | 30 --- .../src/executors/populate-files/index.cts | 3 - .../src/executors/populate-files/index.ts | 44 ----- .../src/executors/populate-files/schema.json | 29 --- .../src/executors/populate-files/schema.ts | 30 --- .../nx-populate-files/src/file-content.ts | 9 - .../nx-populate-files/src/index.ts | 1 - .../nx-populate-files/tsconfig.json | 28 --- pnpm-lock.yaml | 146 -------------- tools/nx-tsc/.npmignore | 24 --- tools/nx-tsc/CHANGELOG.md | 159 ---------------- tools/nx-tsc/LICENSE | 21 -- tools/nx-tsc/README.md | 54 ------ tools/nx-tsc/eslint.config.js | 4 - tools/nx-tsc/executors.json | 9 - tools/nx-tsc/package.json | 59 ------ tools/nx-tsc/project.json | 30 --- tools/nx-tsc/src/executors/build/compiler.ts | 180 ------------------ .../src/executors/build/config-loader.ts | 85 --------- .../src/executors/build/failure-reporter.ts | 26 --- .../nx-tsc/src/executors/build/identifiers.ts | 44 ----- tools/nx-tsc/src/executors/build/index.cts | 3 - tools/nx-tsc/src/executors/build/index.ts | 53 ------ .../nx-tsc/src/executors/build/normalizer.ts | 45 ----- .../src/executors/build/output-cleaner.ts | 12 -- tools/nx-tsc/src/executors/build/schema.json | 17 -- tools/nx-tsc/src/executors/build/schema.ts | 19 -- tools/nx-tsc/src/executors/build/tsc.ts | 41 ---- tools/nx-tsc/src/file-content.ts | 9 - tools/nx-tsc/tsconfig.json | 25 --- 37 files changed, 1592 deletions(-) delete mode 100644 apps/populate-files/nx-populate-files/.npmignore delete mode 100644 apps/populate-files/nx-populate-files/CHANGELOG.md delete mode 100644 apps/populate-files/nx-populate-files/LICENSE delete mode 100644 apps/populate-files/nx-populate-files/README.md delete mode 100644 apps/populate-files/nx-populate-files/eslint.config.js delete mode 100644 apps/populate-files/nx-populate-files/executors.json delete mode 100644 apps/populate-files/nx-populate-files/package.json delete mode 100644 apps/populate-files/nx-populate-files/project.json delete mode 100644 apps/populate-files/nx-populate-files/src/executors/populate-files/index.cts delete mode 100644 apps/populate-files/nx-populate-files/src/executors/populate-files/index.ts delete mode 100644 apps/populate-files/nx-populate-files/src/executors/populate-files/schema.json delete mode 100644 apps/populate-files/nx-populate-files/src/executors/populate-files/schema.ts delete mode 100644 apps/populate-files/nx-populate-files/src/file-content.ts delete mode 100644 apps/populate-files/nx-populate-files/src/index.ts delete mode 100644 apps/populate-files/nx-populate-files/tsconfig.json delete mode 100644 tools/nx-tsc/.npmignore delete mode 100644 tools/nx-tsc/CHANGELOG.md delete mode 100644 tools/nx-tsc/LICENSE delete mode 100644 tools/nx-tsc/README.md delete mode 100644 tools/nx-tsc/eslint.config.js delete mode 100644 tools/nx-tsc/executors.json delete mode 100644 tools/nx-tsc/package.json delete mode 100644 tools/nx-tsc/project.json delete mode 100644 tools/nx-tsc/src/executors/build/compiler.ts delete mode 100644 tools/nx-tsc/src/executors/build/config-loader.ts delete mode 100644 tools/nx-tsc/src/executors/build/failure-reporter.ts delete mode 100644 tools/nx-tsc/src/executors/build/identifiers.ts delete mode 100644 tools/nx-tsc/src/executors/build/index.cts delete mode 100644 tools/nx-tsc/src/executors/build/index.ts delete mode 100644 tools/nx-tsc/src/executors/build/normalizer.ts delete mode 100644 tools/nx-tsc/src/executors/build/output-cleaner.ts delete mode 100644 tools/nx-tsc/src/executors/build/schema.json delete mode 100644 tools/nx-tsc/src/executors/build/schema.ts delete mode 100644 tools/nx-tsc/src/executors/build/tsc.ts delete mode 100644 tools/nx-tsc/src/file-content.ts delete mode 100644 tools/nx-tsc/tsconfig.json diff --git a/apps/populate-files/nx-populate-files/.npmignore b/apps/populate-files/nx-populate-files/.npmignore deleted file mode 100644 index 82db28e9..00000000 --- a/apps/populate-files/nx-populate-files/.npmignore +++ /dev/null @@ -1,24 +0,0 @@ -CHANGELOG.md -project.json -tsconfig.json - -.c8rc.json -.eslintcache -.pnpm-lock-hash -.swcrc -coverage/** -.eslintcache -eslint.config.js - -dist/tsconfig.tsbuildinfo -dist/**/*.map -dist/tests - -src/** -!src/executors/populate-files/schema.json - -dist/file-content.js -dist/file-content.d.ts - -dist/executors/populate-files/schema.js -dist/executors/populate-files/schema.d.ts diff --git a/apps/populate-files/nx-populate-files/CHANGELOG.md b/apps/populate-files/nx-populate-files/CHANGELOG.md deleted file mode 100644 index a95432d9..00000000 --- a/apps/populate-files/nx-populate-files/CHANGELOG.md +++ /dev/null @@ -1,145 +0,0 @@ -# nx-populate-files - -## 0.1.0 - -### Minor Changes - -- 0f55ca6: Move nx devkit to peer dependencies - -### Patch Changes - -- 282a5b7: Bump license version -- 75d9ae4: Migrate to using per-package eslint CLI instead of Nx plugin -- Updated dependencies [282a5b7] -- Updated dependencies [75d9ae4] - - load-populate-files@0.1.1 - - common-proxy@0.1.2 - - juniper@1.2.4 - -## 0.0.14 - -### Patch Changes - -- Updated dependencies [5c09944] - - common-proxy@0.1.1 - - load-populate-files@0.1.0 - -## 0.0.13 - -### Patch Changes - -- 93cdd8a: Use local version of dependency -- 18cfe17: Add dev dependency on pnpm-dedicated-lockfile -- efd163f: Remove local files from publishing -- 3e72e79: Bump container-level dependencies -- 37b2ec5: Move from nx-tsc to swc + tsc CLI -- 36d1c12: Bump dependencies -- Updated dependencies [e5209ca] -- Updated dependencies [93cdd8a] -- Updated dependencies [18cfe17] -- Updated dependencies [2e2c63f] -- Updated dependencies [bc9c9e1] -- Updated dependencies [9ad3555] -- Updated dependencies [0de94ee] -- Updated dependencies [efd163f] -- Updated dependencies [7f6d058] -- Updated dependencies [19244cd] -- Updated dependencies [f5ed1b6] -- Updated dependencies [37b2ec5] -- Updated dependencies [4c71310] -- Updated dependencies [36d1c12] -- Updated dependencies [25d162d] - - load-populate-files@0.1.0 - - common-proxy@0.1.0 - -## 0.0.12 - -### Patch Changes - -- e718f38: Update dependencies -- Updated dependencies [e718f38] - - load-populate-files@0.0.11 - - common-proxy@0.0.7 - -## 0.0.11 - -### Patch Changes - -- 57f2da8: Bump pnpm + nx versions -- Updated dependencies [f04c4fe] - - common-proxy@0.0.6 - - load-populate-files@0.0.10 - -## 0.0.10 - -### Patch Changes - -- bcd9e61: Bump dependencies -- Updated dependencies [bcd9e61] - - load-populate-files@0.0.9 - - common-proxy@0.0.5 - -## 0.0.9 - -### Patch Changes - -- 3b3f77f: Bump dependencies -- 3285cb6: Bump biome version -- 806edcb: Bump Nx Version -- bef3833: Bump Nx+pnpm, remove unnecessary non-null assertions -- 9b58c82: Bump typescript version -- 8d18262: Update dependencies -- 41a9b84: Remove unused nyc dependency -- Updated dependencies [3b3f77f] -- Updated dependencies [3285cb6] -- Updated dependencies [9b58c82] -- Updated dependencies [41a9b84] - - load-populate-files@0.0.8 - - common-proxy@0.0.4 - -## 0.0.8 - -### Patch Changes - -- 1de1659: Omit CHANGELOG from publish -- 725510a: Include npmignore ignore file -- Updated dependencies [1de1659] -- Updated dependencies [725510a] - - load-populate-files@0.0.7 - - common-proxy@0.0.3 - -## 0.0.7 - -### Patch Changes - -- load-populate-files@0.0.6 - -## 0.0.6 - -### Patch Changes - -- load-populate-files@0.0.5 - -## 0.0.5 - -### Patch Changes - -- load-populate-files@0.0.4 - -## 0.0.4 - -### Patch Changes - -- 31f81fa: Internal dependency updates -- 3e7ee18: Dependency bumps -- f6a4729: Update year in LICENSE -- 9c786d0: Update dependencies -- 329146b: Add README -- Updated dependencies [31f81fa] -- Updated dependencies [86a26b1] -- Updated dependencies [3e7ee18] -- Updated dependencies [f6a4729] -- Updated dependencies [9c786d0] -- Updated dependencies [329146b] - - load-populate-files@0.0.3 - - common-proxy@0.0.2 diff --git a/apps/populate-files/nx-populate-files/LICENSE b/apps/populate-files/nx-populate-files/LICENSE deleted file mode 100644 index ec50afa3..00000000 --- a/apps/populate-files/nx-populate-files/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2025 Jacob Ley - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/apps/populate-files/nx-populate-files/README.md b/apps/populate-files/nx-populate-files/README.md deleted file mode 100644 index f8ec0d9d..00000000 --- a/apps/populate-files/nx-populate-files/README.md +++ /dev/null @@ -1,96 +0,0 @@ -
- -# nx-populate-files -Nx plugin to dynamically populate file content. - -[![npm package](https://badge.fury.io/js/nx-populate-files.svg)](https://www.npmjs.com/package/nx-populate-files) -[![License](https://img.shields.io/npm/l/nx-populate-files.svg)](https://github.com/JacobLey/leyman/blob/main/tools/nx-populate-files/LICENSE) - -
- -## Table of Contents - -- [Introduction](#introduction) -- [Usage](#usage) -- [API](#api) - - [populateFile](#populatefileparams-options) - - [populateFiles](#populatefilesparams-options) -- [Also See](#also-see) - -## Introduction - -`nx-populate-files` is an Nx plugin to write files based on dynamic content. Acts the same as calling [loadAndPopulateFiles](https://www.npmjs.com/package/load-populate-files) from your JS code. - -## Usage - -Register the `populate-files` executor and provide the `filePath` to the file that _default exports_ file content, matching the parameters to [populateFile()](https://www.npmjs.com/package/populate-files). - -```ts -// src/config.ts - -export default { - filePath: './foo.json', - content: { bar: 123 }, -} satisfies PopulateFileParams; -``` - -`project.json`: -```json -{ - "targets": { - "populate-files": { - "executor": "nx-populate-files:populate-files", - "options": { - "filePath": "{projectRoot}/dist/config.js", - "cwd": "{projectRoot}" - } - } - } -} -``` - -If caching this target, it is recommended to include all the source files for your config as input, and declare the written files as output. - -## executors - -### populate-files - -Loads the content at `filePath`, and writes the content for each set of params. - -#### options - -A required object. - -| property | required | type | default value | description | -|----------|----------|------|---------------|-------------| -| filePath | ✅ | `string` | ❌ | Path to file that _default exports_ the config for content to populate files | -| check | ❌ | `boolean` | `true` if in a CI environment. Else `false` | If `true`, will fail if writing the files would result in changing the files content. Useful for CI environments to make sure the version-controlled code is up to date before deployment. | -| dryRun | ❌ | `boolean` | `false` | If `true`, will not write file regardless of changes. Can still fail if `check` is `true`. | -| cwd | ❌ | `string \| URL` | `process.env.PWD` | Used as the current working directory if `params.filePath` is a relative file. | - -## Types - -### PopulateFileParams - -Type of the exported config at the specified file. Represents the parametesr to `populateFiles()`. It is highly recommended to combine with the `satisfies` keyword to ensure your exported config will succeed. - -```ts -import type { PopulateFileParams } from 'nx-populate-files'; - -export default { - filePath: './foo.json', - content: { bar: 123 }, -} satisfies PopulateFileParams; -``` - -Note this type can also be imported from [populate-files](https://www.npmjs.com/package/populate-files) and [load-populate-files](https://www.npmjs.com/package/load-populate-files) directly. - -## Also See - -### [populate-files](https://www.npmjs.com/package/populate-files) - -Populate a file based on dynamic content, enforcing changes are complete in CI environments. - -### [load-populate-files](https://www.npmjs.com/package/load-populate-files) - -Load and populate files as a JS method. \ No newline at end of file diff --git a/apps/populate-files/nx-populate-files/eslint.config.js b/apps/populate-files/nx-populate-files/eslint.config.js deleted file mode 100644 index 99658416..00000000 --- a/apps/populate-files/nx-populate-files/eslint.config.js +++ /dev/null @@ -1,4 +0,0 @@ -import configGenerator from '@leyman/eslint-config'; -import packageJson from './package.json' with { type: 'json' }; - -export default configGenerator({ configUrl: import.meta.url, packageJson }); diff --git a/apps/populate-files/nx-populate-files/executors.json b/apps/populate-files/nx-populate-files/executors.json deleted file mode 100644 index 36e4b3ca..00000000 --- a/apps/populate-files/nx-populate-files/executors.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "executors": { - "populate-files": { - "implementation": "dist/executors/populate-files/index.cjs", - "schema": "src/executors/populate-files/schema.json", - "description": "Populate files based on dynamic content." - } - } -} diff --git a/apps/populate-files/nx-populate-files/package.json b/apps/populate-files/nx-populate-files/package.json deleted file mode 100644 index aa8fe9db..00000000 --- a/apps/populate-files/nx-populate-files/package.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "nx-populate-files", - "version": "0.1.0", - "description": "Nx plugin to dynamically populate file content", - "engines": { - "node": ">=20" - }, - "type": "module", - "author": "JacobLey", - "license": "MIT", - "repository": "JacobLey/leyman", - "homepage": "https://github.com/JacobLey/leyman/tree/main/apps/populate-files/nx-populate-files/nx-tsc#readme", - "bugs": { - "url": "https://github.com/JacobLey/leyman/issues" - }, - "keywords": [ - "nx", - "executor", - "content", - "write", - "build" - ], - "sideEffects": false, - "executors": "./executors.json", - "exports": { - ".": "./dist/index.js", - "./package.json": { - "default": "./package.json" - } - }, - "dependencies": { - "@nx/devkit": "^20.3.0", - "ci-info": "^4.1.0", - "common-proxy": "workspace:^", - "load-populate-files": "workspace:^", - "juniper": "workspace:^", - "nx": "^20.3.0" - }, - "devDependencies": { - "@biomejs/biome": "^1.9.4", - "@leyman/eslint-config": "workspace:^", - "@swc/cli": "^0.5.2", - "@swc/core": "^1.10.4", - "@types/chai": "^5.0.1", - "@types/mocha": "^10.0.10", - "@types/node": "^22.10.5", - "chai": "^5.1.2", - "eslint": "^9.17.0", - "mocha": "^11.0.1", - "nx-update-ts-references": "workspace:^", - "pnpm-dedicated-lockfile": "workspace:^", - "typescript": "^5.7.2" - } -} diff --git a/apps/populate-files/nx-populate-files/project.json b/apps/populate-files/nx-populate-files/project.json deleted file mode 100644 index 7f303037..00000000 --- a/apps/populate-files/nx-populate-files/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "name": "nx-populate-files", - "targets": { - "pnpm-dedicated-lockfile": {}, - "biome": {}, - "eslint": {}, - "update-ts-references": {}, - "delete-dist": {}, - "populate-static": {}, - "tsc": {}, - "populate-files": {}, - "analyze:_": {}, - "analyze:format": {}, - "analyze:lint": {}, - "analyze": {}, - "build:_": {}, - "build:pre": {}, - "build:run": {}, - "build:post": {}, - "build": {}, - "install:_": {}, - "install": {}, - "test:_": {}, - "test:reset": {}, - "test:run": {}, - "test:report": {}, - "test": {} - } -} diff --git a/apps/populate-files/nx-populate-files/src/executors/populate-files/index.cts b/apps/populate-files/nx-populate-files/src/executors/populate-files/index.cts deleted file mode 100644 index 4a3b8134..00000000 --- a/apps/populate-files/nx-populate-files/src/executors/populate-files/index.cts +++ /dev/null @@ -1,3 +0,0 @@ -import { commonProxy } from 'common-proxy'; - -export default commonProxy(import('./index.js')); diff --git a/apps/populate-files/nx-populate-files/src/executors/populate-files/index.ts b/apps/populate-files/nx-populate-files/src/executors/populate-files/index.ts deleted file mode 100644 index b03a40b8..00000000 --- a/apps/populate-files/nx-populate-files/src/executors/populate-files/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -import Path from 'node:path'; -import type { ExecutorContext } from '@nx/devkit'; -import { loadAndPopulateFiles } from 'load-populate-files'; -import type { PopulateFilesOptions } from './schema.js'; - -/** - * Loads content from specified file, and populates other file with generated content. - * - * @param options - options provided by user - * @param context - nx workspace context - * @returns success - */ -export default async function nxPopulateFiles( - options: PopulateFilesOptions, - context: ExecutorContext -): Promise<{ success: boolean }> { - try { - await loadAndPopulateFiles( - { - filePath: Path.resolve(context.root, options.filePath), - }, - { - cwd: Path.resolve( - context.root, - options.cwd ?? - context.projectsConfigurations.projects[context.projectName!]!.root - ), - check: options.check, - dryRun: options.dryRun, - } - ); - - return { success: true }; - } catch (error) { - if (error instanceof Error) { - // eslint-disable-next-line no-console - console.error(error.message); - } else { - // eslint-disable-next-line no-console - console.error('Unknown Error', error); - } - return { success: false }; - } -} diff --git a/apps/populate-files/nx-populate-files/src/executors/populate-files/schema.json b/apps/populate-files/nx-populate-files/src/executors/populate-files/schema.json deleted file mode 100644 index 0390e1c9..00000000 --- a/apps/populate-files/nx-populate-files/src/executors/populate-files/schema.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "version": 1, - "outputCapture": "direct-nodejs", - "cli": "nx", - "type": "object", - "title": "Populate Files Target", - "description": "Load and dynamically populate files.", - "properties": { - "filePath": { - "type": "string", - "description": "Path to file with content and file paths to populate." - }, - "cwd": { - "type": "string", - "description": "Path to resolve all provided paths (_excluding_ above `filePath`). Defaults to process.cwd()." - }, - "check": { - "type": "boolean", - "description": "Fails if files are not already written, will not overwrite. Defaults to true during CI, false otherwise." - }, - "dryRun": { - "type": "boolean", - "description": "Load files and content, but do not write anything." - } - }, - "required": [ - "filePath" - ] -} diff --git a/apps/populate-files/nx-populate-files/src/executors/populate-files/schema.ts b/apps/populate-files/nx-populate-files/src/executors/populate-files/schema.ts deleted file mode 100644 index 919dbdd0..00000000 --- a/apps/populate-files/nx-populate-files/src/executors/populate-files/schema.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { booleanSchema, objectSchema, type SchemaType, stringSchema } from 'juniper'; - -const populateFilesOptionsSchema = objectSchema({ - title: 'Populate Files Target', - description: 'Load and dynamically populate files.', - properties: { - filePath: stringSchema({ - description: 'Path to file with content and file paths to populate.', - }), - cwd: stringSchema({ - description: - 'Path to resolve all provided paths (_excluding_ above `filePath`). Defaults to process.cwd().', - }), - check: booleanSchema({ - description: - 'Fails if files are not already written, will not overwrite. Defaults to true during CI, false otherwise.', - }), - dryRun: booleanSchema({ - description: 'Load files and content, but do not write anything.', - }), - }, - required: ['filePath'], -}).metadata({ - version: 1, - outputCapture: 'direct-nodejs', - cli: 'nx', -}); - -export default populateFilesOptionsSchema.toJSON(); -export type PopulateFilesOptions = SchemaType; diff --git a/apps/populate-files/nx-populate-files/src/file-content.ts b/apps/populate-files/nx-populate-files/src/file-content.ts deleted file mode 100644 index 34b9a730..00000000 --- a/apps/populate-files/nx-populate-files/src/file-content.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { PopulateFileParams } from 'load-populate-files'; -import populateFilesOptionsSchema from './executors/populate-files/schema.js'; - -export default [ - { - filePath: './src/executors/populate-files/schema.json', - content: populateFilesOptionsSchema, - }, -] satisfies PopulateFileParams[]; diff --git a/apps/populate-files/nx-populate-files/src/index.ts b/apps/populate-files/nx-populate-files/src/index.ts deleted file mode 100644 index 5408ef31..00000000 --- a/apps/populate-files/nx-populate-files/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { PopulateFileParams } from 'load-populate-files'; diff --git a/apps/populate-files/nx-populate-files/tsconfig.json b/apps/populate-files/nx-populate-files/tsconfig.json deleted file mode 100644 index 9ef7c5dc..00000000 --- a/apps/populate-files/nx-populate-files/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "extends": "../../../tsconfig.build.json", - "compilerOptions": { - "outDir": "dist", - "rootDir": "src", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" - }, - "references": [ - { - "path": "../../juniper" - }, - { - "path": "../../nx-update-ts-references" - }, - { - "path": "../../pnpm-dedicated-lockfile" - }, - { - "path": "../load-populate-files" - }, - { - "path": "../../../leyman/eslint-config" - }, - { - "path": "../../../tools/common-proxy" - } - ] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 34bb47ab..fcdcfec6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -629,67 +629,6 @@ importers: specifier: ^5.7.2 version: 5.7.2 - apps/populate-files/nx-populate-files: - dependencies: - '@nx/devkit': - specifier: ^20.3.0 - version: 20.3.0(nx@20.3.0(@swc/core@1.10.4)) - ci-info: - specifier: ^4.1.0 - version: 4.1.0 - common-proxy: - specifier: workspace:^ - version: link:../../../tools/common-proxy - juniper: - specifier: workspace:^ - version: link:../../juniper - load-populate-files: - specifier: workspace:^ - version: link:../load-populate-files - nx: - specifier: ^20.3.0 - version: 20.3.0(@swc/core@1.10.4) - devDependencies: - '@biomejs/biome': - specifier: ^1.9.4 - version: 1.9.4 - '@leyman/eslint-config': - specifier: workspace:^ - version: link:../../../leyman/eslint-config - '@swc/cli': - specifier: ^0.5.2 - version: 0.5.2(@swc/core@1.10.4) - '@swc/core': - specifier: ^1.10.4 - version: 1.10.4 - '@types/chai': - specifier: ^5.0.1 - version: 5.0.1 - '@types/mocha': - specifier: ^10.0.10 - version: 10.0.10 - '@types/node': - specifier: ^22.10.5 - version: 22.10.5 - chai: - specifier: ^5.1.2 - version: 5.1.2 - eslint: - specifier: ^9.17.0 - version: 9.17.0 - mocha: - specifier: ^11.0.1 - version: 11.0.1 - nx-update-ts-references: - specifier: workspace:^ - version: link:../../nx-update-ts-references - pnpm-dedicated-lockfile: - specifier: workspace:^ - version: link:../../pnpm-dedicated-lockfile - typescript: - specifier: ^5.7.2 - version: 5.7.2 - apps/populate-files/populate-files: dependencies: ci-info: @@ -1710,76 +1649,6 @@ importers: specifier: ^5.7.2 version: 5.7.2 - tools/nx-tsc: - dependencies: - '@swc/core': - specifier: ^1.10.4 - version: 1.10.4(@swc/helpers@0.5.15) - '@swc/helpers': - specifier: ^0.5.15 - version: 0.5.15 - common-proxy: - specifier: workspace:^ - version: link:../common-proxy - haywire: - specifier: workspace:^ - version: link:../haywire - npm-juniper: - specifier: npm:juniper@latest - version: juniper@1.2.4 - nx-plugin-handler: - specifier: workspace:^ - version: link:../nx-plugin-handler - devDependencies: - '@biomejs/biome': - specifier: ^1.9.4 - version: 1.9.4 - '@leyman/eslint-config': - specifier: workspace:^ - version: link:../../leyman/eslint-config - '@nx/devkit': - specifier: ^20.3.0 - version: 20.3.0(nx@20.3.0(@swc/core@1.10.4(@swc/helpers@0.5.15))) - '@swc/cli': - specifier: ^0.5.2 - version: 0.5.2(@swc/core@1.10.4(@swc/helpers@0.5.15)) - '@types/chai': - specifier: ^5.0.1 - version: 5.0.1 - '@types/mocha': - specifier: ^10.0.10 - version: 10.0.10 - '@types/node': - specifier: ^22.10.5 - version: 22.10.5 - chai: - specifier: ^5.1.2 - version: 5.1.2 - eslint: - specifier: ^9.17.0 - version: 9.17.0 - mocha: - specifier: ^11.0.1 - version: 11.0.1 - npm-load-populate-files: - specifier: npm:load-populate-files@latest - version: load-populate-files@0.1.1(@biomejs/biome@1.9.4) - npm-nx-populate-files: - specifier: npm:nx-populate-files@latest - version: nx-populate-files@0.1.0(@biomejs/biome@1.9.4)(@swc/core@1.10.4(@swc/helpers@0.5.15)) - npm-nx-update-ts-references: - specifier: npm:nx-update-ts-references@latest - version: nx-update-ts-references@0.2.0(@biomejs/biome@1.9.4)(@swc/core@1.10.4(@swc/helpers@0.5.15)) - nx: - specifier: ^20.3.0 - version: 20.3.0(@swc/core@1.10.4(@swc/helpers@0.5.15)) - pnpm-dedicated-lockfile: - specifier: workspace:^ - version: link:../../apps/pnpm-dedicated-lockfile - typescript: - specifier: ^5.7.2 - version: 5.7.2 - tools/parse-cwd: devDependencies: '@biomejs/biome': @@ -9242,21 +9111,6 @@ snapshots: optionalDependencies: '@nx/devkit': 20.3.0(nx@20.3.0) - nx-populate-files@0.1.0(@biomejs/biome@1.9.4)(@swc/core@1.10.4(@swc/helpers@0.5.15)): - dependencies: - '@nx/devkit': 20.3.0(nx@20.3.0(@swc/core@1.10.4(@swc/helpers@0.5.15))) - ci-info: 4.1.0 - common-proxy: 0.1.2 - juniper: 1.2.4 - load-populate-files: 0.1.1(@biomejs/biome@1.9.4) - nx: 20.3.0(@swc/core@1.10.4(@swc/helpers@0.5.15)) - transitivePeerDependencies: - - '@biomejs/biome' - - '@swc-node/register' - - '@swc/core' - - debug - - prettier - nx-populate-files@0.1.0(@biomejs/biome@1.9.4)(@swc/core@1.10.4): dependencies: '@nx/devkit': 20.3.0(nx@20.3.0(@swc/core@1.10.4)) diff --git a/tools/nx-tsc/.npmignore b/tools/nx-tsc/.npmignore deleted file mode 100644 index 1cb9f6ef..00000000 --- a/tools/nx-tsc/.npmignore +++ /dev/null @@ -1,24 +0,0 @@ -CHANGELOG.md -project.json -tsconfig.json - -.c8rc.json -.eslintcache -.pnpm-lock-hash -.swcrc -coverage/** -.eslintcache -eslint.config.js - -dist/tsconfig.tsbuildinfo -dist/**/*.map -dist/tests - -src/** -!src/executors/build/schema.json - -dist/file-content.js -dist/file-content.d.ts - -dist/executors/build/schema.js -dist/executors/build/schema.d.ts diff --git a/tools/nx-tsc/CHANGELOG.md b/tools/nx-tsc/CHANGELOG.md deleted file mode 100644 index 8d11e1ac..00000000 --- a/tools/nx-tsc/CHANGELOG.md +++ /dev/null @@ -1,159 +0,0 @@ -# nx-tsc - -## 0.1.0 - -### Minor Changes - -- 0f55ca6: Move nx devkit to peer dependencies - -### Patch Changes - -- 282a5b7: Bump license version -- 75d9ae4: Migrate to using per-package eslint CLI instead of Nx plugin -- Updated dependencies [1ad9f51] -- Updated dependencies [0f55ca6] -- Updated dependencies [282a5b7] -- Updated dependencies [75d9ae4] - - nx-plugin-handler@0.2.0 - - common-proxy@0.1.2 - - haywire@0.1.7 - -## 0.0.15 - -### Patch Changes - -- Updated dependencies [5c09944] - - common-proxy@0.1.1 - - haywire@0.1.6 - - nx-plugin-handler@0.1.1 - -## 0.0.14 - -### Patch Changes - -- 18cfe17: Add dev dependency on pnpm-dedicated-lockfile -- 1c8d928: Include swc+helper as prod dependency -- efd163f: Remove local files from publishing -- 3e72e79: Bump container-level dependencies -- 37b2ec5: Move from nx-tsc to swc + tsc CLI -- 36d1c12: Bump dependencies -- Updated dependencies [18cfe17] -- Updated dependencies [b086047] -- Updated dependencies [9ad3555] -- Updated dependencies [f7ad651] -- Updated dependencies [0de94ee] -- Updated dependencies [efd163f] -- Updated dependencies [3e72e79] -- Updated dependencies [19244cd] -- Updated dependencies [f5ed1b6] -- Updated dependencies [37b2ec5] -- Updated dependencies [36d1c12] -- Updated dependencies [25d162d] - - nx-plugin-handler@0.1.0 - - common-proxy@0.1.0 - - haywire@0.1.6 - -## 0.0.13 - -### Patch Changes - -- e718f38: Update dependencies -- Updated dependencies [e718f38] - - nx-plugin-handler@0.0.9 - - common-proxy@0.0.7 - - haywire@0.1.5 - -## 0.0.12 - -### Patch Changes - -- 57f2da8: Bump pnpm + nx versions -- Updated dependencies [57f2da8] -- Updated dependencies [f04c4fe] - - nx-plugin-handler@0.0.8 - - common-proxy@0.0.6 - - haywire@0.1.4 - -## 0.0.11 - -### Patch Changes - -- 4e564e5: Bump Nx version -- bcd9e61: Bump dependencies -- 1387a8c: Bump sonarjs eslint and fix/ignore issues -- Updated dependencies [4e564e5] -- Updated dependencies [19d5289] -- Updated dependencies [784035c] -- Updated dependencies [bcd9e61] -- Updated dependencies [cbb9ef5] -- Updated dependencies [24d8e87] -- Updated dependencies [1387a8c] -- Updated dependencies [c4af482] - - nx-plugin-handler@0.0.7 - - haywire@0.1.4 - - common-proxy@0.0.5 - -## 0.0.10 - -### Patch Changes - -- 3b3f77f: Bump dependencies -- 3285cb6: Bump biome version -- 806edcb: Bump Nx Version -- bef3833: Bump Nx+pnpm, remove unnecessary non-null assertions -- 9b58c82: Bump typescript version -- 8d18262: Update dependencies -- 41a9b84: Remove unused nyc dependency -- Updated dependencies [3b3f77f] -- Updated dependencies [3285cb6] -- Updated dependencies [7d6f471] -- Updated dependencies [806edcb] -- Updated dependencies [bef3833] -- Updated dependencies [9b58c82] -- Updated dependencies [8d18262] -- Updated dependencies [231acc9] -- Updated dependencies [ff72123] - - nx-plugin-handler@0.0.6 - - common-proxy@0.0.4 - - haywire@0.1.3 - -## 0.0.9 - -### Patch Changes - -- 1de1659: Omit CHANGELOG from publish -- 725510a: Include npmignore ignore file -- Updated dependencies [1de1659] -- Updated dependencies [725510a] - - common-proxy@0.0.3 - - haywire@0.1.2 - - nx-plugin-handler@0.0.5 - -## 0.0.8 - -### Patch Changes - -- Updated dependencies - - haywire@0.1.1 - - nx-plugin-handler@0.0.4 - -## 0.0.7 - -### Patch Changes - -- 47d2b0d: Removed useless function -- 31f81fa: Internal dependency updates -- 3e7ee18: Dependency bumps -- f6a4729: Update year in LICENSE -- 9c786d0: Update dependencies -- Updated dependencies [3dc29d2] -- Updated dependencies [31f81fa] -- Updated dependencies [3e7ee18] -- Updated dependencies [f6a4729] -- Updated dependencies [cab8478] -- Updated dependencies [c2c0990] -- Updated dependencies [9c786d0] -- Updated dependencies [5984ed5] - - haywire@0.1.0 - - common-proxy@0.0.2 - - nx-plugin-handler@0.0.3 diff --git a/tools/nx-tsc/LICENSE b/tools/nx-tsc/LICENSE deleted file mode 100644 index ec50afa3..00000000 --- a/tools/nx-tsc/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2025 Jacob Ley - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/nx-tsc/README.md b/tools/nx-tsc/README.md deleted file mode 100644 index 16a16718..00000000 --- a/tools/nx-tsc/README.md +++ /dev/null @@ -1,54 +0,0 @@ -
- -# nx-tsc -Nx plugin for transpiling typescript files. - -[![npm package](https://badge.fury.io/js/nx-tsc.svg)](https://www.npmjs.com/package/nx-tsc) -[![License](https://img.shields.io/npm/l/nx-tsc.svg)](https://github.com/JacobLey/leyman/blob/main/tools/nx-tsc/LICENSE) - -
- -## Contents - -- [Introduction](#introduction) -- [Usage](#usage) -- [API](#api) - -## Introduction - -Running the default `@nx/tsc` plugin can result in issues if your config setup does not perfectly match what is expected. - -This plugin is a light wrapper around native typescript's `tsc` command for type checking, and `swc` for actual file output. - -## Usage - -Include it as a target in your `project.json`. - -Has a [peer dependency](https://nodejs.org/en/blog/npm/peer-dependencies) on [typescript](https://www.npmjs.com/package/typescript) so make sure that is installed as well. This package is generally tested with the latest version. - -```json -{ - "name": "my-package", - "targets": { - "tsc": { - "executor": "nx-tsc:build", - "options": { "tsConfig": "{projectRoot}/tsconfig.json" } - }, - } -} -``` - -This script will load from the specified `tsconfig.json`, and specified [rootDir](https://www.typescriptlang.org/tsconfig/#rootDir). It will output to the [outDir](https://www.typescriptlang.org/tsconfig/#outDir). - -It is _highly_ recommended to take advantage to Nx's [inputs](https://nx.dev/reference/inputs) and [outputs](https://nx.dev/recipes/running-tasks/configure-outputs) to take advantage of task caching. - -## API - -### build - -Builds the typescript files in local project, outputting `.js` files and - -#### Options: -| name | type | required | default | description | -|------|------|---------|----------|-------------| -| tsConfig | sring | true | ❌ | Path to `tsconfig.json`. Respects internal extensions. \ No newline at end of file diff --git a/tools/nx-tsc/eslint.config.js b/tools/nx-tsc/eslint.config.js deleted file mode 100644 index 99658416..00000000 --- a/tools/nx-tsc/eslint.config.js +++ /dev/null @@ -1,4 +0,0 @@ -import configGenerator from '@leyman/eslint-config'; -import packageJson from './package.json' with { type: 'json' }; - -export default configGenerator({ configUrl: import.meta.url, packageJson }); diff --git a/tools/nx-tsc/executors.json b/tools/nx-tsc/executors.json deleted file mode 100644 index c928e110..00000000 --- a/tools/nx-tsc/executors.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "executors": { - "build": { - "implementation": "./dist/executors/build/index.cjs", - "schema": "./src/executors/build/schema.json", - "description": "Build a project using TypeScript." - } - } -} diff --git a/tools/nx-tsc/package.json b/tools/nx-tsc/package.json deleted file mode 100644 index 11b2345d..00000000 --- a/tools/nx-tsc/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "nx-tsc", - "version": "0.1.0", - "description": "Build typescript package as nx executor", - "engines": { - "node": ">=20" - }, - "type": "module", - "author": "JacobLey", - "license": "MIT", - "repository": "JacobLey/leyman", - "homepage": "https://github.com/JacobLey/leyman/tree/main/tools/nx-tsc#readme", - "bugs": { - "url": "https://github.com/JacobLey/leyman/issues" - }, - "keywords": [ - "nx", - "tsc", - "typescript", - "build" - ], - "sideEffects": false, - "executors": "./executors.json", - "exports": { - "./package.json": { - "default": "./package.json" - } - }, - "dependencies": { - "@swc/core": "^1.10.4", - "@swc/helpers": "^0.5.15", - "common-proxy": "workspace:^", - "haywire": "workspace:^", - "npm-juniper": "npm:juniper@latest", - "nx-plugin-handler": "workspace:^" - }, - "peerDependencies": { - "typescript": "^5.7.2" - }, - "devDependencies": { - "@biomejs/biome": "^1.9.4", - "@leyman/eslint-config": "workspace:^", - "@nx/devkit": "^20.3.0", - "@swc/cli": "^0.5.2", - "@swc/core": "^1.10.4", - "@types/chai": "^5.0.1", - "@types/mocha": "^10.0.10", - "@types/node": "^22.10.5", - "chai": "^5.1.2", - "eslint": "^9.17.0", - "mocha": "^11.0.1", - "npm-load-populate-files": "npm:load-populate-files@latest", - "npm-nx-populate-files": "npm:nx-populate-files@latest", - "npm-nx-update-ts-references": "npm:nx-update-ts-references@latest", - "nx": "^20.3.0", - "pnpm-dedicated-lockfile": "workspace:^", - "typescript": "^5.7.2" - } -} diff --git a/tools/nx-tsc/project.json b/tools/nx-tsc/project.json deleted file mode 100644 index ec43c4f6..00000000 --- a/tools/nx-tsc/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "name": "nx-tsc", - "targets": { - "pnpm-dedicated-lockfile": {}, - "biome": {}, - "eslint": {}, - "npm-update-ts-references": {}, - "delete-dist": {}, - "populate-static": {}, - "tsc": {}, - "populate-files": {}, - "analyze:_": {}, - "analyze:format": {}, - "analyze:lint": {}, - "analyze": {}, - "build:_": {}, - "build:pre": {}, - "build:run": {}, - "build:post": {}, - "build": {}, - "install:_": {}, - "install": {}, - "test:_": {}, - "test:reset": {}, - "test:run": {}, - "test:report": {}, - "test": {} - } -} diff --git a/tools/nx-tsc/src/executors/build/compiler.ts b/tools/nx-tsc/src/executors/build/compiler.ts deleted file mode 100644 index 1b65f710..00000000 --- a/tools/nx-tsc/src/executors/build/compiler.ts +++ /dev/null @@ -1,180 +0,0 @@ -import type fs from 'node:fs/promises'; -import Path from 'node:path'; -import type swc from '@swc/core'; -import type ts from 'typescript'; -import { identifier } from 'haywire'; -import type { ExtendedTsConfig, TsConfigSettings } from './config-loader.js'; -import type { FailureReporter } from './failure-reporter.js'; -import type { NormalizedOptions } from './normalizer.js'; - -// Pull out into a dynamic string so it isn't accidentally detected -const sourceMapUrl = ['//# source', 'MappingURL='].join(''); - -/** - * Using user-input plus options parsed from `tsconfig.json`, populate the `outDir` with - * - transpiled code - * - type declarations - * - map files of both - * - * returns a list of all files written to `outDir`. - */ -export type Compiler = ( - options: NormalizedOptions, - settings: ExtendedTsConfig -) => Promise; -export const compilerId = identifier(); - -const isFileModule = (filename: string, isPackageModule: boolean): boolean => { - const [extension] = /\.[cm]?js$/u.exec(filename) ?? ['']; - if (extension.includes('c')) { - return false; - } - return extension.includes('m') || isPackageModule; -}; - -interface OutputFiles { - js: { - file: string; - map: string; - }; - types: { - file: string; - map: string; - }; -} -const getOutputtedFiles = (filename: string, settings: TsConfigSettings): OutputFiles => { - const relativePath = Path.relative(settings.rootDir, filename); - - // Remove the `x` from jsx file - const outputTypeName = Path.basename(filename).replace(/\.[cm]?tsx$/u, val => val.slice(0, -1)); - const outputTypeDeclaration = outputTypeName.replace(/\.[cm]?ts$/u, val => `.d${val}`); - // Swap the `t` with a `j` - const outputFileName = outputTypeName.replace(/\.[cm]?ts$/u, val => val.replace('t', 'j')); - - const baseOutputPath = Path.join(settings.outDir, relativePath, '..'); - const outputPath = Path.join(baseOutputPath, outputFileName); - const outputTypesPath = Path.join(baseOutputPath, outputTypeDeclaration); - - return { - js: { - file: outputPath, - map: `${outputPath}.map`, - }, - types: { - file: outputTypesPath, - map: `${outputTypesPath}.map`, - }, - }; -}; - -export const compilerProvider = ( - createCompilerHost: typeof ts.createCompilerHost, - createProgram: typeof ts.createProgram, - failureReporter: FailureReporter, - transformFile: typeof swc.transformFile, - writeFile: typeof fs.writeFile -): Compiler => { - const fileTransform = async ( - filename: string, - options: NormalizedOptions, - outputFiles: OutputFiles - ): Promise => { - const jsBaseName = Path.basename(outputFiles.js.file); - - const transformed = await transformFile(filename, { - filename, - isModule: true, - // Force emitting source maps - sourceMaps: true, - sourceFileName: Path.relative(Path.dirname(outputFiles.js.map), filename), - inlineSourcesContent: false, - sourceRoot: '', - // All settings provided here, don't try to load from elsewhere - swcrc: false, - jsc: { - parser: { - syntax: 'typescript', - decorators: true, - dynamicImport: true, - tsx: true, - }, - transform: { - react: { - // Use `__jsx` instead of `React` - runtime: 'automatic', - }, - }, - experimental: { - keepImportAttributes: true, - }, - // Removes comments - minify: { - compress: false, - mangle: false, - }, - }, - module: { - type: isFileModule(jsBaseName, options.isModule) ? 'es6' : 'commonjs', - ignoreDynamic: true, - }, - env: { - // Somehow this is the only way to actually support dynamic import in commonjs - targets: 'last 1 node versions', - dynamicImport: true, - }, - }); - - const parsedSourceMap: unknown = JSON.parse(transformed.map!); - const sourceMapWithFile = JSON.stringify({ - ...(parsedSourceMap as object), - file: jsBaseName, - }); - - const attachedSourcedMapUrl = `${transformed.code}${sourceMapUrl}${Path.basename( - outputFiles.js.map - )}\n`; - - await Promise.all([ - writeFile(outputFiles.js.file, attachedSourcedMapUrl, 'utf8'), - writeFile(outputFiles.js.map, sourceMapWithFile, 'utf8'), - ]); - }; - - const compiler: Compiler = async (options, tsConfig) => { - const host = createCompilerHost({ - ...tsConfig.options, - emitDeclarationOnly: true, - }); - - const program = createProgram({ - rootNames: tsConfig.fileNames, - options: tsConfig.options, - host, - }); - - const results = program.emit(); - - failureReporter(results); - - const outputted = await Promise.all( - tsConfig.fileNames - .filter( - filename => !Path.relative(tsConfig.settings.rootDir, filename).startsWith('..') - ) - .map(async filename => { - const outputtedFiles = getOutputtedFiles(filename, tsConfig.settings); - await fileTransform(filename, options, outputtedFiles); - return [ - outputtedFiles.js.file, - outputtedFiles.js.map, - outputtedFiles.types.file, - outputtedFiles.types.map, - ]; - }) - ); - - return outputted.flat(); - }; - - return compiler; -}; diff --git a/tools/nx-tsc/src/executors/build/config-loader.ts b/tools/nx-tsc/src/executors/build/config-loader.ts deleted file mode 100644 index fa242480..00000000 --- a/tools/nx-tsc/src/executors/build/config-loader.ts +++ /dev/null @@ -1,85 +0,0 @@ -import Path from 'node:path'; -import ts from 'typescript'; -import { identifier } from 'haywire'; -import type { NormalizedOptions } from './normalizer.js'; - -/** - * Additional fields that come from tsconfig, but are now guaranteed to - * exist and to be properly formatted. - */ -export interface TsConfigSettings { - outDir: string; - rootDir: string; -} - -export interface ExtendedTsConfig extends ts.ParsedCommandLine { - /** - * Additional fields that come from tsconfig, but are now guaranteed to - * exist and to be properly formatted. - */ - settings: TsConfigSettings; -} - -export type ConfigLoader = (options: NormalizedOptions) => ExtendedTsConfig; -export const configLoaderId = identifier(); - -type AbsolutePathAsserter = (name: string, dir: string | undefined) => asserts dir is string; -const assertIsAbsolutePath: AbsolutePathAsserter = ( - name: string, - dir: string | undefined -): asserts dir is string => { - if (!dir) { - throw new Error(`Setting \`${name}\` is not provided`); - } - if (!Path.isAbsolute(dir)) { - throw new Error(`Setting \`${name}\` is not an absolute path: \`${dir}\``); - } -}; - -export const configLoaderProvider = ( - readConfigFile: typeof ts.readConfigFile, - readFile: typeof ts.sys.readFile, - flattenDiagnosticMessageText: typeof ts.flattenDiagnosticMessageText, - parseJsonConfigFileContent: typeof ts.parseJsonConfigFileContent, - defaultCompilerOptions: ts.CompilerOptions -): ConfigLoader => { - const flattenMessage = (messageText: string | ts.DiagnosticMessageChain): string => - flattenDiagnosticMessageText(messageText, ts.sys.newLine, 2); - - return tscOptions => { - const configResponse = readConfigFile(tscOptions.tsConfig, readFile); - - if (configResponse.error) { - throw new Error(flattenMessage(configResponse.error.messageText)); - } - - const parsed = parseJsonConfigFileContent( - configResponse.config, - ts.sys, - Path.dirname(tscOptions.tsConfig) - ); - if (parsed.errors.length > 0) { - throw new Error(parsed.errors.map(err => flattenMessage(err.messageText)).join('\n')); - } - - const options = { - typeRoots: [Path.resolve(tscOptions.projectDir, 'node_modules', '@types')], - ...defaultCompilerOptions, - ...parsed.options, - }; - - const { outDir, rootDir } = options; - - assertIsAbsolutePath('outDir', outDir); - assertIsAbsolutePath('rootDir', rootDir); - - return { - ...parsed, - options, - settings: { - outDir, - rootDir, - }, - }; - }; -}; diff --git a/tools/nx-tsc/src/executors/build/failure-reporter.ts b/tools/nx-tsc/src/executors/build/failure-reporter.ts deleted file mode 100644 index a1b6ae76..00000000 --- a/tools/nx-tsc/src/executors/build/failure-reporter.ts +++ /dev/null @@ -1,26 +0,0 @@ -import ts from 'typescript'; -import { identifier } from 'haywire'; - -export type FailureReporter = (results: ts.EmitResult) => void; -export const failureReporterId = identifier(); - -export const failureReporterProvider = - ( - formatDiagnosticsWithColorAndContext: typeof ts.formatDiagnosticsWithColorAndContext - ): FailureReporter => - (results: ts.EmitResult): void => { - const containsError = results.diagnostics.some( - diagnostic => diagnostic.category === ts.DiagnosticCategory.Error - ); - - if (containsError) { - throw new Error( - formatDiagnosticsWithColorAndContext(results.diagnostics, { - // eslint-disable-next-line @typescript-eslint/unbound-method - getCurrentDirectory: ts.sys.getCurrentDirectory, - getNewLine: () => ts.sys.newLine, - getCanonicalFileName: name => name, - }) - ); - } - }; diff --git a/tools/nx-tsc/src/executors/build/identifiers.ts b/tools/nx-tsc/src/executors/build/identifiers.ts deleted file mode 100644 index 9a6721b3..00000000 --- a/tools/nx-tsc/src/executors/build/identifiers.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { readFile, rm, writeFile } from 'node:fs/promises'; -import { transformFile } from '@swc/core'; -import ts from 'typescript'; -import { bind, createModule, identifier } from 'haywire'; - -export const readFileId = identifier(); -export const rmId = identifier(); -export const writeFileId = identifier(); - -const fsModule = createModule(bind(readFileId).withInstance(readFile)) - .addBinding(bind(rmId).withInstance(rm)) - .addBinding(bind(writeFileId).withInstance(writeFile)); - -export const transformFileId = identifier(); - -const swcModule = createModule(bind(transformFileId).withInstance(transformFile)); - -export const createCompilerHostId = identifier(); -export const createProgramId = identifier(); -export const flattenDiagnosticMessageTextId = identifier(); -export const formatDiagnosticsWithColorAndContextId = - identifier(); -export const defaultCompilerOptionsId = identifier(); -export const parseJsonConfigFileContentId = identifier(); -export const readConfigFileId = identifier(); -export const readJsonConfigFileId = identifier(); -export const tsReadFileId = identifier(); - -const tsModule = createModule(bind(createCompilerHostId).withInstance(ts.createCompilerHost)) - .addBinding(bind(createProgramId).withInstance(ts.createProgram)) - .addBinding(bind(flattenDiagnosticMessageTextId).withInstance(ts.flattenDiagnosticMessageText)) - .addBinding( - bind(formatDiagnosticsWithColorAndContextId).withInstance( - ts.formatDiagnosticsWithColorAndContext - ) - ) - .addBinding(bind(defaultCompilerOptionsId).withInstance(ts.getDefaultCompilerOptions())) - .addBinding(bind(parseJsonConfigFileContentId).withInstance(ts.parseJsonConfigFileContent)) - .addBinding(bind(readConfigFileId).withInstance(ts.readConfigFile)) - // eslint-disable-next-line @typescript-eslint/unbound-method - .addBinding(bind(tsReadFileId).withInstance(ts.sys.readFile)) - .addBinding(bind(readJsonConfigFileId).withInstance(ts.readJsonConfigFile)); - -export const externalModule = fsModule.mergeModule(swcModule).mergeModule(tsModule); diff --git a/tools/nx-tsc/src/executors/build/index.cts b/tools/nx-tsc/src/executors/build/index.cts deleted file mode 100644 index 4a3b8134..00000000 --- a/tools/nx-tsc/src/executors/build/index.cts +++ /dev/null @@ -1,3 +0,0 @@ -import { commonProxy } from 'common-proxy'; - -export default commonProxy(import('./index.js')); diff --git a/tools/nx-tsc/src/executors/build/index.ts b/tools/nx-tsc/src/executors/build/index.ts deleted file mode 100644 index f42d3e8c..00000000 --- a/tools/nx-tsc/src/executors/build/index.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { bind, createContainer } from 'haywire'; -import { handler } from 'nx-plugin-handler'; -import { compilerId, compilerProvider } from './compiler.js'; -import { configLoaderId, configLoaderProvider } from './config-loader.js'; -import { failureReporterId, failureReporterProvider } from './failure-reporter.js'; -import * as ids from './identifiers.js'; -import { normalizeOptionsId, normalizeOptionsProvider } from './normalizer.js'; -import { outputCleanerId, outputCleanerProvider } from './output-cleaner.js'; -import { tscId, tscProvider } from './tsc.js'; - -const tscModule = ids.externalModule - .addBinding( - bind(compilerId) - .withProvider(compilerProvider) - .withDependencies([ - ids.createCompilerHostId, - ids.createProgramId, - failureReporterId, - ids.transformFileId, - ids.writeFileId, - ]) - ) - .addBinding( - bind(configLoaderId) - .withProvider(configLoaderProvider) - .withDependencies([ - ids.readConfigFileId, - ids.tsReadFileId, - ids.flattenDiagnosticMessageTextId, - ids.parseJsonConfigFileContentId, - ids.defaultCompilerOptionsId, - ]) - ) - .addBinding( - bind(failureReporterId) - .withProvider(failureReporterProvider) - .withDependencies([ids.formatDiagnosticsWithColorAndContextId]) - ) - .addBinding( - bind(normalizeOptionsId) - .withProvider(normalizeOptionsProvider) - .withDependencies([ids.readFileId]) - ) - .addBinding( - bind(outputCleanerId).withProvider(outputCleanerProvider).withDependencies([ids.rmId]) - ) - .addBinding( - bind(tscId) - .withProvider(tscProvider) - .withDependencies([normalizeOptionsId, configLoaderId, outputCleanerId, compilerId]) - ); - -export default handler(createContainer(tscModule).get(tscId)); diff --git a/tools/nx-tsc/src/executors/build/normalizer.ts b/tools/nx-tsc/src/executors/build/normalizer.ts deleted file mode 100644 index 55069764..00000000 --- a/tools/nx-tsc/src/executors/build/normalizer.ts +++ /dev/null @@ -1,45 +0,0 @@ -import type fs from 'node:fs/promises'; -import Path from 'node:path'; -import type { ExecutorContext } from '@nx/devkit'; -import { identifier } from 'haywire'; -import type { BuildOptions } from './schema.js'; - -export interface NormalizedOptions extends BuildOptions { - projectDir: string; - isModule: boolean; -} - -export type NormalizeOptions = ( - options: BuildOptions, - context: ExecutorContext -) => Promise; -export const normalizeOptionsId = identifier(); - -interface PackageJson { - type?: 'commonjs' | 'module'; -} - -const isPackageJson = (content: unknown): content is PackageJson => - !!content && typeof content === 'object'; - -export const normalizeOptionsProvider = - (readFile: typeof fs.readFile): NormalizeOptions => - async (options, context) => { - const projectDir = Path.resolve( - context.root, - context.projectsConfigurations.projects[context.projectName!]!.root - ); - - const file = await readFile(Path.join(projectDir, 'package.json'), 'utf8'); - - const rawPackageJson: unknown = JSON.parse(file); - if (isPackageJson(rawPackageJson)) { - return { - projectDir, - tsConfig: Path.resolve(context.root, options.tsConfig), - isModule: rawPackageJson.type === 'module', - }; - } - - throw new Error('Unable to parse package.json file'); - }; diff --git a/tools/nx-tsc/src/executors/build/output-cleaner.ts b/tools/nx-tsc/src/executors/build/output-cleaner.ts deleted file mode 100644 index 2d7b7465..00000000 --- a/tools/nx-tsc/src/executors/build/output-cleaner.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type fs from 'node:fs/promises'; -import { identifier } from 'haywire'; -import type { TsConfigSettings } from './config-loader.js'; - -export type OutputCleaner = (settings: TsConfigSettings) => Promise; -export const outputCleanerId = identifier(); - -export const outputCleanerProvider = - (rm: typeof fs.rm): OutputCleaner => - async settings => { - await rm(settings.outDir, { force: true, recursive: true }); - }; diff --git a/tools/nx-tsc/src/executors/build/schema.json b/tools/nx-tsc/src/executors/build/schema.json deleted file mode 100644 index 4aaf107e..00000000 --- a/tools/nx-tsc/src/executors/build/schema.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": 1, - "outputCapture": "direct-nodejs", - "cli": "nx", - "type": "object", - "title": "Typescript Build Target", - "description": "Builds using TypeScript.", - "properties": { - "tsConfig": { - "type": "string", - "description": "The path to the Typescript configuration file." - } - }, - "required": [ - "tsConfig" - ] -} diff --git a/tools/nx-tsc/src/executors/build/schema.ts b/tools/nx-tsc/src/executors/build/schema.ts deleted file mode 100644 index 45e5e6cc..00000000 --- a/tools/nx-tsc/src/executors/build/schema.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { objectSchema, type SchemaType, stringSchema } from 'npm-juniper'; - -const buildOptionsSchema = objectSchema({ - title: 'Typescript Build Target', - description: 'Builds using TypeScript.', - properties: { - tsConfig: stringSchema({ - description: 'The path to the Typescript configuration file.', - }), - }, - required: ['tsConfig'], -}).metadata({ - version: 1, - outputCapture: 'direct-nodejs', - cli: 'nx', -}); - -export default buildOptionsSchema.toJSON(); -export type BuildOptions = SchemaType; diff --git a/tools/nx-tsc/src/executors/build/tsc.ts b/tools/nx-tsc/src/executors/build/tsc.ts deleted file mode 100644 index 9d6904bb..00000000 --- a/tools/nx-tsc/src/executors/build/tsc.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { ExecutorContext } from '@nx/devkit'; -import { identifier } from 'haywire'; -import type { Compiler } from './compiler.js'; -import type { ConfigLoader } from './config-loader.js'; -import type { NormalizeOptions } from './normalizer.js'; -import type { OutputCleaner } from './output-cleaner.js'; -import type { BuildOptions } from './schema.js'; - -/** - * Primary entrypoint for tsc command for Nx. - */ -type Tsc = ( - /** - * Build options passed from project.json - */ - options: BuildOptions, - /** - * Nx/project/command specific context - */ - context: ExecutorContext -) => Promise<{ success: boolean }>; -export const tscId = identifier(); - -export const tscProvider = - ( - normalizeOptions: NormalizeOptions, - configLoader: ConfigLoader, - outputCleaner: OutputCleaner, - compiler: Compiler - ): Tsc => - async (options, context) => { - const normalized = await normalizeOptions(options, context); - - const tsConfig = configLoader(normalized); - - await outputCleaner(tsConfig.settings); - - await compiler(normalized, tsConfig); - - return { success: true }; - }; diff --git a/tools/nx-tsc/src/file-content.ts b/tools/nx-tsc/src/file-content.ts deleted file mode 100644 index 2f8b87f4..00000000 --- a/tools/nx-tsc/src/file-content.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { PopulateFileParams } from 'npm-load-populate-files'; -import buildOptionsSchema from './executors/build/schema.js'; - -export default [ - { - filePath: './src/executors/build/schema.json', - content: buildOptionsSchema, - }, -] satisfies PopulateFileParams[]; diff --git a/tools/nx-tsc/tsconfig.json b/tools/nx-tsc/tsconfig.json deleted file mode 100644 index d14f98cb..00000000 --- a/tools/nx-tsc/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - "compilerOptions": { - "outDir": "dist", - "rootDir": "src", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" - }, - "references": [ - { - "path": "../../apps/pnpm-dedicated-lockfile" - }, - { - "path": "../../leyman/eslint-config" - }, - { - "path": "../common-proxy" - }, - { - "path": "../haywire" - }, - { - "path": "../nx-plugin-handler" - } - ] -}