Skip to content

Commit 83c9d75

Browse files
authored
Merge pull request #6 from typed-ember/test-ts-nightly-and-windows
2 parents 019254a + cc2c556 commit 83c9d75

File tree

17 files changed

+114
-32
lines changed

17 files changed

+114
-32
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
CI: true
1717

1818
jobs:
19-
test-defaults:
19+
test:
2020
name: Test
2121
runs-on: ubuntu-latest
2222
steps:
@@ -26,6 +26,15 @@ jobs:
2626
uses: actions/setup-node@v1
2727
with:
2828
node-version: 12
29+
- name: Locate Yarn Cache
30+
id: yarn-cache-dir-path
31+
run: echo "::set-output name=dir::$(yarn cache dir)"
32+
- uses: actions/cache@v2
33+
with:
34+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
35+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-yarn-
2938
- name: Install Dependencies
3039
run: yarn install --frozen-lockfile
3140
- name: Lint
@@ -34,3 +43,57 @@ jobs:
3443
run: yarn build
3544
- name: Run Tests
3645
run: yarn test
46+
47+
test-windows:
48+
name: Test Windows
49+
needs: [test]
50+
runs-on: windows-latest
51+
steps:
52+
- name: Checkout Code
53+
uses: actions/checkout@v2
54+
- name: Install Node
55+
uses: actions/setup-node@v1
56+
with:
57+
node-version: 12
58+
- name: Locate Yarn Cache
59+
id: yarn-cache-dir-path
60+
run: echo "::set-output name=dir::$(yarn cache dir)"
61+
- uses: actions/cache@v2
62+
with:
63+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
64+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
65+
restore-keys: |
66+
${{ runner.os }}-yarn-
67+
- name: Install Dependencies
68+
run: yarn install --frozen-lockfile
69+
- name: Build
70+
run: yarn build
71+
- name: Run Tests
72+
run: yarn test
73+
74+
test-versions:
75+
name: Test TypeScript Nightly
76+
needs: [test]
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout Code
80+
uses: actions/checkout@v2
81+
- name: Install Node
82+
uses: actions/setup-node@v1
83+
with:
84+
node-version: 12
85+
- name: Locate Yarn Cache
86+
id: yarn-cache-dir-path
87+
run: echo "::set-output name=dir::$(yarn cache dir)"
88+
- uses: actions/cache@v2
89+
with:
90+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
91+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
92+
restore-keys: |
93+
${{ runner.os }}-yarn-
94+
- name: Install Dependencies
95+
run: yarn add --dev -W typescript@next
96+
- name: Build
97+
run: yarn build
98+
- name: Run Tests
99+
run: yarn test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
yarn-error.log

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"prettier": "^2.0.5",
2323
"release-it": "^13.6.3",
2424
"release-it-lerna-changelog": "^2.3.0",
25-
"release-it-yarn-workspaces": "^1.4.0"
25+
"release-it-yarn-workspaces": "^1.4.0",
26+
"typescript": "^3.9.5"
2627
},
2728
"version": "0.1.2"
2829
}

packages/cli/__tests__/utils/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class Project {
5757
}
5858

