Skip to content

Commit

Permalink
Migrate from TSDX to publishing untranspiled .ts source files (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky authored Oct 13, 2024
1 parent be193ec commit cd2105f
Show file tree
Hide file tree
Showing 35 changed files with 1,322 additions and 6,172 deletions.
4 changes: 3 additions & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"buildCommand": false
}
3 changes: 0 additions & 3 deletions .github/workflows/build-and-push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:

- run: pnpm install

- name: Compile TypeScript
run: pnpm docker-build-ts

# Publish to container registry
- name: Log in to the Container registry
uses: docker/login-action@v3
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,5 @@ jobs:
- run: pnpm tsc --build
if: runner.os != 'Windows'

- name: Build
run: pnpm build

- name: Test
run: pnpm test
18 changes: 0 additions & 18 deletions .github/workflows/package-size.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ node_modules
dist

__tests__/fixtures/__temp
docker/clone-and-preflight.js

*.tsbuildinfo

Expand Down
6 changes: 0 additions & 6 deletions .size-limit.json

This file was deleted.

10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:lts-alpine
# TODO: Switch back to lts-alpine once v22 becomes LTS
# FROM node:lts-alpine
FROM node:22-alpine

WORKDIR /preflight

Expand All @@ -21,6 +23,6 @@ ENV PNPM_HOME=/usr/local/bin

RUN pnpm add --global @upleveled/preflight@latest

COPY ./docker/clone-and-preflight.js ./
RUN chmod +x ./clone-and-preflight.js
ENTRYPOINT ["./clone-and-preflight.js"]
COPY ./docker/clone-and-preflight.ts ./
RUN chmod +x ./clone-and-preflight.ts
ENTRYPOINT ["./clone-and-preflight.ts"]
8 changes: 6 additions & 2 deletions __tests__/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const fixturesTempDir = '__tests__/fixtures/__temp';

