From 86a249bbf005289255f8e96ac9dc94d5cb3754a6 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Sun, 26 Apr 2020 02:32:52 +0100 Subject: [PATCH 1/9] ci: give import test a package.json file --- .circleci/config.yml | 4 ++-- test-import/index.ts | 0 test-import/package.json | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test-import/index.ts create mode 100644 test-import/package.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 28280c6..6a32ead 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -123,10 +123,10 @@ commands: command: npm pack - run: name: Setup Import Test - command: echo $PWD && cd .. && mkdir test-import && cp -a project/test-import/ test-import/test-import/ && cd test-import && npm init -y && npm i ../project/is-promise-2.2.2.tgz + command: echo $PWD && cd .. && cp -a project/test-import/ test-import/ && cd test-import && npm i ../project/is-promise-2.2.2.tgz - run: name: Test Import - command: cd ../test-import && node test-import/test.js + command: cd ../test-import && npm test publish-dry-run: steps: diff --git a/test-import/index.ts b/test-import/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/test-import/package.json b/test-import/package.json new file mode 100644 index 0000000..7b0831e --- /dev/null +++ b/test-import/package.json @@ -0,0 +1,8 @@ +{ + "name": "is-promise-test-import", + "private": true, + "@rollingversions/ignore": true, + "scripts": { + "test": "node test" + } +} \ No newline at end of file From 9b8d584f8ffaa41a605262548c27901602f54a1f Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Sun, 26 Apr 2020 02:38:10 +0100 Subject: [PATCH 2/9] test: test typescript definitions --- test-import/index.ts | 9 +++++++++ test-import/package-lock.json | 17 +++++++++++++++++ test-import/package.json | 8 ++++++-- test-import/tsconfig.json | 5 +++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 test-import/package-lock.json create mode 100644 test-import/tsconfig.json diff --git a/test-import/index.ts b/test-import/index.ts index e69de29..c66f943 100644 --- a/test-import/index.ts +++ b/test-import/index.ts @@ -0,0 +1,9 @@ +import * as ta from 'type-assertions'; +import isPromise from '../'; + +declare const x: number | Promise; +if (isPromise(x)) { + ta.assert>>(); +} else { + ta.assert>(); +} \ No newline at end of file diff --git a/test-import/package-lock.json b/test-import/package-lock.json new file mode 100644 index 0000000..700114b --- /dev/null +++ b/test-import/package-lock.json @@ -0,0 +1,17 @@ +{ + "name": "is-promise-test-import", + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "type-assertions": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/type-assertions/-/type-assertions-1.1.0.tgz", + "integrity": "sha512-LJ5h6n63vxS8fSdfTPqIc6IrbCo9X3g6Se+wSikCGsqaAI3ajN0iputclNG07wdWfBoQZIrpASjBQo5BeVNrAg==" + }, + "typescript": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", + "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==" + } + } +} diff --git a/test-import/package.json b/test-import/package.json index 7b0831e..d980a50 100644 --- a/test-import/package.json +++ b/test-import/package.json @@ -3,6 +3,10 @@ "private": true, "@rollingversions/ignore": true, "scripts": { - "test": "node test" + "test": "node test && npx tsc --noEmit index.ts " + }, + "dependencies": { + "type-assertions": "^1.1.0", + "typescript": "*" } -} \ No newline at end of file +} diff --git a/test-import/tsconfig.json b/test-import/tsconfig.json new file mode 100644 index 0000000..d002339 --- /dev/null +++ b/test-import/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strict": true + } +} \ No newline at end of file From 412f683db1d63e635af69b56480089e1c7e27922 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Sun, 26 Apr 2020 02:38:37 +0100 Subject: [PATCH 3/9] fix: import path --- test-import/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-import/index.ts b/test-import/index.ts index c66f943..2ef2089 100644 --- a/test-import/index.ts +++ b/test-import/index.ts @@ -1,5 +1,5 @@ import * as ta from 'type-assertions'; -import isPromise from '../'; +import isPromise from 'is-promise'; declare const x: number | Promise; if (isPromise(x)) { From 1913ef21cb29380aa06dfb25b6cdb0a1e3e93ab0 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Sun, 26 Apr 2020 02:41:28 +0100 Subject: [PATCH 4/9] fix: only test on modern node.js --- test-import/package.json | 2 +- test-import/test.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test-import/package.json b/test-import/package.json index d980a50..844a814 100644 --- a/test-import/package.json +++ b/test-import/package.json @@ -3,7 +3,7 @@ "private": true, "@rollingversions/ignore": true, "scripts": { - "test": "node test && npx tsc --noEmit index.ts " + "test": "node test" }, "dependencies": { "type-assertions": "^1.1.0", diff --git a/test-import/test.js b/test-import/test.js index 50ef5e6..eb7b018 100644 --- a/test-import/test.js +++ b/test-import/test.js @@ -31,5 +31,11 @@ console.log('CommonJS tests passed') if(parseInt(process.version.split('.')[0].substr(1), 10) >= 14) { const result = require('child_process').spawnSync('node', ['test.mjs'], {cwd: __dirname, stdio: 'inherit'}); - process.exit(result.status); + if (result.status) process.exit(result.status); +} + +if(parseInt(process.version.split('.')[0].substr(1), 10) >= 12) { + const result = require('child_process').spawnSync(require.resolve('.bin/tsc'), ['index.ts'], {cwd: __dirname, stdio: 'inherit'}); + if (result.status) process.exit(result.status); + console.log('TypeScript tests passed'); } \ No newline at end of file From 6b0c956b702b9cc000c53e43934367c2911d7d94 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Sun, 26 Apr 2020 02:42:36 +0100 Subject: [PATCH 5/9] ci: stricter ts config --- test-import/tsconfig.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test-import/tsconfig.json b/test-import/tsconfig.json index d002339..8bf3bdd 100644 --- a/test-import/tsconfig.json +++ b/test-import/tsconfig.json @@ -1,5 +1,7 @@ { "compilerOptions": { + "noImplicitAny": true, + "skipLibCheck": false, "strict": true } } \ No newline at end of file From 418a6faf09c95684e721e439be35e8fe5cc0f537 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Sun, 26 Apr 2020 02:43:28 +0100 Subject: [PATCH 6/9] fix: include index.d.ts --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c8a6680..eb3551f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ }, "files": [ "index.js", - "index.mjs" + "index.mjs", + "index.d.ts" ], "repository": { "type": "git", From f9b43c26fedb9b0f7886783682796d0fa2af3233 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Sun, 26 Apr 2020 02:46:13 +0100 Subject: [PATCH 7/9] chore: remove inadvertantly committed package-lock.json --- test-import/package-lock.json | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 test-import/package-lock.json diff --git a/test-import/package-lock.json b/test-import/package-lock.json deleted file mode 100644 index 700114b..0000000 --- a/test-import/package-lock.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "is-promise-test-import", - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "type-assertions": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/type-assertions/-/type-assertions-1.1.0.tgz", - "integrity": "sha512-LJ5h6n63vxS8fSdfTPqIc6IrbCo9X3g6Se+wSikCGsqaAI3ajN0iputclNG07wdWfBoQZIrpASjBQo5BeVNrAg==" - }, - "typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", - "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==" - } - } -} From 92d72b8e6ca1286df7f6497bd2fb77db6b27569b Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Sun, 26 Apr 2020 02:49:16 +0100 Subject: [PATCH 8/9] ci: fix how we reference TypeScript --- test-import/package.json | 3 +-- test-import/test.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test-import/package.json b/test-import/package.json index 844a814..7090b05 100644 --- a/test-import/package.json +++ b/test-import/package.json @@ -6,7 +6,6 @@ "test": "node test" }, "dependencies": { - "type-assertions": "^1.1.0", - "typescript": "*" + "type-assertions": "^1.1.0" } } diff --git a/test-import/test.js b/test-import/test.js index eb7b018..9d0ef7f 100644 --- a/test-import/test.js +++ b/test-import/test.js @@ -35,7 +35,7 @@ if(parseInt(process.version.split('.')[0].substr(1), 10) >= 14) { } if(parseInt(process.version.split('.')[0].substr(1), 10) >= 12) { - const result = require('child_process').spawnSync(require.resolve('.bin/tsc'), ['index.ts'], {cwd: __dirname, stdio: 'inherit'}); + const result = require('child_process').spawnSync('npx', ['typescript', 'index.ts'], {cwd: __dirname, stdio: 'inherit'}); if (result.status) process.exit(result.status); console.log('TypeScript tests passed'); } \ No newline at end of file From 71dd186f725eb91d9b2ed489643dedb37833e0a0 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Sun, 26 Apr 2020 02:50:18 +0100 Subject: [PATCH 9/9] ci: install dependencies --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6a32ead..74caed0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -123,7 +123,7 @@ commands: command: npm pack - run: name: Setup Import Test - command: echo $PWD && cd .. && cp -a project/test-import/ test-import/ && cd test-import && npm i ../project/is-promise-2.2.2.tgz + command: echo $PWD && cd .. && cp -a project/test-import/ test-import/ && cd test-import && npm i && npm i ../project/is-promise-2.2.2.tgz - run: name: Test Import command: cd ../test-import && npm test