Skip to content

Commit 5dcfac6

Browse files
NullVoxPopuliMehulKChaudhari
authored andcommitted
Add smoke-tests for types, build, etc (emberjs#9633)
* Correctly configure package.json#exports for use with tsconfig.json#compilerOptions#types Fix: emberjs#9630 Fix: ember-cli/ember-cli#10611 Related: - ember-cli/ember-cli#10613 Unblocks: - ember-cli/ember-cli#10612 * Fix lints by removing eslint cache * Smoke Tests: dt-types pass * Smoke: native-types pass * ope * Revert changes to vite-basic-compat * lockfile * Revert npmrc * revert pnpm-lock * Smoke tests don't need their own lint config * Use correct script name * Remove added files to vite-basic-compat * Prettier * Revert misguided lint-induced changes
1 parent 9c930c8 commit 5dcfac6

File tree

23 files changed

+848
-3
lines changed

23 files changed

+848
-3
lines changed

.github/renovate.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,5 @@
9595
"assignees": ["@runspired"],
9696
"enabled": true
9797
},
98-
"ignorePaths": ["node_modules/**", "**/node_modules/**"]
98+
"ignorePaths": ["node_modules/**", "**/node_modules/**", "tests/smoke-tests/**"]
9999
}

.github/workflows/compat-tests.yml

+31
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,34 @@ jobs:
8383
repo-token: ${{ secrets.GITHUB_TOKEN }}
8484
- name: Basic Tests
8585
run: pnpm test
86+
87+
smoke-tests:
88+
name: Smoke ${{ matrix.scenario.name }} w/ ${{ matrix.packageManager }}
89+
timeout-minutes: 10
90+
runs-on: ubuntu-latest
91+
# TODO:
92+
# needs: [embroider, vite]
93+
94+
strategy:
95+
matrix:
96+
packageManager:
97+
- npm
98+
# - yarn # yarn@1 has not been reliable, if yarn@4 were easy to setup, we could test against that
99+
- pnpm
100+
scenario:
101+
- { dir: "dt-types", name: "DT Types" }
102+
- { dir: "native-types", name: "Native Types" }
103+
104+
steps:
105+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
106+
- uses: ./.github/actions/setup
107+
with:
108+
restore-broccoli-cache: true
109+
install: true
110+
repo-token: ${{ secrets.GITHUB_TOKEN }}
111+
- name: "Run a basic smoke test with ${{ matrix.packageManager }} and ${{ matrix.kind }} tagging"
112+
run: |
113+
bun ./tests/smoke-tests/run.ts \
114+
"${{ matrix.scenario.dir }}" "${{ matrix.packageManager }}"
115+
116+

