-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from buschtoens/feat/typescript-types
feat(build): generate TypeScript declaration file
- Loading branch information
Showing
9 changed files
with
75 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# compiled output | ||
/dist | ||
/tmp | ||
/index.d.ts | ||
|
||
# dependencies | ||
/node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ bower.json.ember-try | |
package.json.ember-try | ||
|
||
/node-tests | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const VersionChecker = require('ember-cli-version-checker'); | ||
const getFlags = require('../utils/get-flags'); | ||
|
||
/** | ||
* Calls the `get-flags` util with mock inputs in order to retrieve the actual | ||
* flag keys. | ||
*/ | ||
module.exports = Object.keys( | ||
getFlags('0.0.0', new VersionChecker({ root: __dirname })) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
const booleanFlags = require('./boolean-flags'); | ||
|
||
/** | ||
* Generates type declarations for the `comparison-plugin` (`gte`, `lte`) and | ||
* and the debug plugin (boolean flags). | ||
*/ | ||
module.exports = [ | ||
'export function gte(version: string): boolean;', | ||
'export function lte(version: string): boolean;' | ||
] | ||
.concat(booleanFlags.map(b => `export const ${b}: boolean;`)) | ||
.join('\n'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const types = require('./types'); | ||
|
||
fs.writeFileSync(path.resolve(__dirname, '../index.d.ts'), types); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
const extractTrueVersion = require('./extract-true-version'); | ||
const semver = require('semver'); | ||
const satisfies = semver.satisfies; | ||
const gte = semver.gte; | ||
|
||
module.exports = function(emberVersion, parentChecker) { | ||
const trueEmberVersion = extractTrueVersion(emberVersion); | ||
const emberDataVersion = parentChecker.for('ember-data', 'npm').version; | ||
|
||
return { | ||
HAS_UNDERSCORE_ACTIONS: !gte(trueEmberVersion, '2.0.0'), | ||
HAS_MODERN_FACTORY_INJECTIONS: gte(trueEmberVersion, '2.13.0'), | ||
HAS_DESCRIPTOR_TRAP: satisfies(trueEmberVersion, '~3.0.0'), | ||
HAS_NATIVE_COMPUTED_GETTERS: gte(trueEmberVersion, '3.1.0-beta.1'), | ||
|
||
IS_GLIMMER_2: gte(trueEmberVersion, '2.10.0'), | ||
IS_RECORD_DATA: !emberDataVersion ? false : gte(emberDataVersion, '3.5.0'), | ||
|
||
SUPPORTS_FACTORY_FOR: | ||
gte(trueEmberVersion, '2.12.0') || | ||
parentChecker.for('ember-factory-for-polyfill', 'npm').gte('1.0.0'), | ||
SUPPORTS_GET_OWNER: | ||
gte(trueEmberVersion, '2.3.0') || | ||
parentChecker.for('ember-getowner-polyfill', 'npm').gte('1.1.0'), | ||
SUPPORTS_SET_OWNER: gte(trueEmberVersion, '2.3.0'), | ||
SUPPORTS_NEW_COMPUTED: gte(trueEmberVersion, '1.12.0-beta.1'), | ||
SUPPORTS_INVERSE_BLOCK: gte(trueEmberVersion, '1.13.0'), | ||
SUPPORTS_CLOSURE_ACTIONS: gte(trueEmberVersion, '1.13.0'), | ||
SUPPORTS_UNIQ_BY_COMPUTED: gte(trueEmberVersion, '2.7.0') | ||
}; | ||
}; |