5959
public check(options: Options & { flags?: string[] } = {}): ExecaChildProcess {
60-
return execa(`${__dirname}/../../bin/glint.js`, options.flags, {
60+
return execa.node(`${__dirname}/../../bin/glint`, options.flags, {
6161
cwd: this.rootDir,
6262
...options,
6363
});

packages/cli/__tests__/watch.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { stripIndent } from 'common-tags';
22
import stripAnsi from 'strip-ansi';
3+
import os from 'os';
34
import Project from './utils/project';
45

56
describe('watched typechecking', () => {
@@ -68,10 +69,10 @@ describe('watched typechecking', () => {
6869
await watch.terminate();
6970

7071
let stripped = stripAnsi(output);
71-
let error = stripped.slice(stripped.indexOf('index.ts'), stripped.lastIndexOf('~~~\n') + 3);
72+
let error = stripped.slice(stripped.indexOf('index.ts'), stripped.lastIndexOf(`~~~${os.EOL}`) + 3);
7273

7374
expect(output).toMatch('Found 1 error.');
74-
expect(error).toMatchInlineSnapshot(`
75+
expect(error.replace(/\r/g, '')).toMatchInlineSnapshot(`
7576
"index.ts:11:28 - error TS0: [glint] Parse error on line 2:
7677
...e to app v{{@version}. The current t
7778
-----------------------^
@@ -109,10 +110,10 @@ describe('watched typechecking', () => {
109110
await watch.terminate();
110111

111112
let stripped = stripAnsi(output);
112-
let error = stripped.slice(stripped.indexOf('index.ts'), stripped.lastIndexOf(`~~~\n`) + 3);
113+
let error = stripped.slice(stripped.indexOf('index.ts'), stripped.lastIndexOf(`~~~${os.EOL}`) + 3);
113114

114115
expect(output).toMatch('Found 1 error.');
115-
expect(error).toMatchInlineSnapshot(`
116+
expect(error.replace(/\r/g, '')).toMatchInlineSnapshot(`
116117
"index.ts:13:32 - error TS2551: Property 'startupTimee' does not exist on type 'Application'. Did you mean 'startupTime'?
117118
118119
13 The current time is {{this.startupTimee}}.

packages/cli/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"execa": "^4.0.1",
3232
"jest": "^25.2.1",
3333
"strip-ansi": "^6.0.0",
34-
"ts-jest": "^25.5.1",
35-
"typescript": "^3.9.5"
34+
"ts-jest": "^25.5.1"
3635
}
3736
}

packages/config/__tests__/include-exclude.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import path from 'path';
12
import { GlintConfig } from '../src';
23

34
describe('include/exclude configuration', () => {
4-
const root = '/foo/bar';
5+
const root = path.resolve('/foo/bar');
56

67
describe('defaults', () => {
78
const config = new GlintConfig(root, {});

packages/config/__tests__/load-config.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os from 'os';
22
import fs from 'fs';
3-
import { loadConfig } from '../src';
3+
import { loadConfig, normalizePath } from '../src';
44

55
describe('loadConfig', () => {
66
const testDir = `${os.tmpdir()}/glint-config-test-${process.pid}`;
@@ -17,7 +17,7 @@ describe('loadConfig', () => {
1717
test('returns a default config if none is found', () => {
1818
let config = loadConfig(testDir);
1919

20-
expect(config.rootDir).toBe(testDir);
20+
expect(config.rootDir).toBe(normalizePath(testDir));
2121
expect(config.includesFile(`${testDir}/index.ts`)).toBe(true);
2222
expect(config.includesFile(__filename)).toBe(false);
2323
});
@@ -29,7 +29,7 @@ describe('loadConfig', () => {
2929

3030
let config = loadConfig(`${testDir}/deeply/nested/directory`);
3131

32-
expect(config.rootDir).toBe(`${testDir}/deeply`);
32+
expect(config.rootDir).toBe(normalizePath(`${testDir}/deeply`));
3333
expect(config.includesFile(`${testDir}/deeply/index.ts`)).toBe(false);
3434
expect(config.includesFile(`${testDir}/deeply/index.root.ts`)).toBe(false);
3535
expect(config.includesFile(`${testDir}/deeply/index.nested.ts`)).toBe(true);

packages/config/src/index.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,37 @@ export function loadConfig(from: string): GlintConfig {
1616
}
1717

1818
export class GlintConfig {
19+
public readonly rootDir: string;
20+
1921
private includeMatchers: Array<IMinimatch>;
2022
private excludeMatchers: Array<IMinimatch>;
2123

22-
public constructor(public readonly rootDir: string, config: Record<string, unknown> = {}) {
24+
public constructor(rootDir: string, config: Record<string, unknown> = {}) {
2325
validateInput(config);
2426

27+
this.rootDir = normalizePath(rootDir);
28+
2529
let include = Array.isArray(config.include) ? config.include : [config.include ?? '**/*.ts'];
2630
let exclude = Array.isArray(config.exclude)
2731
? config.exclude
2832
: [config.exclude ?? '**/node_modules/**'];
2933

30-
this.includeMatchers = include.map((glob) => new Minimatch(path.resolve(rootDir, glob)));
31-
this.excludeMatchers = exclude.map((glob) => new Minimatch(path.resolve(rootDir, glob)));
34+
this.includeMatchers = this.buildMatchers(include);
35+
this.excludeMatchers = this.buildMatchers(exclude);
3236
}
3337

34-
public includesFile(fileName: string): boolean {
38+
public includesFile(rawFileName: string): boolean {
39+
let fileName = normalizePath(rawFileName);
40+
3541
return (
3642
this.excludeMatchers.every((matcher) => !matcher.match(fileName)) &&
3743
this.includeMatchers.some((matcher) => matcher.match(fileName))
3844
);
3945
}
46+
47+
private buildMatchers(globs: Array<string>): Array<IMinimatch> {
48+
return globs.map((glob) => new Minimatch(normalizePath(path.resolve(this.rootDir, glob))));
49+
}
4050
}
4151

4252
export type GlintConfigInput = {
@@ -65,3 +75,11 @@ function assert(test: unknown, message: string): asserts test {
6575
throw new Error(`@glint/config: ${message}`);
6676
}
6777
}
78+
79+
export function normalizePath(fileName: string): string {
80+
if (path.sep !== '/') {
81+
return fileName.split(path.sep).join('/');
82+
}
83+
84+
return fileName;
85+
}

packages/template/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"@glimmerx/component": "^0.2.2",
2020
"@types/ember__component": "~3.0.7",
2121
"expect-type": "^0.7.4",
22-
"sums-up": "^2.1.0",
23-
"typescript": "^3.9.5"
22+
"sums-up": "^2.1.0"
2423
}
2524
}

packages/transform/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"@types/jest": "^25.2.1",
3131
"common-tags": "^1.8.0",
3232
"jest": "^25.4.0",
33-
"ts-jest": "^25.4.0",
34-
"typescript": "^3.9.5"
33+
"ts-jest": "^25.4.0"
3534
}
3635
}

packages/tsserver-plugin/__tests__/integration.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { stripIndent } from 'common-tags';
2+
import os from 'os';
23
import Protocol, { CommandTypes } from 'typescript/lib/protocol';
34
import { TSServer, Project } from './test-server';
45

@@ -7,6 +8,7 @@ describe('tsserver plugin', () => {
78
let project!: Project;
89

910
beforeAll(async () => {
11+
jest.setTimeout(10_000);
1012
server = await new TSServer().start({
1113
listenForDebugger: false,
1214
printMessages: false,
@@ -434,7 +436,7 @@ describe('tsserver plugin', () => {
434436
fileName: project.filePath('index.ts'),
435437
textChanges: [
436438
{
437-
newText: `import Greeting from './greeting';\n`,
439+
newText: `import Greeting from './greeting';${os.EOL}`,
438440
start: { line: 3, offset: 1 },
439441
end: { line: 3, offset: 1 },
440442
},

packages/tsserver-plugin/__tests__/test-server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import fs from 'fs';
55
import path from 'path';
66
import { EventEmitter } from 'events';
77
import Protocol, { CommandTypes, WatchFileKind } from 'typescript/lib/protocol';
8+
import { normalizePath } from '@glint/config';
89

910
export type Requests = {
1011
[CommandTypes.SemanticDiagnosticsSync]: [
@@ -60,7 +61,7 @@ export class Project {
6061
constructor(private server: TSServer) {}
6162

6263
public filePath(fileName: string): string {
63-
return path.join(this.rootDir, fileName);
64+
return normalizePath(path.join(this.rootDir, fileName));
6465
}
6566

6667
public async create(

packages/tsserver-plugin/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"devDependencies": {
2424
"@types/jest": "^25.2.1",
2525
"jest": "^25.5.4",
26-
"ts-jest": "^25.4.0",
27-
"typescript": "^3.9.5"
26+
"ts-jest": "^25.4.0"
2827
}
2928
}

test-packages/demo-app/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"qunit-dom": "^1.1.0",
5353
"style-loader": "^1.1.3",
5454
"testem": "^3.0.3",
55-
"typescript": "~3.8.3",
5655
"webpack": "^4.42.1",
5756
"webpack-cli": "^3.3.11",
5857
"webpack-dev-server": "^3.10.3"

test-packages/demo-app/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"experimentalDecorators": true,
99
"noEmit": true,
1010
"types": ["qunit"],
11-
"plugins": [{ "name": "@glint/tsserver-plugin", "logFile": "glint.log" }]
11+
"plugins": [{ "name": "@glint/tsserver-plugin", "logFile": "glint.log" }],
12+
// Not ideal, but several of the @glimmer packages fairly consistently
13+
// produce type errors across different versions.
14+
"skipLibCheck": true
1215
},
1316
"exclude": ["node_modules", "tmp", "dist"]
1417
}

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10646,11 +10646,6 @@ typescript@^3.9.5:
1064610646
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36"
1064710647
integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==
1064810648

10649-
typescript@~3.8.3:
10650-
version "3.8.3"
10651-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
10652-
integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
10653-
1065410649
uglify-js@^3.1.4:
1065510650
version "3.10.0"
1065610651
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.10.0.tgz#397a7e6e31ce820bfd1cb55b804ee140c587a9e7"

0 commit comments

Comments
 (0)