packages/codemods/utils/logger.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import assert from 'assert';
12
import chalk from 'chalk';
23
import type { Options, SourceLocation } from 'jscodeshift';
34
import stripAnsi from 'strip-ansi';
@@ -75,6 +76,7 @@ const formatForConsole = winstonFormat.printf((info: Logform.TransformableInfo)
7576

7677
const formatForFile = winstonFormat.printf((info: Logform.TransformableInfo) => {
7778
const { level, label, timestamp } = info as PrintInfo;
79+
assert(typeof timestamp === 'string', `Expected timestamp value to be a string. Instead was ${typeof timestamp}`);
7880
return `${timestamp} [${label}] ${level}: ${formatMessage(info, stripAnsi)}`;
7981
});
8082

packages/ember/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"scripts": {
1818
"_lint": "eslint . --quiet --cache --cache-strategy=content",
19-
"build:glint": "glint --build",
19+
"build:glint": "glint && glint --build",
2020
"build:pkg": "vite build;",
2121
"prepack": "bun run build:pkg",
2222
"sync-hardlinks": "bun run sync-dependencies-meta-injected"

release/core/publish/steps/generate-tarballs.ts

+27
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,34 @@ async function convertTypesToModules(pkg: Package, subdir: 'unstable-preview-typ
307307
}
308308
}
309309

310+
function exposeTypes(pkg: Package, subdir: 'unstable-preview-types' | 'preview-types' | 'types') {
311+
if (pkg.pkgData.exports) {
312+
/**
313+
* Allows tsconfig.json#compilerOptions#types to use import paths,
314+
* rather than file paths (there are no file path guarantees for any given package manager)
315+
*/
316+
pkg.pkgData.exports[`./${subdir}`] = {
317+
/**
318+
* No default, import, or require here, because there are no actual modules to import.
319+
*/
320+
types: `./${subdir}/index.d.ts`,
321+
};
322+
323+
/**
324+
* For older tsconfig.json settings
325+
*/
326+
pkg.pkgData.typesVersions = {
327+
// very loose TS version
328+
'*': {
329+
[subdir]: [`./${subdir}`],
330+
},
331+
};
332+
}
333+
}
334+
310335
async function makeTypesAlpha(pkg: Package) {
311336
scrubTypesFromExports(pkg);
337+
exposeTypes(pkg, 'unstable-preview-types');
312338

313339
// enforce that the correct types directory is present
314340
const present = new Set(pkg.pkgData.files);
@@ -335,6 +361,7 @@ async function makeTypesAlpha(pkg: Package) {
335361

336362
async function makeTypesBeta(pkg: Package) {
337363
scrubTypesFromExports(pkg);
364+
exposeTypes(pkg, 'preview-types');
338365

339366
// enforce that the correct types directory is present
340367
const present = new Set(pkg.pkgData.files);

release/utils/package.ts

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export type PACKAGEJSON = {
5959
scripts?: Record<string, string>;
6060
files?: string[];
6161
exports?: ExportConfig;
62+
typesVersions?: { [tsVersion: string]: { [relativeImportPath: string]: string[] } };
6263
'ember-addon'?: {
6364
main?: 'addon-main.js';
6465
type?: 'addon';

tests/smoke-tests/.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
packages/
2+
node_modules/
3+
tmp/
4+
dist/
5+
pnpm-lock.yaml
6+
package-lock.json
7+
tsconfig.tsbuildinfo

tests/smoke-tests/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
These packages should not be added to the pnpm-workspace.yaml file.
2+
3+
These are for smoke-tests and ensuring that ember-data/warp-drive's outputs work in real projects.
4+
5+
## Running the Smoke Tests
6+
7+
From the monorepo root:
8+
```bash
9+
bun ./tests/smoke-tests/run.ts dt-types pnpm
10+
# or
11+
bun ./tests/smoke-tests/run.ts native-types pnpm
12+
```
13+
14+
This will take a while to build everything.
15+
Once things are built, however, you may:
16+
```bash
17+
bun ./tests/smoke-tests/run.ts dt-types pnpm --reuse-tars
18+
bun ./tests/smoke-tests/run.ts native-types pnpm --reuse-tars
19+
```
20+
21+
Tars only need to be built once, and then they can be shared with all the smoke-tests.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
/**
3+
* These tests are more fro the out-of-monorepo tests,
4+
* as we'll sever the references links to the source of each of these packages
5+
*
6+
* Just need to make sure each module has types at publish.
7+
*/
8+
import { expectTypeOf } from 'expect-type';
9+
import StoreX from 'ember-data/store';
10+
import DS from 'ember-data';
11+
12+
// @ts-expect-error this exists in the real package, but not DT Types
13+
import Adapter from '@ember-data/adapter/-private/build-url-mixin';
14+
15+
expectTypeOf<typeof StoreX>().not.toBeAny();
16+
17+
import Store from '@ember-data/store';
18+
// @ts-expect-error this exists in the real package, but not DT Types
19+
import RequestManager from '@ember-data/request';
20+
import { BuildURLMixin } from '@ember-data/adapter';
21+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
22+
// @ts-expect-error
23+
import jsonapi from '@ember-data/json-api';
24+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
25+
// @ts-expect-error
26+
import { adapterFor } from '@ember-data/legacy-compat';
27+
import Model from '@ember-data/model';
28+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
29+
// @ts-expect-error
30+
import { setBuildURLConfig } from '@ember-data/request-utils';
31+
import Serializer from '@ember-data/serializer';
32+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
33+
// @ts-expect-error
34+
import { createCache } from '@ember-data/tracking';
35+
36+
// Most of this is to assure thet above imports don't get optimized away
37+
expectTypeOf<typeof DS>().not.toBeAny();
38+
expectTypeOf<typeof import('ember-data')>().not.toBeAny();
39+
expectTypeOf<typeof Store>().not.toBeAny();
40+
expectTypeOf<typeof Model>().not.toBeAny();
41+
expectTypeOf<typeof Model>().toHaveProperty('reopen');
42+
expectTypeOf<typeof Serializer>().not.toBeAny();
43+
// @ts-expect-error no DT Types
44+
expectTypeOf<typeof RequestManager>().not.toBeAny();
45+
expectTypeOf<typeof BuildURLMixin>().not.toBeAny();
46+
// @ts-expect-error no DT Types
47+
expectTypeOf<typeof jsonapi>().not.toBeAny();
48+
// @ts-expect-error no DT Types
49+
expectTypeOf<typeof createCache>().not.toBeAny();
50+
// @ts-expect-error no DT Types
51+
expectTypeOf<typeof setBuildURLConfig>().not.toBeAny();
52+
// @ts-expect-error no DT Types
53+
expectTypeOf<typeof adapterFor>().not.toBeAny();
+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
{
2+
"name": "@ember-data/smoke-tests-dt-types",
3+
"version": "0.0.0",
4+
"private": true,
5+
"description": "Small description for vite-basic-compat goes here",
6+
"repository": "",
7+
"license": "MIT",
8+
"author": "",
9+
"directories": {
10+
"doc": "doc",
11+
"test": "tests"
12+
},
13+
"scripts": {
14+
"test": "pnpm tsc --noEmit"
15+
},
16+
"devDependencies": {
17+
"@babel/core": "^7.24.5",
18+
"@babel/eslint-parser": "^7.25.9",
19+
"@babel/plugin-transform-runtime": "^7.25.9",
20+
"@babel/plugin-transform-typescript": "^7.25.9",
21+
"@babel/runtime": "^7.26.0",
22+
"ember-data": "file:./packages/ember-data.tgz",
23+
"@ember-data/adapter": "file:./packages/ember-data-adapter.tgz",
24+
"@ember-data/debug": "file:./packages/ember-data-debug.tgz",
25+
"@ember-data/graph": "file:./packages/ember-data-graph.tgz",
26+
"@ember-data/json-api": "file:./packages/ember-data-json-api.tgz",
27+
"@ember-data/legacy-compat": "file:./packages/ember-data-legacy-compat.tgz",
28+
"@ember-data/model": "file:./packages/ember-data-model.tgz",
29+
"@ember-data/request": "file:./packages/ember-data-request.tgz",
30+
"@ember-data/request-utils": "file:./packages/ember-data-request-utils.tgz",
31+
"@ember-data/rest": "file:./packages/ember-data-rest.tgz",
32+
"@ember-data/serializer": "file:./packages/ember-data-serializer.tgz",
33+
"@ember-data/store": "file:./packages/ember-data-store.tgz",
34+
"@ember-data/tracking": "file:./packages/ember-data-tracking.tgz",
35+
"@warp-drive/build-config": "file:./packages/warp-drive-build-config.tgz",
36+
"@warp-drive/core-types": "file:./packages/warp-drive-core-types.tgz",
37+
"@types/ember": "^4.0.8",
38+
"@types/ember-data": "^4.4.13",
39+
"@types/ember-data__adapter": "^4.0.4",
40+
"@types/ember-data__model": "^4.0.3",
41+
"@types/ember-data__serializer": "^4.0.4",
42+
"@types/ember-data__store": "^4.0.5",
43+
"@types/ember__application": "^4.0.9",
44+
"@types/ember__array": "^4.0.7",
45+
"@types/ember__component": "^4.0.19",
46+
"@types/ember__controller": "^4.0.9",
47+
"@types/ember__debug": "^4.0.6",
48+
"@types/ember__destroyable": "^4.0.3",
49+
"@types/ember__engine": "^4.0.8",
50+
"@types/ember__error": "^4.0.4",
51+
"@types/ember__helper": "^4.0.4",
52+
"@types/ember__modifier": "^4.0.7",
53+
"@types/ember__object": "^4.0.9",
54+
"@types/ember__owner": "^4.0.7",
55+
"@types/ember__polyfills": "^4.0.4",
56+
"@types/ember__routing": "^4.0.17",
57+
"@types/ember__runloop": "^4.0.7",
58+
"@types/ember__service": "^4.0.6",
59+
"@types/ember__string": "^3.16.3",
60+
"@types/ember__template": "^4.0.4",
61+
"@types/ember__test": "^4.0.4",
62+
"@types/ember__utils": "^4.0.5",
63+
"@ember/optional-features": "^2.1.0",
64+
"@ember/string": "^4.0.0",
65+
"@ember/test-helpers": "^4.0.4",
66+
"@ember/test-waiters": "^3.1.0",
67+
"@embroider/compat": "3.7.1-unstable.4070ba7",
68+
"@embroider/config-meta-loader": "0.0.1-unstable.4070ba7",
69+
"@embroider/core": "3.4.20-unstable.4070ba7",
70+
"@embroider/test-setup": "4.0.1-unstable.4070ba7",
71+
"@embroider/vite": "0.2.2-unstable.4070ba7",
72+
"@glimmer/component": "^1.1.2",
73+
"@glimmer/tracking": "^1.1.2",
74+
"@glint/core": "1.5.0",
75+
"@rollup/plugin-babel": "^6.0.4",
76+
"@tsconfig/ember": "^3.0.8",
77+
"@types/eslint__js": "^8.42.3",
78+
"@types/qunit": "2.19.10",
79+
"@types/rsvp": "^4.0.9",
80+
"@typescript-eslint/eslint-plugin": "^8.14.0",
81+
"@typescript-eslint/parser": "^8.14.0",
82+
"babel-plugin-ember-template-compilation": "^2.3.0",
83+
"concurrently": "^9.1.0",
84+
"decorator-transforms": "^2.3.0",
85+
"ember-auto-import": "^2.8.1",
86+
"ember-cli": "~5.12.0",
87+
"ember-cli-babel": "^8.2.0",
88+
"ember-cli-htmlbars": "^6.3.0",
89+
"ember-load-initializers": "^3.0.1",
90+
"ember-modifier": "^4.2.0",
91+
"ember-page-title": "^8.2.3",
92+
"ember-qunit": "9.0.1",
93+
"ember-resolver": "^13.1.0",
94+
"ember-route-template": "^1.0.3",
95+
"ember-source": "~5.12.0",
96+
"ember-template-lint": "^6.0.0",
97+
"ember-welcome-page": "^7.0.2",
98+
"eslint": "^9.14.0",
99+
"eslint-config-prettier": "^9.1.0",
100+
"eslint-plugin-ember": "^12.3.1",
101+
"eslint-plugin-n": "^17.13.1",
102+
"eslint-plugin-prettier": "^5.2.1",
103+
"eslint-plugin-qunit": "^8.1.2",
104+
"expect-type": "^0.20.0",
105+
"globals": "^15.12.0",
106+
"loader.js": "^4.7.0",
107+
"prettier": "^3.3.3",
108+
"prettier-plugin-ember-template-tag": "^2.0.4",
109+
"qunit": "^2.22.0",
110+
"qunit-dom": "^3.3.0",
111+
"tracked-built-ins": "^3.3.0",
112+
"typescript": "^5.7.2",
113+
"typescript-eslint": "^8.13.0",
114+
"vite": "^5.4.11",
115+
"webpack": "^5.95.0"
116+
},
117+
"engines": {
118+
"node": ">= 18"
119+
},
120+
"ember": {
121+
"edition": "octane"
122+
},
123+
"ember-addon": {
124+
"type": "app",
125+
"version": 2
126+
},
127+
"exports": {
128+
"./tests/*": "./tests/*",
129+
"./*": "./app/*"
130+
}
131+
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"include": ["app/**/*", "config/**/*", "tests/**/*"],
3+
"glint": { "environment": [] },
4+
"compilerOptions": {
5+
"lib": ["DOM", "ESNext"],
6+
"module": "esnext",
7+
"target": "esnext",
8+
"moduleResolution": "bundler",
9+
"moduleDetection": "force",
10+
"strict": true,
11+
"pretty": true,
12+
"exactOptionalPropertyTypes": false,
13+
"downlevelIteration": true,
14+
"skipLibCheck": true,
15+
"allowSyntheticDefaultImports": true,
16+
"forceConsistentCasingInFileNames": true,
17+
"allowJs": true,
18+
"baseUrl": ".",
19+
"noImplicitOverride": false,
20+
"experimentalDecorators": true,
21+
"incremental": true,
22+
"noEmit": true,
23+
"declaration": false,
24+
"types": ["@embroider/core/virtual"],
25+
"paths": {
26+
"vite-basic-compat/*": ["./app/*"],
27+
"vite-basic-compat/tests/*": ["./tess/*"],
28+
"*": ["./types/*"]
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Catch-all for ember-data.
3+
*/
4+
export default interface ModelRegistry {
5+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6+
[key: string]: any;
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="@embroider/core/virtual" />

0 commit comments

Comments
 (0)