Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 3905d6f

Browse files
authored
test(projects): add a new check to ensure that typings are correct (#1164)
* test(projects): add a new check to ensure that typings are correct * add to steps * use tsc * fix hang on windows * try to run by step * update example
1 parent b1ff006 commit 3905d6f

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

build/gulp/tasks/test-projects.tsx

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as express from 'express'
22
import * as fs from 'fs'
3-
import { parallel, series, task } from 'gulp'
3+
import { series, task } from 'gulp'
44
import { rollup as lernaAliases } from 'lerna-alias'
55
import * as path from 'path'
66
import * as portfinder from 'portfinder'
@@ -101,7 +101,10 @@ const performBrowserTest = async (publicDirectory: string, listenPort: number) =
101101
const server = await startServer(publicDirectory, listenPort)
102102

103103
const browser = await puppeteer.launch({
104-
args: ['--single-process'], // Workaround for newPage hang in CircleCI: https://github.com/GoogleChrome/puppeteer/issues/1409#issuecomment-453845568
104+
args: [
105+
// Workaround for newPage hang in CircleCI: https://github.com/GoogleChrome/puppeteer/issues/1409#issuecomment-453845568
106+
process.env.CI && '--single-process',
107+
].filter(Boolean),
105108
})
106109
const page = await browser.newPage()
107110
let error: Error
@@ -199,7 +202,45 @@ task('test:projects:rollup', async () => {
199202
logger(`✔️Browser test was passed`)
200203
})
201204

205+
task('test:projects:typings', async () => {
206+
const logger = log('test:projects:typings')
207+
208+
const scaffoldPath = paths.base.bind(null, 'build/gulp/tasks/test-projects/typings')
209+
const tmpDirectory = tmp.dirSync({ prefix: 'stardust-' }).name
210+
211+
logger(`✔️Temporary directory was created: ${tmpDirectory}`)
212+
213+
const dependencies = [
214+
'@types/react',
215+
'@types/react-dom',
216+
'react',
217+
'react-dom',
218+
'typescript',
219+
].join(' ')
220+
await runIn(tmpDirectory)(`yarn add ${dependencies}`)
221+
logger(`✔️Dependencies were installed`)
222+
223+
const packedPackages = await packStardustPackages(logger)
224+
await addResolutionPathsForStardustPackages(tmpDirectory, packedPackages)
225+
await runIn(tmpDirectory)(`yarn add ${packedPackages['@stardust-ui/react']}`)
226+
logger(`✔️Stardust UI packages were added to dependencies`)
227+
228+
fs.mkdirSync(path.resolve(tmpDirectory, 'src'))
229+
fs.copyFileSync(scaffoldPath('index.tsx'), path.resolve(tmpDirectory, 'src/index.tsx'))
230+
fs.copyFileSync(scaffoldPath('tsconfig.json'), path.resolve(tmpDirectory, 'tsconfig.json'))
231+
logger(`✔️Source and configs were copied`)
232+
233+
await runIn(tmpDirectory)(`yarn tsc --noEmit`)
234+
logger(`✔️Example project was successfully built: ${tmpDirectory}`)
235+
})
236+
202237
task(
203238
'test:projects',
204-
series('dll', 'bundle:all-packages', parallel('test:projects:cra-ts', 'test:projects:rollup')),
239+
series(
240+
'dll',
241+
'bundle:all-packages',
242+
'test:projects:cra-ts',
243+
'test:projects:rollup',
244+
'test:projects:typings',
245+
),
205246
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Stardust from '@stardust-ui/react'
2+
import * as React from 'react'
3+
4+
const App = () => (
5+
<Stardust.Provider theme={Stardust.themes.teams}>
6+
<Stardust.Button content="Click me" />
7+
</Stardust.Provider>
8+
)
9+
10+
export default App
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"jsx": "react",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"target": "es5"
6+
},
7+
"include": ["src"]
8+
}

0 commit comments

Comments
 (0)