Skip to content

Commit

Permalink
fix: include type definitions for programatic API
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Jul 31, 2024
1 parent e70c51d commit 96d6079
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
- name: Lint files
run: npm run lint

- run: npm run types

- name: Run tests
run: npm run test:ci

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ jobs:
- name: Lint files
run: npm run lint

- run: npm run types

- name: Run tests
run: npm run test:ci
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ coverage
.vscode
.eikrc
test/.eik
test-read-json.json
test-read-json.json
types/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
package-lock=false
save-exact=true
1 change: 0 additions & 1 deletion classes/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class Ping {

this.log.debug('Requesting ping from server');
try {
// @ts-expect-error We validate it's a string above
const result = await fetch(this.server);

if (!result.ok) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default class CheckIfAlreadyPublished extends Task {
);
}

// @ts-expect-error
const versionMap = new Map(pkgVersions);
for (const v of versionMap.values()) {
const same = hash.compare(v.integrity, localHash);
Expand Down
1 change: 0 additions & 1 deletion classes/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ export default class Version {
}

log.debug(`Incrementing by "${level}" level`);
// @ts-expect-error
const newVersion = semver.inc(version, level);
log.debug(` ==> ${newVersion}`);
return newVersion;
Expand Down
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.0.39",
"description": "CLI tool for publishing assets to an Eik server",
"main": "./classes/index.js",
"types": "./types/classes/index.d.ts",
"type": "module",
"bin": {
"eik": "index.js"
Expand All @@ -15,7 +16,8 @@
"commands",
"classes",
"utils",
"formatters"
"formatters",
"types"
],
"scripts": {
"test": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --no-coverage-report --no-cov --timeout 0 --test-regex=.test.mjs --test-ignore=node_modules",
Expand All @@ -30,7 +32,10 @@
"lint:fix": "eslint --fix .",
"format:check": "prettier -c .",
"format:fix": "prettier -w .",
"fix": "run-s lint:fix format:fix"
"fix": "run-s lint:fix format:fix",
"types": "run-s types:module types:test",
"types:module": "tsc",
"types:test": "tsc --project tsconfig.test.json"
},
"keywords": [],
"author": "",
Expand All @@ -57,6 +62,7 @@
"@babel/eslint-parser": "^7.25.1",
"@eik/core": "1.2.28",
"@eik/service": "1.2.98",
"@eik/typescript-config": "1.0.0",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"cross-env": "7.0.3",
Expand All @@ -71,6 +77,7 @@
"prettier": "2.8.8",
"semantic-release": "19.0.5",
"semantic-release-slack-bot": "3.5.3",
"tap": "15.2.3"
"tap": "15.2.3",
"typescript": "5.5.4"
}
}
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@eik/typescript-config/module.json",
"include": ["./classes/**/*.js"],
"compilerOptions": {
"outDir": "types"
}
}
4 changes: 4 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@eik/typescript-config/test.json",
"include": ["./test/**/*.js"]
}
4 changes: 2 additions & 2 deletions utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import getCWD from './get-cwd.js';
import typeSlug from './type-slug.js';
import typeTitle from './type-title.js';

const { getDefaults, files } = helpers;
const { getDefaults } = helpers;

export { logger, getDefaults, getCWD, files, typeSlug, typeTitle };
export { logger, getDefaults, getCWD, typeSlug, typeTitle };
2 changes: 1 addition & 1 deletion utils/json/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { join, isAbsolute } from 'path';
* @param {string|{filename:string,cwd:string}} location - Path string or object describing location for where to write JSON to.
* If location is a string it can be relative or absolute.
* If location is an object, `pathname` must be given which can be relative or absolute. `cwd` can also be given to define the current working directory.
* @return {Promise<any{}>} - JavaScript object deserialized from JSON file contents
* @return {Promise<unknown>} - JavaScript object deserialized from JSON file contents
*
* @example json.read('/path/to/file.json');
* @example json.read('./relative/path/to/file.json');
Expand Down
2 changes: 1 addition & 1 deletion utils/json/write-eik.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { join } from 'path';
export default async (data = {}, options) => {
const { cwd = process.cwd(), filename = 'eik.json' } = options;
const eikpath = join(cwd, filename);
const eik = await fs.readFile(eikpath);
const eik = await fs.readFile(eikpath, 'utf-8');
const eikjson = JSON.parse(eik);

await fs.writeFile(
Expand Down

0 comments on commit 96d6079

Please sign in to comment.