beforeAll(
async () => {
// Pack and install Preflight globally
const { stdout: pnpmPackTarballPath } = await execa`pnpm pack`;
await execa`pnpm add --global ${process.cwd()}/${pnpmPackTarballPath}`;

await pMap(
[
{
Expand Down Expand Up @@ -60,7 +64,7 @@ function sortStdoutAndStripVersionNumber(stdout: string) {
test('Passes in the react-passing test project', async () => {
const { stdout, stderr } = await execa({

Check failure on line 65 in __tests__/e2e.test.ts

View workflow job for this annotation

GitHub Actions / windows-latest: Build, lint, test

__tests__/e2e.test.ts > Passes in the react-passing test project

ExecaError: Command failed with exit code 1: preflight [FAILED] Your current version of Preflight (8.0.0-0) is older than the latest version 8.0.0 - upgrade with: \u200e $ pnpm add --global @upleveled/preflight 🚀 UpLeveled Preflight v8.0.0-0 [STARTED] All changes committed to Git\r [STARTED] node_modules/ folder ignored in Git\r [STARTED] No extraneous files committed to Git\r [STARTED] No secrets committed to Git\r [STARTED] Use single package manager\r [COMPLETED] No extraneous files committed to Git\r [STARTED] Project folder name matches correct format\r [COMPLETED] Project folder name matches correct format\r [STARTED] No dependency problems\r [STARTED] No unused dependencies\r [STARTED] No dependencies without types\r [COMPLETED] Use single package manager\r [STARTED] GitHub repo has deployed project link under About\r [COMPLETED] No secrets committed to Git\r [STARTED] ESLint\r [COMPLETED] node_modules/ folder ignored in Git\r [STARTED] Stylelint\r [COMPLETED] All changes committed to Git\r [STARTED] Prettier\r [COMPLETED] No dependencies without types\r [COMPLETED] Prettier\r [STARTED] ESLint config is latest version\r [COMPLETED] No unused dependencies\r [COMPLETED] No dependency problems\r [STARTED] Stylelint config is latest version\r [COMPLETED] GitHub repo has deployed project link under About\r [STARTED] Preflight is latest version\r [COMPLETED] Stylelint\r [COMPLETED] Stylelint config is latest version\r [COMPLETED] ESLint config is latest version\r [COMPLETED] ESLint ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ __tests__/e2e.test.ts:65:30 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: preflight', command: 'preflight', escapedCommand: 'preflight', cwd: 'D:\a\preflight\preflight\__tests__\fixtures\__temp\react-passing', durationMs: 9585.9428, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '🚀 UpLeveled Preflight v8.0.0-0\n\u001b[33m[STARTED]\u001b[39m All changes committed to Git\r\n\u001b[33m[STARTED]\u001b[39m node_modules/ folder ignored in Git\r\n\u001b[33m[STARTED]\u001b[39m No extraneous files committed to Git\r\n\u001b[33m[STARTED]\u001b[39m No secrets committed to Git\r\n\u001b[33m[STARTED]\u001b[39m Use single package manager\r\n\u001b[32m[COMPLETED]\u001b[39m No extraneous files committed to Git\r\n\u001b[33m[STARTED]\u001b[39m Project folder name matches correct format\r\n\u001b[32m[COMPLETED]\u001b[39m Project folder name matches correct format\r\n\u001b[33m[STARTED]\u001b[39m No dependency problems\r\n\u001b[33m[STARTED]\u001b[39m No unused dependencies\r\n\u001b[33m[STARTED]\u001b[39m No dependencies without types\r\n\u001b[32m[COMPLETED]\u001b[39m Use single package manager\r\n\u001b[33m[STARTED]\u001b[39m GitHub repo has deployed project link under About\r\n\u001b[32m[COMPLETED]\u001b[39m No secrets committed to Git\r\n\u001b[33m[STARTED]\u001b[39m ESLint\r\n\u001b[32m[COMPLETED]\u001b[39m node_modules/ folder ignored in Git\r\n\u001b[33m[STARTED]\u001b[39m Stylelint\r\n\u001b[32m[COMPLETED]\u001b[39m All changes committed to Git\r\n\u001b[33m[STARTED]\u001b[39m Prettier\r\n\u001b[32m[COMPLETED]\u001b[39m No dependencies without types\r\n\u001b[32m[COMPLETED]\u001b[39m Prettier\r\n\u001b[33m[STARTED]\u001b[39m ESLint config is latest version\r\n\u001b[32m[COMPLETED]\u001b[39m No unused dependencies\r\n\u001b[32m[COMPLETED]\u001b[39m No dependency problems\r\n\u001b[33m[STARTED]\u001b[39m Stylelint config is latest version\r\n\u001b[32m[COMPLETED]\u001b[39m GitHub repo has deployed project link under About\r\n\u001b[33m[STARTED]\u001b[39m Preflight is latest
cwd: `${fixturesTempDir}/react-passing`,
})`${process.cwd()}/bin/preflight.js`;
})`preflight`;

expect(sortStdoutAndStripVersionNumber(stdout)).toMatchSnapshot();
expect(stderr.replace(/^\(node:\d+\) /, '')).toMatchSnapshot();
Expand All @@ -69,7 +73,7 @@ test('Passes in the react-passing test project', async () => {
test('Passes in the next-js-passing test project', async () => {
const { stdout, stderr } = await execa({

Check failure on line 74 in __tests__/e2e.test.ts

View workflow job for this annotation

GitHub Actions / windows-latest: Build, lint, test

__tests__/e2e.test.ts > Passes in the next-js-passing test project

ExecaError: Command failed with exit code 1: preflight [FAILED] Your current version of Preflight (8.0.0-0) is older than the latest version 8.0.0 - upgrade with: \u200e $ pnpm add --global @upleveled/preflight 🚀 UpLeveled Preflight v8.0.0-0 [STARTED] All changes committed to Git\r [STARTED] node_modules/ folder ignored in Git\r [STARTED] No extraneous files committed to Git\r [STARTED] No secrets committed to Git\r [STARTED] Use single package manager\r [COMPLETED] No extraneous files committed to Git\r [STARTED] Project folder name matches correct format\r [COMPLETED] Project folder name matches correct format\r [STARTED] No dependency problems\r [STARTED] No unused dependencies\r [STARTED] No dependencies without types\r [COMPLETED] Use single package manager\r [STARTED] GitHub repo has deployed project link under About\r [COMPLETED] No secrets committed to Git\r [STARTED] ESLint\r [COMPLETED] node_modules/ folder ignored in Git\r [STARTED] Stylelint\r [COMPLETED] All changes committed to Git\r [STARTED] Prettier\r [COMPLETED] No dependencies without types\r [COMPLETED] GitHub repo has deployed project link under About\r [STARTED] ESLint config is latest version\r [COMPLETED] No unused dependencies\r [COMPLETED] No dependency problems\r [STARTED] Stylelint config is latest version\r [COMPLETED] Prettier\r [STARTED] Preflight is latest version\r [COMPLETED] Stylelint\r [COMPLETED] ESLint config is latest version\r [COMPLETED] Stylelint config is latest version\r [COMPLETED] ESLint ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ __tests__/e2e.test.ts:74:30 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: preflight', command: 'preflight', escapedCommand: 'preflight', cwd: 'D:\a\preflight\preflight\__tests__\fixtures\__temp\next-js-passing', durationMs: 10732.3993, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '🚀 UpLeveled Preflight v8.0.0-0\n\u001b[33m[STARTED]\u001b[39m All changes committed to Git\r\n\u001b[33m[STARTED]\u001b[39m node_modules/ folder ignored in Git\r\n\u001b[33m[STARTED]\u001b[39m No extraneous files committed to Git\r\n\u001b[33m[STARTED]\u001b[39m No secrets committed to Git\r\n\u001b[33m[STARTED]\u001b[39m Use single package manager\r\n\u001b[32m[COMPLETED]\u001b[39m No extraneous files committed to Git\r\n\u001b[33m[STARTED]\u001b[39m Project folder name matches correct format\r\n\u001b[32m[COMPLETED]\u001b[39m Project folder name matches correct format\r\n\u001b[33m[STARTED]\u001b[39m No dependency problems\r\n\u001b[33m[STARTED]\u001b[39m No unused dependencies\r\n\u001b[33m[STARTED]\u001b[39m No dependencies without types\r\n\u001b[32m[COMPLETED]\u001b[39m Use single package manager\r\n\u001b[33m[STARTED]\u001b[39m GitHub repo has deployed project link under About\r\n\u001b[32m[COMPLETED]\u001b[39m No secrets committed to Git\r\n\u001b[33m[STARTED]\u001b[39m ESLint\r\n\u001b[32m[COMPLETED]\u001b[39m node_modules/ folder ignored in Git\r\n\u001b[33m[STARTED]\u001b[39m Stylelint\r\n\u001b[32m[COMPLETED]\u001b[39m All changes committed to Git\r\n\u001b[33m[STARTED]\u001b[39m Prettier\r\n\u001b[32m[COMPLETED]\u001b[39m No dependencies without types\r\n\u001b[32m[COMPLETED]\u001b[39m GitHub repo has deployed project link under About\r\n\u001b[33m[STARTED]\u001b[39m ESLint config is latest version\r\n\u001b[32m[COMPLETED]\u001b[39m No unused dependencies\r\n\u001b[32m[COMPLETED]\u001b[39m No dependency problems\r\n\u001b[33m[STARTED]\u001b[39m Stylelint config is latest version\r\n\u001b[32m[COMPLETED]\u001b[39m Prettier\r\n\u001b[33m[STARTED]\u001b[39m Preflight is late
cwd: `${fixturesTempDir}/next-js-passing`,
})`${process.cwd()}/bin/preflight.js`;
})`preflight`;

expect(sortStdoutAndStripVersionNumber(stdout)).toMatchSnapshot();
expect(stderr.replace(/^\(node:\d+\) /, '')).toMatchSnapshot();
Expand Down
3 changes: 0 additions & 3 deletions bin/preflight.js

This file was deleted.

3 changes: 3 additions & 0 deletions bin/preflight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env -S pnpm exec tsx

import '../src/index.ts';
5 changes: 0 additions & 5 deletions bin/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion docker/clone-and-preflight.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env -S node --experimental-strip-types

import { argv, cwd, exit } from 'node:process';
import { execa as bindExeca } from 'execa';
Expand Down
13 changes: 0 additions & 13 deletions docker/tsconfig.build.json

This file was deleted.

10 changes: 0 additions & 10 deletions docker/tsconfig.json

This file was deleted.

48 changes: 10 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@upleveled/preflight",
"version": "7.0.9",
"version": "8.0.0-0",
"repository": "upleveled/preflight",
"license": "MIT",
"author": "UpLeveled (https://github.com/upleveled)",
Expand All @@ -9,28 +9,21 @@
"Karl Horky <[email protected]>"
],
"type": "module",
"main": "dist/preflight.esm.js",
"module": "dist/preflight.esm.js",
"typings": "dist/index.d.ts",
"module": "./src/index.ts",
"types": "./src/index.ts",
"bin": {
"preflight": "bin/preflight.js"
"preflight": "./bin/preflight.ts"
},
"files": [
"bin/preflight.js",
"dist",
"./bin/preflight.js",
"src"
],
"scripts": {
"analyze": "size-limit --why",
"build": "tsdx build --format esm --target node --tsconfig tsconfig.src.json",
"docker-build": "docker build --tag preflight .",
"docker-build-run": "pnpm docker-build-ts && pnpm docker-build && pnpm docker-run",
"docker-build-ts": "tsc --project docker/tsconfig.build.json",
"docker-build-run": "pnpm docker-build && pnpm docker-run",
"docker-run": "docker run preflight",
"lint": "eslint . --max-warnings 0",
"prepare": "pnpm build",
"size": "size-limit",
"start": "tsdx watch --format esm --target node",
"start": "tsx watch ./src/index.ts",
"test": "vitest run",
"test-local": "rm -rf ./__tests__/fixtures/__temp && pnpm test"
},
Expand All @@ -47,44 +40,23 @@
"p-reduce": "3.0.0",
"readdirp": "4.0.2",
"semver": "7.6.3",
"top-user-agents": "2.1.24"
"top-user-agents": "2.1.24",
"tsx": "4.19.1"
},
"devDependencies": {
"@size-limit/file": "11.1.6",
"@types/node": "22.7.5",
"@types/p-map": "2.0.0",
"@types/semver": "7.5.8",
"eslint": "9.12.0",
"eslint-config-upleveled": "8.7.3",
"eslint-config-upleveled": "8.8.0",
"p-map": "7.0.2",
"postinstall-postinstall": "2.1.0",
"prettier": "3.3.3",
"size-limit": "11.1.6",
"stylelint": "16.9.0",
"tsdx": "0.14.1",
"tslib": "2.7.0",
"typescript": "5.6.3",
"vitest": "2.1.2"
},
"packageManager": "[email protected]+sha512.e5a7e52a4183a02d5931057f7a0dbff9d5e9ce3161e33fa68ae392125b79282a8a8a470a51dfc8a0ed86221442eb2fb57019b0990ed24fab519bf0e1bc5ccfc4",
"engines": {
"node": ">=18"
},
"pnpm": {
"overrides": {
"@typescript-eslint/eslint-plugin": "8.8.1",
"@typescript-eslint/parser": "8.8.1",
"@typescript-eslint/scope-manager": "8.8.1",
"@typescript-eslint/utils": "8.8.1",
"eslint": "9.12.0",
"eslint-plugin-jest": "28.8.3",
"eslint-plugin-react-hooks": "4.6.2",
"node-notifier": "10.0.1",
"[email protected]>semver": "5.7.2",
"jest": "30.0.0-alpha.6",
"rollup-plugin-typescript2": "^0.36.0",
"ts-jest": "29.2.5",
"typescript": "5.6.3"
}
}
}
Loading

0 comments on commit cd2105f

Please sign in to comment.