Skip to content

Commit

Permalink
feat: add typescript typings (#577)
Browse files Browse the repository at this point in the history
* This adds typescript typings for the API
  • Loading branch information
lholmquist committed Jul 28, 2021
1 parent b20701e commit e6f09f5
Show file tree
Hide file tree
Showing 6 changed files with 447 additions and 16 deletions.
392 changes: 392 additions & 0 deletions index.d.ts

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const cli = require('./bin/cli');
/**
The login function will login
@param {object} [options] - Options object for the deploy function
@param {object} [options] - Options object for the login function
@param {string} [options.projectLocation] - the location(directory) of your projects package.json. Defaults to `process.cwd`
@param {string} [options.token] - auth token to pass into the openshift rest client for logging in with the API Server. Overrides the username/password
@param {string} [options.username] - username to pass into the openshift rest client for logging in with the API Server
@param {string} [options.password] - password to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - @deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.server] - server to pass into the openshift rest client for logging in with the API Server
@param {string} [options.insecure] - flag to pass into the openshift rest client for logging in with a self signed cert. Only used with apiServer login. default to false
@param {string} [options.forceLogin] - Force a login when using the apiServer login. Only used with apiServer login. default to false
Expand All @@ -27,9 +27,9 @@ function login (options = {}) {
}

/**
The login function will login
The logout function will logout
@param {object} [options] - Options object for the deploy function
@param {object} [options] - Options object for the logout function
@param {string} [options.projectLocation] - the location(directory) of your projects package.json. Defaults to `process.cwd`
*/
function logout (options = {}) {
Expand All @@ -40,12 +40,12 @@ function logout (options = {}) {
/**
The getNodeshiftConfig function will return the config
@param {object} [options] - Options object for the deploy function
@param {object} [options] - Options object for the getNodeshiftConfig function
@param {string} [options.projectLocation] - the location(directory) of your projects package.json. Defaults to `process.cwd`
@param {string} [options.token] - auth token to pass into the openshift rest client for logging in with the API Server. Overrides the username/password
@param {string} [options.username] - username to pass into the openshift rest client for logging in with the API Server
@param {string} [options.password] - password to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - @deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - Deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.server] - server to pass into the openshift rest client for logging in with the API Server
@param {string} [options.insecure] - flag to pass into the openshift rest client for logging in with a self signed cert. Only used with apiServer login. default to false
@param {string} [options.forceLogin] - Force a login when using the apiServer login. Only used with apiServer login. default to false
Expand Down Expand Up @@ -87,7 +87,7 @@ function getNodeshiftConfig (options = {}) {
@param {string} [options.token] - auth token to pass into the openshift rest client for logging in with the API Server. Overrides the username/password
@param {string} [options.username] - username to pass into the openshift rest client for logging in with the API Server
@param {string} [options.password] - password to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - @deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - Deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.server] - server to pass into the openshift rest client for logging in with the API Server
@param {string} [options.insecure] - flag to pass into the openshift rest client for logging in with a self signed cert. Only used with apiServer login. default to false
@param {string} [options.forceLogin] - Force a login when using the apiServer login. Only used with apiServer login. default to false
Expand Down Expand Up @@ -130,7 +130,7 @@ function deploy (options = {}) {
@param {string} [options.token] - auth token to pass into the openshift rest client for logging in with the API Server. Overrides the username/password
@param {string} [options.username] - username to pass into the openshift rest client for logging in with the API Server
@param {string} [options.password] - password to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - @deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - Deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.server] - server to pass into the openshift rest client for logging in with the API Server
@param {string} [options.insecure] - flag to pass into the openshift rest client for logging in with a self signed cert. Only used with apiServer login. default to false
@param {string} [options.forceLogin] - Force a login when using the apiServer login. Only used with apiServer login. default to false
Expand Down Expand Up @@ -166,7 +166,7 @@ function resource (options = {}) {
@param {string} [options.token] - auth token to pass into the openshift rest client for logging in with the API Server. Overrides the username/password
@param {string} [options.username] - username to pass into the openshift rest client for logging in with the API Server
@param {string} [options.password] - password to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - @deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - Deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.server] - server to pass into the openshift rest client for logging in with the API Server
@param {string} [options.insecure] - flag to pass into the openshift rest client for logging in with a self signed cert. Only used with apiServer login. default to false
@param {string} [options.forceLogin] - Force a login when using the apiServer login. Only used with apiServer login. default to false
Expand Down Expand Up @@ -206,7 +206,7 @@ function applyResource (options = {}) {
@param {string} [options.token] - auth token to pass into the openshift rest client for logging in with the API Server. Overrides the username/password
@param {string} [options.username] - username to pass into the openshift rest client for logging in with the API Server
@param {string} [options.password] - password to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - @deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - Deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.server] - server to pass into the openshift rest client for logging in with the API Server
@param {string} [options.insecure] - flag to pass into the openshift rest client for logging in with a self signed cert. Only used with apiServer login. default to false
@param {string} [options.forceLogin] - Force a login when using the apiServer login. Only used with apiServer login. default to false
Expand Down Expand Up @@ -245,7 +245,7 @@ function undeploy (options = {}) {
@param {string} [options.token] - auth token to pass into the openshift rest client for logging in with the API Server. Overrides the username/password
@param {string} [options.username] - username to pass into the openshift rest client for logging in with the API Server
@param {string} [options.password] - password to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - @deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.apiServer] - Deprecated - use server instead. apiServer to pass into the openshift rest client for logging in with the API Server
@param {string} [options.server] - server to pass into the openshift rest client for logging in with the API Server
@param {string} [options.insecure] - flag to pass into the openshift rest client for logging in with a self signed cert. Only used with apiServer login. default to false
@param {string} [options.forceLogin] - Force a login when using the apiServer login. Only used with apiServer login. default to false
Expand Down
25 changes: 22 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"nodeshift": "./bin/nodeshift"
},
"scripts": {
"types": "tsc",
"prepare": "husky install",
"pretest": "eslint --ignore-path .gitignore .",
"test": "cross-env NODESHIFT_QUIET=true nyc tape test/*-test.js test/**/*-test.js | tap-spec",
Expand All @@ -20,8 +21,10 @@
"precommit": "git add docs/"
}
},
"typings":"index.d.ts",
"files": [
"index.js",
"index.d.ts",
"example.js",
"lib",
"bin",
Expand Down Expand Up @@ -73,7 +76,8 @@
"sinon": "~9.2.4",
"standard-version": "^9.3.0",
"tap-spec": "^5.0.0",
"tape": "~4.13.2"
"tape": "~4.13.2",
"typescript": "~4.3.5"
},
"support": true
}
2 changes: 1 addition & 1 deletion test/helpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('checks existing and nonexistent files', (t) => {
const fileList = require('../package.json').files;
fileList.push('bar');
const result = helpers.normalizeFileList(fileList, process.cwd());
t.deepEqual(result.existing, ['index.js', 'lib', 'bin', 'package-support.json'], `existing files: ${result.existing}`);
t.deepEqual(result.existing, ['index.js', 'index.d.ts', 'lib', 'bin', 'package-support.json'], `existing files: ${result.existing}`);
t.deepEqual(result.nonexistent, ['example.js', 'bar'], 'example.js and bar do not exist.');
t.end();
});
Expand Down
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Change this to match your project
"files": ["index.js"],
"compilerOptions": {
// Tells TypeScript to read JS files, as
// normally they are ignored as source files
"allowJs": true,
// Generate d.ts files
"declaration": true,
// This compiler run should
// only output d.ts files
"emitDeclarationOnly": true,
"skipLibCheck": true,
"noResolve": true,
}
}

0 comments on commit e6f09f5

Please sign in to comment.